COSC-4P80-Assignment-2/lib/eigen-3.4.0/doc/snippets/BiCGSTAB_step_by_step.cpp

15 lines
407 B
C++
Raw Normal View History

2024-10-21 16:42:03 -04:00
int n = 10000;
VectorXd x(n), b(n);
SparseMatrix<double> A(n,n);
/* ... fill A and b ... */
BiCGSTAB<SparseMatrix<double> > solver(A);
// start from a random solution
x = VectorXd::Random(n);
solver.setMaxIterations(1);
int i = 0;
do {
x = solver.solveWithGuess(b,x);
std::cout << i << " : " << solver.error() << std::endl;
++i;
} while (solver.info()!=Success && i<100);