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

if values = [x1,x2,...,x10], the resulting variable is [(x1+x2)/2,(x2+x3)/2, ... More...

#include <InterValuesVariable.h>

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

List of all members.

Public Member Functions

 InterValuesVariable ()
 Default constructor for persistence.
 InterValuesVariable (Variable *values)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual InterValuesVariabledeepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
virtual void recomputeSize (int &l, int &w) const
 Recomputes the length l and width w that this variable should have, according to its parent variables.
virtual void fprop ()
 Nothing to do by default.
virtual void bprop ()
 Nothing to do by default.
virtual void symbolicBprop ()
 compute a piece of new Var graph that represents the symbolic derivative of this Var

Static Public Member Functions

static string _classname_ ()
 InterValuesVariable.
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 Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

void build_ ()
 Object-specific post-constructor.

Private Types

typedef UnaryVariable inherited

Detailed Description

if values = [x1,x2,...,x10], the resulting variable is [(x1+x2)/2,(x2+x3)/2, ...

(x9+x10)/2]

Definition at line 54 of file InterValuesVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 56 of file InterValuesVariable.h.


Constructor & Destructor Documentation

PLearn::InterValuesVariable::InterValuesVariable ( ) [inline]

Default constructor for persistence.

Definition at line 60 of file InterValuesVariable.h.

Referenced by symbolicBprop().

{}

Here is the caller graph for this function:

PLearn::InterValuesVariable::InterValuesVariable ( Variable values)

Definition at line 60 of file InterValuesVariable.cc.

References build_().

    : inherited(values,values->length()-1,1) 
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

InterValuesVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file InterValuesVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file InterValuesVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file InterValuesVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file InterValuesVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file InterValuesVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file InterValuesVariable.cc.

void PLearn::InterValuesVariable::bprop ( ) [virtual]

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 103 of file InterValuesVariable.cc.

References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, and PLearn::Variable::nelems().

{
    real* prev_dx = &input->gradientdata[0];
    for (int i=0;i<nelems();i++)
    {
        real* next_dx = &input->gradientdata[i+1];
        *prev_dx += 0.5 * gradientdata[i];
        *next_dx += 0.5 * gradientdata[i];
        prev_dx = next_dx;
    }
}

Here is the call graph for this function:

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

Post-constructor.

The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.

Reimplemented from PLearn::UnaryVariable.

Definition at line 67 of file InterValuesVariable.cc.

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

Here is the call graph for this function:

void PLearn::InterValuesVariable::build_ ( ) [protected]

Object-specific post-constructor.

This method should be redefined in subclasses and do the actual building of the object according to previously set option fields. Constructors can just set option fields, and then call build_. This method is NOT virtual, and will typically be called only from three places: a constructor, the public virtual build() method, and possibly the public virtual read method (which calls its parent's read). build_() can assume that its parent's build_() has already been called.

Reimplemented from PLearn::UnaryVariable.

Definition at line 74 of file InterValuesVariable.cc.

References PLearn::UnaryVariable::input, and PLERROR.

Referenced by build(), and InterValuesVariable().

{
    if(input && !input->isColumnVec())
        PLERROR("In InterValuesVariable: input must be a column vector (single column matrix)");
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file InterValuesVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 63 of file InterValuesVariable.h.

:
    void build_();
InterValuesVariable * PLearn::InterValuesVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file InterValuesVariable.cc.

void PLearn::InterValuesVariable::fprop ( ) [virtual]

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 91 of file InterValuesVariable.cc.

References i, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), and PLearn::Variable::valuedata.

{
    real prev_x = input->valuedata[0];
    for (int i=0;i<nelems();i++)
    {
        real next_x = input->valuedata[i+1];
        valuedata[i] = 0.5 * (prev_x + next_x);
        prev_x = next_x;
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file InterValuesVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file InterValuesVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file InterValuesVariable.cc.

void PLearn::InterValuesVariable::recomputeSize ( int l,
int w 
) const [virtual]

Recomputes the length l and width w that this variable should have, according to its parent variables.

This is used for ex. by sizeprop() The default version stupidly returns the current dimensions, so make sure to overload it in subclasses if this is not appropriate.

Reimplemented from PLearn::Variable.

Definition at line 81 of file InterValuesVariable.cc.

References PLearn::UnaryVariable::input, and PLearn::Var::length().

{
    if (input)
        l = input->length() - 1;
    else
        l = 0;
    w=1;
}

Here is the call graph for this function:

void PLearn::InterValuesVariable::symbolicBprop ( ) [virtual]

compute a piece of new Var graph that represents the symbolic derivative of this Var

Reimplemented from PLearn::Variable.

Definition at line 116 of file InterValuesVariable.cc.

References PLearn::Variable::g, PLearn::UnaryVariable::input, InterValuesVariable(), PLearn::vconcat(), and zero.

{
    Var zero(1);
    Var g1 = new InterValuesVariable(vconcat(zero & g & (VarArray)zero));

    input->accg(g1);
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 63 of file InterValuesVariable.h.


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