diff --git a/common/include/algebra/concepts.hpp b/common/include/algebra/concepts.hpp index b66948ec..374b7bc0 100644 --- a/common/include/algebra/concepts.hpp +++ b/common/include/algebra/concepts.hpp @@ -15,23 +15,23 @@ namespace algebra::concepts { +/// Arithmetic types +template +concept arithmetic = std::is_arithmetic_v; + // Value concept: Single entry template -concept value = std::is_arithmetic_v>; +concept value = algebra::concepts::arithmetic>; /// Scalar concept: Elements of vectors/matrices (can be simd vectors) template concept scalar = !algebra::traits::is_matrix && !algebra::traits::is_vector && requires(T a, T b) { - { a + b } - ->std::convertible_to; - { a - b } - ->std::convertible_to; - { a* b } - ->std::convertible_to; - { a / b } - ->std::convertible_to; -}; + { a + b } -> std::convertible_to; + { a - b } -> std::convertible_to; + { a* b } -> std::convertible_to; + { a / b } -> std::convertible_to; + }; /// Check if a scalar is simd template @@ -71,7 +71,7 @@ template concept matrix = algebra::traits::is_matrix; template -concept square_matrix = matrix&& algebra::traits::is_square; +concept square_matrix = matrix && algebra::traits::is_square; template concept row_matrix = matrix && (algebra::traits::rows == 1); @@ -104,4 +104,25 @@ concept transform3D = requires(T trf) { trf.vector_to_local(typename T::vector3()); }; +/// Algebra plugin concept +template +concept algebra = (concepts::value && + concepts::scalar && + concepts::index && + concepts::simd_scalar> && + concepts::vector3D && + concepts::point2D && + concepts::point3D && + concepts::transform3D && + concepts::matrix>); + +/// Check if an algebra has soa layout +/// @{ +template +concept soa = (!concepts::arithmetic>); + +template +concept aos = (!concepts::soa); +/// @} + } // namespace algebra::concepts diff --git a/common/include/algebra/type_traits.hpp b/common/include/algebra/type_traits.hpp index 3b338aad..7fb7c4b5 100644 --- a/common/include/algebra/type_traits.hpp +++ b/common/include/algebra/type_traits.hpp @@ -12,7 +12,9 @@ #include #include -namespace algebra::traits { +namespace algebra { + +namespace traits { /// Matrix traits /// @{ @@ -79,7 +81,8 @@ struct dimensions { /// Specilization for scalar types template -requires std::is_fundamental_v struct dimensions { + requires std::is_fundamental_v +struct dimensions { using size_type = std::size_t; @@ -129,7 +132,55 @@ template using block_getter_t = typename block_getter::type; /// @} -} // namespace algebra::traits +/// The algebra types +/// @{ +template +struct get_algebra {}; + +template + requires(!std::is_same_v) +struct get_algebra { + template + using simd = typename T::template simd; + using size_type = typename T::size_type; + using value = typename T::value_type; + using scalar = typename T::scalar; + using point2D = typename T::point2D; + using point3D = typename T::point3D; + using vector3D = typename T::vector3D; + using transform3D = typename T::transform3D; + template + using matrix = typename T::template matrix; +}; + +} // namespace traits + +template +using get_scalar_t = typename traits::get_algebra::scalar; + +template +using get_simd_t = typename traits::get_algebra::template simd; + +template +using get_point2D_t = typename traits::get_algebra::point2D; + +template +using get_point3D_t = typename traits::get_algebra::point3D; + +template +using get_vector3D_t = typename traits::get_algebra::vector3D; + +template +using get_transform3D_t = typename traits::get_algebra::transform3D; + +template +using get_size_t = typename traits::get_algebra::size_type; + +template +using get_matrix_t = typename traits::get_algebra::template matrix; +/// @} + +} // namespace algebra /// Default type trait specializations /// @{ diff --git a/frontend/array_cmath/include/algebra/array_cmath.hpp b/frontend/array_cmath/include/algebra/array_cmath.hpp index acb19a3d..7bde32d3 100644 --- a/frontend/array_cmath/include/algebra/array_cmath.hpp +++ b/frontend/array_cmath/include/algebra/array_cmath.hpp @@ -115,4 +115,31 @@ using transform3 = } // namespace array +namespace plugin { + +/// Define the plugin types +/// @{ +template +struct cmath { + /// Define scalar type + using value_type = V; + + template + using simd = T; + + using boolean = bool; + using scalar = value_type; + using size_type = algebra::array::size_type; + using transform3D = algebra::array::transform3; + using point2D = algebra::array::point2; + using point3D = algebra::array::point3; + using vector3D = algebra::array::vector3; + + template + using matrix = algebra::array::matrix_type; +}; +/// @} + +} // namespace plugin + } // namespace algebra diff --git a/frontend/eigen_eigen/include/algebra/eigen_eigen.hpp b/frontend/eigen_eigen/include/algebra/eigen_eigen.hpp index fc9c52a1..fbdf31c7 100644 --- a/frontend/eigen_eigen/include/algebra/eigen_eigen.hpp +++ b/frontend/eigen_eigen/include/algebra/eigen_eigen.hpp @@ -80,4 +80,31 @@ using transform3 = math::transform3; } // namespace eigen +namespace plugin { + +/// Define the plugin types +/// @{ +template +struct eigen { + /// Define scalar type + using value_type = V; + + template + using simd = T; + + using boolean = bool; + using scalar = value_type; + using size_type = algebra::eigen::size_type; + using transform3D = algebra::eigen::transform3; + using point2D = algebra::eigen::point2; + using point3D = algebra::eigen::point3; + using vector3D = algebra::eigen::vector3; + + template + using matrix = algebra::eigen::matrix_type; +}; +/// @} + +} // namespace plugin + } // namespace algebra diff --git a/frontend/eigen_generic/include/algebra/eigen_generic.hpp b/frontend/eigen_generic/include/algebra/eigen_generic.hpp index b7f37321..4eb0eb7f 100644 --- a/frontend/eigen_generic/include/algebra/eigen_generic.hpp +++ b/frontend/eigen_generic/include/algebra/eigen_generic.hpp @@ -93,4 +93,31 @@ using transform3 = } // namespace eigen +namespace plugin { + +/// Define the plugin types +/// @{ +template +struct eigen_generic { + /// Define scalar type + using value_type = V; + + template + using simd = T; + + using boolean = bool; + using scalar = value_type; + using size_type = algebra::eigen::size_type; + using transform3D = algebra::eigen::transform3; + using point2D = algebra::eigen::point2; + using point3D = algebra::eigen::point3; + using vector3D = algebra::eigen::vector3; + + template + using matrix = algebra::eigen::matrix_type; +}; +/// @} + +} // namespace plugin + } // namespace algebra diff --git a/frontend/fastor_fastor/include/algebra/fastor_fastor.hpp b/frontend/fastor_fastor/include/algebra/fastor_fastor.hpp index 122430da..088189a3 100644 --- a/frontend/fastor_fastor/include/algebra/fastor_fastor.hpp +++ b/frontend/fastor_fastor/include/algebra/fastor_fastor.hpp @@ -87,4 +87,31 @@ using transform3 = math::transform3; } // namespace fastor +namespace plugin { + +/// Define the plugin types +/// @{ +template +struct fastor { + /// Define scalar type + using value_type = V; + + template + using simd = T; + + using boolean = bool; + using scalar = value_type; + using size_type = algebra::fastor::size_type; + using transform3D = algebra::fastor::transform3; + using point2D = algebra::fastor::point2; + using point3D = algebra::fastor::point3; + using vector3D = algebra::fastor::vector3; + + template + using matrix = algebra::fastor::matrix_type; +}; +/// @} + +} // namespace plugin + } // namespace algebra diff --git a/frontend/smatrix_generic/include/algebra/smatrix_generic.hpp b/frontend/smatrix_generic/include/algebra/smatrix_generic.hpp index 65436f3d..162b0579 100644 --- a/frontend/smatrix_generic/include/algebra/smatrix_generic.hpp +++ b/frontend/smatrix_generic/include/algebra/smatrix_generic.hpp @@ -84,4 +84,31 @@ using transform3 = } // namespace smatrix +namespace plugin { + +/// Define the plugin types +/// @{ +template +struct smatrix_generic { + /// Define scalar type + using value_type = V; + + template + using simd = T; + + using boolean = bool; + using scalar = value_type; + using size_type = algebra::smatrix::size_type; + using transform3D = algebra::smatrix::transform3; + using point2D = algebra::smatrix::point2; + using point3D = algebra::smatrix::point3; + using vector3D = algebra::smatrix::vector3; + + template + using matrix = algebra::smatrix::matrix_type; +}; +/// @} + +} // namespace plugin + } // namespace algebra diff --git a/frontend/smatrix_smatrix/include/algebra/smatrix_smatrix.hpp b/frontend/smatrix_smatrix/include/algebra/smatrix_smatrix.hpp index c1c243c4..456a4bf1 100644 --- a/frontend/smatrix_smatrix/include/algebra/smatrix_smatrix.hpp +++ b/frontend/smatrix_smatrix/include/algebra/smatrix_smatrix.hpp @@ -78,4 +78,31 @@ using transform3 = math::transform3; } // namespace smatrix +namespace plugin { + +/// Define the plugin types +/// @{ +template +struct smatrix { + /// Define scalar type + using value_type = V; + + template + using simd = T; + + using boolean = bool; + using scalar = value_type; + using size_type = algebra::smatrix::size_type; + using transform3D = algebra::smatrix::transform3; + using point2D = algebra::smatrix::point2; + using point3D = algebra::smatrix::point3; + using vector3D = algebra::smatrix::vector3; + + template + using matrix = algebra::smatrix::matrix_type; +}; +/// @} + +} // namespace plugin + } // namespace algebra diff --git a/frontend/vc_aos/include/algebra/vc_aos.hpp b/frontend/vc_aos/include/algebra/vc_aos.hpp index 473b58e1..da7112cf 100644 --- a/frontend/vc_aos/include/algebra/vc_aos.hpp +++ b/frontend/vc_aos/include/algebra/vc_aos.hpp @@ -83,4 +83,31 @@ using transform3 = math::transform3; } // namespace vc_aos +namespace plugin { + +/// Define the plugin types +/// @{ +template +struct vc_aos { + /// Define scalar type + using value_type = V; + + template + using simd = T; + + using boolean = bool; + using scalar = value_type; + using size_type = algebra::vc_aos::size_type; + using transform3D = algebra::vc_aos::transform3; + using point2D = algebra::vc_aos::point2; + using point3D = algebra::vc_aos::point3; + using vector3D = algebra::vc_aos::vector3; + + template + using matrix = algebra::vc_aos::matrix_type; +}; +/// @} + +} // namespace plugin + } // namespace algebra diff --git a/frontend/vc_aos_generic/include/algebra/vc_aos_generic.hpp b/frontend/vc_aos_generic/include/algebra/vc_aos_generic.hpp index 3f8811e3..6e320848 100644 --- a/frontend/vc_aos_generic/include/algebra/vc_aos_generic.hpp +++ b/frontend/vc_aos_generic/include/algebra/vc_aos_generic.hpp @@ -92,4 +92,31 @@ using transform3 = } // namespace vc_aos +namespace plugin { + +/// Define the plugin types +/// @{ +template +struct vc_aos_generic { + /// Define scalar type + using value_type = V; + + template + using simd = T; + + using boolean = bool; + using scalar = value_type; + using size_type = algebra::vc_aos::size_type; + using transform3D = algebra::vc_aos::transform3; + using point2D = algebra::vc_aos::point2; + using point3D = algebra::vc_aos::point3; + using vector3D = algebra::vc_aos::vector3; + + template + using matrix = algebra::vc_aos::matrix_type; +}; +/// @} + +} // namespace plugin + } // namespace algebra diff --git a/frontend/vc_soa/include/algebra/vc_soa.hpp b/frontend/vc_soa/include/algebra/vc_soa.hpp index aed5e83c..da218d24 100644 --- a/frontend/vc_soa/include/algebra/vc_soa.hpp +++ b/frontend/vc_soa/include/algebra/vc_soa.hpp @@ -84,10 +84,42 @@ namespace vc_soa { template using transform3 = - algebra::vc_aos::math::transform3; + algebra::vc_aos::math::transform3>; /// @} } // namespace vc_soa +namespace plugin { + +/// Define the plugin types +/// @{ +template +struct vc_soa { + /// Define scalar precision + using value_type = V; + + template + using simd = Vc::Vector; + + using boolean = Vc::Mask; + + /// Linear Algebra type definitions + /// @{ + using scalar = simd; + using size_type = algebra::vc_soa::size_type; + using transform3D = algebra::vc_soa::transform3; + using point2D = algebra::vc_soa::point2; + using point3D = algebra::vc_soa::point3; + using vector3D = algebra::vc_soa::vector3; + + template + using matrix = algebra::vc_soa::matrix_type; + /// @} +}; +/// @} + +} // namespace plugin + } // namespace algebra diff --git a/frontend/vecmem_cmath/include/algebra/vecmem_cmath.hpp b/frontend/vecmem_cmath/include/algebra/vecmem_cmath.hpp index 5cf46599..a8c6e9ee 100644 --- a/frontend/vecmem_cmath/include/algebra/vecmem_cmath.hpp +++ b/frontend/vecmem_cmath/include/algebra/vecmem_cmath.hpp @@ -114,4 +114,31 @@ using transform3 = } // namespace vecmem +namespace plugin { + +/// Define the plugin types +/// @{ +template +struct vecmem { + /// Define scalar type + using value_type = V; + + template + using simd = T; + + using boolean = bool; + using scalar = value_type; + using size_type = algebra::vecmem::size_type; + using transform3D = algebra::vecmem::transform3; + using point2D = algebra::vecmem::point2; + using point3D = algebra::vecmem::point3; + using vector3D = algebra::vecmem::vector3; + + template + using matrix = algebra::vecmem::matrix_type; +}; +/// @} + +} // namespace plugin + } // namespace algebra diff --git a/math/vc_aos/include/algebra/math/impl/vc_aos_transform3.hpp b/math/vc_aos/include/algebra/math/impl/vc_aos_transform3.hpp index 170fd41b..24baa9a6 100644 --- a/math/vc_aos/include/algebra/math/impl/vc_aos_transform3.hpp +++ b/math/vc_aos/include/algebra/math/impl/vc_aos_transform3.hpp @@ -36,7 +36,7 @@ using algebra::storage::operator+; /// Transform wrapper class to ensure standard API within differnt plugins template