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

#include <TimesColumnVariable.h>

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

List of all members.

Public Member Functions

 TimesColumnVariable ()
 Default constructor.
 TimesColumnVariable (Variable *input1, Variable *input2, bool call_build_=true)
 Convenience constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual TimesColumnVariabledeepCopy (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 ()
 compute output given input
virtual void bprop ()
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_ ()
 TimesColumnVariable.
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 BinaryVariable inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 52 of file TimesColumnVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file TimesColumnVariable.h.


Constructor & Destructor Documentation

PLearn::TimesColumnVariable::TimesColumnVariable ( ) [inline]

Default constructor.

Definition at line 59 of file TimesColumnVariable.h.

{}
PLearn::TimesColumnVariable::TimesColumnVariable ( Variable input1,
Variable input2,
bool  call_build_ = true 
)

Convenience constructor.

Definition at line 61 of file TimesColumnVariable.cc.

References build_().

                                                          :
    inherited(input1, input2, input1->length(), input1->width(), call_build_)
{
    if (call_build_)
        build_();
}

Here is the call graph for this function:


Member Function Documentation

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

TimesColumnVariable.

Reimplemented from PLearn::BinaryVariable.

Definition at line 56 of file TimesColumnVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 56 of file TimesColumnVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 56 of file TimesColumnVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 56 of file TimesColumnVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file TimesColumnVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 56 of file TimesColumnVariable.cc.

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

Implements PLearn::Variable.

Definition at line 117 of file TimesColumnVariable.cc.

References PLearn::Variable::gradientdata, i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, PLearn::Variable::length(), and PLearn::Variable::width().

{
    int k=0;
    for(int i=0; i<length(); i++)
        for(int j=0; j<width(); j++, k++)
        {
            input1->gradientdata[k] += input2->valuedata[i]*gradientdata[k];
            input2->gradientdata[i] += input1->valuedata[k]*gradientdata[k];
        }
}

Here is the call graph for this function:

void PLearn::TimesColumnVariable::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::BinaryVariable.

Definition at line 72 of file TimesColumnVariable.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 81 of file TimesColumnVariable.cc.

References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), and PLCHECK_MSG.

Referenced by build(), and TimesColumnVariable().

{
    if (input1 && input2) {
        PLCHECK_MSG(input2->isColumnVec(),
                    "input2 must be a column variable");
        PLCHECK_MSG(input2->length() == input1->length(),
                    "input1 and input2 must have same length");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 56 of file TimesColumnVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 65 of file TimesColumnVariable.h.

:

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 56 of file TimesColumnVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 106 of file TimesColumnVariable.cc.

References i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, PLearn::Variable::length(), PLearn::Variable::valuedata, and PLearn::Variable::width().

{
    int k=0;
    for(int i=0; i<length(); i++)
        for(int j=0; j<width(); j++, k++)
            valuedata[k] = input1->valuedata[k] * input2->valuedata[i];
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 56 of file TimesColumnVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file TimesColumnVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file TimesColumnVariable.cc.

void PLearn::TimesColumnVariable::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 94 of file TimesColumnVariable.cc.

References PLearn::BinaryVariable::input1, PLearn::Var::length(), and PLearn::Var::width().

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

Here is the call graph for this function:

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

Reimplemented from PLearn::Variable.

Definition at line 140 of file TimesColumnVariable.cc.

References i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, PLearn::TVec< T >::length(), PLearn::Variable::length(), PLearn::BinaryVariable::resizeRValue(), PLearn::Variable::rValue, PLearn::Variable::rvaluedata, and PLearn::Variable::width().

{
    if (rValue.length()==0) resizeRValue();
    int k=0;
    for(int i=0; i<length(); i++)
        for(int j=0; j<width(); j++, k++)
            rvaluedata[k] = input1->valuedata[k]*input2->rvaluedata[i] + input1->rvaluedata[k]*input2->valuedata[i];
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 131 of file TimesColumnVariable.cc.

References PLearn::Variable::g, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLearn::rowSum().

{
    input1->accg(g*input2);
    input2->accg(rowSum(g*input1));
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 65 of file TimesColumnVariable.h.


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