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

#include <AbsVariable.h>

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

List of all members.

Public Member Functions

 AbsVariable ()
 Default constructor for persistence.
 AbsVariable (Variable *input)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual AbsVariabledeepCopy (CopiesMap &copies) const
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
virtual void rfprop ()

Static Public Member Functions

static string _classname_ ()
 AbsVariable.
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_

Private Types

typedef UnaryVariable inherited

Detailed Description

Definition at line 53 of file AbsVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file AbsVariable.h.


Constructor & Destructor Documentation

PLearn::AbsVariable::AbsVariable ( ) [inline]

Default constructor for persistence.

Definition at line 59 of file AbsVariable.h.

{}
PLearn::AbsVariable::AbsVariable ( Variable input)

Definition at line 60 of file AbsVariable.cc.

    : inherited(input, input->length(), input->width())
{}

Member Function Documentation

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

AbsVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file AbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file AbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file AbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file AbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file AbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file AbsVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 84 of file AbsVariable.cc.

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

{
    for(int i=0; i<nelems(); i++)
    {
        real val = input->valuedata[i];
        if(val>=0)        
            input->gradientdata[i] += gradientdata[i];
        else
            input->gradientdata[i] -= gradientdata[i];
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file AbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file AbsVariable.h.

{ return new AbsVariable(v); }
AbsVariable * PLearn::AbsVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file AbsVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 74 of file AbsVariable.cc.

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

{
    for(int i=0; i<nelems(); i++)
    {
        real val = input->valuedata[i];
        valuedata[i] = val>=0 ?val :-val;
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file AbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file AbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file AbsVariable.cc.

void PLearn::AbsVariable::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 65 of file AbsVariable.cc.

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

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

Here is the call graph for this function:

void PLearn::AbsVariable::rfprop ( ) [virtual]

Reimplemented from PLearn::Variable.

Definition at line 105 of file AbsVariable.cc.

References i, PLearn::UnaryVariable::input, PLearn::TVec< T >::length(), n, PLearn::Variable::nelems(), PLearn::UnaryVariable::resizeRValue(), PLearn::Variable::rValue, and PLearn::Variable::rvaluedata.

{
    if (rValue.length()==0) resizeRValue();
    int n=nelems();
    for(int i=0; i<n; i++)
        if (input->valuedata[i] < 0) 
            rvaluedata[i] = -input->rvaluedata[i];
        else 
            rvaluedata[i] = input->rvaluedata[i];
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 97 of file AbsVariable.cc.

References PLearn::Variable::g, PLearn::ifThenElse(), and PLearn::UnaryVariable::input.

{
    input->accg(ifThenElse(input >= 0., g, -g));
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file AbsVariable.h.


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