Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
gnsstk::SVD< T > Class Template Reference

Detailed Description

template<class T>
class gnsstk::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 99 of file MatrixFunctors.hpp.

#include <MatrixFunctors.hpp>

Public Member Functions

template<class BaseClass >
void backSub (RefVectorBase< T, BaseClass > &b) const
 
det (void)
 
template<class BaseClass >
bool operator() (const ConstMatrixBase< T, BaseClass > &mat)
 
void sort (bool descending=true)
 
 SVD ()
 

Public Attributes

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

Private Member Functions

SIGN (T a, T b)
 

Private Attributes

const size_t iterationMax
 

Constructor & Destructor Documentation

◆ SVD()

template<class T >
gnsstk::SVD< T >::SVD ( )
inline

Definition at line 102 of file MatrixFunctors.hpp.

Member Function Documentation

◆ backSub()

template<class T >
template<class BaseClass >
void gnsstk::SVD< T >::backSub ( RefVectorBase< T, BaseClass > &  b) const
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.

Exceptions
MatrixException

Definition at line 355 of file MatrixFunctors.hpp.

◆ det()

template<class T >
T gnsstk::SVD< T >::det ( void  )
inline

compute determinant from SVD

Exceptions
MatrixException

Definition at line 402 of file MatrixFunctors.hpp.

◆ operator()()

template<class T >
template<class BaseClass >
bool gnsstk::SVD< T >::operator() ( const ConstMatrixBase< T, BaseClass > &  mat)
inline

Singular Value Decomposition

Exceptions
MatrixException

Definition at line 108 of file MatrixFunctors.hpp.

◆ SIGN()

template<class T >
T gnsstk::SVD< T >::SIGN ( a,
b 
)
inlineprivate

Definition at line 419 of file MatrixFunctors.hpp.

◆ sort()

template<class T >
void gnsstk::SVD< T >::sort ( bool  descending = true)
inline

sort singular values - default in descending order

Exceptions
MatrixException

Definition at line 378 of file MatrixFunctors.hpp.

Member Data Documentation

◆ iterationMax

template<class T >
const size_t gnsstk::SVD< T >::iterationMax
private

Definition at line 417 of file MatrixFunctors.hpp.

◆ S

template<class T >
Vector<T> gnsstk::SVD< T >::S

Vector of singular values.

Definition at line 412 of file MatrixFunctors.hpp.

◆ U

template<class T >
Matrix<T> gnsstk::SVD< T >::U

Matrix U.

Definition at line 410 of file MatrixFunctors.hpp.

◆ V

template<class T >
Matrix<T> gnsstk::SVD< T >::V

Matrix V (not transpose(V))

Definition at line 414 of file MatrixFunctors.hpp.


The documentation for this class was generated from the following file:


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:46