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

SelectColumnsVMatrix.h

Go to the documentation of this file.
00001 // -*- C++ -*- 00002 00003 // PLearn (A C++ Machine Learning Library) 00004 // Copyright (C) 1998 Pascal Vincent 00005 // Copyright (C) 1999-2001 Pascal Vincent, Yoshua Bengio, Rejean Ducharme and University of Montreal 00006 // Copyright (C) 2002 Pascal Vincent, Julien Keable, Xavier Saint-Mleux 00007 // Copyright (C) 2003 Olivier Delalleau 00008 // 00009 // Redistribution and use in source and binary forms, with or without 00010 // modification, are permitted provided that the following conditions are met: 00011 // 00012 // 1. Redistributions of source code must retain the above copyright 00013 // notice, this list of conditions and the following disclaimer. 00014 // 00015 // 2. Redistributions in binary form must reproduce the above copyright 00016 // notice, this list of conditions and the following disclaimer in the 00017 // documentation and/or other materials provided with the distribution. 00018 // 00019 // 3. The name of the authors may not be used to endorse or promote 00020 // products derived from this software without specific prior written 00021 // permission. 00022 // 00023 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 00024 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00025 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00026 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00028 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00029 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00030 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00031 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00032 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 // 00034 // This file is part of the PLearn library. For more information on the PLearn 00035 // library, go to the PLearn Web site at www.plearn.org 00036 00037 00038 /* ******************************************************* 00039 * $Id: SelectColumnsVMatrix.h,v 1.12 2004/08/09 16:23:52 tihocan Exp $ 00040 ******************************************************* */ 00041 00042 00045 #ifndef SelectColumnsVMatrix_INC 00046 #define SelectColumnsVMatrix_INC 00047 00048 #include "SourceVMatrix.h" 00049 00050 namespace PLearn { 00051 using namespace std; 00052 00056 class SelectColumnsVMatrix: public SourceVMatrix 00057 { 00058 00059 private: 00060 00061 typedef SourceVMatrix inherited; 00062 00063 public: 00064 00066 TVec<int> indices; 00067 TVec<string> fields; 00068 00069 public: 00070 00072 SelectColumnsVMatrix(); 00073 00076 SelectColumnsVMatrix(VMat the_source, TVec<string> the_fields); 00077 00080 SelectColumnsVMatrix(VMat the_source, TVec<int> the_indices); 00081 00083 SelectColumnsVMatrix(VMat the_source, Vec the_indices); 00084 00085 PLEARN_DECLARE_OBJECT(SelectColumnsVMatrix); 00086 00087 virtual void build(); 00088 virtual void makeDeepCopyFromShallowCopy(map<const void*, void*>& copies); 00089 00090 protected: 00091 00092 static void declareOptions(OptionList &ol); 00093 void getNewRow(int i, const Vec& v) const { getSubRow(i, 0, v); } 00094 00095 public: 00096 00097 virtual real get(int i, int j) const; 00098 virtual void getSubRow(int i, int j, Vec v) const; 00099 virtual void reset_dimensions() 00100 { 00101 source->reset_dimensions(); length_=source->length(); 00102 for (int i=0;indices.length();i++) 00103 if (indices[i]>=source->width()) 00104 PLERROR("SelectColumnsVMatrix::reset_dimensions, underlying source not wide enough (%d>=%d)", 00105 indices[i],source->width()); 00106 } 00107 00108 virtual const map<string,real>& getStringToRealMapping(int col) const; 00109 virtual const map<real,string>& getRealToStringMapping(int col) const; 00110 00111 virtual real getStringVal(int col, const string & str) const; 00112 virtual string getValString(int col, real val) const; 00113 00114 private: 00115 void build_(); 00116 00117 }; 00118 00119 DECLARE_OBJECT_PTR(SelectColumnsVMatrix); 00120 00121 } // end of namespcae PLearn 00122 #endif

Generated on Tue Aug 17 16:04:47 2004 for PLearn by doxygen 1.3.7