tmath::Matrix Class Reference

Standard matrix class. More...

#include <matrix.hpp>

Inheritance diagram for tmath::Matrix:

Inheritance graph
[legend]
Collaboration diagram for tmath::Matrix:

Collaboration graph
[legend]

List of all members.

Public Types

typedef Eigen::Matrix< TScalar,
Eigen::Dynamic, Eigen::Dynamic,
Eigen::ColMajor > 
Base
typedef TScalar * TBuffer
typedef int TEigenIndex
typedef double TScalar
typedef unsigned int TUnsignedIndex

Public Member Functions

Matrix __neg__ () const
const char * __str__ () const
 transforms this objects into a string, required by SWIG
void Add (const Matrix &other)
 modifies this matrix by the matrix sum A+B
Matrix AppendColumns (const Matrix &m)
 returns an object including new data data
Matrix AppendRows (const Matrix &m)
void Assign (const MatrixBlock &ar)
 The assignment operator for blocks.
template<typename OtherDerived>
void Assign (const Eigen::MatrixBase< OtherDerived > &ar)
 converts this matrix to a scalar (in case that it is a scalar)
MatrixBlock Block (const TUnsignedIndex &row, const TUnsignedIndex &col, const TUnsignedIndex &numrows, const TUnsignedIndex &numcols)
 returns a reference to a block starting at 'row','column' with size 'numrows'*'numcols'
MatrixBlock Col (const TUnsignedIndex &col)
 returns a reference to the 'col'th column
TUnsignedIndex Cols () const
 returns the number of cols
void ConservativeResize (const TUnsignedIndex &rows, const TUnsignedIndex &cols=1)
MatrixCWise CW ()
 returns an object providing cwise access
void Div (const TScalar &other)
 modifies this matrix by the scalar matrix quotient A/s
