GCC Code Coverage Report


Directory: ./
File: bindings/python/math/expose-linalg.cpp
Date: 2025-02-12 21:03:38
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 69 void exposeLinalg()
26 {
27 using namespace Eigen;
28
29 {
30 // using the rpy scope
31
3/6
✓ Branch 2 taken 69 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 69 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 69 times.
✗ Branch 9 not taken.
138 bp::scope current_scope = getOrCreatePythonNamespace("linalg");
32
33 #ifndef PINOCCHIO_PYTHON_SKIP_CASADI_UNSUPPORTED
34
1/2
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
65 bp::def(
35 "computeLargestEigenvector",
36 (context::VectorXs(*)(
37 const context::MatrixXs &, const int,
38 const context::Scalar))&computeLargestEigenvector<context::MatrixXs>,
39
7/14
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 65 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 65 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 65 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 65 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 65 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 65 times.
✗ Branch 20 not taken.
130 (bp::arg("mat"), bp::arg("max_it") = 10, bp::arg("rel_tol") = 1e-8),
40 "Compute the lagest eigenvector of a given matrix according to a given eigenvector "
41 "estimate.");
42
43
1/2
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
65 bp::def(
44 "retrieveLargestEigenvalue", &retrieveLargestEigenvalue<context::MatrixXs>,
45
1/2
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
130 bp::arg("eigenvector"),
46 "Compute the lagest eigenvalue of a given matrix. This is taking the eigenvector "
47 "computed by the function computeLargestEigenvector.");
48 #endif // PINOCCHIO_PYTHON_SKIP_CASADI_UNSUPPORTED
49
50
1/2
✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
69 bp::def("inv", &inv<context::MatrixXs>, "Computes the inverse of a matrix.");
51 #ifdef PINOCCHIO_PYTHON_INTERFACE_MAIN_MODULE
52
1/2
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
65 bp::def(
53 "inv", &inv<Matrix<long double, Dynamic, Dynamic>>, "Computes the inverse of a matrix.");
54 #endif
55 69 }
56 69 }
57
58 } // namespace python
59 } // namespace pinocchio
60