EigenSolver.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2020 INRIA
3  */
4 
5 #ifndef __eigenpy_decompositions_eigen_solver_hpp__
6 #define __eigenpy_decompositions_eigen_solver_hpp__
7 
8 #include <Eigen/Core>
9 #include <Eigen/Eigenvalues>
10 
12 #include "eigenpy/eigenpy.hpp"
14 
15 namespace eigenpy {
16 
17 template <typename _MatrixType>
19  : public boost::python::def_visitor<EigenSolverVisitor<_MatrixType> > {
20  typedef _MatrixType MatrixType;
21  typedef typename MatrixType::Scalar Scalar;
22  typedef Eigen::EigenSolver<MatrixType> Solver;
23 
24  template <class PyClass>
25  void visit(PyClass& cl) const {
26  cl.def(bp::init<>("Default constructor"))
27  .def(bp::init<Eigen::DenseIndex>(
28  bp::arg("size"), "Default constructor with memory preallocation"))
29  .def(bp::init<MatrixType, bp::optional<bool> >(
30  bp::args("matrix", "compute_eigen_vectors"),
31  "Computes eigendecomposition of given matrix"))
32 
33  .def("eigenvalues", &Solver::eigenvalues, bp::arg("self"),
34  "Returns the eigenvalues of given matrix.",
35  bp::return_internal_reference<>())
36  .def("eigenvectors", &Solver::eigenvectors, bp::arg("self"),
37  "Returns the eigenvectors of given matrix.")
38 
39  .def("compute", &EigenSolverVisitor::compute_proxy<MatrixType>,
40  bp::args("self", "matrix"),
41  "Computes the eigendecomposition of given matrix.",
42  bp::return_self<>())
43  .def("compute",
44  (Solver &
45  (Solver::*)(const Eigen::EigenBase<MatrixType>& matrix, bool)) &
46  Solver::compute,
47  bp::args("self", "matrix", "compute_eigen_vectors"),
48  "Computes the eigendecomposition of given matrix.",
49  bp::return_self<>())
50 
51  .def("getMaxIterations", &Solver::getMaxIterations, bp::arg("self"),
52  "Returns the maximum number of iterations.")
53  .def("setMaxIterations", &Solver::setMaxIterations,
54  bp::args("self", "max_iter"),
55  "Sets the maximum number of iterations allowed.",
56  bp::return_self<>())
57 
58  .def("pseudoEigenvalueMatrix", &Solver::pseudoEigenvalueMatrix,
59  bp::arg("self"),
60  "Returns the block-diagonal matrix in the "
61  "pseudo-eigendecomposition.")
62  .def("pseudoEigenvectors", &Solver::pseudoEigenvectors, bp::arg("self"),
63  "Returns the pseudo-eigenvectors of given matrix.",
64  bp::return_internal_reference<>())
65 
66  .def("info", &Solver::info, bp::arg("self"),
67  "NumericalIssue if the input contains INF or NaN values or "
68  "overflow occured. Returns Success otherwise.");
69  }
70 
71  static void expose() {
72  static const std::string classname =
73  "EigenSolver" + scalar_name<Scalar>::shortname();
74  expose(classname);
75  }
76 
77  static void expose(const std::string& name) {
78  bp::class_<Solver>(name.c_str(), bp::no_init)
79  .def(EigenSolverVisitor())
80  .def(IdVisitor<Solver>());
81  }
82 
83  private:
84  template <typename MatrixType>
85  static Solver& compute_proxy(Solver& self,
86  const Eigen::EigenBase<MatrixType>& matrix) {
87  return self.compute(matrix);
88  }
89 };
90 
91 } // namespace eigenpy
92 
93 #endif // ifndef __eigenpy_decompositions_eigen_solver_hpp__
eigenpy::EigenSolverVisitor
Definition: EigenSolver.hpp:18
scalar-name.hpp
eigenpy::EigenSolverVisitor::Solver
Eigen::EigenSolver< MatrixType > Solver
Definition: EigenSolver.hpp:22
eigenpy::EigenSolverVisitor::MatrixType
_MatrixType MatrixType
Definition: EigenSolver.hpp:20
eigenpy
Definition: alignment.hpp:14
eigenpy::scalar_name::shortname
static std::string shortname()
eigen-to-python.hpp
eigenpy::IdVisitor
Add the Python method id to retrieving a unique id for a given object exposed with Boost....
Definition: id.hpp:18
eigenpy::EigenSolverVisitor::expose
static void expose(const std::string &name)
Definition: EigenSolver.hpp:77
eigenpy::EigenSolverVisitor::Scalar
MatrixType::Scalar Scalar
Definition: EigenSolver.hpp:21
setup.name
name
Definition: setup.in.py:179
eigenpy.hpp
eigenpy::EigenSolverVisitor::expose
static void expose()
Definition: EigenSolver.hpp:71
eigenpy::EigenSolverVisitor::compute_proxy
static Solver & compute_proxy(Solver &self, const Eigen::EigenBase< MatrixType > &matrix)
Definition: EigenSolver.hpp:85
eigenpy::EigenSolverVisitor::visit
void visit(PyClass &cl) const
Definition: EigenSolver.hpp:25


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Sat Nov 2 2024 02:14:45