mi32/matrix.h File Reference

<mi32/matrix.h> More...

#include <mi32/stddefns.h>
Include dependency graph for matrix.h:

Go to the source code of this file.

Classes

struct  _MATRIX

Defines

#define MATFLAG_NoDiagonal   0x00000002
#define MATFLAG_Symmetric   0x00000001
#define MatGetValue(m, i, j)   ((m)->matrix[i][j])
#define MatIsSymmetric(m)   ((m)->flags&MATFLAG_Symmetric)
#define MatSetValue(m, i, j, v)   ((m)->matrix[i][j]=(v))

Typedefs

typedef DEPRECATED struct _MATRIXMATRIX

Functions

int MatAddMatrix (MATRIX outmatrix, MATRIX matrixA, MATRIX matrixB)
int MatCopy (MATRIX *outmatrix, MATRIX inmatrix)
int MatCreate (MATRIX *matrix, UINT16 rows, UINT16 cols, UINT32 flags)
void MatDestroy (MATRIX matrix)
int MatDeterminant (MATRIX matrix, double *detvalue)
int MatEigenvectors (MATRIX matrix, MATRIX *vectors, MATRIX *values)
double MatGetValueTest (MATRIX matrix, UINT16 row, UINT16 col)
int MatInverse (MATRIX outmatrix, MATRIX inmatrix, int maxiterations, double maxerror)
int MatMultMatrix (MATRIX outmatrix, MATRIX matrixA, MATRIX matrixB)
void MatMultScalar (MATRIX matrix, double value)
int MatPseudoInverse (MATRIX inverse, MATRIX input, double tolerance)
void MatSetScalar (MATRIX matrix, double value)
int MatSubMatrix (MATRIX outmatrix, MATRIX matrixA, MATRIX matrixB)
int MatSVD (MATRIX A, MATRIX *U, MATRIX *W, MATRIX *V)
int MatSVDSolve (MATRIX A, MATRIX B, MATRIX X, double tolerance)
int MatSVDSolveAutoTolerance (MATRIX A, MATRIX B, MATRIX X)
int MatSVDSolveAutoToleranceFast (MATRIX A, MATRIX U, MATRIX W, MATRIX V, MATRIX B, MATRIX X)
double MatTrace (MATRIX matrix)
int MatTranspose (MATRIX outmatrix, MATRIX inmatrix)

Detailed Description

<mi32/matrix.h>

Definitions for matrix manipulation functions


Define Documentation

#define MATFLAG_NoDiagonal   0x00000002

Don't allocate space for diagonal (symmetric only).

#define MATFLAG_Symmetric   0x00000001

Matrix is symmetric.

#define MatGetValue ( m,
i,
 )     ((m)->matrix[i][j])

Retrieve value from matrix.

#define MatIsSymmetric (  )     ((m)->flags&MATFLAG_Symmetric)

Determine if "symmetric" flag set for a matrix.

#define MatSetValue ( m,
i,
j,
 )     ((m)->matrix[i][j]=(v))

Set single matrix entry to a specified value.


Typedef Documentation

typedef DEPRECATED struct _MATRIX * MATRIX

Function Documentation

int MatAddMatrix ( MATRIX  outmatrix,
MATRIX  matrixA,
MATRIX  matrixB 
)

Add one matrix to another of the same size.

Parameters:
outmatrix Output matrix, may be the same as either input matrix
matrixA First input matrix
matrixB Second input matrix, if NULL will use outmatrix
int MatCopy ( MATRIX outmatrix,
MATRIX  inmatrix 
)

Copy one matrix to another.

The output matrix will be resized if it exists and is not the same size as the input matrix.

Parameters:
outmatrix Matrix to copy to, will be created if NULL
inmatrix Matrix to copy from
int MatCreate ( MATRIX matrix,
UINT16  rows,
UINT16  cols,
UINT32  flags 
)

Create a new matrix.

Flags: MATFLAG_Symmetric Matrix is symmetric, don't allocate space for elements above diagonal MATFLAG_NoDiagonal Don't allocate space for diagonal elements (symmetric only)

All matrix elements will be initialized to 0.

Parameters:
matrix Matrix returned
rows Number of rows in matrix
cols Number of columns in matrix
flags Flags
void MatDestroy ( MATRIX  matrix  ) 

Destroy a matrix.

Parameters:
matrix Matrix to be destroyed
int MatDeterminant ( MATRIX  matrix,
double *  detvalue 
)

Compute determinate of a square matrix.

