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

Compute the sum of all elements in the input Var. More...

#include <SumVariable.h>

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

List of all members.

Public Member Functions

 SumVariable ()
 Default constructor for persistence.
 SumVariable (Variable *input)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual SumVariabledeepCopy (CopiesMap &copies) const
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_ ()
 SumVariable.
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 UnaryVariable inherited

Detailed Description

Compute the sum of all elements in the input Var.

This Variable returns the sum of all elements of its single input Variable.

Definition at line 59 of file SumVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file SumVariable.h.


Constructor & Destructor Documentation

PLearn::SumVariable::SumVariable ( ) [inline]

Default constructor for persistence.

Definition at line 65 of file SumVariable.h.

{}
PLearn::SumVariable::SumVariable ( Variable input)

Definition at line 62 of file SumVariable.cc.

    : inherited(input, 1, 1)
{}

Member Function Documentation

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

SumVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 60 of file SumVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 60 of file SumVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 60 of file SumVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 60 of file SumVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 60 of file SumVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 60 of file SumVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 78 of file SumVariable.cc.

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

{
    real grd = gradientdata[0];
    for(int k=0; k<input->nelems(); k++)
        input->gradientdata[k] += grd;
}
string PLearn::SumVariable::classname ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 60 of file SumVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 68 of file SumVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 60 of file SumVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 69 of file SumVariable.cc.

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

{
    real sum = 0.0;
    for(int k=0; k<input->nelems(); k++)
        sum += input->valuedata[k];
    valuedata[0] = sum;
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 60 of file SumVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 60 of file SumVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 60 of file SumVariable.cc.

void PLearn::SumVariable::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 66 of file SumVariable.cc.

{ l=1; w=1; }
void PLearn::SumVariable::rfprop ( ) [virtual]

Reimplemented from PLearn::Variable.

Definition at line 93 of file SumVariable.cc.

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

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

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 86 of file SumVariable.cc.

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

{
    input->accg(g);
}

Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 68 of file SumVariable.h.


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