tngmath::MathArrayBase< Scalar > Class Template Reference

#include <matharray.hpp>

Inheritance diagram for tngmath::MathArrayBase< Scalar >:

Inheritance graph
[legend]
Collaboration diagram for tngmath::MathArrayBase< Scalar >:

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 TIndex
typedef Scalar TScalar

Public Member Functions

TScalar __getitem__ (const TIndex &i) const
 like Get(i), but with asserts (required by SWIG)
void __setitem__ (const TIndex &i, const TScalar &d)
 like Set(i,d), but with asserts (required by SWIG)
char * __str__ () const
 transforms this objects into a string, required by SWIG
MathArrayBase< TScalar > AppendedColumns (const MathArrayBase< TScalar > &ar) const
 returns an array with appended object ar (appended as columns)
MathArrayBase< TScalar > AppendedRows (const MathArrayBase< TScalar > &ar) const
 returns an array with appended object ar (appended as rows)
void Assign (const MathArrayBase< TScalar > &ar)
 The assignment operator for MathArrayBase<TScalar>.
MathArrayBase< TScalar > Col (const TIndex &col) const
 returns the given column as vector
TScalar Cols () const
 returns the number of cols
void ConservativeResize (const TIndex &rows, const TIndex &cols=1)
MathArrayBase< TScalar > Cross (const MathArrayBase< TScalar > &x) const
 returns the cross product of two 3-dimensional vectors
void DeleteCol (const TIndex &col)
 deletes the given column in this array
MathArrayBase< TScalar > DeletedColumns (const TIndex &col, const TIndex &col2) const
 returns an array with deleted columns col..col2 (col2<0 means: single column)
MathArrayBase< TScalar > DeletedRows (const TIndex &row, const TIndex &row2) const
 returns an array with deleted rows row..row2 (row2<0 means: single row)
TScalar Determinant () const
 returns the determinant of this matrix (using LU)
