PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <FileVMatrixTest.h>
Public Member Functions | |
FileVMatrixTest () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual FileVMatrixTest * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
virtual void | perform () |
The method performing the test. | |
Static Public Member Functions | |
static string | _classname_ () |
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_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef PTest | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
The first sentence should be a BRIEF DESCRIPTION of what the class does.
Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html
Definition at line 61 of file FileVMatrixTest.h.
typedef PTest PLearn::FileVMatrixTest::inherited [private] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file FileVMatrixTest.h.
PLearn::FileVMatrixTest::FileVMatrixTest | ( | ) |
Default constructor.
Definition at line 62 of file FileVMatrixTest.cc.
{ // ... // ### You may (or not) want to call build_() to finish building the object // ### (doing so assumes the parent classes' build_() have been called too // ### in the parent classes' constructors, something that you must ensure) }
string PLearn::FileVMatrixTest::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 57 of file FileVMatrixTest.cc.
OptionList & PLearn::FileVMatrixTest::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 57 of file FileVMatrixTest.cc.
RemoteMethodMap & PLearn::FileVMatrixTest::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 57 of file FileVMatrixTest.cc.
Reimplemented from PLearn::PTest.
Definition at line 57 of file FileVMatrixTest.cc.
Object * PLearn::FileVMatrixTest::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 57 of file FileVMatrixTest.cc.
StaticInitializer FileVMatrixTest::_static_initializer_ & PLearn::FileVMatrixTest::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 57 of file FileVMatrixTest.cc.
void PLearn::FileVMatrixTest::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::PTest.
Definition at line 75 of file FileVMatrixTest.cc.
{ inherited::build(); build_(); }
void PLearn::FileVMatrixTest::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::PTest.
Definition at line 121 of file FileVMatrixTest.cc.
{ // ### This method should do the real building of the object, // ### according to set 'options', in *any* situation. // ### Typical situations include: // ### - Initial building of an object from a few user-specified options // ### - Building of a "reloaded" object: i.e. from the complete set of all serialised options. // ### - Updating or "re-building" of an object after a few "tuning" options have been modified. // ### You should assume that the parent class' build_() has already been called. }
string PLearn::FileVMatrixTest::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 57 of file FileVMatrixTest.cc.
void PLearn::FileVMatrixTest::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::PTest.
Definition at line 101 of file FileVMatrixTest.cc.
{ // ### Declare all of this object's options here // ### For the "flags" of each option, you should typically specify // ### one of OptionBase::buildoption, OptionBase::learntoption or // ### OptionBase::tuningoption. Another possible flag to be combined with // ### is OptionBase::nosave // ### ex: // declareOption(ol, "myoption", &FileVMatrixTest::myoption, OptionBase::buildoption, // "Help text describing this option"); // ... // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::FileVMatrixTest::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::PTest.
Definition at line 88 of file FileVMatrixTest.h.
:
//##### Protected Options ###############################################
FileVMatrixTest * PLearn::FileVMatrixTest::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 57 of file FileVMatrixTest.cc.
OptionList & PLearn::FileVMatrixTest::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 57 of file FileVMatrixTest.cc.
OptionMap & PLearn::FileVMatrixTest::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 57 of file FileVMatrixTest.cc.
RemoteMethodMap & PLearn::FileVMatrixTest::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 57 of file FileVMatrixTest.cc.
void PLearn::FileVMatrixTest::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::PTest.
Definition at line 84 of file FileVMatrixTest.cc.
References PLERROR.
{ inherited::makeDeepCopyFromShallowCopy(copies); // ### Call deepCopyField on all "pointer-like" fields // ### that you wish to be deepCopied rather than // ### shallow-copied. // ### ex: // deepCopyField(trainvec, copies); // ### Remove this line when you have fully implemented this method. PLERROR("FileVMatrixTest::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
void PLearn::FileVMatrixTest::perform | ( | ) | [virtual] |
The method performing the test.
A typical test consists in some output (to pout and / or perr), and updates of this object's options.
Reimplemented from PLearn::PTest.
Definition at line 135 of file FileVMatrixTest.cc.
References PLearn::FileVMatrix::appendRow(), DATAFILE_HEADERLENGTH, PLearn::endl(), PLearn::VMatrix::fieldNames(), PLearn::filesize64(), PLearn::TVec< T >::fill(), PLearn::FileVMatrix::flush(), PLearn::force_rmdir(), PLearn::RowBufferedVMatrix::getRow(), i, PLearn::VMatrix::length(), MISSING_VALUE, PLearn::pout, PLearn::VMatrix::putRow(), PLearn::rm(), PLearn::VMatrix::toMat(), and PLearn::VMatrix::width().
{ pout << "Testing small FileVMatrix" << endl; pout << "TEST m1" << endl; FileVMatrix* m1 = new FileVMatrix("fvm1.pmat",10,3); Vec v(3); v[0] = 1.0; v[1] = 2.0; v[2] = 3.0; for(int i=0; i<m1->length(); i++) { m1->putRow(i,v); v += 1.0; } m1->appendRow(v); m1->flush(); m1->putRow(3,v); m1->appendRow(v); v[1] = MISSING_VALUE; m1->putRow(2,v); delete m1; pout << "TEST m2" << endl; FileVMatrix* m2 = new FileVMatrix("fvm1.pmat",true); v += 10.; m2->appendRow(v); m2->putRow(4,v); delete m2; pout << "TEST m3" << endl; FileVMatrix* m3 = new FileVMatrix("fvm1.pmat"); TVec<string> fieldnames(3); fieldnames[0]="aaa"; fieldnames[1]="bbb"; fieldnames[2]="ccc"; pout << "TEST m4" << endl; FileVMatrix* m4 = new FileVMatrix("fvm4.pmat",0,fieldnames); int l = m3->length(); for(int i=0; i<l; i++) { m3->getRow(i,v); m4->appendRow(v); } delete m4; pout << "TEST m5" << endl; FileVMatrix* m5 = new FileVMatrix("fvm4.pmat"); pout << "Fieldnames: " << m5->fieldNames() << " SAME? " << (m5->fieldNames()==fieldnames) << endl; pout << "toMat(): \n" << m5->toMat() << endl; pout << "TEST m6" << endl; pout << "Testing huge FileVMatrix" << endl; v[0] = 100; v[1] = 101; v[2] = 102; l = 200000000; FileVMatrix* m6 = new FileVMatrix("fvm6.pmat",l,3); m6->putRow(l-5,v+1.0); m6->putRow(5,v-1.0); m6->getRow(l-5, v); pout << l-5 << ": " << v << " (should be 101 102 103)" << endl; m6->getRow(5, v); pout << 5 << ": " << v << " (should be 99 100 101)" << endl; v.fill(999); m6->appendRow(v); pout << "l=" << l << " length=" << m6->length() << " (should be l+1)" << endl; m6->getRow(l-5, v); pout << l-5 << ": " << v << " (should be 101 102 103)" << endl; m6->getRow(5, v); pout << 5 << ": " << v << " (should be 99 100 101)" << endl; m6->getRow(l, v); pout << l << ": " << v << " (should be 999 999 999)" << endl; PRUint64 siz1 = m6->length(); siz1 *= m6->width()*sizeof(real); siz1 += DATAFILE_HEADERLENGTH; delete m6; PRUint64 siz2 = filesize64("fvm6.pmat"); pout << "Huge file size: " << siz2 << " sohuld equal " << siz1 << " ? " << (siz2==siz1) << endl; pout << "TEST m7" << endl; FileVMatrix* m7 = new FileVMatrix("fvm6.pmat"); pout << "l=" << l << " length=" << m7->length() << " (should be l+1)" << endl; m7->getRow(l-5, v); pout << l-5 << ": " << v << " (should be 101 102 103)" << endl; m7->getRow(5, v); pout << 5 << ": " << v << " (should be 99 100 101)" << endl; m7->getRow(l, v); pout << l << ": " << v << " (should be 999 999 999)" << endl; delete m7; // remove it because we don't want to keep such a huge file under revision control rm("fvm6.pmat"); force_rmdir("fvm6.pmat.metadata"); }
Reimplemented from PLearn::PTest.
Definition at line 88 of file FileVMatrixTest.h.