SVD Class Template Reference
[Vector and Matrix mathematics]

#include <MatrixFunctors.hpp>

List of all members.


Detailed Description

template<class T>
class gpstk::SVD< T >

Class SVD: A function object for the singular value decomposition of a matrix.

Given a matrix A [m,n], the SVD of A = U*S*transpose(V), where U is [m,m], V is [n,n], and S is [m,n] (like A). Both U and V are unitary [meaning transpose(U)*U = unity = transpose(V)*V] and the columns of U[resp,V] are orthonormal vectors spanning the space A*transpose(A) [transpose(A)*A]. Note that U*transpose(U)=1 and V*transpose(V)=1 are not true in general, but may be. S[m,n] is 'diagonal' in the sense that only diagonal elements are non-zero (even when m != n); the min(m,n) diagonal elements are called the singular values of A, often referred to as S[i]. The singular values may be sorted, as the SVD is invariant under a consistent re-ordering of {singular values / columns of U / columns of V}. The condition number of A is the ratio cn = fabs(largest S[i])/fabs(smallest S[i]). Note that inverse(A) = V*inverse(S)*UT where inverse(S) is diagonal with elements equal to the inverse of elements of S, and with dimension [n,m]. The matrix A is non-singular matrix if and only if all of its singular values are non-zero. If some of the singular values are zero, the 'generalized inverse' of A may be formed by editing the singular values in this way: if the ratio of S[i] to S[0] (where S[0] is the largest singular value) is bigger than some tolerance (1.e-7 is good), then 1/S[i] is set to zero in the inverse. In this way the 'generalized inverse' of ANY matrix is guaranteed to exist. The SVD algorithm never fails.

Ref: Bulirsch and Stoer, "Introduction to Numerical Analysis," NY, Springer-Verlag, 1980.

 Matrix<double> m(and is assigned some value);
 SVD<double> d;
 d(m);
 cout << d.U << endl << d.V << endl << d.S << endl;

Definition at line 77 of file MatrixFunctors.hpp.

Public Member Functions

 SVD ()
template<class BaseClass>
bool operator() (const ConstMatrixBase< T, BaseClass > &mat) throw (MatrixException)
 Singular Value Decomposition.
template<class BaseClass>
void backSub (RefVectorBase< T, BaseClass > &b) const throw (MatrixException)
 Backsubstitution using SVD.
void sort (bool descending) throw (MatrixException)
 sort singular values
det (void) throw (MatrixException)
 compute determinant from SVD

Public Attributes

Matrix< T > U
 Matrix U.
Vector< T > S
 Vector of singular values.
Matrix< T > V
 Matrix V (not transpose(V)).


Constructor & Destructor Documentation

SVD  )  [inline]
 

Definition at line 80 of file MatrixFunctors.hpp.


Member Function Documentation

void backSub RefVectorBase< T, BaseClass > &  b  )  const throw (MatrixException) [inline]
 

Backsubstitution using SVD.

Solve A*x=b for vector x where A [mxn] has been SVD'ed and is given by U,W,V (*this); that is A[mxn] = U[mxm]*W[mxn]*VT[nxn]. b has dimension m, x dimension n. Singular values are NOT edited, except that if s.v. == 0, 1/0 is replaced by 0. Result is returned as b.

Definition at line 329 of file MatrixFunctors.hpp.

References RefMatrixBase< T, Matrix< T > >::assignFrom(), Matrix::cols(), GPSTK_THROW, Matrix::rows(), and gpstk::transpose().

Referenced by MatrixTest4().

T det void   )  throw (MatrixException) [inline]
 

compute determinant from SVD

Definition at line 374 of file MatrixFunctors.hpp.

Referenced by MatrixTest4().

bool operator() const ConstMatrixBase< T, BaseClass > &  mat  )  throw (MatrixException) [inline]
 

Singular Value Decomposition.

Definition at line 86 of file MatrixFunctors.hpp.

References ABS, GPSTK_THROW, Vector::resize(), Matrix::rows(), gpstk::RSS(), SQRT, and gpstk::transpose().

void sort bool  descending  )  throw (MatrixException) [inline]
 

sort singular values

Definition at line 351 of file MatrixFunctors.hpp.

References RefMatrixBase< T, Matrix< T > >::swapCols().

Referenced by SRI::getConditionNumber(), and MatrixTest4().


Member Data Documentation

Vector<T> S
 

Vector of singular values.

Definition at line 385 of file MatrixFunctors.hpp.

Referenced by SRI::getConditionNumber(), and MatrixTest4().

Matrix<T> U
 

Matrix U.

Definition at line 383 of file MatrixFunctors.hpp.

Referenced by MatrixTest4().

Matrix<T> V
 

Matrix V (not transpose(V)).

Definition at line 387 of file MatrixFunctors.hpp.

Referenced by MatrixTest4().


The documentation for this class was generated from the following file:
Generated on Wed Feb 8 03:31:40 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1