PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <HeapTest.h>
Public Member Functions | |
HeapTest () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual HeapTest * | 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 () |
Public Attributes | |
int | n |
int | m |
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 HeapTest.h.
typedef PTest PLearn::HeapTest::inherited [private] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file HeapTest.h.
PLearn::HeapTest::HeapTest | ( | ) |
Default constructor.
Definition at line 65 of file HeapTest.cc.
: n(1000), m(100000) /* ### Initialize all fields to their default value */ { // ... // ### 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::HeapTest::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 60 of file HeapTest.cc.
OptionList & PLearn::HeapTest::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 60 of file HeapTest.cc.
RemoteMethodMap & PLearn::HeapTest::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 60 of file HeapTest.cc.
Reimplemented from PLearn::PTest.
Definition at line 60 of file HeapTest.cc.
Object * PLearn::HeapTest::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 60 of file HeapTest.cc.
StaticInitializer HeapTest::_static_initializer_ & PLearn::HeapTest::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 60 of file HeapTest.cc.
void PLearn::HeapTest::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 80 of file HeapTest.cc.
References PLearn::PTest::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::HeapTest::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::PTest.
Definition at line 127 of file HeapTest.cc.
Referenced by build().
{ // ### 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::HeapTest::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 60 of file HeapTest.cc.
void PLearn::HeapTest::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::PTest.
Definition at line 106 of file HeapTest.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::PTest::declareOptions(), m, and n.
{ // ### 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 declareOption(ol, "m", &HeapTest::m, OptionBase::buildoption, "Number of random updates."); declareOption(ol, "n", &HeapTest::n, OptionBase::buildoption, "Size of the data vector."); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::HeapTest::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::PTest.
Definition at line 87 of file HeapTest.h.
:
//##### Protected Options ###############################################
Reimplemented from PLearn::PTest.
Definition at line 60 of file HeapTest.cc.
OptionList & PLearn::HeapTest::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 60 of file HeapTest.cc.
OptionMap & PLearn::HeapTest::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 60 of file HeapTest.cc.
RemoteMethodMap & PLearn::HeapTest::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 60 of file HeapTest.cc.
void PLearn::HeapTest::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::PTest.
Definition at line 89 of file HeapTest.cc.
References PLearn::PTest::makeDeepCopyFromShallowCopy(), and 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("HeapTest::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
void PLearn::HeapTest::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 141 of file HeapTest.cc.
References PLearn::bounded_uniform(), PLearn::endl(), PLearn::gaussian_01(), i, PLearn::is_valid_heap(), j, m, n, PLASSERT, and PLearn::update_heap().
{ // ### The test code should go here. vector<real> data(n); for (int i=0; i<n; ++i) data[i] = gaussian_01(); make_heap(data.begin(), data.end()); PLASSERT(is_valid_heap(data.begin(), data.end())); // Destroy heap and reconstruct it for (int i=0; i<m; ++i) { int j = int(bounded_uniform(0,n)); PLASSERT(j>=0 && j<n); data[j] = gaussian_01(); if (! is_valid_heap(data.begin(), data.end())) { update_heap(data.begin(), data.end(), data.begin()+j); PLASSERT(is_valid_heap(data.begin(), data.end())); } } cout << "Heap condition successfully restored" << endl; }
Reimplemented from PLearn::PTest.
Definition at line 87 of file HeapTest.h.
Definition at line 69 of file HeapTest.h.
Referenced by declareOptions(), and perform().
Definition at line 68 of file HeapTest.h.
Referenced by declareOptions(), and perform().