Sleipnir
Public Member Functions
Sleipnir::CFullMatrix< tType > Class Template Reference

An asymmetric two-dimensional matrix. More...

#include <fullmatrix.h>

Public Member Functions

void Reset ()
 Empties the matrix and deallocates all associated memory.
tType **const Get () const
 Return the two-dimensional array backing the matrix.
tType * Get (size_t iY) const
 Return a single row of the matrix.
tType & Get (size_t iY, size_t iX) const
 Returns the value at the requested matrix position.
void Set (size_t iY, size_t iX, const tType &Value)
 Set the value at the requested matrix position.
void Set (size_t iY, const tType *aValues)
 Set a single row of the matrix.
void Initialize (const CFullMatrix &Mat)
 Create a new matrix using a reference to the given matrix.
virtual void Initialize (size_t iR, size_t iC, tType **aaData=NULL)
 Create a new matrix of the requested size and, optionally, referencing the given data.
size_t GetRows () const
 Return the number of rows in the matrix.
size_t GetColumns () const
 Return the number of columns in the matrix.
bool Open (std::istream &istm, bool fBinary)
 Loads a matrix from the given stream.
bool Open (const char *szFile)
 Loads a matrix from the given filename, or standard input if null.
bool Open (const CFullMatrix &Mat)
 Creates a copy of the given matrix's data.
bool Save (std::ostream &ostm, bool fBinary) const
 Saves a matrix to the given stream in either binary or tab-delimited text format.
bool Save (const char *szFile) const
 Saves a matrix to the given file in binary form; if null, save text to standard output.
bool Save (const char *szFile, bool fBinary) const
 Saves a matrix to the given stream in either binary or tab-delimited text format.
void Clear ()
 Sets all entries of the matrix to 0 without changing its size.
bool AddRows (size_t iR, bool fClear=false)
 Increases the number of rows in the matrix by the requested amount.
bool Multiply (std::vector< tType > &vecRight)
 Performs matrix multiplication by applying the given vector on the right of the current matrix.
bool Multiply (const CFullMatrix &MatRight, bool fTranspose=false)
 Performs matrix multiplication by applying the given matrix on the right of the current matrix.
bool SVD (CFullMatrix< tType > &MatU, CFullMatrix< tType > &MatV, std::vector< tType > &vecS) const
 Performs singular value decomposition of the current matrix.

Detailed Description

template<class tType>
class Sleipnir::CFullMatrix< tType >

An asymmetric two-dimensional matrix.

Parameters:
tTypeType of element contained by the matrix.
Remarks:
Essentially nothing except a lack of bounds checking for efficiency's sake separates this from every other 2D matrix implementation known to man.
See also:
CCompactMatrix | CHalfMatrix

Definition at line 52 of file fullmatrix.h.


Member Function Documentation

template<class tType>
bool Sleipnir::CFullMatrix< tType >::AddRows ( size_t  iR,
bool  fClear = false 
) [inline]

Increases the number of rows in the matrix by the requested amount.

Parameters:
iRNumber of rows to append to the matrix.
fClearIf true, set all values in the new rows to zero.
Returns:
True if the rows were appended successfully.
Remarks:
On success, GetRows will be increased by the requested amount. The news rows are not initialized to any particular value.

Definition at line 421 of file fullmatrix.h.

Referenced by Sleipnir::CPCL::AddGenes().

template<class tType>
tType** const Sleipnir::CFullMatrix< tType >::Get ( ) const [inline]
template<class tType>
tType* Sleipnir::CFullMatrix< tType >::Get ( size_t  iY) const [inline]

Return a single row of the matrix.

Parameters:
iYMatrix row.
Returns:
Requested matrix row.
Remarks:
For efficiency, no bounds checking is performed. The given row must be smaller than the size. The returned array will contain a number of elements equal to the number of columns.
See also:
Set

Definition at line 103 of file fullmatrix.h.

template<class tType>
tType& Sleipnir::CFullMatrix< tType >::Get ( size_t  iY,
size_t  iX 
) const [inline]

Returns the value at the requested matrix position.

