15 #ifndef __UT_MATRIXSOLVERIMPL_H_INCLUDED__
16 #define __UT_MATRIXSOLVERIMPL_H_INCLUDED__
22 template <
typename AMult,
typename AtASolve>
27 fpreal tol,
int norm_type,
int max_iter)
41 rhs_norm2 =
dot(
s,
s);
44 rhs_norm2 =
s.norm(norm_type);
45 rhs_norm2 *= rhs_norm2;
54 fpreal64 threshold = tol * tol * rhs_norm2;
57 max_iter = 2 * (rows + cols);
65 residual_norm2 =
dot(
s,
s);
68 residual_norm2 =
s.norm(norm_type);
69 residual_norm2 *= residual_norm2;
72 if (residual_norm2 < threshold)
74 return SYSsqrt(residual_norm2 / rhs_norm2);
80 for (
exint iter = 0; iter < max_iter; ++iter)
86 alpha = abs_new /
dot(tmp, tmp);
87 x.addScaledVec(alpha, p);
88 r.addScaledVec(-alpha, tmp);
92 residual_norm2 =
dot(
s,
s);
95 residual_norm2 =
s.norm(norm_type);
96 residual_norm2 *= residual_norm2;
98 if (residual_norm2 < threshold)
104 p.scaleAddVec(abs_new / absOld, z);
107 return residual_norm2 / rhs_norm2;
111 #endif // __UT_MATRIXSOLVERIMPL_H_INCLUDED__
void zero()
Initialize to zeros.
GLdouble GLdouble GLdouble z
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
GLfloat GLfloat GLfloat alpha
void PCGLS(UT_VectorT< T > &x, const UT_VectorT< T > &b, exint *resultIters=NULL, UT_PreciseT< T > *resultError=NULL, UT_Interrupt *boss=NULL) const
GLboolean GLboolean GLboolean b