TScalar Dot (const Matrix &other) const
 returns the scalar product of two vectors (a'b)
TScalar Dott (const Matrix &other) const
 returns the weighted scalar product of this matrix and the given vector multiplied once from left and once from right (b'Ab)
Matrix GetColumns (const TUnsignedIndex &col1, const TUnsignedIndex &ncol=1)
 returns an object providing copy of data
Matrix GetRows (const TUnsignedIndex &row1, const TUnsignedIndex &nrow=1)
Matrix InnerProduct (const Matrix &other) const
 returns the inner product of two vectors (a'*b)
bool IsApprox (const Matrix &other, const TScalar &s) const
 returns true if other and this are approx. identical
bool IsApproxToConstant (const TScalar &value, const TScalar &s) const
 returns true if array is constant and approx. equal s
bool IsDiagonal (const TScalar &s) const
 returns true if array is a diagonal matrix by precision s
bool IsIdentity (const TScalar &s) const
 returns true if array is the identity matrix by precision s
bool IsLowerTriangular (const TScalar &s) const
 returns true if array is a lower triangular matrix by precision s
bool IsScalar () const
 returns true if array is a scalar
bool IsUnitary (const TScalar &s) const
 returns true if array is a unitary matrix by precision s (is an orthonormal basis)
bool IsUpperTriangular (const TScalar &s) const
 returns true if array is an upper triangular matrix by precision s
bool IsVector () const
 returns true if array is a vector
bool IsZero (const TScalar &s) const
 returns true if array is a zero matrix by precision s
 Matrix (const sparse::SymSparseMatrix &x)
 copies from a symmetric sparse matrix
 Matrix (const sparse::SparseMatrix &x)
 copies from a sparse matrix
 Matrix (const MatrixBlock &x)
 constructs a matrix from a matrix block
 Matrix (const TUnsignedIndex &nrow, const TUnsignedIndex &ncol=1)
 constructs a matrix and allocates nrow*ncol elements
template<typename OtherDerived>
 Matrix (const Eigen::MatrixBase< OtherDerived > &x)
 copy constructor from Eigen objects
 Matrix (const Matrix &ar)
 copy constructor
 Matrix ()
 default constructor
TScalar MaxCoeff (TEigenIndex *row, TEigenIndex *col) const
TScalar MinCoeff (TEigenIndex *row, TEigenIndex *col) const
void Mul (const TScalar &other)
 modifies this matrix by the scalar matrix product A*s
Matrix operator* (const TScalar &other) const
 returns the scalar matrix product A*s
Matrix operator* (const Matrix &other) const
 returns the matrix product A*B
Matrix operator+ (const Matrix &other) const
 returns the matrix sum A+B
Matrix operator- (const Matrix &other) const
 returns the matrix difference A-B
Matrix operator/ (const TScalar &other) const
 returns the scalar matrix quotient A/s
Matrix operator< (const TScalar &x) const
 returns a matrix of 1 and 0 indicating which element is less than x
Matrix OuterProduct (const Matrix &other) const
 returns the outer product of two vectors (a*b')
void Print (const std::string &format="%g ", const TUnsignedIndex &rows=20, const TUnsignedIndex &cols=20) const
 prints the matrix up to the given rows and columns
MatrixBlock Row (const TUnsignedIndex &row)
 returns a reference to the 'row'th row
TUnsignedIndex Rows () const
 returns the number of rows
void SetColumns (const Matrix &m, const TUnsignedIndex &col)
 changes object data in place
void SetConstant (const TScalar &value)
 initializes the matrix with constant values
void SetIdentity ()
 initializes the matrix as identity matrix
void SetLinearCols (const TScalar &a, const TScalar &b)
 initializes the matrix with linear columns
void SetLinearRows (const TScalar &a, const TScalar &b)
 initializes the matrix with linear rows
void SetOnes ()
 initializes the matrix with constant values "1"
void SetRandom ()
 initializes the matrix with random values
void SetRows (const Matrix &m, const TUnsignedIndex &row)
void SetZero ()
 initializes the matrix with zeros
void Sub (const Matrix &other)
 modifies this matrix by the matrix difference A-B
template<typename OtherDerived>
void Swap (const Eigen::MatrixBase< OtherDerived > &ar)
 The swap operator.
Matrix Transpose () const
 returns the transpose
void TransposeInPlace ()
 transposes this matrix
virtual ~Matrix ()
 destructor


Detailed Description

Standard matrix class.

A class that represents storage for dense linalg objects.

The storage scheme is column_major (FORTRAN).

It is derived from Eigen::Matrix. Many operations have been added/overwritten for compatibility with scripting requirements. Most operations of Eigen2 are still available.

Basic Eigen linalg operators have been overloaded. To access a linalg operator from C++, for example the matrix product, type

                                Matrix x,y,z;
                                ...
                                z = x.Base::operator*(z)
This will give you the fastest operation possible within the Eigen library. The overloaded operators have some if-clauses and do not make use of expression templates what may harm performance.

Matrix offers a handling for complex numbers which differs from Eigen: The odd columns are the real parts and the odd columns contain the imaginary parts.

Some of the underlying Eigen methods are available for SWIG. They are not integrated into the error chacking system, though! neverthelesse, ften they are the most efficient methods. To distuingish between Eigen and own methods, the Eigen methods identifiers start with a noncapital first letter, our own methods start with a capital letter.

Operators for SWIG are provided using the methods __add__, etc., The SWIG-operators must be safeguarded, whereas the C++-operators should be the original Eigen2 operators. Therefore they must be defined separately on C++ level.

Matrix is useing a reference counter system. It is advised not to use 'delete Matrix();' to remove it from memory, but to use removeReference.


Member Function Documentation

Matrix tmath::Matrix::__neg__ (  )  const [inline]

returns unary minus (B=-A)

template<typename OtherDerived>
void tmath::Matrix::Assign ( const Eigen::MatrixBase< OtherDerived > &  ar  )  [inline]

converts this matrix to a scalar (in case that it is a scalar)

The assignment operator

void tmath::Matrix::ConservativeResize ( const TUnsignedIndex &  rows,
const TUnsignedIndex &  cols = 1 
)

resizes the matrix to its new dimensions without destroying the contents. Internally it creates a copy of the object (nothing if memory is crucial).

TScalar tmath::Matrix::MaxCoeff ( TEigenIndex *  row,
TEigenIndex *  col 
) const [inline]

find the largest element in the array returns the maximum element in the array

Parameters:
row will be modified and will contain the row position of the found value on return
col will be modified and will contain the column position of the found value on return

TScalar tmath::Matrix::MinCoeff ( TEigenIndex *  row,
TEigenIndex *  col 
) const [inline]

find the smallest element in the array returns the minimum element in the array

Parameters:
row will be modified and will contain the row position of the found value on return
col will be modified and will contain the column position of the found value on return


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

Generated on Wed Nov 17 17:36:01 2010 for 'tmath' Module Programming Interface by  doxygen 1.5.6