19 PartialPivLUSolverVisitor<_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::PartialPivLU<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 LU factorization from a given matrix."))
42 .def(
"determinant", &Solver::determinant, bp::arg(
"self"),
43 "Returns the determinant of the matrix of which *this is the LU " 47 (Solver & (Solver::*)(
const Eigen::EigenBase<MatrixType> &matrix)) &
49 bp::args(
"self",
"matrix"),
50 "Computes the LU factorization of given matrix.",
54 +[](
const Solver &self) -> MatrixType {
return self.inverse(); },
56 "Returns the inverse of the matrix of which *this is the LU " 58 .def(
"matrixLU", &Solver::matrixLU, bp::arg(
"self"),
59 "Returns the LU decomposition matrix.",
60 bp::return_internal_reference<>())
62 .def(
"permutationP", &Solver::permutationP, bp::arg(
"self"),
63 "Returns the permutation P.",
64 bp::return_value_policy<bp::copy_const_reference>())
66 .def(
"rcond", &Solver::rcond, bp::arg(
"self"),
67 "Returns an estimate of the reciprocal condition number of the " 69 .def(
"reconstructedMatrix", &Solver::reconstructedMatrix,
71 "Returns the matrix represented by the decomposition, i.e., it " 72 "returns the product: P-1LUQ-1. This function is provided for " 75 .def(
"solve", &solve<VectorXs>, bp::args(
"self",
"b"),
76 "Returns the solution x of A x = b using the current " 77 "decomposition of A.")
78 .def(
"solve", &solve<MatrixXs>, bp::args(
"self",
"B"),
79 "Returns the solution X of A X = B using the current " 80 "decomposition of A where B is a right hand side matrix.");
84 static const std::string classname =
85 "FullPivLU" + scalar_name<Scalar>::shortname();
89 static void expose(
const std::string &name) {
92 "LU decomposition of a matrix with partial pivoting, " 93 "and related features. \n\n" 94 "This class represents a LU decomposition of a square " 96 "with partial pivoting: the matrix A is decomposed as A " 98 "unit-lower-triangular, U is upper-triangular, and P is " 99 "a permutation matrix.\n\n" 100 "Typically, partial pivoting LU decomposition is only " 101 "considered numerically " 102 "stable for square invertible matrices. Thus LAPACK's " 103 "dgesv and dgesvx require " 104 "the matrix to be square and invertible. The present " 105 "class does the same. It " 106 "will assert that the matrix is square, but it won't " 107 "(actually it can't) check " 108 "that the matrix is invertible: it is your task to " 109 "check that you only use this " 110 "decomposition on invertible matrices. \n\n" 111 "The guaranteed safe alternative, working for all matrices, " 112 "is the full pivoting LU decomposition, provided by class " 114 "This is not a rank-revealing LU decomposition. Many features " 115 "are intentionally absent from this class, such as " 116 "rank computation. If you need these features, use class " 118 "This LU decomposition is suitable to invert invertible " 119 "matrices. It is what MatrixBase::inverse() uses in the " 120 "general case. On the other hand, it is not suitable to " 121 "determine whether a given matrix is invertible. \n\n" 122 "The data of the LU decomposition can be directly accessed " 123 "through the methods matrixLU(), permutationP().",
130 template <
typename MatrixOrVector>
131 static MatrixOrVector solve(
const Solver &self,
const MatrixOrVector &vec) {
132 return self.solve(vec);