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

#include <BinaryOpVMatrix.h>

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

List of all members.

Public Member Functions

 BinaryOpVMatrix ()
 Default constructor.
 BinaryOpVMatrix (VMat source1, VMat source2, const string &op, bool call_build_=true)
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transform a shallow copy into a deep copy.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual BinaryOpVMatrixdeepCopy (CopiesMap &copies) const

Static Public Member Functions

static string _classname_ ()
 Declare name and deepCopy methods.
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 ()

Public Attributes

VMat source1
 First VMatrix to operate on.
VMat source2
 Second VMatrix to operate on.
string op
 Operation to perform; may be "add", "sub", "mult", "div".

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

virtual void getNewRow (int i, const Vec &v) const
 Fill the vector 'v' with the content of the i-th row.

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares this class' options.

Private Types

typedef RowBufferedVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Static Private Member Functions

static real op_add (double x, double y)
static real op_sub (double x, double y)
static real op_mul (double x, double y)
static real op_div (double x, double y)

Private Attributes

real(* selected_op )(double, double)
 Operation to perform.
Vec row1
 Implementation buffers.
Vec row2

Detailed Description

Definition at line 52 of file BinaryOpVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 57 of file BinaryOpVMatrix.h.


Constructor & Destructor Documentation

PLearn::BinaryOpVMatrix::BinaryOpVMatrix ( )

Default constructor.

Definition at line 50 of file BinaryOpVMatrix.cc.

{}
PLearn::BinaryOpVMatrix::BinaryOpVMatrix ( VMat  source1,
VMat  source2,
const string &  op,
bool  call_build_ = true 
)

Definition at line 53 of file BinaryOpVMatrix.cc.

References build_().

                                                  :
    inherited(call_build_),
    source1(source1),
    source2(source2),
    op(op)
{
    if (call_build_)
        build_();
}

Here is the call graph for this function:


Member Function Documentation

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

Declare name and deepCopy methods.

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 67 of file BinaryOpVMatrix.cc.

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

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 67 of file BinaryOpVMatrix.cc.

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

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 67 of file BinaryOpVMatrix.cc.

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

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 67 of file BinaryOpVMatrix.cc.

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

Reimplemented from PLearn::Object.

Definition at line 67 of file BinaryOpVMatrix.cc.

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

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 67 of file BinaryOpVMatrix.cc.

void PLearn::BinaryOpVMatrix::build ( ) [virtual]

Simply calls inherited::build() then build_().

Reimplemented from PLearn::VMatrix.

Definition at line 136 of file BinaryOpVMatrix.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::VMatrix.

Definition at line 101 of file BinaryOpVMatrix.cc.

References PLearn::VMat::length(), op, op_add(), op_div(), op_mul(), op_sub(), PLERROR, selected_op, PLearn::VMatrix::setMetaInfoFrom(), source1, source2, PLearn::VMatrix::updateMtime(), and PLearn::VMat::width().

Referenced by BinaryOpVMatrix(), and build().

