Directory: | ./ |
---|---|
File: | include/pinocchio/bindings/python/algorithm/delassus-operator.hpp |
Date: | 2024-08-27 18:20:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 21 | 23 | 91.3% |
Branches: | 44 | 88 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2024 INRIA | ||
3 | // | ||
4 | |||
5 | #ifndef __pinocchio_python_algorithm_delssus_operator_hpp__ | ||
6 | #define __pinocchio_python_algorithm_delssus_operator_hpp__ | ||
7 | |||
8 | #include <eigenpy/memory.hpp> | ||
9 | #include "pinocchio/algorithm/delassus-operator-base.hpp" | ||
10 | |||
11 | namespace pinocchio | ||
12 | { | ||
13 | namespace python | ||
14 | { | ||
15 | namespace bp = boost::python; | ||
16 | |||
17 | template<typename DelassusOperator> | ||
18 | struct DelassusOperatorBasePythonVisitor | ||
19 | : public boost::python::def_visitor<DelassusOperatorBasePythonVisitor<DelassusOperator>> | ||
20 | { | ||
21 | typedef DelassusOperator Self; | ||
22 | typedef typename DelassusOperator::Scalar Scalar; | ||
23 | typedef context::MatrixXs Matrix; | ||
24 | typedef typename DelassusOperator::Vector Vector; | ||
25 | |||
26 | template<class PyClass> | ||
27 | 120 | void visit(PyClass & cl) const | |
28 | { | ||
29 |
1/2✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
|
120 | cl.def(bp::self * bp::other<Matrix>()) |
30 |
2/4✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 60 times.
✗ Branch 6 not taken.
|
120 | .def( |
31 | "__matmul__", | ||
32 | ✗ | +[](const DelassusOperator & self, const Matrix & other) -> Matrix { | |
33 | ✗ | return self * other; | |
34 | }, | ||
35 | bp::args("self", "other"), | ||
36 | "Matrix multiplication between self and another matrix. Returns the result of Delassus " | ||
37 | "* matrix.") | ||
38 | |||
39 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
240 | .def( |
40 | "solve", &DelassusOperator::template solve<Matrix>, bp::args("self", "mat"), | ||
41 | "Returns the solution x of Delassus * x = mat using the current decomposition of " | ||
42 | "the Delassus matrix.") | ||
43 | |||
44 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
120 | .def( |
45 | "computeLargestEigenValue", | ||
46 | (Scalar(DelassusOperator::*)(const bool, const int, const Scalar) const) | ||
47 | & DelassusOperator::computeLargestEigenValue, | ||
48 |
7/14✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 60 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 60 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 60 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 60 times.
✗ Branch 20 not taken.
|
240 | (bp::arg("self"), bp::arg("reset") = true, bp::arg("max_it") = 10, |
49 |
3/6✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 60 times.
✗ Branch 8 not taken.
|
240 | bp::arg("prec") = Scalar(1e-8)), |
50 | "Compute the largest eigenvalue associated to the underlying Delassus matrix.") | ||
51 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
120 | .def( |
52 | "computeLowestEigenValue", | ||
53 | (Scalar(DelassusOperator::*)(const bool, const bool, const int, const Scalar) const) | ||
54 | & DelassusOperator::computeLowestEigenValue, | ||
55 |
7/14✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 60 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 60 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 60 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 60 times.
✗ Branch 20 not taken.
|
240 | (bp::arg("self"), bp::arg("reset") = true, bp::arg("compute_largest") = true, |
56 |
6/12✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 60 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 60 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 60 times.
✗ Branch 17 not taken.
|
240 | bp::arg("max_it") = 10, bp::arg("prec") = Scalar(1e-8)), |
57 | "Compute the lowest eigenvalue associated to the underlying Delassus matrix.") | ||
58 | |||
59 |
3/6✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 60 times.
✗ Branch 8 not taken.
|
240 | .def( |
60 | "updateDamping", | ||
61 | (void(DelassusOperator::*)(const Scalar &)) & DelassusOperator::updateDamping, | ||
62 | bp::args("self", "mu"), | ||
63 | "Add a damping term to the diagonal of the Delassus matrix. The damping term should " | ||
64 | "be positive.") | ||
65 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
240 | .def( |
66 | "updateDamping", &DelassusOperator::template updateDamping<Vector>, | ||
67 | bp::args("self", "mus"), | ||
68 | "Add a damping term to the diagonal of the Delassus matrix. The damping terms " | ||
69 | "should be all positive.") | ||
70 | |||
71 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
120 | .def( |
72 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
240 | "matrix", &DelassusOperator::matrix, bp::arg("self"), |
73 | "Returns the Delassus expression as a dense matrix.") | ||
74 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
120 | .def( |
75 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
240 | "inverse", &DelassusOperator::inverse, bp::arg("self"), |
76 | "Returns the inverse of the Delassus expression as a dense matrix.") | ||
77 | |||
78 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
120 | .def( |
79 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
240 | "size", &DelassusOperator::size, bp::arg("self"), |
80 | "Returns the size of the decomposition.") | ||
81 |
2/4✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
|
240 | .def("rows", &DelassusOperator::rows, bp::arg("self"), "Returns the number of rows.") |
82 |
3/6✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 60 times.
✗ Branch 8 not taken.
|
120 | .def("cols", &DelassusOperator::cols, bp::arg("self"), "Returns the number of columns."); |
83 | 120 | } | |
84 | }; | ||
85 | |||
86 | } // namespace python | ||
87 | } // namespace pinocchio | ||
88 | |||
89 | #endif // ifndef __pinocchio_python_algorithm_delssus_operator_hpp__ | ||
90 |