PLearn 0.1
|
#include <ConcatRowsSubVMatrix.h>
Public Member Functions | |
ConcatRowsSubVMatrix (bool call_build_=false) | |
default constructor (for automatic deserialization) | |
ConcatRowsSubVMatrix (VMat the_source, TVec< int > &the_start, TVec< int > &the_len, bool call_build_=true) | |
The field names of the parent VMat are copied upon construction. | |
ConcatRowsSubVMatrix (VMat the_source, int start1, int len1, int start2, int len2, bool call_build_=true) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual ConcatRowsSubVMatrix * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Simply calls inherited::build() then build_(). | |
virtual real | get (int i, int j) const |
These methods are implemented by buffering calls to getNewRow. | |
virtual void | getSubRow (int i, int j, Vec v) const |
fills v with the subrow i laying between columns j (inclusive) and j+v.length() (exclusive) | |
virtual void | reset_dimensions () |
In case the dimensions of an underlying VMat has changed, recompute it. | |
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). | |
Static Public Member Functions | |
static string | _classname_ () |
ConcatRowsSubVMatrix. | |
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) |
Declares this class' options. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Member Functions | |
void | getpositions (int i, int &whichvm, int &rowofvm) const |
returns the index of the correct sub-VMat in the array and the the row number in this VMat that correspond to row i in the ConcatRowsVMat | |
Protected Attributes | |
TVec< int > | start |
TVec< int > | len |
Private Types | |
typedef SourceVMatrix | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
This class concatenates several (virtual) subVMatrices of the same source VMatrix. For each sub-vmatrix block, the user specifies the starting row and the number of rows in the source VMatrix. The resulting vmatrix sees first all the rows of the first sub-vmatrix, then all the rows of the 2nd, etc...
Definition at line 61 of file ConcatRowsSubVMatrix.h.
typedef SourceVMatrix PLearn::ConcatRowsSubVMatrix::inherited [private] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 63 of file ConcatRowsSubVMatrix.h.
PLearn::ConcatRowsSubVMatrix::ConcatRowsSubVMatrix | ( | bool | call_build_ = false | ) |
default constructor (for automatic deserialization)
Definition at line 64 of file ConcatRowsSubVMatrix.cc.
References build_().
PLearn::ConcatRowsSubVMatrix::ConcatRowsSubVMatrix | ( | VMat | the_source, |
TVec< int > & | the_start, | ||
TVec< int > & | the_len, | ||
bool | call_build_ = true |
||
) |
The field names of the parent VMat are copied upon construction.
Copy parent field names
Definition at line 71 of file ConcatRowsSubVMatrix.cc.
References build_().
: inherited(the_source, -1, the_source->width(), call_build_), start(the_start), len(the_len) { /* fieldinfos = the_source->getFieldInfos(); check(); */ if( call_build_ ) build_(); }
PLearn::ConcatRowsSubVMatrix::ConcatRowsSubVMatrix | ( | VMat | the_source, |
int | start1, | ||
int | len1, | ||
int | start2, | ||
int | len2, | ||
bool | call_build_ = true |
||
) |
Copy parent field names
Definition at line 88 of file ConcatRowsSubVMatrix.cc.
References build_(), len, and start.
: inherited(the_source, -1, the_source->width(), call_build_), start(2), len(2) { //fieldinfos = the_source->getFieldInfos(); start[0]=start1; start[1]=start2; len[0]=len1; len[1]=len2; //check(); if( call_build_ ) build_(); }
string PLearn::ConcatRowsSubVMatrix::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 62 of file ConcatRowsSubVMatrix.cc.
OptionList & PLearn::ConcatRowsSubVMatrix::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 62 of file ConcatRowsSubVMatrix.cc.
RemoteMethodMap & PLearn::ConcatRowsSubVMatrix::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 62 of file ConcatRowsSubVMatrix.cc.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 62 of file ConcatRowsSubVMatrix.cc.
Object * PLearn::ConcatRowsSubVMatrix::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 62 of file ConcatRowsSubVMatrix.cc.
StaticInitializer ConcatRowsSubVMatrix::_static_initializer_ & PLearn::ConcatRowsSubVMatrix::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 62 of file ConcatRowsSubVMatrix.cc.
void PLearn::ConcatRowsSubVMatrix::build | ( | ) | [virtual] |
Simply calls inherited::build() then build_().
Reimplemented from PLearn::SourceVMatrix.
Definition at line 187 of file ConcatRowsSubVMatrix.cc.
References PLearn::SourceVMatrix::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::ConcatRowsSubVMatrix::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 193 of file ConcatRowsSubVMatrix.cc.
References PLearn::VMatrix::fieldinfos, i, len, PLearn::VMat::length(), PLearn::TVec< T >::length(), PLearn::VMatrix::length_, PLERROR, PLearn::VMatrix::setMetaInfoFrom(), PLearn::SourceVMatrix::source, and start.
Referenced by build(), and ConcatRowsSubVMatrix().
{ if (source) { fieldinfos = source->getFieldInfos(); setMetaInfoFrom(source); length_=0; for (int i = 0; i < start.length(); i++) { if (start[i]<0 || start[i]+len[i]>source->length()) PLERROR("ConcatRowsSubVMatrix: out-of-range specs for submat" " %d,\n" "start=%d, len=%d, underlying distr length=%d\n", i, start[i], len[i], source->length()); length_ += len[i]; } } }
string PLearn::ConcatRowsSubVMatrix::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 62 of file ConcatRowsSubVMatrix.cc.
void PLearn::ConcatRowsSubVMatrix::declareOptions | ( | OptionList & | ol | ) | [static] |
Declares this class' options.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 170 of file ConcatRowsSubVMatrix.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::SourceVMatrix::declareOptions(), PLearn::OptionBase::learntoption, len, PLearn::OptionBase::nosave, PLearn::SourceVMatrix::source, and start.
{ declareOption(ol, "distr", &ConcatRowsSubVMatrix::source, (OptionBase::learntoption | OptionBase::nosave), "DEPRECATED - Use 'source' instead"); declareOption(ol, "start", &ConcatRowsSubVMatrix::start, OptionBase::buildoption, ""); declareOption(ol, "len", &ConcatRowsSubVMatrix::len, OptionBase::buildoption, ""); inherited::declareOptions(ol); }
static const PPath& PLearn::ConcatRowsSubVMatrix::declaringFile | ( | ) | [inline, static] |
ConcatRowsSubVMatrix * PLearn::ConcatRowsSubVMatrix::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 62 of file ConcatRowsSubVMatrix.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::RowBufferedVMatrix.
Definition at line 154 of file ConcatRowsSubVMatrix.cc.
References getpositions(), PLearn::SourceVMatrix::source, and start.
{ int whichvm1, rowofvm1; getpositions(i1,whichvm1,rowofvm1); int whichvm2, rowofvm2; getpositions(i2,whichvm2,rowofvm2); return source->dot(start[whichvm1]+rowofvm1, start[whichvm2]+rowofvm2, inputsize); }
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::RowBufferedVMatrix.
Definition at line 163 of file ConcatRowsSubVMatrix.cc.
References getpositions(), PLearn::SourceVMatrix::source, and start.
{ int whichvm, rowofvm; getpositions(i,whichvm,rowofvm); return source->dot(start[whichvm]+rowofvm,v); }
These methods are implemented by buffering calls to getNewRow.
returns element (i,j)
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 140 of file ConcatRowsSubVMatrix.cc.
References getpositions(), PLearn::SourceVMatrix::source, and start.
{ int whichvm, rowofvm; getpositions(i,whichvm,rowofvm); return source->get(start[whichvm]+rowofvm,j); }
OptionList & PLearn::ConcatRowsSubVMatrix::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 62 of file ConcatRowsSubVMatrix.cc.
OptionMap & PLearn::ConcatRowsSubVMatrix::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 62 of file ConcatRowsSubVMatrix.cc.
void PLearn::ConcatRowsSubVMatrix::getpositions | ( | int | i, |
int & | whichvm, | ||
int & | rowofvm | ||
) | const [protected] |
returns the index of the correct sub-VMat in the array and the the row number in this VMat that correspond to row i in the ConcatRowsVMat
Definition at line 121 of file ConcatRowsSubVMatrix.cc.
References len, PLearn::VMatrix::length(), and PLERROR.
Referenced by dot(), get(), and getSubRow().
{ #ifdef BOUNDCHECK if(i<0 || i>=length()) PLERROR("In ConcatRowsSubVMatrix::getpositions OUT OF BOUNDS"); #endif int pos = 0; int k=0; while(i>=pos+len[k]) { pos += len[k]; k++; } whichvm = k; rowofvm = i-pos; }
RemoteMethodMap & PLearn::ConcatRowsSubVMatrix::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 62 of file ConcatRowsSubVMatrix.cc.
fills v with the subrow i laying between columns j (inclusive) and j+v.length() (exclusive)
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 147 of file ConcatRowsSubVMatrix.cc.
References getpositions(), PLearn::VMat::getSubRow(), PLearn::SourceVMatrix::source, and start.
{ int whichvm, rowofvm; getpositions(i,whichvm,rowofvm); source->getSubRow(start[whichvm]+rowofvm, j, v); }
virtual void PLearn::ConcatRowsSubVMatrix::reset_dimensions | ( | ) | [inline, virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 95 of file ConcatRowsSubVMatrix.h.
TVec<int> PLearn::ConcatRowsSubVMatrix::len [protected] |
Definition at line 69 of file ConcatRowsSubVMatrix.h.
Referenced by build_(), ConcatRowsSubVMatrix(), declareOptions(), and getpositions().
TVec<int> PLearn::ConcatRowsSubVMatrix::start [protected] |
Definition at line 68 of file ConcatRowsSubVMatrix.h.
Referenced by build_(), ConcatRowsSubVMatrix(), declareOptions(), dot(), get(), and getSubRow().