1 year ago

#301893

test-img

skrat

Wrong number of iterations when BiCGSTAB called with guess

I am using the c++ and Eigen library to solve a system with BiCGSTAB solver.

#include <Eigen/IterativeLinearSolvers>

At some point in the code I initialize the matrix A and rhs vector rhs

int N = domain.size();
Eigen::SparseMatrix<double, Eigen::RowMajor> M(N, N);
Eigen::VectorXd rhs(N);
rhs.setZero();
M.reserve(storage.supportSizes());

Finally solver is created and system is solved

        Eigen::BiCGSTAB<decltype(M), Eigen::IncompleteLUT<double>> solver;
        solver.setMaxIterations(300);
        solver.compute(M);
        auto sol = solver.solveWithGuess(rhs, guess);
        if (debug) {
            print(solver.iterations());
            print(solver.error());
        }

Problem

The problem with the above code is that the output is unreasonable

solver.iterations() = 94414646480416;
solver.error() = 6.91858e-310;

even when the initial guess is a vector of zeros (as is the defaulty way for BiCGSTAB). I must point out here, that the the time required to solve the system is a matter of (mili)seconds, so I am quite sure it did not do the 94414646480416 iterations.

Does anybody know how to get the number of iterations when solution is obtained with a guess?

c++

solver

eigen3

0 Answers

Your Answer

Accepted video resources