19 :
public boost::python::def_visitor<LLTSolverVisitor<_MatrixType>> {
20 typedef _MatrixType MatrixType;
21 typedef typename MatrixType::Scalar Scalar;
22 typedef typename MatrixType::RealScalar RealScalar;
23 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, MatrixType::Options>
25 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic,
28 typedef Eigen::LLT<MatrixType> Solver;
30 template <
class PyClass>
31 void visit(PyClass &cl)
const {
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 LLT factorization from a given matrix."))
42 .def(
"matrixL", &matrixL, bp::arg(
"self"),
43 "Returns the lower triangular matrix L.")
44 .def(
"matrixU", &matrixU, bp::arg(
"self"),
45 "Returns the upper triangular matrix U.")
46 .def(
"matrixLLT", &Solver::matrixLLT, bp::arg(
"self"),
47 "Returns the LLT decomposition matrix.",
48 bp::return_internal_reference<>())
50#if EIGEN_VERSION_AT_LEAST(3, 3, 90) 52 (Solver & (Solver::*)(
const VectorXs &,
const RealScalar &)) &
53 Solver::template rankUpdate<VectorXs>,
54 bp::args(
"self",
"vector",
"sigma"), bp::return_self<>())
59 const RealScalar &))&Solver::template rankUpdate<VectorXs>,
60 bp::args(
"self",
"vector",
"sigma"))
63#if EIGEN_VERSION_AT_LEAST(3, 3, 0) 64 .def(
"adjoint", &Solver::adjoint, bp::arg(
"self"),
65 "Returns the adjoint, that is, a reference to the decomposition " 66 "itself as if the underlying matrix is self-adjoint.",
72 (Solver & (Solver::*)(
const Eigen::EigenBase<MatrixType> &matrix)) &
74 bp::args(
"self",
"matrix"),
"Computes the LLT of given matrix.",
77 .def(
"info", &Solver::info, bp::arg(
"self"),
78 "NumericalIssue if the input contains INF or NaN values or " 79 "overflow occured. Returns Success otherwise.")
80#if EIGEN_VERSION_AT_LEAST(3, 3, 0) 81 .def(
"rcond", &Solver::rcond, bp::arg(
"self"),
82 "Returns an estimate of the reciprocal condition number of the " 85 .def(
"reconstructedMatrix", &Solver::reconstructedMatrix,
87 "Returns the matrix represented by the decomposition, i.e., it " 88 "returns the product: L L^*. This function is provided for debug " 90 .def(
"solve", &solve<VectorXs>, bp::args(
"self",
"b"),
91 "Returns the solution x of A x = b using the current " 92 "decomposition of A.")
93 .def(
"solve", &solve<MatrixXs>, bp::args(
"self",
"B"),
94 "Returns the solution X of A X = B using the current " 95 "decomposition of A where B is a right hand side matrix.");
99 static const std::string classname =
100 "LLT" + scalar_name<Scalar>::shortname();
104 static void expose(
const std::string &name) {
107 "Standard Cholesky decomposition (LL^T) of a matrix and associated " 109 "This class performs a LL^T Cholesky decomposition of a symmetric, " 110 "positive definite matrix A such that A = LL^* = U^*U, where L is " 111 "lower triangular.\n\n" 112 "While the Cholesky decomposition is particularly useful to solve " 113 "selfadjoint problems like D^*D x = b, for that purpose, we recommend " 114 "the Cholesky decomposition without square root which is more stable " 115 "and even faster. Nevertheless, this standard Cholesky decomposition " 116 "remains useful in many other situations like generalised eigen " 117 "problems with hermitian matrices.",
124 static MatrixType matrixL(
const Solver &self) {
return self.matrixL(); }
125 static MatrixType matrixU(
const Solver &self) {
return self.matrixU(); }
127 template <
typename MatrixOrVector>
128 static MatrixOrVector solve(
const Solver &self,
const MatrixOrVector &vec) {
129 return self.solve(vec);