Line data Source code
1 : #ifndef D350299D_28E6_4635_9D1B_F2C6D569A1C3
2 : #define D350299D_28E6_4635_9D1B_F2C6D569A1C3
3 :
4 : #include "conversions.h"
5 : #include "math/linalg/matrix_column_view.hpp" // IWYU pragma: keep
6 : #include "math/linalg/vector.hpp" // IWYU pragma: keep
7 :
8 : namespace tracking
9 : {
10 : namespace math
11 : {
12 : namespace conversions
13 : {
14 :
15 : /// \brief Creates a Vector from a MatrixColumnView
16 : ///
17 : /// This function extracts the elements from a matrix column view to create a vector.
18 : /// The column view must have the correct dimensions.
19 : ///
20 : /// \tparam ValueType_ The atomic data type of internal elements
21 : /// \tparam Size_ The size of the resulting vector
22 : /// \param[in] colView The source matrix column view
23 : /// \return Vector containing the elements from the column view
24 : /// \note The column view row count must equal Size_, otherwise assertion fails
25 : /// \see VectorFromList() for creating from initializer lists
26 : /// \see MatrixFromVector() for the reverse conversion
27 : template <typename ValueType_, sint32 Size_>
28 1 : inline auto VectorFromMatrixColumnView(const MatrixColumnView<ValueType_, Size_, 1, true>& colView) -> Vector<ValueType_, Size_>
29 : {
30 1 : assert(colView.getRowCount() == Size_);
31 1 : Vector<ValueType_, Size_> result;
32 4 : for (sint32 i = 0; i < Size_; ++i)
33 : {
34 3 : result.at_unsafe(i) = colView.at_unsafe(i);
35 : }
36 1 : return result;
37 : }
38 :
39 : } // namespace conversions
40 : } // namespace math
41 : } // namespace tracking
42 :
43 : #endif // D350299D_28E6_4635_9D1B_F2C6D569A1C3
|