diff options
author | Gael Guennebaud <g.gael@free.fr> | 2013-10-16 15:25:39 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2013-10-16 15:25:39 +0200 |
commit | c6da881849734fc8c76a151e60da3bc65ef2e2fd (patch) | |
tree | 160f6b0e5d82ec7a9abe084251efad6f0f74a2a8 /doc/snippets | |
parent | b61facb08b1e6c49724f27e15d72b490c6c07d8f (diff) |
Fix bug #674: typo in documentation example for BiCGSTAB. They are now proper snippet files.
Diffstat (limited to 'doc/snippets')
-rw-r--r-- | doc/snippets/BiCGSTAB_simple.cpp | 11 | ||||
-rw-r--r-- | doc/snippets/BiCGSTAB_step_by_step.cpp | 14 | ||||
-rw-r--r-- | doc/snippets/compile_snippet.cpp.in | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/doc/snippets/BiCGSTAB_simple.cpp b/doc/snippets/BiCGSTAB_simple.cpp new file mode 100644 index 000000000..5520f4f1f --- /dev/null +++ b/doc/snippets/BiCGSTAB_simple.cpp @@ -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
\ No newline at end of file diff --git a/doc/snippets/BiCGSTAB_step_by_step.cpp b/doc/snippets/BiCGSTAB_step_by_step.cpp new file mode 100644 index 000000000..06147bb81 --- /dev/null +++ b/doc/snippets/BiCGSTAB_step_by_step.cpp @@ -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);
\ No newline at end of file diff --git a/doc/snippets/compile_snippet.cpp.in b/doc/snippets/compile_snippet.cpp.in index 894cd526c..82ae89162 100644 --- a/doc/snippets/compile_snippet.cpp.in +++ b/doc/snippets/compile_snippet.cpp.in @@ -1,4 +1,4 @@ -#include <Eigen/Dense> +#include <Eigen/Eigen> #include <iostream> using namespace Eigen; |