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

#include <PrecomputedVMatrix.h>

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

List of all members.

Public Member Functions

 PrecomputedVMatrix ()
virtual void setMetaDataDir (const PPath &the_metadatadir)
 Also sets the source's meta-data dir if it's not already set.
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 PrecomputedVMatrixdeepCopy (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

string precomp_type
bool temporary

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.

Protected Attributes

VMat precomp_source
 The precomputed source (FileVMatrix or DiskVMatrix).

Private Types

typedef SourceVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.
void usePrecomputed ()

Detailed Description

Definition at line 53 of file PrecomputedVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 55 of file PrecomputedVMatrix.h.


Constructor & Destructor Documentation

PLearn::PrecomputedVMatrix::PrecomputedVMatrix ( )

Definition at line 57 of file PrecomputedVMatrix.cc.

                                      :
    precomp_type("dmat"),
    temporary(false)
{}

Member Function Documentation

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

Declares name and deepCopy methods.

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 71 of file PrecomputedVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 71 of file PrecomputedVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 71 of file PrecomputedVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 71 of file PrecomputedVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 71 of file PrecomputedVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 71 of file PrecomputedVMatrix.cc.

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

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

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 194 of file PrecomputedVMatrix.cc.

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

Referenced by PLearn::LocallyPrecomputedVMatrix::build(), and PLearn::LocallyPrecomputedVMatrix::build_().

Here is the call graph for this function:

Here is the caller graph for this function:

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

This does the actual building.

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 185 of file PrecomputedVMatrix.cc.

References PLearn::VMatrix::hasMetaDataDir(), PLearn::VMat::length(), PLearn::SourceVMatrix::setMetaInfoFromSource(), PLearn::SourceVMatrix::source, and PLearn::VMat::width().

Referenced by build().

{
    //We don't always call it as some matrix(FilteredVMatrix) are only
    //completly set if they have a metadatadir.
    if(hasMetaDataDir() ||(source->width()>0 && source->length()>0))
        setMetaInfoFromSource();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 71 of file PrecomputedVMatrix.cc.

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

Declares this class' options.

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 87 of file PrecomputedVMatrix.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::SourceVMatrix::declareOptions(), PLearn::VMatrix::inputsize_, PLearn::VMatrix::length_, PLearn::OptionBase::nosave, precomp_type, PLearn::redeclareOption(), PLearn::VMatrix::targetsize_, temporary, PLearn::VMatrix::weightsize_, PLearn::VMatrix::width_, and PLearn::VMatrix::writable.

Referenced by PLearn::LocallyPrecomputedVMatrix::declareOptions().

{
    declareOption(ol, "precomp_type", &PrecomputedVMatrix::precomp_type, OptionBase::buildoption,
        "The type of VMatrix to be used for the cached precomputed version\n"
        "of the source. Currently supported are 'dmat' and 'pmat'.");

    declareOption(ol, "temporary", &PrecomputedVMatrix::temporary, OptionBase::buildoption,
        "If set to 1, the created precomputed data will be temporary, i.e.\n"
        "will be deleted when not used anymore.");

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

    // Hide useless options.
    redeclareOption(ol, "writable", &PrecomputedVMatrix::writable, OptionBase::nosave,
                    "Unused option.");
    redeclareOption(ol, "length", &PrecomputedVMatrix::length_, OptionBase::nosave,
                    "Unused option.");
    redeclareOption(ol, "width", &PrecomputedVMatrix::width_, OptionBase::nosave,
                    "Unused option.");
    redeclareOption(ol, "inputsize", &PrecomputedVMatrix::inputsize_, OptionBase::nosave,
                    "Unused option.");
    redeclareOption(ol, "targetsize", &PrecomputedVMatrix::targetsize_, OptionBase::nosave,
                    "Unused option.");
    redeclareOption(ol, "weightsize", &PrecomputedVMatrix::weightsize_, OptionBase::nosave,
                    "Unused option.");
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 108 of file PrecomputedVMatrix.h.

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

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 71 of file PrecomputedVMatrix.cc.

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

This is the only method requiring implementation.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 76 of file PrecomputedVMatrix.cc.

References PLearn::PP< T >::isNull(), PLERROR, and precomp_source.

{
    if(precomp_source.isNull())
        PLERROR("Source has not been precomputed. Did you properly set the "
                "MetaDataDir?");
    precomp_source->getRow(i,v);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 71 of file PrecomputedVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 71 of file PrecomputedVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 71 of file PrecomputedVMatrix.cc.

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

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 200 of file PrecomputedVMatrix.cc.

References PLearn::deepCopyField(), PLearn::SourceVMatrix::makeDeepCopyFromShallowCopy(), and precomp_source.

Referenced by PLearn::LocallyPrecomputedVMatrix::makeDeepCopyFromShallowCopy().

{
    inherited::makeDeepCopyFromShallowCopy(copies);

    // ### Call deepCopyField on all "pointer-like" fields
    // ### that you wish to be deepCopied rather than
    // ### shallow-copied.
    // ### ex:
    deepCopyField(precomp_source, copies);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::PrecomputedVMatrix::setMetaDataDir ( const PPath the_metadatadir) [virtual]

Also sets the source's meta-data dir if it's not already set.

If there are fields that have no corresponding .smap .notes or .binning info files but the source has those files for a field with the same name, then those of the source will be set also for this vmatrix.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 118 of file PrecomputedVMatrix.cc.

References PLearn::VMatrix::hasMetaDataDir(), PLearn::SourceVMatrix::setMetaDataDir(), PLearn::SourceVMatrix::setMetaInfoFromSource(), and usePrecomputed().

{
    inherited::setMetaDataDir(the_metadatadir);
    if ( hasMetaDataDir() ) // don't do anything if the meta-data-dir is not yet set.
    {
        setMetaInfoFromSource();
        usePrecomputed();
    }
}

Here is the call graph for this function:

void PLearn::PrecomputedVMatrix::usePrecomputed ( ) [private]

Definition at line 128 of file PrecomputedVMatrix.cc.

References PLearn::force_rmdir(), PLearn::VMatrix::getMetaDataDir(), PLearn::isdir(), PLearn::isfile(), PLearn::VMatrix::isUpToDate(), PLearn::VMat::length(), PLearn::VMatrix::length_, PLERROR, precomp_source, precomp_type, PLearn::rm(), PLearn::SourceVMatrix::source, and temporary.

Referenced by setMetaDataDir().

{
    PPath mdir = getMetaDataDir();

    if ( precomp_type == "dmat" )
    {
        PPath dmatdir  = mdir / "precomp.dmat";
        bool recompute = true;

        if ( isdir(dmatdir) )
        {
            precomp_source = temporary ? new TemporaryDiskVMatrix(dmatdir,
                                                                  false)
                                       : new DiskVMatrix(dmatdir);
            if(isUpToDate(precomp_source))
                recompute = false;
        }

        if(recompute)
        {
            force_rmdir(dmatdir);
            source->saveDMAT(dmatdir);
            precomp_source = temporary ? new TemporaryDiskVMatrix(dmatdir,
                                                                  false)
                                       : new DiskVMatrix(dmatdir);
        }
        length_ = precomp_source->length();
    }

    else if ( precomp_type == "pmat" )
    {
        PPath pmatfile = mdir / "precomp.pmat";
        bool recompute = true;

        if ( isfile(pmatfile) )
        {
            precomp_source = temporary ? new TemporaryFileVMatrix(pmatfile)
                                       : new FileVMatrix(pmatfile);
            if(isUpToDate(pmatfile))
                recompute = false;
        }

        if(recompute)
        {
            rm(pmatfile);
            source->savePMAT(pmatfile);
            precomp_source = temporary ? new TemporaryFileVMatrix(pmatfile)
                                       : new FileVMatrix(pmatfile);
        }
        length_ = precomp_source->length();
    }

    else
        PLERROR("Invalid precomp_type=%s. Must be one of: dmat, pmat.",
                precomp_type.c_str());
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from PLearn::SourceVMatrix.

Reimplemented in PLearn::LocallyPrecomputedVMatrix.

Definition at line 108 of file PrecomputedVMatrix.h.


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