LTL  2.0.x
Static Protected Member Functions | List of all members
ltl::SVDecomposition< T > Class Template Reference

Static Public Member Functions

template<int M, int N>
static FVector< T, N > solve (FMatrix< T, M, N > A, const FVector< T, M > &b)
 
template<int M, int N>
static FVector< T, N > svbksb (const FMatrix< T, M, N > &U, const FVector< T, N > &W, const FMatrix< T, N, N > &V, const FVector< T, M > &b)
 
template<int M, int N>
static void svdcmp (FMatrix< T, M, N > &A, FVector< T, N > &W, FMatrix< T, N, N > &V)
 

Static Protected Member Functions

static T pythag (const T a, const T b)
 

Detailed Description

template<typename T>
class ltl::SVDecomposition< T >

Perform Singular Value Decomposition and solve linear systems.
Adapted from Numerical Recipes.

Example:
* FVector<double,4> x(2.); // target
*
* FMatrix<double,4,4> A; // the matrix
* A = 1., 2., 3., 2.,
* 5., 11., 7., 13.,
* 9., 7., 5., 1.,
* 7., 13., 17., 11.;
* FVector<double,4> b(dot(A, x)); // construct b
*
* x = 0.;
* x = SVDecomposition<double>::solve(A, B); // solve Ax = b
* // x should be [2,2].
*

Member Function Documentation

template<typename T >
template<int M, int N>
FVector< T, N > ltl::SVDecomposition< T >::solve ( FMatrix< T, M, N >  A,
const FVector< T, M > &  b 
)
static

Given A[m][n], b[m], solves A x = b using SVD. returns solution vector x[n] No input quantities are changed.

template<typename T >
template<int M, int N>
FVector< T, N > ltl::SVDecomposition< T >::svbksb ( const FMatrix< T, M, N > &  U,
const FVector< T, N > &  W,
const FMatrix< T, N, N > &  V,
const FVector< T, M > &  b 
)
static

Given A[m][n], b[m], solves A x = b in the SVD form U W V'x = b so x = V U'b/W U[m][n], W[n][n] and V[n][n] No input quantities are changed.

template<typename T >
template<int M, int N>
void ltl::SVDecomposition< T >::svdcmp ( FMatrix< T, M, N > &  A,
FVector< T, N > &  W,
FMatrix< T, N, N > &  V 
)
static

Given matrix A[m][n], m>=n, using svd decomposition A = U W V' to get U[m][n], W[n][n] and V[n][n], where U occupies the position of A. NOTE: if m<n, A should be filled up to square with zero rows. A[m][n] has been destroyed by U[m][n] after the decomposition.

References ltl::max(), ltl::min(), and SVD_SIGN.

template<typename T >
static T ltl::SVDecomposition< T >::pythag ( const T  a,
const T  b 
)
inlinestaticprotected

Computes (a^2 + b^2)^1/2 without destructive underflow or overflow