remove CG printf outputs
This commit is contained in:
@@ -35,7 +35,7 @@ public:
|
|||||||
virtual ~btConjugateGradient(){}
|
virtual ~btConjugateGradient(){}
|
||||||
|
|
||||||
// return the number of iterations taken
|
// return the number of iterations taken
|
||||||
int solve(MatrixX& A, TVStack& x, const TVStack& b, btScalar tolerance)
|
int solve(MatrixX& A, TVStack& x, const TVStack& b, btScalar tolerance, bool verbose = false)
|
||||||
{
|
{
|
||||||
BT_PROFILE("CGSolve");
|
BT_PROFILE("CGSolve");
|
||||||
btAssert(x.size() == b.size());
|
btAssert(x.size() == b.size());
|
||||||
@@ -49,8 +49,11 @@ public:
|
|||||||
A.project(z);
|
A.project(z);
|
||||||
btScalar r_dot_z = dot(z,r);
|
btScalar r_dot_z = dot(z,r);
|
||||||
if (r_dot_z < tolerance) {
|
if (r_dot_z < tolerance) {
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
std::cout << "Iteration = 0" << std::endl;
|
std::cout << "Iteration = 0" << std::endl;
|
||||||
std::cout << "Two norm of the residual = " << r_dot_z << std::endl;
|
std::cout << "Two norm of the residual = " << r_dot_z << std::endl;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
p = z;
|
p = z;
|
||||||
@@ -70,13 +73,19 @@ public:
|
|||||||
r_dot_z = r_dot_z_new;
|
r_dot_z = r_dot_z_new;
|
||||||
r_dot_z_new = dot(r,z);
|
r_dot_z_new = dot(r,z);
|
||||||
if (r_dot_z_new < tolerance) {
|
if (r_dot_z_new < tolerance) {
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
std::cout << "ConjugateGradient iterations " << k << std::endl;
|
std::cout << "ConjugateGradient iterations " << k << std::endl;
|
||||||
|
}
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
btScalar beta = r_dot_z_new/ r_dot_z;
|
btScalar beta = r_dot_z_new/ r_dot_z;
|
||||||
p = multAndAdd(beta, p, z);
|
p = multAndAdd(beta, p, z);
|
||||||
}
|
}
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
std::cout << "ConjugateGradient max iterations reached " << max_iterations << std::endl;
|
std::cout << "ConjugateGradient max iterations reached " << max_iterations << std::endl;
|
||||||
|
}
|
||||||
return max_iterations;
|
return max_iterations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user