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

#include <ConcatRowsSubVMatrix.h>

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

List of all members.

Public Member Functions

 ConcatRowsSubVMatrix (bool call_build_=false)
 default constructor (for automatic deserialization)
 ConcatRowsSubVMatrix (VMat the_source, TVec< int > &the_start, TVec< int > &the_len, bool call_build_=true)
 The field names of the parent VMat are copied upon construction.
 ConcatRowsSubVMatrix (VMat the_source, int start1, int len1, int start2, int len2, bool call_build_=true)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ConcatRowsSubVMatrixdeepCopy (CopiesMap &copies) const
virtual void build ()
 Simply calls inherited::build() then build_().
virtual real get (int i, int j) const
 These methods are implemented by buffering calls to getNewRow.
virtual void getSubRow (int i, int j, Vec v) const
 fills v with the subrow i laying between columns j (inclusive) and j+v.length() (exclusive)
virtual void reset_dimensions ()
 In case the dimensions of an underlying VMat has changed, recompute it.
virtual real dot (int i1, int i2, int inputsize) const
 Returns the dot product between row i1 and row i2 (considering only the inputsize first elements).
virtual real dot (int i, const Vec &v) const
 Returns the result of the dot product between row i and the given vec (only v.length() first elements of row i are considered).

Static Public Member Functions

static string _classname_ ()
 ConcatRowsSubVMatrix.
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 ()
static void declareOptions (OptionList &ol)
 Declares this class' options.

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

void getpositions (int i, int &whichvm, int &rowofvm) const
 returns the index of the correct sub-VMat in the array and the the row number in this VMat that correspond to row i in the ConcatRowsVMat

Protected Attributes

TVec< intstart
TVec< intlen

Private Types

typedef SourceVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

This class concatenates several (virtual) subVMatrices of the same source VMatrix. For each sub-vmatrix block, the user specifies the starting row and the number of rows in the source VMatrix. The resulting vmatrix sees first all the rows of the first sub-vmatrix, then all the rows of the 2nd, etc...

Definition at line 61 of file ConcatRowsSubVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::SourceVMatrix.

Definition at line 63 of file ConcatRowsSubVMatrix.h.


Constructor & Destructor Documentation

PLearn::ConcatRowsSubVMatrix::ConcatRowsSubVMatrix ( bool  call_build_ = false)

default constructor (for automatic deserialization)

Definition at line 64 of file ConcatRowsSubVMatrix.cc.

References build_().

    : inherited(call_build_)
{
    if( call_build_ )
        build_();
}

Here is the call graph for this function:

PLearn::ConcatRowsSubVMatrix::ConcatRowsSubVMatrix ( VMat  the_source,
TVec< int > &  the_start,
TVec< int > &  the_len,
bool  call_build_ = true 
)

The field names of the parent VMat are copied upon construction.

Copy parent field names

Definition at line 71 of file ConcatRowsSubVMatrix.cc.

References build_().

    : inherited(the_source, -1, the_source->width(), call_build_),
      start(the_start),
      len(the_len)
{
/*
  fieldinfos = the_source->getFieldInfos();
  check();
*/
    if( call_build_ )
        build_();
}

Here is the call graph for this function:

PLearn::ConcatRowsSubVMatrix::ConcatRowsSubVMatrix ( VMat  the_source,
int  start1,
int  len1,
int  start2,
int  len2,
bool  call_build_ = true 
)

Copy parent field names

Definition at line 88 of file ConcatRowsSubVMatrix.cc.

References build_(), len, and start.

    : inherited(the_source, -1, the_source->width(), call_build_),
      start(2), len(2)
{
    //fieldinfos = the_source->getFieldInfos();

    start[0]=start1;
    start[1]=start2;
    len[0]=len1;
    len[1]=len2;
    //check();
    if( call_build_ )
        build_();
}

Here is the call graph for this function:


Member Function Documentation

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

ConcatRowsSubVMatrix.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 62 of file ConcatRowsSubVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 62 of file ConcatRowsSubVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 62 of file ConcatRowsSubVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 62 of file ConcatRowsSubVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 62 of file ConcatRowsSubVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 62 of file ConcatRowsSubVMatrix.cc.

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

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 187 of file ConcatRowsSubVMatrix.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 193 of file ConcatRowsSubVMatrix.cc.

References PLearn::VMatrix::fieldinfos, i, len, PLearn::VMat::length(), PLearn::TVec< T >::length(), PLearn::VMatrix::length_, PLERROR, PLearn::VMatrix::setMetaInfoFrom(), PLearn::SourceVMatrix::source, and start.

Referenced by build(), and ConcatRowsSubVMatrix().

