MIMATRIX Class Reference

Matrix class. More...

#include <mi32/mimatrix.h>

List of all members.

Public Member Functions

 MIMATRIX (const MIMATRIX &rhs)
 MIMATRIX ()
 ~MIMATRIX ()
ERRVALUE Add (const MIMATRIX &matrix)
void Add (UINT32 row, UINT32 col, double value)
void AddScalar (double value)
double ComputeConditionNumber () const
double ComputeDeterminant () const
ERRVALUE ComputeEigen (MIMATRIX &EigenVectors, MIMATRIX &EigenValues) const
ERRVALUE ComputeInverse (MIMATRIX &result, UINT32 MaxIterations=0, double MaxError=0) const
double ComputeMaxAbsolute () const
ERRVALUE ComputePseudoInverse (MIMATRIX &result, double tolerance=0) const
ERRVALUE ComputeSVD (MIMATRIX &U, MIMATRIX &W, MIMATRIX &V) const
double ComputeTrace () const
ERRVALUE Create (UINT32 Rows, UINT32 Cols, const double *values=0)
ERRVALUE CreateDiagonal (const MIMATRIX &vector)
ERRVALUE CreateDiagonal (UINT32 Size, double value)
ERRVALUE CreateProduct (const MIMATRIX &left, const MIMATRIX &right)
ERRVALUE GetDiagonal (MIMATRIX &result) const
UINT32 GetNumColumns () const
UINT32 GetNumElements () const
UINT32 GetNumRows () const
double GetValueFast (UINT32 num) const
double GetValueFast (UINT32 row, UINT32 col) const
void GetValues (double *values) const
double GetValueValidated (UINT32 num) const
double GetValueValidated (UINT32 row, UINT32 col) const
bool IsDiagonal (double tolerance=0) const
bool IsEqual (const MIMATRIX &matrix, double tolerance=0) const
bool IsSameSize (const MIMATRIX &matrix) const
bool IsSingular () const
bool IsSymmetric (double tolerance=0) const
bool IsVector () const
ERRVALUE MultiplyLeft (const MIMATRIX &left)
ERRVALUE MultiplyRight (const MIMATRIX &right)
void MultiplyScalar (double value)
MIMATRIXoperator*= (double value)
const MIMATRIX operator- ()
MIMATRIXoperator/= (double value)
MIMATRIXoperator= (const MIMATRIX &rhs)
ERRVALUE ReplaceSubMatrix (UINT32 TgtStartRow, UINT32 TgtStartCol, const MIMATRIX &SrcMatrix, UINT32 SrcStartRow=0, UINT32 SrcStartCol=0, UINT32 NumRows=0, UINT32 NumCols=0)
ERRVALUE Resize (UINT32 Rows, UINT32 Cols)
void RotateClockwise ()
void SetIdentity ()
void SetScalar (double value)
void SetValueFast (UINT32 num, double value)
void SetValueFast (UINT32 row, UINT32 col, double value)
void SetValueValidated (UINT32 num, double value)
void SetValueValidated (UINT32 row, UINT32 col, double value)
void SetZero ()
ERRVALUE SolveLinear (const MIMATRIX &A, const MIMATRIX &B, double tolerance=0)
ERRVALUE SolveLinearSVD (const MIMATRIX &U, const MIMATRIX &W, const MIMATRIX &V, const MIMATRIX &B, double tolerance=0)
ERRVALUE Subtract (const MIMATRIX &matrix)
void Swap (MIMATRIX &other)
void Transpose ()

Detailed Description

Matrix class.


Constructor & Destructor Documentation

MIMATRIX::MIMATRIX (  ) 

Default constructor.

MIMATRIX::MIMATRIX ( const MIMATRIX rhs  ) 

Copy constructor.

MIMATRIX::~MIMATRIX (  ) 

Destructor.


Member Function Documentation

ERRVALUE MIMATRIX::Add ( const MIMATRIX matrix  ) 

Add matrix.

Matrix to be added must be same size as this matrix.

void MIMATRIX::Add ( UINT32  row,
UINT32  col,
double  value 
)

Add value to specified element.

void MIMATRIX::AddScalar ( double  value  ) 

Add scalar value to all elements in matrix.

double MIMATRIX::ComputeConditionNumber (  )  const

Compute "condition number" of matrix.

Returns:
0.0 instead of INFINITY to simplify handling of the result.

The condition number of a matrix is defined as the ratio of the largest (in magnitude) of the elements of matrix W to the smallest one. Where W is one of the results of SVD defined as: T A = U * W * V (see ComputeSVD). A matrix is singular if it's condition number is large.

double MIMATRIX::ComputeDeterminant (  )  const

Compute determinant.

