16 #ifndef BT_CONJUGATE_GRADIENT_H
17 #define BT_CONJUGATE_GRADIENT_H
24 template <
class MatrixX>
57 std::cout <<
"Iteration = 0" << std::endl;
58 std::cout <<
"Two norm of the residual = " << r_dot_z << std::endl;
71 std::cout <<
"Encountered negative direction in CG!" << std::endl;
86 r_dot_z = r_dot_z_new;
87 r_dot_z_new =
dot(
r,
z);
91 std::cout <<
"ConjugateGradient iterations " << k << std::endl;
101 std::cout <<
"ConjugateGradient max iterations reached " <<
max_iterations << std::endl;
120 for (
int i = 0; i < a.
size(); ++i)
135 for (
int i = 0; i < a.
size(); ++i)
136 ans += a[i].
dot(b[i]);
144 for (
int i = 0; i < a.
size(); ++i)
145 result[i] += s * a[i];
153 for (
int i = 0; i < a.
size(); ++i)
154 result[i] = s * a[i] + b[i];
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
int size() const
return the number of elements in the array
void resize(int newsize, const T &fillData=T())
btConjugateGradient(const int max_it_in)
btScalar dot(const TVStack &a, const TVStack &b)
btScalar squaredNorm(const TVStack &a)
virtual ~btConjugateGradient()
btScalar tolerance_squared
int solve(MatrixX &A, TVStack &x, const TVStack &b, bool verbose=false)
void multAndAddTo(btScalar s, const TVStack &a, TVStack &result)
btAlignedObjectArray< btVector3 > TVStack
void reinitialize(const TVStack &b)
TVStack multAndAdd(btScalar s, const TVStack &a, const TVStack &b)
TVStack sub(const TVStack &a, const TVStack &b)