Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion include/xsimd/arch/common/xsimd_common_trigo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,14 @@ namespace xsimd
XSIMD_INLINE batch<T, A> atan2(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
{
using batch_type = batch<T, A>;
#ifdef __FAST_MATH__
const batch_type q = abs(self / other);
const batch_type q_p = abs(other / self);
#else
const batch_type q = abs(self / other);
const batch_type z = detail::kernel_atan(q, batch_type(1.) / q);
const batch_type q_p = 1. / q;
#endif
const batch_type z = detail::kernel_atan(q, q_p);
return select(other > batch_type(0.), z, constants::pi<batch_type>() - z) * signnz(self);
}

Expand Down
14 changes: 11 additions & 3 deletions test/test_xsimd_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,17 @@ struct xsimd_api_float_types_functions
}
void test_atan2()
{
value_type val0(0);
value_type val1(1);
CHECK_EQ(extract(xsimd::atan2(T(val0), T(val1))), std::atan2(val0, val1));
{
value_type val0(0);
value_type val1(1);
CHECK_EQ(extract(xsimd::atan2(T(val0), T(val1))), std::atan2(val0, val1));
}

{
value_type val0(1);
value_type val1(0);
CHECK_EQ(extract(xsimd::atan2(T(val0), T(val1))), std::atan2(val0, val1));
}
}
void test_atanh()
{
Expand Down
Loading