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

#include <ColumnIndexVariable.h>

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

List of all members.

Public Member Functions

 ColumnIndexVariable ()
 Default constructor for persistence.
 ColumnIndexVariable (Variable *input1, Variable *input2)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ColumnIndexVariabledeepCopy (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

Static Public Member Functions

static string _classname_ ()
 ColumnIndexVariable.
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_ ()
 This does the actual building.

Private Types

typedef BinaryVariable inherited

Detailed Description

Definition at line 53 of file ColumnIndexVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 55 of file ColumnIndexVariable.h.


Constructor & Destructor Documentation

PLearn::ColumnIndexVariable::ColumnIndexVariable ( ) [inline]

Default constructor for persistence.

Definition at line 59 of file ColumnIndexVariable.h.

{}
PLearn::ColumnIndexVariable::ColumnIndexVariable ( Variable input1,
Variable input2 
)

Definition at line 61 of file ColumnIndexVariable.cc.

References build_().

    : inherited(input1, input2, 1, input1->width())
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

ColumnIndexVariable.

Reimplemented from PLearn::BinaryVariable.

Definition at line 59 of file ColumnIndexVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 59 of file ColumnIndexVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 59 of file ColumnIndexVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 59 of file ColumnIndexVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 59 of file ColumnIndexVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 59 of file ColumnIndexVariable.cc.

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

Implements PLearn::Variable.

Definition at line 115 of file ColumnIndexVariable.cc.

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

{
    for (int i=0; i<input2->size(); i++)
    {
        int num = (int) input2->valuedata[i];
        input1->gradientdata[num*input1->width()+i] += gradientdata[i];
    }
}

Here is the call graph for this function:

void PLearn::ColumnIndexVariable::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 70 of file ColumnIndexVariable.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 79 of file ColumnIndexVariable.cc.

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

Referenced by build(), and ColumnIndexVariable().

{
    if (input2 && !input2->isVec())
        PLERROR("In ColumnIndexVariable::build_ - input2 must be a vector "
                "variable representing the indices of input1");
    if (input1 && input2 && input1->width() != input2->size())
        PLERROR("In ColumnIndexVariable::build_ - input1's width (%d) "
                "should be equal to input2's size (%d)",
                input1->width(), input2->size());
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 59 of file ColumnIndexVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file ColumnIndexVariable.h.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 59 of file ColumnIndexVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 105 of file ColumnIndexVariable.cc.

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

{
    for (int i=0; i<input2->size(); i++)
    {
        int num = (int)input2->valuedata[i];
        valuedata[i] = input1->valuedata[num*input1->width()+i];
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 59 of file ColumnIndexVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 59 of file ColumnIndexVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 59 of file ColumnIndexVariable.cc.

void PLearn::ColumnIndexVariable::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 93 of file ColumnIndexVariable.cc.

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

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

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 125 of file ColumnIndexVariable.cc.

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

{
    input1->accg(new IndexAtPositionVariable(g,input2,input1->length(),input1->width()));
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file ColumnIndexVariable.h.


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