From d4e78a6bc30c06c238a35cee77b00d3a27ec0516 Mon Sep 17 00:00:00 2001 From: Joana Niermann Date: Fri, 12 Apr 2024 14:53:09 +0200 Subject: [PATCH] Split the test suit to allow for incremental development of plugins --- frontend/vc_vc/include/algebra/vc_vc.hpp | 113 +--- .../algebra/math/impl/vc_transform3.hpp | 24 +- .../include/algebra/math/impl/vc_vector.hpp | 2 +- .../common/include/algebra/storage/vector.hpp | 114 ++-- storage/vc/CMakeLists.txt | 4 +- tests/array/array_cmath.cpp | 16 +- tests/common/test_host_basics.hpp | 493 +++++++++--------- tests/eigen/eigen_cmath.cpp | 16 +- tests/eigen/eigen_eigen.cpp | 16 +- tests/fastor/fastor_fastor.cpp | 16 +- tests/smatrix/smatrix_cmath.cpp | 16 +- tests/smatrix/smatrix_smatrix.cpp | 16 +- tests/vc/vc_cmath.cpp | 25 +- tests/vc/vc_vc.cpp | 17 +- tests/vecmem/vecmem_cmath.cpp | 16 +- 15 files changed, 464 insertions(+), 440 deletions(-) diff --git a/frontend/vc_vc/include/algebra/vc_vc.hpp b/frontend/vc_vc/include/algebra/vc_vc.hpp index f044e3ef..aab5ae3a 100644 --- a/frontend/vc_vc/include/algebra/vc_vc.hpp +++ b/frontend/vc_vc/include/algebra/vc_vc.hpp @@ -1,6 +1,6 @@ /** Algebra plugins library, part of the ACTS project * - * (c) 2020-2022 CERN for the benefit of the ACTS project + * (c) 2020-2024 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -16,25 +16,12 @@ #include #include -/// @name Operators on @c algebra::vc types -/// @{ - -using algebra::cmath::operator*; -using algebra::cmath::operator-; -using algebra::cmath::operator+; - -/// @} - namespace algebra { namespace vc { /// @name Vc based transforms on @c algebra::vc::storage_type /// @{ -// Pull in the definitions needed by the cmath transforms, into this namespace. -using math::perp; -using math::phi; - template using transform3 = math::transform3, point2>; @@ -47,12 +34,6 @@ namespace getter { /// @name Getter functions on @c algebra::vc types /// @{ -using cmath::eta; -using cmath::norm; -using cmath::perp; -using cmath::phi; -using cmath::theta; - using vc::math::eta; using vc::math::norm; using vc::math::perp; @@ -64,13 +45,14 @@ using vc::math::theta; /// Function extracting a slice from the matrix used by /// @c algebra::vc::transform3 template = true> -ALGEBRA_HOST_DEVICE inline auto vector(const vc::transform3::matrix44& m, - std::size_t +ALGEBRA_HOST_DEVICE inline vc::vector3 vector( + const vc::transform3::matrix44& m, + std::size_t #ifndef NDEBUG - row + row #endif // not NDEBUG - , - std::size_t col) { + , + std::size_t col) { assert(row == 0); assert(col < 4); @@ -91,7 +73,7 @@ ALGEBRA_HOST_DEVICE inline auto vector(const vc::transform3::matrix44& m, /// Function extracting a slice from the matrix used by /// @c algebra::vc::transform3 template = true> -ALGEBRA_HOST_DEVICE inline auto vector( +ALGEBRA_HOST_DEVICE inline vc::vector3 vector( const vc::transform3::matrix44& m, std::size_t #ifndef NDEBUG @@ -130,8 +112,6 @@ namespace vector { /// @name Vector functions on @c algebra::vc types /// @{ -using cmath::dot; -using cmath::normalize; using vc::math::cross; using vc::math::dot; using vc::math::normalize; @@ -150,82 +130,5 @@ using array_type = vc::storage_type; template using matrix_type = vc::matrix_type; -/*template -using element_getter = cmath::element_getter; - -template -using block_getter = cmath::block_getter; - -// matrix actor -template -using actor = - cmath::matrix::actor, block_getter>;*/ - -namespace determinant { - -// determinant aggregation -/*template -using actor = - cmath::matrix::determinant::actor; - -// determinant::cofactor -template -using cofactor = - cmath::matrix::determinant::cofactor, Ds...>; - -// determinant::partial_pivot_lud -template -using partial_pivot_lud = cmath::matrix::determinant::partial_pivot_lud< - size_type, matrix_type, scalar_t, element_getter, Ds...>; - -// determinant::hard_coded -template -using hard_coded = - cmath::matrix::determinant::hard_coded, Ds...>; - -// preset(s) as standard option(s) for user's convenience -template -using preset0 = - actor, hard_coded>; - -} // namespace determinant - -namespace inverse { - -// inverion aggregation -template -using actor = - cmath::matrix::inverse::actor; - -// inverse::cofactor -template -using cofactor = - cmath::matrix::inverse::cofactor, Ds...>; - -// inverse::partial_pivot_lud -template -using partial_pivot_lud = - cmath::matrix::inverse::partial_pivot_lud, Ds...>; - -// inverse::hard_coded -template -using hard_coded = - cmath::matrix::inverse::hard_coded, Ds...>; - -// preset(s) as standard option(s) for user's convenience -template -using preset0 = - actor, hard_coded>;*/ - -} // namespace determinant - } // namespace matrix } // namespace algebra diff --git a/math/vc/include/algebra/math/impl/vc_transform3.hpp b/math/vc/include/algebra/math/impl/vc_transform3.hpp index 8fcb99d7..1ef3b000 100644 --- a/math/vc/include/algebra/math/impl/vc_transform3.hpp +++ b/math/vc/include/algebra/math/impl/vc_transform3.hpp @@ -135,10 +135,10 @@ struct transform3 { ALGEBRA_HOST_DEVICE transform3(const vector3 &t, const vector3 &x, const vector3 &y, const vector3 &z, bool get_inverse = true) { - _data.x = {x[0], x[1], x[2], 0.}; - _data.y = {y[0], y[1], y[2], 0.}; - _data.z = {z[0], z[1], z[2], 0.}; - _data.t = {t[0], t[1], t[2], 1.}; + _data.x = {x[0], x[1], x[2], 0.f}; + _data.y = {y[0], y[1], y[2], 0.f}; + _data.z = {z[0], z[1], z[2], 0.f}; + _data.t = {t[0], t[1], t[2], 1.f}; if (get_inverse) { _data_inv = invert(_data); @@ -163,10 +163,10 @@ struct transform3 { ALGEBRA_HOST_DEVICE transform3(const vector3 &t) { - _data.x = {1., 0., 0., 0.}; - _data.y = {0., 1., 0., 0.}; - _data.z = {0., 0., 1., 0.}; - _data.t = {t[0], t[1], t[2], 1.}; + _data.x = {1.f, 0.f, 0.f, 0.f}; + _data.y = {0.f, 1.f, 0.f, 0.f}; + _data.z = {0.f, 0.f, 1.f, 0.f}; + _data.t = {t[0], t[1], t[2], 1.f}; _data_inv = invert(_data); } @@ -199,10 +199,10 @@ struct transform3 { ALGEBRA_HOST_DEVICE transform3() { - _data.x = {1., 0., 0., 0.}; - _data.y = {0., 1., 0., 0.}; - _data.z = {0., 0., 1., 0.}; - _data.t = {0., 0., 0., 1.}; + _data.x = {1.f, 0.f, 0.f, 0.f}; + _data.y = {0.f, 1.f, 0.f, 0.f}; + _data.z = {0.f, 0.f, 1.f, 0.f}; + _data.t = {0.f, 0.f, 0.f, 1.f}; _data_inv = _data; } diff --git a/math/vc/include/algebra/math/impl/vc_vector.hpp b/math/vc/include/algebra/math/impl/vc_vector.hpp index 49b4d1db..967717ac 100644 --- a/math/vc/include/algebra/math/impl/vc_vector.hpp +++ b/math/vc/include/algebra/math/impl/vc_vector.hpp @@ -84,7 +84,7 @@ ALGEBRA_HOST_DEVICE inline auto cross(const vector_type1 &a, -> decltype(a * b - a * b) { return {a[1] * b[2] - b[1] * a[2], a[2] * b[0] - b[2] * a[0], - a[0] * b[1] - b[0] * a[1], 0}; + a[0] * b[1] - b[0] * a[1], 0.f}; } } // namespace algebra::vc::math diff --git a/storage/common/include/algebra/storage/vector.hpp b/storage/common/include/algebra/storage/vector.hpp index 3dacccbf..f2eec8fd 100644 --- a/storage/common/include/algebra/storage/vector.hpp +++ b/storage/common/include/algebra/storage/vector.hpp @@ -42,15 +42,23 @@ class vector { template ...> && - sizeof...(Values) <= N, + sizeof...(Values) <= N && N != 4, bool> = true> constexpr vector(Values &&... vals) : m_data{std::forward(vals)...} { if constexpr ((sizeof...(Values) < N) && (!std::conjunction_v...>)) { - zero_fill(std::make_index_sequence{}); + zero_fill(std::make_index_sequence{}); } } + template ...> && + N == 4, + bool> = true> + constexpr vector(Values &&... vals) + : m_data{std::forward(vals)..., 0.f} {} + /// Construct from existing array storage @param vals . constexpr vector(const array_type &vals) : m_data{vals} {} @@ -132,9 +140,7 @@ class vector { /// Sets the trailing uninitialized values to zero. template constexpr void zero_fill(std::index_sequence) noexcept { - if constexpr (sizeof...(Is) > 0) { - ((m_data[N - sizeof...(Is) + Is] = value_t(0)), ...); - } + //((m_data[N - sizeof...(Is) + Is] = value_t(0)), ...); } }; @@ -186,55 +192,55 @@ constexpr bool operator==(const vector &lhs, /// @} /// Macro declaring all instances of a specific arithmetic operator -#define DECLARE_vector_OPERATORS(OP) \ - template class array_t, \ - std::enable_if_t, bool> = true> \ - inline constexpr decltype(auto) operator OP( \ - const vector &lhs, scalar_t rhs) noexcept { \ - return lhs.m_data OP static_cast(rhs); \ - } \ - template class array_t, \ - std::enable_if_t, bool> = true> \ - inline decltype(auto) operator OP( \ - scalar_t lhs, const vector &rhs) noexcept { \ - return static_cast(lhs) OP rhs.m_data; \ - } \ - template class array_t> \ - inline constexpr decltype(auto) operator OP( \ - const vector &lhs, \ - const vector &rhs) noexcept { \ - return lhs.m_data OP rhs.m_data; \ - } \ - template < \ - std::size_t N, typename value_t, \ - template class array_t, typename other_type, \ - std::enable_if_t< \ - std::is_object::array_type>() OP \ - std::declval())>::value && \ - !std::is_scalar_v, \ - bool> = true> \ - inline constexpr decltype(auto) operator OP( \ - const vector &lhs, \ - const other_type &rhs) noexcept { \ - return lhs.m_data OP rhs; \ - } \ - template < \ - std::size_t N, typename value_t, \ - template class array_t, typename other_type, \ - std::enable_if_t< \ - std::is_object::array_type>() OP \ - std::declval())>::value && \ - !std::is_scalar_v, \ - bool> = true> \ - inline constexpr decltype(auto) operator OP( \ - const other_type &lhs, \ - const vector &rhs) noexcept { \ - return lhs OP rhs.m_data; \ +#define DECLARE_vector_OPERATORS(OP) \ + template class array_t, \ + std::enable_if_t, bool> = true> \ + inline constexpr decltype(auto) operator OP( \ + const vector &lhs, scalar_t rhs) noexcept { \ + return lhs.m_data OP static_cast(rhs); \ + } \ + template class array_t, \ + std::enable_if_t, bool> = true> \ + inline decltype(auto) operator OP( \ + scalar_t lhs, const vector &rhs) noexcept { \ + return static_cast(lhs) OP rhs.m_data; \ + } \ + template class array_t> \ + inline constexpr decltype(auto) operator OP( \ + const vector &lhs, \ + const vector &rhs) noexcept { \ + return lhs.m_data OP rhs.m_data; \ + } \ + template < \ + std::size_t N, typename value_t, \ + template class array_t, typename other_type, \ + std::enable_if_t< \ + std::is_object::array_type>() \ + OP std::declval())>::value && \ + !std::is_scalar_v, \ + bool> = true> \ + inline constexpr decltype(auto) operator OP( \ + const vector &lhs, \ + const other_type &rhs) noexcept { \ + return lhs.m_data OP rhs; \ + } \ + template < \ + std::size_t N, typename value_t, \ + template class array_t, typename other_type, \ + std::enable_if_t< \ + std::is_object::array_type>() \ + OP std::declval())>::value && \ + !std::is_scalar_v, \ + bool> = true> \ + inline constexpr decltype(auto) operator OP( \ + const other_type &lhs, \ + const vector &rhs) noexcept { \ + return lhs OP rhs.m_data; \ } // Implement all arithmetic operations on top of @c vector. diff --git a/storage/vc/CMakeLists.txt b/storage/vc/CMakeLists.txt index edb494c8..628c5aeb 100644 --- a/storage/vc/CMakeLists.txt +++ b/storage/vc/CMakeLists.txt @@ -1,6 +1,6 @@ # Algebra plugins library, part of the ACTS project (R&D line) # -# (c) 2021-2023 CERN for the benefit of the ACTS project +# (c) 2021-2024 CERN for the benefit of the ACTS project # # Mozilla Public License Version 2.0 @@ -9,6 +9,6 @@ algebra_add_library( algebra_vc_storage vc_storage "include/algebra/storage/vc.hpp" "include/algebra/storage/impl/vc_array4_wrapper.hpp" ) target_link_libraries( algebra_vc_storage - INTERFACE algebra::common Vc::Vc ) + INTERFACE algebra::common algebra::common_storage Vc::Vc ) algebra_test_public_headers( algebra_vc_storage "algebra/storage/vc.hpp" ) diff --git a/tests/array/array_cmath.cpp b/tests/array/array_cmath.cpp index 676dd611..9f8845c9 100644 --- a/tests/array/array_cmath.cpp +++ b/tests/array/array_cmath.cpp @@ -1,6 +1,6 @@ /** Algebra plugins library, part of the ACTS project * - * (c) 2020-2022 CERN for the benefit of the ACTS project + * (c) 2020-2024 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -32,6 +32,14 @@ struct test_specialisation_name { } }; +// Register the tests +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_vector, local_vectors, vector3, + getter); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_matrix, matrix3, matrix64, + matrix22); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_transform, transform3, + global_transformations); + // Instantiate the test(s). typedef testing::Types< test_types, @@ -51,5 +59,9 @@ typedef testing::Types< double, algebra::matrix::determinant::preset0, algebra::matrix::inverse::preset0>>> array_cmath_types; -INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics, +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_vector, + array_cmath_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_matrix, + array_cmath_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_transform, array_cmath_types, test_specialisation_name); diff --git a/tests/common/test_host_basics.hpp b/tests/common/test_host_basics.hpp index d28d3050..d651f4d0 100644 --- a/tests/common/test_host_basics.hpp +++ b/tests/common/test_host_basics.hpp @@ -18,105 +18,143 @@ #include #include -/// Test case class, to be specialised for the different plugins +/// Test case class, to be specialised for the different plugins - vectors template -class test_host_basics : public testing::Test, public test_base {}; -TYPED_TEST_SUITE_P(test_host_basics); +class test_host_basics_vector : public testing::Test, public test_base {}; +TYPED_TEST_SUITE_P(test_host_basics_vector); + +/// Test case class, to be specialised for the different plugins - matrices +template +class test_host_basics_matrix : public testing::Test, public test_base {}; +TYPED_TEST_SUITE_P(test_host_basics_matrix); + +/// Test case class, to be specialised for the different plugins - transforms +template +class test_host_basics_transform : public testing::Test, public test_base {}; +TYPED_TEST_SUITE_P(test_host_basics_transform); // This defines the local frame test suite -TYPED_TEST_P(test_host_basics, local_vectors) { +TYPED_TEST_P(test_host_basics_vector, local_vectors) { // Construction - typename TypeParam::point2 vA{0., 1.}; - ASSERT_EQ(vA[0], 0.); - ASSERT_EQ(vA[1], 1.); + typename TypeParam::point2 vA{0.f, 1.f}; + ASSERT_EQ(vA[0], 0.f); + ASSERT_EQ(vA[1], 1.f); // Assignment typename TypeParam::point2 vB = vA; - ASSERT_EQ(vB[0], 0.); - ASSERT_EQ(vB[1], 1.); + ASSERT_EQ(vB[0], 0.f); + ASSERT_EQ(vB[1], 1.f); // Addition typename TypeParam::point2 vC = vA + vB; - ASSERT_EQ(vC[0], 0.); - ASSERT_EQ(vC[1], 2.); + ASSERT_EQ(vC[0], 0.f); + ASSERT_EQ(vC[1], 2.f); // Multiplication by scalar - typename TypeParam::point2 vC2 = vC * 2.; - ASSERT_EQ(vC2[0], 0.); - ASSERT_EQ(vC2[1], 4.); + typename TypeParam::point2 vC2 = vC * 2.f; + ASSERT_EQ(vC2[0], 0.f); + ASSERT_EQ(vC2[1], 4.f); // Cast operations to phi, theta, eta, perp - typename TypeParam::vector2 vD{1., 1.}; + typename TypeParam::vector2 vD{1.f, 1.f}; typename TypeParam::scalar phi = algebra::getter::phi(vD); ASSERT_NEAR(phi, M_PI_4, this->m_epsilon); typename TypeParam::scalar perp = algebra::getter::perp(vD); - ASSERT_NEAR(perp, std::sqrt(2.), this->m_epsilon); + ASSERT_NEAR(perp, std::sqrt(2.f), this->m_epsilon); typename TypeParam::scalar norm = algebra::getter::norm(vD); - ASSERT_NEAR(norm, std::sqrt(2.), this->m_epsilon); + ASSERT_NEAR(norm, std::sqrt(2.f), this->m_epsilon); typename TypeParam::vector2 vDnorm = algebra::vector::normalize(vD); - ASSERT_NEAR(vDnorm[0], 1. / std::sqrt(2.), this->m_epsilon); - ASSERT_NEAR(vDnorm[1], 1. / std::sqrt(2.), this->m_epsilon); + ASSERT_NEAR(vDnorm[0], 1.f / std::sqrt(2.f), this->m_epsilon); + ASSERT_NEAR(vDnorm[1], 1.f / std::sqrt(2.f), this->m_epsilon); } // This defines the vector3 test suite -TYPED_TEST_P(test_host_basics, vector3) { +TYPED_TEST_P(test_host_basics_vector, vector3) { // Construction - typename TypeParam::vector3 vA{0., 1., 2.}; - ASSERT_EQ(vA[0], 0.); - ASSERT_EQ(vA[1], 1.); - ASSERT_EQ(vA[2], 2.); + typename TypeParam::vector3 vA{0.f, 1.f, 2.f}; + ASSERT_EQ(vA[0], 0.f); + ASSERT_EQ(vA[1], 1.f); + ASSERT_EQ(vA[2], 2.f); // Assignment typename TypeParam::vector3 vB = vA; - ASSERT_EQ(vB[0], 0.); - ASSERT_EQ(vB[1], 1.); - ASSERT_EQ(vB[2], 2.); + ASSERT_EQ(vB[0], 0.f); + ASSERT_EQ(vB[1], 1.f); + ASSERT_EQ(vB[2], 2.f); // Addition typename TypeParam::vector3 vC = vA + vB; - ASSERT_EQ(vC[0], 0.); - ASSERT_EQ(vC[1], 2.); - ASSERT_EQ(vC[2], 4.); + ASSERT_EQ(vC[0], 0.f); + ASSERT_EQ(vC[1], 2.f); + ASSERT_EQ(vC[2], 4.f); // Multiplication by scalar - typename TypeParam::vector3 vC2 = vC * 2.0; - ASSERT_EQ(vC2[0], 0.); - ASSERT_EQ(vC2[1], 4.); - ASSERT_EQ(vC2[2], 8.); + typename TypeParam::vector3 vC2 = vC * 2.0f; + ASSERT_EQ(vC2[0], 0.f); + ASSERT_EQ(vC2[1], 4.f); + ASSERT_EQ(vC2[2], 8.f); // Cast operations to phi, theta, eta, perp - typename TypeParam::vector3 vD{1., 1., 1.}; + typename TypeParam::vector3 vD{1.f, 1.f, 1.f}; typename TypeParam::scalar phi = algebra::getter::phi(vD); ASSERT_NEAR(phi, M_PI_4, this->m_epsilon); typename TypeParam::scalar theta = algebra::getter::theta(vD); - ASSERT_NEAR(theta, std::atan2(std::sqrt(2.), 1.), this->m_epsilon); + ASSERT_NEAR(theta, std::atan2(std::sqrt(2.f), 1.f), this->m_epsilon); typename TypeParam::scalar eta = algebra::getter::eta(vD); ASSERT_NEAR(eta, 0.65847891569137573, this->m_isclose); typename TypeParam::scalar perp = algebra::getter::perp(vD); - ASSERT_NEAR(perp, std::sqrt(2.), this->m_epsilon); + ASSERT_NEAR(perp, std::sqrt(2.f), this->m_epsilon); typename TypeParam::scalar norm = algebra::getter::norm(vD); - ASSERT_NEAR(norm, std::sqrt(3.), this->m_epsilon); + ASSERT_NEAR(norm, std::sqrt(3.f), this->m_epsilon); +} + +// This defines the vector operation test suite +TYPED_TEST_P(test_host_basics_vector, getter) { + + typename TypeParam::vector3 v3{1.f, 1.f, 1.f}; + + // Normalization + typename TypeParam::vector3 v3n = algebra::vector::normalize(v3); + ASSERT_NEAR(v3n[0], 1.f / std::sqrt(3.f), this->m_epsilon); + ASSERT_NEAR(v3n[1], 1.f / std::sqrt(3.f), this->m_epsilon); + ASSERT_NEAR(v3n[2], 1.f / std::sqrt(3.f), this->m_epsilon); + + // Cross product + typename TypeParam::vector3 z = + algebra::vector::normalize(typename TypeParam::vector3{3.f, 2.f, 1.f}); + typename TypeParam::vector3 x = + algebra::vector::normalize(typename TypeParam::vector3{2.f, -3.f, 0.f}); + typename TypeParam::vector3 y = + algebra::vector::cross(z, algebra::vector::normalize(x)); + + // Check with dot product + ASSERT_NEAR(algebra::vector::dot(x, y), 0.f, this->m_epsilon); + ASSERT_NEAR(algebra::vector::dot(y, z), 0.f, this->m_epsilon); + ASSERT_NEAR(algebra::vector::dot(z, x), 0.f, this->m_epsilon); +} + +TYPED_TEST_P(test_host_basics_matrix, matrix3) { // Test on matrix - vector operations - /*typename TypeParam::vector3 vE{1., 2., 3.}; + typename TypeParam::vector3 vE{1.f, 2.f, 3.f}; typename TypeParam::template matrix<2, 3> m23; - algebra::getter::element(m23, 0, 0) = 1; - algebra::getter::element(m23, 0, 1) = 2; - algebra::getter::element(m23, 0, 2) = 3; - algebra::getter::element(m23, 1, 0) = 4; - algebra::getter::element(m23, 1, 1) = 5; - algebra::getter::element(m23, 1, 2) = 6; + algebra::getter::element(m23, 0, 0) = 1.f; + algebra::getter::element(m23, 0, 1) = 2.f; + algebra::getter::element(m23, 0, 2) = 3.f; + algebra::getter::element(m23, 1, 0) = 4.f; + algebra::getter::element(m23, 1, 1) = 5.f; + algebra::getter::element(m23, 1, 2) = 6.f; typename TypeParam::vector2 v2 = m23 * vE; @@ -125,22 +163,23 @@ TYPED_TEST_P(test_host_basics, vector3) { // Cross product on vector3 and matrix<3,1> typename TypeParam::template matrix<3, 1> vF; - algebra::getter::element(vF, 0, 0) = 5; - algebra::getter::element(vF, 1, 0) = 6; - algebra::getter::element(vF, 2, 0) = 13; + algebra::getter::element(vF, 0, 0) = 5.f; + algebra::getter::element(vF, 1, 0) = 6.f; + algebra::getter::element(vF, 2, 0) = 13.f; + typename TypeParam::vector3 vD{1.f, 1.f, 1.f}; typename TypeParam::vector3 vG = algebra::vector::cross(vD, vF); - ASSERT_NEAR(vG[0], 7, this->m_epsilon); - ASSERT_NEAR(vG[1], -8, this->m_epsilon); - ASSERT_NEAR(vG[2], 1, this->m_epsilon); + ASSERT_NEAR(vG[0], 7.f, this->m_epsilon); + ASSERT_NEAR(vG[1], -8.f, this->m_epsilon); + ASSERT_NEAR(vG[2], 1.f, this->m_epsilon); // Dot product on vector3 and matrix<3,1> auto dot = algebra::vector::dot(vG, vF); - ASSERT_NEAR(dot, 0, this->m_epsilon);*/ + ASSERT_NEAR(dot, 0.f, this->m_epsilon); } // Test generic access to a 6x4 matrix -/*TYPED_TEST_P(test_host_basics, matrix64) { +TYPED_TEST_P(test_host_basics_matrix, matrix64) { // Create the matrix. static constexpr typename TypeParam::size_type ROWS = 6; @@ -180,132 +219,132 @@ TYPED_TEST_P(test_host_basics, vector3) { for (typename TypeParam::size_type i = 0; i < ROWS; ++i) { for (typename TypeParam::size_type j = 0; j < COLS; ++j) { if (i == j) { - ASSERT_NEAR(algebra::getter::element(m, i, j), 1., this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m, i, j), 1.f, this->m_epsilon); } else { - ASSERT_NEAR(algebra::getter::element(m, i, j), 0., this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m, i, j), 0.f, this->m_epsilon); } } } // Test block operations auto b13 = typename TypeParam::matrix_actor().template block<1, 3>(m, 0, 0); - ASSERT_NEAR(algebra::getter::element(b13, 0, 0), 1., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(b13, 0, 1), 0., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(b13, 0, 2), 0., this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(b13, 0, 0), 1.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(b13, 0, 1), 0.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(b13, 0, 2), 0.f, this->m_epsilon); auto b13_tp = typename TypeParam::matrix_actor().transpose(b13); - ASSERT_NEAR(algebra::getter::element(b13_tp, 0, 0), 1., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(b13_tp, 1, 0), 0., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(b13_tp, 2, 0), 0., this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(b13_tp, 0, 0), 1.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(b13_tp, 1, 0), 0.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(b13_tp, 2, 0), 0.f, this->m_epsilon); auto b32 = typename TypeParam::matrix_actor().template block<3, 2>(m, 2, 2); - ASSERT_NEAR(algebra::getter::element(b32, 0, 0), 1., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(b32, 0, 1), 0., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(b32, 1, 0), 0., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(b32, 1, 1), 1., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(b32, 2, 0), 0., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(b32, 2, 1), 0., this->m_epsilon); - - algebra::getter::element(b32, 0, 0) = 4; - algebra::getter::element(b32, 0, 1) = 3; - algebra::getter::element(b32, 1, 0) = 12; - algebra::getter::element(b32, 1, 1) = 13; - algebra::getter::element(b32, 2, 0) = 5; - algebra::getter::element(b32, 2, 1) = 6; + ASSERT_NEAR(algebra::getter::element(b32, 0, 0), 1.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(b32, 0, 1), 0.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(b32, 1, 0), 0.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(b32, 1, 1), 1.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(b32, 2, 0), 0.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(b32, 2, 1), 0.f, this->m_epsilon); + + algebra::getter::element(b32, 0, 0) = 4.f; + algebra::getter::element(b32, 0, 1) = 3.f; + algebra::getter::element(b32, 1, 0) = 12.f; + algebra::getter::element(b32, 1, 1) = 13.f; + algebra::getter::element(b32, 2, 0) = 5.f; + algebra::getter::element(b32, 2, 1) = 6.f; typename TypeParam::matrix_actor().set_block(m, b32, 2, 2); - ASSERT_NEAR(algebra::getter::element(m, 2, 2), 4., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m, 2, 3), 3., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m, 3, 2), 12., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m, 3, 3), 13., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m, 4, 2), 5., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m, 4, 3), 6., this->m_epsilon); - - typename TypeParam::vector3 v = {10, 20, 30}; + ASSERT_NEAR(algebra::getter::element(m, 2, 2), 4.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m, 2, 3), 3.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m, 3, 2), 12.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m, 3, 3), 13.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m, 4, 2), 5.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m, 4, 3), 6.f, this->m_epsilon); + + typename TypeParam::vector3 v = {10.f, 20.f, 30.f}; typename TypeParam::matrix_actor().set_block(m, v, 0, 2); - ASSERT_NEAR(algebra::getter::element(m, 0, 2), 10., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m, 1, 2), 20., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m, 2, 2), 30., this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m, 0, 2), 10.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m, 1, 2), 20.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m, 2, 2), 30.f, this->m_epsilon); } // Test matrix operations with 3x3 matrix -TYPED_TEST_P(test_host_basics, matrix22) { +TYPED_TEST_P(test_host_basics_matrix, matrix22) { typename TypeParam::template matrix<2, 2> m22; - algebra::getter::element(m22, 0, 0) = 4; - algebra::getter::element(m22, 0, 1) = 3; - algebra::getter::element(m22, 1, 0) = 12; - algebra::getter::element(m22, 1, 1) = 13; + algebra::getter::element(m22, 0, 0) = 4.f; + algebra::getter::element(m22, 0, 1) = 3.f; + algebra::getter::element(m22, 1, 0) = 12.f; + algebra::getter::element(m22, 1, 1) = 13.f; // Test 2 X 2 matrix determinant auto m22_det = typename TypeParam::matrix_actor().determinant(m22); - ASSERT_NEAR(m22_det, 16., this->m_isclose); + ASSERT_NEAR(m22_det, 16.f, this->m_isclose); // Test 2 X 2 matrix inverse auto m22_inv = typename TypeParam::matrix_actor().inverse(m22); - ASSERT_NEAR(algebra::getter::element(m22_inv, 0, 0), 13 / 16., + ASSERT_NEAR(algebra::getter::element(m22_inv, 0, 0), 13.f / 16.f, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m22_inv, 0, 1), -3 / 16., + ASSERT_NEAR(algebra::getter::element(m22_inv, 0, 1), -3.f / 16.f, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m22_inv, 1, 0), -12 / 16., + ASSERT_NEAR(algebra::getter::element(m22_inv, 1, 0), -12.f / 16.f, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m22_inv, 1, 1), 4 / 16., + ASSERT_NEAR(algebra::getter::element(m22_inv, 1, 1), 4.f / 16.f, this->m_isclose); typename TypeParam::template matrix<3, 3> m33; - algebra::getter::element(m33, 0, 0) = 1; - algebra::getter::element(m33, 0, 1) = 5; - algebra::getter::element(m33, 0, 2) = 7; - algebra::getter::element(m33, 1, 0) = 3; - algebra::getter::element(m33, 1, 1) = 5; - algebra::getter::element(m33, 1, 2) = 6; - algebra::getter::element(m33, 2, 0) = 2; - algebra::getter::element(m33, 2, 1) = 8; - algebra::getter::element(m33, 2, 2) = 9; + algebra::getter::element(m33, 0, 0) = 1.f; + algebra::getter::element(m33, 0, 1) = 5.f; + algebra::getter::element(m33, 0, 2) = 7.f; + algebra::getter::element(m33, 1, 0) = 3.f; + algebra::getter::element(m33, 1, 1) = 5.f; + algebra::getter::element(m33, 1, 2) = 6.f; + algebra::getter::element(m33, 2, 0) = 2.f; + algebra::getter::element(m33, 2, 1) = 8.f; + algebra::getter::element(m33, 2, 2) = 9.f; // Test 3 X 3 matrix determinant auto m33_det = typename TypeParam::matrix_actor().determinant(m33); - ASSERT_NEAR(m33_det, 20., this->m_isclose); + ASSERT_NEAR(m33_det, 20.f, this->m_isclose); // Test 3 X 3 matrix inverse auto m33_inv = typename TypeParam::matrix_actor().inverse(m33); - ASSERT_NEAR(algebra::getter::element(m33_inv, 0, 0), -3 / 20., + ASSERT_NEAR(algebra::getter::element(m33_inv, 0, 0), -3.f / 20.f, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m33_inv, 0, 1), 11 / 20., + ASSERT_NEAR(algebra::getter::element(m33_inv, 0, 1), 11.f / 20.f, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m33_inv, 0, 2), -5 / 20., + ASSERT_NEAR(algebra::getter::element(m33_inv, 0, 2), -5.f / 20.f, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m33_inv, 1, 0), -15 / 20., + ASSERT_NEAR(algebra::getter::element(m33_inv, 1, 0), -15.f / 20.f, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m33_inv, 1, 1), -5 / 20., + ASSERT_NEAR(algebra::getter::element(m33_inv, 1, 1), -5.f / 20.f, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m33_inv, 1, 2), 15 / 20., + ASSERT_NEAR(algebra::getter::element(m33_inv, 1, 2), 15.f / 20.f, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m33_inv, 2, 0), 14 / 20., + ASSERT_NEAR(algebra::getter::element(m33_inv, 2, 0), 14.f / 20.f, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m33_inv, 2, 1), 2 / 20., + ASSERT_NEAR(algebra::getter::element(m33_inv, 2, 1), 2.f / 20.f, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m33_inv, 2, 2), -10 / 20., + ASSERT_NEAR(algebra::getter::element(m33_inv, 2, 2), -10.f / 20.f, this->m_isclose); // Test Zero typename TypeParam::template matrix<2, 3> m23 = typename TypeParam::matrix_actor().template zero<2, 3>(); - algebra::getter::element(m23, 0, 0) += 2; - algebra::getter::element(m23, 0, 1) += 3; - algebra::getter::element(m23, 0, 2) += 4; - algebra::getter::element(m23, 1, 0) += 5; - algebra::getter::element(m23, 1, 1) += 6; - algebra::getter::element(m23, 1, 2) += 7; + algebra::getter::element(m23, 0, 0) += 2.f; + algebra::getter::element(m23, 0, 1) += 3.f; + algebra::getter::element(m23, 0, 2) += 4.f; + algebra::getter::element(m23, 1, 0) += 5.f; + algebra::getter::element(m23, 1, 1) += 6.f; + algebra::getter::element(m23, 1, 2) += 7.f; // Test scalar X Matrix m23 = 2. * m23; - ASSERT_NEAR(algebra::getter::element(m23, 0, 0), 4., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m23, 0, 1), 6., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m23, 0, 2), 8., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m23, 1, 0), 10., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m23, 1, 1), 12., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m23, 1, 2), 14., this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m23, 0, 0), 4.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m23, 0, 1), 6.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m23, 0, 2), 8.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m23, 1, 0), 10.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m23, 1, 1), 12.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m23, 1, 2), 14.f, this->m_epsilon); // Test Transpose auto m32 = typename TypeParam::matrix_actor().transpose(m23); @@ -314,69 +353,69 @@ TYPED_TEST_P(test_host_basics, matrix22) { m32 = m32 + typename TypeParam::matrix_actor().template identity<3, 2>(); // Test Matrix X scalar - m32 = m32 * 2.; + m32 = m32 * 2.f; - ASSERT_NEAR(algebra::getter::element(m32, 0, 0), 10., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m32, 0, 1), 20., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m32, 1, 0), 12., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m32, 1, 1), 26., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m32, 2, 0), 16., this->m_epsilon); - ASSERT_NEAR(algebra::getter::element(m32, 2, 1), 28., this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m32, 0, 0), 10.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m32, 0, 1), 20.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m32, 1, 0), 12.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m32, 1, 1), 26.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m32, 2, 0), 16.f, this->m_epsilon); + ASSERT_NEAR(algebra::getter::element(m32, 2, 1), 28.f, this->m_epsilon); // Test Matrix multiplication m22 = m22_inv * m23 * m33_inv * m32; - ASSERT_NEAR(algebra::getter::element(m22, 0, 0), 6.225, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m22, 0, 1), 14.675, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m22, 1, 0), -3.3, this->m_isclose); - ASSERT_NEAR(algebra::getter::element(m22, 1, 1), -7.9, this->m_isclose); + ASSERT_NEAR(algebra::getter::element(m22, 0, 0), 6.225f, this->m_isclose); + ASSERT_NEAR(algebra::getter::element(m22, 0, 1), 14.675f, this->m_isclose); + ASSERT_NEAR(algebra::getter::element(m22, 1, 0), -3.3f, this->m_isclose); + ASSERT_NEAR(algebra::getter::element(m22, 1, 1), -7.9f, this->m_isclose); // Test 6 X 6 big matrix determinant typename TypeParam::template matrix<6, 6> m66_big; - algebra::getter::element(m66_big, 0, 0) = 1; - algebra::getter::element(m66_big, 0, 1) = 0; - algebra::getter::element(m66_big, 0, 2) = 3; - algebra::getter::element(m66_big, 0, 3) = 0; - algebra::getter::element(m66_big, 0, 4) = 0; - algebra::getter::element(m66_big, 0, 5) = 0; - - algebra::getter::element(m66_big, 1, 0) = 0; - algebra::getter::element(m66_big, 1, 1) = -2; - algebra::getter::element(m66_big, 1, 2) = 4; - algebra::getter::element(m66_big, 1, 3) = 0; - algebra::getter::element(m66_big, 1, 4) = 5; - algebra::getter::element(m66_big, 1, 5) = 0; - - algebra::getter::element(m66_big, 2, 0) = 0; - algebra::getter::element(m66_big, 2, 1) = 0; - algebra::getter::element(m66_big, 2, 2) = 3; - algebra::getter::element(m66_big, 2, 3) = 0; - algebra::getter::element(m66_big, 2, 4) = 0; - algebra::getter::element(m66_big, 2, 5) = 0; - - algebra::getter::element(m66_big, 3, 0) = 0; - algebra::getter::element(m66_big, 3, 1) = 0; - algebra::getter::element(m66_big, 3, 2) = 0; - algebra::getter::element(m66_big, 3, 3) = 4; - algebra::getter::element(m66_big, 3, 4) = 0; - algebra::getter::element(m66_big, 3, 5) = 0; - - algebra::getter::element(m66_big, 4, 0) = 0; - algebra::getter::element(m66_big, 4, 1) = 0; - algebra::getter::element(m66_big, 4, 2) = 0; - algebra::getter::element(m66_big, 4, 3) = 0; - algebra::getter::element(m66_big, 4, 4) = 9; - algebra::getter::element(m66_big, 4, 5) = 0; - - algebra::getter::element(m66_big, 5, 0) = -1; - algebra::getter::element(m66_big, 5, 1) = -1; - algebra::getter::element(m66_big, 5, 2) = -1; - algebra::getter::element(m66_big, 5, 3) = -1; - algebra::getter::element(m66_big, 5, 4) = -1; - algebra::getter::element(m66_big, 5, 5) = -1; + algebra::getter::element(m66_big, 0, 0) = 1.f; + algebra::getter::element(m66_big, 0, 1) = 0.f; + algebra::getter::element(m66_big, 0, 2) = 3.f; + algebra::getter::element(m66_big, 0, 3) = 0.f; + algebra::getter::element(m66_big, 0, 4) = 0.f; + algebra::getter::element(m66_big, 0, 5) = 0.f; + + algebra::getter::element(m66_big, 1, 0) = 0.f; + algebra::getter::element(m66_big, 1, 1) = -2.f; + algebra::getter::element(m66_big, 1, 2) = 4.f; + algebra::getter::element(m66_big, 1, 3) = 0.f; + algebra::getter::element(m66_big, 1, 4) = 5.f; + algebra::getter::element(m66_big, 1, 5) = 0.f; + + algebra::getter::element(m66_big, 2, 0) = 0.f; + algebra::getter::element(m66_big, 2, 1) = 0.f; + algebra::getter::element(m66_big, 2, 2) = 3.f; + algebra::getter::element(m66_big, 2, 3) = 0.f; + algebra::getter::element(m66_big, 2, 4) = 0.f; + algebra::getter::element(m66_big, 2, 5) = 0.f; + + algebra::getter::element(m66_big, 3, 0) = 0.f; + algebra::getter::element(m66_big, 3, 1) = 0.f; + algebra::getter::element(m66_big, 3, 2) = 0.f; + algebra::getter::element(m66_big, 3, 3) = 4.f; + algebra::getter::element(m66_big, 3, 4) = 0.f; + algebra::getter::element(m66_big, 3, 5) = 0.f; + + algebra::getter::element(m66_big, 4, 0) = 0.f; + algebra::getter::element(m66_big, 4, 1) = 0.f; + algebra::getter::element(m66_big, 4, 2) = 0.f; + algebra::getter::element(m66_big, 4, 3) = 0.f; + algebra::getter::element(m66_big, 4, 4) = 9.f; + algebra::getter::element(m66_big, 4, 5) = 0.f; + + algebra::getter::element(m66_big, 5, 0) = -1.f; + algebra::getter::element(m66_big, 5, 1) = -1.f; + algebra::getter::element(m66_big, 5, 2) = -1.f; + algebra::getter::element(m66_big, 5, 3) = -1.f; + algebra::getter::element(m66_big, 5, 4) = -1.f; + algebra::getter::element(m66_big, 5, 5) = -1.f; auto m66_big_det = typename TypeParam::matrix_actor().determinant(m66_big); - ASSERT_NEAR(m66_big_det, 216, 2 * this->m_isclose); + ASSERT_NEAR(m66_big_det, 216.f, 2.f * this->m_isclose); // Test 6 X 6 small matrix determinant typename TypeParam::template matrix<6, 6> m66_small; @@ -461,45 +500,20 @@ TYPED_TEST_P(test_host_basics, matrix22) { auto m66_small_det = typename TypeParam::matrix_actor().determinant(m66_small); - ASSERT_NEAR((m66_small_det - 4.30636e-11) / 4.30636e-11, 0, - 2 * this->m_isclose); -} - -// This defines the vector operation test suite -TYPED_TEST_P(test_host_basics, getter) { - - typename TypeParam::vector3 v3{1., 1., 1.}; - - // Normalization - typename TypeParam::vector3 v3n = algebra::vector::normalize(v3); - ASSERT_NEAR(v3n[0], 1. / std::sqrt(3.), this->m_epsilon); - ASSERT_NEAR(v3n[1], 1. / std::sqrt(3.), this->m_epsilon); - ASSERT_NEAR(v3n[2], 1. / std::sqrt(3.), this->m_epsilon); - - // Cross product - typename TypeParam::vector3 z = - algebra::vector::normalize(typename TypeParam::vector3{3., 2., 1.}); - typename TypeParam::vector3 x = - algebra::vector::normalize(typename TypeParam::vector3{2., -3., 0.}); - typename TypeParam::vector3 y = - algebra::vector::cross(z, algebra::vector::normalize(x)); - - // Check with dot product - ASSERT_NEAR(algebra::vector::dot(x, y), 0., this->m_epsilon); - ASSERT_NEAR(algebra::vector::dot(y, z), 0., this->m_epsilon); - ASSERT_NEAR(algebra::vector::dot(z, x), 0., this->m_epsilon); + ASSERT_NEAR((m66_small_det - 4.30636e-11f) / 4.30636e-11f, 0.f, + 2.f * this->m_isclose); } // This defines the transform3 test suite -TYPED_TEST_P(test_host_basics, transform3) { +TYPED_TEST_P(test_host_basics_transform, transform3) { // Preparation work typename TypeParam::vector3 z = - algebra::vector::normalize(typename TypeParam::vector3{3., 2., 1.}); + algebra::vector::normalize(typename TypeParam::vector3{3.f, 2.f, 1.f}); typename TypeParam::vector3 x = - algebra::vector::normalize(typename TypeParam::vector3{2., -3., 0.}); + algebra::vector::normalize(typename TypeParam::vector3{2.f, -3.f, 0.f}); typename TypeParam::vector3 y = algebra::vector::cross(z, x); - typename TypeParam::point3 t = {2., 3., 4.}; + typename TypeParam::point3 t = {2.f, 3.f, 4.f}; // Test constructor from t, z, x typename TypeParam::transform3 trf1(t, z, x); @@ -522,9 +536,9 @@ TYPED_TEST_P(test_host_basics, transform3) { ASSERT_NEAR(element_getter(rot, 2, 2), z[2], this->m_epsilon); auto trn = trf2.translation(); - ASSERT_NEAR(trn[0], 2., this->m_epsilon); - ASSERT_NEAR(trn[1], 3., this->m_epsilon); - ASSERT_NEAR(trn[2], 4., this->m_epsilon); + ASSERT_NEAR(trn[0], 2.f, this->m_epsilon); + ASSERT_NEAR(trn[1], 3.f, this->m_epsilon); + ASSERT_NEAR(trn[2], 4.f, this->m_epsilon); // Test constructor from matrix auto m44 = trf2.matrix(); @@ -560,13 +574,14 @@ TYPED_TEST_P(test_host_basics, transform3) { ASSERT_NEAR(element_getter(rotm, 2, 2), z[2], this->m_epsilon); auto trnm = trfm.translation(); - ASSERT_NEAR(trnm[0], 2., this->m_epsilon); - ASSERT_NEAR(trnm[1], 3., this->m_epsilon); - ASSERT_NEAR(trnm[2], 4., this->m_epsilon); + ASSERT_NEAR(trnm[0], 2.f, this->m_epsilon); + ASSERT_NEAR(trnm[1], 3.f, this->m_epsilon); + ASSERT_NEAR(trnm[2], 4.f, this->m_epsilon); // Check a contruction from an array[16] std::array matray_helper = { - 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}; + 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f}; typename TypeParam::transform3::template array_type<16> matray; for (unsigned int i = 0u; i < 16u; ++i) { matray[i] = matray_helper[i]; @@ -575,43 +590,43 @@ TYPED_TEST_P(test_host_basics, transform3) { // Re-evaluate rot and trn auto rotma = trfma.rotation(); - ASSERT_NEAR(element_getter(rotma, 0, 0), 1., this->m_epsilon); - ASSERT_NEAR(element_getter(rotma, 1, 0), 0., this->m_epsilon); - ASSERT_NEAR(element_getter(rotma, 2, 0), 0., this->m_epsilon); - ASSERT_NEAR(element_getter(rotma, 0, 1), 0., this->m_epsilon); - ASSERT_NEAR(element_getter(rotma, 1, 1), 1., this->m_epsilon); - ASSERT_NEAR(element_getter(rotma, 2, 1), 0., this->m_epsilon); - ASSERT_NEAR(element_getter(rotma, 0, 2), 0., this->m_epsilon); - ASSERT_NEAR(element_getter(rotma, 1, 2), 0., this->m_epsilon); - ASSERT_NEAR(element_getter(rotma, 2, 2), 1., this->m_epsilon); + ASSERT_NEAR(element_getter(rotma, 0, 0), 1.f, this->m_epsilon); + ASSERT_NEAR(element_getter(rotma, 1, 0), 0.f, this->m_epsilon); + ASSERT_NEAR(element_getter(rotma, 2, 0), 0.f, this->m_epsilon); + ASSERT_NEAR(element_getter(rotma, 0, 1), 0.f, this->m_epsilon); + ASSERT_NEAR(element_getter(rotma, 1, 1), 1.f, this->m_epsilon); + ASSERT_NEAR(element_getter(rotma, 2, 1), 0.f, this->m_epsilon); + ASSERT_NEAR(element_getter(rotma, 0, 2), 0.f, this->m_epsilon); + ASSERT_NEAR(element_getter(rotma, 1, 2), 0.f, this->m_epsilon); + ASSERT_NEAR(element_getter(rotma, 2, 2), 1.f, this->m_epsilon); auto trnma = trfma.translation(); - ASSERT_NEAR(trnma[0], 0., this->m_epsilon); - ASSERT_NEAR(trnma[1], 0., this->m_epsilon); - ASSERT_NEAR(trnma[2], 0., this->m_epsilon); + ASSERT_NEAR(trnma[0], 0.f, this->m_epsilon); + ASSERT_NEAR(trnma[1], 0.f, this->m_epsilon); + ASSERT_NEAR(trnma[2], 0.f, this->m_epsilon); } // This test global coordinate transforms -TYPED_TEST_P(test_host_basics, global_transformations) { +TYPED_TEST_P(test_host_basics_transform, global_transformations) { // Preparation work typename TypeParam::vector3 z = - algebra::vector::normalize(typename TypeParam::vector3{3., 2., 1.}); + algebra::vector::normalize(typename TypeParam::vector3{3.f, 2.f, 1.f}); typename TypeParam::vector3 x = - algebra::vector::normalize(typename TypeParam::vector3{2., -3., 0.}); + algebra::vector::normalize(typename TypeParam::vector3{2.f, -3.f, 0.f}); [[maybe_unused]] typename TypeParam::vector3 y = algebra::vector::cross(z, x); - typename TypeParam::point3 t = {2., 3., 4.}; + typename TypeParam::point3 t = {2.f, 3.f, 4.f}; typename TypeParam::transform3 trf(t, z, x); // Check that local origin translates into global translation - typename TypeParam::point3 lzero = {0., 0., 0.}; + typename TypeParam::point3 lzero = {0.f, 0.f, 0.f}; typename TypeParam::point3 gzero = trf.point_to_global(lzero); ASSERT_NEAR(gzero[0], t[0], this->m_epsilon); ASSERT_NEAR(gzero[1], t[1], this->m_epsilon); ASSERT_NEAR(gzero[2], t[2], this->m_epsilon); // Check a round trip for point - typename TypeParam::point3 lpoint = {3., 4., 5.}; + typename TypeParam::point3 lpoint = {3.f, 4.f, 5.f}; typename TypeParam::point3 gpoint = trf.point_to_global(lpoint); typename TypeParam::point3 lpoint_r = trf.point_to_local(gpoint); ASSERT_NEAR(lpoint[0], lpoint_r[0], this->m_isclose); @@ -622,19 +637,17 @@ TYPED_TEST_P(test_host_basics, global_transformations) { // vector should not change if transformed by a pure translation typename TypeParam::transform3 ttrf(t); - typename TypeParam::vector3 gvector = {1., 1., 1.}; + typename TypeParam::vector3 gvector = {1.f, 1.f, 1.f}; typename TypeParam::vector3 lvector = ttrf.vector_to_local(gvector); ASSERT_NEAR(gvector[0], lvector[0], this->m_isclose); ASSERT_NEAR(gvector[1], lvector[1], this->m_isclose); ASSERT_NEAR(gvector[2], lvector[2], this->m_isclose); // Check a round trip for vector - typename TypeParam::vector3 lvectorB = {7., 8., 9.}; + typename TypeParam::vector3 lvectorB = {7.f, 8.f, 9.f}; typename TypeParam::vector3 gvectorB = trf.vector_to_local(lvectorB); typename TypeParam::vector3 lvectorC = trf.vector_to_global(gvectorB); ASSERT_NEAR(lvectorB[0], lvectorC[0], this->m_isclose); ASSERT_NEAR(lvectorB[1], lvectorC[1], this->m_isclose); ASSERT_NEAR(lvectorB[2], lvectorC[2], this->m_isclose); -}*/ - -REGISTER_TYPED_TEST_SUITE_P(test_host_basics, local_vectors, vector3); +} diff --git a/tests/eigen/eigen_cmath.cpp b/tests/eigen/eigen_cmath.cpp index 6bfd5fa0..3e7be1be 100644 --- a/tests/eigen/eigen_cmath.cpp +++ b/tests/eigen/eigen_cmath.cpp @@ -1,6 +1,6 @@ /** Algebra plugins library, part of the ACTS project * - * (c) 2020-2022 CERN for the benefit of the ACTS project + * (c) 2020-2024 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -32,6 +32,14 @@ struct test_specialisation_name { } }; +// Register the tests +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_vector, local_vectors, vector3, + getter); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_matrix, matrix3, matrix64, + matrix22); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_transform, transform3, + global_transformations); + // Instantiate the test(s). typedef testing::Types< test_types< @@ -49,5 +57,9 @@ typedef testing::Types< algebra::matrix::determinant::preset0, algebra::matrix::inverse::preset0>>> eigen_cmath_types; -INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics, +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_vector, + eigen_cmath_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_matrix, + eigen_cmath_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_transform, eigen_cmath_types, test_specialisation_name); diff --git a/tests/eigen/eigen_eigen.cpp b/tests/eigen/eigen_eigen.cpp index 046ca406..19085018 100644 --- a/tests/eigen/eigen_eigen.cpp +++ b/tests/eigen/eigen_eigen.cpp @@ -1,6 +1,6 @@ /** Algebra plugins library, part of the ACTS project * - * (c) 2020-2022 CERN for the benefit of the ACTS project + * (c) 2020-2024 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -32,6 +32,14 @@ struct test_specialisation_name { } }; +// Register the tests +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_vector, local_vectors, vector3, + getter); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_matrix, matrix3, matrix64, + matrix22); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_transform, transform3, + global_transformations); + // Instantiate the test(s). typedef testing::Types< test_types, @@ -45,5 +53,9 @@ typedef testing::Types< algebra::eigen::transform3, int, algebra::eigen::matrix_type, algebra::matrix::actor>> eigen_eigen_types; -INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics, +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_vector, + eigen_eigen_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_matrix, + eigen_eigen_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_transform, eigen_eigen_types, test_specialisation_name); diff --git a/tests/fastor/fastor_fastor.cpp b/tests/fastor/fastor_fastor.cpp index 607bb09e..97317b02 100644 --- a/tests/fastor/fastor_fastor.cpp +++ b/tests/fastor/fastor_fastor.cpp @@ -1,6 +1,6 @@ /** Algebra plugins library, part of the ACTS project * - * (c) 2022 CERN for the benefit of the ACTS project + * (c) 2022-2024 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -33,6 +33,14 @@ struct test_specialisation_name { } }; +// Register the tests +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_vector, local_vectors, vector3, + getter); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_matrix, matrix3, matrix64, + matrix22); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_transform, transform3, + global_transformations); + // Instantiate the test(s). typedef testing::Types< test_types, @@ -47,5 +55,9 @@ typedef testing::Types< algebra::fastor::transform3, std::size_t, algebra::fastor::matrix_type, algebra::matrix::actor>> fastor_fastor_types; -INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics, +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_vector, + fastor_fastor_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_matrix, + fastor_fastor_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_transform, fastor_fastor_types, test_specialisation_name); diff --git a/tests/smatrix/smatrix_cmath.cpp b/tests/smatrix/smatrix_cmath.cpp index 73fb0eb8..15cc1f84 100644 --- a/tests/smatrix/smatrix_cmath.cpp +++ b/tests/smatrix/smatrix_cmath.cpp @@ -1,6 +1,6 @@ /** Algebra plugins library, part of the ACTS project * - * (c) 2020-2022 CERN for the benefit of the ACTS project + * (c) 2020-2024 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -32,6 +32,14 @@ struct test_specialisation_name { } }; +// Register the tests +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_vector, local_vectors, vector3, + getter); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_matrix, matrix3, matrix64, + matrix22); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_transform, transform3, + global_transformations); + // Instantiate the test(s). typedef testing::Types< test_types< @@ -51,5 +59,9 @@ typedef testing::Types< algebra::matrix::determinant::preset0, algebra::matrix::inverse::preset0>>> smatrix_cmath_types; -INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics, +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_vector, + smatrix_cmath_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_matrix, + smatrix_cmath_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_transform, smatrix_cmath_types, test_specialisation_name); diff --git a/tests/smatrix/smatrix_smatrix.cpp b/tests/smatrix/smatrix_smatrix.cpp index e7c6e1e4..ae91cd48 100644 --- a/tests/smatrix/smatrix_smatrix.cpp +++ b/tests/smatrix/smatrix_smatrix.cpp @@ -1,6 +1,6 @@ /** Algebra plugins library, part of the ACTS project * - * (c) 2020-2022 CERN for the benefit of the ACTS project + * (c) 2020-2024 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -32,6 +32,14 @@ struct test_specialisation_name { } }; +// Register the tests +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_vector, local_vectors, vector3, + getter); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_matrix, matrix3, matrix64, + matrix22); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_transform, transform3, + global_transformations); + // Instantiate the test(s). typedef testing::Types< test_types< @@ -46,5 +54,9 @@ typedef testing::Types< algebra::smatrix::transform3, unsigned int, algebra::smatrix::matrix_type, algebra::matrix::actor>> smatrix_smatrix_types; -INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics, +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_vector, + smatrix_smatrix_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_matrix, + smatrix_smatrix_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_transform, smatrix_smatrix_types, test_specialisation_name); diff --git a/tests/vc/vc_cmath.cpp b/tests/vc/vc_cmath.cpp index bdc8a145..4f05adbe 100644 --- a/tests/vc/vc_cmath.cpp +++ b/tests/vc/vc_cmath.cpp @@ -1,6 +1,6 @@ /** Algebra plugins library, part of the ACTS project * - * (c) 2020-2022 CERN for the benefit of the ACTS project + * (c) 2020-2024 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -32,22 +32,27 @@ struct test_specialisation_name { } }; +// Register the tests +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_vector, local_vectors, vector3, + getter); +/*REGISTER_TYPED_TEST_SUITE_P(test_host_basics_matrix, matrix3, matrix64, +matrix22); REGISTER_TYPED_TEST_SUITE_P(test_host_basics_transform, transform3, + global_transformations);*/ + // Instantiate the test(s). typedef testing::Types< test_types, algebra::vc::point3, algebra::vc::vector2, algebra::vc::vector3, algebra::vc::transform3, std::size_t, - algebra::vc::matrix_type, - algebra::matrix::actor< - float, algebra::matrix::determinant::preset0, - algebra::matrix::inverse::preset0>>, + algebra::vc::matrix_type, float>, test_types, algebra::vc::point3, algebra::vc::vector2, algebra::vc::vector3, algebra::vc::transform3, std::size_t, - algebra::vc::matrix_type, - algebra::matrix::actor< - double, algebra::matrix::determinant::preset0, - algebra::matrix::inverse::preset0>>> + algebra::vc::matrix_type, double>> vc_cmath_types; -INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics, +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_vector, + vc_cmath_types, test_specialisation_name); +/*INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_matrix, vc_cmath_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_transform, + vc_cmath_types, test_specialisation_name);*/ diff --git a/tests/vc/vc_vc.cpp b/tests/vc/vc_vc.cpp index 7aa83b30..ca11ac28 100644 --- a/tests/vc/vc_vc.cpp +++ b/tests/vc/vc_vc.cpp @@ -32,6 +32,14 @@ struct test_specialisation_name { } }; +// Register the tests +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_vector, local_vectors, vector3, + getter); +/*REGISTER_TYPED_TEST_SUITE_P(test_host_basics_matrix, matrix3, matrix64, + * matrix22);*/ +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_transform, transform3, + global_transformations); + // Instantiate the test(s). typedef testing::Types< test_types, algebra::vc::point3, @@ -43,5 +51,10 @@ typedef testing::Types< algebra::vc::transform3, std::size_t, algebra::vc::matrix_type, double>> vc_vc_types; -INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics, vc_vc_types, - test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_vector, + vc_vc_types, test_specialisation_name); +// @TODO: Implement +/*INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_matrix, + array_cmath_types, test_specialisation_name);*/ +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_transform, + vc_vc_types, test_specialisation_name); diff --git a/tests/vecmem/vecmem_cmath.cpp b/tests/vecmem/vecmem_cmath.cpp index 0600f8d0..e55aca24 100644 --- a/tests/vecmem/vecmem_cmath.cpp +++ b/tests/vecmem/vecmem_cmath.cpp @@ -1,6 +1,6 @@ /** Algebra plugins library, part of the ACTS project * - * (c) 2020-2022 CERN for the benefit of the ACTS project + * (c) 2020-2024 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -32,6 +32,14 @@ struct test_specialisation_name { } }; +// Register the tests +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_vector, local_vectors, vector3, + getter); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_matrix, matrix3, matrix64, + matrix22); +REGISTER_TYPED_TEST_SUITE_P(test_host_basics_transform, transform3, + global_transformations); + // Instantiate the test(s). typedef testing::Types< test_types, @@ -51,5 +59,9 @@ typedef testing::Types< algebra::matrix::determinant::preset0, algebra::matrix::inverse::preset0>>> vecmem_cmath_types; -INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics, +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_vector, + vecmem_cmath_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_matrix, + vecmem_cmath_types, test_specialisation_name); +INSTANTIATE_TYPED_TEST_SUITE_P(algebra_plugins, test_host_basics_transform, vecmem_cmath_types, test_specialisation_name);