17 #ifndef __eigenpy_basic_preconditioners_hpp__ 18 #define __eigenpy_basic_preconditioners_hpp__ 21 #include <Eigen/IterativeLinearSolvers> 28 template<
typename Preconditioner>
30 :
public bp::def_visitor< PreconditionerBaseVisitor<Preconditioner> >
35 template<
class PyClass>
39 .def(bp::init<>(
"Default constructor"))
40 .def(bp::init<MatrixType>(bp::arg(
"A"),
"Initialize the preconditioner with matrix A for further Az=b solving."))
41 #if EIGEN_VERSION_AT_LEAST(3,3,0) 42 .def(
"info",&Preconditioner::info,
43 "Returns success if the Preconditioner has been well initialized.")
45 .def(
"solve",&
solve,bp::arg(
"b"),
46 "Returns the solution A * z = b where the preconditioner is an estimate of A^-1.")
48 .def(
"compute",&Preconditioner::template compute<MatrixType>,bp::arg(
"mat"),
49 "Initialize the preconditioner from the matrix value.",
50 bp::return_value_policy<bp::reference_existing_object>())
51 .def(
"factorize",&Preconditioner::template factorize<MatrixType>,bp::arg(
"mat"),
52 "Initialize the preconditioner from the matrix value, i.e factorize the mat given as input to approximate its inverse.",
53 bp::return_value_policy<bp::reference_existing_object>())
60 static VectorType
solve(Preconditioner &
self,
const VectorType & b)
67 template<
typename Scalar>
70 typedef Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>
MatrixType;
73 template<
class PyClass>
86 bp::class_<Preconditioner>(
"DiagonalPreconditioner",
87 "A preconditioner based on the digonal entrie.\n" 88 "This class allows to approximately solve for A.x = b problems assuming A is a diagonal matrix.",
95 #if EIGEN_VERSION_AT_LEAST(3,3,5) 96 template<
typename Scalar>
97 struct LeastSquareDiagonalPreconditionerVisitor :
PreconditionerBaseVisitor<Eigen::LeastSquareDiagonalPreconditioner<Scalar> >
99 typedef Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>
MatrixType;
100 typedef Eigen::LeastSquareDiagonalPreconditioner<Scalar>
Preconditioner;
102 template<
class PyClass>
103 void visit(PyClass&)
const 109 bp::class_<Preconditioner>(
"LeastSquareDiagonalPreconditioner",
110 "Jacobi preconditioner for LeastSquaresConjugateGradient.\n" 111 "his class allows to approximately solve for A' A x = A' b problems assuming A' A is a diagonal matrix.",
124 template<
class PyClass>
131 bp::class_<Preconditioner>(
"IdentityPreconditioner",
142 #endif // ifndef __eigenpy_basic_preconditioners_hpp__ Eigen::IdentityPreconditioner Preconditioner
Eigen::VectorXd VectorType
void visit(PyClass &) const
void visit(PyClass &cl) const
Eigen::DiagonalPreconditioner< Scalar > Preconditioner
Eigen::MatrixXd MatrixType
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > MatrixType
void expose()
Call the expose function of a given type T.
static VectorType solve(Preconditioner &self, const VectorType &b)
void visit(PyClass &cl) const