LCOV - code coverage report
Current view: top level - math/linalg - matrix_row_view.hpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 24 24
Test Date: 2026-04-26 21:52:20 Functions: 89.7 % 29 26
Legend: Lines: hit not hit

            Line data    Source code
       1              : #ifndef E2428903_D53A_4EC7_89B5_8C772C073887
       2              : #define E2428903_D53A_4EC7_89B5_8C772C073887
       3              : 
       4              : #include "math/linalg/matrix_row_view.h"
       5              : 
       6              : #include "math/linalg/matrix.hpp"             // IWYU pragma: keep
       7              : #include "math/linalg/matrix_column_view.hpp" // IWYU pragma: keep
       8              : #include "math/linalg/vector.hpp"             // IWYU pragma: keep
       9              : 
      10              : 
      11              : namespace tracking
      12              : {
      13              : namespace math
      14              : {
      15              : 
      16              : template <typename ValueType_, sint32 Rows_, sint32 Cols_, bool IsRowMajor_>
      17         3700 : MatrixRowView<ValueType_, Rows_, Cols_, IsRowMajor_>::MatrixRowView(const Matrix<ValueType_, Rows_, Cols_, IsRowMajor_>& matrix,
      18              :                                                                     const sint32                                         row,
      19              :                                                                     const sint32                                         colBegin,
      20              :                                                                     const sint32                                         colEnd)
      21         3700 :     : _matrix{matrix}
      22         3700 :     , _row{row}
      23         3700 :     , _colBegin{colBegin}
      24         3700 :     , _colCount{colEnd - colBegin + 1}
      25              : {
      26         3700 :   assert(_colBegin >= 0);
      27         3700 :   assert(_colCount <= Cols_);
      28         3700 : }
      29              : 
      30              : template <typename ValueType_, sint32 Rows_, sint32 Cols_, bool IsRowMajor_>
      31        11282 : inline auto MatrixRowView<ValueType_, Rows_, Cols_, IsRowMajor_>::at_unsafe(const sint32 idx) const -> ValueType_
      32              : {
      33        11282 :   assert(idx < _colCount);
      34        11282 :   const auto col = _colBegin + idx;
      35        11282 :   return _matrix.at_unsafe(_row, col);
      36              : }
      37              : 
      38              : template <typename ValueType_, sint32 Rows_, sint32 Cols_, bool IsRowMajor_>
      39              : template <sint32 Rows2_, sint32 Cols2_, bool IsRowMajor2_>
      40            2 : inline auto MatrixRowView<ValueType_, Rows_, Cols_, IsRowMajor_>::operator*(
      41              :     const Matrix<ValueType_, Rows2_, Cols2_, IsRowMajor2_>& other) const -> Matrix<ValueType_, 1, Cols2_, IsRowMajor2_>
      42              : {
      43              :   static_assert(Rows2_ <= Cols_);
      44            2 :   assert(Rows2_ == _colCount);
      45              : 
      46            2 :   Matrix<ValueType_, 1, Cols2_, IsRowMajor2_> result{};
      47            6 :   for (auto col = 0; col < Cols2_; ++col)
      48              :   {
      49           14 :     for (auto row = 0; row < Rows2_; ++row)
      50              :     {
      51           10 :       result.at_unsafe(0, col) += at_unsafe(row) * other.at_unsafe(row, col);
      52              :     }
      53              :   }
      54            2 :   return result;
      55              : }
      56              : 
      57              : template <typename ValueType_, sint32 Rows_, sint32 Cols_, bool IsRowMajor_>
      58              : template <sint32 Rows2_, sint32 Cols2_, bool IsRowMajor2_>
      59         3698 : inline auto MatrixRowView<ValueType_, Rows_, Cols_, IsRowMajor_>::operator*(
      60              :     const MatrixColumnView<ValueType_, Rows2_, Cols2_, IsRowMajor2_>& other) const -> ValueType_
      61              : {
      62         3698 :   assert(_colCount == other.getRowCount());
      63              :   // calc dot product
      64              :   ValueType_ result{};
      65        14970 :   for (auto idx = 0; idx < _colCount; ++idx)
      66              :   {
      67        11272 :     result += at_unsafe(idx) * other.at_unsafe(idx);
      68              :   }
      69         3698 :   return result;
      70              : }
      71              : 
      72              : 
      73              : } // namespace math
      74              : } // namespace tracking
      75              : 
      76              : #endif // E2428903_D53A_4EC7_89B5_8C772C073887
        

Generated by: LCOV version 2.0-1