#include <TMat_decl.h>
Inheritance diagram for PLearn::TMat< T >:
Public Types | |
typedef T | value_type |
typedef int | size_type |
typedef TMatElementIterator< T > | iterator |
typedef TMatElementIterator< T > | const_iterator |
typedef T * | compact_iterator |
typedef T * | rowelements_iterator |
typedef TMatRowsIterator< T > | rows_iterator |
typedef TMatRowsAsArraysIterator< T > | rows_as_arrays_iterator |
typedef TMatColRowsIterator< T > | colrows_iterator |
Public Member Functions | |
int | nrows () const |
for template compatibility with other types of matrices | |
int | ncols () const |
TMat () | |
TMat (int the_length, int the_width) | |
TMat (int the_length, int the_width, const T &init_value) | |
TMat (int the_length, int the_width, T *the_data) | |
TMat (int the_length, int the_width, const TVec< T > &v) | |
const TMat< T > & | operator= (const TMat< T > &other) |
NOTE: operator= COPIES THE TMat STRUCTURE BUT NOT THE DATA (use operator<< to copy data). | |
iterator | begin () const |
returns an iterator over elements | |
iterator | end () const |
compact_iterator | compact_begin () const |
returns a compact_iterator, which is an iterator over elements, but that works only if the matrix is compact | |
compact_iterator | compact_end () const |
rowelements_iterator | rowelements_begin (int rownum) const |
returns an iterator over the elements of a particular row | |
rowelements_iterator | rowelements_end (int rownum) const |
IMPORTANT WARNING: use this only to check reaching the end with an iterator obtained through rowelements_begin USING THE *SAME* rownum. | |
TMatRowsIterator< T > | rows_begin () |
Return an iterator over all rows of the matrix. | |
TMatRowsIterator< T > | rows_end () |
TMatRowsAsArraysIterator< T > | rows_as_arrays_begin () |
Return an iterator over all rows of the matrix. | |
TMatRowsAsArraysIterator< T > | rows_as_arrays_end () |
TMatColRowsIterator< T > | col_begin (int column) |
Return an iterator over a single column of the matrix. | |
TMatColRowsIterator< T > | col_end (int column) |
This version is not strictly standards-compliant since the end-pointer is beyond 1-past-the-end-of-the-array. | |
void | resize (int newlength, int newwidth, int extrabytes=0) |
int | length () const |
int | width () const |
int | size () const |
int | mod () const |
PP< Storage< T > > | getStorage () const |
bool | isSquare () const |
bool | hasMissing () const |
T * | data () const |
Returns a pointer to the beginning of the matrix data. | |
T * | operator[] (int rownum) const |
Returns a pointer to the data beginning of the required row. | |
T * | rowdata (int i) const |
T & | operator() (int rownum, int colnum) const |
TVec< T > | operator() (int rownum) const |
void | write (PStream &out) const |
writes the Mat to the PStream: Note that users should rather use the form out << m; | |
void | read (PStream &in) |
reads the Mat from the PStream: Note that users should rather use the form in >> m; | |
void | save (const string &filename) const |
void | load (const string &filename) |
TMat< T > | column (int colnum) const |
Returns a TMat that is a column of the matrix. | |
TMat< T > | firstColumn () const |
TMat< T > | lastColumn () const |
TMat< T > | row (int row) const |
Returns a Mat that is a row of the matrix. | |
T & | firstElement () const |
T & | lastElement () const |
TVec< T > | firstRow () const |
TVec< T > | lastRow () const |
TVec< T > | front () const |
TVec< T > | back () const |
template<class I> TMat< T > | columns (const TVec< I > &columns) const |
selectColumns(*this,columns,result) i.e. | |
template<class I> TMat< T > | rows (const TVec< I > &rows) const |
selectRows(*this,rows,result) i.e. | |
bool | operator== (const TMat< T > &other) const |
template<class I> TMat< T > | operator() (const TVec< I > &rows, const TVec< I > &columns) const |
TMat< T > | subMat (int rowstart, int colstart, int newlength, int newwidth) const |
Returns a sub-matrix that is a rectangular portion of this matrix. | |
TMat< T > | subMatRows (int rowstart, int newlength) const |
Returns a sub-matrix that is a range of rows of this matrix. | |
TMat< T > | subMatColumns (int colstart, int newwidth) const |
Returns a sub-matrix that is a range of columns of this matrix. | |
TMat< T > | copy () const |
returns a newly created copy of this Matrix | |
void | copyTo (T *x) const |
copy to a C vector starting at x | |
void | makeDeepCopyFromShallowCopy (map< const void *, void * > &copies) |
TMat< T > | deepCopy (map< const void *, void * > &copies) const |
TVec< T > | toVecCopy () const |
Copy of data. | |
TVec< T > | toVec () const |
Views same data (not always possible) Actually it's the matrix view rows by rows. | |
bool | isNull () const |
bool | isNotNull () const |
bool | isEmpty () const |
bool | isNotEmpty () const |
bool | operator! () const |
To allow if(!m) statements. | |
void | fill (const T &value) const |
void | operator= (const T &f) const |
void | clear () const |
void | swapRows (int i, int j) const |
swap the contents of row i and row j | |
int | findRow (const TVec< T > &row) const |
void | appendRow (const TVec< T > &newrow) |
void | push_back (const TVec< T > &newrow) |
stl-like push_back and pop_back | |
void | pop_back () |
bool | isCompact () const |
bool | isSymmetric () const |
void | compact () |
Makes sure the allocated memory for this matrix is exactly length()*width(). | |
void | transpose () |
void | swapUpsideDown () const |
void | print (ostream &out=cout) const |
C++ stream output. | |
void | input (istream &in=cin) const |
void | debugPrint () |
void | operator<< (const string &datastring) const |
Protected Attributes | |
int | offset_ |
int | mod_ |
int | length_ |
int | width_ |
PP< Storage< T > > | storage |
Friends | |
class | TVec< T > |
|
Definition at line 94 of file TMat_decl.h. |
|
Definition at line 89 of file TMat_decl.h. |
|
Definition at line 88 of file TMat_decl.h. |
|
Definition at line 87 of file TMat_decl.h. |
|
Definition at line 90 of file TMat_decl.h. |
|
Definition at line 93 of file TMat_decl.h. |
|
Definition at line 92 of file TMat_decl.h. |
|
Definition at line 86 of file TMat_decl.h. |
|
Definition at line 85 of file TMat_decl.h. |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 297 of file TMat_impl.h. References PLearn::TMat< T >::length(), PLearn::TVec< T >::length(), PLERROR, resize(), PLearn::TMat< T >::storage, and PLearn::TMat< T >::width(). Referenced by PLearn::MemoryVMatrix::appendRow(), and PLearn::multivariate_normal(). |
|
Definition at line 515 of file TMat_decl.h. |
|
returns an iterator over elements
Definition at line 365 of file TMat_impl.h. References PLearn::TMat< T >::data(), PLearn::TMat< T >::mod_, and PLearn::TMat< T >::width_. Referenced by PLearn::dot(), PLearn::fill_random_normal(), PLearn::fill_random_uniform(), PLearn::TMat< pair< real, real > >::hasMissing(), PLearn::multiply(), PLearn::multiplyAcc(), PLearn::TMat< pair< real, real > >::operator==(), PLearn::squareElements(), PLearn::sumabs(), PLearn::sumsquare(), and PLearn::swap(). |
|
|
Return an iterator over a single column of the matrix. No const version for now. In other words, this iterator views a single column of the matrix AS A VECTOR to iterate on; very useful for STL algorithms. Definition at line 395 of file TMat_impl.h. References PLearn::TMat< T >::data(), and PLearn::TMat< T >::mod_. |
|
This version is not strictly standards-compliant since the end-pointer is beyond 1-past-the-end-of-the-array. But this pointer is never dereferenced and should work on all reasonable architectures Definition at line 400 of file TMat_impl.h. References PLearn::TMat< T >::data(), PLearn::TMat< T >::length_, and PLearn::TMat< T >::mod_. |
|
|
selectColumns(*this,columns,result) i.e. return the matrix with specified columns (indices) Definition at line 520 of file TMat_decl.h. |
|
Makes sure the allocated memory for this matrix is exactly length()*width().
Definition at line 755 of file TMat_decl.h. Referenced by PLearn::grep(). |
|
returns a compact_iterator, which is an iterator over elements, but that works only if the matrix is compact
Definition at line 134 of file TMat_decl.h. Referenced by PLearn::multiply(), PLearn::multiplyAcc(), PLearn::squareElements(), PLearn::sumabs(), and PLearn::sumsquare(). |
|
Definition at line 143 of file TMat_decl.h. Referenced by PLearn::multiply(), PLearn::multiplyAcc(), PLearn::squareElements(), PLearn::sumabs(), and PLearn::sumsquare(). |
|
returns a newly created copy of this Matrix
Definition at line 606 of file TMat_decl.h. Referenced by PLearn::TMat< pair< real, real > >::compact(), PLearn::det(), PLearn::diagonalizeSubspace(), PLearn::loadLetters(), PLearn::multivariate_normal(), PLearn::operator *(), PLearn::operator+(), PLearn::operator-(), PLearn::operator/(), PLearn::Gnuplot::plotClasses(), and PLearn::Function::verifyHessian(). |
|
copy to a C vector starting at x
Definition at line 614 of file TMat_decl.h. |
|
|
Definition at line 791 of file TMat_decl.h. |
|
Notice that deepCopy of a Mat returns a Mat rather than a Mat*. The reason for this being that a Mat is already some kind of "smart pointer" to an underlying Storage Definition at line 352 of file TMat_impl.h. References PLearn::TMat< T >::makeDeepCopyFromShallowCopy(). Referenced by PLearn::deepCopy(). |
|
|
|
Definition at line 288 of file TMat_impl.h. References PLearn::TMat< T >::length(). |
|
Definition at line 499 of file TMat_decl.h. |
|
Definition at line 509 of file TMat_decl.h. Referenced by PLearn::trace(). |
|
Definition at line 512 of file TMat_decl.h. Referenced by PLearn::MatrixAffineTransformVariable::bprop(), PLearn::AffineTransformVariable::bprop(), PLearn::MatrixAffineTransformFeedbackVariable::fprop(), and PLearn::TMat< pair< real, real > >::front(). |
|
Definition at line 514 of file TMat_decl.h. |
|
Definition at line 231 of file TMat_decl.h. |
|
Definition at line 237 of file TMat_decl.h. Referenced by PLearn::SequentialModelSelector::train(). |
|
Definition at line 329 of file TMat_impl.h. References PLearn::TMat< T >::length(), PLERROR, PLearn::TMat< T >::rowdata(), and PLearn::TMat< T >::width(). Referenced by PLearn::operator>>(). |
|
|
Definition at line 649 of file TMat_decl.h. Referenced by PLearn::RemapLastColumnVMatrix::getNewRow(), PLearn::lapackEIGEN(), PLearn::lapackGeneralizedEIGEN(), and PLearn::TMat< pair< real, real > >::operator!(). |
|
Definition at line 652 of file TMat_decl.h. Referenced by PLearn::YMDDatedVMatrix::build_(), PLearn::computeConditionalMeans(), PLearn::SequentialLearner::forget(), PLearn::lapackEIGEN(), PLearn::lapackGeneralizedEIGEN(), PLearn::lapackSVD(), and PLearn::MatRowVariable::recomputeSize(). |
|
Definition at line 646 of file TMat_decl.h. Referenced by PLearn::TMat< pair< real, real > >::fill(). |
|
Definition at line 643 of file TMat_decl.h. |
|
Definition at line 234 of file TMat_decl.h. Referenced by PLearn::TMat< pair< real, real > >::isSymmetric(), PLearn::makeItSymmetric(), and PLearn::trace(). |
|
Definition at line 735 of file TMat_decl.h. Referenced by PLearn::eigen_SymmMat(). |
|
Definition at line 502 of file TMat_decl.h. Referenced by PLearn::RGBImageDB::computeHistogramRepresentation(), and PLearn::Gnuplot::featureplot(). |
|
Definition at line 510 of file TMat_decl.h. |
|
Definition at line 513 of file TMat_decl.h. Referenced by PLearn::TMat< pair< real, real > >::back(). |
|
|
Definition at line 493 of file TMat_decl.h. Referenced by PLearn::loadClassificationDataset(). |
|
************ Deep copying Definition at line 346 of file TMat_impl.h. References PLearn::deepCopyField(), and PLearn::TMat< T >::storage. Referenced by PLearn::TMat< T >::deepCopy(), and PLearn::deepCopyField(). |
|
|
Definition at line 81 of file TMat_decl.h. |
|
for template compatibility with other types of matrices
Definition at line 80 of file TMat_decl.h. |
|
To allow if(!m) statements. This method is commented out because it is much too dangerous: it allows a TMat to be converted into an int, which can cause some very weird bugs that the compiler would have caught otherwise. Definition at line 665 of file TMat_decl.h. |
|
Definition at line 555 of file TMat_decl.h. |
|
Definition at line 279 of file TMat_decl.h. |
|
Definition at line 269 of file TMat_decl.h. |
|
Definition at line 794 of file TMat_decl.h. |
|
Definition at line 686 of file TMat_decl.h. |
|
NOTE: operator= COPIES THE TMat STRUCTURE BUT NOT THE DATA (use operator<< to copy data).
Definition at line 119 of file TMat_decl.h. |
|
Definition at line 537 of file TMat_decl.h. |
|
Returns a pointer to the data beginning of the required row.
Definition at line 258 of file TMat_decl.h. |
|
Definition at line 729 of file TMat_decl.h. |
|
C++ stream output.
Definition at line 315 of file TMat_impl.h. References PLearn::TMat< T >::length(), PLearn::TMat< T >::rowdata(), and PLearn::TMat< T >::width(). Referenced by PLearn::operator<<(). |
|
stl-like push_back and pop_back
Definition at line 728 of file TMat_decl.h. |
|
reads the Mat from the PStream: Note that users should rather use the form in >> m;
Definition at line 394 of file TMat_decl.h. Referenced by PLearn::operator>>(). |
|
|
Returns a Mat that is a row of the matrix.
Definition at line 506 of file TMat_decl.h. Referenced by PLearn::VarRowsVariable::bprop(), PLearn::KNNVMatrix::build_(), and PLearn::Variable::clearGradient(). |
|
|
returns an iterator over the elements of a particular row
Definition at line 147 of file TMat_decl.h. |
|
IMPORTANT WARNING: use this only to check reaching the end with an iterator obtained through rowelements_begin USING THE *SAME* rownum.
Definition at line 158 of file TMat_decl.h. |
|
selectRows(*this,rows,result) i.e. return the matrix with specified rows (indices) Definition at line 530 of file TMat_decl.h. |
|
Return an iterator over all rows of the matrix. No const version for now Definition at line 385 of file TMat_impl.h. References PLearn::TMat< T >::data(), PLearn::TMat< T >::mod_, and PLearn::TMat< T >::width_. Referenced by PLearn::sortRows(). |
|
Definition at line 390 of file TMat_impl.h. References PLearn::TMat< T >::data(), PLearn::TMat< T >::length_, PLearn::TMat< T >::mod_, and PLearn::TMat< T >::width_. Referenced by PLearn::sortRows(). |
|
Return an iterator over all rows of the matrix. No const version for now Definition at line 374 of file TMat_impl.h. References PLearn::TMat< T >::data(), PLearn::TMat< T >::mod_, and PLearn::TMat< T >::width_. |
|
Definition at line 379 of file TMat_impl.h. References PLearn::TMat< T >::data(), PLearn::TMat< T >::length_, PLearn::TMat< T >::mod_, and PLearn::TMat< T >::width_. |
|
Definition at line 492 of file TMat_decl.h. |
|
|
Returns a sub-matrix that is a rectangular portion of this matrix.
Definition at line 563 of file TMat_decl.h. Referenced by PLearn::ProjectionErrorVariable::build_(), PLearn::ReconstructionWeightsKernel::evaluate_x_i_again(), PLearn::LiftStatsIterator::finish(), PLearn::SequentialLearner::getCostSequence(), PLearn::VMatrixFromDistribution::getMat(), PLearn::MemoryVMatrix::getMat(), PLearn::loadCorel(), PLearn::MemoryVMatrix::putMat(), PLearn::MemoryVMatrix::subMat(), PLearn::SequentialModelSelector::train(), and PLearn::GaussMix::updateFromConditionalSorting(). |
|
Returns a sub-matrix that is a range of columns of this matrix.
Definition at line 593 of file TMat_decl.h. Referenced by PLearn::StringTable::appendRow(), PLearn::RGBImageDB::computeHistogramRepresentation(), PLearn::Kernel::estimateHistograms(), PLearn::Gnuplot::featureplot(), PLearn::hconcat(), PLearn::loadATT800(), PLearn::loadBreastCancerWisconsin(), PLearn::loadDiabetes(), PLearn::loadHousing(), PLearn::loadLetters(), PLearn::loadPimaIndians(), PLearn::loadUCI(), PLearn::newIndexedMatArray(), PLearn::normalizeDataSets(), PLearn::operator^(), PLearn::removeColumn(), and PLearn::PCA::train(). |
|
Returns a sub-matrix that is a range of rows of this matrix.
Definition at line 580 of file TMat_decl.h. Referenced by PLearn::MatrixAffineTransformVariable::bprop(), PLearn::AffineTransformVariable::bprop(), PLearn::KernelProjection::computeOutput(), PLearn::IsomapTangentLearner::computeOutput(), PLearn::diagonalizeSubspace(), PLearn::MatrixAffineTransformFeedbackVariable::fprop(), PLearn::loadATT800(), PLearn::loadBreastCancer(), PLearn::loadDiabetes(), PLearn::loadLetters(), PLearn::loadUCI(), PLearn::newIndexedMatArray(), PLearn::removeRow(), PLearn::TestDependenciesCommand::run(), PLearn::PCA::train(), PLearn::LinearRegressor::train(), PLearn::KernelProjection::train(), and PLearn::vconcat(). |
|
swap the contents of row i and row j
Definition at line 706 of file TMat_decl.h. Referenced by PLearn::LU_decomposition(), PLearn::partialSortRows(), PLearn::selectAndOrder(), PLearn::shuffleRows(), and PLearn::sortRows(). |
|
Definition at line 779 of file TMat_decl.h. Referenced by PLearn::eigen_SymmMat_decreasing(), PLearn::eigenVecOfSymmMat(), and PLearn::generalizedEigenVecOfSymmMat(). |
|
|
Copy of data.
Definition at line 264 of file TMat_impl.h. References PLearn::TMat< T >::length(), and PLearn::TMat< T >::width(). Referenced by PLearn::columnWeightedMean(), PLearn::columnWeightedVariance(), PLearn::displayHistogram(), PLearn::fullyRebalance2Classes(), and PLearn::rebalanceNClasses(). |
|
Definition at line 765 of file TMat_decl.h. |
|
|
writes the Mat to the PStream: Note that users should rather use the form out << m;
Definition at line 294 of file TMat_decl.h. |
|
Definition at line 66 of file TMat_decl.h. |
|
the actual length() of the matrix Definition at line 73 of file TMat_decl.h. Referenced by PLearn::TMat< T >::col_end(), PLearn::TMat< T >::end(), PLearn::TMat< pair< real, real > >::operator=(), PLearn::TMat< T >::rows_as_arrays_end(), PLearn::TMat< T >::rows_end(), PLearn::TMat< pair< real, real > >::subMat(), PLearn::TMat< pair< real, real > >::subMatRows(), and PLearn::TVec< T >::toMat(). |
|
|
the displacement to do with respect to storage->data Definition at line 71 of file TMat_decl.h. Referenced by PLearn::Variable::makeSharedGradient(), PLearn::Variable::makeSharedRValue(), PLearn::Variable::makeSharedValue(), PLearn::TMat< pair< real, real > >::operator=(), PLearn::TMat< pair< real, real > >::subMat(), PLearn::TMat< pair< real, real > >::subMatColumns(), PLearn::TMat< pair< real, real > >::subMatRows(), PLearn::TVec< T >::toMat(), and PLearn::TMat< T >::toVec(). |
|
where the data is really kept Definition at line 75 of file TMat_decl.h. Referenced by PLearn::TMat< T >::appendRow(), PLearn::TMat< T >::makeDeepCopyFromShallowCopy(), PLearn::Variable::makeSharedGradient(), PLearn::Variable::makeSharedRValue(), PLearn::Variable::makeSharedValue(), PLearn::TMat< pair< real, real > >::operator=(), PLearn::TVec< T >::toMat(), and PLearn::TMat< T >::toVec(). |
|
the actual width() of the matrix Definition at line 74 of file TMat_decl.h. Referenced by PLearn::TMat< T >::begin(), PLearn::TMat< T >::end(), PLearn::TMat< pair< real, real > >::operator=(), PLearn::TMat< T >::rows_as_arrays_begin(), PLearn::TMat< T >::rows_as_arrays_end(), PLearn::TMat< T >::rows_begin(), PLearn::TMat< T >::rows_end(), PLearn::TMat< pair< real, real > >::subMat(), PLearn::TMat< pair< real, real > >::subMatColumns(), and PLearn::TVec< T >::toMat(). |