16#ifndef BT_CONJUGATE_GRADIENT_H
17#define BT_CONJUGATE_GRADIENT_H
19template <
class MatrixX>
48 r = this->
sub(b, temp);
58 std::cout <<
"Iteration = 0" << std::endl;
59 std::cout <<
"Two norm of the residual = " << r_dot_z << std::endl;
70 if (this->
dot(p, temp) < 0)
73 std::cout <<
"Encountered negative direction in CG!" << std::endl;
88 r_dot_z = r_dot_z_new;
89 r_dot_z_new = this->
dot(r,
z);
94 std::cout <<
"ConjugateGradient iterations " << k <<
" residual = " << r_dot_z_new << std::endl;
104 std::cout <<
"ConjugateGradient max iterations reached " <<
Base::m_maxIterations <<
" error = " << r_dot_z_new << std::endl;
SIMD_FORCE_INLINE const T & btMin(const T &a, const T &b)
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 void resize(int newsize, const T &fillData=T())
btConjugateGradient(const int max_it_in)
virtual ~btConjugateGradient()
int solve(MatrixX &A, TVStack &x, const TVStack &b, bool verbose=false)
void reinitialize(const TVStack &b)
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)