HDK
|
#include <UT_MatrixSolver.h>
Public Types | |
typedef UT_Functor2< void, const UT_VectorT< T > &, UT_VectorT< T > & > | MatrixOp |
typedef UT_Functor2< bool, exint, T > | StopConditionOp |
typedef UT_Functor2 < UT_PreciseT< T >, const UT_VectorT< T > &, UT_VectorT < T > & > | MatrixDotOp |
typedef UT_SparseMatrixCSRT< T > | SparseMatrixType |
Public Member Functions | |
UT_MatrixIterSolverT (exint maxIterations=-1, UT_PreciseT< T > tolerance=1e-5, bool useAbsoluteError=false) | |
void | setMultVec (const MatrixOp &op) |
void | setMultVec (const SparseMatrixType &matrix) |
void | setTransposeMultVec (const MatrixOp &op) |
void | setTransposeMultVec (const SparseMatrixType &transposematrix) |
void | setPreconditioner (const MatrixOp &op) |
void | setPreconditioner (const UT_VectorT< T > &invertedDiagonal) |
void | setPreconditioner (const SparseMatrixType &L, const SparseMatrixType &U, bool LhasUnitDiagonal=false, bool UhasUnitDiagonal=false) |
void | setTransposePreconditioner (const MatrixOp &op) |
void | setTransposePreconditioner (const UT_VectorT< T > &invertedDiagonal) |
void | setStopCondition (const StopConditionOp &op) |
void | PCG (UT_VectorT< T > &x, const UT_VectorT< T > &b, exint *resultIters=NULL, UT_PreciseT< T > *resultError=NULL, UT_Interrupt *boss=NULL) const |
void | PCGLS (UT_VectorT< T > &x, const UT_VectorT< T > &b, exint *resultIters=NULL, UT_PreciseT< T > *resultError=NULL, UT_Interrupt *boss=NULL) const |
void | PBiCG (UT_VectorT< T > &x, const UT_VectorT< T > &b, exint *resultIters=NULL, UT_PreciseT< T > *resultError=NULL, UT_Interrupt *boss=NULL) const |
void | PBiCGStab (UT_VectorT< T > &x, const UT_VectorT< T > &b, exint *resultIters=NULL, UT_PreciseT< T > *resultError=NULL, UT_Interrupt *boss=NULL) const |
T | PCG (void(*AMult)(const UT_VectorT< T > &x, UT_VectorT< T > &result), void(*ASolve)(const UT_VectorT< T > &b, UT_VectorT< T > &x), int n, UT_VectorT< T > &x, const UT_VectorT< T > &b, T tol=1e-3, int normType=2, int maxIter=-1) |
T | PCGLS (void(*AMult)(const UT_VectorT< T > &x, UT_VectorT< T > &result, int transpose), void(*AtASolve)(const UT_VectorT< T > &b, UT_VectorT< T > &x), int m, int n, UT_VectorT< T > &x, const UT_VectorT< T > &b, T tol=1e-3, int normType=2, int maxIter=-1) |
template<typename AMult , typename AtASolve > | |
T | PCGLS (const AMult &amult, const AtASolve &atasolve, int rows, int cols, UT_VectorT< T > &x, const UT_VectorT< T > &b, fpreal tol=-1.0, int norm_type=2, int max_iter=-1) |
T | biPCG (void(*AMult)(const UT_VectorT< T > &x, UT_VectorT< T > &result, int transpose), void(*ASolve)(const UT_VectorT< T > &b, UT_VectorT< T > &x, int transpose), int n, UT_VectorT< T > &x, const UT_VectorT< T > &b, T tol=1e-3, int normType=2, int maxIter=-1) |
Static Public Member Functions | |
static void | PCG (UT_VectorT< T > &x, const UT_VectorT< T > &b, const UT_Functor2< void, const UT_VectorT< T > &, UT_VectorT< T > & > &AMult, const UT_Functor2< void, const UT_VectorT< T > &, UT_VectorT< T > & > &ASolve, const UT_Functor2< bool, int, const UT_VectorT< T > & > &iterateTest) |
Definition at line 457 of file UT_MatrixSolver.h.
typedef UT_Functor2<UT_PreciseT<T>, const UT_VectorT<T> &, UT_VectorT<T> &> UT_MatrixIterSolverT< T >::MatrixDotOp |
Definition at line 463 of file UT_MatrixSolver.h.
typedef UT_Functor2<void, const UT_VectorT<T> &, UT_VectorT<T> &> UT_MatrixIterSolverT< T >::MatrixOp |
Definition at line 460 of file UT_MatrixSolver.h.
typedef UT_SparseMatrixCSRT<T> UT_MatrixIterSolverT< T >::SparseMatrixType |
Definition at line 464 of file UT_MatrixSolver.h.
typedef UT_Functor2<bool, exint, T> UT_MatrixIterSolverT< T >::StopConditionOp |
Definition at line 461 of file UT_MatrixSolver.h.
UT_MatrixIterSolverT< T >::UT_MatrixIterSolverT | ( | exint | maxIterations = -1 , |
UT_PreciseT< T > | tolerance = 1e-5 , |
||
bool | useAbsoluteError = false |
||
) |
T UT_MatrixIterSolverT< T >::biPCG | ( | void(*)(const UT_VectorT< T > &x, UT_VectorT< T > &result, int transpose) | AMult, |
void(*)(const UT_VectorT< T > &b, UT_VectorT< T > &x, int transpose) | ASolve, | ||
int | n, | ||
UT_VectorT< T > & | x, | ||
const UT_VectorT< T > & | b, | ||
T | tol = 1e-3 , |
||
int | normType = 2 , |
||
int | maxIter = -1 |
||
) |
Preconditioned Conjugate Gradient method for solving Ax=b, given the matrix A[0..m-1][0..n-1] indirectly through AMult (ie. Ax if int = 0 or A^tx if int = 1), a preconditioner for A through ASolve, the vector b[0..m-1] and an initial guess x[0..n-1]. maxIter defaults to 2n. error |b-Ax|/|b| < tol. normType indicates the type of norm used for error: 0 L-infinity norm (ie. max) 1 L1-norm (ie. sum of abs) 2 L2-norm (ie. Euclidean distance) Output: x[0..n-1] and error.
void UT_MatrixIterSolverT< T >::PBiCG | ( | UT_VectorT< T > & | x, |
const UT_VectorT< T > & | b, | ||
exint * | resultIters = NULL , |
||
UT_PreciseT< T > * | resultError = NULL , |
||
UT_Interrupt * | boss = NULL |
||
) | const |
void UT_MatrixIterSolverT< T >::PBiCGStab | ( | UT_VectorT< T > & | x, |
const UT_VectorT< T > & | b, | ||
exint * | resultIters = NULL , |
||
UT_PreciseT< T > * | resultError = NULL , |
||
UT_Interrupt * | boss = NULL |
||
) | const |
void UT_MatrixIterSolverT< T >::PCG | ( | UT_VectorT< T > & | x, |
const UT_VectorT< T > & | b, | ||
exint * | resultIters = NULL , |
||
UT_PreciseT< T > * | resultError = NULL , |
||
UT_Interrupt * | boss = NULL |
||
) | const |
T UT_MatrixIterSolverT< T >::PCG | ( | void(*)(const UT_VectorT< T > &x, UT_VectorT< T > &result) | AMult, |
void(*)(const UT_VectorT< T > &b, UT_VectorT< T > &x) | ASolve, | ||
int | n, | ||
UT_VectorT< T > & | x, | ||
const UT_VectorT< T > & | b, | ||
T | tol = 1e-3 , |
||
int | normType = 2 , |
||
int | maxIter = -1 |
||
) |
Preconditioned Conjugate Gradient method for solving Ax=b, given the symmetric positive definite matrix A[0..n-1][0..n-1] indirectly through AMult (ie. Ax), a preconditioner for A through ASolve, the vector b[0..n-1] and an initial guess x[0..n-1]. maxIter defaults to 2n. error |b-Ax|/|b| < tol. normType indicates the type of norm used for error: 0 L-infinity norm (ie. max) 1 L1-norm (ie. sum of abs) 2 L2-norm (ie. Euclidean distance) Output: x[0..n-1] and error.
|
static |
Preconditioned Conjugate Gradient method for solving Ax=b with the symmetric positive definite matrix A, preconditioner, and iteration conditions implicitly defined by functors.
void UT_MatrixIterSolverT< T >::PCGLS | ( | UT_VectorT< T > & | x, |
const UT_VectorT< T > & | b, | ||
exint * | resultIters = NULL , |
||
UT_PreciseT< T > * | resultError = NULL , |
||
UT_Interrupt * | boss = NULL |
||
) | const |
T UT_MatrixIterSolverT< T >::PCGLS | ( | void(*)(const UT_VectorT< T > &x, UT_VectorT< T > &result, int transpose) | AMult, |
void(*)(const UT_VectorT< T > &b, UT_VectorT< T > &x) | AtASolve, | ||
int | m, | ||
int | n, | ||
UT_VectorT< T > & | x, | ||
const UT_VectorT< T > & | b, | ||
T | tol = 1e-3 , |
||
int | normType = 2 , |
||
int | maxIter = -1 |
||
) |
Preconditioned Conjugate Gradient method for solving least squares Ax=b, given the matrix A[0..m-1][0..n-1] indirectly through AMult (ie. Ax if int = 0 or A^tx if int = 1), a preconditioner for A^tA through AtASolve, the vector b[0..m-1] and an initial guess x[0..n-1]. maxIter defaults to 2n. error |A^t(b-Ax)|/|A^tb| < tol. normType indicates the type of norm used for error: 0 L-infinity norm (ie. max) 1 L1-norm (ie. sum of abs) 2 L2-norm (ie. Euclidean distance) Output: x[0..n-1] and error.
T UT_MatrixIterSolverT< T >::PCGLS | ( | const AMult & | amult, |
const AtASolve & | atasolve, | ||
int | rows, | ||
int | cols, | ||
UT_VectorT< T > & | x, | ||
const UT_VectorT< T > & | b, | ||
fpreal | tol = -1.0 , |
||
int | norm_type = 2 , |
||
int | max_iter = -1 |
||
) |
Modified interface for the above Preconditioned Conjugate Gradient for solving Ax=b. The template parameter class C must implement the following two methods:
1) A method to compute either Av or A^tv depending on transpose being 0 or 1.
void AMult(const UT_VectorT<T> &v, UT_VectorT<T> &result, bool transpose);
2) The preconditioner as above.
void AtASolve(const UT_VectorT<fpreal> &b, UT_VectorT<fpreal> &x)
The rel_tol and abs_tol respectively represent relative and absolute tolerance. Set either to a positive number to stop the solver as soon as the corresponding error drops below the given threshold. If both positive, the solver stops as soon as one of the errors meets its corresponding threshold.
Definition at line 24 of file UT_MatrixSolverImpl.h.
void UT_MatrixIterSolverT< T >::setMultVec | ( | const MatrixOp & | op | ) |
void UT_MatrixIterSolverT< T >::setMultVec | ( | const SparseMatrixType & | matrix | ) |
void UT_MatrixIterSolverT< T >::setPreconditioner | ( | const MatrixOp & | op | ) |
void UT_MatrixIterSolverT< T >::setPreconditioner | ( | const UT_VectorT< T > & | invertedDiagonal | ) |
void UT_MatrixIterSolverT< T >::setPreconditioner | ( | const SparseMatrixType & | L, |
const SparseMatrixType & | U, | ||
bool | LhasUnitDiagonal = false , |
||
bool | UhasUnitDiagonal = false |
||
) |
void UT_MatrixIterSolverT< T >::setStopCondition | ( | const StopConditionOp & | op | ) |
void UT_MatrixIterSolverT< T >::setTransposeMultVec | ( | const MatrixOp & | op | ) |
void UT_MatrixIterSolverT< T >::setTransposeMultVec | ( | const SparseMatrixType & | transposematrix | ) |
void UT_MatrixIterSolverT< T >::setTransposePreconditioner | ( | const MatrixOp & | op | ) |
void UT_MatrixIterSolverT< T >::setTransposePreconditioner | ( | const UT_VectorT< T > & | invertedDiagonal | ) |