Parameters:
matrix Matrix to compute determinant for
detvalue Determinant returned
int MatEigenvectors ( MATRIX  matrix,
MATRIX vectors,
MATRIX values 
)

Compute eigenvectors and eigenvalues of the SYMMETRIC matrix.

WARNING: This function computes eigen-stuff for SYMMETRIC matrices ONLY. Example: correlation /covariation matrix. NO CHECKING IS PERFORMED ON INPUT TO MAKE SURE IT'S SYMMETRIC.

Parameters:
matrix Matrix to use
vectors Matrix returned, that contain eigenvectors as columns
values Matrix returned (vector), that contains eigenvalues
double MatGetValueTest ( MATRIX  matrix,
UINT16  row,
UINT16  col 
)

Retrieve value from matrix with range check.

Returns:
Value in matrix. This function will return 0.0 for values outside the matrix. It also handles symmetric matrices.
Parameters:
matrix Matrix to retrieve value from
row Row in matrix (0 - numrows-1)
col Column in matrix (0 - numcols-1)
int MatInverse ( MATRIX  outmatrix,
MATRIX  inmatrix,
int  maxiterations,
double  maxerror 
)

Compute inverse of a square matrix.

Parameters:
outmatrix Inverse matrix computed
inmatrix Matrix to compute inverse of
maxiterations Maximum iterations for convergence (0 for default)
maxerror Maximum error, (0.0 for default)
int MatMultMatrix ( MATRIX  outmatrix,
MATRIX  matrixA,
MATRIX  matrixB 
)

Multiply one matrix by another.

Parameters:
outmatrix Output matrix, may be the same as either input matrix
matrixA Left matrix, will use outmatrix if NULL
matrixB Right matrix, will use outmatrix if NULL
void MatMultScalar ( MATRIX  matrix,
double  value 
)

Multiply a matrix by a scalar.

Parameters:
matrix Matrix to use
value Value to multiply all matrix elements by
int MatPseudoInverse ( MATRIX  inverse,
MATRIX  input,
double  tolerance 
)

Compute pseudoinverse of the matrix using SVD.

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

Parameters:
inverse Output pseudoinverse
input Input matrix
tolerance Tolerance to use, if in doubt pass 0.0 and function will use built-in defaults
void MatSetScalar ( MATRIX  matrix,
double  value 
)

Set all entries in a matrix to a specified scalar value.

Parameters:
matrix Matrix to use
value Value to set all matrix elements to
int MatSubMatrix ( MATRIX  outmatrix,
MATRIX  matrixA,
MATRIX  matrixB 
)

Subtract one matrix from another.

Parameters:
outmatrix Output matrix, may be the same as either input matrix
matrixA Matrix to subtract FROM
matrixB Second to subtract, if NULL will subtract matrixA from outmatrix
int MatSVD ( MATRIX  A,
MATRIX U,
MATRIX W,
MATRIX V 
)

Compute Singular Value Decomposition (SVD).

This function computes SVD as A = U * W * V ; Output matrix U has the same dimension as input matrix 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:
A Input matrix
U Returned
W Returned
V Returned
int MatSVDSolve ( MATRIX  A,
MATRIX  B,
MATRIX  X,
double  tolerance 
)

Stable Solution of system of linear equation using SVD algorithm.

A * X = B where A(M x N) matrix and X (N) vector. B(M) is also a vector. X is the output solution vector. Matrix A is decomposed into U(M x N), W(N) and V(N x N) matrices using SVD operation.

Parameters:
A Input matrix of equations
B Input vector that contains right side of equations NOTE: you can pass ANY type of vector: numrows = 1 or numcols = 1
X Solution returned
tolerance Tolerance to use, if in doubt pass 0.0 for defaults
int MatSVDSolveAutoTolerance ( MATRIX  A,
MATRIX  B,
MATRIX  X 
)
Parameters:
X Size of A->cols x 1
int MatSVDSolveAutoToleranceFast ( MATRIX  A,
MATRIX  U,
MATRIX  W,
MATRIX  V,
MATRIX  B,
MATRIX  X 
)
Parameters:
X Size of A->cols x 1
double MatTrace ( MATRIX  matrix  ) 

Compute trace of the matrix: sum of it's diagonal elements.

Parameters:
matrix Matrix to use
int MatTranspose ( MATRIX  outmatrix,
MATRIX  inmatrix 
)

Transpose a matrix.

Parameters:
outmatrix Output matrix (may be the same as the input matrix)
inmatrix Input matrix

Generated on Sun Oct 7 21:26:50 2012 for TNTsdk 2012 by  doxygen 1.6.1