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

PLearn::FileVMatrix Class Reference

A VMatrix that exists in a .pmat file (native plearn matrix format, same as for Mat). More...

#include <FileVMatrix.h>

Inheritance diagram for PLearn::FileVMatrix:

Inheritance graph
[legend]
Collaboration diagram for PLearn::FileVMatrix:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FileVMatrix ()
 FileVMatrix (const string &filename, bool writable_=false)
 opens an existing file

 FileVMatrix (const string &filename, int the_length, int the_width)
 create a new matrix file

 FileVMatrix (const string &filename, int the_length, const TVec< string > &fieldnames)
 create a new matrix file

virtual void updateHeader ()
 Re-write the header with all current field values.

virtual void put (int i, int j, real value)
 sets element (i,j) to value

virtual void putSubRow (int i, int j, Vec v)
virtual void appendRow (Vec v)
 This method must be implemented for matrices that are allowed to grow.

virtual void flush ()
 For matrices stored on disk, this should flush all pending buffered write operations.

virtual void build ()
 Should call simply inherited::build(), then this class's build_().

 PLEARN_DECLARE_OBJECT (FileVMatrix)
virtual void makeDeepCopyFromShallowCopy (map< const void *, void * > &copies)
 Transform a shallow copy into a deep copy.

virtual ~FileVMatrix ()

Protected Member Functions

virtual void getNewRow (int i, const Vec &v) const
 This is the only method requiring implementation in subclasses.


Static Protected Member Functions

void declareOptions (OptionList &ol)
 redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down)


Protected Attributes

string filename_
FILE * f
bool file_is_bigendian
bool file_is_float

Private Types

typedef RowBufferedVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.


Private Attributes

bool build_new_file

Detailed Description

A VMatrix that exists in a .pmat file (native plearn matrix format, same as for Mat).

Definition at line 54 of file FileVMatrix.h.


Member Typedef Documentation

typedef RowBufferedVMatrix PLearn::FileVMatrix::inherited [private]
 

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 59 of file FileVMatrix.h.

Referenced by FileVMatrix().


Constructor & Destructor Documentation

PLearn::FileVMatrix::FileVMatrix  ) 
 

Definition at line 55 of file FileVMatrix.cc.

PLearn::FileVMatrix::FileVMatrix const string filename,
bool  writable_ = false
 

opens an existing file

Definition at line 61 of file FileVMatrix.cc.

References PLearn::abspath(), build_(), and PLearn::isfile().

PLearn::FileVMatrix::FileVMatrix const string filename,
int  the_length,
int  the_width
 

create a new matrix file

Definition at line 75 of file FileVMatrix.cc.

References PLearn::abspath(), build_(), and inherited.

PLearn::FileVMatrix::FileVMatrix const string filename,
int  the_length,
const TVec< string > &  fieldnames
 

create a new matrix file

Definition at line 83 of file FileVMatrix.cc.

References PLearn::abspath(), build_(), and PLearn::VMatrix::saveFieldInfos().

PLearn::FileVMatrix::~FileVMatrix  )  [virtual]
 

Definition at line 267 of file FileVMatrix.cc.

References f, and PLearn::VMatrix::saveFieldInfos().


Member Function Documentation

void PLearn::FileVMatrix::appendRow Vec  v  )  [virtual]
 

This method must be implemented for matrices that are allowed to grow.

Reimplemented from PLearn::VMatrix.

Definition at line 330 of file FileVMatrix.cc.

References PLearn::TVec< T >::data(), DATAFILE_HEADERLENGTH, f, file_is_bigendian, file_is_float, PLearn::fwrite_double(), PLearn::fwrite_float(), PLearn::TVec< T >::length(), and updateHeader().

void PLearn::FileVMatrix::build  )  [virtual]
 

Should call simply inherited::build(), then this class's build_().

This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.

Reimplemented from PLearn::VMatrix.

Definition at line 96 of file FileVMatrix.cc.

References build_().

Referenced by makeDeepCopyFromShallowCopy().

void PLearn::FileVMatrix::build_  )  [private]
 

This does the actual building.

Reimplemented from PLearn::VMatrix.

Definition at line 105 of file FileVMatrix.cc.

