16#ifndef BT_CONJUGATE_RESIDUAL_H
17#define BT_CONJUGATE_RESIDUAL_H
20template <
class MatrixX>
25 TVStack r, p, z, temp_p, temp_r, best_x;
33 : Base(max_it_in, 1
e-8)
40 int solve(MatrixX&
A, TVStack&
x,
const TVStack&
b,
bool verbose =
false)
46 A.multiply(
x, temp_r);
47 r = this->
sub(
b, temp_r);
59 A.multiply(p, temp_p);
62 r_dot_Ar = this->
dot(r, temp_r);
66 A.precondition(temp_p, z);
84 A.multiply(r, temp_r);
85 r_dot_Ar_new = this->
dot(r, temp_r);
87 r_dot_Ar = r_dot_Ar_new;
95 std::cout <<
"ConjugateResidual max iterations reached, residual = " << best_r << std::endl;
106 temp_p.resize(
b.size());
107 temp_r.resize(
b.size());
108 best_x.resize(
b.size());
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btConjugateResidual(const int max_it_in)
int solve(MatrixX &A, TVStack &x, const TVStack &b, bool verbose=false)
void reinitialize(const TVStack &b)
virtual ~btConjugateResidual()
virtual SIMD_FORCE_INLINE TVStack sub(const TVStack &a, const TVStack &b)
virtual SIMD_FORCE_INLINE TVStack multAndAdd(btScalar s, const TVStack &a, const TVStack &b)
btKrylovSolver(int maxIterations, btScalar tolerance)
virtual SIMD_FORCE_INLINE btScalar norm(const TVStack &a)
virtual SIMD_FORCE_INLINE btScalar dot(const TVStack &a, const TVStack &b)
virtual SIMD_FORCE_INLINE void multAndAddTo(btScalar s, const TVStack &a, TVStack &result)
ccl_device_inline float beta(const float x, const float y)