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

concatenation of the rows of several variables More...

#include <ConcatRowsVariable.h>

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

List of all members.

Public Member Functions

 ConcatRowsVariable ()
 Default constructor for persistence.
 ConcatRowsVariable (const VarArray &vararray)
 all the variables must have the same number of columns
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ConcatRowsVariabledeepCopy (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_ ()
 ConcatRowsVariable.
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 NaryVariable inherited

Detailed Description

concatenation of the rows of several variables

Definition at line 53 of file ConcatRowsVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::NaryVariable.

Definition at line 55 of file ConcatRowsVariable.h.


Constructor & Destructor Documentation

PLearn::ConcatRowsVariable::ConcatRowsVariable ( ) [inline]

Default constructor for persistence.

Definition at line 59 of file ConcatRowsVariable.h.

{}
PLearn::ConcatRowsVariable::ConcatRowsVariable ( const VarArray vararray)

all the variables must have the same number of columns

Definition at line 57 of file ConcatRowsVariable.cc.

References build_().

    : inherited(vararray.nonNull(), vararray.sumOfLengths(), vararray.maxWidth())
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

ConcatRowsVariable.

Reimplemented from PLearn::NaryVariable.

Definition at line 55 of file ConcatRowsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 55 of file ConcatRowsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 55 of file ConcatRowsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 55 of file ConcatRowsVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 55 of file ConcatRowsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 55 of file ConcatRowsVariable.cc.

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

Implements PLearn::Variable.

Definition at line 104 of file ConcatRowsVariable.cc.

References PLearn::Variable::gradientdata, i, n, PLearn::TVec< T >::size(), and PLearn::NaryVariable::varray.

{
    int k=0;
    for (int n=0; n<varray.size(); n++) {
        Var vn = varray[n];
        for (int i=0; i<vn->nelems(); i++, k++)
            vn->gradientdata[i] += gradientdata[k];
    }
}

Here is the call graph for this function:

void PLearn::ConcatRowsVariable::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::NaryVariable.

Definition at line 64 of file ConcatRowsVariable.cc.

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

Here is the call graph for this function:

void PLearn::ConcatRowsVariable::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::NaryVariable.

Definition at line 71 of file ConcatRowsVariable.cc.

References i, PLearn::TVec< T >::length(), PLERROR, PLearn::TVec< T >::size(), PLearn::NaryVariable::varray, w, and PLearn::Variable::width().

Referenced by build(), and ConcatRowsVariable().

{
    // all the variables must have the same width
    if (varray->length()) {
        int w = varray[0]->width();
        for (int i = 1; i < varray.size(); i++)
            if (w != varray[i]->width())
                PLERROR("ConcatRowsVariable: all non-null variables must have the same width (%d != %d)", w, varray[i]->width());
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 55 of file ConcatRowsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 63 of file ConcatRowsVariable.h.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 55 of file ConcatRowsVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 93 of file ConcatRowsVariable.cc.

References i, n, PLearn::TVec< T >::size(), PLearn::Variable::valuedata, and PLearn::NaryVariable::varray.

{
    int k=0;
    for (int n=0; n<varray.size(); n++) {
        Var vn = varray[n];
        for (int i=0; i<vn->nelems(); i++, k++)
            valuedata[k] = vn->valuedata[i];
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 55 of file ConcatRowsVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 55 of file ConcatRowsVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 55 of file ConcatRowsVariable.cc.

void PLearn::ConcatRowsVariable::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 83 of file ConcatRowsVariable.cc.

References PLearn::VarArray::maxWidth(), PLearn::VarArray::sumOfLengths(), and PLearn::NaryVariable::varray.

{
    if (varray) {
        l = varray.sumOfLengths();
        w = varray.maxWidth(); // Note: actually, all vars have same width.
    } else
        l = w = 0;
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Variable.

Definition at line 126 of file ConcatRowsVariable.cc.

References i, PLearn::TVec< T >::length(), n, PLearn::NaryVariable::resizeRValue(), PLearn::Variable::rValue, PLearn::Variable::rvaluedata, PLearn::TVec< T >::size(), and PLearn::NaryVariable::varray.

{
    if (rValue.length()==0) resizeRValue();
    int k=0;
    for (int n=0; n<varray.size(); n++) {
        Var vn = varray[n];
        for (int i=0; i<vn->nelems(); i++, k++)
            rvaluedata[k] = vn->rvaluedata[i];
    }
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 115 of file ConcatRowsVariable.cc.

References PLearn::Variable::g, PLearn::Var::length(), n, PLearn::TVec< T >::size(), PLearn::NaryVariable::varray, and PLearn::Variable::width().

{
    int k=0;
    for (int n=0; n<varray.size(); n++) {
        Var vn = varray[n];
        vn->accg(new SubMatVariable(g, k, 0, vn->length(), width()));
        k += vn->length();
    }
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::NaryVariable.

Definition at line 63 of file ConcatRowsVariable.h.


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