Developer Documentation
Centre for Vision, Speech & Signal Processing
USER IN NAMESPACE AMMA TREE ROOT AMMA SEARCH AMMA HOME
 

  PUBLIC
MatrixC::MatrixC(void)
MatrixC::MatrixC(const SizeT,const SizeT)
MatrixC::MatrixC(const SizeT,const SizeT,RealT)
MatrixC::MatrixC(const MatrixC &)
MatrixC::MatrixC(const Matrix3d3C &)
MatrixC::MatrixC(const Matrix2d2C &)
MatrixC::MatrixC(const VectorC &)
MatrixC::MatrixC(istream &)
MatrixC::operator=(const MatrixC &)
MatrixC::Copy(void) const
MatrixC::~MatrixC(void)
MatrixC::IsValid(void) const
MatrixC::operator[](IndexT) const
MatrixC::operator[](IndexT)
MatrixC::Matrix(void) const
MatrixC::Matrix(void)
MatrixC::SubMatrix(const SizeT,const SizeT) const
MatrixC::GetDiag(void) const
MatrixC::GetRow(IndexT) const
MatrixC::GetColumn(IndexT) const
MatrixC::RDim(void) const
MatrixC::CDim(void) const
MatrixC::G(IndexT,IndexT) const
MatrixC::P(IndexT,IndexT)
MatrixC::ColumnModulus(IndexT) const
MatrixC::SubtractColumnFrom(IndexT,IndexT,RealT)
MatrixC::DivColumn(IndexT,RealT)
MatrixC::MakeUnitColumn(IndexT)
MatrixC::DotColumns(IndexT,IndexT) const
MatrixC::Fill(RealT)
MatrixC::SetZero(void)
MatrixC::SetRandom(RealT)
MatrixC::SetRandom(RealT,RealT)
MatrixC::SetDiag(const VectorC &)
MatrixC::SetRow(const IndexT,const VectorC &,const IndexT)
MatrixC::SetCol(const IndexT,const VectorC &,const IndexT)
MatrixC::SetRow(const IndexT,const IndexT,const VectorC &,const IndexT,const IndexT)
MatrixC::SetCol(const IndexT,const IndexT,const VectorC &,const IndexT,const IndexT)
MatrixC::SwapRows(const IndexT,const IndexT)
MatrixC::SwapCols(const IndexT,const IndexT)
MatrixC::SetSmallToBeZero(RealT)
MatrixC::EDiag(void)
MatrixC::operator+(const MatrixC &) const
MatrixC::operator-(const MatrixC &) const
MatrixC::operator+=(const MatrixC &)
MatrixC::operator+=(const RealT)
MatrixC::operator-=(const MatrixC &)
MatrixC::operator-=(const RealT)
MatrixC::operator*=(const RealT)
MatrixC::operator/=(const RealT)
MatrixC::operator*(const RealT) const
MatrixC::operator*(const VectorC &) const
MatrixC::operator*(const MatrixC &) const
MatrixC::AddDiag(const VectorC &)
MatrixC::MulDiag(const VectorC &)
MatrixC::DiagMul(const VectorC &)
MatrixC::MulT(const MatrixC &) const
MatrixC::TMul(const MatrixC &) const
MatrixC::T(void) const
MatrixC::Trace(void) const
MatrixC::I(void) const
MatrixC::NearSingularI(void)
MatrixC::InPlaceI(void)
MatrixC::OrgI(void) const
MatrixC::LUDecomposition(RealT &)
MatrixC::LUSolution(VectorC &)
MatrixC::SVD(VectorC &,MatrixC &,MatrixC &)
MatrixC::SVD(VectorC &,MatrixC &,const RealT)
MatrixC::OrgSVD(VectorC &,MatrixC &,const RealT)
MatrixC::SVD(const RealT)
MatrixC::Det(void)
MatrixC::IsSingular(void)
MatrixC::DiagonalProduct(void) const
MatrixC::WalshTransformation(const IntSArray1dC &,const IntSArray1dC &,IntT)
MatrixC::ColumnGramSchmidtOrthogonalization(void)
MatrixC::FixSmallToBeZero(RealT)
MatrixC::Identity(UIntT)
MatrixC::SumOfAbs(void) const
MatrixC::ErrNotValidOrInRange(IndexT,IndexT,char *) const
MatrixC::ErrNotValid(char *) const
MatrixC::AllocData(void)
MatrixC::DeallocData(void)
MatrixC::operator<<(ostream &,const MatrixC &)
MatrixC::operator>>(istream &,MatrixC &)
MatrixC
 
General matrix ndim x mdim
 
include "amma/Matrix.hh"
User Level:Default
Library:Mlalg
Example:exEndPoint.cc
Section:Basic Types.Numerical Geometry.N-D
In Scope:std

Comments:
The class MatrixC represents the NxM matrix of real numbers. MatrixC is a BIG object.

Parent Classes: Derived Classes: Variables:
RealT ** data;

SizeT rows;

SizeT cols;

Methods:
MatrixC()
Empty matrix

MatrixC(const SizeT r,const SizeT c)
Matrix r x c
NB. In check and debug modes the matrix is filled with Nan. In optimised its contents are random.

