GCC Code Coverage Report


Directory: ./
File: include/pinocchio/bindings/python/utils/eigen.hpp
Date: 2024-08-27 18:20:05
Exec Total Coverage
Lines: 7 10 70.0%
Branches: 4 16 25.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2020-2021 INRIA
3 //
4
5 #ifndef __pinocchio_python_utils_eigen_hpp__
6 #define __pinocchio_python_utils_eigen_hpp__
7
8 #include "pinocchio/bindings/python/fwd.hpp"
9 #include <eigenpy/eigen-to-python.hpp>
10
11 namespace pinocchio
12 {
13 namespace python
14 {
15
16 template<typename Matrix>
17 6 Eigen::Ref<Matrix> make_ref(const Eigen::PlainObjectBase<Matrix> & mat)
18 {
19 typedef Eigen::Ref<Matrix> ReturnType;
20 6 return ReturnType(mat.const_cast_derived());
21 }
22
23 template<typename Matrix>
24 2 void make_symmetric(const Eigen::MatrixBase<Matrix> & mat, const int mode = Eigen::Upper)
25 {
26
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (mode == Eigen::Upper)
27 {
28
2/4
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
2 mat.const_cast_derived().template triangularView<Eigen::StrictlyLower>() =
29
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
4 mat.transpose().template triangularView<Eigen::StrictlyLower>();
30 }
31 else if (mode == Eigen::Lower)
32 {
33 mat.const_cast_derived().template triangularView<Eigen::StrictlyUpper>() =
34 mat.transpose().template triangularView<Eigen::StrictlyUpper>();
35 }
36 2 }
37
38 template<typename Matrix>
39 typename PINOCCHIO_EIGEN_PLAIN_TYPE(Matrix) make_copy(const Eigen::MatrixBase<Matrix> & mat)
40 {
41 typedef typename PINOCCHIO_EIGEN_PLAIN_TYPE(Matrix) ReturnType;
42 return ReturnType(mat);
43 }
44
45 } // namespace python
46 } // namespace pinocchio
47
48 #endif // ifndef __pinocchio_python_utils_eigen_hpp__
49