Fix regeression in bicgstab: the threshold used to detect the need for a restart was much too large.

(grafted from bf334b8ae51725754f525c2ffcfbd83ffc55ff2e
)
This commit is contained in:
Gael Guennebaud 2014-07-01 22:29:04 +02:00
parent 065344a06b
commit e84bdbb445

View File

@ -61,6 +61,7 @@ bool bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,
VectorType s(n), t(n); VectorType s(n), t(n);
RealScalar tol2 = tol*tol; RealScalar tol2 = tol*tol;
RealScalar eps2 = NumTraits<Scalar>::epsilon()*NumTraits<Scalar>::epsilon();
int i = 0; int i = 0;
int restarts = 0; int restarts = 0;
@ -69,7 +70,7 @@ bool bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,
Scalar rho_old = rho; Scalar rho_old = rho;
rho = r0.dot(r); rho = r0.dot(r);
if (internal::isMuchSmallerThan(rho,r0_sqnorm)) if (abs(rho) < eps2*r0_sqnorm)
{ {
// The new residual vector became too orthogonal to the arbitrarily choosen direction r0 // The new residual vector became too orthogonal to the arbitrarily choosen direction r0
// Let's restart with a new r0: // Let's restart with a new r0: