PLearn 0.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | Private Types | Private Member Functions
PLearn::SourceKernel Class Reference

#include <SourceKernel.h>

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

List of all members.

Public Member Functions

 SourceKernel ()
 Default constructor.
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual SourceKerneldeepCopy (CopiesMap &copies) const
virtual real evaluate (const Vec &x1, const Vec &x2) const
 Compute K(x1,x2).
virtual void addDataForKernelMatrix (const Vec &newRow)
 Overridden to forward to source_kernel.
virtual void computeGramMatrix (Mat K) const
 Call evaluate_i_j to fill each of the entries (i,j) of symmetric matrix K.
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
 Return 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)) [default version calls evaluate_i_x if kernel is_symmetric]
virtual void setDataForKernelMatrix (VMat the_data)
 ** Subclasses may override these methods to provide efficient kernel matrix access **
virtual void setParameters (Vec paramvec)
 ** Subclasses may override these methods ** They provide a generic way to set and retrieve kernel parameters
virtual Vec getParameters () const
 default version returns an empty Vec

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 PPathdeclaringFile ()

Public Attributes

Ker source_kernel

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares this class' options.

Private Types

typedef Kernel inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 52 of file SourceKernel.h.


Member Typedef Documentation


Constructor & Destructor Documentation

PLearn::SourceKernel::SourceKernel ( )

Default constructor.

Definition at line 51 of file SourceKernel.cc.

{}

Member Function Documentation

string PLearn::SourceKernel::_classname_ ( ) [static]
OptionList & PLearn::SourceKernel::_getOptionList_ ( ) [static]
RemoteMethodMap & PLearn::SourceKernel::_getRemoteMethodMap_ ( ) [static]
bool PLearn::SourceKernel::_isa_ ( const Object o) [static]
Object * PLearn::SourceKernel::_new_instance_for_typemap_ ( ) [static]
StaticInitializer SourceKernel::_static_initializer_ & PLearn::SourceKernel::_static_initialize_ ( ) [static]
void PLearn::SourceKernel::addDataForKernelMatrix ( const Vec newRow) [virtual]

Overridden to forward to source_kernel.

Reimplemented from PLearn::Kernel.

Definition at line 103 of file SourceKernel.cc.

                                                           {
    // By default, this kernel and its source_kernel share the same data.
    // Therefore, we must be careful not to append 'newRow' twice. This is
    // why we do not call inherited::addDataForKernelMatrix().
    source_kernel->addDataForKernelMatrix(newRow);
}
void PLearn::SourceKernel::build ( ) [virtual]
void PLearn::SourceKernel::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::Kernel.

Reimplemented in PLearn::AdditiveNormalizationKernel, PLearn::DivisiveNormalizationKernel, and PLearn::ThresholdedKernel.

Definition at line 86 of file SourceKernel.cc.

{
    this->is_symmetric = source_kernel->is_symmetric;
    this->data_inputsize = source_kernel->dataInputsize();
    this->n_examples = source_kernel->nExamples();
    if (specify_dataset) {
        // Forward the specified dataset to the underlying kernel, if it is not done already.
        if (static_cast<VMatrix*>(specify_dataset) != static_cast<VMatrix*>(source_kernel->specify_dataset)) {
            source_kernel->specify_dataset = specify_dataset;
            source_kernel->build();
        }
    }
}
string PLearn::SourceKernel::classname ( ) const [virtual]
void PLearn::SourceKernel::computeGramMatrix ( Mat  K) const [virtual]

Call evaluate_i_j to fill each of the entries (i,j) of symmetric matrix K.

Reimplemented from PLearn::Kernel.

Reimplemented in PLearn::AdditiveNormalizationKernel, PLearn::DivisiveNormalizationKernel, and PLearn::ThresholdedKernel.

Definition at line 113 of file SourceKernel.cc.

                                                {
    source_kernel->computeGramMatrix(K);
}
void PLearn::SourceKernel::declareOptions ( OptionList ol) [static, protected]

Declares this class' options.

Reimplemented from PLearn::Kernel.

Reimplemented in PLearn::AdditiveNormalizationKernel, PLearn::DivisiveNormalizationKernel, and PLearn::ThresholdedKernel.

Definition at line 65 of file SourceKernel.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), and source_kernel.

Referenced by PLearn::ThresholdedKernel::declareOptions(), PLearn::DivisiveNormalizationKernel::declareOptions(), and PLearn::AdditiveNormalizationKernel::declareOptions().

{
    declareOption(ol, "source_kernel", &SourceKernel::source_kernel, OptionBase::buildoption,
                  "The underlying kernel.");

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static const PPath& PLearn::SourceKernel::declaringFile ( ) [inline, static]
SourceKernel * PLearn::SourceKernel::deepCopy ( CopiesMap copies) const [virtual]
real PLearn::SourceKernel::evaluate ( const Vec x1,
const Vec x2 
) const [virtual]

Compute K(x1,x2).

Implements PLearn::Kernel.

Reimplemented in PLearn::AdditiveNormalizationKernel, PLearn::DivisiveNormalizationKernel, and PLearn::ThresholdedKernel.

Definition at line 120 of file SourceKernel.cc.

                                                              {
    return source_kernel->evaluate(x1, x2);
}
real PLearn::SourceKernel::evaluate_i_j ( int  i,
int  j 
) const [virtual]

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

Reimplemented from PLearn::Kernel.

Reimplemented in PLearn::AdditiveNormalizationKernel, PLearn::DivisiveNormalizationKernel, and PLearn::ThresholdedKernel.

Definition at line 127 of file SourceKernel.cc.

                                                  {
    return source_kernel->evaluate_i_j(i,j);
}
real PLearn::SourceKernel::evaluate_i_x ( int  i,
const Vec x,
real  squared_norm_of_x = -1 
) const [virtual]

Return evaluate(data(i),x).

[squared_norm_of_x is just a hint that may allow to speed up computation if it is already known, but it's optional]

Reimplemented from PLearn::Kernel.

Reimplemented in PLearn::AdditiveNormalizationKernel, PLearn::DivisiveNormalizationKernel, and PLearn::ThresholdedKernel.

Definition at line 134 of file SourceKernel.cc.

                                                                                 {
    return source_kernel->evaluate_i_x(i, x, squared_norm_of_x);
}
real PLearn::SourceKernel::evaluate_x_i ( const Vec x,
int  i,
real  squared_norm_of_x = -1 
) const [virtual]

returns evaluate(x,data(i)) [default version calls evaluate_i_x if kernel is_symmetric]

Reimplemented from PLearn::Kernel.

Reimplemented in PLearn::AdditiveNormalizationKernel, PLearn::DivisiveNormalizationKernel, and PLearn::ThresholdedKernel.

Definition at line 141 of file SourceKernel.cc.

                                                                                 {
    return source_kernel->evaluate_x_i(x, i, squared_norm_of_x);
}
OptionList & PLearn::SourceKernel::getOptionList ( ) const [virtual]
OptionMap & PLearn::SourceKernel::getOptionMap ( ) const [virtual]
Vec PLearn::SourceKernel::getParameters ( ) const [virtual]

default version returns an empty Vec

Reimplemented from PLearn::Kernel.

Definition at line 148 of file SourceKernel.cc.

                                      {
    return source_kernel->getParameters();
}
RemoteMethodMap & PLearn::SourceKernel::getRemoteMethodMap ( ) const [virtual]
void PLearn::SourceKernel::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::Kernel.

Reimplemented in PLearn::AdditiveNormalizationKernel, PLearn::DivisiveNormalizationKernel, and PLearn::ThresholdedKernel.

Definition at line 155 of file SourceKernel.cc.

References PLearn::deepCopyField().

Referenced by PLearn::ThresholdedKernel::makeDeepCopyFromShallowCopy(), PLearn::DivisiveNormalizationKernel::makeDeepCopyFromShallowCopy(), and PLearn::AdditiveNormalizationKernel::makeDeepCopyFromShallowCopy().

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::SourceKernel::setDataForKernelMatrix ( VMat  the_data) [virtual]

** Subclasses may override these methods to provide efficient kernel matrix access **

This method sets the data VMat that will be used to define the kernel matrix. It may precompute values from this that may later accelerate the evaluation of a kernel matrix element

Reimplemented from PLearn::Kernel.

Reimplemented in PLearn::AdditiveNormalizationKernel, PLearn::DivisiveNormalizationKernel, and PLearn::ThresholdedKernel.

Definition at line 164 of file SourceKernel.cc.

Referenced by PLearn::ThresholdedKernel::setDataForKernelMatrix(), PLearn::DivisiveNormalizationKernel::setDataForKernelMatrix(), and PLearn::AdditiveNormalizationKernel::setDataForKernelMatrix().

                                                       {
    inherited::setDataForKernelMatrix(the_data);
    source_kernel->setDataForKernelMatrix(the_data);
}

Here is the caller graph for this function:

void PLearn::SourceKernel::setParameters ( Vec  paramvec) [virtual]

** Subclasses may override these methods ** They provide a generic way to set and retrieve kernel parameters

default version produces an error

Reimplemented from PLearn::Kernel.

Definition at line 172 of file SourceKernel.cc.

                                             {
    source_kernel->setParameters(paramvec);
}

Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines