15 :
public boost::python::def_visitor<IncompleteLUTVisitor<_MatrixType>> {
16 typedef _MatrixType MatrixType;
17 typedef typename MatrixType::Scalar Scalar;
18 typedef typename MatrixType::RealScalar RealScalar;
19 typedef Eigen::IncompleteLUT<Scalar> Solver;
20 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, MatrixType::Options>
22 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic,
26 template <
class PyClass>
27 void visit(PyClass& cl)
const {
28 cl.def(bp::init<>(bp::arg(
"self"),
"Default constructor"))
29 .def(bp::init<MatrixType>(bp::args(
"self",
"matrix"),
30 "Constructs and performs the LDLT " 31 "factorization from a given matrix."))
32 .def(bp::init<const MatrixType&, RealScalar, int>(
34 bp::arg(
"droptol") = Eigen::NumTraits<Scalar>::dummy_precision(),
35 bp::arg(
"fillfactor") = 10),
36 "Constructs an incomplete LU factorization from a given matrix."))
38 .def(
"rows", &Solver::rows, bp::arg(
"self"),
39 "Returns the number of rows of the matrix.")
40 .def(
"cols", &Solver::cols, bp::arg(
"self"),
41 "Returns the number of cols of the matrix.")
43 .def(
"info", &Solver::info, bp::arg(
"self"),
44 "Reports whether previous computation was successful.")
48 +[](Solver& self,
const MatrixType& amat) {
49 self.analyzePattern(amat);
54 +[](Solver& self,
const MatrixType& amat) { self.factorize(amat); },
58 +[](Solver& self,
const MatrixType& amat) { self.compute(amat); },
61 .def(
"setDroptol", &Solver::setDroptol, bp::arg(
"self"))
62 .def(
"setFillfactor", &Solver::setFillfactor, bp::arg(
"self"))
66 +[](
const Solver& self,
const Eigen::Ref<DenseVectorXs const>& b)
67 -> DenseVectorXs {
return self.solve(b); },
69 "Returns the solution x of A x = b using the current decomposition " 70 "of A, where b is a right hand side vector.")
73 +[](
const Solver& self,
const Eigen::Ref<DenseMatrixXs const>& B)
74 -> DenseMatrixXs {
return self.solve(B); },
76 "Returns the solution X of A X = B using the current decomposition " 77 "of A where B is a right hand side matrix.")
80 +[](
const Solver& self,
const MatrixType& B) -> MatrixType {
81 DenseMatrixXs B_dense = DenseMatrixXs(B);
82 DenseMatrixXs X_dense = self.solve(B_dense);
83 return MatrixType(X_dense.sparseView());
86 "Returns the solution X of A X = B using the current decomposition " 87 "of A where B is a right hand side matrix.");
91 static const std::string classname =
92 "IncompleteLUT_" + scalar_name<Scalar>::shortname();
96 static void expose(
const std::string& name) {
97 bp::class_<Solver, boost::noncopyable>(
99 "Incomplete LU factorization with dual-threshold strategy.",