TBCI Numerical high perf. C++ Library  2.8.0
Macros | Functions
svd_solver.h File Reference
#include "tbci/matrix.h"
Include dependency graph for svd_solver.h:

Go to the source code of this file.

Macros

#define SVDFLOAT   typename MatrixType::value_type
 svd_solver.h More...
 
#define SVDREAL(x)   (x)
 

Functions

template<typename ARG >
double sv_decomp_pythag (ARG a, ARG b)
 Calculate sqrt (a^2 + b^2) avoiding under/overflows. More...
 
template<typename MatrixType , typename VectorType >
void sv_decomp (MatrixType &A, MatrixType &V, VectorType &W)
 Singular Value Decomposition Decomposes matrix A into U * diag(W) * V^T A is overwritten with U. More...
 
template<typename MatrixType , typename VectorType >
void sv_decomp_backsub (const MatrixType &U, const MatrixType &V, const VectorType &W, const VectorType &b, VectorType &x)
 
template<typename VectorType >
static int fix_condition (VectorType &vec, const double cndno=1e-12)
 
template<typename MatrixType , typename VectorType >
VectorType svd_solve (const MatrixType &mat, const VectorType &b, const double cndno=1e-12)
 The interface to use the SVD solver: Solve the equation mat * x = b. More...
 
template<typename MatrixType , typename T >
TVector< Tsv_decomp_backsub (const MatrixType &U, const MatrixType &V, const Vector< T > &W, const Vector< T > &b)
 
template<typename MatrixType , typename T >
TVector< Tsvd_solve (const MatrixType &mat, const Vector< T > &b, const double cndno=1e-12)
 The interface to use the SVD solver: Solve the equation mat * x = b. More...
 

Macro Definition Documentation

#define SVDFLOAT   typename MatrixType::value_type

svd_solver.h

Singular Value Decomposition matrix solver implementation by Bart Hartgers bart@.nosp@m.etpm.nosp@m.od.ph.nosp@m.ys.t.nosp@m.ue.nl, 2001-09-05 inspired by Numerical Recipes, ch. 2.6 Ported to TBCI by Kurt Garloff kurt@.nosp@m.garl.nosp@m.off.d.nosp@m.e, 2001-09-06

Id:
svd_solver.h,v 1.1.2.18 2019/05/28 11:13:02 garloff Exp

Definition at line 18 of file svd_solver.h.

Referenced by sv_decomp(), and sv_decomp_backsub().

#define SVDREAL (   x)    (x)

Definition at line 26 of file svd_solver.h.

Referenced by sv_decomp().

Function Documentation

template<typename VectorType >
static int fix_condition ( VectorType &  vec,
const double  cndno = 1e-12 
)
static

Definition at line 296 of file svd_solver.h.

References std::fabs(), i, MATH__, and MAX.

Referenced by svd_solve().

template<typename MatrixType , typename VectorType >
void sv_decomp ( MatrixType A,
MatrixType V,
VectorType &  W 
)

Singular Value Decomposition Decomposes matrix A into U * diag(W) * V^T A is overwritten with U.

Definition at line 53 of file svd_solver.h.

References c, std::fabs(), h, i, MATH__, MAX, MIN, std::sqrt(), STD__, sv_decomp_pythag(), SVDFLOAT, SVDREAL, x, y, and z.

template<typename MatrixType , typename VectorType >
void sv_decomp_backsub ( const MatrixType U,
const MatrixType V,
const VectorType &  W,
const VectorType &  b,
VectorType &  x 
)

Definition at line 268 of file svd_solver.h.

References i, SVDFLOAT, and U.

Referenced by svd_solve().

template<typename MatrixType , typename T >
TVector<T> sv_decomp_backsub ( const MatrixType U,
const MatrixType V,
const Vector< T > &  W,
const Vector< T > &  b 
)

Definition at line 341 of file svd_solver.h.

References i, TVector< T >::set(), TVector< T >::size(), SVDFLOAT, U, and x.

template<typename ARG >
double sv_decomp_pythag ( ARG  a,
ARG  b 
)
inline

Calculate sqrt (a^2 + b^2) avoiding under/overflows.

Definition at line 31 of file svd_solver.h.

References std::fabs(), MATH__, and std::sqrt().

Referenced by sv_decomp().

template<typename MatrixType , typename VectorType >
VectorType svd_solve ( const MatrixType mat,
const VectorType &  b,
const double  cndno = 1e-12 
)

The interface to use the SVD solver: Solve the equation mat * x = b.

Input mat, b: Return value x Optimized version returning a TVector below. cndno is the maximum allowable condition numbers. Singular values below maxSV * cndno are set to zero.

Definition at line 324 of file svd_solver.h.

References fix_condition(), MatrixType, sv_decomp_backsub(), and x.

template<typename MatrixType , typename T >
TVector<T> svd_solve ( const MatrixType mat,
const Vector< T > &  b,
const double  cndno = 1e-12 
)

The interface to use the SVD solver: Solve the equation mat * x = b.

Input mat, b: Return value x Optimized version returning a TVector. cndno is the maximum allowable condition numbers. Singular values below maxSV * cndno are set to zero.

Note that we don't change the mat, unlike in LU solver, as we can't store the complete result of the decomposition in it anyway.

Definition at line 379 of file svd_solver.h.

References fix_condition(), MatrixType, and sv_decomp_backsub().