Directory: | ./ |
---|---|
File: | include/pinocchio/math/triangular-matrix.hpp |
Date: | 2025-02-12 21:03:38 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 12 | 12 | 100.0% |
Branches: | 7 | 14 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2022-2023 INRIA | ||
3 | // | ||
4 | |||
5 | #ifndef __pinocchio_math_triangular_matrix_hpp__ | ||
6 | #define __pinocchio_math_triangular_matrix_hpp__ | ||
7 | |||
8 | #include "pinocchio/macros.hpp" | ||
9 | |||
10 | #include <Eigen/Dense> | ||
11 | |||
12 | namespace pinocchio | ||
13 | { | ||
14 | |||
15 | namespace internal | ||
16 | { | ||
17 | template< | ||
18 | Eigen::UpLoType info, | ||
19 | typename RhsMatrix, | ||
20 | typename Scalar = typename RhsMatrix::Scalar, | ||
21 | bool is_vector_at_compile_time = RhsMatrix::IsVectorAtCompileTime> | ||
22 | struct TriangularMatrixMatrixProduct | ||
23 | { | ||
24 | template<typename LhsMatrix, typename ResMat> | ||
25 | 5818 | static void run( | |
26 | const Eigen::MatrixBase<LhsMatrix> & lhs_mat, | ||
27 | const Eigen::MatrixBase<RhsMatrix> & rhs_vec, | ||
28 | const Eigen::MatrixBase<ResMat> & res) | ||
29 | { | ||
30 |
3/6✓ Branch 2 taken 2909 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2909 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2909 times.
✗ Branch 9 not taken.
|
5818 | res.const_cast_derived().col(0).noalias() = |
31 |
1/2✓ Branch 4 taken 2909 times.
✗ Branch 5 not taken.
|
5818 | lhs_mat.derived().template triangularView<info>() * rhs_vec.derived(); |
32 | 5818 | } | |
33 | }; | ||
34 | |||
35 | template<Eigen::UpLoType info, typename RhsMatrix, typename Scalar> | ||
36 | struct TriangularMatrixMatrixProduct<info, RhsMatrix, Scalar, false> | ||
37 | { | ||
38 | template<typename LhsMatrix, typename ResMat> | ||
39 | 5834 | static void run( | |
40 | const Eigen::MatrixBase<LhsMatrix> & lhs_mat, | ||
41 | const Eigen::MatrixBase<RhsMatrix> & rhs_mat, | ||
42 | const Eigen::MatrixBase<ResMat> & res) | ||
43 | { | ||
44 |
2/4✓ Branch 2 taken 2917 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2917 times.
✗ Branch 6 not taken.
|
5834 | res.const_cast_derived().noalias() = |
45 |
1/2✓ Branch 4 taken 2917 times.
✗ Branch 5 not taken.
|
5834 | lhs_mat.derived().template triangularView<info>() * rhs_mat.derived(); |
46 | 5834 | } | |
47 | }; | ||
48 | } // namespace internal | ||
49 | |||
50 | /// | ||
51 | /// \brief Evaluate the product of a triangular matrix times a matrix. Eigen showing a bug at this | ||
52 | /// level, in the case of vector entry. | ||
53 | /// | ||
54 | /// \param[in] lhs_mat Input tringular matrix | ||
55 | /// \param[in] rhs_mat Right hand side operand in the multplication | ||
56 | /// \param[in] res Resulting matrix | ||
57 | /// | ||
58 | template<Eigen::UpLoType info, typename LhsMatrix, typename RhsMatrix, typename ResMat> | ||
59 | 11652 | inline void triangularMatrixMatrixProduct( | |
60 | const Eigen::MatrixBase<LhsMatrix> & lhs_mat, | ||
61 | const Eigen::MatrixBase<RhsMatrix> & rhs_mat, | ||
62 | const Eigen::MatrixBase<ResMat> & res) | ||
63 | { | ||
64 | 11652 | internal::TriangularMatrixMatrixProduct<info, RhsMatrix>::run( | |
65 | 11652 | lhs_mat.derived(), rhs_mat.derived(), res.const_cast_derived()); | |
66 | 11652 | } | |
67 | |||
68 | } // namespace pinocchio | ||
69 | |||
70 | #endif // #ifndef __pinocchio_math_triangular_matrix_hpp__ | ||
71 |