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

Variable that is the row of matrix mat indexed by variable input. More...

#include <MatRowVariable.h>

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

List of all members.

Public Member Functions

 MatRowVariable ()
 Default constructor for persistence.
 MatRowVariable (const Mat &mat, Variable *input)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual MatRowVariabledeepCopy (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 ()
 Nothing to do by default.
virtual void bprop ()
 Nothing to do by default.
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_ ()
 MatRowVariable.
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)
 Declare options (data fields) for the class.

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

void build_ ()
 Object-specific post-constructor.

Protected Attributes

Mat m

Private Types

typedef UnaryVariable inherited

Detailed Description

Variable that is the row of matrix mat indexed by variable input.

* Indexing an external Mat or Vec with a variable *

Definition at line 55 of file MatRowVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 57 of file MatRowVariable.h.


Constructor & Destructor Documentation

PLearn::MatRowVariable::MatRowVariable ( ) [inline]

Default constructor for persistence.

Definition at line 64 of file MatRowVariable.h.

{}
PLearn::MatRowVariable::MatRowVariable ( const Mat mat,
Variable input 
)

Definition at line 56 of file MatRowVariable.cc.

References build_().

    : inherited(input, mat.width(), 1), m(mat)
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

MatRowVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file MatRowVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file MatRowVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file MatRowVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file MatRowVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file MatRowVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file MatRowVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 101 of file MatRowVariable.cc.

{}
void PLearn::MatRowVariable::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::UnaryVariable.

Definition at line 63 of file MatRowVariable.cc.

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

Here is the call graph for this function:

void PLearn::MatRowVariable::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::UnaryVariable.

Definition at line 70 of file MatRowVariable.cc.

References PLearn::UnaryVariable::input, and PLERROR.

Referenced by build(), and MatRowVariable().

{
    if(input && !input->isScalar())
        PLERROR("IN MatRowVariable(const Mat& mat, Variable* input) input must have nelems() 1 as it is supposed to be an integer index");
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file MatRowVariable.cc.

void PLearn::MatRowVariable::declareOptions ( OptionList ol) [static]

Declare options (data fields) for the class.

Redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options). Please call the inherited method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).

  static void MyDerivedClass::declareOptions(OptionList& ol)
  {
      declareOption(ol, "inputsize", &MyObject::inputsize_,
                    OptionBase::buildoption,
                    "The size of the input; it must be provided");
      declareOption(ol, "weights", &MyObject::weights,
                    OptionBase::learntoption,
                    "The learned model weights");
      inherited::declareOptions(ol);
  }
Parameters:
olList of options that is progressively being constructed for the current class.

Reimplemented from PLearn::UnaryVariable.

Definition at line 77 of file MatRowVariable.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::UnaryVariable::declareOptions(), and m.

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 67 of file MatRowVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file MatRowVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 97 of file MatRowVariable.cc.

References PLearn::UnaryVariable::input, m, and PLearn::Variable::value.

{  value << m(int(input->value[0])); }
OptionList & PLearn::MatRowVariable::getOptionList ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file MatRowVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file MatRowVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file MatRowVariable.cc.

void PLearn::MatRowVariable::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::UnaryVariable.

Definition at line 91 of file MatRowVariable.cc.

References PLearn::deepCopyField(), m, and PLearn::UnaryVariable::makeDeepCopyFromShallowCopy().

Here is the call graph for this function:

void PLearn::MatRowVariable::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 84 of file MatRowVariable.cc.

References PLearn::TMat< T >::isNotEmpty(), m, and PLearn::TMat< T >::width().

{
    if (m.isNotEmpty())
        l=m.width();
    w = 1;
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 103 of file MatRowVariable.cc.

{}

Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 67 of file MatRowVariable.h.

Definition at line 60 of file MatRowVariable.h.

Referenced by declareOptions(), fprop(), makeDeepCopyFromShallowCopy(), and recomputeSize().


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