Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

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)
virtual real get (int i, int j) const
 returns element (i,j)

virtual void getSubRow (int i, int j, Vec v) const
 fills v with the subrow i lying between columns j (inclusive) and j+v.length() (exclusive)

virtual void getRow (int i, Vec v) const
 copies row i into v (which must have appropriate length equal to the VMat's width)

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)
 sets element (i,j) to value

virtual void putSubRow (int i, int j, Vec v)
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
virtual VMat subMat (int i, int j, int l, int w)
virtual real dot (int i1, int i2, int inputsize) const
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_()

 PLEARN_DECLARE_OBJECT (MemoryVMatrix)
void makeDeepCopyFromShallowCopy (map< const void *, void * > &copies)

Public Attributes

Mat data
VMat data_vm

Static Protected Member Functions

void declareOptions (OptionList &ol)
 redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down)


Private Types

typedef VMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.


Member Typedef Documentation

typedef VMatrix PLearn::MemoryVMatrix::inherited [private]
 

Reimplemented from PLearn::VMatrix.

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

Definition at line 54 of file MemoryVMatrix.h.


Constructor & Destructor Documentation

PLearn::MemoryVMatrix::MemoryVMatrix  ) 
 

Definition at line 56 of file MemoryVMatrix.cc.

References PLearn::Mat.

Referenced by subMat().

PLearn::MemoryVMatrix::MemoryVMatrix const Mat the_data  ) 
 

Definition at line 65 of file MemoryVMatrix.cc.

References PLearn::TMat< T >::width().

PLearn::MemoryVMatrix::MemoryVMatrix int  l,
int  w
 

Definition at line 59 of file MemoryVMatrix.cc.

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


Member Function Documentation

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 175 of file MemoryVMatrix.cc.

References PLearn::TMat< T >::appendRow(), and data.

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

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

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix.

Definition at line 120 of file MemoryVMatrix.cc.

References build_().

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

This does the actual building.

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix.

Definition at line 92 of file MemoryVMatrix.cc.

References data, data_vm, PLearn::TMat< T >::length(), PLearn::VMatrix::length(), PLearn::TMat< T >::resize(), PLearn::VMat::toMat(), PLearn::VMatrix::width(), and PLearn::TMat< T >::width().

Referenced by build().

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

redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down)

ex: static void declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "the size of the input\n it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "the learnt model weights"); inherited::declareOptions(ol); }

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix.

Definition at line 71 of file MemoryVMatrix.cc.

References PLearn::declareOption(), and PLearn::OptionList.

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 220 of file MemoryVMatrix.cc.

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

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 206 of file MemoryVMatrix.cc.

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

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

Reimplemented from PLearn::VMatrix.

Definition at line 166 of file MemoryVMatrix.cc.

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

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

returns element (i,j)

Reimplemented from PLearn::VMatrix.

Definition at line 126 of file MemoryVMatrix.cc.

References data.

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 132 of file MemoryVMatrix.cc.

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

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 153 of file MemoryVMatrix.cc.

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

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

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

Reimplemented from PLearn::VMatrix.

Definition at line 148 of file MemoryVMatrix.cc.

References PLearn::TVec< T >::copyFrom(), and data.

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

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

Reimplemented from PLearn::VMatrix.

Definition at line 135 of file MemoryVMatrix.cc.

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

void PLearn::MemoryVMatrix::makeDeepCopyFromShallowCopy map< const void *, void * > &  copies  ) 
 

Reimplemented from PLearn::VMatrix.

Reimplemented in PLearn::GramVMatrix.

Definition at line 82 of file MemoryVMatrix.cc.

References data, data_vm, and PLearn::deepCopyField().

PLearn::MemoryVMatrix::PLEARN_DECLARE_OBJECT MemoryVMatrix   ) 
 

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

sets element (i,j) to value

Reimplemented from PLearn::VMatrix.

Definition at line 129 of file MemoryVMatrix.cc.

References data.

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 172 of file MemoryVMatrix.cc.

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

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

Reimplemented from PLearn::VMatrix.

Definition at line 169 of file MemoryVMatrix.cc.

References PLearn::TVec< T >::copyTo(), and data.

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 156 of file MemoryVMatrix.cc.

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

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 200 of file MemoryVMatrix.cc.

References data, MemoryVMatrix(), and PLearn::TMat< T >::subMat().

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

returns a Mat with the same data as this VMat The default version of this method copies the data in a fresh Mat created in memory 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.

Reimplemented from PLearn::VMatrix.

Definition at line 197 of file MemoryVMatrix.cc.

References data.


Member Data Documentation

Mat PLearn::MemoryVMatrix::data
 

Definition at line 58 of file MemoryVMatrix.h.

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

VMat PLearn::MemoryVMatrix::data_vm
 

Definition at line 59 of file MemoryVMatrix.h.

Referenced by build_(), and makeDeepCopyFromShallowCopy().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:26:27 2004 for PLearn by doxygen 1.3.7