xref: /aosp_15_r20/external/eigen/doc/snippets/BiCGSTAB_simple.cpp (revision bf2c37156dfe67e5dfebd6d394bad8b2ab5804d4)
1*bf2c3715SXin Li   int n = 10000;
2*bf2c3715SXin Li   VectorXd x(n), b(n);
3*bf2c3715SXin Li   SparseMatrix<double> A(n,n);
4*bf2c3715SXin Li   /* ... fill A and b ... */
5*bf2c3715SXin Li   BiCGSTAB<SparseMatrix<double> > solver;
6*bf2c3715SXin Li   solver.compute(A);
7*bf2c3715SXin Li   x = solver.solve(b);
8*bf2c3715SXin Li   std::cout << "#iterations:     " << solver.iterations() << std::endl;
9*bf2c3715SXin Li   std::cout << "estimated error: " << solver.error()      << std::endl;
10*bf2c3715SXin Li   /* ... update b ... */
11*bf2c3715SXin Li   x = solver.solve(b); // solve again
12