Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

JulianizeVMatrix.h

Go to the documentation of this file.
00001 00002 // -*- C++ -*- 00003 00004 // JulianizeVMatrix.h 00005 // 00006 // Copyright (C) 2003 Nicolas Chapados 00007 // 00008 // Redistribution and use in source and binary forms, with or without 00009 // modification, are permitted provided that the following conditions are met: 00010 // 00011 // 1. Redistributions of source code must retain the above copyright 00012 // notice, this list of conditions and the following disclaimer. 00013 // 00014 // 2. Redistributions in binary form must reproduce the above copyright 00015 // notice, this list of conditions and the following disclaimer in the 00016 // documentation and/or other materials provided with the distribution. 00017 // 00018 // 3. The name of the authors may not be used to endorse or promote 00019 // products derived from this software without specific prior written 00020 // permission. 00021 // 00022 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 00023 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00024 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00025 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00026 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00027 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00028 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00029 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00030 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00031 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 // 00033 // This file is part of the PLearn library. For more information on the PLearn 00034 // library, go to the PLearn Web site at www.plearn.org 00035 00036 /* ******************************************************* 00037 * $Id: JulianizeVMatrix.h,v 1.10 2004/07/09 19:42:23 tihocan Exp $ 00038 ******************************************************* */ 00039 00041 #ifndef JulianizeVMatrix_INC 00042 #define JulianizeVMatrix_INC 00043 00044 #include <utility> 00045 #include <vector> 00046 #include <algorithm> 00047 00048 #include "RowBufferedVMatrix.h" 00049 #include "VMat.h" 00050 00051 namespace PLearn { 00052 using namespace std; 00053 00068 class JulianizeVMatrix : public RowBufferedVMatrix 00069 { 00070 typedef RowBufferedVMatrix inherited; 00071 00072 public: 00075 enum DateCode { 00076 Date = 0, 00077 DateTime = 1 00078 }; 00079 00081 static int dateCodeWidth(DateCode dc) { 00082 switch(dc) { 00083 case Date: return 3; 00084 case DateTime: return 6; 00085 } 00086 PLERROR("JulianizeVMatrix::dateCodeWidth: unknown date code"); 00087 return 0; 00088 } 00089 00090 protected: 00091 VMat underlying_; 00092 vector< pair<int,DateCode> > cols_codes_; 00093 mutable Vec und_row_; 00094 00095 public: 00096 00097 00098 // ************************ 00099 // * public build options * 00100 // ************************ 00101 00102 // ### declare public option fields (such as build options) here 00103 // ... 00104 00105 // **************** 00106 // * Constructors * 00107 // **************** 00108 00111 JulianizeVMatrix(); 00112 00115 JulianizeVMatrix(VMat underlying, 00116 DateCode date_code = Date, 00117 int starting_column = 0); 00118 00119 // ****************** 00120 // * Object methods * 00121 // ****************** 00122 00123 private: 00125 void build_(); 00126 00127 protected: 00129 static void declareOptions(OptionList& ol); 00130 00132 virtual void getNewRow(int i, const Vec& v) const; 00133 00134 public: 00135 00136 // simply calls inherited::build() then build_() 00137 virtual void build(); 00138 00140 virtual void makeDeepCopyFromShallowCopy(map<const void*, void*>& copies); 00141 00143 PLEARN_DECLARE_OBJECT(JulianizeVMatrix); 00144 00145 protected: 00146 // Return the new number of columns 00147 static int newWidth(VMat und, DateCode dc) { 00148 return und->width() - dateCodeWidth(dc) + 1; 00149 } 00150 00151 // Set the VMFields in this VMatrix from the underlying field names. All 00152 // "date" fields are named "Date", and "date-time" are named "DateTime". 00153 void setVMFields(); 00154 }; 00155 00156 DECLARE_OBJECT_PTR(JulianizeVMatrix); 00157 00158 } // end of namespace PLearn 00159 #endif

Generated on Tue Aug 17 15:56:14 2004 for PLearn by doxygen 1.3.7