MatrixC(const SizeT r,const SizeT c,RealT setVal)
Matrix r x c, filled with setVal.

MatrixC(const MatrixC & m)
Another access to the matrix m

MatrixC(const Matrix3d3C & mat)
Create a new matrix 3 x 3 and copy the content of the matrix mat

MatrixC(const Matrix2d2C & mat)
Create a new matrix 2 x 2 and copy the content of the matrix mat

MatrixC(const VectorC & oth)
Construct one column matrix.
This make a copy of VectorC 'oth'.

MatrixC(istream & s)
Create a new matrix from input stream

const MatrixC & operator=(const MatrixC & mat)
Assignment of a big object

MatrixC Copy() const

~MatrixC()
Destructor

BooleanT IsValid() const
Returns TRUE if this matrix exists.

Access to the elements


const SizeBufferAccessC<RealT> operator[](IndexT r) const
Access to the row of the constant matrix

SizeBufferAccessC<RealT> operator[](IndexT r)
Access to the row of the matrix

const MatrixC & Matrix() const
Access to the constant matrix

MatrixC & Matrix()
Access to the matrix

MatrixC SubMatrix(const SizeT sr,const SizeT sc) const
Returns the submatrix created from the first 'sr' rows and 'sc' columns of this matrix.
This makes a copy of the matrix elements specified.

VectorC GetDiag() const
Creates the vector of the diagonal elements

VectorC GetRow(IndexT r) const
Creates the vector of elements of the row 'r'.

VectorC GetColumn(IndexT c) const
Creates the vector of elements of the column 'c'.

SizeT RDim() const
Return the number of rows

SizeT CDim() const
Return the number of columns

RealT G(IndexT r,IndexT c) const
Get the value

RealT & P(IndexT r,IndexT c)
Put the value

RealT ColumnModulus(IndexT c) const
Returns the modulus of the column 'c'.

void SubtractColumnFrom(IndexT c1,IndexT c2,RealT a)
Subtracts the column 'c2' multiplied by the parameter 'a' from the column 'c1'.

void DivColumn(IndexT c,RealT val)
Divides the column 'c' by the value val.

RealT MakeUnitColumn(IndexT c)
Divides the column 'c' by its modulus. Returns its original modulus.

RealT DotColumns(IndexT c1,IndexT c2) const
Returns the dot product of columns 'c1' and 'c2'.

Set element values


void Fill(RealT val)
Fill matrix with value 'val'

MatrixC & SetZero()
set all elements to be zero

MatrixC & SetRandom(RealT scale = 1)
set all elements to be random value, between 0 and 'scale'.

MatrixC & SetRandom(RealT lo,RealT hi)
set all elements to uniformly random between lo and hi

MatrixC & SetDiag(const VectorC & vec)
set the diagonal elements according to vec

MatrixC & SetRow(const IndexT r,const VectorC & vec,const IndexT n)
Sets the first 'n' elements of the row 'r' according to the first 'n' elements of the vector 'vec'.

MatrixC & SetCol(const IndexT c,const VectorC & vec,const IndexT n)
Sets the first 'n' elements of the column 'c' according to the first 'n' elements of the vector 'vec'.

MatrixC & SetRow(const IndexT r,const IndexT c,const VectorC & vec,const IndexT s1,const IndexT s2)
Sets the elements of the row 'r' starting at the column 'c' according to the elements of the vector 'vec' with the indexes in the range .

MatrixC & SetCol(const IndexT r,const IndexT c,const VectorC & vec,const IndexT s1,const IndexT s2)
Sets the elements of the column 'c' starting at the row 'r' according to the elements of the vector 'vec' with the indexes in the range .

MatrixC & SwapRows(const IndexT r1,const IndexT r2)
Swaps the row 'r1' and 'r2'.

MatrixC & SwapCols(const IndexT c1,const IndexT c2)
Swaps the columns 'c1' and 'c2'.

MatrixC & SetSmallToBeZero(RealT thr)
Set all elements smaller than 'thr' to be zero.

MatrixC & EDiag()
Set all diagonal elements to be 1.0

Arithmetic operators


MatrixC operator+(const MatrixC & mat) const
Sum 2 matrixes "MatrixC" = "This" + mat

MatrixC operator-(const MatrixC & mat) const
Subtract 2 matrixes "MatrixC" = "This" - mat

MatrixC & operator+=(const MatrixC & mat)
Add the matrix "mat": "This" = "This" + mat

MatrixC & operator+=(const RealT alpha)
Add scalar to each element of matrix i.e. "mat": "This" = "This" + alpha

MatrixC & operator-=(const MatrixC & mat)
Subtract the matrix "mat": "This" = "This" - mat

MatrixC & operator-=(const RealT alpha)
Subtract scalar from each element in the matrix "mat": "This" = "This" - alpha

MatrixC & operator*=(const RealT a)
Multiplication "Matrix" = "Matrix" * "Scalar"

MatrixC & operator/=(const RealT a)
Division "Matrix" = "Matrix" / "Scalar"

MatrixC operator*(const RealT a) const
Multiply this matrix by the scalar 'a'.