{
    if (! source1)
        PLERROR("BinaryOpVMatrix::build_: source1 not defined");
    if (! source2)
        PLERROR("BinaryOpVMatrix::build_: source2 not defined");
    updateMtime(source1);
    updateMtime(source2);
    if (source1.length() != source2.length())
        PLERROR("BinaryOpVMatrix::build_: source1 has %d rows but\n"
                "source2 has %d rows; both must have the same number of"
                " rows.\n", source1.length(), source2.length());

    if (source1.width() != source2.width())
        PLERROR("BinaryOpVMatrix::build_: source1 has %d columns but\n"
                "source2 has %d columns; both must have the same number of"
                " columns.", source1.width(), source2.width());

    if (op == "add")
        selected_op = op_add;
    else if (op == "sub")
        selected_op = op_sub;
    else if (op == "mult")
        selected_op = op_mul;
    else if (op == "div")
        selected_op = op_div;
    else
        PLERROR("BinaryOpVMatrix::build_: unknown operation type \"%s\"; supported operatrions "
                "are \"add\", \"sub\", \"mult\", \"div\"", op.c_str());

    // Copy the metainformation from first VMat
    setMetaInfoFrom(source1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 67 of file BinaryOpVMatrix.cc.

void PLearn::BinaryOpVMatrix::declareOptions ( OptionList ol) [static, protected]

Declares this class' options.

Reimplemented from PLearn::VMatrix.

Definition at line 84 of file BinaryOpVMatrix.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::VMatrix::declareOptions(), op, source1, and source2.

{
    declareOption(ol, "source1", &BinaryOpVMatrix::source1,
                  OptionBase::buildoption,
                  "First source VMatrix to operate on");

    declareOption(ol, "source2", &BinaryOpVMatrix::source2,
                  OptionBase::buildoption,
                  "Second source VMatrix to operate on");

    declareOption(ol, "op", &BinaryOpVMatrix::op, OptionBase::buildoption,
                  "Operation to perform; may be \"add\", \"sub\", \"mult\", \"div\"");

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 117 of file BinaryOpVMatrix.h.

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

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 67 of file BinaryOpVMatrix.cc.

void PLearn::BinaryOpVMatrix::getNewRow ( int  i,
const Vec v 
) const [protected, virtual]

Fill the vector 'v' with the content of the i-th row.

v is assumed to be the right size.

Implements PLearn::RowBufferedVMatrix.

Definition at line 69 of file BinaryOpVMatrix.cc.

References i, n, PLASSERT, PLearn::TVec< T >::resize(), row1, row2, selected_op, PLearn::TVec< T >::size(), source1, source2, and PLearn::VMat::width().

{
    PLASSERT( source1 && source2 );
    row1.resize(source1.width());
    row2.resize(source2.width());
    PLASSERT( row1.size() == row2.size() );
    PLASSERT( v.size()    == row1.size() );

    source1->getRow(i, row1);
    source2->getRow(i, row2);

    for (int i=0, n=row1.size() ; i<n ; ++i)
        v[i] = selected_op(row1[i], row2[i]);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 67 of file BinaryOpVMatrix.cc.

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

Reimplemented from PLearn::Object.

Definition at line 67 of file BinaryOpVMatrix.cc.

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

Reimplemented from PLearn::Object.

Definition at line 67 of file BinaryOpVMatrix.cc.

void PLearn::BinaryOpVMatrix::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transform a shallow copy into a deep copy.

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 142 of file BinaryOpVMatrix.cc.

References PLearn::deepCopyField(), PLearn::RowBufferedVMatrix::makeDeepCopyFromShallowCopy(), row1, row2, source1, and source2.

Here is the call graph for this function:

static real PLearn::BinaryOpVMatrix::op_add ( double  x,
double  y 
) [inline, static, private]

Definition at line 59 of file BinaryOpVMatrix.h.

Referenced by build_().

{ return x+y; }

Here is the caller graph for this function:

static real PLearn::BinaryOpVMatrix::op_div ( double  x,
double  y 
) [inline, static, private]

Definition at line 62 of file BinaryOpVMatrix.h.

Referenced by build_().

{ return x/y; }

Here is the caller graph for this function:

static real PLearn::BinaryOpVMatrix::op_mul ( double  x,
double  y 
) [inline, static, private]

Definition at line 61 of file BinaryOpVMatrix.h.

Referenced by build_().

{ return x*y; }

Here is the caller graph for this function:

static real PLearn::BinaryOpVMatrix::op_sub ( double  x,
double  y 
) [inline, static, private]

Definition at line 60 of file BinaryOpVMatrix.h.

Referenced by build_().

{ return x-y; }

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 117 of file BinaryOpVMatrix.h.

Operation to perform; may be "add", "sub", "mult", "div".

Definition at line 79 of file BinaryOpVMatrix.h.

Referenced by build_(), and declareOptions().

Vec PLearn::BinaryOpVMatrix::row1 [mutable, private]

Implementation buffers.

Definition at line 68 of file BinaryOpVMatrix.h.

Referenced by getNewRow(), and makeDeepCopyFromShallowCopy().

Vec PLearn::BinaryOpVMatrix::row2 [mutable, private]

Definition at line 68 of file BinaryOpVMatrix.h.

Referenced by getNewRow(), and makeDeepCopyFromShallowCopy().

real(* PLearn::BinaryOpVMatrix::selected_op)(double, double) [private]

Operation to perform.

Definition at line 65 of file BinaryOpVMatrix.h.

Referenced by build_(), and getNewRow().

First VMatrix to operate on.

Definition at line 73 of file BinaryOpVMatrix.h.

Referenced by build_(), declareOptions(), getNewRow(), and makeDeepCopyFromShallowCopy().

Second VMatrix to operate on.

Definition at line 76 of file BinaryOpVMatrix.h.

Referenced by build_(), declareOptions(), getNewRow(), and makeDeepCopyFromShallowCopy().


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