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].
FVector< T, N > ltl::SVDecomposition< T >::solve | ( | FMatrix< T, M, N > | A, | |
const FVector< T, M > & | b | |||
) | [inline, static] |
Given A[m][n], b[m], solves A x = b using SVD. returns solution vector x[n] No input quantities are changed.
References ltl::SVDecomposition< T >::svbksb(), and ltl::SVDecomposition< T >::svdcmp().
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 | |||
) | [inline, 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.
Referenced by ltl::SVDecomposition< T >::solve().
void ltl::SVDecomposition< T >::svdcmp | ( | FMatrix< T, M, N > & | A, | |
FVector< T, N > & | W, | |||
FMatrix< T, N, N > & | V | |||
) | [inline, 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(), ltl::SVDecomposition< T >::pythag(), and SVD_SIGN.
Referenced by ltl::SVDecomposition< T >::solve().
static T ltl::SVDecomposition< T >::pythag | ( | const T | a, | |
const T | b | |||
) | [inline, static, protected] |
Computes (a^2 + b^2)^1/2 without destructive underflow or overflow
Referenced by ltl::SVDecomposition< T >::svdcmp().