PLearn 0.1
|
#include <KernelVMatrix.h>
Public Member Functions | |
KernelVMatrix () | |
KernelVMatrix (VMat the_source1, VMat the_source2, Ker the_ker) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual KernelVMatrix * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Simply calls inherited::build() then build_(). | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be. | |
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). | |
Static Public Member Functions | |
static string | _classname_ () |
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 | source1 |
KernelVMatrix() : source1(), source2(), ker(), input1(), input2() {}. | |
VMat | source2 |
Ker | ker |
Vec | input1 |
Vec | input2 |
Private Types | |
typedef VMatrix | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
***************** KernelVMatrix *
This VMat is built from 2 other (possibly identical) VMats and a Kernel K. The resulting VMat takes every sample (x_i,y_i)
Definition at line 63 of file KernelVMatrix.h.
typedef VMatrix PLearn::KernelVMatrix::inherited [private] |
Reimplemented from PLearn::VMatrix.
Definition at line 65 of file KernelVMatrix.h.
PLearn::KernelVMatrix::KernelVMatrix | ( | ) |
Definition at line 63 of file KernelVMatrix.cc.
{ }
string PLearn::KernelVMatrix::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Definition at line 61 of file KernelVMatrix.cc.
OptionList & PLearn::KernelVMatrix::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Definition at line 61 of file KernelVMatrix.cc.
RemoteMethodMap & PLearn::KernelVMatrix::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Definition at line 61 of file KernelVMatrix.cc.
Reimplemented from PLearn::VMatrix.
Definition at line 61 of file KernelVMatrix.cc.
Object * PLearn::KernelVMatrix::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 61 of file KernelVMatrix.cc.
StaticInitializer KernelVMatrix::_static_initializer_ & PLearn::KernelVMatrix::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Definition at line 61 of file KernelVMatrix.cc.
void PLearn::KernelVMatrix::build | ( | ) | [virtual] |
Simply calls inherited::build() then build_().
Reimplemented from PLearn::VMatrix.
Definition at line 74 of file KernelVMatrix.cc.
References PLearn::VMatrix::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::KernelVMatrix::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::VMatrix.
Definition at line 81 of file KernelVMatrix.cc.
References input1, input2, ker, PLearn::TVec< T >::resize(), source1, source2, PLearn::VMatrix::updateMtime(), and PLearn::VMat::width().
Referenced by build().
{ if (source1) input1.resize(source1->width()); if (source2) input2.resize(source2->width()); updateMtime(source1); updateMtime(source2); updateMtime(ker.getData()); }
string PLearn::KernelVMatrix::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 61 of file KernelVMatrix.cc.
void PLearn::KernelVMatrix::declareOptions | ( | OptionList & | ol | ) | [static] |
Declare this class' options.
Reimplemented from PLearn::VMatrix.
Definition at line 93 of file KernelVMatrix.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::VMatrix::declareOptions(), ker, source1, and source2.
{ declareOption(ol, "source1", &KernelVMatrix::source1, OptionBase::buildoption, ""); declareOption(ol, "source2", &KernelVMatrix::source2, OptionBase::buildoption, ""); declareOption(ol, "ker", &KernelVMatrix::ker, OptionBase::buildoption, ""); inherited::declareOptions(ol); }
static const PPath& PLearn::KernelVMatrix::declaringFile | ( | ) | [inline, static] |
KernelVMatrix * PLearn::KernelVMatrix::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::VMatrix.
Definition at line 61 of file KernelVMatrix.cc.
This method must be implemented in all subclasses.
Returns element (i,j).
Implements PLearn::VMatrix.
Definition at line 120 of file KernelVMatrix.cc.
References input1, input2, ker, PLearn::VMatrix::length(), PLERROR, source1, source2, and PLearn::VMatrix::width().
{ #ifdef BOUNDCHECK if(i<0 || i>=length() || j<0 || j>=width()) PLERROR("In KernelVMatrix::get OUT OF BOUNDS"); #endif source1->getRow(i,input1); source2->getRow(j,input2); return ker(input1,input2); }
OptionList & PLearn::KernelVMatrix::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 61 of file KernelVMatrix.cc.
OptionMap & PLearn::KernelVMatrix::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 61 of file KernelVMatrix.cc.
RemoteMethodMap & PLearn::KernelVMatrix::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 61 of file KernelVMatrix.cc.
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 133 of file KernelVMatrix.cc.
References input1, input2, ker, PLearn::VMatrix::length(), PLearn::TVec< T >::length(), PLERROR, source1, source2, and PLearn::VMatrix::width().
{ #ifdef BOUNDCHECK if(i<0 || i>=length() || j<0 || j+v.length()>width()) PLERROR("In KernelVMatrix::getRow OUT OF BOUNDS"); #endif source1->getRow(i,input1); for(int jj=0; jj<v.length(); jj++) { source2->getRow(j+jj,input2); v[jj] = ker(input1,input2); } }
void PLearn::KernelVMatrix::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.
This needs to be overridden by every class that adds "complex" data members to the class, such as Vec
, Mat
, PP<Something>
, etc. Typical implementation:
void CLASS_OF_THIS::makeDeepCopyFromShallowCopy(CopiesMap& copies) { inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(complex_data_member1, copies); deepCopyField(complex_data_member2, copies); ... }
copies | A map used by the deep-copy mechanism to keep track of already-copied objects. |
Reimplemented from PLearn::VMatrix.
Definition at line 109 of file KernelVMatrix.cc.
References PLearn::deepCopyField(), input1, input2, ker, PLearn::VMatrix::makeDeepCopyFromShallowCopy(), source1, and source2.
{ inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(source1, copies); deepCopyField(source2, copies); deepCopyField(ker, copies); deepCopyField(input1, copies); deepCopyField(input2, copies); }
Reimplemented from PLearn::VMatrix.
Definition at line 80 of file KernelVMatrix.h.
Vec PLearn::KernelVMatrix::input1 [protected] |
Definition at line 73 of file KernelVMatrix.h.
Referenced by build_(), get(), getSubRow(), and makeDeepCopyFromShallowCopy().
Vec PLearn::KernelVMatrix::input2 [protected] |
Definition at line 74 of file KernelVMatrix.h.
Referenced by build_(), get(), getSubRow(), and makeDeepCopyFromShallowCopy().
Ker PLearn::KernelVMatrix::ker [protected] |
Definition at line 71 of file KernelVMatrix.h.
Referenced by build_(), declareOptions(), get(), getSubRow(), and makeDeepCopyFromShallowCopy().
VMat PLearn::KernelVMatrix::source1 [protected] |
KernelVMatrix() : source1(), source2(), ker(), input1(), input2() {}.
Definition at line 69 of file KernelVMatrix.h.
Referenced by build_(), declareOptions(), get(), getSubRow(), and makeDeepCopyFromShallowCopy().
VMat PLearn::KernelVMatrix::source2 [protected] |
Definition at line 70 of file KernelVMatrix.h.
Referenced by build_(), declareOptions(), get(), getSubRow(), and makeDeepCopyFromShallowCopy().