EigenSolver.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2020 INRIA
3  */
4 
5 #ifndef __eigenpy_decomposition_eigen_solver_hpp__
6 #define __eigenpy_decomposition_eigen_solver_hpp__
7 
8 #include "eigenpy/eigenpy.hpp"
10 
11 #include <Eigen/Core>
12 #include <Eigen/Eigenvalues>
13 
15 
16 namespace eigenpy
17 {
18 
19  template<typename _MatrixType>
21  : public boost::python::def_visitor< EigenSolverVisitor<_MatrixType> >
22  {
23 
24  typedef _MatrixType MatrixType;
25  typedef typename MatrixType::Scalar Scalar;
26  typedef Eigen::EigenSolver<MatrixType> Solver;
27 
28  template<class PyClass>
29  void visit(PyClass& cl) const
30  {
31  namespace bp = boost::python;
32  cl
33  .def(bp::init<>("Default constructor"))
34  .def(bp::init<Eigen::DenseIndex>(bp::arg("size"),
35  "Default constructor with memory preallocation"))
36  .def(bp::init<MatrixType,bp::optional<bool> >(bp::args("matrix","compute_eigen_vectors"),
37  "Computes eigendecomposition of given matrix"))
38 
39  .def("eigenvalues",&Solver::eigenvalues,bp::arg("self"),
40  "Returns the eigenvalues of given matrix.",
41  bp::return_internal_reference<>())
42  .def("eigenvectors",&Solver::eigenvectors,bp::arg("self"),
43  "Returns the eigenvectors of given matrix.")
44 
45  .def("compute",&EigenSolverVisitor::compute_proxy<MatrixType>,
46  bp::args("self","matrix"),
47  "Computes the eigendecomposition of given matrix.",
48  bp::return_self<>())
49  .def("compute",(Solver & (Solver::*)(const Eigen::EigenBase<MatrixType> & matrix, bool))&Solver::compute,
50  bp::args("self","matrix","compute_eigen_vectors"),
51  "Computes the eigendecomposition of given matrix.",
52  bp::return_self<>())
53 
54  .def("getMaxIterations",&Solver::getMaxIterations,bp::arg("self"),
55  "Returns the maximum number of iterations.")
56  .def("setMaxIterations",&Solver::setMaxIterations,bp::args("self","max_iter"),
57  "Sets the maximum number of iterations allowed.",
58  bp::return_self<>())
59 
60  .def("pseudoEigenvalueMatrix",&Solver::pseudoEigenvalueMatrix,bp::arg("self"),
61  "Returns the block-diagonal matrix in the 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 overflow occured. Returns Success otherwise.")
68  ;
69  }
70 
71  static void expose()
72  {
73  static const std::string classname = "EigenSolver" + scalar_name<Scalar>::shortname();
74  expose(classname);
75  }
76 
77  static void expose(const std::string & name)
78  {
79  namespace bp = boost::python;
80  bp::class_<Solver>(name.c_str(),
81  bp::no_init)
82  .def(EigenSolverVisitor());
83  }
84 
85  private:
86 
87  template<typename MatrixType>
88  static Solver & compute_proxy(Solver & self, const Eigen::EigenBase<MatrixType> & matrix)
89  {
90  return self.compute(matrix);
91  }
92 
93  };
94 
95 } // namespace eigenpy
96 
97 #endif // ifndef __eigenpy_decomposition_eigen_solver_hpp__
98 
boost::python::object matrix()
Definition: bnpy.cpp:20
MatrixType::Scalar Scalar
Definition: EigenSolver.hpp:25
void visit(PyClass &cl) const
Definition: EigenSolver.hpp:29
static std::string shortname()
static Solver & compute_proxy(Solver &self, const Eigen::EigenBase< MatrixType > &matrix)
Definition: EigenSolver.hpp:88
Eigen::EigenSolver< MatrixType > Solver
Definition: EigenSolver.hpp:26
static void expose(const std::string &name)
Definition: EigenSolver.hpp:77


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Sat Apr 17 2021 02:37:59