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

#include <InvertElementsVariable.h>

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

List of all members.

Public Member Functions

 InvertElementsVariable ()
 Default constructor for persistence.
 InvertElementsVariable (Variable *input)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual InvertElementsVariabledeepCopy (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_ ()
 InvertElementsVariable.
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

Definition at line 52 of file InvertElementsVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file InvertElementsVariable.h.


Constructor & Destructor Documentation

PLearn::InvertElementsVariable::InvertElementsVariable ( ) [inline]

Default constructor for persistence.

Definition at line 58 of file InvertElementsVariable.h.

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

Definition at line 56 of file InvertElementsVariable.cc.

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

Member Function Documentation

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

InvertElementsVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file InvertElementsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file InvertElementsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file InvertElementsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file InvertElementsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file InvertElementsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file InvertElementsVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 77 of file InvertElementsVariable.cc.

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

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

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file InvertElementsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file InvertElementsVariable.h.

{ return new InvertElementsVariable(v); }
InvertElementsVariable * PLearn::InvertElementsVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file InvertElementsVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 70 of file InvertElementsVariable.cc.

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

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

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file InvertElementsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file InvertElementsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file InvertElementsVariable.cc.

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

Reimplemented from PLearn::Variable.

Definition at line 95 of file InvertElementsVariable.cc.

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

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

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 87 of file InvertElementsVariable.cc.

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

{
    Var v = input * input;
    input->accg(-g/v);
}

Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file InvertElementsVariable.h.


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