eigenpy 3.12.0
Bindings between Numpy and Eigen using Boost.Python
Loading...
Searching...
No Matches
ComplexSchur.hpp
1/*
2 * Copyright 2025 INRIA
3 */
4
5#ifndef __eigenpy_decompositions_complex_schur_hpp__
6#define __eigenpy_decompositions_complex_schur_hpp__
7
8#include <Eigen/Core>
9#include <Eigen/Eigenvalues>
10
11#include "eigenpy/eigen-to-python.hpp"
12#include "eigenpy/eigenpy.hpp"
13#include "eigenpy/utils/scalar-name.hpp"
14
15namespace eigenpy {
16
17template <typename _MatrixType>
19 : public boost::python::def_visitor<ComplexSchurVisitor<_MatrixType>> {
20 typedef _MatrixType MatrixType;
21 typedef typename MatrixType::Scalar Scalar;
22 typedef Eigen::ComplexSchur<MatrixType> Solver;
23
24 template <class PyClass>
25 void visit(PyClass& cl) const {
26 cl.def(bp::init<Eigen::DenseIndex>(bp::arg("size"), "Default constructor"))
27 .def(bp::init<MatrixType, bp::optional<bool>>(
28 bp::args("matrix", "computeU"), "Computes Schur of given matrix"))
29
30 .def("matrixU", &Solver::matrixU, bp::arg("self"),
31 "Returns the unitary matrix in the Schur decomposition. ",
32 bp::return_value_policy<bp::copy_const_reference>())
33 .def("matrixT", &Solver::matrixT, bp::arg("self"),
34 "Returns the triangular matrix in the Schur decomposition. ",
35 bp::return_value_policy<bp::copy_const_reference>())
36
37 .def("compute", &ComplexSchurVisitor::compute_proxy<MatrixType>,
38 bp::args("self", "matrix"), "Computes the Schur of given matrix.",
39 bp::return_self<>())
40 .def("compute",
41 (Solver &
42 (Solver::*)(const Eigen::EigenBase<MatrixType>& matrix, bool)) &
43 Solver::compute,
44 bp::args("self", "matrix", "computeU"),
45 "Computes the Schur of given matrix.", bp::return_self<>())
46
47 .def("computeFromHessenberg",
48 (Solver & (Solver::*)(const Eigen::EigenBase<MatrixType>& matrixH,
49 const Eigen::EigenBase<MatrixType>& matrixQ,
50 bool)) &
51 Solver::computeFromHessenberg,
52 bp::args("self", "matrixH", "matrixQ", "computeU"),
53 "Compute Schur decomposition from a given Hessenberg matrix. ",
54 bp::return_self<>())
55
56 .def("info", &Solver::info, bp::arg("self"),
57 "NumericalIssue if the input contains INF or NaN values or "
58 "overflow occured. Returns Success otherwise.")
59
60 .def("getMaxIterations", &Solver::getMaxIterations, bp::arg("self"),
61 "Returns the maximum number of iterations.")
62 .def("setMaxIterations", &Solver::setMaxIterations,
63 bp::args("self", "max_iter"),
64 "Sets the maximum number of iterations allowed.",
65 bp::return_self<>());
66 }
67
68 static void expose() {
69 static const std::string classname =
70 "ComplexSchur" + scalar_name<Scalar>::shortname();
71 expose(classname);
72 }
73
74 static void expose(const std::string& name) {
75 bp::class_<Solver>(name.c_str(), bp::no_init)
77 .def(IdVisitor<Solver>());
78 }
79
80 private:
81 template <typename MatrixType>
82 static Solver& compute_proxy(Solver& self,
83 const Eigen::EigenBase<MatrixType>& matrix) {
84 return self.compute(matrix);
85 }
86};
87
88} // namespace eigenpy
89
90#endif // ifndef __eigenpy_decompositions_complex_schur_hpp__
void expose()
Call the expose function of a given type T.
Definition expose.hpp:23
Add the Python method id to retrieving a unique id for a given object exposed with Boost....
Definition id.hpp:18