{
    if (source) {
        fieldinfos = source->getFieldInfos();
        setMetaInfoFrom(source);
        length_=0;
        for (int i = 0; i < start.length(); i++) {
            if (start[i]<0 || start[i]+len[i]>source->length())
                PLERROR("ConcatRowsSubVMatrix: out-of-range specs for submat"
                        " %d,\n"
                        "start=%d, len=%d, underlying distr length=%d\n",
                        i, start[i], len[i], source->length());
            length_ += len[i];
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 62 of file ConcatRowsSubVMatrix.cc.

void PLearn::ConcatRowsSubVMatrix::declareOptions ( OptionList ol) [static]
static const PPath& PLearn::ConcatRowsSubVMatrix::declaringFile ( ) [inline, static]

Reimplemented from PLearn::SourceVMatrix.

Definition at line 95 of file ConcatRowsSubVMatrix.h.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 62 of file ConcatRowsSubVMatrix.cc.

real PLearn::ConcatRowsSubVMatrix::dot ( int  i1,
int  i2,
int  inputsize 
) const [virtual]

Returns the dot product between row i1 and row i2 (considering only the inputsize first elements).

The default version in VMatrix is somewhat inefficient, as it repeatedly calls get(i,j) The default version in RowBufferedVMatrix is a little better as it buffers the 2 Vecs between calls in case one of them is needed again. But the real strength of this method is for specialised and efficient versions in subbclasses. This method is typically used by SmartKernels so that they can compute kernel values between input samples efficiently.

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 154 of file ConcatRowsSubVMatrix.cc.

References getpositions(), PLearn::SourceVMatrix::source, and start.

{
    int whichvm1, rowofvm1;
    getpositions(i1,whichvm1,rowofvm1);
    int whichvm2, rowofvm2;
    getpositions(i2,whichvm2,rowofvm2);
    return source->dot(start[whichvm1]+rowofvm1, start[whichvm2]+rowofvm2, inputsize);
}

Here is the call graph for this function:

real PLearn::ConcatRowsSubVMatrix::dot ( int  i,
const Vec v 
) const [virtual]

Returns the result of the dot product between row i and the given vec (only v.length() first elements of row i are considered).

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 163 of file ConcatRowsSubVMatrix.cc.

References getpositions(), PLearn::SourceVMatrix::source, and start.

{
    int whichvm, rowofvm;
    getpositions(i,whichvm,rowofvm);
    return source->dot(start[whichvm]+rowofvm,v);
}

Here is the call graph for this function:

real PLearn::ConcatRowsSubVMatrix::get ( int  i,
int  j 
) const [virtual]

These methods are implemented by buffering calls to getNewRow.

returns element (i,j)

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 140 of file ConcatRowsSubVMatrix.cc.

References getpositions(), PLearn::SourceVMatrix::source, and start.

{
    int whichvm, rowofvm;
    getpositions(i,whichvm,rowofvm);
    return source->get(start[whichvm]+rowofvm,j);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 62 of file ConcatRowsSubVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 62 of file ConcatRowsSubVMatrix.cc.

void PLearn::ConcatRowsSubVMatrix::getpositions ( int  i,
int whichvm,
int rowofvm 
) const [protected]

returns the index of the correct sub-VMat in the array and the the row number in this VMat that correspond to row i in the ConcatRowsVMat

Definition at line 121 of file ConcatRowsSubVMatrix.cc.

References len, PLearn::VMatrix::length(), and PLERROR.

Referenced by dot(), get(), and getSubRow().

{
#ifdef BOUNDCHECK
    if(i<0 || i>=length())
        PLERROR("In ConcatRowsSubVMatrix::getpositions OUT OF BOUNDS");
#endif

    int pos = 0;
    int k=0;
    while(i>=pos+len[k])
    {
        pos += len[k];
        k++;
    }

    whichvm = k;
    rowofvm = i-pos;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 62 of file ConcatRowsSubVMatrix.cc.

void PLearn::ConcatRowsSubVMatrix::getSubRow ( int  i,
int  j,
Vec  v 
) const [virtual]

fills v with the subrow i laying between columns j (inclusive) and j+v.length() (exclusive)

Reimplemented from PLearn::RowBufferedVMatrix.

Definition at line 147 of file ConcatRowsSubVMatrix.cc.

References getpositions(), PLearn::VMat::getSubRow(), PLearn::SourceVMatrix::source, and start.

{
    int whichvm, rowofvm;
    getpositions(i,whichvm,rowofvm);
    source->getSubRow(start[whichvm]+rowofvm, j, v);
}

Here is the call graph for this function:

virtual void PLearn::ConcatRowsSubVMatrix::reset_dimensions ( ) [inline, virtual]

In case the dimensions of an underlying VMat has changed, recompute it.

Reimplemented from PLearn::VMatrix.

Definition at line 102 of file ConcatRowsSubVMatrix.h.

References i.

    {
        source->reset_dimensions();
        width_=source->width();
        length_=0;
        for (int i=0;i<len.length();i++)
            length_ += len[i];
    }

Member Data Documentation

Reimplemented from PLearn::SourceVMatrix.

Definition at line 95 of file ConcatRowsSubVMatrix.h.

Definition at line 69 of file ConcatRowsSubVMatrix.h.

Referenced by build_(), ConcatRowsSubVMatrix(), declareOptions(), and getpositions().

Definition at line 68 of file ConcatRowsSubVMatrix.h.

Referenced by build_(), ConcatRowsSubVMatrix(), declareOptions(), dot(), get(), and getSubRow().


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