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

This VMat delay the last targetsize entries of a source VMat by a certain horizon. More...

#include <TemporalHorizonVMatrix.h>

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

List of all members.

Public Member Functions

 TemporalHorizonVMatrix (bool call_build_=false)
 Also copies the original fieldinfos upon construction.
 TemporalHorizonVMatrix (VMat the_source, int the_horizon, int target_size, bool call_build_=false)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual TemporalHorizonVMatrixdeepCopy (CopiesMap &copies) const
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual real get (int i, int j) const
 These methods are implemented by buffering calls to getNewRow.
virtual void put (int i, int j, real value)
 This method must be implemented in all subclasses of writable matrices.
virtual real getStringVal (int col, const string &str) const
 Returns value associated with a string (or MISSING_VALUE if there's no association for this string).
virtual string getValString (int col, real val) const
 Returns the string associated with value val for field# col.
virtual string getString (int row, int col) const
 Returns element as a string, even if value doesn't map to a string, in which case tostring(value) is returned.
virtual const map< string, real > & getStringToRealMapping (int col) const
 returns the whole string->value mapping
virtual const map< real, string > & getRealToStringMapping (int col) const
 Returns the real->string mapping for column 'col'.
virtual void reset_dimensions ()
 In case the dimensions of an underlying VMat has changed, recompute it.
virtual real dot (int i1, int i2, int inputsize) const
 Returns the dot product between row i1 and row i2 (considering only the inputsize first elements).
virtual real dot (int i, const Vec &v) const
 Returns the result of the dot product between row i and the given vec (only v.length() first elements of row i are considered).

Static Public Member Functions

static string _classname_ ()
 TemporalHorizonVMatrix.
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 ()
static void declareOptions (OptionList &ol)
 Declares this class' options.

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Attributes

int horizon
int targetsize
TVec< introw_delay

Private Types

typedef SourceVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

This VMat delay the last targetsize entries of a source VMat by a certain horizon.

Definition at line 55 of file TemporalHorizonVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::SourceVMatrix.

Definition at line 57 of file TemporalHorizonVMatrix.h.


Constructor & Destructor Documentation

PLearn::TemporalHorizonVMatrix::TemporalHorizonVMatrix ( bool  call_build_ = false)

Also copies the original fieldinfos upon construction.

Definition at line 54 of file TemporalHorizonVMatrix.cc.

    : inherited(call_build_)
{
    // don't call build_() because it would do nothing
    /* if( call_build_ )
        build_(); */
}
PLearn::TemporalHorizonVMatrix::TemporalHorizonVMatrix ( VMat  the_source,
int  the_horizon,
int  target_size,
bool  call_build_ = false 
)

Definition at line 62 of file TemporalHorizonVMatrix.cc.

References PLearn::VMatrix::defineSizes(), PLearn::VMatrix::fieldinfos, horizon, i, PLearn::TVec< T >::resize(), row_delay, PLearn::SourceVMatrix::source, PLearn::VMatrix::targetsize(), and PLearn::VMatrix::width().

    : inherited(the_source,
                the_source.length()-the_horizon, the_source->width(),
                call_build_),
      horizon(the_horizon),
      targetsize(target_size)
{
    fieldinfos = source->fieldinfos;
    row_delay.resize(width());
    for (int i=0; i<width(); i++)
        row_delay[i] = i<width()-targetsize ? 0 : horizon;

    defineSizes(source->inputsize(),
                source->targetsize(),
                source->weightsize());

    // don't call build_() because it would do nothing
    /* if( call_build_ )
        build_(); */
}

Here is the call graph for this function:


Member Function Documentation

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

TemporalHorizonVMatrix.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 52 of file TemporalHorizonVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 52 of file TemporalHorizonVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 52 of file TemporalHorizonVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 52 of file TemporalHorizonVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 52 of file TemporalHorizonVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 52 of file TemporalHorizonVMatrix.cc.

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

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 148 of file TemporalHorizonVMatrix.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 157 of file TemporalHorizonVMatrix.cc.

References PLearn::VMatrix::defineSizes(), PLearn::VMatrix::fieldinfos, horizon, i, PLearn::VMat::length(), PLearn::VMatrix::length_, PLearn::TVec< T >::resize(), row_delay, PLearn::SourceVMatrix::source, PLearn::VMatrix::targetsize(), PLearn::VMatrix::updateMtime(), PLearn::VMatrix::width(), PLearn::VMat::width(), and PLearn::VMatrix::width_.

Referenced by build().

{
    if (source) {
        updateMtime(source);
        length_ = source->length()-horizon;
        width_ = source->width();
        fieldinfos = source->fieldinfos;

        row_delay.resize(width());
        for (int i=0; i<width(); i++)
            row_delay[i] = i<width()-targetsize ? 0 : horizon;

        defineSizes(source->inputsize(),
                    source->targetsize(),
                    source->weightsize());
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 52 of file TemporalHorizonVMatrix.cc.

void PLearn::TemporalHorizonVMatrix::declareOptions ( OptionList ol) [static]

Declares this class' options.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 123 of file TemporalHorizonVMatrix.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::SourceVMatrix::declareOptions(), horizon, PLearn::OptionBase::learntoption, PLearn::OptionBase::nosave, PLearn::SourceVMatrix::source, and PLearn::VMatrix::targetsize().

{
    declareOption(ol, "distr", &TemporalHorizonVMatrix::source,
                  (OptionBase::learntoption | OptionBase::nosave),
                  "DEPRECATED - Use 'source' instead.");

    declareOption(ol, "horizon", &TemporalHorizonVMatrix::horizon,
                  OptionBase::buildoption,
                  "The temporal value by which to delay the source VMat");

    declareOption(ol, "targetsize", &TemporalHorizonVMatrix::targetsize,
                  OptionBase::buildoption,
                  "The number of last entries to delay");

    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file TemporalHorizonVMatrix.h.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 52 of file TemporalHorizonVMatrix.cc.

real PLearn::TemporalHorizonVMatrix::dot ( int  i1,
int  i2,
int  inputsize 
) const [virtual]

Returns the dot product between row i1 and row i2 (considering only the inputsize first elements).

The default version in VMatrix is somewhat inefficient, as it repeatedly calls get(i,j) The default version in RowBufferedVMatrix is a little better as it buffers the 2 Vecs between calls in case one of them is needed again. But the real strength of this method is for specialised and efficient versions in subbclasses. This method is typically used by SmartKernels so that they can compute kernel values between input samples efficiently.

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 92 of file TemporalHorizonVMatrix.cc.

References PLearn::VMatrix::inputsize(), row_delay, and PLearn::SourceVMatrix::source.

{
    real res = 0.;
    for(int k=0; k<inputsize; k++)
        res += source->get(i1+row_delay[k],k)*source->get(i2+row_delay[k],k);
    return res;
}

Here is the call graph for this function:

real PLearn::TemporalHorizonVMatrix::dot ( int  i,
const Vec v 
) const [virtual]

Returns the result of the dot product between row i and the given vec (only v.length() first elements of row i are considered).

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 100 of file TemporalHorizonVMatrix.cc.

References PLearn::TVec< T >::length(), row_delay, and PLearn::SourceVMatrix::source.

{
    real res = 0.;
    for(int k=0; k<v.length(); k++)
        res += source->get(i+row_delay[k],k)*v[k];
    return res;
}

Here is the call graph for this function:

real PLearn::TemporalHorizonVMatrix::get ( int  i,
int  j 
) const [virtual]

These methods are implemented by buffering calls to getNewRow.

returns element (i,j)

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 86 of file TemporalHorizonVMatrix.cc.

References row_delay, and PLearn::SourceVMatrix::source.

{ return source->get(i+row_delay[j], j); }
OptionList & PLearn::TemporalHorizonVMatrix::getOptionList ( ) const [virtual]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 52 of file TemporalHorizonVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 52 of file TemporalHorizonVMatrix.cc.

const map< real, string > & PLearn::TemporalHorizonVMatrix::getRealToStringMapping ( int  col) const [virtual]

Returns the real->string mapping for column 'col'.

Reimplemented from PLearn::VMatrix.

Definition at line 120 of file TemporalHorizonVMatrix.cc.

References PLearn::SourceVMatrix::source.

{ return source->getRealToStringMapping(col);}
RemoteMethodMap & PLearn::TemporalHorizonVMatrix::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 52 of file TemporalHorizonVMatrix.cc.

string PLearn::TemporalHorizonVMatrix::getString ( int  row,
int  col 
) const [virtual]

Returns element as a string, even if value doesn't map to a string, in which case tostring(value) is returned.

Reimplemented from PLearn::VMatrix.

Definition at line 114 of file TemporalHorizonVMatrix.cc.

References row_delay, and PLearn::SourceVMatrix::source.

{ return source->getString(row+row_delay[col],col); }
const map< string, real > & PLearn::TemporalHorizonVMatrix::getStringToRealMapping ( int  col) const [virtual]

returns the whole string->value mapping

Reimplemented from PLearn::VMatrix.

Definition at line 117 of file TemporalHorizonVMatrix.cc.

References PLearn::SourceVMatrix::source.

{ return source->getStringToRealMapping(col);}
real PLearn::TemporalHorizonVMatrix::getStringVal ( int  col,
const string &  str 
) const [virtual]

Returns value associated with a string (or MISSING_VALUE if there's no association for this string).

Reimplemented from PLearn::VMatrix.

Definition at line 108 of file TemporalHorizonVMatrix.cc.

References PLearn::SourceVMatrix::source.

{ return source->getStringVal(col, str); }
string PLearn::TemporalHorizonVMatrix::getValString ( int  col,
real  val 
) const [virtual]

Returns the string associated with value val for field# col.

Or returns "" if no string is associated.

Reimplemented from PLearn::VMatrix.

Definition at line 111 of file TemporalHorizonVMatrix.cc.

References PLearn::SourceVMatrix::source.

{ return source->getValString(col,val); }
void PLearn::TemporalHorizonVMatrix::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 140 of file TemporalHorizonVMatrix.cc.

References PLearn::SourceVMatrix::makeDeepCopyFromShallowCopy().

Here is the call graph for this function:

void PLearn::TemporalHorizonVMatrix::put ( int  i,
int  j,
real  value 
) [virtual]

This method must be implemented in all subclasses of writable matrices.

Sets element (i,j) to value.

Reimplemented from PLearn::VMatrix.

Definition at line 89 of file TemporalHorizonVMatrix.cc.

References row_delay, and PLearn::SourceVMatrix::source.

{ source->put(i+row_delay[j], j, value); }
virtual void PLearn::TemporalHorizonVMatrix::reset_dimensions ( ) [inline, virtual]

In case the dimensions of an underlying VMat has changed, recompute it.

Reimplemented from PLearn::VMatrix.

Definition at line 91 of file TemporalHorizonVMatrix.h.

    {
        source->reset_dimensions();
        width_=source->width();
    }

Member Data Documentation

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file TemporalHorizonVMatrix.h.

Definition at line 62 of file TemporalHorizonVMatrix.h.

Referenced by build_(), declareOptions(), and TemporalHorizonVMatrix().

Definition at line 64 of file TemporalHorizonVMatrix.h.

Referenced by build_(), dot(), get(), getString(), put(), and TemporalHorizonVMatrix().

Definition at line 63 of file TemporalHorizonVMatrix.h.


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