15 IncompleteCholeskyVisitor<_MatrixType>> {
16 typedef _MatrixType MatrixType;
17 typedef typename MatrixType::Scalar Scalar;
18 typedef typename MatrixType::RealScalar RealScalar;
19 typedef Eigen::IncompleteCholesky<Scalar> Solver;
20 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, MatrixType::Options>
22 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic,
26 typedef Eigen::SparseMatrix<Scalar, Eigen::ColMajor> FactorType;
27 typedef Eigen::Matrix<RealScalar, Eigen::Dynamic, 1> VectorRx;
28 typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic>
31 template <
class PyClass>
32 void visit(PyClass& cl)
const {
33 cl.def(bp::init<>(bp::arg(
"self"),
"Default constructor"))
34 .def(bp::init<MatrixType>(bp::args(
"self",
"matrix"),
35 "Constructs and performs the LDLT " 36 "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.")
46 .def(
"setInitialShift", &Solver::setInitialShift,
47 bp::args(
"self",
"shift"),
"Set the initial shift parameter.")
51 +[](Solver& self,
const MatrixType& amat) {
52 self.analyzePattern(amat);
57 +[](Solver& self,
const MatrixType& amat) { self.factorize(amat); },
61 +[](Solver& self,
const MatrixType& amat) { self.compute(amat); },
66 +[](
const Solver& self) ->
const FactorType& {
67 return self.matrixL();
69 bp::return_value_policy<bp::copy_const_reference>())
72 +[](
const Solver& self) ->
const VectorRx& {
73 return self.scalingS();
75 bp::return_value_policy<bp::copy_const_reference>())
78 +[](
const Solver& self) ->
const PermutationType& {
79 return self.permutationP();
81 bp::return_value_policy<bp::copy_const_reference>())
85 +[](
const Solver& self,
const Eigen::Ref<DenseVectorXs const>& b)
86 -> DenseVectorXs {
return self.solve(b); },
88 "Returns the solution x of A x = b using the current decomposition " 89 "of A, where b is a right hand side vector.")
92 +[](
const Solver& self,
const Eigen::Ref<DenseMatrixXs const>& B)
93 -> DenseMatrixXs {
return self.solve(B); },
95 "Returns the solution X of A X = B using the current decomposition " 96 "of A where B is a right hand side matrix.")
99 +[](
const Solver& self,
const MatrixType& B) -> MatrixType {
100 DenseMatrixXs B_dense = DenseMatrixXs(B);
101 DenseMatrixXs X_dense = self.solve(B_dense);
102 return MatrixType(X_dense.sparseView());
105 "Returns the solution X of A X = B using the current decomposition " 106 "of A where B is a right hand side matrix.");
110 static const std::string classname =
111 "IncompleteCholesky_" + scalar_name<Scalar>::shortname();
115 static void expose(
const std::string& name) {
116 bp::class_<Solver, boost::noncopyable>(name.c_str(),
"Incomplete Cholesky.",