Skip to content

Commit

Permalink
Avoid lgamma issue on arm on lgamma(2) by hardcoding the output result
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-sans-paille committed May 18, 2024
1 parent 5ac7edf commit 62a3e13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/xsimd/arch/generic/xsimd_generic_math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,8 @@ namespace xsimd
return r;
}
batch_type r2 = select(ltza, r, r1);
// FIXME: added to avoid producing -nan here
r2 = select((a == 1) || (a == 2), batch_type(0), r2);
return select(a == constants::minusinfinity<batch_type>(), constants::nan<batch_type>(), select(inf_result, constants::infinity<batch_type>(), r2));
}

Expand Down
6 changes: 4 additions & 2 deletions test/test_xsimd_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,10 @@ struct xsimd_api_float_types_functions
}
void test_lgamma()
{
value_type val(2);
CHECK_EQ(extract(xsimd::lgamma(T(val))), std::lgamma(val));
value_type val0(2);
CHECK_EQ(extract(xsimd::lgamma(T(val0))), std::lgamma(val0));
value_type val1(.5);
CHECK_EQ(extract(xsimd::lgamma(T(val1))), std::lgamma(val1));
}
void test_log()
{
Expand Down

0 comments on commit 62a3e13

Please sign in to comment.