22 * Copyright 2024 INRIA
33 */
44
5- #ifndef __eigenpy_decompositions_sparse_ldlt_hpp__
6- #define __eigenpy_decompositions_sparse_ldlt_hpp__
5+ #ifndef __eigenpy_decompositions_sparse_incomplete_cholesky_hpp__
6+ #define __eigenpy_decompositions_sparse_incomplete_cholesky_hpp__
77
88#include " eigenpy/eigenpy.hpp"
99#include " eigenpy/utils/scalar-name.hpp"
1010
1111namespace eigenpy {
1212
1313template <typename _MatrixType>
14- struct IncompleteCholeskyVisitor
15- : public boost::python::def_visitor<
16- IncompleteCholeskyVisitor<_MatrixType>> {
17-
14+ struct IncompleteCholeskyVisitor : public boost ::python::def_visitor<
15+ IncompleteCholeskyVisitor<_MatrixType>> {
1816 typedef _MatrixType MatrixType;
1917 typedef typename MatrixType::Scalar Scalar;
2018 typedef typename MatrixType::RealScalar RealScalar;
@@ -27,82 +25,81 @@ struct IncompleteCholeskyVisitor
2725
2826 typedef Eigen::SparseMatrix<Scalar, Eigen::ColMajor> FactorType;
2927 typedef Eigen::Matrix<RealScalar, Eigen::Dynamic, 1 > VectorRx;
30- typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic> PermutationType;
28+ typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic>
29+ PermutationType;
3130
3231 template <class PyClass >
33- void visit (PyClass & cl) const {
32+ void visit (PyClass& cl) const {
3433 cl.def (bp::init<>(bp::arg (" self" ), " Default constructor" ))
3534 .def (bp::init<MatrixType>(bp::args (" self" , " matrix" ),
3635 " Constructs and performs the LDLT "
3736 " factorization from a given matrix." ))
3837
39- .def (" rows" , &Solver::rows, bp::arg (" self" ),
38+ .def (" rows" , &Solver::rows, bp::arg (" self" ),
4039 " Returns the number of rows of the matrix." )
41- .def (" cols" , &Solver::cols, bp::arg (" self" ),
40+ .def (" cols" , &Solver::cols, bp::arg (" self" ),
4241 " Returns the number of cols of the matrix." )
4342
4443 .def (" info" , &Solver::info, bp::arg (" self" ),
45- " Reports whether previous computation was successful." )
44+ " Reports whether previous computation was successful." )
4645
47- .def (" setInitialShift" , &Solver::setInitialShift,
48- bp::args (" self" , " shift" ),
49- " Set the initial shift parameter." )
46+ .def (" setInitialShift" , &Solver::setInitialShift,
47+ bp::args (" self" , " shift" ), " Set the initial shift parameter." )
5048
5149 .def (
52- " analyzePattern" ,
53- +[](Solver& self, const MatrixType& amat) {
54- self.analyzePattern (amat);
55- },
56- bp::arg (" matrix" ))
50+ " analyzePattern" ,
51+ +[](Solver& self, const MatrixType& amat) {
52+ self.analyzePattern (amat);
53+ },
54+ bp::arg (" matrix" ))
5755 .def (
58- " factorize" ,
59- +[](Solver& self, const MatrixType& amat) { self.factorize (amat); },
60- bp::arg (" matrix" ))
56+ " factorize" ,
57+ +[](Solver& self, const MatrixType& amat) { self.factorize (amat); },
58+ bp::arg (" matrix" ))
6159 .def (
62- " compute" ,
63- +[](Solver& self, const MatrixType& amat) { self.compute (amat); },
64- bp::arg (" matrix" ))
60+ " compute" ,
61+ +[](Solver& self, const MatrixType& amat) { self.compute (amat); },
62+ bp::arg (" matrix" ))
6563
6664 .def (
67- " matrixL" ,
68- +[](Solver& self) -> const FactorType& { return self.matrixL (); },
69- bp::return_value_policy<bp::copy_const_reference>())
65+ " matrixL" ,
66+ +[](Solver& self) -> const FactorType& { return self.matrixL (); },
67+ bp::return_value_policy<bp::copy_const_reference>())
7068 .def (
71- " scalingS" ,
72- +[](Solver& self) -> const VectorRx& { return self.scalingS (); },
73- bp::return_value_policy<bp::copy_const_reference>())
69+ " scalingS" ,
70+ +[](Solver& self) -> const VectorRx& { return self.scalingS (); },
71+ bp::return_value_policy<bp::copy_const_reference>())
7472 .def (
75- " permutationP" ,
76- +[](Solver& self) -> const PermutationType& {
77- return self.permutationP ();
78- },
79- bp::return_value_policy<bp::copy_const_reference>())
73+ " permutationP" ,
74+ +[](Solver& self) -> const PermutationType& {
75+ return self.permutationP ();
76+ },
77+ bp::return_value_policy<bp::copy_const_reference>())
8078
8179 .def (
82- " solve" ,
83- +[](Solver const & self, const Eigen::Ref<DenseVectorXs const >& b)
84- -> DenseVectorXs { return self.solve (b); },
85- bp::arg (" b" ),
86- " Returns the solution x of A x = b using the current decomposition "
87- " of A, where b is a right hand side vector." )
80+ " solve" ,
81+ +[](Solver const & self, const Eigen::Ref<DenseVectorXs const >& b)
82+ -> DenseVectorXs { return self.solve (b); },
83+ bp::arg (" b" ),
84+ " Returns the solution x of A x = b using the current decomposition "
85+ " of A, where b is a right hand side vector." )
8886 .def (
89- " solve" ,
90- +[](Solver const & self, const Eigen::Ref<DenseMatrixXs const >& B)
91- -> DenseMatrixXs { return self.solve (B); },
92- bp::arg (" b" ),
93- " Returns the solution X of A X = B using the current decomposition "
94- " of A where B is a right hand side matrix." )
87+ " solve" ,
88+ +[](Solver const & self, const Eigen::Ref<DenseMatrixXs const >& B)
89+ -> DenseMatrixXs { return self.solve (B); },
90+ bp::arg (" b" ),
91+ " Returns the solution X of A X = B using the current decomposition "
92+ " of A where B is a right hand side matrix." )
9593 .def (
96- " solve" ,
97- +[](Solver const & self, const MatrixType& B) -> MatrixType {
98- DenseMatrixXs B_dense = DenseMatrixXs (B);
99- DenseMatrixXs X_dense = self.solve (B_dense);
100- return MatrixType (X_dense.sparseView ());
101- },
102- bp::arg (" b" ),
103- " Returns the solution X of A X = B using the current decomposition "
104- " of A where B is a right hand side matrix." )
105- ;
94+ " solve" ,
95+ +[](Solver const & self, const MatrixType& B) -> MatrixType {
96+ DenseMatrixXs B_dense = DenseMatrixXs (B);
97+ DenseMatrixXs X_dense = self.solve (B_dense);
98+ return MatrixType (X_dense.sparseView ());
99+ },
100+ bp::arg (" b" ),
101+ " Returns the solution X of A X = B using the current decomposition "
102+ " of A where B is a right hand side matrix." );
106103 }
107104
108105 static void expose () {
@@ -111,16 +108,14 @@ struct IncompleteCholeskyVisitor
111108 expose (classname);
112109 }
113110
114- static void expose (const std::string &name) {
115- bp::class_<Solver, boost::noncopyable>(
116- name.c_str (),
117- " Incomplete Cholesky." ,
118- bp::no_init)
111+ static void expose (const std::string& name) {
112+ bp::class_<Solver, boost::noncopyable>(name.c_str (), " Incomplete Cholesky." ,
113+ bp::no_init)
119114 .def (IncompleteCholeskyVisitor ())
120115 .def (IdVisitor<Solver>());
121116 }
122117};
123118
124119} // namespace eigenpy
125120
126- #endif // ifndef __eigenpy_decompositions_sparse_ldlt_hpp__
121+ #endif // ifndef __eigenpy_decompositions_sparse_incomplete_cholesky_hpp__
0 commit comments