19 :
public boost::python::def_visitor<SVDBaseVisitor<Derived>> {
20 typedef Derived Solver;
22 typedef typename Derived::MatrixType MatrixType;
23 typedef typename MatrixType::Scalar Scalar;
24 typedef typename MatrixType::RealScalar RealScalar;
26 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, MatrixType::Options>
28 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic,
32 template <
class PyClass>
33 void visit(PyClass &cl)
const {
34 cl.def(bp::init<>(bp::arg(
"self"),
"Default constructor"))
36 .def(
"computeU", &Solver::computeU, bp::arg(
"self"),
37 "Returns true if U (full or thin) is asked for in this " 39 .def(
"computeV", &Solver::computeV, bp::arg(
"self"),
40 "Returns true if V (full or thin) is asked for in this " 43 .def(
"info", &Solver::info, bp::arg(
"self"),
44 "Reports whether previous computation was successful. ")
46 .def(
"matrixU", &matrixU, bp::arg(
"self"),
"Returns the matrix U.")
47 .def(
"matrixV", &matrixV, bp::arg(
"self"),
"Returns the matrix V.")
49 .def(
"nonzeroSingularValues", &Solver::nonzeroSingularValues,
51 "Returns the number of singular values that are not exactly 0 ")
52 .def(
"rank", &Solver::rank, bp::arg(
"self"),
53 "the rank of the matrix of which *this is the SVD. ")
56 (Solver & (Solver::*)(
const RealScalar &)) & Solver::setThreshold,
57 bp::args(
"self",
"threshold"),
58 "Allows to prescribe a threshold to be used by certain methods, " 60 "rank() and solve(), which need to determine when singular values " 62 "to be considered nonzero. This is not used for the SVD " 66 "When it needs to get the threshold value, Eigen calls " 68 "The default is NumTraits<Scalar>::epsilon()",
72 +[](Solver &self) -> Solver & {
73 return self.setThreshold(Eigen::Default);
76 "Allows to come back to the default behavior, letting Eigen use " 77 "its default formula for determining the threshold.",
80 .def(
"singularValues", &Solver::singularValues, bp::arg(
"self"),
81 "Returns the vector of singular values.",
82 bp::return_value_policy<bp::copy_const_reference>())
84 .def(
"solve", &solve<VectorXs>, bp::args(
"self",
"b"),
85 "Returns the solution x of A x = b using the current " 86 "decomposition of A.")
87 .def(
"solve", &solve<MatrixXs>, bp::args(
"self",
"B"),
88 "Returns the solution X of A X = B using the current " 89 "decomposition of A where B is a right hand side matrix.")
91 .def(
"threshold", &Solver::threshold, bp::arg(
"self"),
92 "Returns the threshold that will be used by certain methods such " 97 static MatrixXs matrixU(
const Solver &self) {
return self.matrixU(); }
98 static MatrixXs matrixV(
const Solver &self) {
return self.matrixV(); }
100 template <
typename MatrixOrVector>
101 static MatrixOrVector solve(
const Solver &self,
const MatrixOrVector &vec) {
102 return self.solve(vec);