Parameters:
iYMatrix row.
iXMatrix column.
Returns:
Value at the requested matrix position.
Remarks:
For efficiency, no bounds checking is performed. The given row and column must be smaller than the size.
See also:
Set

Definition at line 127 of file fullmatrix.h.

template<class tType>
size_t Sleipnir::CFullMatrix< tType >::GetColumns ( ) const [inline]
template<class tType>
size_t Sleipnir::CFullMatrix< tType >::GetRows ( ) const [inline]
template<class tType>
void Sleipnir::CFullMatrix< tType >::Initialize ( const CFullMatrix< tType > &  Mat) [inline]
template<class tType>
virtual void Sleipnir::CFullMatrix< tType >::Initialize ( size_t  iR,
size_t  iC,
tType **  aaData = NULL 
) [inline, virtual]

Create a new matrix of the requested size and, optionally, referencing the given data.

Parameters:
iRMatrix rows.
iCMatrix columns.
aaDataIf non-null, the memory that will back the newly created matrix.
Remarks:
A reference is held to the given memory; it is not copied, so it should not be destroyed before the newly initialized matrix.

Definition at line 208 of file fullmatrix.h.

template<class tType>
bool Sleipnir::CFullMatrix< tType >::Multiply ( std::vector< tType > &  vecRight) [inline]

Performs matrix multiplication by applying the given vector on the right of the current matrix.

Parameters:
vecRightVector by which current matrix is multiplied on the right.
Returns:
True on success, false if the given vector is of an inappropriate size.
Remarks:
vecRight must have the same number of entries as the current matrix has columns.
See also:
Multiply

Definition at line 456 of file fullmatrix.h.

template<class tType>
bool Sleipnir::CFullMatrix< tType >::Multiply ( const CFullMatrix< tType > &  MatRight,
bool  fTranspose = false 
) [inline]

Performs matrix multiplication by applying the given matrix on the right of the current matrix.

Parameters:
MatRightMatrix by which current matrix is multiplied on the right.
fTransposeIf true, transpose MatRight prior to multiplication.
Returns:
True on success, false if MatRight is of inappropriate dimensions.
Remarks:
If fTranspose is false, MatRight must have the same number of rows as the current matrix has columns; if it is true, MatRight and the current matrix must have the same number of columns.
See also:
Multiply

Definition at line 488 of file fullmatrix.h.

template<class tType>
bool Sleipnir::CFullMatrix< tType >::Open ( std::istream &  istm,
bool  fBinary 
) [inline]

Loads a matrix from the given stream.

Parameters:
istmStream from which matrix is loaded.
fBinaryIf true, matrix and stream are in binary format.
Returns:
True if matrix was loaded successfully.
Remarks:
A binary matrix is saved in row-major order and should have been produced using Save. A text matrix is a simple tab-delimited file from which matrix elements are read using >>.

Definition at line 264 of file fullmatrix.h.

Referenced by Sleipnir::CFullMatrix< CExampleImpl >::Multiply(), Sleipnir::CStatistics::MultivariateNormalPDF(), Sleipnir::CFullMatrix< CExampleImpl >::Open(), Sleipnir::CBayesNetMinimal::Open(), Sleipnir::CSeekTools::ReadPlatforms(), and Sleipnir::CFullMatrix< CExampleImpl >::SVD().

template<class tType>
bool Sleipnir::CFullMatrix< tType >::Open ( const char *  szFile) [inline]

Loads a matrix from the given filename, or standard input if null.

Parameters:
szFileFile from which binary matrix is opened; if null, use text from standard input.
Returns:
True if open was successful, false otherwise.
See also:
Save

Definition at line 281 of file fullmatrix.h.

template<class tType>
bool Sleipnir::CFullMatrix< tType >::Open ( const CFullMatrix< tType > &  Mat) [inline]

Creates a copy of the given matrix's data.

Parameters:
MatMatrix from which data is copied.
Returns:
True if matrix was copied successfully.
Remarks:
Matrix will be resized if dimensions do not match exactly.
See also:
Initialize

Definition at line 307 of file fullmatrix.h.

template<class tType>
bool Sleipnir::CFullMatrix< tType >::Save ( std::ostream &  ostm,
bool  fBinary 
) const [inline]

