bindings/python/math/lanczos-decomposition.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2024 INRIA
3 //
4 
5 #ifndef __pinocchio_python_math_lanczos_decomposition_hpp__
6 #define __pinocchio_python_math_lanczos_decomposition_hpp__
7 
10 
11 #include <eigenpy/eigenpy.hpp>
12 #include <eigenpy/memory.hpp>
13 
14 namespace pinocchio
15 {
16  namespace python
17  {
18  namespace bp = boost::python;
19 
20  template<typename LanczosDecomposition>
22  : public boost::python::def_visitor<LanczosDecompositionPythonVisitor<LanczosDecomposition>>
23  {
25  typedef typename LanczosDecomposition::TridiagonalMatrix TridiagonalMatrix;
26  typedef typename LanczosDecomposition::PlainMatrix PlainMatrix;
27 
28  public:
29  template<class PyClass>
30  void visit(PyClass & cl) const
31  {
32  // static const Scalar dummy_precision = Eigen::NumTraits<Scalar>::dummy_precision();
33 
34  cl.def(bp::init<const context::MatrixXs &, const Eigen::DenseIndex>(
35  (bp::arg("self"), bp::arg("mat"), bp::arg("decomposition_size")),
36  "Default constructor from a given matrix and a given decomposition size."))
37 
38  .def(
39  "compute", &LanczosDecomposition::template compute<context::MatrixXs>,
40  bp::args("self", "mat"),
41  "Computes the Lanczos decomposition for the given input matrix.")
42 
43  .def(
44  "Ts", (TridiagonalMatrix & (LanczosDecomposition::*)()) & LanczosDecomposition::Ts,
45  bp::arg("self"),
46  "Returns the tridiagonal matrix associated with the Lanczos decomposition.",
47  bp::return_internal_reference<>())
48  .def(
49  "Qs", (PlainMatrix & (LanczosDecomposition::*)()) & LanczosDecomposition::Qs,
50  bp::arg("self"),
51  "Returns the orthogonal basis associated with the Lanczos decomposition.",
52  bp::return_internal_reference<>())
53 
54  .def(
55  "rank", &LanczosDecomposition::rank, bp::arg("self"),
56  "Returns the rank of the decomposition.")
57 
58  .def(
59  "computeDecompositionResidual",
60  &LanczosDecomposition::template computeDecompositionResidual<context::MatrixXs>,
61  bp::args("self", "mat"),
62  "Computes the residual associated with the decomposition, namely, the quantity \f$ "
63  "A Q_s - Q_s T_s \f$")
64 
65 #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
66  .def(bp::self == bp::self)
67  .def(bp::self != bp::self)
68 #endif
69 
70  ;
71  }
72 
73  static void expose()
74  {
75 #if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 6 && EIGENPY_VERSION_AT_LEAST(2, 9, 0)
76  typedef PINOCCHIO_SHARED_PTR_HOLDER_TYPE(LanczosDecomposition) HolderType;
77 #else
78  typedef ::boost::python::detail::not_specified HolderType;
79 #endif
80  bp::class_<LanczosDecomposition, HolderType>(
81  "LanczosDecomposition", "Lanczos decomposition.", bp::no_init)
83  }
84  };
85 
86  } // namespace python
87 } // namespace pinocchio
88 
89 #endif // ifndef __pinocchio_python_math_lanczos_decomposition_hpp__
boost::python
PINOCCHIO_SHARED_PTR_HOLDER_TYPE
#define PINOCCHIO_SHARED_PTR_HOLDER_TYPE(T)
Definition: bindings/python/fwd.hpp:17
pinocchio::python::LanczosDecompositionPythonVisitor
Definition: bindings/python/math/lanczos-decomposition.hpp:21
eigenpy.hpp
pinocchio::python::LanczosDecompositionPythonVisitor::Scalar
LanczosDecomposition::Scalar Scalar
Definition: bindings/python/math/lanczos-decomposition.hpp:24
pinocchio::python::Scalar
context::Scalar Scalar
Definition: admm-solver.cpp:29
pinocchio::python::LanczosDecompositionPythonVisitor::expose
static void expose()
Definition: bindings/python/math/lanczos-decomposition.hpp:73
lanczos-decomposition.hpp
python
pinocchio::python::LanczosDecompositionPythonVisitor::PlainMatrix
LanczosDecomposition::PlainMatrix PlainMatrix
Definition: bindings/python/math/lanczos-decomposition.hpp:26
pinocchio::python::LanczosDecompositionPythonVisitor::TridiagonalMatrix
LanczosDecomposition::TridiagonalMatrix TridiagonalMatrix
Definition: bindings/python/math/lanczos-decomposition.hpp:25
pinocchio::python::LanczosDecompositionPythonVisitor::visit
void visit(PyClass &cl) const
Definition: bindings/python/math/lanczos-decomposition.hpp:30
cl
cl
memory.hpp
fwd.hpp
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:31