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

multiplies a matrix var by a scalar constant More...

#include <TimesConstantVariable.h>

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

List of all members.

Public Member Functions

 TimesConstantVariable ()
 Default constructor for persistence.
 TimesConstantVariable (Variable *input, real c)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual TimesConstantVariabledeepCopy (CopiesMap &copies) const
virtual string info () const
 Returns a bit more informative string about object (default returns classname())
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 ()
 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
virtual void rfprop ()

Static Public Member Functions

static string _classname_ ()
 TimesConstantVariable.
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 ()

Public Attributes

real cst
 The constant.

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declare options (data fields) for the class.

Private Types

typedef UnaryVariable inherited

Detailed Description

multiplies a matrix var by a scalar constant

* Times... *

Definition at line 57 of file TimesConstantVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file TimesConstantVariable.h.


Constructor & Destructor Documentation

PLearn::TimesConstantVariable::TimesConstantVariable ( ) [inline]

Default constructor for persistence.

Definition at line 67 of file TimesConstantVariable.h.

: cst() {}
PLearn::TimesConstantVariable::TimesConstantVariable ( Variable input,
real  c 
)

Definition at line 56 of file TimesConstantVariable.cc.

    : inherited(input, input->length(), input->width()), cst(c) 
{}

Member Function Documentation

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

TimesConstantVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TimesConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TimesConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TimesConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TimesConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TimesConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TimesConstantVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 84 of file TimesConstantVariable.cc.

References cst, PLearn::Variable::gradientdata, PLearn::UnaryVariable::input, and PLearn::Variable::nelems().

{
    for(int k=0; k<nelems(); k++)
        input->gradientdata[k] += cst*gradientdata[k];
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TimesConstantVariable.cc.

void PLearn::TimesConstantVariable::declareOptions ( OptionList ol) [static, protected]

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 62 of file TimesConstantVariable.cc.

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

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 70 of file TimesConstantVariable.h.

{ return string("TimesConstant (* ")+tostring(cst)+")"; }
TimesConstantVariable * PLearn::TimesConstantVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TimesConstantVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 77 of file TimesConstantVariable.cc.

References cst, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), and PLearn::Variable::valuedata.

{
    for(int k=0; k<nelems(); k++)
        valuedata[k] = input->valuedata[k] * cst;
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TimesConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TimesConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TimesConstantVariable.cc.

virtual string PLearn::TimesConstantVariable::info ( ) const [inline, virtual]

Returns a bit more informative string about object (default returns classname())

Returns:
Information about the object

Reimplemented from PLearn::Object.

Definition at line 73 of file TimesConstantVariable.h.

References PLearn::tostring().

    { return string("TimesConstant (* ")+tostring(cst)+")"; }

Here is the call graph for this function:

void PLearn::TimesConstantVariable::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 68 of file TimesConstantVariable.cc.

References PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().

{
    if (input) {
        l = input->length();
        w = input->width();
    } else
        l = w = 0;
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Variable.

Definition at line 98 of file TimesConstantVariable.cc.

References cst, PLearn::UnaryVariable::input, PLearn::TVec< T >::length(), PLearn::Variable::nelems(), PLearn::UnaryVariable::resizeRValue(), PLearn::Variable::rValue, and PLearn::Variable::rvaluedata.

{
    if (rValue.length()==0) resizeRValue();
    for(int k=0; k<nelems(); k++)
        rvaluedata[k] = input->rvaluedata[k]*cst;
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 91 of file TimesConstantVariable.cc.

References cst, PLearn::Variable::g, and PLearn::UnaryVariable::input.

{
    input->accg(g*cst);
}

Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 70 of file TimesConstantVariable.h.

The constant.

Definition at line 63 of file TimesConstantVariable.h.

Referenced by bprop(), declareOptions(), fprop(), rfprop(), and symbolicBprop().


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