Skip to content

Commit

Permalink
Test and fix 0^-x
Browse files Browse the repository at this point in the history
Fix #995
  • Loading branch information
serge-sans-paille committed Dec 29, 2023
1 parent bc29d96 commit 06894d6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/test_power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct power_test
using vector_type = std::vector<value_type>;

size_t nb_input;
vector_type zero_input;
vector_type zlhs_input;
vector_type lhs_input;
vector_type rhs_input;
Expand All @@ -32,11 +33,13 @@ struct power_test
power_test()
{
nb_input = size * 10000;
zero_input.resize(nb_input);
zlhs_input.resize(nb_input);
lhs_input.resize(nb_input);
rhs_input.resize(nb_input);
for (size_t i = 0; i < nb_input; ++i)
{
zero_input[i] = 0;
lhs_input[i] = value_type(i) / 4 + value_type(1.2) * std::sqrt(value_type(i + 0.25));
zlhs_input[i] = lhs_input[i] * (i % 2);
rhs_input[i] = value_type(10.2) / (i + 2) + value_type(0.25);
Expand Down Expand Up @@ -100,6 +103,23 @@ struct power_test
CHECK_EQ(diff, 0);
#endif
}
// pow 0^-x
{
std::transform(zero_input.cbegin(), zero_input.cend(), rhs_input.cbegin(), expected.begin(),
[](const value_type& z, const value_type& r)
{ return std::pow(z, -r); });
batch_type zero_in, rhs_in, out;
for (size_t i = 0; i < nb_input; i += size)
{
detail::load_batch(zero_in, zero_input, i);
detail::load_batch(rhs_in, rhs_input, i);
out = pow(zero_in, -rhs_in);
detail::store_batch(out, res, i);
}
size_t diff = detail::get_nb_diff(res, expected);
INFO("pow(0, -x)");
CHECK_EQ(diff, 0);
}
// ipow
{
long k = 0;
Expand Down

0 comments on commit 06894d6

Please sign in to comment.