From dceb779ecd822f55b4ae78f760371b0e08a889f2 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Mon, 12 Sep 2022 15:51:27 -0700 Subject: [PATCH] Fix test for pow with mixed integer types. We do not convert the exponent if it is an integer type. --- test/array_cwise.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp index 5a4c28278..319eba303 100644 --- a/test/array_cwise.cpp +++ b/test/array_cwise.cpp @@ -144,6 +144,22 @@ Scalar calc_overflow_threshold(const ScalarExponent exponent) { } } +template ::IsInteger> +struct ref_pow { + static Base run(Base base, Exponent exponent) { + EIGEN_USING_STD(pow); + return pow(base, static_cast(exponent)); + } +}; + +template +struct ref_pow { + static Base run(Base base, Exponent exponent) { + EIGEN_USING_STD(pow); + return pow(base, exponent); + } +}; + template void test_exponent(Exponent exponent) { const Base max_abs_bases = static_cast(10000); @@ -166,9 +182,8 @@ void test_exponent(Exponent exponent) { if (exponent < 0 && base == 0) continue; x.setConstant(base); y = x.pow(exponent); - EIGEN_USING_STD(pow); - Base e = pow(base, static_cast(exponent)); for (Base a : y) { + Base e = ref_pow::run(base, exponent); bool pass = (a == e); if (!NumTraits::IsInteger) { pass = pass || (((numext::isfinite)(e) && internal::isApprox(a, e)) ||