PLearn 0.1
ConcatColumnsVMatrix.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 //
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 /* *******************************************************
00038  * $Id: ConcatColumnsVMatrix.h 8239 2007-11-09 15:35:34Z nouiz $
00039  ******************************************************* */
00040 
00041 
00044 #ifndef ConcatColumnsVMatrix_INC
00045 #define ConcatColumnsVMatrix_INC
00046 
00047 #include "RowBufferedVMatrix.h"
00048 #include "VMat.h"
00049 
00050 namespace PLearn {
00051 using namespace std;
00052 
00053 
00054 class ConcatColumnsVMatrix: public RowBufferedVMatrix
00055 {
00056     typedef RowBufferedVMatrix inherited;
00057 
00058 protected:
00059     // Array<VMat> array;
00060     TVec<VMat> sources;
00061 
00062 public:
00063 
00064     bool no_duplicate_fieldnames;
00065 
00068     ConcatColumnsVMatrix(TVec<VMat> the_sources = TVec<VMat>());
00069     ConcatColumnsVMatrix(VMat d1, VMat d2);
00070 
00071 protected:
00072 
00073     static void declareOptions(OptionList &ol);
00074     virtual void getNewRow(int i, const Vec& samplevec) const;
00075 
00076 public:
00077 
00078     virtual real getStringVal(int col, const string & str) const;
00080     const map<string,real>& getStringMapping(int col) const;
00081     virtual string getValString(int col, real val) const;
00082     virtual string getString(int row,int col) const;
00083     virtual void reset_dimensions()
00084     { PLERROR("ConcatColumnsVMatrix::reset_dimensions() not implemented"); }
00085 
00086     virtual real dot(int i1, int i2, int inputsize) const;
00087     virtual real dot(int i, const Vec& v) const;
00088 
00089     PLEARN_DECLARE_OBJECT(ConcatColumnsVMatrix);
00090     virtual void build();
00091 
00093     virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies);
00094 
00097     virtual PP<Dictionary> getDictionary(int col) const;
00098 
00100     virtual void getValues(int row, int col, Vec& values) const;
00101 
00103     virtual void getValues(const Vec& input, int col, Vec& values) const;
00104 
00106     virtual void put(int i, int j, real value);
00107 
00108 private:
00109     void build_();
00110 
00111 };
00112 
00113 DECLARE_OBJECT_PTR(ConcatColumnsVMatrix);
00114 
00115 inline VMat hconcat(VMat d1, VMat d2)
00116 { return new ConcatColumnsVMatrix(d1,d2); }
00117 
00118 inline VMat hconcat(TVec<VMat> ds)
00119 { return new ConcatColumnsVMatrix(ds); }
00120 
00121 
00122 } // end of namespace PLearn
00123 #endif
00124 
00125 
00126 /*
00127   Local Variables:
00128   mode:c++
00129   c-basic-offset:4
00130   c-file-style:"stroustrup"
00131   c-file-offsets:((innamespace . 0)(inline-open . 0))
00132   indent-tabs-mode:nil
00133   fill-column:79
00134   End:
00135 */
00136 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines