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

#include <Min2Variable.h>

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

List of all members.

Public Member Functions

 Min2Variable ()
 Default constructor for persistence.
 Min2Variable (Variable *input1, Variable *input2)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual Min2VariabledeepCopy (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 fprop ()
 compute output given input
virtual void bprop ()
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_ ()
 Min2Variable.
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_

Protected Member Functions

void build_ ()
 This does the actual building.

Private Types

typedef BinaryVariable inherited

Detailed Description

elementwise min over 2 elements: min(v1,v2)[i] = min(v1[i],v2[i]) with same dimensions as the input vectors (both must have same length())

Definition at line 56 of file Min2Variable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 58 of file Min2Variable.h.


Constructor & Destructor Documentation

PLearn::Min2Variable::Min2Variable ( ) [inline]

Default constructor for persistence.

Definition at line 62 of file Min2Variable.h.

{}
PLearn::Min2Variable::Min2Variable ( Variable input1,
Variable input2 
)

Definition at line 64 of file Min2Variable.cc.

References build_(), and PLASSERT.

    : inherited(input1, input2, input1->length(), input1->width())
{
    PLASSERT( input1 && input2 );
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

Min2Variable.

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file Min2Variable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file Min2Variable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file Min2Variable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file Min2Variable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file Min2Variable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file Min2Variable.cc.

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

Implements PLearn::Variable.

Definition at line 109 of file Min2Variable.cc.

References PLearn::TVec< T >::data(), grad, PLearn::Variable::gradient, i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), n, and PLASSERT.

{
    PLASSERT( input1 && input2 );
    int n=input1->value.length();
    real* v1=input1->value.data();
    real* v2=input2->value.data();
    real* grad1=input1->gradient.data();
    real* grad2=input2->gradient.data();
    real* grad=gradient.data();
    for (int i=0;i<n;i++)
    {
        if (v1[i]<v2[i])
            grad1[i] += grad[i];
        if (v2[i]<v1[i])
            grad2[i] += grad[i];
    }
}

Here is the call graph for this function:

void PLearn::Min2Variable::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::BinaryVariable.

Definition at line 72 of file Min2Variable.cc.

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

Here is the call graph for this function:

void PLearn::Min2Variable::build_ ( ) [protected]

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 79 of file Min2Variable.cc.

References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), PLERROR, and PLearn::Var::width().

Referenced by build(), and Min2Variable().

{
    if (input1 && input2) {
        if (input1->length() != input2->length()  ||  input1->width() != input2->width())
            PLERROR("IN Min2Variable input1 and input2 must have the same size");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 62 of file Min2Variable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 65 of file Min2Variable.h.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file Min2Variable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 97 of file Min2Variable.cc.

References PLearn::TVec< T >::data(), i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), min, n, PLASSERT, and PLearn::Variable::value.

{
    PLASSERT( input1 && input2 );
    int n=input1->value.length();
    real* v1=input1->value.data();
    real* v2=input2->value.data();
    real* v=value.data();
    for (int i=0;i<n;i++)
        v[i] = std::min(v1[i],v2[i]);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 62 of file Min2Variable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file Min2Variable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file Min2Variable.cc.

void PLearn::Min2Variable::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 88 of file Min2Variable.cc.

References PLearn::BinaryVariable::input1, PLearn::Var::length(), and PLearn::Var::width().

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

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 128 of file Min2Variable.cc.

References PLearn::Variable::g, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLASSERT.

{
    PLASSERT( input1 && input2 );
    input1->accg((input1<input2)*g);
    input2->accg((input2<input1)*g);
}

Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 65 of file Min2Variable.h.


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