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

#include <ArgminVariable.h>

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

List of all members.

Public Member Functions

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

Static Public Member Functions

static string _classname_ ()
 ArgminVariable.
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

This variable computes the index of the minimum value in the input It is a scalar variable if the input is a vector (single row or single column) Otherwise it is a single-column of length() 2 containing the (i,j) coordinate of the min

Definition at line 56 of file ArgminVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file ArgminVariable.h.


Constructor & Destructor Documentation

PLearn::ArgminVariable::ArgminVariable ( ) [inline]

Default constructor for persistence.

Definition at line 62 of file ArgminVariable.h.

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

Definition at line 55 of file ArgminVariable.cc.

    : inherited(input, input->isVec()?1:2, 1)
{}

Member Function Documentation

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

ArgminVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file ArgminVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file ArgminVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file ArgminVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file ArgminVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file ArgminVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file ArgminVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 105 of file ArgminVariable.cc.

{}
string PLearn::ArgminVariable::classname ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file ArgminVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 65 of file ArgminVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file ArgminVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 66 of file ArgminVariable.cc.

References PLearn::argmin(), i, PLearn::UnaryVariable::input, j, PLearn::Var::length(), PLearn::Variable::valuedata, and PLearn::Var::width().

{
    real minval = input->valuedata[0];
    if (input->isVec())
    {
        int argmin = 0;
        for(int i=1; i<input->nelems(); i++)
        {
            real val = input->valuedata[i];
            if(val<minval)
            {
                minval = val;
                argmin = i;
            }
        }
        valuedata[0] = argmin;
    }
    else
    {
        int k = 0;
        int argmin_i = 0;
        int argmin_j = 0;
        for(int i=0; i<input->length(); i++)
            for(int j=0; j<input->width(); j++, k++)
            {
                real val = input->valuedata[k];
                if(val<minval)
                {
                    minval = val;
                    argmin_i = i;
                    argmin_j = j;
                }
            }
        valuedata[0] = argmin_i;
        valuedata[1] = argmin_j;
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file ArgminVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file ArgminVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file ArgminVariable.cc.

void PLearn::ArgminVariable::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 59 of file ArgminVariable.cc.

References PLearn::UnaryVariable::input.

{
    if (input)
        l = input->isVec() ? 1 : 2;
    w=1;
}
void PLearn::ArgminVariable::symbolicBprop ( ) [virtual]

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

Reimplemented from PLearn::Variable.

Definition at line 107 of file ArgminVariable.cc.

{}

Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 65 of file ArgminVariable.h.


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