diff --git a/frontend/eigen_cmath/include/algebra/eigen_cmath.hpp b/frontend/eigen_cmath/include/algebra/eigen_cmath.hpp index 724ca45e..8cc9bf74 100644 --- a/frontend/eigen_cmath/include/algebra/eigen_cmath.hpp +++ b/frontend/eigen_cmath/include/algebra/eigen_cmath.hpp @@ -43,7 +43,8 @@ template ALGEBRA_HOST_DEVICE inline auto vector(const Eigen::MatrixBase& m, std::size_t row, std::size_t col) { - return m.template block(row, col); + return m.template block(static_cast(row), + static_cast(col)); } /// @name Getter functions on @c algebra::eigen::matrix_type diff --git a/frontend/eigen_eigen/include/algebra/eigen_eigen.hpp b/frontend/eigen_eigen/include/algebra/eigen_eigen.hpp index 7dbcd183..bcf2e38f 100644 --- a/frontend/eigen_eigen/include/algebra/eigen_eigen.hpp +++ b/frontend/eigen_eigen/include/algebra/eigen_eigen.hpp @@ -40,7 +40,8 @@ template ALGEBRA_HOST_DEVICE inline auto vector(const Eigen::MatrixBase& m, std::size_t row, std::size_t col) { - return m.template block(row, col); + return m.template block(static_cast(row), + static_cast(col)); } /// @name Getter functions on @c algebra::eigen::matrix_type diff --git a/math/cmath/include/algebra/math/algorithms/matrix/determinant/partial_pivot_lud.hpp b/math/cmath/include/algebra/math/algorithms/matrix/determinant/partial_pivot_lud.hpp index e59d1675..b7b5bd3f 100644 --- a/math/cmath/include/algebra/math/algorithms/matrix/determinant/partial_pivot_lud.hpp +++ b/math/cmath/include/algebra/math/algorithms/matrix/determinant/partial_pivot_lud.hpp @@ -41,7 +41,7 @@ struct partial_pivot_lud { // Get the LU decomposition matrix equal to (L - I) + U const auto& lu = decomp_res.lu; - const auto& n_pivot = decomp_res.n_pivot; + const size_type n_pivot = static_cast(decomp_res.n_pivot); scalar_t det = element_getter_t()(lu, 0, 0); diff --git a/math/cmath/include/algebra/math/algorithms/matrix/inverse/partial_pivot_lud.hpp b/math/cmath/include/algebra/math/algorithms/matrix/inverse/partial_pivot_lud.hpp index 5ee15fa9..327b69cb 100644 --- a/math/cmath/include/algebra/math/algorithms/matrix/inverse/partial_pivot_lud.hpp +++ b/math/cmath/include/algebra/math/algorithms/matrix/inverse/partial_pivot_lud.hpp @@ -1,6 +1,6 @@ /** Algebra plugins library, part of the ACTS project * - * (c) 2022 CERN for the benefit of the ACTS project + * (c) 2022-2023 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -50,9 +50,10 @@ struct partial_pivot_lud { // Calculate inv(A) = inv(U) * inv(L) * P; for (size_type j = 0; j < N; j++) { for (size_type i = 0; i < N; i++) { - element_getter_t()(inv, i, j) = element_getter_t()(P, 0, i) == j - ? static_cast(1.0) - : static_cast(0.0); + element_getter_t()(inv, i, j) = + static_cast(element_getter_t()(P, 0, i)) == j + ? static_cast(1.0) + : static_cast(0.0); for (size_type k = 0; k < i; k++) { element_getter_t()(inv, i, j) -= diff --git a/math/cmath/include/algebra/math/impl/cmath_matrix.hpp b/math/cmath/include/algebra/math/impl/cmath_matrix.hpp index d76a66c8..eacb5be3 100644 --- a/math/cmath/include/algebra/math/impl/cmath_matrix.hpp +++ b/math/cmath/include/algebra/math/impl/cmath_matrix.hpp @@ -1,6 +1,6 @@ /** Algebra plugins library, part of the ACTS project * - * (c) 2022 CERN for the benefit of the ACTS project + * (c) 2022-2023 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -67,8 +67,8 @@ struct actor { /// Operator setting a block with a vector matrix template ALGEBRA_HOST_DEVICE void set_block(input_matrix_type &m, - const matrix_type &b, int row, - int col) { + const matrix_type &b, + size_type row, size_type col) { for (size_type i = 0; i < ROWS; ++i) { for (size_type j = 0; j < COLS; ++j) { element_getter()(m, i + row, j + col) = element_getter()(b, i, j); @@ -80,8 +80,8 @@ struct actor { template class vector_t, class input_matrix_type> ALGEBRA_HOST_DEVICE void set_block(input_matrix_type &m, - const vector_t &b, int row, - int col) { + const vector_t &b, + size_type row, size_type col) { for (size_type i = 0; i < ROWS; ++i) { element_getter()(m, i + row, col) = b[i]; } diff --git a/math/cmath/include/algebra/math/impl/cmath_transform3.hpp b/math/cmath/include/algebra/math/impl/cmath_transform3.hpp index 1e43157f..7e7c9f08 100644 --- a/math/cmath/include/algebra/math/impl/cmath_transform3.hpp +++ b/math/cmath/include/algebra/math/impl/cmath_transform3.hpp @@ -191,8 +191,8 @@ struct transform3 { ALGEBRA_HOST_DEVICE inline bool operator==(const transform3 &rhs) const { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { + for (size_type i = 0; i < 4; i++) { + for (size_type j = 0; j < 4; j++) { if (matrix_actor().element(_data, i, j) != matrix_actor().element(rhs._data, i, j)) { return false; diff --git a/math/eigen/include/algebra/math/impl/eigen_getter.hpp b/math/eigen/include/algebra/math/impl/eigen_getter.hpp index c990faf9..73216685 100644 --- a/math/eigen/include/algebra/math/impl/eigen_getter.hpp +++ b/math/eigen/include/algebra/math/impl/eigen_getter.hpp @@ -1,6 +1,6 @@ /** Algebra plugins, part of the ACTS project * - * (c) 2020-2022 CERN for the benefit of the ACTS project + * (c) 2020-2023 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -108,7 +108,7 @@ struct element_getter { Eigen::MatrixBase &m, size_type_1 row, size_type_2 col) const { - return m(row, col); + return m(static_cast(row), static_cast(col)); } /// Get const access to a matrix element template &m, size_type_1 row, size_type_2 col) const { - return m(row, col); + return m(static_cast(row), static_cast(col)); } }; // struct element_getter /// Function extracting an element from a matrix (const) -template +template < + typename derived_type, typename size_type_1, typename size_type_2, + std::enable_if_t::value && + std::is_convertible::value, + bool> = true> ALGEBRA_HOST_DEVICE inline auto element( const Eigen::MatrixBase &m, size_type_1 row, size_type_2 col) { @@ -134,12 +138,14 @@ ALGEBRA_HOST_DEVICE inline auto element( } /// Function extracting an element from a matrix (non-const) -template < - typename derived_type, typename size_type_1, typename size_type_2, - std::enable_if_t, - Eigen::MatrixBase >::value, - bool> = true> +template , + Eigen::MatrixBase >::value && + std::is_convertible::value && + std::is_convertible::value, + bool> = true> ALGEBRA_HOST_DEVICE inline auto &element(Eigen::MatrixBase &m, size_type_1 row, size_type_2 col) { @@ -161,4 +167,4 @@ struct block_getter { } }; // struct block_getter -} // namespace algebra::eigen::math +} // namespace algebra::eigen::math \ No newline at end of file diff --git a/math/eigen/include/algebra/math/impl/eigen_matrix.hpp b/math/eigen/include/algebra/math/impl/eigen_matrix.hpp index ec738773..25547151 100644 --- a/math/eigen/include/algebra/math/impl/eigen_matrix.hpp +++ b/math/eigen/include/algebra/math/impl/eigen_matrix.hpp @@ -1,6 +1,6 @@ /** Algebra plugins library, part of the ACTS project * - * (c) 2022 CERN for the benefit of the ACTS project + * (c) 2022-2023 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ @@ -52,7 +52,7 @@ struct actor { ALGEBRA_HOST_DEVICE inline scalar_t &element(matrix_type &m, size_type_1 row, size_type_2 col) const { - return m(row, col); + return m(static_cast(row), static_cast(col)); } /// Operator getting one value of a const matrix @@ -64,7 +64,7 @@ struct actor { ALGEBRA_HOST_DEVICE inline scalar_t element(const matrix_type &m, size_type_1 row, size_type_2 col) const { - return m(row, col); + return m(static_cast(row), static_cast(col)); } /// Operator getting a block of a const matrix @@ -77,7 +77,8 @@ struct actor { ALGEBRA_HOST_DEVICE matrix_type block(const input_matrix_type &m, size_type_1 row, size_type_2 col) { - return m.template block(row, col); + return m.template block(static_cast(row), + static_cast(col)); } /// Operator setting a block @@ -90,7 +91,8 @@ struct actor { ALGEBRA_HOST_DEVICE void set_block(input_matrix_type &m, const matrix_type &b, size_type_1 row, size_type_2 col) { - m.template block(row, col) = b; + m.template block(static_cast(row), + static_cast(col)) = b; } // Create zero matrix @@ -139,4 +141,4 @@ struct actor { } }; -} // namespace algebra::eigen::matrix +} // namespace algebra::eigen::matrix \ No newline at end of file diff --git a/math/smatrix/include/algebra/math/impl/smatrix_getter.hpp b/math/smatrix/include/algebra/math/impl/smatrix_getter.hpp index 37c8054c..f87264a0 100644 --- a/math/smatrix/include/algebra/math/impl/smatrix_getter.hpp +++ b/math/smatrix/include/algebra/math/impl/smatrix_getter.hpp @@ -30,7 +30,7 @@ template = 2, bool> = true> ALGEBRA_HOST inline scalar_t phi( const ROOT::Math::SVector &v) noexcept { - return TMath::ATan2(v[1], v[0]); + return static_cast(TMath::ATan2(v[1], v[0])); } template &v) noexcept { - return TMath::ATan2(v.apply(1), v.apply(0)); + return static_cast(TMath::ATan2(v.apply(1), v.apply(0))); } /** This method retrieves theta from a vector, vector base with rows >= 3 @@ -49,7 +49,8 @@ template = 3, bool> = true> ALGEBRA_HOST inline scalar_t theta( const ROOT::Math::SVector &v) noexcept { - return TMath::ATan2(TMath::Sqrt(v[0] * v[0] + v[1] * v[1]), v[2]); + return static_cast( + TMath::ATan2(TMath::Sqrt(v[0] * v[0] + v[1] * v[1]), v[2])); } template &v) noexcept { - return TMath::ATan2( + return static_cast(TMath::ATan2( TMath::Sqrt(v.apply(0) * v.apply(0) + v.apply(1) * v.apply(1)), - v.apply(2)); + v.apply(2))); } /** This method retrieves the norm of a vector, no dimension restriction @@ -69,14 +70,14 @@ ALGEBRA_HOST inline scalar_t theta( template ALGEBRA_HOST inline scalar_t norm(const ROOT::Math::SVector &v) { - return TMath::Sqrt(ROOT::Math::Dot(v, v)); + return static_cast(TMath::Sqrt(ROOT::Math::Dot(v, v))); } template ALGEBRA_HOST inline scalar_t norm( const ROOT::Math::VecExpr &v) { - return TMath::Sqrt(ROOT::Math::Dot(v, v)); + return static_cast(TMath::Sqrt(ROOT::Math::Dot(v, v))); } /** This method retrieves the pseudo-rapidity from a vector or vector base with @@ -88,7 +89,7 @@ template = 3, bool> = true> ALGEBRA_HOST inline scalar_t eta( const ROOT::Math::SVector &v) noexcept { - return TMath::ATanH(v[2] / norm(v)); + return static_cast(TMath::ATanH(v[2] / norm(v))); } template &v) noexcept { - return TMath::ATanH(v.apply(2) / norm(v)); + return static_cast(TMath::ATanH(v.apply(2) / norm(v))); } /** This method retrieves the perpenticular magnitude of a vector with rows >= 2 @@ -107,7 +108,7 @@ template = 2, bool> = true> ALGEBRA_HOST inline scalar_t perp( const ROOT::Math::SVector &v) noexcept { - return TMath::Sqrt(v[0] * v[0] + v[1] * v[1]); + return static_cast(TMath::Sqrt(v[0] * v[0] + v[1] * v[1])); } template &v) noexcept { - return TMath::Sqrt(v.apply(0) * v.apply(0) + v.apply(1) * v.apply(1)); + return static_cast( + TMath::Sqrt(v.apply(0) * v.apply(0) + v.apply(1) * v.apply(1))); } /// Functor used to access elements of Vc matrices diff --git a/tests/common/test_host_basics.hpp b/tests/common/test_host_basics.hpp index c8fd1c84..b64335b8 100644 --- a/tests/common/test_host_basics.hpp +++ b/tests/common/test_host_basics.hpp @@ -151,7 +151,7 @@ TYPED_TEST_P(test_host_basics, matrix64) { for (typename TypeParam::size_type i = 0; i < ROWS; ++i) { for (typename TypeParam::size_type j = 0; j < COLS; ++j) { algebra::getter::element(m, i, j) = - static_cast(0.5 * i + j); + 0.5f * static_cast(i + j); } } @@ -160,7 +160,7 @@ TYPED_TEST_P(test_host_basics, matrix64) { for (typename TypeParam::size_type i = 0; i < ROWS; ++i) { for (typename TypeParam::size_type j = 0; j < COLS; ++j) { const typename TypeParam::scalar ref = - static_cast(0.5 * i + j); + 0.5f * static_cast(i + j); ASSERT_NEAR(algebra::getter::element(m, i, j), ref, this->m_epsilon); ASSERT_NEAR(algebra::getter::element(m_const_ref, i, j), ref, this->m_epsilon); @@ -564,7 +564,7 @@ TYPED_TEST_P(test_host_basics, transform3) { std::array matray_helper = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}; typename TypeParam::transform3::template array_type<16> matray; - for (int i = 0; i < 16; ++i) { + for (unsigned int i = 0u; i < 16u; ++i) { matray[i] = matray_helper[i]; } typename TypeParam::transform3 trfma(matray);