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

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,v 1.8 2004/05/14 02:13:41 tihocan Exp $ 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 00054 00055 class ForwardVMatrix: public VMatrix 00056 { 00057 typedef VMatrix inherited; 00058 00059 protected: 00060 VMat vm; // the underlying vmatrix to which all calls will be forwarded 00061 00062 public: 00063 00064 ForwardVMatrix(); 00065 ForwardVMatrix(VMat vm); 00066 00067 PLEARN_DECLARE_OBJECT(ForwardVMatrix); 00068 static void declareOptions(OptionList &ol); 00069 00070 virtual void build(); 00071 00073 void setVMat(VMat the_vm); 00074 00077 virtual string getValString(int col, real val) const; 00078 00080 virtual real getStringVal(int col, const string & str) const; 00081 00083 virtual string getString(int row,int col) const; 00084 00086 map<string,real> getStringMapping(int col) const; 00087 00088 // Overridden from VMatrix.h to forward to the underlying VMat. 00089 virtual const map<string,real>& getStringToRealMapping(int col) const; 00090 virtual const map<real,string>& getRealToStringMapping(int col) const; 00091 00092 virtual void computeStats(); 00093 00094 // default version calls savePMAT 00095 virtual void save(const string& filename) const; 00096 00097 virtual void savePMAT(const string& pmatfile) const; 00098 virtual void saveDMAT(const string& dmatdir) const; 00099 virtual void saveAMAT(const string& amatfile) const; 00100 00102 virtual real get(int i, int j) const; 00103 00105 virtual void put(int i, int j, real value); 00106 00109 virtual void getSubRow(int i, int j, Vec v) const; 00110 00115 virtual void putSubRow(int i, int j, Vec v); 00116 00118 virtual void appendRow(Vec v); 00119 00122 virtual void getRow(int i, Vec v) const; 00123 virtual void putRow(int i, Vec v); 00124 virtual void fill(real value); 00125 virtual void getMat(int i, int j, Mat m) const; 00126 virtual void putMat(int i, int j, Mat m); 00127 00129 virtual void getColumn(int i, Vec v) const; 00130 00139 virtual Mat toMat() const; 00140 00143 virtual void compacify(); 00144 00146 virtual void reset_dimensions(); 00147 00152 virtual VMat subMat(int i, int j, int l, int w); 00153 00160 virtual real dot(int i1, int i2, int inputsize) const; 00161 00163 virtual real dot(int i, const Vec& v) const; 00164 00167 virtual void getRow(int i, VarArray& inputs) const; 00168 00169 virtual void oldwrite(ostream& out) const; 00170 virtual void oldread(istream& in); 00171 00172 void makeDeepCopyFromShallowCopy(map<const void*, void*>& copies); 00173 00174 00185 virtual void evaluateKernel(Ker ker, int v1_startcol, int v1_ncols, 00186 const Vec& v2, const Vec& result, int startrow=0, int nrows=-1) const; 00187 00189 virtual real evaluateKernelSum(Ker ker, int v1_startcol, int v1_ncols, 00190 const Vec& v2, int startrow=0, int nrows=-1, int ignore_this_row=-1) const; 00191 00194 virtual real evaluateKernelWeightedTargetSum(Ker ker, int v1_startcol, int v1_ncols, const Vec& v2, 00195 int t_startcol, int t_ncols, Vec& targetsum, int startrow=0, int nrows=-1, int ignore_this_row=-1) const; 00196 00197 00202 virtual TVec< pair<real,int> > evaluateKernelTopN(int N, Ker ker, int v1_startcol, int v1_ncols, 00203 const Vec& v2, int startrow=0, int nrows=-1, int ignore_this_row=-1) const; 00204 00207 virtual TVec< pair<real,int> > evaluateKernelBottomN(int N, Ker ker, int v1_startcol, int v1_ncols, 00208 const Vec& v2, int startrow=0, int nrows=-1, int ignore_this_row=-1) const; 00209 00210 00215 virtual void accumulateXtY(int X_startcol, int X_ncols, int Y_startcol, int Y_ncols, 00216 Mat& result, int startrow=0, int nrows=-1, int ignore_this_row=-1) const; 00217 00218 00223 virtual void accumulateXtX(int X_startcol, int X_ncols, 00224 Mat& result, int startrow=0, int nrows=-1, int ignore_this_row=-1) const; 00225 00227 virtual void evaluateSumOfFprop(Func f, Vec& output_result, int nsamples=-1); 00228 virtual void evaluateSumOfFbprop(Func f, Vec& output_result, Vec& output_gradient, int nsamples=-1); 00229 00230 private: 00231 void build_(); 00232 }; 00233 00234 DECLARE_OBJECT_PTR(ForwardVMatrix); 00235 00236 } // end of namespace PLearn 00237 00238 #endif 00239

Generated on Tue Aug 17 15:53:24 2004 for PLearn by doxygen 1.3.7