VectorC operator*(const VectorC & vector) const
Multiplication "VectorC" = "This" * vector

MatrixC operator*(const MatrixC & mat) const
Multiplication "result" = "this" * "mat"

MatrixC & AddDiag(const VectorC & v)
Adds the diagonal matrix represented by the vector 'v' (m = m + v).

MatrixC & MulDiag(const VectorC & v)
Multiplies the matrix from the right by the diagonal matrix represented by the vector 'v' (m = m * v).

MatrixC & DiagMul(const VectorC & v)
Multiplies the matrix from the left by the diagonal matrix represented by the vector 'v' (m = v * m).

MatrixC MulT(const MatrixC & mat) const
Multiplication A * B.T()

MatrixC TMul(const MatrixC & mat) const
Multiplication A.T() * B

MatrixC T() const
Returns the transposition of this matrix.

RealT Trace() const
Returns the trace of this matrix.

Matrix inversion and decomposition


MatrixC I() const
Returns the inversion of this matrix.
Uses the algorithm from InPlaceI(), unless matrix is non-square, in which case OrgI() is called. The original matrix is preserved, however.

RealT NearSingularI()
Inverts this matrix and returns determinant of original matrix.
This routine is particularly useful when you matrices are near singular as it uses PCA to first rotate co-ordinate axis, so no nasty divisions. See Fukunaga -Introduction to Statistical Pat Rec, page 40.

RealT InPlaceI()
Replaces the original matrix with its inverse, and returns its determinant.
Uses the in-place Gauss-Jordan elimination method.

MatrixC OrgI() const
Returns the inversion of this matrix.
Radek's original inversion routine. Does something even with non-square matrices.

IntSArray1dC LUDecomposition(RealT & d)
This function replaces this matrix by the LU decomposition of a row-wise permutation of itself.
The lower triangle submatrix has got the diagonal unity elements. The returned index array records the row permutation effected by the partial pivoting. 'd' is output as +-1 depending on whether the number of row interchanges was even or odd, respectively.

VectorC LUSolution(VectorC & rightSide)
Returns the vector X that is the solution of the linear system described by the matrix equation A*X=B, where A is this matrix, and the vector B is equal to the vector 'rightSide'.
The method used is the LU decomposition.
BUG: NOT IMPLEMENTED

void SVD(VectorC & d,MatrixC & u,MatrixC & v)
Singular value decomposition. DO NOT USE. It does not work.

void SVD(VectorC & d,MatrixC & v,const RealT isSmall = 1e-8)
Singular value decomposition, eg. M = U * D * V.T().
The function changes the input matrix M to U. The diagonal matrix D is returned as the vector 'd' and the matrix V is returned as the matrix 'v'. Both object 'd' and 'v' are supposed to have the proper size.

void OrgSVD(VectorC & d,MatrixC & v,const RealT isSmall = 1e-8)
The original NR SVD. (Default).

VecMatC SVD(const RealT isSmall = 1e-8)
Singular value decomposition, eg. M = U * D * V.T().
The function changes the input matrix M to U. The diagonal matrix D is returned as the vector in the result object and the matrix V is returned as the matrix in the result object. The singular values are not ordered. The effect of isSmall is not known in detail to CG or AJS It is provided as a feature for experimentation - if interested users should perhaps consult the Numerical Recipes Book At a rough guess decreasing this number will give a more accurate result, but it might not converge?

RealT Det()
Returns the determinant of this matrix. The matrix is changed.

BooleanT IsSingular()
Returns TRUE if the matrix is singular.
The SVD is used for computation of the determinant. The matrix is changed.
BUG: DO NOT TRUST

Miscellaneous


RealT DiagonalProduct() const
Returns the product of the diagonal elements.

MatrixC & WalshTransformation(const IntSArray1dC & lbr,const IntSArray1dC & lbc,IntT ifun)
2D Walsh-Hadamard transformation
lbr bit-reversal field of the size RDim()
lbc bit-reversal field of the size CDim()
ifunType of ordering (I),
IFUN=1
Hadamard ordering
IFUN=2 ... Walsh ordering

MatrixC & ColumnGramSchmidtOrthogonalization()
Performs Gram-Schmidt orthogonalisation of columns of this matrix.

MatrixC & FixSmallToBeZero(RealT thr = 1e-12)
All elements whose absolute values are smaller than 'thr' are changed to be zero.

MatrixC Identity(UIntT size)
Construct an identity matrix of size * size.

RealT SumOfAbs() const
Sum of the absolute value of all the elements of the matrix.

void ErrNotValidOrInRange(IndexT r,IndexT c,char * functionName) const
Triggers the error event if the matrix is not valid or the indexes 'r' or 'c' are out of their range.

void ErrNotValid(char * functionName) const
Triggers the error event if this matrix is not valid.

void AllocData()
Allocates the memory for the matrix.

void DeallocData()
Deallocates the memory for the matrix.

ostream & operator<<(ostream & s,const MatrixC & mat)

istream & operator>>(istream & s,MatrixC & mat)


Programmer:Radek Marik, Documentation by CxxDoc: Tue Mar 20 10:49:27 2001