ERRVALUE MIMATRIX::ComputeEigen ( MIMATRIX EigenVectors,
MIMATRIX EigenValues 
) const

Compute Eigenvectors and Eigenvalues from symmetric matrix.

Matrix must be symmetric, error will be returned if not.

Parameters:
EigenVectors Eigenvectors returned as columns
EigenValues Eigenvalues returned
ERRVALUE MIMATRIX::ComputeInverse ( MIMATRIX result,
UINT32  MaxIterations = 0,
double  MaxError = 0 
) const

Compute inverse of square matrix.

Parameters:
result Result matrix
MaxIterations Maximum number of iterations
double MIMATRIX::ComputeMaxAbsolute (  )  const

Compute maximum absolute element value.

ERRVALUE MIMATRIX::ComputePseudoInverse ( MIMATRIX result,
double  tolerance = 0 
) const

Compute pseudoinverse of matrix using SVD.

If Input matrix is not singular pseudoinverse is equal to normal inverse of the matrix. Pseudoinverse is such matrix X that satisfy the following condition: A * X * A = A, if matrix A is singular X still exists.

Parameters:
result Result matrix
tolerance Tolerance to use, 0 for default
ERRVALUE MIMATRIX::ComputeSVD ( MIMATRIX U,
MIMATRIX W,
MIMATRIX V 
) const

Compute Singular Value Decomposition (SVD).

This function computes SVD as A(MxN) = U(MxN) * W(N) * V(NxN)[transpose] ; Output matrix U has the same dimension as input matrix A and the columns will be the orthonormal basis vectors for A. The diagonal matrix of singular values W is output as a vector. The matrix V (not transpose of V) is output as a matrix.

Parameters:
W Returned
V Returned Returned
double MIMATRIX::ComputeTrace (  )  const

Compute trace (sum of diagonal elements).

ERRVALUE MIMATRIX::Create ( UINT32  Rows,
UINT32  Cols,
const double *  values = 0 
)

Create matrix of specified size.

Parameters:
Rows Number of rows
Cols Number of columns
values Initial values as Rows * Cols array
ERRVALUE MIMATRIX::CreateDiagonal ( const MIMATRIX vector  ) 

Create diagonal matrix from vector.

Will create a square matrix of order N + ABS(K) with elements of input on the K-th diagonal. K = 0 is the main diagonal, K > 0 is above main diagonal, K < 0 below.

Parameters:
vector One-dimensional matrix containing diagonal values
ERRVALUE MIMATRIX::CreateDiagonal ( UINT32  Size,
double  value 
)

Create diagonal matrix of specified size.

Parameters:
Size Size of matrix to create
value Value to replicate on diagonal
ERRVALUE MIMATRIX::CreateProduct ( const MIMATRIX left,
const MIMATRIX right 
)

Create matrix as product of two matrices.

Parameters:
left Left side of multiplication
right Right side of multiplication
ERRVALUE MIMATRIX::GetDiagonal ( MIMATRIX result  )  const

Get diagonal elements as column vector.

Parameters:
result Column vector returned
UINT32 MIMATRIX::GetNumColumns (  )  const [inline]

Get number of columns in matrix.

UINT32 MIMATRIX::GetNumElements (  )  const [inline]

Get number of matrix elements.

UINT32 MIMATRIX::GetNumRows (  )  const [inline]

Get number of rows in matrix.

double MIMATRIX::GetValueFast ( UINT32  num  )  const [inline]

Get vector value at location with no validation.

Intended for use on 'vector' matrix (1 x N or N x 1) only.

Parameters:
num Vector element number
double MIMATRIX::GetValueFast ( UINT32  row,
UINT32  col 
) const [inline]

Get value at location with no validation.

Parameters:
row Row (0-based)
col Column (0-based)
void MIMATRIX::GetValues ( double *  values  )  const

Get values as array.

Parameters:
values Values returned, must be large enough to hold all elements
double MIMATRIX::GetValueValidated ( UINT32  num  )  const

Get vector value at location with validation of element location.

Intended for use on 'vector' matrix (1 x N or N x 1) only.

Parameters:
num Vector element number
double MIMATRIX::GetValueValidated ( UINT32  row,
UINT32  col 
) const

Get value at location with validation of element location.

Parameters:
row Row (0-based)
col Column (0-based)
bool MIMATRIX::IsDiagonal ( double  tolerance = 0  )  const

Determine if matrix has at one non-zero element on main diagonal and zero everywhere else.

bool MIMATRIX::IsEqual ( const MIMATRIX matrix,
double  tolerance = 0 
) const

Determine if matrices are equal within specified tolerance.

Will return false if matrices are not the same size.

bool MIMATRIX::IsSameSize ( const MIMATRIX matrix  )  const [inline]

Determine if matrices are the same size.

