17 :
public boost::python::def_visitor<
18 FullPivHouseholderQRSolverVisitor<_MatrixType>> {
19 typedef _MatrixType MatrixType;
20 typedef typename MatrixType::Scalar Scalar;
21 typedef typename MatrixType::RealScalar RealScalar;
22 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, MatrixType::Options>
24 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic,
27 typedef Eigen::FullPivHouseholderQR<MatrixType> Solver;
30 template <
class PyClass>
31 void visit(PyClass &cl)
const {
32 cl.def(bp::init<>(bp::arg(
"self"),
33 "Default constructor.\n" 34 "The default constructor is useful in cases in which the " 35 "user intends to perform decompositions via " 36 "HouseholderQR.compute(matrix)"))
37 .def(bp::init<Eigen::DenseIndex, Eigen::DenseIndex>(
38 bp::args(
"self",
"rows",
"cols"),
39 "Default constructor with memory preallocation.\n" 40 "Like the default constructor but with preallocation of the " 41 "internal data according to the specified problem size. "))
42 .def(bp::init<MatrixType>(
43 bp::args(
"self",
"matrix"),
44 "Constructs a QR factorization from a given matrix.\n" 45 "This constructor computes the QR factorization of the matrix " 46 "matrix by calling the method compute()."))
48 .def(
"absDeterminant", &Self::absDeterminant, bp::arg(
"self"),
49 "Returns the absolute value of the determinant of the matrix of " 50 "which *this is the QR decomposition.\n" 51 "It has only linear complexity (that is, O(n) where n is the " 52 "dimension of the square matrix) as the QR decomposition has " 53 "already been computed.\n" 54 "Note: This is only for square matrices.")
55 .def(
"logAbsDeterminant", &Self::logAbsDeterminant, bp::arg(
"self"),
56 "Returns the natural log of the absolute value of the determinant " 57 "of the matrix of which *this is the QR decomposition.\n" 58 "It has only linear complexity (that is, O(n) where n is the " 59 "dimension of the square matrix) as the QR decomposition has " 60 "already been computed.\n" 61 "Note: This is only for square matrices. This method is useful to " 62 "work around the risk of overflow/underflow that's inherent to " 63 "determinant computation.")
64 .def(
"dimensionOfKernel", &Self::dimensionOfKernel, bp::arg(
"self"),
65 "Returns the dimension of the kernel of the matrix of which *this " 66 "is the QR decomposition.")
67 .def(
"isInjective", &Self::isInjective, bp::arg(
"self"),
68 "Returns true if the matrix associated with this QR decomposition " 69 "represents an injective linear map, i.e. has trivial kernel; " 72 "Note: This method has to determine which pivots should be " 73 "considered nonzero. For that, it uses the threshold value that " 74 "you can control by calling setThreshold(threshold).")
75 .def(
"isInvertible", &Self::isInvertible, bp::arg(
"self"),
76 "Returns true if the matrix associated with the QR decomposition " 79 "Note: This method has to determine which pivots should be " 80 "considered nonzero. For that, it uses the threshold value that " 81 "you can control by calling setThreshold(threshold).")
82 .def(
"isSurjective", &Self::isSurjective, bp::arg(
"self"),
83 "Returns true if the matrix associated with this QR decomposition " 84 "represents a surjective linear map; false otherwise.\n" 86 "Note: This method has to determine which pivots should be " 87 "considered nonzero. For that, it uses the threshold value that " 88 "you can control by calling setThreshold(threshold).")
89 .def(
"maxPivot", &Self::maxPivot, bp::arg(
"self"),
90 "Returns the absolute value of the biggest pivot, i.e. the " 91 "biggest diagonal coefficient of U.")
92 .def(
"nonzeroPivots", &Self::nonzeroPivots, bp::arg(
"self"),
93 "Returns the number of nonzero pivots in the QR decomposition. " 94 "Here nonzero is meant in the exact sense, not in a fuzzy sense. " 95 "So that notion isn't really intrinsically interesting, but it is " 96 "still useful when implementing algorithms.")
97 .def(
"rank", &Self::rank, bp::arg(
"self"),
98 "Returns the rank of the matrix associated with the QR " 101 "Note: This method has to determine which pivots should be " 102 "considered nonzero. For that, it uses the threshold value that " 103 "you can control by calling setThreshold(threshold).")
106 (Self & (Self::*)(
const RealScalar &)) & Self::setThreshold,
107 bp::args(
"self",
"threshold"),
108 "Allows to prescribe a threshold to be used by certain methods, " 109 "such as rank(), who need to determine when pivots are to be " 110 "considered nonzero. This is not used for the QR decomposition " 113 "When it needs to get the threshold value, Eigen calls " 114 "threshold(). By default, this uses a formula to automatically " 115 "determine a reasonable threshold. Once you have called the " 116 "present method setThreshold(const RealScalar&), your value is " 119 "Note: A pivot will be considered nonzero if its absolute value " 120 "is strictly greater than |pivot| ⩽ threshold×|maxpivot| where " 121 "maxpivot is the biggest pivot.",
123 .def(
"threshold", &Self::threshold, bp::arg(
"self"),
124 "Returns the threshold that will be used by certain methods such " 127 .def(
"matrixQR", &Self::matrixQR, bp::arg(
"self"),
128 "Returns the matrix where the Householder QR decomposition is " 129 "stored in a LAPACK-compatible way.",
130 bp::return_value_policy<bp::copy_const_reference>())
134 (Solver & (Solver::*)(
const Eigen::EigenBase<MatrixType> &matrix)) &
136 bp::args(
"self",
"matrix"),
137 "Computes the QR factorization of given matrix.",
140 .def(
"inverse", inverse, bp::arg(
"self"),
141 "Returns the inverse of the matrix associated with the QR " 144 .def(
"solve", &solve<MatrixXs>, bp::args(
"self",
"B"),
145 "Returns the solution X of A X = B using the current " 146 "decomposition of A where B is a right hand side matrix.");
150 static const std::string classname =
151 "FullPivHouseholderQR" + scalar_name<Scalar>::shortname();
155 static void expose(
const std::string &name) {
158 "This class performs a rank-revealing QR decomposition of a matrix A " 159 "into matrices P, P', Q and R such that:\n" 161 "by using Householder transformations. Here, P and P' are permutation " 162 "matrices, Q a unitary matrix and R an upper triangular matrix.\n" 164 "This decomposition performs a very prudent full pivoting in order to " 165 "be rank-revealing and achieve optimal numerical stability. The " 166 "trade-off is that it is slower than HouseholderQR and " 167 "ColPivHouseholderQR.",
174 template <
typename MatrixOrVector>
175 static MatrixOrVector solve(
const Solver &self,
const MatrixOrVector &vec) {
176 return self.solve(vec);
178 static MatrixXs inverse(
const Self &self) {
return self.inverse(); }