5 #ifndef __eigenpy_decomposition_llt_hpp__ 6 #define __eigenpy_decomposition_llt_hpp__ 8 #include <Eigen/Cholesky> 16 template <
typename _MatrixType>
18 :
public boost::python::def_visitor<LLTSolverVisitor<_MatrixType> > {
20 typedef typename MatrixType::Scalar
Scalar;
22 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, MatrixType::Options>
24 typedef Eigen::Matrix<
Scalar, Eigen::Dynamic, Eigen::Dynamic,
27 typedef Eigen::LLT<MatrixType>
Solver;
29 template <
class PyClass>
31 cl.def(bp::init<>(bp::arg(
"self"),
"Default constructor"))
32 .def(bp::init<Eigen::DenseIndex>(
33 bp::args(
"self",
"size"),
34 "Default constructor with memory preallocation"))
35 .def(bp::init<MatrixType>(
36 bp::args(
"self",
"matrix"),
37 "Constructs a LLT factorization from a given matrix."))
39 .def(
"matrixL", &
matrixL, bp::arg(
"self"),
40 "Returns the lower triangular matrix L.")
41 .def(
"matrixU", &
matrixU, bp::arg(
"self"),
42 "Returns the upper triangular matrix U.")
43 .def(
"matrixLLT", &Solver::matrixLLT, bp::arg(
"self"),
44 "Returns the LLT decomposition matrix.",
45 bp::return_internal_reference<>())
47 #if EIGEN_VERSION_AT_LEAST(3, 3, 90) 49 (Solver & (Solver::*)(
const VectorXs &,
const RealScalar &)) &
50 Solver::template rankUpdate<VectorXs>,
51 bp::args(
"self",
"vector",
"sigma"), bp::return_self<>())
55 Solver::template rankUpdate<VectorXs>,
56 bp::args(
"self",
"vector",
"sigma"))
59 #if EIGEN_VERSION_AT_LEAST(3, 3, 0) 60 .def(
"adjoint", &Solver::adjoint, bp::arg(
"self"),
61 "Returns the adjoint, that is, a reference to the decomposition " 62 "itself as if the underlying matrix is self-adjoint.",
68 (Solver & (Solver::*)(
const Eigen::EigenBase<MatrixType> &matrix)) &
70 bp::args(
"self",
"matrix"),
"Computes the LLT of given matrix.",
73 .def(
"info", &Solver::info, bp::arg(
"self"),
74 "NumericalIssue if the input contains INF or NaN values or " 75 "overflow occured. Returns Success otherwise.")
76 #if EIGEN_VERSION_AT_LEAST(3, 3, 0) 77 .def(
"rcond", &Solver::rcond, bp::arg(
"self"),
78 "Returns an estimate of the reciprocal condition number of the " 81 .def(
"reconstructedMatrix", &Solver::reconstructedMatrix,
83 "Returns the matrix represented by the decomposition, i.e., it " 84 "returns the product: L L^*. This function is provided for debug " 86 .def(
"solve", &solve<VectorXs>, bp::args(
"self",
"b"),
87 "Returns the solution x of A x = b using the current " 88 "decomposition of A.")
89 .def(
"solve", &solve<MatrixXs>, bp::args(
"self",
"B"),
90 "Returns the solution X of A X = B using the current " 91 "decomposition of A where B is a right hand side matrix.");
95 static const std::string classname =
103 "Standard Cholesky decomposition (LL^T) of a matrix and associated " 105 "This class performs a LL^T Cholesky decomposition of a symmetric, " 106 "positive definite matrix A such that A = LL^* = U^*U, where L is " 107 "lower triangular.\n\n" 108 "While the Cholesky decomposition is particularly useful to solve " 109 "selfadjoint problems like D^*D x = b, for that purpose, we recommend " 110 "the Cholesky decomposition without square root which is more stable " 111 "and even faster. Nevertheless, this standard Cholesky decomposition " 112 "remains useful in many other situations like generalised eigen " 113 "problems with hermitian matrices.",
119 static MatrixType
matrixL(
const Solver &
self) {
return self.matrixL(); }
120 static MatrixType
matrixU(
const Solver &
self) {
return self.matrixU(); }
122 template <
typename MatrixOrVector>
123 static MatrixOrVector
solve(
const Solver &
self,
const MatrixOrVector &
vec) {
124 return self.solve(vec);
130 #endif // ifndef __eigenpy_decomposition_llt_hpp__ void visit(PyClass &cl) const
static void expose(const std::string &name)
static MatrixOrVector solve(const Solver &self, const MatrixOrVector &vec)
MatrixType::RealScalar RealScalar
static std::string shortname()
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic, MatrixType::Options > MatrixXs
Eigen::LLT< MatrixType > Solver
static MatrixType matrixL(const Solver &self)
static MatrixType matrixU(const Solver &self)
Eigen::Matrix< Scalar, Eigen::Dynamic, 1, MatrixType::Options > VectorXs
MatrixType::Scalar Scalar