19 :
public boost::python::def_visitor<
20 SelfAdjointEigenSolverVisitor<_MatrixType>> {
21 typedef _MatrixType MatrixType;
22 typedef typename MatrixType::Scalar Scalar;
23 typedef Eigen::SelfAdjointEigenSolver<MatrixType> Solver;
24 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> VectorType;
26 template <
class PyClass>
27 void visit(PyClass& cl)
const {
28 cl.def(bp::init<>(bp::arg(
"self"),
"Default constructor"))
29 .def(bp::init<Eigen::DenseIndex>(
30 bp::args(
"self",
"size"),
31 "Default constructor with memory preallocation"))
32 .def(bp::init<MatrixType, bp::optional<int>>(
33 bp::args(
"self",
"matrix",
"options"),
34 "Computes eigendecomposition of given matrix"))
38 +[](
const Solver& c) ->
const VectorType& {
39 return c.eigenvalues();
41 "Returns the eigenvalues of given matrix.",
42 bp::return_internal_reference<>())
45 +[](
const Solver& c) ->
const MatrixType& {
46 return c.eigenvectors();
48 "Returns the eigenvectors of given matrix.",
49 bp::return_internal_reference<>())
52 &SelfAdjointEigenSolverVisitor::compute_proxy<MatrixType>,
53 bp::args(
"self",
"matrix"),
54 "Computes the eigendecomposition of given matrix.",
55 bp::return_value_policy<bp::reference_existing_object>())
57 (Solver & (Solver::*)(
const Eigen::EigenBase<MatrixType>& matrix,
60 bp::args(
"self",
"matrix",
"options"),
61 "Computes the eigendecomposition of given matrix.",
65 &SelfAdjointEigenSolverVisitor::computeDirect_proxy,
66 bp::args(
"self",
"matrix"),
67 "Computes eigendecomposition of given matrix using a closed-form " 71 (Solver & (Solver::*)(
const MatrixType& matrix,
int options)) &
72 Solver::computeDirect,
73 bp::args(
"self",
"matrix",
"options"),
74 "Computes eigendecomposition of given matrix using a closed-form " 78 .def(
"operatorInverseSqrt", &Solver::operatorInverseSqrt,
79 bp::arg(
"self"),
"Computes the inverse square root of the matrix.")
80 .def(
"operatorSqrt", &Solver::operatorSqrt, bp::arg(
"self"),
81 "Computes the inverse square root of the matrix.")
83 .def(
"info", &Solver::info, bp::arg(
"self"),
84 "NumericalIssue if the input contains INF or NaN values or " 85 "overflow occured. Returns Success otherwise.");
89 static const std::string classname =
90 "SelfAdjointEigenSolver" + scalar_name<Scalar>::shortname();
94 static void expose(
const std::string& name) {
95 bp::class_<Solver>(name.c_str(), bp::no_init)
101 template <
typename MatrixType>
102 static Solver& compute_proxy(Solver& self,
103 const Eigen::EigenBase<MatrixType>& matrix) {
104 return self.compute(matrix);
107 static Solver& computeDirect_proxy(Solver& self,
const MatrixType& matrix) {
108 return self.computeDirect(matrix);