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)
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;
91 temp_p = this->
multAndAdd(beta, temp_p, temp_r);
95 std::cout <<
"ConjugateResidual max iterations reached, residual = " << best_r << std::endl;
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
SIMD_FORCE_INLINE void resize(int newsize, const T &fillData=T())
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)
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)
local_group_size(16, 16) .push_constant(Type b
ccl_device_inline float beta(float x, float y)