eigen/doc/snippets/BiCGSTAB_step_by_step.cpp
Aaron Franke 5c22c7a7de Make file formatting comply with POSIX and Unix standards
UTF-8, LF, no BOM, and newlines at the end of files
2020-03-23 18:09:02 +00:00

15 lines
407 B
C++

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);