pinocchio 4.1.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
Loading...
Searching...
No Matches
lanczos-decomposition.hpp
1//
2// Copyright (c) 2024-2025 INRIA
3//
4
5#pragma once
6
7#include "pinocchio/bindings/python/fwd.hpp"
8#include "pinocchio/math.hpp"
9#include <eigenpy/copyable.hpp>
10
11#include <eigenpy/eigenpy.hpp>
12#include <eigenpy/memory.hpp>
13
14namespace 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 {
24 typedef LanczosDecomposition Self;
25 typedef typename LanczosDecomposition::Scalar Scalar;
26 typedef typename LanczosDecomposition::TridiagonalMatrix TridiagonalMatrix;
27 typedef typename LanczosDecomposition::PlainMatrix PlainMatrix;
28
29 public:
30 template<class PyClass>
31 void visit(PyClass & cl) const
32 {
33 // static const Scalar dummy_precision = Eigen::NumTraits<Scalar>::dummy_precision();
34
35 cl.def(
36 bp::init<const context::MatrixXs &, const Eigen::Index>(
37 (bp::arg("self"), bp::arg("matrix"), bp::arg("decomposition_size")),
38 "Default constructor from a given matrix and a given decomposition size."))
39
40 .def(
41 bp::init<const Eigen::Index, const Eigen::Index>(
42 (bp::arg("self"), bp::arg("size"), bp::arg("decomposition_size")),
43 "Default constructor for the Lanczos decomposition from a given matrix size."))
44
45 .def(
46 "compute", &LanczosDecomposition::template compute<context::MatrixXs>,
47 bp::args("self", "matrix"),
48 "Computes the Lanczos decomposition for the given input matrix.")
49
50 .def(
51 "Ts", (TridiagonalMatrix & (LanczosDecomposition::*)()) & LanczosDecomposition::Ts,
52 bp::arg("self"),
53 "Returns the tridiagonal matrix associated with the Lanczos decomposition.",
54 bp::return_internal_reference<>())
55 .def(
56 "Qs", (PlainMatrix & (LanczosDecomposition::*)()) & LanczosDecomposition::Qs,
57 bp::arg("self"),
58 "Returns the orthogonal basis associated with the Lanczos decomposition.",
59 bp::return_internal_reference<>())
60
61 .def(
62 "computeDecompositionResidual",
63 &LanczosDecomposition::template computeDecompositionResidual<context::MatrixXs>,
64 bp::args("self", "matrix"),
65 "Computes the residual associated with the decomposition, namely, the quantity \f$ A "
66 "Q_s - Q_s T_s \f$")
67
68 .def(
69 "size", &LanczosDecomposition::size, bp::arg("self"),
70 "Returns the size of the underlying matrix.")
71 .def(
72 "decompositionSize", &LanczosDecomposition::decompositionSize, bp::arg("self"),
73 "Returns the size of the decomposition.")
74
75#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
76 .def(bp::self == bp::self)
77 .def(bp::self != bp::self)
78#endif
79
80 .def(::eigenpy::CopyableVisitor<Self>())
81
82 ;
83 }
84
85 static void expose()
86 {
87 typedef ::boost::python::detail::not_specified HolderType;
88 bp::class_<LanczosDecomposition, HolderType>(
89 "LanczosDecomposition", "Lanczos decomposition.", bp::no_init)
91 }
92 };
93
94 } // namespace python
95} // namespace pinocchio
Main pinocchio namespace.
Definition treeview.dox:11