diff --git a/common/include/algebra/type_traits.hpp b/common/include/algebra/type_traits.hpp index 53adf683..7cdda65d 100644 --- a/common/include/algebra/type_traits.hpp +++ b/common/include/algebra/type_traits.hpp @@ -121,6 +121,101 @@ template using block_getter_t = typename block_getter::type; /// @} -/// @} - } // namespace algebra::trait + +/// Default type trait specializations +/// @{ +#define ALGEBRA_PLUGINS_DEFINE_TYPE_TRAITS(A) \ + \ + namespace trait { \ + \ + template \ + struct index> { \ + using type = algebra::A::size_type; \ + }; \ + \ + template \ + struct index> { \ + using type = algebra::A::size_type; \ + }; \ + \ + template \ + struct dimensions> { \ + \ + using size_type = index_t>; \ + \ + static constexpr size_type dim{1}; \ + static constexpr size_type rows{N}; \ + static constexpr size_type columns{1}; \ + }; \ + \ + template \ + struct dimensions> { \ + \ + using size_type = index_t>; \ + \ + static constexpr size_type dim{2}; \ + static constexpr size_type rows{ROWS}; \ + static constexpr size_type columns{COLS}; \ + }; \ + \ + template \ + struct value> { \ + using type = T; \ + }; \ + \ + template \ + struct value> { \ + using type = T; \ + }; \ + \ + template \ + struct vector> { \ + \ + template \ + using other_type = A::vector_type; \ + \ + using type = other_type; \ + }; \ + \ + template \ + struct vector> { \ + \ + template \ + using other_type = A::vector_type; \ + \ + using type = other_type; \ + }; \ + \ + template \ + struct matrix> { \ + template \ + using other_type = A::matrix_type; \ + \ + using type = A::matrix_type; \ + }; \ + \ + template \ + struct matrix> { \ + template \ + using other_type = A::matrix_type; \ + \ + using type = other_type; \ + }; \ + \ + template \ + struct element_getter> { \ + using type = A::element_getter; \ + }; \ + \ + template \ + struct element_getter> { \ + using type = A::element_getter; \ + }; \ + \ + template \ + struct block_getter> { \ + using type = A::block_getter; \ + }; \ + \ + } // namespace algebra::trait diff --git a/storage/array/include/algebra/storage/array.hpp b/storage/array/include/algebra/storage/array.hpp index 49226ecf..ed79c674 100644 --- a/storage/array/include/algebra/storage/array.hpp +++ b/storage/array/include/algebra/storage/array.hpp @@ -44,120 +44,13 @@ using vector2 = storage_type; template using point2 = vector2; -} // namespace array - -namespace trait { - -/// Type trait specializations -/// @{ - -/// Index -/// @{ -template -struct index> { - using type = algebra::array::size_type; -}; - -template -struct index, COLS>> { - using type = algebra::array::size_type; -}; -/// @} - -/// Dimension -/// @{ -template -struct dimensions> { - - using size_type = index_t>; - - static constexpr size_type dim{1}; - static constexpr size_type rows{N}; - static constexpr size_type columns{1}; -}; - -template -struct dimensions, COLS>> { - - using size_type = index_t, COLS>>; - - static constexpr size_type dim{2}; - static constexpr size_type rows{ROWS}; - static constexpr size_type columns{COLS}; -}; -/// @} - -/// Value -/// @{ -template -struct value> { - using type = T; -}; - -template -struct value, COLS>> { - using type = T; -}; -/// @} +/// Element Getter +using element_getter = cmath::storage::element_getter; +/// Block Getter +using block_getter = cmath::storage::block_getter; -/// Vector -/// @{ -template -struct vector> { - - template - using other_type = std::array; - - using type = other_type; -}; - -template -struct vector, COLS>> { - - template - using other_type = std::array; - - using type = other_type; -}; -/// @} - -/// Matrix -/// @{ -template -struct matrix, COLS>> { - template - using other_type = std::array, other_COLS>; - - using type = std::array, COLS>; -}; - -template -struct matrix> { - template - using other_type = std::array, other_COLS>; - - using type = other_type; -}; -/// @} - -/// Elemet/Block Getter -/// @{ -template -struct element_getter> { - using type = cmath::storage::element_getter; -}; - -template -struct element_getter, COLS>> { - using type = cmath::storage::element_getter; -}; - -template -struct block_getter, COLS>> { - using type = cmath::storage::block_getter; -}; -/// @} +} // namespace array -} // namespace trait +ALGEBRA_PLUGINS_DEFINE_TYPE_TRAITS(array) } // namespace algebra diff --git a/storage/eigen/include/algebra/storage/eigen.hpp b/storage/eigen/include/algebra/storage/eigen.hpp index cb193743..cced2081 100644 --- a/storage/eigen/include/algebra/storage/eigen.hpp +++ b/storage/eigen/include/algebra/storage/eigen.hpp @@ -32,62 +32,46 @@ using vector_type = storage_type; template using matrix_type = Eigen::Matrix; -/// 3-element "vector" type, using @c algebra::eigen::array +/// 3-element "vector" type, using @c eigen::vector_type template using vector3 = storage_type; -/// Point in 3D space, using @c algebra::eigen::array +/// Point in 3D space, using @c eigen::vector_type template using point3 = vector3; -/// 2-element "vector" type, using @c algebra::eigen::array +/// 2-element "vector" type, using @c eigen::vector_type template using vector2 = storage_type; -/// Point in 2D space, using @c algebra::eigen::array +/// Point in 2D space, using @c eigen::vector_type template using point2 = vector2; +/// Element Getter +using element_getter = eigen::storage::element_getter; +/// Block Getter +using block_getter = eigen::storage::block_getter; + } // namespace eigen -namespace trait { +ALGEBRA_PLUGINS_DEFINE_TYPE_TRAITS(eigen) -/// Type trait specializations -/// @{ +// Extra specializations needed for some additional eigen types +namespace trait { /// Index /// @{ -template -struct index> { - using type = algebra::eigen::size_type; -}; - template struct index> { using type = algebra::eigen::size_type; }; -template -struct index> { - using type = algebra::eigen::size_type; -}; - template -struct index, bROWS, - bCOLS, false>> { +struct index, bROWS, bCOLS, false>> { using type = algebra::eigen::size_type; }; /// @} /// Dimensions /// @{ -template -struct dimensions> { - - using size_type = index_t>; - - static constexpr size_type dim{1}; - static constexpr size_type rows{N}; - static constexpr size_type columns{1}; -}; - template struct dimensions> { @@ -100,16 +84,6 @@ struct dimensions> { Eigen::MatrixBase::ColsAtCompileTime}; }; -template -struct dimensions> { - - using size_type = index_t>; - - static constexpr size_type dim{2}; - static constexpr size_type rows{ROWS}; - static constexpr size_type columns{COLS}; -}; - template struct dimensions, bROWS, bCOLS, false>> { @@ -126,21 +100,11 @@ struct dimensions, /// Value /// @{ -template -struct value> { - using type = T; -}; - template struct value> { using type = typename Eigen::MatrixBase::value_type; }; -template -struct value> { - using type = T; -}; - template struct value, bROWS, bCOLS, false>> { @@ -150,33 +114,15 @@ struct value, bROWS, /// Vector /// @{ -template -struct vector> { - - template - using other_type = algebra::eigen::array; - - using type = other_type; -}; - template struct vector> { template - using other_type = algebra::eigen::array; + using other_type = eigen::vector_type; using type = other_type>, rows>>; }; - -template -struct vector> { - - template - using other_type = algebra::eigen::array; - - using type = other_type; -}; /// @} /// Matrix @@ -192,22 +138,6 @@ struct matrix> { using type = Eigen::MatrixBase; }; -template -struct matrix> { - template - using other_type = eigen::matrix_type; - - using type = Eigen::Matrix; -}; - -template -struct matrix> { - template - using other_type = eigen::matrix_type; - - using type = other_type; -}; - template struct matrix, bROWS, bCOLS, false>> { @@ -221,21 +151,11 @@ struct matrix, bROWS, /// Element getter /// @{ -template -struct element_getter> { - using type = eigen::storage::element_getter; -}; - template struct element_getter> { using type = eigen::storage::element_getter; }; -template -struct element_getter> { - using type = eigen::storage::element_getter; -}; - template struct element_getter, bROWS, bCOLS, false>> { @@ -249,12 +169,6 @@ template struct block_getter> { using type = eigen::storage::block_getter; }; - -template -struct block_getter> { - using type = eigen::storage::block_getter; -}; -/// @} /// @} } // namespace trait diff --git a/storage/fastor/include/algebra/storage/fastor.hpp b/storage/fastor/include/algebra/storage/fastor.hpp index c58271f9..8b2ccb98 100644 --- a/storage/fastor/include/algebra/storage/fastor.hpp +++ b/storage/fastor/include/algebra/storage/fastor.hpp @@ -24,6 +24,9 @@ using size_type = std::size_t; /// Array type used in the Fastor storage model template using storage_type = Fastor::Tensor; +/// Vector type used in the Fastor storage model +template +using vector_type = storage_type; /// Matrix type used in the Fastor storage model template using matrix_type = algebra::fastor::Matrix; @@ -41,172 +44,13 @@ using vector2 = storage_type; template using point2 = vector2; -} // namespace fastor - -namespace trait { - -/// Type trait specializations -/// @{ - -/// Index -/// @{ -template -struct index> { - using type = std::size_t; -}; - -template -struct index> { - using type = std::size_t; -}; - -template -struct index> { - using type = std::size_t; -}; -/// @} - -/// Dimension -/// @{ -template -struct dimensions> { - - using size_type = std::size_t; - - static constexpr size_type dim{2}; - static constexpr size_type rows{ROWS}; - static constexpr size_type columns{COLS}; -}; - -template -struct dimensions> { - - using size_type = std::size_t; - - static constexpr size_type dim{2}; - static constexpr size_type rows{ROWS}; - static constexpr size_type columns{COLS}; -}; - -template -struct dimensions> { - - using size_type = std::size_t; - - static constexpr size_type dim{1}; - static constexpr size_type rows{N}; - static constexpr size_type columns{1}; -}; -/// @} - -/// Value -/// @{ -template -struct value> { - using type = T; -}; - -template -struct value> { - using type = T; -}; - -template -struct value> { - using type = T; -}; -/// @} - -/// Vector -/// @{ -template -struct vector> { +/// Element Getter +using element_getter = fastor::storage::element_getter; +/// Block Getter +using block_getter = fastor::storage::block_getter; - template - using other_type = Fastor::Tensor; - - using type = other_type; -}; - -template -struct vector> { - - template - using other_type = Fastor::Tensor; - - using type = Fastor::Tensor; -}; - -template -struct vector> { - - template - using other_type = Fastor::Tensor; - - using type = Fastor::Tensor; -}; -/// @} - -/// Matrix -/// @{ -template -struct matrix> { - template - using other_type = Fastor::Tensor; - - using type = Fastor::Tensor; -}; - -template -struct matrix> { - template - using other_type = algebra::fastor::Matrix; - - using type = algebra::fastor::Matrix; -}; - -template -struct matrix> { - template - using other_type = algebra::fastor::Matrix; - - using type = other_type; -}; -/// @} - -/// Element/Block Getter -/// @{ -template -struct element_getter> { - using type = fastor::storage::element_getter; -}; - -template -struct element_getter> { - using type = fastor::storage::element_getter; -}; - -template -struct element_getter> { - using type = fastor::storage::element_getter; -}; - -template -struct block_getter> { - using type = fastor::storage::block_getter; -}; - -template -struct block_getter> { - using type = fastor::storage::block_getter; -}; - -template -struct block_getter> { - using type = fastor::storage::block_getter; -}; -/// @} +} // namespace fastor -} // namespace trait +ALGEBRA_PLUGINS_DEFINE_TYPE_TRAITS(fastor) } // namespace algebra diff --git a/storage/smatrix/include/algebra/storage/impl/smatrix_getter.hpp b/storage/smatrix/include/algebra/storage/impl/smatrix_getter.hpp index 5184e0ba..5c725c1a 100644 --- a/storage/smatrix/include/algebra/storage/impl/smatrix_getter.hpp +++ b/storage/smatrix/include/algebra/storage/impl/smatrix_getter.hpp @@ -9,6 +9,7 @@ // Project include(s). #include "algebra/qualifiers.hpp" +#include "algebra/storage/smatrix.hpp" // ROOT/Smatrix include(s). #include @@ -26,16 +27,16 @@ namespace algebra::smatrix::storage { template struct element_getter { - template - ALGEBRA_HOST_DEVICE inline scalar_t &operator()(ROOT::Math::SMatrix &m, - unsigned int row, - unsigned int col) const { + template + ALGEBRA_HOST_DEVICE inline scalar_t &operator()( + ROOT::Math::SMatrix &m, unsigned int row, + unsigned int col) const { assert(row < ROWS); assert(col < COLS); return m(row, col); } - template + template ALGEBRA_HOST_DEVICE inline scalar_t operator()( const ROOT::Math::SMatrix &m, unsigned int row, unsigned int col) const { @@ -44,31 +45,31 @@ struct element_getter { return m(row, col); } - template - ALGEBRA_HOST_DEVICE inline scalar_t &operator()(ROOT::Math::SMatrix &m, - unsigned int row) const { - assert(row < ROWS); + template + ALGEBRA_HOST_DEVICE inline scalar_t &operator()( + ROOT::Math::SMatrix &m, unsigned int row) const { + assert(row < N); return m(row); } - template + template ALGEBRA_HOST_DEVICE inline scalar_t operator()( const ROOT::Math::SMatrix &m, unsigned int row) const { - assert(row < ROWS); + assert(row < N); return m(row); } - template - ALGEBRA_HOST_DEVICE inline scalar_t &operator()(ROOT::Math::SVector &m, - unsigned int row) const { - assert(row < ROWS); + template + ALGEBRA_HOST_DEVICE inline scalar_t &operator()( + ROOT::Math::SVector &m, unsigned int row) const { + assert(row < N); return m(row); } - template + template ALGEBRA_HOST_DEVICE inline scalar_t operator()( const ROOT::Math::SVector &m, unsigned int row) const { - assert(row < ROWS); + assert(row < N); return m(row); } }; // element_getter @@ -78,7 +79,8 @@ template ALGEBRA_HOST_DEVICE inline scalar_t element( const ROOT::Math::SMatrix &m, std::size_t row, std::size_t col) { - return element_getter()(m, static_cast(row), static_cast(col)); + return element_getter()(m, static_cast(row), + static_cast(col)); } /// Function extracting an element from a matrix (non-const) @@ -86,7 +88,8 @@ template ALGEBRA_HOST_DEVICE inline scalar_t &element( ROOT::Math::SMatrix &m, std::size_t row, std::size_t col) { - return element_getter()(m, static_cast(row), static_cast(col)); + return element_getter()(m, static_cast(row), + static_cast(col)); } /// Function extracting an element from a matrix (const) @@ -113,35 +116,40 @@ ALGEBRA_HOST_DEVICE inline scalar_t element( /// Function extracting an element from a matrix (non-const) template ALGEBRA_HOST_DEVICE inline scalar_t &element( - ROOT::Math::SVector &m, std::size_t row) { + ROOT::Math::SVector &m, std::size_t row) { return element_getter()(m, static_cast(row)); } /// Functor used to extract a block from SMatrix matrices struct block_getter { - template + template ALGEBRA_HOST_DEVICE ROOT::Math::SMatrix operator()( - const ROOT::Math::SMatrix &m, unsigned int row, unsigned int col) const { + const ROOT::Math::SMatrix &m, unsigned int row, + unsigned int col) const { return m.template Sub>(row, col); } - template + template ALGEBRA_HOST_DEVICE ROOT::Math::SVector operator()( - const ROOT::Math::SMatrix &m, unsigned int row, unsigned int col) const { + const ROOT::Math::SMatrix &m, unsigned int row, + unsigned int col) const { - return m.template SubCol>(col, row); + return m.template SubCol>(col, row); } }; // struct block_getter /// Operator getting a block of a const matrix -template -ALGEBRA_HOST_DEVICE matrix_type block(const ROOT::Math::SMatrix&m, - std::size_t row, - std::size_t col) { - return block_getter{}.template operator()(m, static_cast(row), static_cast(col)); +template +ALGEBRA_HOST_DEVICE matrix_type block( + const ROOT::Math::SMatrix &m, std::size_t row, + std::size_t col) { + return block_getter{}.template operator()( + m, static_cast(row), static_cast(col)); } /// Function extracting a slice from the matrix used by @@ -149,10 +157,11 @@ ALGEBRA_HOST_DEVICE matrix_type block(const ROOT::Math::SMatrix ALGEBRA_HOST_DEVICE inline auto vector( - const ROOT::Math::SMatrix& m, std::size_t row, + const ROOT::Math::SMatrix &m, std::size_t row, std::size_t col) { - return block_getter{}.template operator()(m, static_cast(row), static_cast(col)); + return block_getter{}.template operator()( + m, static_cast(row), static_cast(col)); } /// Operator setting a block with a matrix @@ -162,7 +171,8 @@ ALGEBRA_HOST_DEVICE void set_block(input_matrix_type &m, std::size_t row, std::size_t col) { for (unsigned int i = 0; i < ROWS; ++i) { for (unsigned int j = 0; j < COLS; ++j) { - m(i + static_cast(row), j + static_cast(col)) = b(i, j); + m(i + static_cast(row), + j + static_cast(col)) = b(i, j); } } } @@ -177,4 +187,4 @@ ALGEBRA_HOST_DEVICE void set_block(input_matrix_type &m, } } -} // namespace algebra::smatrix +} // namespace algebra::smatrix::storage diff --git a/storage/smatrix/include/algebra/storage/smatrix.hpp b/storage/smatrix/include/algebra/storage/smatrix.hpp index 8527c10f..a78e56f0 100644 --- a/storage/smatrix/include/algebra/storage/smatrix.hpp +++ b/storage/smatrix/include/algebra/storage/smatrix.hpp @@ -44,101 +44,13 @@ using vector2 = storage_type; template using point2 = vector2; -} // namespace smatrix - -namespace trait { - -/// Type trait specializations -/// @{ - -/// Index -/// @{ -template -struct index> { - using type = unsigned int; -}; -/// @} - -/// Dimension -/// @{ -template -struct dimensions> { - - using size_type = unsigned int; - - static constexpr size_type dim{2}; - static constexpr size_type rows{ROWS}; - static constexpr size_type columns{COLS}; -}; -/// @} - -/// Value -/// @{ -template -struct value> { - using type = T; -}; -/// @} - -/// Vector -/// @{ -template -struct vector> { - - template - using other_type = ROOT::Math::SVector; - - using type = other_type; -}; +/// Element Getter +using element_getter = smatrix::storage::element_getter; +/// Block Getter +using block_getter = smatrix::storage::block_getter; -template -struct vector> { - using type = ROOT::Math::SVector; - - template - using other_type = ROOT::Math::SVector; - - using type = other_type; -}; -/// @} - -/// Matrix -/// @{ -template -struct matrix> { - template - using other_type = ROOT::Math::SMatrix; - - using type = ROOT::Math::SMatrix; -}; - -template -struct matrix> { - template - using other_type = ROOT::Math::SMatrix; - - using type = other_type; -}; -/// @} - -/// Elemet/Block Getter -/// @{ -template -struct element_getter> { - using type = smatrix::storage::element_getter; -}; - -template -struct element_getter> { - using type = smatrix::storage::element_getter; -}; - -template -struct block_getter> { - using type = smatrix::storage::block_getter; -}; -/// @} +} // namespace smatrix -} // namespace trait +ALGEBRA_PLUGINS_DEFINE_TYPE_TRAITS(smatrix) } // namespace algebra diff --git a/storage/vc_aos/include/algebra/storage/vc_aos.hpp b/storage/vc_aos/include/algebra/storage/vc_aos.hpp index 4a5d334f..f3960d00 100644 --- a/storage/vc_aos/include/algebra/storage/vc_aos.hpp +++ b/storage/vc_aos/include/algebra/storage/vc_aos.hpp @@ -64,128 +64,13 @@ using vector6 = vector_type; template using vector8 = vector_type; -} // namespace vc_aos - -namespace trait { - -/// Type trait specializations -/// @{ - -/// Index -/// @{ -template -struct index> { - using type = algebra::vc_aos::size_type; -}; - -template -struct index> { - using type = algebra::vc_aos::size_type; -}; -/// @} - -/// Dimension -/// @{ -template -struct dimensions> { - - using size_type = - index_t>; - - static constexpr size_type dim{1}; - static constexpr size_type rows{N}; - static constexpr size_type columns{1}; -}; - -template -struct dimensions< - algebra::storage::matrix> { - - using size_type = - index_t>; - - static constexpr size_type dim{2}; - static constexpr size_type rows{ROWS}; - static constexpr size_type columns{COLS}; -}; -/// @} - -/// Value -/// @{ -template -struct value> { - using type = T; -}; +/// Element Getter +using element_getter = algebra::storage::element_getter; +/// Block Getter +using block_getter = algebra::storage::block_getter; -template -struct value> { - using type = T; -}; -/// @} - -/// Matrix -/// @{ -template -struct vector> { - - template - using other_type = - algebra::storage::vector; - - using type = other_type; -}; - -template -struct vector> { - - template - using other_type = - algebra::storage::vector; - - using type = other_type; -}; -/// @} - -/// Matrix -/// @{ -template -struct matrix> { - template - using other_type = algebra::storage::matrix; - - using type = algebra::storage::matrix; -}; - -template -struct matrix> { - template - using other_type = algebra::storage::matrix; - - using type = other_type; -}; -/// @} - -/// Elemet/Block Getter -/// @{ -template -struct element_getter> { - using type = algebra::storage::element_getter; -}; - -template -struct element_getter< - algebra::storage::matrix> { - using type = algebra::storage::element_getter; -}; +} // namespace vc_aos -template -struct block_getter< - algebra::storage::matrix> { - using type = algebra::storage::block_getter; -}; -/// @} -} // namespace trait +ALGEBRA_PLUGINS_DEFINE_TYPE_TRAITS(vc_aos) } // namespace algebra diff --git a/storage/vc_soa/include/algebra/storage/vc_soa.hpp b/storage/vc_soa/include/algebra/storage/vc_soa.hpp index 905062be..c1821d45 100644 --- a/storage/vc_soa/include/algebra/storage/vc_soa.hpp +++ b/storage/vc_soa/include/algebra/storage/vc_soa.hpp @@ -40,11 +40,11 @@ template using value_type = Vc::Vector; /// Vector type used in the Vc SoA storage model template -using vector_type = algebra::storage::vector, storage_type>; +using vector_type = algebra::storage::vector, std::array>; /// Matrix type used in the Vc SoA storage model template using matrix_type = - algebra::storage::matrix, ROWS, COLS>; + algebra::storage::matrix, ROWS, COLS>; /// 2-element "vector" type, using @c Vc::Vector in every element template @@ -65,113 +65,25 @@ using vector6 = vector_type; template using vector8 = vector_type; -} // namespace vc_soa - -namespace trait { +/// Element Getter +using element_getter = algebra::storage::element_getter; +/// Block Getter +using block_getter = algebra::storage::block_getter; -/// Type trait specializations -/// @{ - -/// Index -/// @{ -template -struct index, ROWS, COLS>> { - using type = algebra::vc_soa::size_type; -}; -/// @} - -/// Dimension -/// @{ -template -struct dimensions< - algebra::storage::matrix, ROWS, COLS>> { +} // namespace vc_soa - using size_type = - index_t, ROWS, COLS>>; +ALGEBRA_PLUGINS_DEFINE_TYPE_TRAITS(vc_soa) - static constexpr size_type dim{2}; - static constexpr size_type rows{ROWS}; - static constexpr size_type columns{COLS}; -}; -/// @} +namespace trait { -/// Value/Scalar +/// Make sure the simd scalar type is recognized correctly /// @{ -template -struct value, ROWS, COLS>> { - using type = T; -}; - template struct scalar, ROWS, COLS>> { using type = Vc::Vector; }; /// @} -/// Vector -/// @{ -template -struct vector, std::array>> { - - template - using other_type = - algebra::storage::vector, std::array>; - - using type = other_type; -}; - -template -struct vector, ROWS, COLS>> { - - template - using other_type = - algebra::storage::vector, std::array>; - - using type = other_type; -}; -/// @} - -/// Matrix -/// @{ -template -struct matrix, ROWS, COLS>> { - template - using other_type = algebra::storage::matrix, - other_ROWS, other_COLS>; - - using type = algebra::storage::matrix, ROWS, COLS>; -}; - -template -struct matrix, std::array>> { - template - using other_type = algebra::storage::matrix, - other_ROWS, other_COLS>; - - using type = other_type; -}; -/// @} - -/// Elemet/Block Getter -/// @{ -template -struct element_getter, std::array>> { - using type = algebra::storage::element_getter; -}; - -template -struct element_getter< - algebra::storage::matrix, ROWS, COLS>> { - using type = algebra::storage::element_getter; -}; - -template -struct block_getter< - algebra::storage::matrix, ROWS, COLS>> { - using type = algebra::storage::block_getter; -}; -/// @} - } // namespace trait } // namespace algebra diff --git a/storage/vecmem/include/algebra/storage/vecmem.hpp b/storage/vecmem/include/algebra/storage/vecmem.hpp index 77ef938e..ec76106a 100644 --- a/storage/vecmem/include/algebra/storage/vecmem.hpp +++ b/storage/vecmem/include/algebra/storage/vecmem.hpp @@ -21,9 +21,14 @@ namespace algebra { namespace vecmem { +/// size type for VecMem storage model +using size_type = std::size_t; /// Array type used in the VecMem storage model template using storage_type = ::vecmem::static_array; +/// Vector type used in the VecMem storage model +template +using vector_type = storage_type; /// Matrix type used in the VecMem storage model template using matrix_type = storage_type, COLS>; @@ -41,128 +46,13 @@ using vector2 = storage_type; template using point2 = vector2; -} // namespace vecmem - -namespace trait { - -/// Type trait specializations -/// @{ - -/// Index -/// @{ -template -struct index<::vecmem::static_array> { - using type = std::size_t; -}; - -template -struct index<::vecmem::static_array<::vecmem::static_array, COLS>> { - using type = std::size_t; -}; -/// @} - -/// Dimension -/// @{ -template -struct dimensions<::vecmem::static_array> { - - using size_type = index_t<::vecmem::static_array>; - - static constexpr size_type dim{1}; - static constexpr size_type rows{N}; - static constexpr size_type columns{1}; -}; - -template -struct dimensions< - ::vecmem::static_array<::vecmem::static_array, COLS>> { - - using size_type = - index_t<::vecmem::static_array<::vecmem::static_array, COLS>>; - - static constexpr size_type dim{2}; - static constexpr size_type rows{ROWS}; - static constexpr size_type columns{COLS}; -}; -/// @} - -/// Value -/// @{ -template -struct value<::vecmem::static_array> { - using type = T; -}; - -template -struct value<::vecmem::static_array<::vecmem::static_array, COLS>> { - using type = T; -}; -/// @} +/// Element Getter +using element_getter = cmath::storage::element_getter; +/// Block Getter +using block_getter = cmath::storage::block_getter; -/// Vector -/// @{ -template -struct vector<::vecmem::static_array> { - - template - using other_type = ::vecmem::static_array; - - using type = other_type; -}; - -template -struct vector<::vecmem::static_array<::vecmem::static_array, COLS>> { - - template - using other_type = ::vecmem::static_array; - - using type = other_type; -}; -/// @} - -/// Matrix -/// @{ -template -struct matrix<::vecmem::static_array<::vecmem::static_array, COLS>> { - template - using other_type = - ::vecmem::static_array<::vecmem::static_array, - other_COLS>; - - using type = ::vecmem::static_array<::vecmem::static_array, COLS>; -}; - -template -struct matrix<::vecmem::static_array> { - template - using other_type = - ::vecmem::static_array<::vecmem::static_array, - other_COLS>; - - using type = other_type; -}; -/// @} - -/// Elemet/Block Getter -/// @{ -template -struct element_getter<::vecmem::static_array> { - using type = cmath::storage::element_getter; -}; - -template -struct element_getter< - ::vecmem::static_array<::vecmem::static_array, COLS>> { - using type = cmath::storage::element_getter; -}; - -template -struct block_getter< - ::vecmem::static_array<::vecmem::static_array, COLS>> { - using type = cmath::storage::block_getter; -}; -/// @} +} // namespace vecmem -} // namespace trait +ALGEBRA_PLUGINS_DEFINE_TYPE_TRAITS(vecmem) } // namespace algebra