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

#include <MatrixElementsVariable.h>

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

List of all members.

Public Member Functions

 MatrixElementsVariable ()
 protected default constructor for persistence
 MatrixElementsVariable (Variable *the_expression, const Var &i_index, const Var &j_index, int number_of_i_values, int number_of_j_values, const VarArray &the_parameters)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual MatrixElementsVariabledeepCopy (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 makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.
virtual void fprop ()
 compute output given input
virtual void bprop ()
virtual void fbprop ()
 do both fprop and bprop

Static Public Member Functions

static string _classname_ ()
 MatrixElementsVariable.
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 void declareOptions (OptionList &ol)
 Default constructor for persistence.

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

void build_ ()
 Object-specific post-constructor.

Protected Attributes

Var i
Var j
int ni
int nj
Var expression
VarArray parameters
VarArray full_fproppath
 output(inputs&parameters)
VarArray fproppath
 output(inputs)
VarArray bproppath
 output(parameters)

Private Types

typedef NaryVariable inherited

Detailed Description

Definition at line 52 of file MatrixElementsVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::NaryVariable.

Definition at line 54 of file MatrixElementsVariable.h.


Constructor & Destructor Documentation

PLearn::MatrixElementsVariable::MatrixElementsVariable ( ) [inline]

protected default constructor for persistence

Definition at line 70 of file MatrixElementsVariable.h.

        : i(), j(), ni(), nj(), expression(), parameters(), full_fproppath(), fproppath(),
          bproppath()
    {}
PLearn::MatrixElementsVariable::MatrixElementsVariable ( Variable the_expression,
const Var i_index,
const Var j_index,
int  number_of_i_values,
int  number_of_j_values,
const VarArray the_parameters 
)

Definition at line 62 of file MatrixElementsVariable.cc.

References build_().

    : inherited(the_parameters, number_of_i_values, number_of_j_values), i(i_index), 
      j(j_index), ni(number_of_i_values), nj(number_of_j_values), expression(the_expression), 
      parameters(the_parameters)
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

MatrixElementsVariable.

Reimplemented from PLearn::NaryVariable.

Definition at line 59 of file MatrixElementsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 59 of file MatrixElementsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 59 of file MatrixElementsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 59 of file MatrixElementsVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 59 of file MatrixElementsVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 59 of file MatrixElementsVariable.cc.

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

Implements PLearn::Variable.

Definition at line 151 of file MatrixElementsVariable.cc.

References PLearn::VarArray::bprop(), bproppath, PLearn::VarArray::clearGradient(), expression, PLearn::VarArray::fprop(), fproppath, full_fproppath, i, j, PLearn::Variable::matGradient, ni, and nj.

{
    int ii,jj;

    for (ii=0;ii<ni;ii++)
    {
        i->value[0]=ii;
        for (jj=0;jj<nj;jj++)
        {
            j->value[0]=jj;
            if (ii==0 && jj==0)
                // effect of parameters is computed only once
                full_fproppath.fprop();
            else
                fproppath.fprop();
            bproppath.clearGradient();
            // PASCAL: peut-etre qu'ici on devrait avoir += ?
            // (si l'expression est une Var utilisee ailleurs!)
            // REPONSE: Non! (expression ne devrait etre utilisee 
            // nulle part ailleurs. To do: utilisation de Func 
            // pour le garantir...)
            expression->gradient[0] = matGradient(ii,jj);
            bproppath.bprop();
        }
    }
}

Here is the call graph for this function:

void PLearn::MatrixElementsVariable::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 MatrixElementsVariable.cc.

References PLearn::NaryVariable::build().

Here is the call graph for this function:

void PLearn::MatrixElementsVariable::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 79 of file MatrixElementsVariable.cc.

References bproppath, expression, fproppath, full_fproppath, i, j, parameters, PLERROR, PLearn::propagationPath(), and PLearn::TVec< T >::size().

Referenced by MatrixElementsVariable().

{
    if (i && j && (parameters.size() > 0) && expression) {
        if (!i->isScalar())
            PLERROR("MatrixElementsVariable expect a scalar index Var i_index");
        if (!j->isScalar())
            PLERROR("MatrixElementsVariable expect a scalar index Var j_index");

        full_fproppath = propagationPath(parameters&(VarArray)i&(VarArray)j, expression);
        fproppath = propagationPath(i&j, expression);
        bproppath = propagationPath(parameters, expression);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 59 of file MatrixElementsVariable.cc.

void PLearn::MatrixElementsVariable::declareOptions ( OptionList ol) [static]
static const PPath& PLearn::MatrixElementsVariable::declaringFile ( ) [inline, static]

Reimplemented from PLearn::NaryVariable.

Definition at line 77 of file MatrixElementsVariable.h.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 59 of file MatrixElementsVariable.cc.

void PLearn::MatrixElementsVariable::fbprop ( ) [virtual]

do both fprop and bprop

Reimplemented from PLearn::Variable.

Definition at line 179 of file MatrixElementsVariable.cc.

References PLearn::VarArray::bprop(), bproppath, PLearn::VarArray::clearGradient(), expression, PLearn::VarArray::fprop(), fproppath, full_fproppath, i, j, PLearn::Variable::matGradient, PLearn::Variable::matValue, ni, and nj.

{
    int ii,jj;

    for (ii=0;ii<ni;ii++)
    {
        i->value[0]=ii;
        for (jj=0;jj<nj;jj++)
        {
            j->value[0]=jj;
            if (ii==0 && jj==0)
                // effect of parameters is computed only once
                full_fproppath.fprop();
            else
                fproppath.fprop();
            matValue(ii,jj) = expression->value[0];
            bproppath.clearGradient();
            // PASCAL: peut-etre qu'ici on devrait avoir += ?
            // (si l'expression est une Var utilisee ailleurs!)
            // REPONSE: Non! (expression ne devrait etre utilisee 
            // nulle part ailleurs. To do: utilisation de Func 
            // pour le garantir...)
            expression->gradient[0] = matGradient(ii,jj);
            bproppath.bprop();
        }
    }
}

Here is the call graph for this function:

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

compute output given input

Implements PLearn::Variable.

Definition at line 130 of file MatrixElementsVariable.cc.

References expression, PLearn::VarArray::fprop(), fproppath, full_fproppath, i, j, PLearn::Variable::matValue, ni, and nj.

{
    int ii,jj;

    for (ii=0;ii<ni;ii++)
    {
        i->value[0]=ii;
        for (jj=0;jj<nj;jj++)
        {
            j->value[0]=jj;
            if (ii==0 && jj==0)
                // effect of parameters is computed only once
                full_fproppath.fprop();
            else
                fproppath.fprop();
            matValue(ii,jj) = expression->value[0];
        }
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 59 of file MatrixElementsVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 59 of file MatrixElementsVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 59 of file MatrixElementsVariable.cc.

void PLearn::MatrixElementsVariable::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.

This needs to be overridden by every class that adds "complex" data members to the class, such as Vec, Mat, PP<Something>, etc. Typical implementation:

  void CLASS_OF_THIS::makeDeepCopyFromShallowCopy(CopiesMap& copies)
  {
      inherited::makeDeepCopyFromShallowCopy(copies);
      deepCopyField(complex_data_member1, copies);
      deepCopyField(complex_data_member2, copies);
      ...
  }
Parameters:
copiesA map used by the deep-copy mechanism to keep track of already-copied objects.

Reimplemented from PLearn::NaryVariable.

Definition at line 117 of file MatrixElementsVariable.cc.

References bproppath, PLearn::deepCopyField(), expression, fproppath, full_fproppath, i, j, PLearn::NaryVariable::makeDeepCopyFromShallowCopy(), parameters, and PLearn::varDeepCopyField().

Here is the call graph for this function:

void PLearn::MatrixElementsVariable::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 105 of file MatrixElementsVariable.cc.

References ni, and nj.

{ l=ni; w=nj; }

Member Data Documentation

Reimplemented from PLearn::NaryVariable.

Definition at line 77 of file MatrixElementsVariable.h.

output(parameters)

Definition at line 66 of file MatrixElementsVariable.h.

Referenced by bprop(), build_(), fbprop(), and makeDeepCopyFromShallowCopy().

output(inputs)

Definition at line 65 of file MatrixElementsVariable.h.

Referenced by bprop(), build_(), fbprop(), fprop(), and makeDeepCopyFromShallowCopy().

output(inputs&parameters)

Definition at line 64 of file MatrixElementsVariable.h.

Referenced by bprop(), build_(), fbprop(), fprop(), and makeDeepCopyFromShallowCopy().

Definition at line 59 of file MatrixElementsVariable.h.

Referenced by bprop(), declareOptions(), fbprop(), fprop(), and recomputeSize().

Definition at line 60 of file MatrixElementsVariable.h.

Referenced by bprop(), declareOptions(), fbprop(), fprop(), and recomputeSize().

Definition at line 62 of file MatrixElementsVariable.h.

Referenced by build_(), declareOptions(), and makeDeepCopyFromShallowCopy().


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