mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Fix bug #674: typo in documentation example for BiCGSTAB. They are now proper snippet files.
This commit is contained in:
parent
b61facb08b
commit
c6da881849
@ -136,34 +136,13 @@ struct traits<BiCGSTAB<_MatrixType,_Preconditioner> >
|
|||||||
* and NumTraits<Scalar>::epsilon() for the tolerance.
|
* and NumTraits<Scalar>::epsilon() for the tolerance.
|
||||||
*
|
*
|
||||||
* This class can be used as the direct solver classes. Here is a typical usage example:
|
* This class can be used as the direct solver classes. Here is a typical usage example:
|
||||||
* \code
|
* \include BiCGSTAB_simple.cpp
|
||||||
* int n = 10000;
|
|
||||||
* VectorXd x(n), b(n);
|
|
||||||
* SparseMatrix<double> A(n,n);
|
|
||||||
* // fill A and b
|
|
||||||
* BiCGSTAB<SparseMatrix<double> > solver;
|
|
||||||
* solver(A);
|
|
||||||
* x = solver.solve(b);
|
|
||||||
* std::cout << "#iterations: " << solver.iterations() << std::endl;
|
|
||||||
* std::cout << "estimated error: " << solver.error() << std::endl;
|
|
||||||
* // update b, and solve again
|
|
||||||
* x = solver.solve(b);
|
|
||||||
* \endcode
|
|
||||||
*
|
*
|
||||||
* By default the iterations start with x=0 as an initial guess of the solution.
|
* By default the iterations start with x=0 as an initial guess of the solution.
|
||||||
* One can control the start using the solveWithGuess() method. Here is a step by
|
* One can control the start using the solveWithGuess() method. Here is a step by
|
||||||
* step execution example starting with a random guess and printing the evolution
|
* step execution example starting with a random guess and printing the evolution
|
||||||
* of the estimated error:
|
* of the estimated error:
|
||||||
* * \code
|
* \include BiCGSTAB_step_by_step.cpp
|
||||||
* 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);
|
|
||||||
* \endcode
|
|
||||||
* Note that such a step by step excution is slightly slower.
|
* Note that such a step by step excution is slightly slower.
|
||||||
*
|
*
|
||||||
* \sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner
|
* \sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner
|
||||||
|
11
doc/snippets/BiCGSTAB_simple.cpp
Normal file
11
doc/snippets/BiCGSTAB_simple.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
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
|
14
doc/snippets/BiCGSTAB_step_by_step.cpp
Normal file
14
doc/snippets/BiCGSTAB_step_by_step.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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);
|
@ -1,4 +1,4 @@
|
|||||||
#include <Eigen/Dense>
|
#include <Eigen/Eigen>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace Eigen;
|
using namespace Eigen;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user