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

PLearn::PrecomputedKernel Class Reference

A kernel that precomputes the kernel matrix as soon as setDataForKernelMatrix is called. More...

#include <PrecomputedKernel.h>

Inheritance diagram for PLearn::PrecomputedKernel:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

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

 PLEARN_DECLARE_OBJECT (PrecomputedKernel)
virtual void makeDeepCopyFromShallowCopy (map< const void *, void * > &copies)
virtual void setDataForKernelMatrix (VMat the_data)
 This method precomputes and stores all kernel values.

virtual void addDataForKernelMatrix (const Vec &newRow)
virtual real evaluate (const Vec &x1, const Vec &x2) const
 returns K(x1,x2)

virtual real evaluate_i_j (int i, int j) const
 returns evaluate(data(i),data(j))

virtual real evaluate_i_x (int i, const Vec &x, real squared_norm_of_x=-1) const
 returns evaluate(data(i),x)

virtual real evaluate_x_i (const Vec &x, int i, real squared_norm_of_x=-1) const
 returns evaluate(x,data(i))


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

Ker ker
 the real underlying kernel

TVec< VecprecomputedK
 the precomputed kernel matrix


Private Types

typedef Kernel inherited

Private Member Functions

void build_ ()

Detailed Description

A kernel that precomputes the kernel matrix as soon as setDataForKernelMatrix is called.

Definition at line 54 of file PrecomputedKernel.h.


Member Typedef Documentation

typedef Kernel PLearn::PrecomputedKernel::inherited [private]
 

Reimplemented from PLearn::Kernel.

Definition at line 56 of file PrecomputedKernel.h.


Constructor & Destructor Documentation

PLearn::PrecomputedKernel::PrecomputedKernel  )  [inline]
 

Definition at line 70 of file PrecomputedKernel.h.

PLearn::PrecomputedKernel::PrecomputedKernel Ker  the_ker  )  [inline]
 

Definition at line 73 of file PrecomputedKernel.h.

References ker.


Member Function Documentation

virtual void PLearn::PrecomputedKernel::addDataForKernelMatrix const Vec newRow  )  [inline, virtual]
 

This method is meant to be used any time the data matrix is appended a new row by an outer instance (e.g. SequentialKernel). Through this method, the kernel must update any data dependent internal structure. The internal structures should have consistent length with the data matrix, assuming a sequential growing of the vmat.

Reimplemented from PLearn::Kernel.

Definition at line 86 of file PrecomputedKernel.h.

References addDataForKernelMatrix(), and PLERROR.

Referenced by addDataForKernelMatrix().

void PLearn::PrecomputedKernel::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::Kernel.

Definition at line 64 of file PrecomputedKernel.cc.

References build_().

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

This method should be redefined in subclasses and do the actual building of the object according to previously set option fields. Constructors can just set option fields, and then call build_. This method is NOT virtual, and will typically be called only from three places: a constructor, the public virtual build() method, and possibly the public virtual read method (which calls its parent's read). build_() can assume that it's parent's build_ has already been called.

Reimplemented from PLearn::Kernel.

Definition at line 60 of file PrecomputedKernel.cc.

Referenced by build().

void PLearn::PrecomputedKernel::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::Kernel.

Definition at line 150 of file PrecomputedKernel.cc.

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

real PLearn::PrecomputedKernel::evaluate const Vec x1,
const Vec x2
const [virtual]
 

returns K(x1,x2)

Implements PLearn::Kernel.

Definition at line 126 of file PrecomputedKernel.cc.

References ker, and PLearn::Vec.

real PLearn::PrecomputedKernel::evaluate_i_j int  i,
int  j
const [virtual]
 

returns evaluate(data(i),data(j))

Reimplemented from PLearn::Kernel.

Definition at line 130 of file PrecomputedKernel.cc.

References PLearn::TVec< Vec >::isNull(), PLearn::VMat::length(), PLERROR, and precomputedK.

real PLearn::PrecomputedKernel::evaluate_i_x int  i,
const Vec x,
real  squared_norm_of_x = -1
const [virtual]
 

returns evaluate(data(i),x)

Reimplemented from PLearn::Kernel.

Definition at line 143 of file PrecomputedKernel.cc.

References ker, and x.

real PLearn::PrecomputedKernel::evaluate_x_i const Vec x,
int  i,
real  squared_norm_of_x = -1
const [virtual]
 

returns evaluate(x,data(i))

Reimplemented from PLearn::Kernel.

Definition at line 147 of file PrecomputedKernel.cc.

References ker, and x.

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

Definition at line 72 of file PrecomputedKernel.cc.

References PLearn::deepCopyField(), ker, and precomputedK.

PLearn::PrecomputedKernel::PLEARN_DECLARE_OBJECT PrecomputedKernel   ) 
 

void PLearn::PrecomputedKernel::setDataForKernelMatrix VMat  the_data  )  [virtual]
 

This method precomputes and stores all kernel values.

Reimplemented from PLearn::Kernel.

Definition at line 104 of file PrecomputedKernel.cc.

References ker, PLearn::VMat::length(), precomputedK, and PLearn::TVec< Vec >::resize().


Member Data Documentation

Ker PLearn::PrecomputedKernel::ker [protected]
 

the real underlying kernel

Definition at line 59 of file PrecomputedKernel.h.

Referenced by evaluate(), evaluate_i_x(), evaluate_x_i(), makeDeepCopyFromShallowCopy(), PrecomputedKernel(), and setDataForKernelMatrix().

TVec<Vec> PLearn::PrecomputedKernel::precomputedK [protected]
 

the precomputed kernel matrix

Definition at line 60 of file PrecomputedKernel.h.

Referenced by evaluate_i_j(), makeDeepCopyFromShallowCopy(), and setDataForKernelMatrix().


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