5 #ifndef __eigenpy_iterative_solver_base_hpp__
6 #define __eigenpy_iterative_solver_base_hpp__
13 template <
typename IterativeSolver>
15 IterativeSolverVisitor<IterativeSolver> > {
20 template <
class PyClass>
22 typedef IterativeSolver IS;
25 .def(
"error", &IS::error,
26 "Returns the tolerance error reached during the last solve.\n"
27 "It is a close approximation of the true relative residual error "
29 .def(
"info", &IS::info,
30 "Returns success if the iterations converged, and NoConvergence "
33 "iterations", &IS::iterations,
34 "Returns the number of iterations performed during the last solve.")
35 .def(
"maxIterations", &IS::maxIterations,
36 "Returns the max number of iterations.\n"
37 "It is either the value setted by setMaxIterations or, by "
38 "default, twice the number of columns of the matrix.")
39 .def(
"setMaxIterations", &IS::setMaxIterations,
40 "Sets the max number of iterations.\n"
41 "Default is twice the number of columns of the matrix.",
42 bp::return_value_policy<bp::reference_existing_object>())
43 .def(
"tolerance", &IS::tolerance,
44 "Returns he tolerance threshold used by the stopping criteria.")
45 .def(
"setTolerance", &IS::setTolerance,
46 "Sets the tolerance threshold used by the stopping criteria.\n"
47 "This value is used as an upper bound to the relative residual "
48 "error: |Ax-b|/|b|. The default value is the machine precision.",
49 bp::return_value_policy<bp::reference_existing_object>())
51 "Initializes the iterative solver for the sparsity pattern of the "
52 "matrix A for further solving Ax=b problems.\n"
53 "Currently, this function mostly calls analyzePattern on the "
55 "In the future we might, for instance, implement column "
56 "reordering for faster matrix vector products.",
57 bp::return_value_policy<bp::reference_existing_object>())
58 .def(
"factorize", &
factorize, bp::arg(
"A"),
59 "Initializes the iterative solver with the numerical values of "
60 "the matrix A for further solving Ax=b problems.\n"
61 "Currently, this function mostly calls factorize on the "
63 bp::return_value_policy<bp::reference_existing_object>())
64 .def(
"compute", &
compute, bp::arg(
"A"),
65 "Initializes the iterative solver with the numerical values of "
66 "the matrix A for further solving Ax=b problems.\n"
67 "Currently, this function mostly calls factorize on the "
69 "In the future we might, for instance, implement column "
70 "reordering for faster matrix vector products.",
71 bp::return_value_policy<bp::reference_existing_object>())
73 "Returns the solution x of Ax = b using the current decomposition "
74 "of A and x0 as an initial solution.")
75 .def(
"preconditioner",
77 "Returns a read-write reference to the preconditioner for custom "
79 bp::return_internal_reference<>());
83 static IterativeSolver&
factorize(IterativeSolver&
self,
85 return self.factorize(
m);
89 return self.compute(
m);
94 return self.analyzePattern(
m);
98 const Eigen::VectorXd& b,
99 const Eigen::VectorXd& x0) {
100 return self.solveWithGuess(b, x0);
106 #endif // ifndef __eigenpy_iterative_solver_base_hpp__