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

Variable that is the row of the input1 variable indexed by the input2 variable. More...

#include <VarRowVariable.h>

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

List of all members.

Public Member Functions

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

Variable that is the row of the input1 variable indexed by the input2 variable.

Definition at line 54 of file VarRowVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 56 of file VarRowVariable.h.


Constructor & Destructor Documentation

PLearn::VarRowVariable::VarRowVariable ( ) [inline]

Default constructor for persistence.

Definition at line 60 of file VarRowVariable.h.

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

Definition at line 55 of file VarRowVariable.cc.

References build_().

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

Here is the call graph for this function:


Member Function Documentation

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

VarRowVariable.

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file VarRowVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file VarRowVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file VarRowVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file VarRowVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file VarRowVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file VarRowVariable.cc.

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

Implements PLearn::Variable.

Definition at line 95 of file VarRowVariable.cc.

References PLearn::Variable::gradient, i, PLearn::BinaryVariable::input1, and PLearn::BinaryVariable::input2.

{
    int i = int(input2->valuedata[0]);
    Vec input1_gradient_i = input1->matGradient(i);
    input1_gradient_i += gradient;
    input1->updateRow(i);
}
void PLearn::VarRowVariable::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 62 of file VarRowVariable.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 69 of file VarRowVariable.cc.

References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLERROR.

Referenced by build(), and VarRowVariable().

{
    if (input1 && input2) {
        if (!input2->isScalar())
            PLERROR("IN VarRowVariable(Variable* input1, Variable* input2) input2 must be scalar as it is supposed to be an integer index");
        input1->allowPartialUpdates();
    }
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 53 of file VarRowVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 63 of file VarRowVariable.h.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file VarRowVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 88 of file VarRowVariable.cc.

References i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLearn::Variable::value.

{
    int i = int(input2->valuedata[0]);
    value << input1->matValue(i);
}
OptionList & PLearn::VarRowVariable::getOptionList ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 53 of file VarRowVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file VarRowVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file VarRowVariable.cc.

void PLearn::VarRowVariable::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 79 of file VarRowVariable.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::VarRowVariable::rfprop ( ) [virtual]

Reimplemented from PLearn::Variable.

Definition at line 110 of file VarRowVariable.cc.

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

{
    if (rValue.length()==0) resizeRValue(); 
    int i = int(input2->valuedata[0]);
    rValue << input1->matRValue(i);
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 104 of file VarRowVariable.cc.

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

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

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 63 of file VarRowVariable.h.


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