TBCI Numerical high perf. C++ Library 2.8.0
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
#define SVDREAL(x)

Functions

template<typename ARG>
double sv_decomp_pythag (ARG a, ARG b)
 Calculate sqrt (a^2 + b^2) avoiding under/overflows.
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.
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.
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.

Macro Definition Documentation

◆ SVDFLOAT

#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(), sv_decomp_backsub(), and sv_decomp_backsub().

◆ SVDREAL

#define SVDREAL ( x)
Value:
(x)
const Vector< T > const Vector< T > & x
Definition LM_fit.h:97

Definition at line 26 of file svd_solver.h.

Referenced by sv_decomp().

Function Documentation

◆ fix_condition()

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

Definition at line 296 of file svd_solver.h.

References fabs(), fix_condition(), i, MATH__, and MAX.

Referenced by fix_condition(), svd_solve(), and svd_solve().

◆ sv_decomp()

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, fabs(), h, i, MATH__, MatrixType, MAX, MIN, sqrt(), STD__, sv_decomp(), sv_decomp_pythag(), SVDFLOAT, SVDREAL, x, and y.

Referenced by sv_decomp(), svd_solve(), and svd_solve().

◆ sv_decomp_backsub() [1/2]

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 b, i, MatrixType, TVector< T >::size(), sv_decomp_backsub(), SVDFLOAT, U, and x.

◆ sv_decomp_backsub() [2/2]

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 b, i, MatrixType, sv_decomp_backsub(), SVDFLOAT, U, and x.

Referenced by sv_decomp_backsub(), sv_decomp_backsub(), svd_solve(), and svd_solve().

◆ sv_decomp_pythag()

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 a, b, fabs(), MATH__, and sqrt().

Referenced by sv_decomp().

◆ svd_solve() [1/2]

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 b, fix_condition(), MatrixType, sv_decomp(), sv_decomp_backsub(), and svd_solve().

◆ svd_solve() [2/2]

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 b, fix_condition(), MatrixType, sv_decomp(), sv_decomp_backsub(), svd_solve(), and x.

Referenced by svd_solve(), and svd_solve().