MatrixMathLA.h

Classes

Global Functions -- Linear algebra functions on Vectors and Matrices. (full description)

Linear algebra functions on Vectors and Matrices. (source)

Interface

void invert(Matrix<T> & out, T& determinate, const Matrix<T> &in)
Matrix<T> invert(const Matrix<T> &in)
T determinate(const Matrix<T> &in)
void invertSymPosDef(Matrix<T> & out, T& determinate, const Matrix<T> &in)
Matrix<T> invertSymPosDef(const Matrix<T> &in)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Programs:
Tests:

Member Description

void invert(Matrix<T> & out, T& determinate, const Matrix<T> &in)
Matrix<T> invert(const Matrix<T> &in)
T determinate(const Matrix<T> &in)

Routines which calculate the inverse of a matrix. The inverse is very often the worst way to do a calculation. Nevertheless it is often convenient. The present implementation uses LU decomposition implemented by LAPACK. The determinate can be calculated "for free" as it is the product of the diagonal terms after decomposition. If the input matrix is singular, a matrix with no rows or columns is returned. in must be a square matrix.

WarningThis function will only work for complex types if Complex and DComplex map onto their FORTRAN counterparts.

void invertSymPosDef(Matrix<T> & out, T& determinate, const Matrix<T> &in)

This function inverts a symmetric positive definite matrix. It is written in C++, so it should work with any data type for which operators +, -, *, /, =, and sqrt are defined. The function uses the Cholesky decomposition method to invert the matrix. Cholesky decomposition is about a factor of 2 better than LU decomposition where symmetry is ignored.

Matrix<T> invertSymPosDef(const Matrix<T> &in)