Physsim::LinAlg Class Reference

Linear algebra routines. More...

#include <LinAlg.h>

List of all members.

Static Public Member Functions

static Real cond (const MatrixN &x)
static MatrixN to_matrix (const std::string &s)
 Constructs a matrix from a string.
static VectorN to_vector (const std::string &s)
 Constructs a vector from a string.
static VectorN solve (const MatrixNN &A, const VectorN &b)
 Solves the general system Ax = b.
static VectorN solve_symmetric (const MatrixNN &A, const VectorN &b)
 Solves a symmetric, indefinite square matrix.
static VectorN solve_PD (const MatrixNN &A, const VectorN &b)
 Solves a symmetric, positivie-definite square matrix.
static void solve_iterative (const MatrixNN &A, const VectorN &b, VectorN &x, unsigned iter)
 Iteratively solves a system of equations using the Conjugate-Gradient method.
static void svd (const MatrixN &A, MatrixN &U, VectorN &S, MatrixN &V)
 Performs singular value decomposition on A.
static MatrixNN inverse (const MatrixNN &mat)
 Inverts the matrix A using LU decomposition.
static MatrixNN inverse_symmetric (const MatrixNN &mat)
 Inverts the symmetric, indefinite matrix A.
static MatrixNN inverse_PD (const MatrixNN &mat)
 Inverts the symmetric, positive-definite matrix A using Cholesky factorization.
static MatrixN pseudo_inverse (const MatrixNN &A, Real tol=0)
 Computes the psuedo-inverse of a square matrix.
static MatrixN pseudo_inverse (const MatrixN &A, Real tol=0)
 Computes the psuedo-inverse of a non-square matrix.
static MatrixN right_pseudo_inverse (const MatrixN &A)
 Computes the right pseudo inverse of a matrix.
static MatrixN left_pseudo_inverse (const MatrixN &A)
 Computes the left pseudo inverse of a matrix.
static unsigned calc_rank (const MatrixN &x, Real tol=1e-10)
static Matrix3 rot_X (Real angle)
 Returns the rotation matrix of the specified angle about the X-axis.
static Matrix3 rot_Y (Real angle)
 Returns the rotation matrix of the specified angle about the Y-axis.
static Matrix3 rot_Z (Real angle)
 Returns the rotation matrix of the specified angle about the Z-axis.
static void eig_symm (const MatrixNN &A, VectorN &evals)
 Computes the eigenvalues of the matrix A.
static bool is_PSD (const MatrixNN &A, Real tolerance)
 Determines whether a symmetric matrix is positive semi-definite.
static bool is_PD (const MatrixNN &A, Real tolerance)
 Determines whether a matrix is positive-definite.


Detailed Description

Linear algebra routines.

LinAlg is a set of static routines that interface to LAPACK. I have included only very few routines here, however they should be some of the most utilized: SVD, (SVD-based) pseudo-inverse, linear equation solving, and matrix inverse.


Member Function Documentation

MatrixN LinAlg::to_matrix ( const std::string &  str  )  [static]

Constructs a matrix from a string.

Elements in a row are separated ustd::sing whitespace or commas. Rows are separated ustd::sing semicolons.

VectorN LinAlg::to_vector ( const std::string &  str  )  [static]

Constructs a vector from a string.

Parameters:
str a string representing the vector; elements are separated ustd::sing whitespace, comma, or semicolon

VectorN LinAlg::solve ( const MatrixNN A,
const VectorN b 
) [static]

Solves the general system Ax = b.

Parameters:
A a square matrix
b a vector of length A.rows()
Returns:
the solution vector of length b.size()

void LinAlg::solve_iterative ( const MatrixNN A,
const VectorN b,
VectorN x,
unsigned  iter 
) [static]

Iteratively solves a system of equations using the Conjugate-Gradient method.

Note:
A must have given form to ensure convergence (e.g., diagonally dominant, symmetric PSD, etc.)

void LinAlg::svd ( const MatrixN A,
MatrixN U,
VectorN S,
MatrixN V 
) [static]

Performs singular value decomposition on A.

The singular value decomposition of A is U*S*V' (' is the transpose operator); to recompose A, it will be necessary to transpose V before multiplication (i.e., V is returned by the algorithm, not V'). Note: passed matrices and vectors U, S, and V are resized as necessary.

Parameters:
A the matrix on which the SVD will be performed
U on output, a A.rows() x A.rows() orthogonal matrix
S on output, a min(A.rows(), A.columns()) length vector of singular values
V on output, a A.columns() x A.columns() orthogonal matrix

MatrixNN LinAlg::inverse ( const MatrixNN A  )  [static]

Inverts the matrix A using LU decomposition.

Parameters:
A a square matrix
Returns:
the inverse of A

MatrixNN LinAlg::inverse_symmetric ( const MatrixNN A  )  [static]

Inverts the symmetric, indefinite matrix A.

Parameters:
A a square, symmetric indefinite matrix
Returns:
the inverse of A

MatrixNN LinAlg::inverse_PD ( const MatrixNN A  )  [static]

Inverts the symmetric, positive-definite matrix A using Cholesky factorization.

Parameters:
A a square, symmetric positive-definite matrix
Returns:
the inverse of A

void LinAlg::eig_symm ( const MatrixNN A,
VectorN evals 
) [static]

Computes the eigenvalues of the matrix A.

Parameters:
A a matrix
evals on return, the eigenvalues will be stored here


The documentation for this class was generated from the following files:
Generated on Wed Oct 24 14:54:23 2007 for Physsim by  doxygen 1.5.1