Classes | ||||||||||||||||
| class | CMatrixType | |||||||||||||||
| The Matrix type. More... | ||||||||||||||||
| class | CVectorType | |||||||||||||||
| The Vector type. More... | ||||||||||||||||
Singular Value Decomposition SVD | ||||||||||||||||
| These functions perform the Singular Value Decomposition SVD of the MxN matrix A. The SVD is defined by: A=U*S*V^T where:
| ||||||||||||||||
| void | SVD (const CMatrix &A, CMatrix &U, CVector &s, CMatrix &V) | |||||||||||||||
| SVD of A, where the singular values are returned in a Vector. | ||||||||||||||||
| void | SVD (const CMatrix &A, CMatrix &U, CMatrix &S, CMatrix &V) | |||||||||||||||
| SVD of A, where the singular values are returned in a 'diagonal' Matrix. | ||||||||||||||||
| CVector | SVD (const CMatrix &A) | |||||||||||||||
| SVD of A, returning only the singular values in a Vector. | ||||||||||||||||
Linear Equations | ||||||||||||||||
| These functions solve the system of linear equations A*x=b for x, where:
There a speceilaized functions for symetric positive definite (SPD) matrices yeilding better performance. These are denote by SPD in there function name.
| ||||||||||||||||
| void | LinearSolve (const CMatrix &A, const CVector &b, CVector &x) | |||||||||||||||
| Solves Ax=b for x. | ||||||||||||||||
| CVector | LinearSolve (const CMatrix &A, const CVector &b) | |||||||||||||||
| Solves Ax=b for x and returns x. | ||||||||||||||||
| void | LinearSolveSPD (const CMatrix &A, const CVector &b, CVector &x) | |||||||||||||||
| Solves Ax=b for x, where A is SPD. | ||||||||||||||||
| CVector | LinearSolveSPD (const CMatrix &A, const CVector &b) | |||||||||||||||
| Solves Ax=b for x and returns x, where A is SPD. | ||||||||||||||||
Linear Least Squares | ||||||||||||||||
| These functions solve the Linear Least Squares problem: min_x ||Ax-b||^2 for x, where:
If the solution is not well formed the algorithm provided will find a solution, x, which is not unique, but which sets the objective function to 0. The reson being that the underlining algorithm works by SVD.
| ||||||||||||||||
| void | LinearLSSolve (const CMatrix &A, const CVector &b, CVector &x) | |||||||||||||||
| Solves the Linear Least Squares problem min_x ||Ax=b||^2 for x. | ||||||||||||||||
| CVector | LinearLSSolve (const CMatrix &A, const CVector &b) | |||||||||||||||
| Solves the Linear Least Squares problem min_x ||Ax=b||^2 for x, and returnes x. | ||||||||||||||||
Matrix Inversion | ||||||||||||||||
| These functions inverts the square matrix A. This matrix A must have full rank.
| ||||||||||||||||
| void | Invert (CMatrix &A) | |||||||||||||||
| Invertes the square matrix A. That is here A is altered as opposed to the other Invert functions. | ||||||||||||||||
| void | Inverted (const CMatrix &A, CMatrix &InvA) | |||||||||||||||
| Returns the inverse of the square matrix A in InvA. | ||||||||||||||||
| CMatrix | Inverted (const CMatrix &A) | |||||||||||||||
| Returns the inverse of the square matrix A. | ||||||||||||||||
QR Factorization | ||||||||||||||||
| This function returns the QR factorization of A, such that Q*R=A where Q is a orthonormal matrix and R is an upper triangular matrix. However, in the case of A.Col()>A.Row(), the last A.Col-A.Row columns of Q are 'carbage' and as such not part of a orthonormal matrix.
| ||||||||||||||||
| void | QRfact (const CMatrix &A, CMatrix &Q, CMatrix &R) | |||||||||||||||
RQ Factorization | ||||||||||||||||
| This function returns the RQ factorization of A, such that R*Q=A where Q is a orthonormal matrix and R is an upper triangular matrix. However, in the case of A not beeing a square matrix, there might be some fuck up of Q.
| ||||||||||||||||
| void | RQfact (const CMatrix &A, CMatrix &R, CMatrix &Q) | |||||||||||||||
I/O from MatLab | ||||||||||||||||
| Reads or writes the type to or from a m-file with a somwhat strict format. MatLab can 'load' the matrix by running the m-file in question, and write to the format via the 'LinAlg.m' function. Since MatLab uses double as the working percision, this is the only value of T where this interface to MatLab works. For other types, this functionality is good for loading, saving and debuging.
| ||||||||||||||||
| void | ToMatlab (const CMatrix &M, const std::string &VarName, const std::string &FileName="c:\\test.m", const bool append=true, const std::string &Comment="") | |||||||||||||||
| void | FromMatlab (CMatrix &M, const std::string &VarName, const std::string &FileName="c:\\test.m") | |||||||||||||||
Additional matrix operators | ||||||||||||||||
| These are operators heavily associated with CMAtrixType, but not included in the class definition it self. | ||||||||||||||||
| template<class T> | ||||||||||||||||
| CMatrixType< T > | operator+ (const T &Lhs, const CMatrixType< T > &Rhs) | |||||||||||||||
| template<class T> | ||||||||||||||||
| CMatrixType< T > | operator * (const T &Lhs, const CMatrixType< T > &Rhs) | |||||||||||||||
| template<class T> | ||||||||||||||||
| std::ostream & | operator<< (std::ostream &s, const CMatrixType< T > &A) | |||||||||||||||
| template<class T> | ||||||||||||||||
| std::istream & | operator>> (std::istream &s, CMatrixType< T > &A) | |||||||||||||||
Additional vector operators | ||||||||||||||||
| These are operators heavily associated with CVectorType, but not included in the class definition it self. | ||||||||||||||||
| template<class T> | ||||||||||||||||
| CVectorType< T > | operator+ (const T &Lhs, const CVectorType< T > &Rhs) | |||||||||||||||
| template<class T> | ||||||||||||||||
| CVectorType< T > | operator * (const T &Lhs, const CVectorType< T > &Rhs) | |||||||||||||||
| template<class T> | ||||||||||||||||
| std::ostream & | operator<< (std::ostream &s, const CVectorType< T > &a) | |||||||||||||||
| template<class T> | ||||||||||||||||
| std::istream & | operator>> (std::istream &s, CVectorType< T > &a) | |||||||||||||||
Typedefs | ||||||||||||||||
| typedef CMatrixType< double > | CMatrix | |||||||||||||||
| The Matrix annotation intended for use. | ||||||||||||||||
| typedef CVectorType< double > | CVector | |||||||||||||||
| The Vector annotation intended for use. | ||||||||||||||||
Functions | ||||||||||||||||
| void | LinearSolveSym (const CMatrix &A, const CVector &b, CVector &x) | |||||||||||||||
This is the linear algebra package deal with vector and matrix types plus the basic operation on them. The Vector and Matrix Types are templated such that the precision of a given 'system' can be changen. Though the precision or type in mind is the double. Special types for 2 and 3 vectors (CVec2 and CVec3) are included for improved performance. The more advanced linear algebra functions are supplied by lincage to the LaPack package.
|
|
The Matrix annotation intended for use.
|
|
|
The Vector annotation intended for use.
|
|
|
Invertes the square matrix A. That is here A is altered as opposed to the other Invert functions.
|
|
|
Returns the inverse of the square matrix A.
|
|
||||||||||||
|
Returns the inverse of the square matrix A in InvA.
|
|
||||||||||||
|
Solves the Linear Least Squares problem min_x ||Ax=b||^2 for x, and returnes x.
|
|
||||||||||||||||
|
Solves the Linear Least Squares problem min_x ||Ax=b||^2 for x.
|
|
||||||||||||
|
Solves Ax=b for x and returns x.
|
|
||||||||||||||||
|
Solves Ax=b for x.
|
|
||||||||||||
|
Solves Ax=b for x and returns x, where A is SPD.
|
|
||||||||||||||||
|
Solves Ax=b for x, where A is SPD.
|
|
|
SVD of A, returning only the singular values in a Vector.
|
|
||||||||||||||||||||
|
SVD of A, where the singular values are returned in a 'diagonal' Matrix.
|
|
||||||||||||||||||||
|
SVD of A, where the singular values are returned in a Vector.
|
1.4.1