TScalar Dot (const MathArrayBase< TScalar > &other) const
 returns the scalar product of two vectors (a'b)
TScalar Dott (const MathArrayBase< TScalar > &other) const
 returns the weighted scalar product of this matrix and tehgiven vector multiplied once from left and once from right (b'Ab)
void EigenSymInPlace (const MathArrayBase< TScalar > &mass, MathArrayBase< TScalar > &eval, MathArrayBase< TScalar > &evec) const
void EigenSymInPlace (const MathArrayBase< TScalar > &mass, MathArrayBase< TScalar > **eval, MathArrayBase< TScalar > **evec) const
 returns the eigenvalues and eigenvectors, if this is a symmetric matrix
void EigenSymInPlace (MathArrayBase< TScalar > &eval, MathArrayBase< TScalar > &evec) const
void EigenSymInPlace (MathArrayBase< TScalar > **eval, MathArrayBase< TScalar > **evec) const
 returns the eigenvalues and eigenvectors, if this is a symmetric matrix
MathArrayBase< TScalar > ExtractBlock (const TIndex &row, const TIndex &col, const TIndex &row2, const TIndex &col2) const
 returns a given block; empty columns and rows are allowed
MathArrayBase< TScalar > ExtractColumns (const TIndex &col, const TIndex &col2=-1) const
 returns the columns in the given range; col2<0 means col2=col; col>col2 means no columns
MathArrayBase< TScalar > ExtractDiagonal () const
 extracts the diagonal of the matrix as a vector; needs not to be quadratic
MathArrayBase< TScalar > ExtractRows (const TIndex &row, const TIndex &row2=-1) const
 returns the rows in the given range; row2<0 means row2=row; row>row2 means no rows
TScalar Get (const TIndex &nrow, const TIndex &ncol) const
 returns matrix element given by nrow,ncol, with asserts; also see coeff()
TScalar Get (const TIndex &nrow) const
 returns vector element given by nrow, with asserts
MathArrayBase< TScalar > GramSchmidt (const MathArrayBase< TScalar > &x) const
void GramSchmidt (const TIndex &col)
MathArrayBase< TScalar > GramSchmidt () const
 returns the Gram-Schmidt orthogonalized basis of this matrix
MathArrayBase< TScalar > Hankel (const TIndex &m) const
 returns the Hankel transform of this array; it will have dimension [(rows-m+1)*cols]x[m]
void Init ()
 sets all elements to zero
MathArrayBase< TScalar > InnerProduct (const MathArrayBase< TScalar > &other) const
 returns the inner product of two vectors (a'*b)
MathArrayBase< TScalar > Inverse () const
 returns the inverse matrix using LU decomposition
bool IsApprox (const MathArrayBase< TScalar > &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
MathArrayBase< TScalar > LinearRegression (const MathArrayBase< TScalar > &y, const bool compute) const
 performs a linear regression of array.
 MathArrayBase (const TIndex &nrow, const TIndex &ncol=1)
 constructs a matrix and allocates nrow*ncol elements
template<typename OtherDerived>
 MathArrayBase (const Eigen::MatrixBase< OtherDerived > &x)
 copy constructor from Eigen objects
 MathArrayBase (const MathArrayBase< TScalar > &ar)
 copy constructor
 MathArrayBase ()
 default constructor
TScalar MaxCoeff (TIndex *row, TIndex *col) const
TScalar MinCoeff (TIndex *row, TIndex *col) const
void ModAdd (const MathArrayBase< TScalar > &other)
 modifies this matrix by the matrix sum A+B
void ModDiv (const TScalar &other)
 modifies this matrix by the scalar matrix quotient A/s
void ModMul (const TScalar &other)
 modifies this matrix by the scalar matrix product A*s
void ModSub (const MathArrayBase< TScalar > &other)
 modifies this matrix by the matrix difference A-B
TScalar Norm () const
 returns the l2-norm of this matrix
void Normalize ()
 modifies this matrix such that it has normalized components
MathArrayBase< TScalar > Normalized () const
 creates an array from this with normalized components and returns it
MathArrayBase< TScalar > operator* (const TScalar &other) const
 returns the scalar matrix product A*s
MathArrayBase< TScalar > operator* (const MathArrayBase< TScalar > &other) const
 returns the matrix product A*B
MathArrayBase< TScalar > operator+ (const MathArrayBase< TScalar > &other) const
 returns the matrix sum A+B
MathArrayBase< TScalar > operator- (const MathArrayBase< TScalar > &other) const
 returns the matrix difference A-B
MathArrayBase< TScalar > operator/ (const TScalar &other) const
 returns the scalar matrix quotient A/s
template<typename OtherDerived>
MathArrayBase< TScalar > & operator= (const Eigen::MatrixBase< OtherDerived > &other)
 The assignment operator for Eigen matrix objects (required for inheriting Eigen matrix class).
MathArrayBase< TScalar > & operator= (const MathArrayBase< TScalar > &ar)
 The assignment operator for MathArrayBase<TScalar>.
MathArrayBase< TScalar > OuterProduct (const MathArrayBase< TScalar > &other) const
 returns the outer product of two vectors (a*b')
void Output (const std::string &file) const
void Print (const std::string &format="%g ") const
 calls a printf using the given format
void PrintComplex (const std::string &format="%g ") const
 calls a printf using the given format; the even columns are interpreted as imaginary parts
MathArrayBase< TScalar > QuadraticRegression (const MathArrayBase< TScalar > &y, const bool full, const bool compute) const
TScalar Rank () const
 returns the rank of this matrix (using LU)
MathArrayBase< TScalar > Rasterize (TScalar xlo, TScalar xhi, const TIndex &nx, TScalar ylo, TScalar yhi, const TIndex &ny, const bool trans=false) const
void Read (const TIndex &n, const TBuffer &x)
void Resize (const TIndex &rows, const TIndex &cols=1)
 resized the data buffer regardless of the column layout.
MathArrayBase< TScalar > Rotate (const MathArrayBase< TScalar > &center, const MathArrayBase< TScalar > &omega) const
MathArrayBase< TScalar > Row (const TIndex &row) const
 returns the given row as row vector
TScalar Rows () const
 returns the number of rows
void Set (const TIndex &nrow, const TIndex &ncol, const TScalar &val)
 sets the component at matrix index nrow*ncol, with asserts; also see coeffRef()
void Set (const TIndex &nrow, const TScalar &val)
 sets the component at vector index nrow, with asserts
void Set (const TScalar &val)
 sets the value to all components of the object
void SetBlock (const MathArrayBase< TScalar > &ar, const TIndex &row, const TIndex &col)
 inserts the block ar at given position
void SetColumns (const TIndex &col, const MathArrayBase< TScalar > &ar)
 sets the given column to ar
void SetConstant (const Scalar &value)
 initializes the matrix with constant values
void SetDiagonal (const MathArrayBase< TScalar > &d)
 sets the diagonal to vector 'd'; no square matrix required
void SetDiagonal (const TScalar &d)
 sets the diagonal to 'd'; no square matrix required
void SetIdentity ()
 initializes the matrix as identity matrix
void SetLinearMap (const TScalar &lefttop, const TScalar &bottom, const TScalar &right)
 initializes the matrix as a linear map with the values lefttop, bottom, right at its borders
void SetLinearMap (const TScalar &lefttop, const TScalar &bottom)
void SetOnes ()
 initializes the matrix with constant values "1"
void SetRandom ()
 initializes the matrix with random values
void SetRows (const TIndex &row, const MathArrayBase< TScalar > &ar)
 sets the given row to ar
void SetZero ()
 initializes the matrix with zeros
MathArrayBase< TScalar > SolveLowerTriangular (const MathArrayBase< TScalar > &n) const
 if this is an lower triangular matrix, the matrix/vector n is inverted and returned
MathArrayBase< TScalar > SolveUpperTriangular (const MathArrayBase< TScalar > &n) const
 if this is an upper triangular matrix, the matrix/vector n is inverted and returned
MathArrayBase< TScalar > Sort (const TIndex &col=0, const bool up=true) const
TScalar Sum () const
 returns the algebraic sum of all elements
void SVDInPlace (MathArrayBase< TScalar > &svalues, MathArrayBase< TScalar > &mat_U, MathArrayBase< TScalar > &mat_V) const
void SVDInPlace (MathArrayBase< TScalar > **svalues, MathArrayBase< TScalar > **mat_U, MathArrayBase< TScalar > **mat_V) const
 returns the singular values and vectors of this matrix (rows()>=cols()) with A=U*diag(S)*V'
template<typename OtherDerived>
void Swap (Eigen::MatrixBase< OtherDerived > &other)
 swaps the data pointers of both objects (fastest way to transfer data)
void Swap (MathArrayBase< TScalar > &other)
 swaps the data pointers of both objects (fastest way to transfer data)
TScalar ToScalar () const
 converts this matrix to an XMatrix object (copies data)
MathArrayBase< TScalar > Trace () const
 returns the trace of this matrix
MathArrayBase< TScalar > Transpose () const
 returns the transpose
void TransposeInPlace ()
 transposes this matrix
virtual ~MathArrayBase ()
 destructor

Static Public Member Functions

static MathArrayBase< TScalar > Constant (const TIndex &rows, const TIndex &cols, const Scalar &value)
static MathArrayBase< TScalar > Constant (const TIndex &rows, const Scalar &value)
 returns a matrix with constant values
static MathArrayBase< TScalar > Identity (const TIndex &rows, const TIndex &cols)
 returns a matrix as identity matrix
static MathArrayBase< TScalar > Ones (const TIndex &rows, const TIndex &cols=1)
 returns a matrix with constant values "1"
static MathArrayBase< TScalar > Random (const TIndex &rows, const TIndex &cols=1)
 returns a matrix with random values
static MathArrayBase< TScalar > Zero (const TIndex &rows, const TIndex &cols=1)
 returns a matrix with zeros


Detailed Description

template<typename Scalar>
class tngmath::MathArrayBase< Scalar >

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

                                MathArray 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 which may harm performance.

MathArray 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.


Member Function Documentation

template<typename Scalar>
void tngmath::MathArrayBase< Scalar >::ConservativeResize ( const TIndex &  rows,
const TIndex &  cols = 1 
)

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

template<typename Scalar>
MathArrayBase<TScalar> tngmath::MathArrayBase< Scalar >::GramSchmidt ( const MathArrayBase< TScalar > &  x  )  const

returns a matrix consisting of x and this matrix being appended by column. x may be interpreted as a starting set of orthogonal vectors (but are not required to be orthogonal, only independent) The columns which have been appended will be orthogonalized.

template<typename Scalar>
void tngmath::MathArrayBase< Scalar >::GramSchmidt ( const TIndex &  col  ) 

modifies this matrix by Gram-Schmidt orthogonalization, whereby only the columns starting at col are considered during orthogonalization.

template<typename Scalar>
MathArrayBase<TScalar> tngmath::MathArrayBase< Scalar >::LinearRegression ( const MathArrayBase< TScalar > &  y,
const bool  compute 
) const

performs a linear regression of array.

Todo:
parameters docu

template<typename Scalar>
TScalar tngmath::MathArrayBase< Scalar >::MaxCoeff ( TIndex *  row,
TIndex *  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

template<typename Scalar>
TScalar tngmath::MathArrayBase< Scalar >::MinCoeff ( TIndex *  row,
TIndex *  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

template<typename Scalar>
void tngmath::MathArrayBase< Scalar >::Output ( const std::string &  file  )  const

writes the objects to a file. if the extension is '.bin', then the output format is binary. the file is overwritten if existing.

template<typename Scalar>
MathArrayBase<TScalar> tngmath::MathArrayBase< Scalar >::QuadraticRegression ( const MathArrayBase< TScalar > &  y,
const bool  full,
const bool  compute 
) const

Todo:
docu

template<typename Scalar>
MathArrayBase<TScalar> tngmath::MathArrayBase< Scalar >::Rasterize ( TScalar  xlo,
TScalar  xhi,
const TIndex &  nx,
TScalar  ylo,
TScalar  yhi,
const TIndex &  ny,
const bool  trans = false 
) const

Todo:
check parameters (const + reference) + docu

template<typename Scalar>
void tngmath::MathArrayBase< Scalar >::Read ( const TIndex &  n,
const TBuffer &  x 
)

reads the contents of the buffer x into the array. n must be the dimension of x and equal to the dimension of the array.

template<typename Scalar>
MathArrayBase<TScalar> tngmath::MathArrayBase< Scalar >::Rotate ( const MathArrayBase< TScalar > &  center,
const MathArrayBase< TScalar > &  omega 
) const

Rotates all columns of array around an axis defined by omega (length of omega is the angle) centr denotes the origin of the rotation

template<typename Scalar>
void tngmath::MathArrayBase< Scalar >::SetLinearMap ( const TScalar &  lefttop,
const TScalar &  bottom 
) [inline]

template<typename Scalar>
MathArrayBase<TScalar> tngmath::MathArrayBase< Scalar >::Sort ( const TIndex &  col = 0,
const bool  up = true 
) const

sorts the entries in the matrix in the specified column and returns the sorted array 'up' specifies if the items shall be sorted in ascending order

template<typename Scalar>
TScalar tngmath::MathArrayBase< Scalar >::ToScalar (  )  const

converts this matrix to an XMatrix object (copies data)

converts this matrix to an XMatrix object the data of this object will be deleted afterwards (moves data; is, therefore, fast) converts this matrix to a scalar (in case that it is a scalar)


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

Generated on Wed Nov 17 17:35:51 2010 for 'tngmath' Module Programming Interface by  doxygen 1.5.6