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

#include <MemoryVMatrix.h>

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

List of all members.

Public Member Functions

 MemoryVMatrix ()
 MemoryVMatrix (const Mat &the_data)
 MemoryVMatrix (int l, int w)
 MemoryVMatrix (VMat the_source, bool call_build_=true)
virtual real get (int i, int j) const
 This method must be implemented in all subclasses.
virtual void getSubRow (int i, int j, Vec v) const
 It is suggested that this method be implemented in subclasses to speed up accesses (default version repeatedly calls get(i,j) which may have a significant overhead).
virtual void getRow (int i, Vec v) const
 These methods do not usually need to be overridden in subclasses (default versions call getSubRow, which should do just fine)
virtual void getColumn (int i, Vec v) const
 Copies column i into v (which must have appropriate length equal to the VMat's length).
virtual void getMat (int i, int j, Mat m) const
 Copies the submatrix starting at i,j into m (which must have appropriate length and width).
virtual void put (int i, int j, real value)
 This method must be implemented in all subclasses of writable matrices.
virtual void putSubRow (int i, int j, Vec v)
 It is suggested that this method be implemented in subclasses of writable matrices to speed up accesses (default version repeatedly calls put(i,j,value) which may have a significant overhead)
virtual void putRow (int i, Vec v)
virtual void appendRow (Vec v)
 This method must be implemented for matrices that are allowed to grow.
virtual void fill (real value)
virtual void putMat (int i, int j, Mat m)
 Copies matrix m at position i,j of this VMat.
virtual Mat toMat () const
 Returns a Mat with the same data as this VMat.
virtual VMat subMat (int i, int j, int l, int w)
 Default version returns a SubVMatrix referencing the current VMatrix however this can be overridden to provide more efficient shortcuts (see MemoryVMatrix::subMat and SubVMatrix::subMat for examples)
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).
virtual void build ()
 simply calls inherited::build() then build_()
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual MemoryVMatrixdeepCopy (CopiesMap &copies) const
void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.

Static Public Member Functions

static string _classname_ ()
 MemoryVMatrix.
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

Mat data
VMat source
bool deep_copy_memory_data

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declare this class' options.

Protected Attributes

Mat memory_data
 The matrix storing the data in memory.
bool synch_data
 Set to true if data is given through the 'data' option instead of the 'source' option.
TVec< string > fieldnames

Private Types

typedef VMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 52 of file MemoryVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 54 of file MemoryVMatrix.h.


Constructor & Destructor Documentation

PLearn::MemoryVMatrix::MemoryVMatrix ( )

Definition at line 60 of file MemoryVMatrix.cc.

References data, and memory_data.

Referenced by subMat().

Here is the caller graph for this function:

PLearn::MemoryVMatrix::MemoryVMatrix ( const Mat the_data)

Definition at line 78 of file MemoryVMatrix.cc.

References PLearn::VMatrix::defineSizes(), memory_data, and PLearn::TMat< T >::width().

    : inherited(the_data.length(), the_data.width()),
      synch_data(true),
      data(the_data),
      deep_copy_memory_data(true)

{
    memory_data = the_data;
    defineSizes(the_data.width(), 0, 0);
}

Here is the call graph for this function:

PLearn::MemoryVMatrix::MemoryVMatrix ( int  l,
int  w 
)

Definition at line 68 of file MemoryVMatrix.cc.

References data, PLearn::VMatrix::defineSizes(), memory_data, PLearn::TMat< T >::resize(), and PLearn::TMat< T >::width().

    : inherited(l, w),
      synch_data(false),
      deep_copy_memory_data(true)
{
    data.resize(l,w);
    memory_data = data;
    defineSizes(data.width(), 0, 0);
}

Here is the call graph for this function:

PLearn::MemoryVMatrix::MemoryVMatrix ( VMat  the_source,
bool  call_build_ = true 
)

Definition at line 89 of file MemoryVMatrix.cc.

References build_().

                                                             :
    inherited(the_source->length(), the_source->width(), call_build_),
    synch_data(false),
    source(the_source),
    deep_copy_memory_data(true)
{
    if (call_build_)
        build_();
}

