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

12 lines
394 B
C++
Raw Permalink 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;
solver.compute(A);
x = solver.solve(b);
std::cout << "#iterations: " << solver.iterations() << std::endl;
std::cout << "estimated error: " << solver.error() << std::endl;
/* ... update b ... */
x = solver.solve(b); // solve again