bool MIMATRIX::IsSingular (  )  const

Determine if matrix is singular.

Uses ComputeConditionNumber with default limits. This is not a fast operation.

bool MIMATRIX::IsSymmetric ( double  tolerance = 0  )  const

Determine if matrix is symmetric.

bool MIMATRIX::IsVector (  )  const [inline]

Determine if matrix is a 'vector' (1 x N or N x 1 matrix).

ERRVALUE MIMATRIX::MultiplyLeft ( const MIMATRIX left  ) 

Left multiply (this = left * this).

ERRVALUE MIMATRIX::MultiplyRight ( const MIMATRIX right  ) 

Left multiply (this = this * right).

void MIMATRIX::MultiplyScalar ( double  value  ) 

Multiply all matrix elements by specified value.

MIMATRIX& MIMATRIX::operator*= ( double  value  )  [inline]

Multiply by scalar.

const MIMATRIX MIMATRIX::operator- (  )  [inline]

Negation.

MIMATRIX& MIMATRIX::operator/= ( double  value  )  [inline]

Divide by scalar.

MIMATRIX& MIMATRIX::operator= ( const MIMATRIX rhs  ) 

Assignment operator.

ERRVALUE MIMATRIX::ReplaceSubMatrix ( UINT32  TgtStartRow,
UINT32  TgtStartCol,
const MIMATRIX SrcMatrix,
UINT32  SrcStartRow = 0,
UINT32  SrcStartCol = 0,
UINT32  NumRows = 0,
UINT32  NumCols = 0 
)

Replace elements with submatrix of elements from another matrix.

Parameters:
TgtStartCol Target matrix starting row
SrcMatrix Target matrix starting column
SrcStartRow Source matrix
SrcStartCol Source matrix starting row
NumRows Source matrix starting column
NumCols Number of rows to replace, 0 for maximum possible Number of columns to replace, 0 for maximum possible
ERRVALUE MIMATRIX::Resize ( UINT32  Rows,
UINT32  Cols 
)

Resize matrix.

Newly created elements will be initialized to 0.

void MIMATRIX::RotateClockwise (  ) 

Rotate the matrix 90 degrees clockwise If tha matrix is not square, it will be resized (i.e., an NxM matrix will become an MxN matrix.

void MIMATRIX::SetIdentity (  ) 

Set matrix to identity.

void MIMATRIX::SetScalar ( double  value  ) 

Set all elements in matrix to a specified scalar value.

void MIMATRIX::SetValueFast ( UINT32  num,
double  value 
) [inline]

Set vector value at location with no validation.

Intended for use on 'vector' matrix (1 x N or N x 1) only.

Parameters:
value Vector element number
void MIMATRIX::SetValueFast ( UINT32  row,
UINT32  col,
double  value 
) [inline]

Set value at location with no validation.

void MIMATRIX::SetValueValidated ( UINT32  num,
double  value 
)

Set vector value at location with validation of element location.

Intended for use on 'vector' matrix (1 x N or N x 1) only.

Parameters:
value Vector element number
void MIMATRIX::SetValueValidated ( UINT32  row,
UINT32  col,
double  value 
)

Set value at location with validation of element location.

void MIMATRIX::SetZero (  )  [inline]

Set all matrix elements to zero.

ERRVALUE MIMATRIX::SolveLinear ( const MIMATRIX A,
const MIMATRIX B,
double  tolerance = 0 
)

Solve system of linear equations and put result in this matrix.

A * X = B where A(M x N) matrix and X (N) vector. B(M) is also a vector. This is done using ComputeSVD, if already have performed SVD then can use SolveLinearSVD for improved performance.

Parameters:
A M x N matrix of linear equations
B Vector of linear equation values
tolerance Tolerance, 0 to use default based on maximum value in SVD W matrix
ERRVALUE MIMATRIX::SolveLinearSVD ( const MIMATRIX U,
const MIMATRIX W,
const MIMATRIX V,
const MIMATRIX B,
double  tolerance = 0 
)

Solve system of linear equations using SVD components.

Parameters:
U From ComputeSVD
W From ComputeSVD
V From ComputeSVD
tolerance Tolerance, 0 to use default based on maximum value in SVD W matrix
ERRVALUE MIMATRIX::Subtract ( const MIMATRIX matrix  ) 

Subtract matrix.

Matrix to be subtracted must be same size as this matrix.

void MIMATRIX::Swap ( MIMATRIX other  ) 

Swap this matrix with another.

This is done by swapping memory pointers so is very fast.

Parameters:
other Matrix to swap with
void MIMATRIX::Transpose (  ) 

Transpose matrix.


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

Generated on Sun Oct 7 21:33:38 2012 for TNTsdk 2012 by  doxygen 1.6.1