17 #ifndef __eigenpy_iterative_solver_base_hpp__ 18 #define __eigenpy_iterative_solver_base_hpp__ 28 template<
typename IterativeSolver>
30 :
public boost::python::def_visitor< IterativeSolverVisitor<IterativeSolver> >
37 template<
class PyClass>
40 typedef IterativeSolver IS;
44 .def(
"error",&IS::error,
"Returns the tolerance error reached during the last solve.\n" 45 "It is a close approximation of the true relative residual error |Ax-b|/|b|.")
46 .def(
"info",&IS::info,
"Returns success if the iterations converged, and NoConvergence otherwise.")
47 .def(
"iterations",&IS::iterations,
"Returns the number of iterations performed during the last solve.")
48 .def(
"maxIterations",&IS::maxIterations,
"Returns the max number of iterations.\n" 49 "It is either the value setted by setMaxIterations or, by default, twice the number of columns of the matrix.")
50 .def(
"setMaxIterations",&IS::setMaxIterations,
"Sets the max number of iterations.\n" 51 "Default is twice the number of columns of the matrix.",
52 bp::return_value_policy<bp::reference_existing_object>())
53 .def(
"tolerance",&IS::tolerance,
"Returns he tolerance threshold used by the stopping criteria.")
54 .def(
"setTolerance",&IS::setTolerance,
"Sets the tolerance threshold used by the stopping criteria.\n" 55 "This value is used as an upper bound to the relative residual error: |Ax-b|/|b|. The default value is the machine precision.",
56 bp::return_value_policy<bp::reference_existing_object>())
57 .def(
"analyzePattern",&
analyzePattern,bp::arg(
"A"),
"Initializes the iterative solver for the sparsity pattern of the matrix A for further solving Ax=b problems.\n" 58 "Currently, this function mostly calls analyzePattern on the preconditioner.\n" 59 "In the future we might, for instance, implement column reordering for faster matrix vector products.",
60 bp::return_value_policy<bp::reference_existing_object>())
61 .def(
"factorize",&
factorize,bp::arg(
"A"),
"Initializes the iterative solver with the numerical values of the matrix A for further solving Ax=b problems.\n" 62 "Currently, this function mostly calls factorize on the preconditioner.",
63 bp::return_value_policy<bp::reference_existing_object>())
64 .def(
"compute",&
compute,bp::arg(
"A"),
"Initializes the iterative solver with the numerical values of the matrix A for further solving Ax=b problems.\n" 65 "Currently, this function mostly calls factorize on the preconditioner.\n" 66 "In the future we might, for instance, implement column reordering for faster matrix vector products.",
67 bp::return_value_policy<bp::reference_existing_object>())
69 "Returns the solution x of Ax = b using the current decomposition of A and x0 as an initial solution.")
70 .def(
"preconditioner",(Preconditioner & (IS::*)(
void))&IS::preconditioner,
"Returns a read-write reference to the preconditioner for custom configuration.",bp::return_internal_reference<>())
77 static IterativeSolver &
factorize(IterativeSolver &
self,
const MatrixType & m)
79 return self.factorize(m);
82 static IterativeSolver &
compute(IterativeSolver &
self,
const MatrixType & m)
84 return self.compute(m);
87 static IterativeSolver &
analyzePattern(IterativeSolver &
self,
const MatrixType & m)
89 return self.analyzePattern(m);
92 static VectorType
solveWithGuess(IterativeSolver &
self,
const Eigen::VectorXd & b,
const Eigen::VectorXd & x0)
94 return self.solveWithGuess(b,x0);
102 #endif // ifndef __eigenpy_iterative_solver_base_hpp__ static IterativeSolver & analyzePattern(IterativeSolver &self, const MatrixType &m)
Eigen::VectorXd VectorType
IterativeSolver::Preconditioner Preconditioner
static IterativeSolver & factorize(IterativeSolver &self, const MatrixType &m)
IterativeSolver::MatrixType MatrixType
void visit(PyClass &cl) const
static IterativeSolver & compute(IterativeSolver &self, const MatrixType &m)
static VectorType solveWithGuess(IterativeSolver &self, const Eigen::VectorXd &b, const Eigen::VectorXd &x0)