27 template<
typename MatrixType,
30 typename FilterMatrixType,
35 const FilterMatrixType &
filter,
38 typename Dest::RealScalar &tol_error)
42 typedef typename Dest::RealScalar RealScalar;
44 typedef Matrix<Scalar, Dynamic, 1> VectorType;
46 RealScalar tol = tol_error;
51 VectorType residual =
filter * (rhs - mat *
x);
53 RealScalar rhsNorm2 = (
filter * rhs).squaredNorm();
61 RealScalar
threshold = tol * tol * rhsNorm2;
62 RealScalar residualNorm2 = residual.squaredNorm();
65 tol_error =
sqrt(residualNorm2 / rhsNorm2);
70 p =
filter * precond.solve(residual);
72 VectorType
z(n), tmp(n);
76 while (i < maxIters) {
77 tmp.noalias() =
filter * (mat * p);
79 Scalar alpha = absNew / p.dot(tmp);
81 residual -= alpha * tmp;
83 residualNorm2 = residual.squaredNorm();
88 z = precond.solve(residual);
90 RealScalar absOld = absNew;
98 tol_error =
sqrt(residualNorm2 / rhsNorm2);
105 template<
typename MatrixType>
struct MatrixFilter {
106 MatrixFilter() : m_cmat(
NULL)
110 MatrixFilter(
const MatrixType &cmat) : m_cmat(&cmat)
114 void setMatrix(
const MatrixType &cmat)
119 template<
typename VectorType>
void apply(VectorType
v)
const
125 const MatrixType *m_cmat;
129 template<
typename _MatrixType,
131 typename _FilterMatrixType = _MatrixType,
132 typename _Preconditioner = DiagonalPreconditioner<typename _MatrixType::Scalar>>
133 class ConstrainedConjugateGradient;
137 template<
typename _MatrixType,
int _UpLo,
typename _FilterMatrixType,
typename _Preconditioner>
196 template<
typename _MatrixType,
int _UpLo,
typename _FilterMatrixType,
typename _Preconditioner>
198 :
public IterativeSolverBase<
199 ConstrainedConjugateGradient<_MatrixType, _UpLo, _FilterMatrixType, _Preconditioner>> {
200 typedef IterativeSolverBase<ConstrainedConjugateGradient> Base;
203 using Base::m_isInitialized;
204 using Base::m_iterations;
205 using Base::mp_matrix;
210 typedef typename MatrixType::Index
Index;
255 template<
typename Rhs,
typename Guess>
256 inline const internal::solve_retval_with_guess<ConstrainedConjugateGradient, Rhs, Guess>
259 eigen_assert(m_isInitialized &&
"ConjugateGradient is not initialized.");
261 Base::rows() ==
b.rows() &&
262 "ConjugateGradient::solve(): invalid number of rows of the right hand side matrix b");
263 return internal::solve_retval_with_guess<ConstrainedConjugateGradient, Rhs, Guess>(
264 *
this,
b.derived(), x0);
270 m_iterations = Base::maxIterations();
271 m_error = Base::m_tolerance;
273 for (
int j = 0; j <
b.cols(); j++) {
274 m_iterations = Base::maxIterations();
275 m_error = Base::m_tolerance;
277 typename Dest::ColXpr xj(
x, j);
282 Base::m_preconditioner,
287 m_isInitialized =
true;
288 m_info = m_error <= Base::m_tolerance ? Success : NoConvergence;
292 template<
typename Rhs,
typename Dest>
void _solve(
const Rhs &
b, Dest &
x)
const
304 template<
typename _MatrixType,
int _UpLo,
typename _Filter,
typename _Preconditioner,
typename Rhs>
307 : solve_retval_base<ConstrainedConjugateGradient<_MatrixType, _UpLo, _Filter, _Preconditioner>,
310 EIGEN_MAKE_SOLVE_HELPERS(
Dec, Rhs)
312 template<typename Dest>
void evalTo(Dest &dst)
const
314 dec()._solve(rhs(), dst);
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
ATTR_WARN_UNUSED_RESULT const BMVert * v
A conjugate gradient solver for sparse self-adjoint problems with additional constraints.
ConstrainedConjugateGradient()
void _solve(const Rhs &b, Dest &x) const
_FilterMatrixType FilterMatrixType
const FilterMatrixType & filter() const
void _solveWithGuess(const Rhs &b, Dest &x) const
FilterMatrixType & filter()
ConstrainedConjugateGradient(const MatrixType &A)
~ConstrainedConjugateGradient()
_Preconditioner Preconditioner
MatrixType::Scalar Scalar
MatrixType::RealScalar RealScalar
FilterMatrixType m_filter
const internal::solve_retval_with_guess< ConstrainedConjugateGradient, Rhs, Guess > solveWithGuess(const MatrixBase< Rhs > &b, const Guess &x0) const
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
EIGEN_DONT_INLINE void constrained_conjugate_gradient(const MatrixType &mat, const Rhs &rhs, Dest &x, const FilterMatrixType &filter, const Preconditioner &precond, int &iters, typename Dest::RealScalar &tol_error)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
ConstrainedConjugateGradient< _MatrixType, _UpLo, _Filter, _Preconditioner > Dec
_Preconditioner Preconditioner
_FilterMatrixType FilterMatrixType
ccl_device_inline float beta(float x, float y)