Directory: | ./ |
---|---|
File: | bindings/python/math/expose-linalg.cpp |
Date: | 2024-08-27 18:20:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 10 | 14 | 71.4% |
Branches: | 15 | 34 | 44.1% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2021 INRIA | ||
3 | // | ||
4 | |||
5 | #include "pinocchio/bindings/python/fwd.hpp" | ||
6 | #include "pinocchio/bindings/python/utils/namespace.hpp" | ||
7 | |||
8 | #include "pinocchio/math/matrix.hpp" | ||
9 | #include "pinocchio/math/eigenvalues.hpp" | ||
10 | |||
11 | namespace pinocchio | ||
12 | { | ||
13 | namespace python | ||
14 | { | ||
15 | namespace bp = boost::python; | ||
16 | |||
17 | template<typename MatrixType> | ||
18 | ✗ | typename PINOCCHIO_EIGEN_PLAIN_TYPE(MatrixType) inv(const Eigen::MatrixBase<MatrixType> & mat) | |
19 | { | ||
20 | ✗ | typename PINOCCHIO_EIGEN_PLAIN_TYPE(MatrixType) res(mat.rows(), mat.cols()); | |
21 | ✗ | inverse(mat, res); | |
22 | ✗ | return res; | |
23 | } | ||
24 | |||
25 | 20 | void exposeLinalg() | |
26 | { | ||
27 | using namespace Eigen; | ||
28 | |||
29 | { | ||
30 | // using the rpy scope | ||
31 |
3/6✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
|
40 | bp::scope current_scope = getOrCreatePythonNamespace("linalg"); |
32 | |||
33 | #ifndef PINOCCHIO_PYTHON_SKIP_CASADI_UNSUPPORTED | ||
34 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | bp::def( |
35 | "computeLargestEigenvector", | ||
36 | (context::VectorXs(*)(const context::MatrixXs &, const int, const context::Scalar)) | ||
37 | & computeLargestEigenvector<context::MatrixXs>, | ||
38 |
7/14✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 20 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 20 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 20 times.
✗ Branch 20 not taken.
|
40 | (bp::arg("mat"), bp::arg("max_it") = 10, bp::arg("rel_tol") = 1e-8), |
39 | "Compute the lagest eigenvector of a given matrix according to a given eigenvector " | ||
40 | "estimate."); | ||
41 | |||
42 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | bp::def( |
43 | "retrieveLargestEigenvalue", &retrieveLargestEigenvalue<context::MatrixXs>, | ||
44 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
40 | bp::arg("eigenvector"), |
45 | "Compute the lagest eigenvalue of a given matrix. This is taking the eigenvector " | ||
46 | "computed by the function computeLargestEigenvector."); | ||
47 | #endif // PINOCCHIO_PYTHON_SKIP_CASADI_UNSUPPORTED | ||
48 | |||
49 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | bp::def("inv", &inv<context::MatrixXs>, "Computes the inverse of a matrix."); |
50 | #ifdef PINOCCHIO_PYTHON_INTERFACE_MAIN_MODULE | ||
51 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | bp::def( |
52 | "inv", &inv<Matrix<long double, Dynamic, Dynamic>>, "Computes the inverse of a matrix."); | ||
53 | #endif | ||
54 | 20 | } | |
55 | 20 | } | |
56 | |||
57 | } // namespace python | ||
58 | } // namespace pinocchio | ||
59 |