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

concatenation of the columns of several variables More...

#include <ConcatColumnsVariable.h>

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

List of all members.

Public Member Functions

 ConcatColumnsVariable ()
 Default constructor.
 ConcatColumnsVariable (const VarArray &vararray, bool call_build_=true)
 Convenience constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ConcatColumnsVariabledeepCopy (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_ ()
 ConcatColumnsVariable.
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 NaryVariable inherited

Private Member Functions

void build_ ()
 Object-specific post-constructor.

Detailed Description

concatenation of the columns of several variables

Definition at line 53 of file ConcatColumnsVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::NaryVariable.

Definition at line 55 of file ConcatColumnsVariable.h.


Constructor & Destructor Documentation

PLearn::ConcatColumnsVariable::ConcatColumnsVariable ( ) [inline]

Default constructor.

Definition at line 60 of file ConcatColumnsVariable.h.

{}
PLearn::ConcatColumnsVariable::ConcatColumnsVariable ( const VarArray vararray,
bool  call_build_ = true 
)

Convenience constructor.

Definition at line 61 of file ConcatColumnsVariable.cc.

References build_().

                                                              :
    inherited(vararray.nonNull(), vararray.maxLength(), vararray.sumOfWidths(),
              call_build_)
{
    if (call_build_)
        build_();
}

Here is the call graph for this function:


Member Function Documentation

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

ConcatColumnsVariable.

Reimplemented from PLearn::NaryVariable.

Definition at line 56 of file ConcatColumnsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 56 of file ConcatColumnsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 56 of file ConcatColumnsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 56 of file ConcatColumnsVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file ConcatColumnsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 56 of file ConcatColumnsVariable.cc.

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

Implements PLearn::Variable.

Definition at line 119 of file ConcatColumnsVariable.cc.

References PLearn::Variable::gradientdata, i, j, PLearn::TMat< T >::length(), m, PLearn::Variable::matValue, PLearn::TMat< T >::mod(), PLearn::TVec< T >::size(), and PLearn::NaryVariable::varray.

{
    int n_rows = matValue.length();
    int m_start = 0;
    int mod = matValue.mod();
    for (int m=0;m<varray.size();m++)
    {
        real* mp = varray[m]->gradientdata;
        int n_cols = varray[m]->matGradient.width();
        real* p = &gradientdata[m_start];
        for (int i=0;i<n_rows;i++,p+=mod)
            for (int j=0;j<n_cols;j++,mp++)
                *mp += p[j];
        m_start+=n_cols;
    }
}

Here is the call graph for this function:

void PLearn::ConcatColumnsVariable::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 73 of file ConcatColumnsVariable.cc.

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

Here is the call graph for this function:

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

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 82 of file ConcatColumnsVariable.cc.

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

Referenced by build(), and ConcatColumnsVariable().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 56 of file ConcatColumnsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 65 of file ConcatColumnsVariable.h.

:

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

Reimplemented from PLearn::NaryVariable.

Definition at line 56 of file ConcatColumnsVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 101 of file ConcatColumnsVariable.cc.

References i, j, PLearn::TMat< T >::length(), m, PLearn::Variable::matValue, PLearn::TMat< T >::mod(), PLearn::TVec< T >::size(), PLearn::Variable::valuedata, and PLearn::NaryVariable::varray.

{
    int n_rows = matValue.length();
    int m_start = 0;
    int mod = matValue.mod();
    for (int m=0;m<varray.size();m++)
    {
        real* mp = varray[m]->valuedata;
        int n_cols = varray[m]->matValue.width();
        real* p = &valuedata[m_start];
        for (int i=0;i<n_rows;i++,p+=mod)
            for (int j=0;j<n_cols;j++,mp++)
                p[j] = *mp;
        m_start+=n_cols;
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 56 of file ConcatColumnsVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file ConcatColumnsVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 56 of file ConcatColumnsVariable.cc.

void PLearn::ConcatColumnsVariable::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 92 of file ConcatColumnsVariable.cc.

References PLearn::VarArray::maxLength(), PLearn::VarArray::sumOfWidths(), and PLearn::NaryVariable::varray.

{
    if (varray) {
        l = varray.maxLength();
        w = varray.sumOfWidths();
    } else
        l = w = 0;
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 137 of file ConcatColumnsVariable.cc.

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

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

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::NaryVariable.

Definition at line 65 of file ConcatColumnsVariable.h.


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