Here is the call graph for this function:


Member Function Documentation

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

MemoryVMatrix.

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 55 of file MemoryVMatrix.cc.

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

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 55 of file MemoryVMatrix.cc.

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

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 55 of file MemoryVMatrix.cc.

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

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 55 of file MemoryVMatrix.cc.

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

Reimplemented from PLearn::Object.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 55 of file MemoryVMatrix.cc.

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

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 55 of file MemoryVMatrix.cc.

void PLearn::MemoryVMatrix::appendRow ( Vec  v) [virtual]

This method must be implemented for matrices that are allowed to grow.

Reimplemented from PLearn::VMatrix.

Definition at line 302 of file MemoryVMatrix.cc.

References PLearn::TMat< T >::appendRow(), data, PLearn::VMatrix::length_, memory_data, PLASSERT, and source.

{
    memory_data.appendRow(v);
    length_++;
    PLASSERT(!source);
    data = memory_data;
}

Here is the call graph for this function:

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

simply calls inherited::build() then build_()

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix, and PLearn::MemoryVMatrixNoSave.

Definition at line 198 of file MemoryVMatrix.cc.

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

Referenced by PLearn::MemoryVMatrixNoSave::build(), PLearn::GramVMatrix::build(), PLearn::GramVMatrix::build_(), and PLearn::StrTableVMatrix::StrTableVMatrix().

Here is the call graph for this function:

Here is the caller graph for this function:

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

This does the actual building.

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix, and PLearn::MemoryVMatrixNoSave.

Definition at line 154 of file MemoryVMatrix.cc.

References PLearn::VMatrix::copySizesFrom(), data, PLearn::VMatrix::declareFieldNames(), fieldnames, PLearn::TVec< T >::length(), PLearn::TMat< T >::length(), PLearn::VMatrix::length(), PLearn::VMatrix::length_, memory_data, PLearn::TMat< T >::resize(), PLearn::VMatrix::setMetaInfoFrom(), source, synch_data, PLearn::VMat::toMat(), PLearn::VMatrix::width(), PLearn::TMat< T >::width(), and PLearn::VMatrix::width_.

Referenced by build(), and MemoryVMatrix().

