PLearn 0.1
|
#include <SelectRowsFileIndexVMatrix.h>
Public Member Functions | |
SelectRowsFileIndexVMatrix () | |
default constructor (for automatic deserialization) | |
SelectRowsFileIndexVMatrix (VMat the_distr, const string &indexfile) | |
Copy the original fieldinfos upon construction. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual SelectRowsFileIndexVMatrix * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Simply calls inherited::build() then build_(). | |
virtual real | get (int i, int j) const |
This method must be implemented in all subclasses. | |
virtual void | getSubRow (int i, int j, Vec v) const |
It is suggested that this method be implemented in subclasses to speed up accesses (default version repeatedly calls get(i,j) which may have a significant overhead). | |
virtual void | getRow (int i, Vec v) const |
These methods do not usually need to be overridden in subclasses (default versions call getSubRow, which should do just fine) | |
virtual real | getStringVal (int col, const string &str) const |
Returns value associated with a string (or MISSING_VALUE if there's no association for this string). | |
virtual string | getValString (int col, real val) const |
Returns the string associated with value val for field# col. | |
virtual string | getString (int row, int col) const |
Returns element as a string, even if value doesn't map to a string, in which case tostring(value) is returned. | |
virtual const map< string, real > & | getStringToRealMapping (int col) const |
Returns the string->real mapping for column 'col'. | |
virtual real | dot (int i1, int i2, int inputsize) const |
Returns the dot product between row i1 and row i2 (considering only the inputsize first elements). | |
virtual real | dot (int i, const Vec &v) const |
Returns the result of the dot product between row i and the given vec (only v.length() first elements of row i are considered). | |
virtual void | reset_dimensions () |
In case the dimensions of an underlying VMat has changed, recompute it. | |
Static Public Member Functions | |
static string | _classname_ () |
SelectRowsFileIndexVMatrix. | |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
static void | declareOptions (OptionList &ol) |
Declare this class' options. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Attributes | |
VMat | distr |
IntVecFile | indices |
string | index_file |
Private Types | |
typedef VMatrix | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
selects samples from a sub-distribution according to given vector of indices that is stored on disk as an IntVecFile
Definition at line 58 of file SelectRowsFileIndexVMatrix.h.
typedef VMatrix PLearn::SelectRowsFileIndexVMatrix::inherited [private] |
Reimplemented from PLearn::VMatrix.
Definition at line 60 of file SelectRowsFileIndexVMatrix.h.
PLearn::SelectRowsFileIndexVMatrix::SelectRowsFileIndexVMatrix | ( | ) |
default constructor (for automatic deserialization)
Definition at line 50 of file SelectRowsFileIndexVMatrix.cc.
{ }
PLearn::SelectRowsFileIndexVMatrix::SelectRowsFileIndexVMatrix | ( | VMat | the_distr, |
const string & | indexfile | ||
) |
Copy the original fieldinfos upon construction.
Definition at line 54 of file SelectRowsFileIndexVMatrix.cc.
References build().
: inherited(0,the_distr->width()), distr(the_distr), indices(indexfile), index_file(indexfile) { build(); }
string PLearn::SelectRowsFileIndexVMatrix::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Definition at line 48 of file SelectRowsFileIndexVMatrix.cc.
OptionList & PLearn::SelectRowsFileIndexVMatrix::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Definition at line 48 of file SelectRowsFileIndexVMatrix.cc.
RemoteMethodMap & PLearn::SelectRowsFileIndexVMatrix::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Definition at line 48 of file SelectRowsFileIndexVMatrix.cc.
Reimplemented from PLearn::VMatrix.
Definition at line 48 of file SelectRowsFileIndexVMatrix.cc.
Object * PLearn::SelectRowsFileIndexVMatrix::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 48 of file SelectRowsFileIndexVMatrix.cc.
StaticInitializer SelectRowsFileIndexVMatrix::_static_initializer_ & PLearn::SelectRowsFileIndexVMatrix::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Definition at line 48 of file SelectRowsFileIndexVMatrix.cc.
void PLearn::SelectRowsFileIndexVMatrix::build | ( | ) | [virtual] |
Simply calls inherited::build() then build_().
Reimplemented from PLearn::VMatrix.
Definition at line 61 of file SelectRowsFileIndexVMatrix.cc.
References PLearn::VMatrix::build(), and build_().
Referenced by SelectRowsFileIndexVMatrix().
{ inherited::build(); build_(); }
void PLearn::SelectRowsFileIndexVMatrix::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::VMatrix.
Definition at line 68 of file SelectRowsFileIndexVMatrix.cc.
References PLearn::VMatrix::defineSizes(), distr, PLearn::VMatrix::fieldinfos, index_file, indices, PLearn::IntVecFile::length(), PLearn::VMatrix::length_, PLearn::IntVecFile::open(), PLearn::VMatrix::updateMtime(), PLearn::VMat::width(), and PLearn::VMatrix::width_.
Referenced by build().
{ if (distr) { updateMtime(distr); fieldinfos = distr->fieldinfos; length_ = indices.length(); if (length_ == -1) { indices.open(index_file); length_ = indices.length(); } width_= distr->width(); defineSizes(distr->inputsize(), distr->targetsize(), distr->weightsize()); } }
string PLearn::SelectRowsFileIndexVMatrix::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 48 of file SelectRowsFileIndexVMatrix.cc.
void PLearn::SelectRowsFileIndexVMatrix::declareOptions | ( | OptionList & | ol | ) | [static] |
Declare this class' options.
Reimplemented from PLearn::VMatrix.
Definition at line 84 of file SelectRowsFileIndexVMatrix.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::VMatrix::declareOptions(), distr, and index_file.
{ declareOption(ol, "distr", &SelectRowsFileIndexVMatrix::distr, OptionBase::buildoption, ""); declareOption(ol, "index_file", &SelectRowsFileIndexVMatrix::index_file, OptionBase::buildoption, ""); inherited::declareOptions(ol); }
static const PPath& PLearn::SelectRowsFileIndexVMatrix::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::VMatrix.
Definition at line 75 of file SelectRowsFileIndexVMatrix.h.
SelectRowsFileIndexVMatrix * PLearn::SelectRowsFileIndexVMatrix::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::VMatrix.
Definition at line 48 of file SelectRowsFileIndexVMatrix.cc.
Returns the result of the dot product between row i and the given vec (only v.length() first elements of row i are considered).
Reimplemented from PLearn::VMatrix.
Definition at line 103 of file SelectRowsFileIndexVMatrix.cc.
Returns the dot product between row i1 and row i2 (considering only the inputsize first elements).
The default version in VMatrix is somewhat inefficient, as it repeatedly calls get(i,j) The default version in RowBufferedVMatrix is a little better as it buffers the 2 Vecs between calls in case one of them is needed again. But the real strength of this method is for specialised and efficient versions in subbclasses. This method is typically used by SmartKernels so that they can compute kernel values between input samples efficiently.
Reimplemented from PLearn::VMatrix.
Definition at line 100 of file SelectRowsFileIndexVMatrix.cc.
This method must be implemented in all subclasses.
Returns element (i,j).
Implements PLearn::VMatrix.
Definition at line 91 of file SelectRowsFileIndexVMatrix.cc.
OptionList & PLearn::SelectRowsFileIndexVMatrix::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 48 of file SelectRowsFileIndexVMatrix.cc.
OptionMap & PLearn::SelectRowsFileIndexVMatrix::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 48 of file SelectRowsFileIndexVMatrix.cc.
RemoteMethodMap & PLearn::SelectRowsFileIndexVMatrix::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 48 of file SelectRowsFileIndexVMatrix.cc.
These methods do not usually need to be overridden in subclasses (default versions call getSubRow, which should do just fine)
Copies row i into v (which must have appropriate length equal to the VMat's width).
Reimplemented from PLearn::VMatrix.
Definition at line 97 of file SelectRowsFileIndexVMatrix.cc.
Returns element as a string, even if value doesn't map to a string, in which case tostring(value) is returned.
Reimplemented from PLearn::VMatrix.
Definition at line 112 of file SelectRowsFileIndexVMatrix.cc.
const map< string, real > & PLearn::SelectRowsFileIndexVMatrix::getStringToRealMapping | ( | int | col | ) | const [virtual] |
Returns the string->real mapping for column 'col'.
Reimplemented from PLearn::VMatrix.
Definition at line 115 of file SelectRowsFileIndexVMatrix.cc.
References distr.
{ return distr->getStringToRealMapping(col);}
real PLearn::SelectRowsFileIndexVMatrix::getStringVal | ( | int | col, |
const string & | str | ||
) | const [virtual] |
Returns value associated with a string (or MISSING_VALUE if there's no association for this string).
Reimplemented from PLearn::VMatrix.
Definition at line 106 of file SelectRowsFileIndexVMatrix.cc.
References distr.
{ return distr->getStringVal(col, str); }
It is suggested that this method be implemented in subclasses to speed up accesses (default version repeatedly calls get(i,j) which may have a significant overhead).
Fills v with the subrow i lying between columns j (inclusive) and j+v.length() (exclusive).
Reimplemented from PLearn::VMatrix.
Definition at line 94 of file SelectRowsFileIndexVMatrix.cc.
References distr, PLearn::VMat::getSubRow(), and indices.
Returns the string associated with value val for field# col.
Or returns "" if no string is associated.
Reimplemented from PLearn::VMatrix.
Definition at line 109 of file SelectRowsFileIndexVMatrix.cc.
References distr.
{ return distr->getValString(col,val); }
virtual void PLearn::SelectRowsFileIndexVMatrix::reset_dimensions | ( | ) | [inline, virtual] |
In case the dimensions of an underlying VMat has changed, recompute it.
Reimplemented from PLearn::VMatrix.
Definition at line 90 of file SelectRowsFileIndexVMatrix.h.
Reimplemented from PLearn::VMatrix.
Definition at line 75 of file SelectRowsFileIndexVMatrix.h.
VMat PLearn::SelectRowsFileIndexVMatrix::distr [protected] |
Definition at line 63 of file SelectRowsFileIndexVMatrix.h.
Referenced by build_(), declareOptions(), dot(), get(), getRow(), getString(), getStringToRealMapping(), getStringVal(), getSubRow(), and getValString().
string PLearn::SelectRowsFileIndexVMatrix::index_file [protected] |
Definition at line 65 of file SelectRowsFileIndexVMatrix.h.
Referenced by build_(), and declareOptions().
Definition at line 64 of file SelectRowsFileIndexVMatrix.h.
Referenced by build_(), dot(), get(), getRow(), getString(), and getSubRow().