aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
diff options
context:
space:
mode:
authorGravatar Desire NUENTSA <desire.nuentsa_wakam@inria.fr>2012-02-10 10:59:39 +0100
committerGravatar Desire NUENTSA <desire.nuentsa_wakam@inria.fr>2012-02-10 10:59:39 +0100
commita815d962daa778408942aeac4ef9c3fe283bd724 (patch)
tree86d6fbdbd9aafcc945c7c6feddf373c277369273 /Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
parent9ed6a267a336f0fff4a2183a622e311d05194aca (diff)
Add the implementation of the Incomplete LU preconditioner with dual threshold (ILUT)
Modify the BiCGSTAB function to check the residual norm of the initial guess
Diffstat (limited to 'Eigen/src/IterativeLinearSolvers/BiCGSTAB.h')
-rw-r--r--Eigen/src/IterativeLinearSolvers/BiCGSTAB.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h b/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
index b8073915e..c0a9b120d 100644
--- a/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
+++ b/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
@@ -53,6 +53,7 @@ void bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,
int n = mat.cols();
VectorType r = rhs - mat * x;
VectorType r0 = r;
+
RealScalar r0_sqnorm = r0.squaredNorm();
Scalar rho = 1;
Scalar alpha = 1;
@@ -67,15 +68,17 @@ void bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,
RealScalar tol2 = tol*tol;
int i = 0;
- do
+ while ( r.squaredNorm()/r0_sqnorm > tol2 && i<maxIters )
{
Scalar rho_old = rho;
rho = r0.dot(r);
+ eigen_assert((rho != Scalar(0)) && "BiCGSTAB BROKE DOWN !!!");
Scalar beta = (rho/rho_old) * (alpha / w);
p = r + beta * (p - w * v);
y = precond.solve(p);
+
v.noalias() = mat * y;
alpha = rho / r0.dot(v);
@@ -84,17 +87,12 @@ void bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,
z = precond.solve(s);
t.noalias() = mat * z;
- kt = precond.solve(t);
- ks = precond.solve(s);
-
- w = kt.dot(ks) / kt.squaredNorm();
+ w = t.dot(s) / t.squaredNorm();
x += alpha * y + w * z;
r = s - w * t;
++i;
- } while ( r.squaredNorm()/r0_sqnorm > tol2 && i<maxIters );
-
+ }
tol_error = sqrt(r.squaredNorm()/r0_sqnorm);
- //tol_error = sqrt(abs(absNew / absInit));
iters = i;
}
@@ -233,7 +231,7 @@ public:
template<typename Rhs,typename Dest>
void _solve(const Rhs& b, Dest& x) const
{
- x.setOnes();
+ x.setZero();
_solveWithGuess(b,x);
}