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

#include <RandomNeighborsDifferencesVMatrix.h>

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

List of all members.

Public Member Functions

 RandomNeighborsDifferencesVMatrix ()
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
RandomNeighborsDifferencesVMatrix
deepCopy (CopiesMap &copies) const

Static Public Member Functions

static string _classname_ ()
 Declares name and deepCopy methods.
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

int n_neighbors
bool append_current_point_indexe
bool append_random_neighbors_indexes

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

virtual void getNewRow (int i, const Vec &v) const
 This is the only method requiring implementation.

Static Protected Member Functions

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

Private Types

typedef SourceVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Private Attributes

Vec neighbor_row
 Used to store data and save memory allocations.
Vec ith_row
Vec diff_k

Detailed Description

Definition at line 52 of file RandomNeighborsDifferencesVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::SourceVMatrix.

Definition at line 57 of file RandomNeighborsDifferencesVMatrix.h.


Constructor & Destructor Documentation

PLearn::RandomNeighborsDifferencesVMatrix::RandomNeighborsDifferencesVMatrix ( )

Definition at line 53 of file RandomNeighborsDifferencesVMatrix.cc.

    :inherited(), n_neighbors(-1), append_current_point_indexe(false), append_random_neighbors_indexes(false)
    /* ### Initialise all fields to their default value */
{
}

Member Function Documentation

string PLearn::RandomNeighborsDifferencesVMatrix::_classname_ ( ) [static]

Declares name and deepCopy methods.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 64 of file RandomNeighborsDifferencesVMatrix.cc.

