From: kronbichler Date: Tue, 23 Aug 2011 09:41:55 +0000 (+0000) Subject: Fix computation of eigenvalues when only a few iterations are done. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74b3245444c68d8ca436242e8f369b59f8864681;p=dealii-svn.git Fix computation of eigenvalues when only a few iterations are done. git-svn-id: https://svn.dealii.org/trunk@24170 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/lac/precondition.h b/deal.II/include/deal.II/lac/precondition.h index 0d96f8f45b..224044fe5e 100644 --- a/deal.II/include/deal.II/lac/precondition.h +++ b/deal.II/include/deal.II/lac/precondition.h @@ -1592,6 +1592,8 @@ PreconditionChebyshev::initialize (const MATRIX &matrix, const AdditionalData &additional_data) { Assert (matrix.m() == matrix.n(), ExcMessage("Matrix not quadratic.")); + Assert (additional_data.eig_cg_n_iterations > 2, + ExcMessage ("Need to set at least two iterations to find eigenvalues.")); matrix_ptr = &matrix; data = additional_data; if (data.matrix_diagonal_inverse.size() != matrix.m()) @@ -1644,7 +1646,10 @@ PreconditionChebyshev::initialize (const MATRIX &matrix, g.add (alpha, update1); res = g.l2_norm(); - if (it > data.eig_cg_n_iterations || res < data.eig_cg_residual) + // need at least two iterations to have + // maximum and minimum eigenvalue + if (it > data.eig_cg_n_iterations || (it > 2 && + res < data.eig_cg_residual)) break; beta = gh;