PLearn 0.1
|
A scalar var; equal 1 if input1==input2, 0 otherwise. More...
#include <EqualVariable.h>
Public Member Functions | |
EqualVariable () | |
Default constructor for persistence. | |
EqualVariable (Variable *input1, Variable *input2) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual EqualVariable * | deepCopy (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_ () |
EqualVariable. | |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Member Functions | |
void | build_ () |
This does the actual building. | |
Private Types | |
typedef BinaryVariable | inherited |
A scalar var; equal 1 if input1==input2, 0 otherwise.
Definition at line 54 of file EqualVariable.h.
typedef BinaryVariable PLearn::EqualVariable::inherited [private] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 56 of file EqualVariable.h.
PLearn::EqualVariable::EqualVariable | ( | ) | [inline] |
string PLearn::EqualVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 56 of file EqualVariable.cc.
OptionList & PLearn::EqualVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 56 of file EqualVariable.cc.
RemoteMethodMap & PLearn::EqualVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 56 of file EqualVariable.cc.
Reimplemented from PLearn::BinaryVariable.
Definition at line 56 of file EqualVariable.cc.
Object * PLearn::EqualVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 56 of file EqualVariable.cc.
StaticInitializer EqualVariable::_static_initializer_ & PLearn::EqualVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 56 of file EqualVariable.cc.
void PLearn::EqualVariable::bprop | ( | ) | [virtual] |
void PLearn::EqualVariable::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 65 of file EqualVariable.cc.
References PLearn::BinaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::EqualVariable::build_ | ( | ) | [protected] |
This does the actual building.
Reimplemented from PLearn::BinaryVariable.
Definition at line 72 of file EqualVariable.cc.
References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), PLERROR, and PLearn::Var::width().
Referenced by build(), and EqualVariable().
{ if (input1 && input2) { if (input1->length() != input2->length() || input1->width() != input2->width()) PLERROR("IN EqualVariable(Variable* input1, Variable* input2) input1 and input2 must have the same size"); } }
string PLearn::EqualVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 56 of file EqualVariable.cc.
static const PPath& PLearn::EqualVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 63 of file EqualVariable.h.
: void build_();
EqualVariable * PLearn::EqualVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 56 of file EqualVariable.cc.
void PLearn::EqualVariable::fprop | ( | ) | [virtual] |
compute output given input
Implements PLearn::Variable.
Definition at line 84 of file EqualVariable.cc.
References PLearn::fast_exact_is_equal(), i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Variable::nelems(), and PLearn::Variable::valuedata.
{ bool equal=true; for (int i=0; i<nelems(); i++) equal = equal && fast_exact_is_equal(input1->valuedata[i],input2->valuedata[i]); valuedata[0]=equal; }
OptionList & PLearn::EqualVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 56 of file EqualVariable.cc.
OptionMap & PLearn::EqualVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 56 of file EqualVariable.cc.
RemoteMethodMap & PLearn::EqualVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 56 of file EqualVariable.cc.
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 81 of file EqualVariable.cc.
{ l=1; w=1; }
void PLearn::EqualVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 97 of file EqualVariable.cc.
{}
Reimplemented from PLearn::BinaryVariable.
Definition at line 63 of file EqualVariable.h.