PLearn 0.1
NetflixVMatrix.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // NetflixVMatrix.h
00004 //
00005 // Copyright (C) 2006 Pierre-Antoine Manzagol
00006 //
00007 // Redistribution and use in source and binary forms, with or without
00008 // modification, are permitted provided that the following conditions are met:
00009 //
00010 //  1. Redistributions of source code must retain the above copyright
00011 //     notice, this list of conditions and the following disclaimer.
00012 //
00013 //  2. Redistributions in binary form must reproduce the above copyright
00014 //     notice, this list of conditions and the following disclaimer in the
00015 //     documentation and/or other materials provided with the distribution.
00016 //
00017 //  3. The name of the authors may not be used to endorse or promote
00018 //     products derived from this software without specific prior written
00019 //     permission.
00020 //
00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00023 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
00024 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00025 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00026 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00027 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00028 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00029 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 //
00032 // This file is part of the PLearn library. For more information on the PLearn
00033 // library, go to the PLearn Web site at www.plearn.org
00034 
00035 // Authors: Pierre-Antoine Manzagol
00036 
00040 #ifndef NetflixVMatrix_INC
00041 #define NetflixVMatrix_INC
00042 
00043 #include <plearn/vmat/VMat.h>
00044 
00045 // **********************************************************
00046 // **                    W A R N I N G                     **
00047 // **********************************************************
00048 // **   MOST NEW VMatrix SUBCLASSES SHOULD BE WRITTEN AS   **
00049 // **   SUBCLASSES OF RowBufferedVMatrix INSTEAD.          **
00050 // **   Make sure your REALLY want to subclass VMatrix!!!  **
00051 // **********************************************************
00052 
00053 namespace PLearn {
00054 
00065 class NetflixVMatrix : public VMatrix
00066 {
00067     typedef VMatrix inherited;
00068 
00069 public:
00070     //#####  Public Build Options  ############################################
00071 
00074 
00075     string sourceFileName;
00076     TVec< TVec< int > > data;
00077 
00078 public:
00079     //#####  Public Member Functions  #########################################
00080 
00082     // ### Make sure the implementation in the .cc
00083     // ### initializes all fields to reasonable default values.
00084     NetflixVMatrix();
00085 
00086 
00087     //#####  VMatrix Member Functions  ########################################
00088 
00090     //  (Please implement in .cc)
00091     virtual real get(int i, int j) const;
00092 
00099     virtual void getExample(int i, Vec& input, Vec& target, real& weight);
00100 
00103     //  (Please implement in .cc)
00104     //  (default version repeatedly calls get(i,j) which may have a significant overhead)
00105     //virtual void getSubRow(int i, int j, Vec v) const;
00106 
00107     //virtual void getRow(int i, Vec v) const;
00108 
00109     // ** The methods can be optionally implemented
00110     // ** (their default implementation throws an error)
00111 
00113     // virtual void reset_dimensions();
00114 
00115     // ** for writable VMatrices
00116 
00118     // virtual void put(int i, int j, real value);
00119 
00122     // virtual void putSubRow(int i, int j, Vec v);
00123 
00125     // virtual void putMat(int i, int j, Mat m);
00126 
00128     // virtual void appendRow(Vec v);
00129 
00131     // virtual void fill(real value);
00132 
00135     // virtual void flush();
00136 
00138     // void putOrAppendRow(int i, Vec v);
00139 
00143     // void forcePutRow(int i, Vec v);
00144 
00145     // ** Some other VMatrix methods, that can be redefined if a more
00146     // ** efficient implementation is possible with
00147     // ** this particular subclass.
00148     //
00149 
00153     // virtual VMat subMat(int i, int j, int l, int w);
00154 
00157     // virtual void getMat(int i, int j, Mat m) const;
00158 
00161     // virtual void getColumn(int i, Vec v) const;
00162 
00173     // virtual Mat toMat() const;
00174 
00178     // virtual void compacify();
00179 
00190     // virtual real dot(int i1, int i2, int inputsize) const;
00191 
00194     // virtual real dot(int i, const Vec& v) const;
00195 
00196 
00197     //#####  PLearn::Object Protocol  #########################################
00198 
00199     // Declares other standard object methods.
00200     // ### If your class is not instantiatable (it has pure virtual methods)
00201     // ### you should replace this by PLEARN_DECLARE_ABSTRACT_OBJECT_METHODS
00202     PLEARN_DECLARE_OBJECT(NetflixVMatrix);
00203 
00204     // Simply calls inherited::build() then build_()
00205     virtual void build();
00206 
00208     // (PLEASE IMPLEMENT IN .cc)
00209     virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies);
00210 
00211 protected:
00212     //#####  Protected Options  ###############################################
00213 
00214     // ### Declare protected option fields (such as learned parameters) here
00215     // ...
00216 
00217 protected:
00218     //#####  Protected Member Functions  ######################################
00219 
00221     // (PLEASE IMPLEMENT IN .cc)
00222     static void declareOptions(OptionList& ol);
00223 
00224 private:
00225     //#####  Private Member Functions  ########################################
00226 
00228     // (PLEASE IMPLEMENT IN .cc)
00229     void build_();
00230 
00231 private:
00232     //#####  Private Data Members  ############################################
00233 
00234     // The rest of the private stuff goes here
00235 };
00236 
00237 // Declares a few other classes and functions related to this class
00238 DECLARE_OBJECT_PTR(NetflixVMatrix);
00239 
00240 } // end of namespace PLearn
00241 
00242 #endif
00243 
00244 
00245 /*
00246   Local Variables:
00247   mode:c++
00248   c-basic-offset:4
00249   c-file-style:"stroustrup"
00250   c-file-offsets:((innamespace . 0)(inline-open . 0))
00251   indent-tabs-mode:nil
00252   fill-column:79
00253   End:
00254 */
00255 // 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