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

#include <SubMatTransposeVariable.h>

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

List of all members.

Public Member Functions

 SubMatTransposeVariable ()
 Default constructor for persistence.
 SubMatTransposeVariable (Variable *v, int i, int j, int the_length, int the_width)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual SubMatTransposeVariabledeepCopy (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 ()
 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_ ()
 SubMatTransposeVariable.
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 void declareOptions (OptionList &ol)
 Declare options (data fields) for the class.

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Attributes

int startk
int length_
int width_
int i_
int j_

Private Types

typedef UnaryVariable inherited

Private Member Functions

void build_ ()
 Object-specific post-constructor.

Detailed Description

Definition at line 52 of file SubMatTransposeVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 57 of file SubMatTransposeVariable.h.


Constructor & Destructor Documentation

PLearn::SubMatTransposeVariable::SubMatTransposeVariable ( ) [inline]

Default constructor for persistence.

Definition at line 68 of file SubMatTransposeVariable.h.

: startk(0), length_(0), width_(0), i_(0), j_(0) {}
PLearn::SubMatTransposeVariable::SubMatTransposeVariable ( Variable v,
int  i,
int  j,
int  the_length,
int  the_width 
)

Definition at line 55 of file SubMatTransposeVariable.cc.

References build_().

    : inherited(v, the_width, the_length),
      startk(i*v->length()+j),
      length_(the_length),
      width_(the_width),
      i_(i),
      j_(j)
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

SubMatTransposeVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubMatTransposeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubMatTransposeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubMatTransposeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubMatTransposeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubMatTransposeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubMatTransposeVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 119 of file SubMatTransposeVariable.cc.

References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, j, PLearn::Var::length(), PLearn::Variable::length(), PLearn::Variable::nelems(), startk, PLearn::Variable::width(), and PLearn::Var::width().

{
    if(input->length()==1 || input->width()==1) // optimized version for this special case...
    {
        real* inputdata = input->gradientdata+startk;
        for(int k=0; k<nelems(); k++)
            inputdata[k] += gradientdata[k];
    }
    else // general case
    {
        real* inputrowdata = input->gradientdata+startk;
        int thiskcolstart = 0; // element index of start of column in this var
        for(int i=0; i<width(); i++) // the width() of this var is the length() of the submat
        {
            int thisk = thiskcolstart++;
            for(int j=0; j<length(); j++, thisk+=width()) // the length() of this var is the width() of the submat
                inputrowdata[j] += gradientdata[thisk];
            inputrowdata += input->width();
        }
    }
}

Here is the call graph for this function:

void PLearn::SubMatTransposeVariable::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::UnaryVariable.

Definition at line 66 of file SubMatTransposeVariable.cc.

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

Here is the call graph for this function:

void PLearn::SubMatTransposeVariable::build_ ( ) [private]

Object-specific post-constructor.

This method should be redefined in subclasses and do the actual building of the object according to previously set option fields. Constructors can just set option fields, and then call build_. This method is NOT virtual, and will typically be called only from three places: a constructor, the public virtual build() method, and possibly the public virtual read method (which calls its parent's read). build_() can assume that its parent's build_() has already been called.

Reimplemented from PLearn::UnaryVariable.

Definition at line 72 of file SubMatTransposeVariable.cc.

References i_, PLearn::UnaryVariable::input, j_, PLearn::Var::length(), PLERROR, startk, and PLearn::Var::width().

Referenced by build(), and SubMatTransposeVariable().

{
    if (input) {
        // input is v from constructor
        if (i_ < 0 || i_ + length_ > input->length() || j_ < 0 || j_ + width_ > input->width())
            PLERROR("In SubMatTransposeVariable: requested sub-matrix is out of matrix bounds");
        startk = i_ * input->length() + j_;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubMatTransposeVariable.cc.

void PLearn::SubMatTransposeVariable::declareOptions ( OptionList ol) [static]

Declare options (data fields) for the class.

Redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options). Please call the inherited method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).

  static void MyDerivedClass::declareOptions(OptionList& ol)
  {
      declareOption(ol, "inputsize", &MyObject::inputsize_,
                    OptionBase::buildoption,
                    "The size of the input; it must be provided");
      declareOption(ol, "weights", &MyObject::weights,
                    OptionBase::learntoption,
                    "The learned model weights");
      inherited::declareOptions(ol);
  }
Parameters:
olList of options that is progressively being constructed for the current class.

Reimplemented from PLearn::UnaryVariable.

Definition at line 83 of file SubMatTransposeVariable.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::UnaryVariable::declareOptions(), i_, j_, length_, startk, and width_.

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 71 of file SubMatTransposeVariable.h.

:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubMatTransposeVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 96 of file SubMatTransposeVariable.cc.

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

{
    if(input->length()==1 || input->width()==1) // optimized version for this special case...
    {
        real* inputdata = input->valuedata+startk;
        for(int k=0; k<nelems(); k++)
            valuedata[k] = inputdata[k];
    }
    else // general case
    {
        real* inputrowdata = input->valuedata+startk;
        int thiskcolstart = 0; // element index of start of column in this var
        for(int i=0; i<width(); i++) // the width() of this var is the length() of the submat
        {
            int thisk = thiskcolstart++;
            for(int j=0; j<length(); j++, thisk+=width()) // the length() of this var is the width() of the submat
                valuedata[thisk] = inputrowdata[j];
            inputrowdata += input->width();
        }
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubMatTransposeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubMatTransposeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubMatTransposeVariable.cc.

void PLearn::SubMatTransposeVariable::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 93 of file SubMatTransposeVariable.cc.

References length_, and width_.

{ l=width_; w=length_; }
void PLearn::SubMatTransposeVariable::rfprop ( ) [virtual]

Reimplemented from PLearn::Variable.

Definition at line 154 of file SubMatTransposeVariable.cc.

References i, PLearn::UnaryVariable::input, j, PLearn::Var::length(), PLearn::TVec< T >::length(), PLearn::Variable::length(), PLearn::Variable::nelems(), PLearn::UnaryVariable::resizeRValue(), PLearn::Variable::rValue, PLearn::Variable::rvaluedata, startk, PLearn::Variable::width(), and PLearn::Var::width().

{
    if (rValue.length()==0) resizeRValue();
    if(input->length()==1 || input->width()==1) // optimized version for this special case...
    {
        real* inputdata = input->rvaluedata+startk;
        for(int k=0; k<nelems(); k++)
            rvaluedata[k] = inputdata[k];
    }
    else // general case
    {
        real* inputrowdata = input->rvaluedata+startk;
        int thiskcolstart = 0; // element index of start of column in this var
        for(int i=0; i<width(); i++) // the width() of this var is the length() of the submat
        {
            int thisk = thiskcolstart++;
            for(int j=0; j<length(); j++, thisk+=width()) // the length() of this var is the width() of the submat
                rvaluedata[thisk] = inputrowdata[j];
            inputrowdata += input->width();
        }
    }
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 142 of file SubMatTransposeVariable.cc.

References PLearn::extend(), PLearn::Variable::g, i, PLearn::UnaryVariable::input, j, PLearn::Variable::length(), PLearn::Var::length(), startk, PLearn::transpose(), PLearn::Variable::width(), and PLearn::Var::width().

{
    int i = startk/input->width();
    int j = startk%input->width();
    int topextent = i;
    int bottomextent = input->length()-(i+width()); // the width() of this var is the length() of the submat
    int leftextent = j;
    int rightextent = input->width()-(j+length()); // the length() of this var is the width() of the submat
    input->accg(extend(transpose(g),topextent,bottomextent,leftextent,rightextent));
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 71 of file SubMatTransposeVariable.h.

Definition at line 63 of file SubMatTransposeVariable.h.

Referenced by build_(), and declareOptions().

Definition at line 63 of file SubMatTransposeVariable.h.

Referenced by build_(), and declareOptions().

Definition at line 62 of file SubMatTransposeVariable.h.

Referenced by declareOptions(), and recomputeSize().

Definition at line 61 of file SubMatTransposeVariable.h.

Referenced by bprop(), build_(), declareOptions(), fprop(), rfprop(), and symbolicBprop().

Definition at line 62 of file SubMatTransposeVariable.h.

Referenced by declareOptions(), and recomputeSize().


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