OptionList & PLearn::RandomNeighborsDifferencesVMatrix::_getOptionList_ ( ) [static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 64 of file RandomNeighborsDifferencesVMatrix.cc.

RemoteMethodMap & PLearn::RandomNeighborsDifferencesVMatrix::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 64 of file RandomNeighborsDifferencesVMatrix.cc.

bool PLearn::RandomNeighborsDifferencesVMatrix::_isa_ ( const Object o) [static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 64 of file RandomNeighborsDifferencesVMatrix.cc.

Object * PLearn::RandomNeighborsDifferencesVMatrix::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 64 of file RandomNeighborsDifferencesVMatrix.cc.

StaticInitializer RandomNeighborsDifferencesVMatrix::_static_initializer_ & PLearn::RandomNeighborsDifferencesVMatrix::_static_initialize_ ( ) [static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 64 of file RandomNeighborsDifferencesVMatrix.cc.

void PLearn::RandomNeighborsDifferencesVMatrix::build ( ) [virtual]

Simply calls inherited::build() then build_().

Reimplemented from PLearn::SourceVMatrix.

Definition at line 123 of file RandomNeighborsDifferencesVMatrix.cc.

References PLearn::SourceVMatrix::build(), and build_().

Referenced by PLearn::random_neighbors_differences().

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::RandomNeighborsDifferencesVMatrix::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 109 of file RandomNeighborsDifferencesVMatrix.cc.

References append_current_point_indexe, append_random_neighbors_indexes, PLearn::VMat::length(), PLearn::VMatrix::length_, n_neighbors, PLearn::SourceVMatrix::source, PLearn::VMatrix::updateMtime(), PLearn::VMat::width(), and PLearn::VMatrix::width_.

Referenced by build().

{
    if (source)
        // will not work if source is changed but has the same dimensions
    {
        updateMtime(source);
        width_ = source->width()*n_neighbors;
        if(append_current_point_indexe) width_ += 1;
        if(append_random_neighbors_indexes) width_ += n_neighbors;
        length_ = source->length();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::RandomNeighborsDifferencesVMatrix::classname ( ) const [virtual]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 64 of file RandomNeighborsDifferencesVMatrix.cc.

void PLearn::RandomNeighborsDifferencesVMatrix::declareOptions ( OptionList ol) [static, protected]

Declares this class' options.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 92 of file RandomNeighborsDifferencesVMatrix.cc.

References append_current_point_indexe, append_random_neighbors_indexes, PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::SourceVMatrix::declareOptions(), and n_neighbors.

{
    declareOption(ol, "n_neighbors", &RandomNeighborsDifferencesVMatrix::n_neighbors, OptionBase::buildoption,
                  "Number of nearest neighbors. Determines the width of this vmatrix, which\n"
                  "is source->width() * n_neighbors.\n");
    declareOption(ol, "append_current_point_indexe", &RandomNeighborsDifferencesVMatrix::append_current_point_indexe, OptionBase::buildoption,
                  "Indication that the indexe of the current data point should be appended \n"
                  "to the row of the VMatrix.\n");
    declareOption(ol, "append_random_neighbors_indexes", &RandomNeighborsDifferencesVMatrix::append_random_neighbors_indexes, OptionBase::buildoption,
                  "Indication that the indexes of the random data points should be appended \n"
                  "to the row of the VMatrix.\n");


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

Here is the call graph for this function:

static const PPath& PLearn::RandomNeighborsDifferencesVMatrix::declaringFile ( ) [inline, static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 114 of file RandomNeighborsDifferencesVMatrix.h.

{
RandomNeighborsDifferencesVMatrix * PLearn::RandomNeighborsDifferencesVMatrix::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 64 of file RandomNeighborsDifferencesVMatrix.cc.

void PLearn::RandomNeighborsDifferencesVMatrix::getNewRow ( int  i,
const Vec v 
) const [protected, virtual]

This is the only method requiring implementation.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 66 of file RandomNeighborsDifferencesVMatrix.cc.

References append_current_point_indexe, append_random_neighbors_indexes, diff_k, i, ith_row, PLearn::VMat::length(), n_neighbors, neighbor_row, PLERROR, PLearn::TVec< T >::resize(), PLearn::SourceVMatrix::source, PLearn::substract(), PLearn::TVec< T >::toMat(), PLearn::uniform_sample(), PLearn::VMat::width(), and PLearn::VMatrix::width_.

{
    if (width_<0)
        PLERROR("RandomNeighborsDifferencesVMatrix::getNewRow called but build was not done yet");

    // vue en matrice du vecteur de sortie, ca pointe sur les memes donnees.
    Mat differences = v.toMat(n_neighbors,source->width());
    neighbor_row.resize(source->width());
    ith_row.resize(source->width());
    source->getRow(i,ith_row);
    int rand_index;
    if(append_current_point_indexe)
        v[n_neighbors*source->width()+1] = i;
    for (int k=0;k<n_neighbors;k++)
    {
        rand_index = int(uniform_sample()*source->length());
        diff_k = differences(k);
        source->getRow(rand_index,neighbor_row);
        substract(neighbor_row,ith_row, diff_k);
        // normalize result
        // now it's done in ProjectionErrorVariable diff_k /= norm(diff_k);
        if(append_random_neighbors_indexes)
            v[n_neighbors*source->width()+(append_current_point_indexe?1:0)+k] = rand_index;
    }
}

Here is the call graph for this function:

OptionList & PLearn::RandomNeighborsDifferencesVMatrix::getOptionList ( ) const [virtual]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 64 of file RandomNeighborsDifferencesVMatrix.cc.

OptionMap & PLearn::RandomNeighborsDifferencesVMatrix::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 64 of file RandomNeighborsDifferencesVMatrix.cc.

RemoteMethodMap & PLearn::RandomNeighborsDifferencesVMatrix::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 64 of file RandomNeighborsDifferencesVMatrix.cc.

void PLearn::RandomNeighborsDifferencesVMatrix::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 129 of file RandomNeighborsDifferencesVMatrix.cc.

References PLearn::deepCopyField(), ith_row, PLearn::SourceVMatrix::makeDeepCopyFromShallowCopy(), and neighbor_row.

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::SourceVMatrix.

Definition at line 114 of file RandomNeighborsDifferencesVMatrix.h.

Definition at line 60 of file RandomNeighborsDifferencesVMatrix.h.

Referenced by getNewRow().

Definition at line 60 of file RandomNeighborsDifferencesVMatrix.h.

Referenced by getNewRow(), and makeDeepCopyFromShallowCopy().

Used to store data and save memory allocations.

Definition at line 60 of file RandomNeighborsDifferencesVMatrix.h.

Referenced by getNewRow(), and makeDeepCopyFromShallowCopy().


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