Skip to content

Commit

Permalink
Test nearbyint_as_int using xsimd's scalar version instead of lround
Browse files Browse the repository at this point in the history
Fix #948
  • Loading branch information
serge-sans-paille committed Oct 16, 2023
1 parent 0f51f66 commit 0f1ebf8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
4 changes: 2 additions & 2 deletions include/xsimd/arch/generic/xsimd_generic_math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1855,7 +1855,7 @@ namespace xsimd
{
using U = as_integer_t<float>;
return kernel::detail::apply_transform<U>([](float x) noexcept -> U
{ return std::lroundf(x); },
{ return std::nearbyintf(x); },
self);
}

Expand All @@ -1865,7 +1865,7 @@ namespace xsimd
{
using U = as_integer_t<double>;
return kernel::detail::apply_transform<U>([](double x) noexcept -> U
{ return std::llround(x); },
{ return std::nearbyint(x); },
self);
}

Expand Down
17 changes: 2 additions & 15 deletions test/test_rounding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@

#include "test_utils.hpp"

namespace detail
{
inline xsimd::as_integer_t<float> nearbyint_as_int(float a)
{
return std::lroundf(a);
}

inline xsimd::as_integer_t<double> nearbyint_as_int(double a)
{
return std::llround(a);
}
}

template <class B>
struct rounding_test
{
Expand Down Expand Up @@ -163,7 +150,7 @@ struct rounding_test
std::array<int_value_type, nb_input> res;
std::transform(input.cbegin(), input.cend(), expected.begin(),
[](const value_type& v)
{ return detail::nearbyint_as_int(v); });
{ return xsimd::nearbyint_as_int(v); });
batch_type in;
int_batch_type out;
for (size_t i = 0; i < nb_batches; i += size)
Expand All @@ -174,7 +161,7 @@ struct rounding_test
}
for (size_t i = nb_batches; i < nb_input; ++i)
{
res[i] = detail::nearbyint_as_int(input[i]);
res[i] = xsimd::nearbyint_as_int(input[i]);
}
size_t diff = detail::get_nb_diff(res, expected);
INFO("nearbyint_as_int");
Expand Down

0 comments on commit 0f1ebf8

Please sign in to comment.