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

PLearn::DistanceKernel Class Reference

This class implements an Ln distance (defaults to L2 i.e. euclidean distance). More...

#include <DistanceKernel.h>

Inheritance diagram for PLearn::DistanceKernel:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DistanceKernel (real the_Ln=2)
 PLEARN_DECLARE_OBJECT (DistanceKernel)
virtual string info () const
 returns a bit more informative string about object (default returns classname())

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 void setDataForKernelMatrix (VMat the_data)
 This method precomputes the squared norm for all the data to later speed up evaluate methods, if n == 2.


Public Attributes

bool pow_distance

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

real n
 1 for L1, 2 for L2, etc..

Vec squarednorms
 Used to store the squared norm of the input data.


Private Types

typedef Kernel inherited

Detailed Description

This class implements an Ln distance (defaults to L2 i.e. euclidean distance).

Definition at line 52 of file DistanceKernel.h.


Member Typedef Documentation

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

Reimplemented from PLearn::Kernel.

Definition at line 57 of file DistanceKernel.h.


Constructor & Destructor Documentation

PLearn::DistanceKernel::DistanceKernel real  the_Ln = 2  ) 
 

Definition at line 55 of file DistanceKernel.cc.


Member Function Documentation

void PLearn::DistanceKernel::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 63 of file DistanceKernel.cc.

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

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

returns K(x1,x2)

Implements PLearn::Kernel.

Definition at line 78 of file DistanceKernel.cc.

References PLearn::dist(), n, pow_distance, PLearn::powdistance(), and PLearn::Vec.

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

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

Reimplemented from PLearn::Kernel.

Definition at line 89 of file DistanceKernel.cc.

References n, PLERROR, pow_distance, PLearn::sqrt(), and squarednorms.

virtual string PLearn::DistanceKernel::info  )  const [inline, virtual]
 

returns a bit more informative string about object (default returns classname())

Reimplemented from PLearn::Object.

Definition at line 73 of file DistanceKernel.h.

References n, and PLearn::tostring().

PLearn::DistanceKernel::PLEARN_DECLARE_OBJECT DistanceKernel   ) 
 

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

This method precomputes the squared norm for all the data to later speed up evaluate methods, if n == 2.

Reimplemented from PLearn::Kernel.

Definition at line 119 of file DistanceKernel.cc.

References PLearn::VMat::length(), n, PLearn::TVec< T >::resize(), and squarednorms.

Referenced by PLearn::RemoveDuplicateVMatrix::build_(), and PLearn::KNNVMatrix::build_().


Member Data Documentation

real PLearn::DistanceKernel::n [protected]
 

1 for L1, 2 for L2, etc..

Definition at line 61 of file DistanceKernel.h.

Referenced by evaluate(), evaluate_i_j(), info(), and setDataForKernelMatrix().

bool PLearn::DistanceKernel::pow_distance
 

Definition at line 67 of file DistanceKernel.h.

Referenced by PLearn::RemoveDuplicateVMatrix::build_(), evaluate(), and evaluate_i_j().

Vec PLearn::DistanceKernel::squarednorms [protected]
 

Used to store the squared norm of the input data.

Definition at line 63 of file DistanceKernel.h.

Referenced by evaluate_i_j(), and setDataForKernelMatrix().


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