5 #ifndef __eigenpy_decompositions_ldlt_hpp__
6 #define __eigenpy_decompositions_ldlt_hpp__
8 #include <Eigen/Cholesky>
17 template <
typename _MatrixType>
19 :
public boost::python::def_visitor<LDLTSolverVisitor<_MatrixType> > {
21 typedef typename MatrixType::Scalar
Scalar;
23 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, MatrixType::Options>
25 typedef Eigen::Matrix<
Scalar, Eigen::Dynamic, Eigen::Dynamic,
28 typedef Eigen::LDLT<MatrixType>
Solver;
30 template <
class PyClass>
32 cl.def(bp::init<>(bp::arg(
"self"),
"Default constructor"))
33 .def(bp::init<Eigen::DenseIndex>(
34 bp::args(
"self",
"size"),
35 "Default constructor with memory preallocation"))
36 .def(bp::init<MatrixType>(
37 bp::args(
"self",
"matrix"),
38 "Constructs a LDLT factorization from a given matrix."))
42 .def(
"isNegative", &Solver::isNegative, bp::arg(
"self"),
43 "Returns true if the matrix is negative (semidefinite).")
44 .def(
"isPositive", &Solver::isPositive, bp::arg(
"self"),
45 "Returns true if the matrix is positive (semidefinite).")
47 .def(
"matrixL", &
matrixL, bp::arg(
"self"),
48 "Returns the lower triangular matrix L.")
49 .def(
"matrixU", &
matrixU, bp::arg(
"self"),
50 "Returns the upper triangular matrix U.")
51 .def(
"vectorD", &
vectorD, bp::arg(
"self"),
52 "Returns the coefficients of the diagonal matrix D.")
54 "Returns the permutation matrix P.")
56 .def(
"matrixLDLT", &Solver::matrixLDLT, bp::arg(
"self"),
57 "Returns the LDLT decomposition matrix.",
58 bp::return_internal_reference<>())
61 (
Solver & (
Solver::*)(
const Eigen::MatrixBase<VectorXs> &,
63 Solver::template rankUpdate<VectorXs>,
64 bp::args(
"self",
"vector",
"sigma"), bp::return_self<>())
66 #if EIGEN_VERSION_AT_LEAST(3, 3, 0)
67 .def(
"adjoint", &Solver::adjoint, bp::arg(
"self"),
68 "Returns the adjoint, that is, a reference to the decomposition "
69 "itself as if the underlying matrix is self-adjoint.",
75 (
Solver & (
Solver::*)(
const Eigen::EigenBase<MatrixType> &matrix)) &
77 bp::args(
"self",
"matrix"),
"Computes the LDLT of given matrix.",
80 .def(
"info", &Solver::info, bp::arg(
"self"),
81 "NumericalIssue if the input contains INF or NaN values or "
82 "overflow occured. Returns Success otherwise.")
83 #if EIGEN_VERSION_AT_LEAST(3, 3, 0)
84 .def(
"rcond", &Solver::rcond, bp::arg(
"self"),
85 "Returns an estimate of the reciprocal condition number of the "
88 .def(
"reconstructedMatrix", &Solver::reconstructedMatrix,
90 "Returns the matrix represented by the decomposition, i.e., it "
91 "returns the product: L L^*. This function is provided for debug "
93 .def(
"solve", &solve<VectorXs>, bp::args(
"self",
"b"),
94 "Returns the solution x of A x = b using the current "
95 "decomposition of A.")
96 .def(
"solve", &solve<MatrixXs>, bp::args(
"self",
"B"),
97 "Returns the solution X of A X = B using the current "
98 "decomposition of A where B is a right hand side matrix.")
101 "Clear any existing decomposition.");
105 static const std::string classname =
113 "Robust Cholesky decomposition of a matrix with pivoting.\n\n"
114 "Perform a robust Cholesky decomposition of a positive semidefinite or "
115 "negative semidefinite matrix $ A $ such that $ A = P^TLDL^*P $, where "
116 "P is a permutation matrix, L is lower triangular with a unit diagonal "
117 "and D is a diagonal matrix.\n\n"
118 "The decomposition uses pivoting to ensure stability, so that L will "
119 "have zeros in the bottom right rank(A) - n submatrix. Avoiding the "
120 "square root on D also stabilizes the computation.",
132 return self.transpositionsP() *
136 template <
typename MatrixOrVector>
138 return self.solve(
vec);
144 #endif // ifndef __eigenpy_decompositions_ldlt_hpp__