PLearn 0.1
ForwardVMatrix.h
Go to the documentation of this file.
00001 // ForwardVMatrix.h
00002 // Copyright (C) 2002 Pascal Vincent
00003 //
00004 
00005 // Redistribution and use in source and binary forms, with or without
00006 // modification, are permitted provided that the following conditions are met:
00007 //
00008 //  1. Redistributions of source code must retain the above copyright
00009 //     notice, this list of conditions and the following disclaimer.
00010 //
00011 //  2. Redistributions in binary form must reproduce the above copyright
00012 //     notice, this list of conditions and the following disclaimer in the
00013 //     documentation and/or other materials provided with the distribution.
00014 //
00015 //  3. The name of the authors may not be used to endorse or promote
00016 //     products derived from this software without specific prior written
00017 //     permission.
00018 //
00019 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
00020 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00021 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
00022 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00024 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00025 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00026 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00027 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00028 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // This file is part of the PLearn library. For more information on the PLearn
00031 // library, go to the PLearn Web site at www.plearn.org
00032 
00033 
00034 
00035 
00036 /* *******************************************************
00037  * $Id: ForwardVMatrix.h 8239 2007-11-09 15:35:34Z nouiz $
00038  * This file is part of the PLearn library.
00039  ******************************************************* */
00040 
00041 
00044 #ifndef ForwardVMatrix_INC
00045 #define ForwardVMatrix_INC
00046 
00047 #include "VMat.h"
00048 
00049 namespace PLearn {
00050 using namespace std;
00051 
00052 class ForwardVMatrix: public VMatrix
00053 {
00054     typedef VMatrix inherited;
00055 
00056 protected:
00057     VMat vm; // the underlying vmatrix to which all calls will be forwarded
00058 
00059 public:
00060 
00061     ForwardVMatrix();
00062     ForwardVMatrix(VMat vm);
00063 
00064     PLEARN_DECLARE_OBJECT(ForwardVMatrix);
00065     static void declareOptions(OptionList &ol);
00066 
00067     virtual void build();
00068 
00070     void setVMat(VMat the_vm);
00071 
00074     virtual string getValString(int col, real val) const;
00075 
00077     virtual real getStringVal(int col, const string & str) const;
00078 
00080     virtual string getString(int row,int col) const;
00081 
00083     map<string,real> getStringMapping(int col) const;
00084 
00085     // Overridden from VMatrix.h to forward to the underlying VMat.
00086     virtual const map<string,real>& getStringToRealMapping(int col) const;
00087     virtual const map<real,string>& getRealToStringMapping(int col) const;
00088 
00089     virtual void computeStats();
00090 
00091     // default version calls savePMAT
00092     virtual void save(const PPath& filename) const;
00093 
00094     virtual void savePMAT(const PPath& pmatfile) const;
00095     virtual void saveDMAT(const PPath& dmatdir) const;
00096     virtual void saveAMAT(const PPath& amatfile, bool verbose = true,
00097                           bool no_header = false, bool save_strings = false) const;
00098 
00100     virtual real get(int i, int j) const; 
00101 
00103     virtual void put(int i, int j, real value); 
00104 
00107     virtual void getSubRow(int i, int j, Vec v) const; 
00108 
00113     virtual void putSubRow(int i, int j, Vec v);
00114 
00116     virtual void appendRow(Vec v);
00117 
00120     virtual void getRow(int i, Vec v) const; 
00121     virtual void putRow(int i, Vec v);
00122     virtual void fill(real value);
00123     virtual void getMat(int i, int j, Mat m) const; 
00124     virtual void putMat(int i, int j, Mat m); 
00125 
00127     virtual void getColumn(int i, Vec v) const;
00128 
00137     virtual Mat toMat() const;
00138 
00141     virtual void compacify();
00142 
00144     virtual void reset_dimensions();
00145 
00150     virtual VMat subMat(int i, int j, int l, int w);
00151 
00158     virtual real dot(int i1, int i2, int inputsize) const;
00159 
00161     virtual real dot(int i, const Vec& v) const;
00162 
00163     void makeDeepCopyFromShallowCopy(CopiesMap& copies);
00164 
00165 
00170     virtual void accumulateXtY(int X_startcol, int X_ncols, int Y_startcol, int Y_ncols,
00171                                Mat& result, int startrow=0, int nrows=-1, int ignore_this_row=-1) const;
00172 
00173 
00178     virtual void accumulateXtX(int X_startcol, int X_ncols,
00179                                Mat& result, int startrow=0, int nrows=-1, int ignore_this_row=-1) const;
00180 
00181 
00182 private:
00183     void build_();
00184 };
00185 
00186 DECLARE_OBJECT_PTR(ForwardVMatrix);
00187 
00188 } // end of namespace PLearn
00189 
00190 #endif
00191 
00192 
00193 /*
00194   Local Variables:
00195   mode:c++
00196   c-basic-offset:4
00197   c-file-style:"stroustrup"
00198   c-file-offsets:((innamespace . 0)(inline-open . 0))
00199   indent-tabs-mode:nil
00200   fill-column:79
00201   End:
00202 */
00203 // 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