{
    if (source) {
        // Precompute data from source
        memory_data = source->toMat();
        copySizesFrom(source);
        setMetaInfoFrom(source);
        synch_data = false;
    } else {
        synch_data = true;
    }
    if (synch_data) {
        memory_data = data;
        // We temporarily set data to a new empty Mat, so that memory_data
        // can be safely resized.
        data = Mat();
    }
    if (this->length() >= 0 && this->length() != memory_data.length()) {
        // New length specified.
        memory_data.resize(this->length(), memory_data.width());
    }
    if (this->width() >= 0 && this->width() != memory_data.width()) {
        // New width specified.
        memory_data.resize(memory_data.length(), this->width());
    }
    if (this->length() < 0 && memory_data.length() >= 0) {
        // Take the length from the data matrix.
        this->length_ = memory_data.length();
    }
    if (this->width() < 0 && memory_data.width() >= 0) {
        // Take the width from the data matrix.
        this->width_ = memory_data.width();
    }
    if (synch_data)
        // Restore data so that it is equal to memory_data.
        data = memory_data;

    if ( fieldnames.length() == memory_data.width() )
        declareFieldNames(fieldnames);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 55 of file MemoryVMatrix.cc.

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

Declare this class' options.

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix, and PLearn::MemoryVMatrixNoSave.

Definition at line 102 of file MemoryVMatrix.cc.

References PLearn::OptionBase::buildoption, data, PLearn::declareOption(), PLearn::VMatrix::declareOptions(), deep_copy_memory_data, fieldnames, PLearn::OptionBase::learntoption, PLearn::OptionBase::nosave, and source.

Referenced by PLearn::MemoryVMatrixNoSave::declareOptions(), and PLearn::GramVMatrix::declareOptions().

{
    declareOption(ol, "data", &MemoryVMatrix::data, OptionBase::buildoption,
                  "The external Mat source");

    declareOption(ol, "data_vm", &MemoryVMatrix::source,
                  (OptionBase::learntoption | OptionBase::nosave),
                  "DEPRECATED - Use 'source' instead.");

    declareOption(ol, "source", &MemoryVMatrix::source,
                  OptionBase::buildoption,
                  "The (optional) source VMatrix. Will overwrite 'data'"
                  " if provided.");

    declareOption( ol, "fieldnames", &MemoryVMatrix::fieldnames,
                   OptionBase::buildoption,
                   "If provided, will be used to set this VMatrix's"
                   " fieldnames." );

    declareOption( ol, "deep_copy_memory_data", &MemoryVMatrix::deep_copy_memory_data,
                   OptionBase::buildoption,
                   "If true, when this object is deep copied, we will deep copy the memory_data");

    /* This field was declared as an option, but the author does not remember
     * why. The problem is that we do not want it to be a learnt option, since
     * it may save the whole dataset pointed by 'source', which could waste a
     * lot of disk space.
     * As a result, the two lines below are now commented out.
    declareOption(ol, "memory_data", &MemoryVMatrix::memory_data, OptionBase::learntoption,
                  "The underlying Mat with the data.");
    */

    inherited::declareOptions(ol);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 113 of file MemoryVMatrix.h.

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

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 55 of file MemoryVMatrix.cc.

real PLearn::MemoryVMatrix::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::VMatrix.

Definition at line 344 of file MemoryVMatrix.cc.

References PLearn::TVec< T >::data(), PLearn::TVec< T >::length(), memory_data, PLERROR, PLearn::TMat< T >::rowdata(), and PLearn::VMatrix::width().

{
#ifdef BOUNDCHECK
    if(v.length()>width())
        PLERROR("In MemoryVMatrix::dot length of vector v is greater than VMat's width");
#endif
    if (v.length() > 0) {
        real* v1 = memory_data.rowdata(i);
        real* v2 = v.data();
        real res = 0.;
        for(int k=0; k<v.length(); k++)
            res += v1[k]*v2[k];
        return res;
    }
    return 0.0;                                // in the case of a null vector
}

Here is the call graph for this function:

real PLearn::MemoryVMatrix::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::VMatrix.

Definition at line 330 of file MemoryVMatrix.cc.

References PLearn::VMatrix::inputsize(), memory_data, PLERROR, PLearn::TMat< T >::rowdata(), and PLearn::VMatrix::width().

{
#ifdef BOUNDCHECK
    if(inputsize>width())
        PLERROR("In MemoryVMatrix::dot inputsize>width()");
#endif
    real* v1 = memory_data.rowdata(i1);
    real* v2 = memory_data.rowdata(i2);
    real res = 0.;
    for(int k=0; k<inputsize; k++)
        res += (*v1++) * (*v2++);
    return res;
}

Here is the call graph for this function:

void PLearn::MemoryVMatrix::fill ( real  value) [virtual]

Reimplemented from PLearn::VMatrix.

Definition at line 270 of file MemoryVMatrix.cc.

References data, PLearn::TMat< T >::fill(), memory_data, PLASSERT, and source.

{
    memory_data.fill(value);
    PLASSERT(!source);
    data = memory_data;
}

Here is the call graph for this function:

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

This method must be implemented in all subclasses.

Returns element (i,j).

Implements PLearn::VMatrix.

Definition at line 207 of file MemoryVMatrix.cc.

References memory_data.

{ return memory_data(i,j); }
void PLearn::MemoryVMatrix::getColumn ( int  i,
Vec  v 
) const [virtual]

Copies column i into v (which must have appropriate length equal to the VMat's length).

Reimplemented from PLearn::VMatrix.

Definition at line 213 of file MemoryVMatrix.cc.

References PLearn::TMat< T >::column(), and memory_data.

{ v << memory_data.column(i); }

Here is the call graph for this function:

void PLearn::MemoryVMatrix::getMat ( int  i,
int  j,
Mat  m 
) const [virtual]

Copies the submatrix starting at i,j into m (which must have appropriate length and width).

Reimplemented from PLearn::VMatrix.

Definition at line 240 of file MemoryVMatrix.cc.

References PLearn::TMat< T >::length(), memory_data, PLearn::TMat< T >::subMat(), and PLearn::TMat< T >::width().

{ m << memory_data.subMat(i,j,m.length(),m.width()); }

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 55 of file MemoryVMatrix.cc.

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

Reimplemented from PLearn::Object.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 55 of file MemoryVMatrix.cc.

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

Reimplemented from PLearn::Object.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 55 of file MemoryVMatrix.cc.

void PLearn::MemoryVMatrix::getRow ( int  i,
Vec  v 
) const [virtual]

These methods do not usually need to be overridden in subclasses (default versions call getSubRow, which should do just fine)

Copies row i into v (which must have appropriate length equal to the VMat's width).

Reimplemented from PLearn::VMatrix.

Definition at line 230 of file MemoryVMatrix.cc.

References PLearn::TVec< T >::copyFrom(), PLearn::TVec< T >::length(), memory_data, PLASSERT, and PLearn::VMatrix::width_.

{
    PLASSERT( v.length() == width_ );
    if (width_ > 0)
        v.copyFrom(memory_data[i], width_);
}

Here is the call graph for this function:

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

It is suggested that this method be implemented in subclasses to speed up accesses (default version repeatedly calls get(i,j) which may have a significant overhead).

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

Reimplemented from PLearn::VMatrix.

Definition at line 216 of file MemoryVMatrix.cc.

References PLearn::TVec< T >::copyFrom(), PLearn::TVec< T >::length(), memory_data, PLERROR, and PLearn::VMatrix::width().

{
#ifdef BOUNDCHECK
    if (j+v.length()>width())
        PLERROR("MemoryVMatrix::getSubRow(int i, int j, Vec v) OUT OF BOUNDS. "
                "j=%d, v.length()=%d, width()=%d", j, v.length(), width());
#endif
    if (v.length() > 0)
        v.copyFrom(memory_data[i]+j, v.length());
}

Here is the call graph for this function:

void PLearn::MemoryVMatrix::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.

This needs to be overridden by every class that adds "complex" data members to the class, such as Vec, Mat, PP<Something>, etc. Typical implementation:

  void CLASS_OF_THIS::makeDeepCopyFromShallowCopy(CopiesMap& copies)
  {
      inherited::makeDeepCopyFromShallowCopy(copies);
      deepCopyField(complex_data_member1, copies);
      deepCopyField(complex_data_member2, copies);
      ...
  }
Parameters:
copiesA map used by the deep-copy mechanism to keep track of already-copied objects.

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix.

Definition at line 140 of file MemoryVMatrix.cc.

References data, deep_copy_memory_data, PLearn::deepCopyField(), fieldnames, PLearn::VMatrix::makeDeepCopyFromShallowCopy(), memory_data, and source.

Referenced by PLearn::GramVMatrix::makeDeepCopyFromShallowCopy().

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::MemoryVMatrix::put ( int  i,
int  j,
real  value 
) [virtual]

This method must be implemented in all subclasses of writable matrices.

Sets element (i,j) to value.

Reimplemented from PLearn::VMatrix.

Definition at line 210 of file MemoryVMatrix.cc.

References memory_data.

{ memory_data(i,j) = value; }
void PLearn::MemoryVMatrix::putMat ( int  i,
int  j,
Mat  m 
) [virtual]

Copies matrix m at position i,j of this VMat.

Reimplemented from PLearn::VMatrix.

Definition at line 292 of file MemoryVMatrix.cc.

References data, PLearn::TMat< T >::length(), memory_data, PLASSERT, source, PLearn::TMat< T >::subMat(), and PLearn::TMat< T >::width().

{
    memory_data.subMat(i,j,m.length(),m.width()) << m;
    PLASSERT(!source);
    data = memory_data;
}

Here is the call graph for this function:

void PLearn::MemoryVMatrix::putRow ( int  i,
Vec  v 
) [virtual]

Reimplemented from PLearn::VMatrix.

Definition at line 281 of file MemoryVMatrix.cc.

References PLearn::TVec< T >::copyTo(), data, PLearn::TVec< T >::length(), memory_data, PLASSERT, and source.

{
    if (v.length() > 0)
        v.copyTo(memory_data[i]);
    PLASSERT(!source);
    data = memory_data;
}

Here is the call graph for this function:

void PLearn::MemoryVMatrix::putSubRow ( int  i,
int  j,
Vec  v 
) [virtual]

It is suggested that this method be implemented in subclasses of writable matrices to speed up accesses (default version repeatedly calls put(i,j,value) which may have a significant overhead)

Reimplemented from PLearn::VMatrix.

Definition at line 246 of file MemoryVMatrix.cc.

References PLearn::TVec< T >::copyTo(), data, PLearn::TVec< T >::length(), memory_data, PLASSERT, PLERROR, source, and PLearn::VMatrix::width().

{
#ifdef BOUNDCHECK
    if (j+v.length()>width())
        PLERROR("MemoryVMatrix::putSubRow(int i, int j, Vec v) OUT OF BOUNDS. "
                "j=%d, v.length()=%d, width()=%d", j, v.length(), width());
#endif
    if (v.length() > 0)
        v.copyTo(memory_data[i]+j);

    // Every method that writes data has the following two lines, because:
    // (1) The correct implementation when using a source VMat should be to
    // write in this source VMat as well, but it is not currently implemented,
    // so we just throw an error if we try to do this.
    // (2) We need to ensure that 'data' points to 'memory_data', in case this
    // VMat was initially created without any 'data' build option. Otherwise
    // the data will not be saved.
    PLASSERT(!source);
    data = memory_data;
}

Here is the call graph for this function:

VMat PLearn::MemoryVMatrix::subMat ( int  i,
int  j,
int  l,
int  w 
) [virtual]

Default version returns a SubVMatrix referencing the current VMatrix however this can be overridden to provide more efficient shortcuts (see MemoryVMatrix::subMat and SubVMatrix::subMat for examples)

Reimplemented from PLearn::VMatrix.

Definition at line 319 of file MemoryVMatrix.cc.

References deep_copy_memory_data, memory_data, MemoryVMatrix(), PLearn::VMatrix::setMetaInfoFrom(), and PLearn::TMat< T >::subMat().

{
    MemoryVMatrix* result = new MemoryVMatrix(memory_data.subMat(i,j,l,w));
    result->deep_copy_memory_data=deep_copy_memory_data;
    result->setMetaInfoFrom(this);
    return (VMat)result;
}

Here is the call graph for this function:

Mat PLearn::MemoryVMatrix::toMat ( ) const [virtual]

Returns a Mat with the same data as this VMat.

The default version of this method calls toMatCopy(). However this method will typically be overrided by subclasses (such as MemoryVMatrix) whose internal representation is already a Mat in order to return this Mat directly to avoid a new memory allocation and copy of elements. In this case, and in this case only, modifying the elements of the returned Mat will logically result in modified elements in the original VMatrix view of it. If you want to be sure that altering the content of the returned Mat won't modify the data contained in the VMatrix, you should call toMatCopy() instead.

Reimplemented from PLearn::VMatrix.

Definition at line 313 of file MemoryVMatrix.cc.

References memory_data.

{ return memory_data; }

Member Data Documentation

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix, PLearn::MemoryVMatrixNoSave, and PLearn::StrTableVMatrix.

Definition at line 113 of file MemoryVMatrix.h.

Definition at line 77 of file MemoryVMatrix.h.

Referenced by declareOptions(), makeDeepCopyFromShallowCopy(), and subMat().

If provided, will be used to set this vmatrix's fieldnames.

Definition at line 71 of file MemoryVMatrix.h.

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

The matrix storing the data in memory.

It can either point to 'data' or be filled with the content of 'source', depending on which of these two options is used.

Definition at line 61 of file MemoryVMatrix.h.

Referenced by appendRow(), build_(), dot(), fill(), get(), getColumn(), getMat(), getRow(), getSubRow(), makeDeepCopyFromShallowCopy(), MemoryVMatrix(), put(), putMat(), putRow(), putSubRow(), subMat(), and toMat().

Set to true if data is given through the 'data' option instead of the 'source' option.

It requires memory_data and data to systematically be the same.

Definition at line 66 of file MemoryVMatrix.h.

Referenced by build_().


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