References build_new_file, DATAFILE_HEADERLENGTH, f, file_is_bigendian, file_is_float, filename_, PLearn::force_mkdir_for_file(), PLearn::VMatrix::getFieldInfos(), header, PLearn::isfile(), PLearn::mtime(), PLERROR, and updateHeader().

Referenced by build(), and FileVMatrix().

void PLearn::FileVMatrix::declareOptions OptionList ol  )  [static, protected]
 

redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down)

ex: static void declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "the size of the input\n it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "the learnt model weights"); inherited::declareOptions(ol); }

Reimplemented from PLearn::VMatrix.

Definition at line 234 of file FileVMatrix.cc.

References PLearn::declareOption(), and PLearn::OptionList.

void PLearn::FileVMatrix::flush  )  [virtual]
 

For matrices stored on disk, this should flush all pending buffered write operations.

Reimplemented from PLearn::VMatrix.

Definition at line 350 of file FileVMatrix.cc.

References f.

void PLearn::FileVMatrix::getNewRow int  i,
const Vec v
const [protected, virtual]
 

This is the only method requiring implementation in subclasses.

Implements PLearn::RowBufferedVMatrix.

Definition at line 279 of file FileVMatrix.cc.

References PLearn::TVec< T >::data(), DATAFILE_HEADERLENGTH, f, file_is_bigendian, file_is_float, PLearn::fread_double(), PLearn::fread_float(), PLearn::TVec< T >::length(), and PLearn::Vec.

void PLearn::FileVMatrix::makeDeepCopyFromShallowCopy map< const void *, void * > &  copies  )  [virtual]
 

Transform a shallow copy into a deep copy.

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 244 of file FileVMatrix.cc.

References build(), f, and PLWARNING.

PLearn::FileVMatrix::PLEARN_DECLARE_OBJECT FileVMatrix   ) 
 

void PLearn::FileVMatrix::put int  i,
int  j,
real  value
[virtual]
 

sets element (i,j) to value

Reimplemented from PLearn::VMatrix.

Definition at line 313 of file FileVMatrix.cc.

References DATAFILE_HEADERLENGTH, f, file_is_bigendian, file_is_float, PLearn::fwrite_double(), and PLearn::fwrite_float().

void PLearn::FileVMatrix::putSubRow int  i,
int  j,
Vec  v
[virtual]
 

It is suggested that this method be implemented in subclasses of writable matrices to speed up accesses (default version repeatedly calls put(i,j,value) which may have a significant overhead)

Reimplemented from PLearn::VMatrix.

Definition at line 296 of file FileVMatrix.cc.

References PLearn::TVec< T >::data(), DATAFILE_HEADERLENGTH, f, file_is_bigendian, file_is_float, PLearn::fwrite_double(), PLearn::fwrite_float(), and PLearn::TVec< T >::length().

void PLearn::FileVMatrix::updateHeader  )  [virtual]
 

Re-write the header with all current field values.

Definition at line 358 of file FileVMatrix.cc.

References DATAFILE_HEADERLENGTH, f, header, and PLearn::strlen().

Referenced by appendRow(), and build_().


Member Data Documentation

bool PLearn::FileVMatrix::build_new_file [private]
 

Definition at line 70 of file FileVMatrix.h.

Referenced by build_().

FILE* PLearn::FileVMatrix::f [protected]
 

Definition at line 64 of file FileVMatrix.h.

Referenced by appendRow(), build_(), flush(), getNewRow(), makeDeepCopyFromShallowCopy(), put(), putSubRow(), updateHeader(), and ~FileVMatrix().

bool PLearn::FileVMatrix::file_is_bigendian [protected]
 

Definition at line 65 of file FileVMatrix.h.

Referenced by appendRow(), build_(), getNewRow(), put(), and putSubRow().

bool PLearn::FileVMatrix::file_is_float [protected]
 

Definition at line 66 of file FileVMatrix.h.

Referenced by appendRow(), build_(), getNewRow(), put(), and putSubRow().

string PLearn::FileVMatrix::filename_ [protected]
 

Definition at line 63 of file FileVMatrix.h.

Referenced by build_().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:26:14 2004 for PLearn by doxygen 1.3.7