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

adds a scalar constant to a matrix var More...

#include <PlusConstantVariable.h>

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

List of all members.

Public Member Functions

 PlusConstantVariable ()
 Default constructor.
 PlusConstantVariable (Variable *input, real c, bool call_build_=true)
 Convenience constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual PlusConstantVariabledeepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
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_ ()
 PlusConstantVariable.
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

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

Private Member Functions

void build_ ()
 Object-specific post-constructor.

Detailed Description

adds a scalar constant to a matrix var

* Plus... *

Definition at line 57 of file PlusConstantVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file PlusConstantVariable.h.


Constructor & Destructor Documentation

PLearn::PlusConstantVariable::PlusConstantVariable ( )

Default constructor.

Definition at line 60 of file PlusConstantVariable.cc.

                                          :
    cst(0)
{}
PLearn::PlusConstantVariable::PlusConstantVariable ( Variable input,
real  c,
bool  call_build_ = true 
)

Convenience constructor.

Definition at line 64 of file PlusConstantVariable.cc.

References build_().

                                                            :
    inherited(input, input->length(), input->width(), call_build_),
    cst(c)
{
    if (call_build_)
        build_();
}

Here is the call graph for this function:


Member Function Documentation

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

PlusConstantVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PlusConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PlusConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PlusConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PlusConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PlusConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PlusConstantVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 115 of file PlusConstantVariable.cc.

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

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

Here is the call graph for this function:

void PLearn::PlusConstantVariable::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 76 of file PlusConstantVariable.cc.

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

Here is the call graph for this function:

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

Definition at line 84 of file PlusConstantVariable.cc.

Referenced by build(), and PlusConstantVariable().

                                  {
    // Nothing to do here.
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PlusConstantVariable.cc.

void PLearn::PlusConstantVariable::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 91 of file PlusConstantVariable.cc.

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

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 72 of file PlusConstantVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PlusConstantVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 108 of file PlusConstantVariable.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::PlusConstantVariable::getOptionList ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PlusConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PlusConstantVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PlusConstantVariable.cc.

virtual string PLearn::PlusConstantVariable::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 76 of file PlusConstantVariable.h.

References PLearn::tostring().

    { return string("PlusConstant (+ ")+tostring(cst)+")"; }

Here is the call graph for this function:

void PLearn::PlusConstantVariable::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 99 of file PlusConstantVariable.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::PlusConstantVariable::rfprop ( ) [virtual]

Reimplemented from PLearn::Variable.

Definition at line 129 of file PlusConstantVariable.cc.

References 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];
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 122 of file PlusConstantVariable.cc.

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

{
    input->accg(g);
}

Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 72 of file PlusConstantVariable.h.

Definition at line 63 of file PlusConstantVariable.h.

Referenced by declareOptions(), and fprop().


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