|
PLearn 0.1
|
#include <RandomNeighborsDifferencesVMatrix.h>


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 OptionList & | getOptionList () const |
| virtual OptionMap & | getOptionMap () const |
| virtual RemoteMethodMap & | getRemoteMethodMap () 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 PPath & | declaringFile () |
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 |
Definition at line 52 of file RandomNeighborsDifferencesVMatrix.h.
typedef SourceVMatrix PLearn::RandomNeighborsDifferencesVMatrix::inherited [private] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file RandomNeighborsDifferencesVMatrix.h.
| 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 */ { }
| 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.
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().
{
inherited::build();
build_();
}


| 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();
}
}


| 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);
}

| 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;
}
}

| 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.
{
inherited::makeDeepCopyFromShallowCopy(copies);
deepCopyField(neighbor_row, copies);
deepCopyField(ith_row, copies);
}

Reimplemented from PLearn::SourceVMatrix.
Definition at line 114 of file RandomNeighborsDifferencesVMatrix.h.
Definition at line 78 of file RandomNeighborsDifferencesVMatrix.h.
Referenced by build_(), declareOptions(), getNewRow(), and PLearn::random_neighbors_differences().
Definition at line 79 of file RandomNeighborsDifferencesVMatrix.h.
Referenced by build_(), declareOptions(), getNewRow(), and PLearn::random_neighbors_differences().
Vec PLearn::RandomNeighborsDifferencesVMatrix::diff_k [mutable, private] |
Definition at line 60 of file RandomNeighborsDifferencesVMatrix.h.
Referenced by getNewRow().
Vec PLearn::RandomNeighborsDifferencesVMatrix::ith_row [mutable, private] |
Definition at line 60 of file RandomNeighborsDifferencesVMatrix.h.
Referenced by getNewRow(), and makeDeepCopyFromShallowCopy().
Definition at line 77 of file RandomNeighborsDifferencesVMatrix.h.
Referenced by build_(), declareOptions(), getNewRow(), and PLearn::random_neighbors_differences().
Vec PLearn::RandomNeighborsDifferencesVMatrix::neighbor_row [mutable, private] |
Used to store data and save memory allocations.
Definition at line 60 of file RandomNeighborsDifferencesVMatrix.h.
Referenced by getNewRow(), and makeDeepCopyFromShallowCopy().
1.7.4