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

VMatrix that contains random samples from a VMatrix. More...

#include <RandomSamplesFromVMatrix.h>

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

List of all members.

Public Member Functions

 RandomSamplesFromVMatrix ()
 Default constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual RandomSamplesFromVMatrixdeepCopy (CopiesMap &copies) const
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual PP< DictionarygetDictionary (int col) const
 Return the Dictionary object for a certain field, or a null pointer if there isn't one.
virtual void getValues (int row, int col, Vec &values) const
 Returns the possible values for a certain field in the VMatrix.
virtual void getValues (const Vec &input, int col, Vec &values) const
 Returns the possible values of a certain field (column) given the input.

Static Public Member Functions

static string _classname_ ()
 RowBufferedVMatrix.
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 source
 VMatrix from which the samples are taken.
real flength
 If provided, will overwrite length by flength * source->length()
int32_t seed
 Random number generator's seed.

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 the class options.

Protected Attributes

PP< PRandomrgen
 Random number generator for selecting random sample.

Private Types

typedef RowBufferedVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

VMatrix that contains random samples from a VMatrix.

The samples are ALWAYS random, i.e. they are not pre-defined at building time. The only exception is when the same row is accessed many consecutive times, in which case the same example is returned.

Definition at line 55 of file RandomSamplesFromVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 57 of file RandomSamplesFromVMatrix.h.


Constructor & Destructor Documentation

PLearn::RandomSamplesFromVMatrix::RandomSamplesFromVMatrix ( )

Default constructor.

Definition at line 57 of file RandomSamplesFromVMatrix.cc.

                                                  :
    flength(-1),
    seed(0), 
    rgen(new PRandom())
{
}

Member Function Documentation

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

RowBufferedVMatrix.

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 55 of file RandomSamplesFromVMatrix.cc.

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

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 55 of file RandomSamplesFromVMatrix.cc.

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

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 55 of file RandomSamplesFromVMatrix.cc.

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

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 55 of file RandomSamplesFromVMatrix.cc.

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

Reimplemented from PLearn::Object.

Definition at line 55 of file RandomSamplesFromVMatrix.cc.

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

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 55 of file RandomSamplesFromVMatrix.cc.

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

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

Reimplemented from PLearn::VMatrix.

Definition at line 116 of file RandomSamplesFromVMatrix.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::VMatrix.

Definition at line 95 of file RandomSamplesFromVMatrix.cc.

References PLearn::VMatrix::fieldinfos, flength, PLearn::VMatrix::inputsize_, PLearn::VMat::length(), PLearn::VMatrix::length_, rgen, seed, source, PLearn::VMatrix::targetsize_, PLearn::VMatrix::updateMtime(), PLearn::VMatrix::weightsize_, PLearn::VMat::width(), and PLearn::VMatrix::width_.

Referenced by build().

{
    if(source)
    {
        updateMtime(source);
        if(flength > 0)
            length_ = int(flength * source->length());
        if(length_ < 0)
            length_ = source->length();
        if(seed != 0)
            rgen->manual_seed(seed);
        
        width_ = source->width();
        if(inputsize_ < 0) inputsize_ = source->inputsize();
        if(targetsize_ < 0) targetsize_ = source->targetsize();
        if(weightsize_ < 0) weightsize_ = source->weightsize();
        fieldinfos = source->fieldinfos;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 55 of file RandomSamplesFromVMatrix.cc.

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

Declares the class options.

Reimplemented from PLearn::VMatrix.

Definition at line 69 of file RandomSamplesFromVMatrix.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::VMatrix::declareOptions(), flength, seed, and source.

{
    declareOption(ol, "source", &RandomSamplesFromVMatrix::source,
                  OptionBase::buildoption,
                  "VMatrix from which the samples are taken");
    
    declareOption(ol, "flength", &RandomSamplesFromVMatrix::flength,
                  OptionBase::buildoption,
                  "If provided, will overwrite length by flength * source->length()");
    declareOption(ol, "seed", &RandomSamplesFromVMatrix::seed,
                  OptionBase::buildoption,
                  "The initial seed for the random number generator used in this\n"
                  "VMatrix, for sample selection.\n"
                  "If -1 is provided, then a 'random' seed is chosen based on time\n"
                  "of day, ensuring that different experiments run differently.\n"
                  "If 0 is provided, no (re)initialization of the random number\n"
                  "generator is performed.\n"
                  "With a given positive seed, this VMatrix should always select\n"
                  "the same sequence of samples.");

    

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

Here is the call graph for this function:

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

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 82 of file RandomSamplesFromVMatrix.h.

:
    //#####  Protected Options  ###############################################
RandomSamplesFromVMatrix * PLearn::RandomSamplesFromVMatrix::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 55 of file RandomSamplesFromVMatrix.cc.

PP< Dictionary > PLearn::RandomSamplesFromVMatrix::getDictionary ( int  col) const [virtual]

Return the Dictionary object for a certain field, or a null pointer if there isn't one.

Reimplemented from PLearn::VMatrix.

Definition at line 131 of file RandomSamplesFromVMatrix.cc.

References source.

{
    return source->getDictionary(col);
}
void PLearn::RandomSamplesFromVMatrix::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 64 of file RandomSamplesFromVMatrix.cc.

References PLearn::VMat::length(), rgen, and source.

{
    source->getRow(rgen->uniform_multinomial_sample(source->length()),v);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 55 of file RandomSamplesFromVMatrix.cc.

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

Reimplemented from PLearn::Object.

Definition at line 55 of file RandomSamplesFromVMatrix.cc.

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

Reimplemented from PLearn::Object.

Definition at line 55 of file RandomSamplesFromVMatrix.cc.

void PLearn::RandomSamplesFromVMatrix::getValues ( int  row,
int  col,
Vec values 
) const [virtual]

Returns the possible values for a certain field in the VMatrix.

Reimplemented from PLearn::VMatrix.

Definition at line 136 of file RandomSamplesFromVMatrix.cc.

References PLERROR.

{
    PLERROR("In RandomSamplesFromVMatrix::getValues(): Cannot give possible values given a row index because samples are independent of the row index.");
}
void PLearn::RandomSamplesFromVMatrix::getValues ( const Vec input,
int  col,
Vec values 
) const [virtual]

Returns the possible values of a certain field (column) given the input.

Reimplemented from PLearn::VMatrix.

Definition at line 141 of file RandomSamplesFromVMatrix.cc.

References source.

{
    source->getValues(input,col,values);
}
void PLearn::RandomSamplesFromVMatrix::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 122 of file RandomSamplesFromVMatrix.cc.

References PLearn::deepCopyField(), PLearn::RowBufferedVMatrix::makeDeepCopyFromShallowCopy(), rgen, and source.

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 82 of file RandomSamplesFromVMatrix.h.

If provided, will overwrite length by flength * source->length()

Definition at line 65 of file RandomSamplesFromVMatrix.h.

Referenced by build_(), and declareOptions().

Random number generator for selecting random sample.

Definition at line 106 of file RandomSamplesFromVMatrix.h.

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

Random number generator's seed.

Definition at line 67 of file RandomSamplesFromVMatrix.h.

Referenced by build_(), and declareOptions().

VMatrix from which the samples are taken.

Definition at line 63 of file RandomSamplesFromVMatrix.h.

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


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