Saves a matrix to the given stream in either binary or tab-delimited text format.

Parameters:
ostmStream to which matrix is saved.
fBinaryIf true, matrix is saved in binary format; otherwise, matrix is saved as tab-delimited text.
Returns:
True if matrix was saved successfully.
Remarks:
A binary matrix is saved in row-major order; a text matrix is a simple tab-delimited file from which matrix elements are read using >>.
See also:
Open

Definition at line 338 of file fullmatrix.h.

Referenced by Sleipnir::CBayesNetMinimal::Save(), and Sleipnir::CFullMatrix< CExampleImpl >::Save().

template<class tType>
bool Sleipnir::CFullMatrix< tType >::Save ( const char *  szFile) const [inline]

Saves a matrix to the given file in binary form; if null, save text to standard output.

Parameters:
szFileFile in which binary matrix is saved; if null, text is saved to standard output.
Returns:
True if matrix was saved successfully.
See also:
Open

Definition at line 355 of file fullmatrix.h.

template<class tType>
bool Sleipnir::CFullMatrix< tType >::Save ( const char *  szFile,
bool  fBinary 
) const [inline]

Saves a matrix to the given stream in either binary or tab-delimited text format.

Parameters:
szFileFile to which matrix is saved.
fBinaryIf true, matrix is saved in binary format; otherwise, matrix is saved as tab-delimited text.
Returns:
True if matrix was saved successfully.
Remarks:
A binary matrix is saved in row-major order; a text matrix is a simple tab-delimited file from which matrix elements are read using >>.
See also:
Open

Definition at line 385 of file fullmatrix.h.

template<class tType>
void Sleipnir::CFullMatrix< tType >::Set ( size_t  iY,
size_t  iX,
const tType &  Value 
) [inline]

Set the value at the requested matrix position.

Parameters:
iYMatrix row.
iXMatrix column.
ValueValue to store.
Remarks:
For efficiency, no bounds checking is performed. The given row and column must be smaller than the size.
See also:
Get

Definition at line 151 of file fullmatrix.h.

Referenced by Sleipnir::CPCL::AddGenes(), Sleipnir::CStatistics::CholeskyDecomposition(), Sleipnir::CClustKMeans::Cluster(), Sleipnir::CStatistics::MatrixLUDecompose(), Sleipnir::CStatistics::MatrixLUInvert(), Sleipnir::CFullMatrix< CExampleImpl >::Multiply(), Sleipnir::CPCLSet::Open(), Sleipnir::CPCL::Open(), Sleipnir::CBayesNetMinimal::OpenCounts(), Sleipnir::CPCL::Set(), Sleipnir::CHMM::SetUniform(), and Sleipnir::CFullMatrix< CExampleImpl >::SVD().

template<class tType>
void Sleipnir::CFullMatrix< tType >::Set ( size_t  iY,
const tType *  aValues 
) [inline]

Set a single row of the matrix.

Parameters:
iYMatrix row.
aValuesData to be copied into the requested row.
Remarks:
For efficiency, no bounds checking is performed. The given row must be smaller than the size, and the given data array must be at least as long as the number of columns.
See also:
Get

Definition at line 172 of file fullmatrix.h.

template<class tType>
bool Sleipnir::CFullMatrix< tType >::SVD ( CFullMatrix< tType > &  MatU,
CFullMatrix< tType > &  MatV,
std::vector< tType > &  vecS 
) const [inline]

Performs singular value decomposition of the current matrix.

Parameters:
MatUOutput U matrix of basis vectors.
MatVOutput V matrix of analysis vectors.
vecSOutput diagonal of Sigma matrix of singular values.
Returns:
True on success, false if the matrix cannot be decomposed.

Outputs a singular value decomposition of the current matrix M such that M = U * Sigma * V'. For a matrix of expression values, V behaves as eigengenes, U as eigenconditions, and S quantifies the variability (or weight) attributable to each eigengene.

Remarks:
Matrix must not contain any missing values. Implementation courtesy of AJ Sedgewick.

Definition at line 529 of file fullmatrix.h.


The documentation for this class was generated from the following file: