|
PLearn 0.1
|
#include <BinaryOpVMatrix.h>


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 OptionList & | getOptionList () const |
| virtual OptionMap & | getOptionMap () const |
| virtual RemoteMethodMap & | getRemoteMethodMap () const |
| virtual BinaryOpVMatrix * | deepCopy (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 PPath & | declaringFile () |
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 |
Definition at line 52 of file BinaryOpVMatrix.h.
typedef RowBufferedVMatrix PLearn::BinaryOpVMatrix::inherited [private] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 57 of file BinaryOpVMatrix.h.
| PLearn::BinaryOpVMatrix::BinaryOpVMatrix | ( | ) |
| 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.
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_().
{
inherited::build();
build_();
}

| 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);
}


| 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);
}

| 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.
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]);
}

| 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.
{
inherited::makeDeepCopyFromShallowCopy(copies);
deepCopyField(row1, copies);
deepCopyField(row2, copies);
deepCopyField(source1, copies);
deepCopyField(source2, copies);
}

| 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; }

| 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; }

| 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; }

| 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; }

Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 117 of file BinaryOpVMatrix.h.
| string PLearn::BinaryOpVMatrix::op |
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().
1.7.4