Skip to content

Commit 67067ad

Browse files
Accept a difference of epsilon when computing xsimd::pow
1 parent 6c86b23 commit 67067ad

File tree

1 file changed

+13
-38
lines changed

1 file changed

+13
-38
lines changed

test/test_complex_power.cpp

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,19 @@ struct complex_power_test
9595

9696
void test_pow()
9797
{
98-
test_conditional_pow<real_value_type>();
98+
std::transform(lhs_np.cbegin(), lhs_np.cend(), rhs.cbegin(), expected.begin(),
99+
[](const value_type& l, const value_type& r)
100+
{ using std::pow; return pow(l, r); });
101+
batch_type lhs_in, rhs_in, out;
102+
for (size_t i = 0; i < nb_input; i += size)
103+
{
104+
detail::load_batch(lhs_in, lhs_np, i);
105+
detail::load_batch(rhs_in, rhs, i);
106+
out = pow(lhs_in, rhs_in);
107+
detail::store_batch(out, res, i);
108+
}
109+
size_t diff = detail::get_nb_diff_near(res, expected, std::numeric_limits<real_value_type>::epsilon());
110+
CHECK_EQ(diff, 0);
99111
}
100112

101113
void test_sqrt_nn()
@@ -161,43 +173,6 @@ struct complex_power_test
161173
size_t diff = detail::get_nb_diff(res, expected);
162174
CHECK_EQ(diff, 0);
163175
}
164-
165-
private:
166-
void test_pow_impl()
167-
{
168-
std::transform(lhs_np.cbegin(), lhs_np.cend(), rhs.cbegin(), expected.begin(),
169-
[](const value_type& l, const value_type& r)
170-
{ using std::pow; return pow(l, r); });
171-
batch_type lhs_in, rhs_in, out;
172-
for (size_t i = 0; i < nb_input; i += size)
173-
{
174-
detail::load_batch(lhs_in, lhs_np, i);
175-
detail::load_batch(rhs_in, rhs, i);
176-
out = pow(lhs_in, rhs_in);
177-
detail::store_batch(out, res, i);
178-
}
179-
size_t diff = detail::get_nb_diff(res, expected);
180-
CHECK_EQ(diff, 0);
181-
}
182-
183-
template <class T, typename std::enable_if<!std::is_same<T, float>::value, int>::type = 0>
184-
void test_conditional_pow()
185-
{
186-
test_pow_impl();
187-
}
188-
189-
template <class T, typename std::enable_if<std::is_same<T, float>::value, int>::type = 0>
190-
void test_conditional_pow()
191-
{
192-
193-
#if (XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX512_VERSION) || (XSIMD_ARM_INSTR_SET >= XSIMD_ARM7_NEON_VERSION)
194-
#if DEBUG_ACCURACY
195-
test_pow_impl();
196-
#endif
197-
#else
198-
test_pow_impl();
199-
#endif
200-
}
201176
};
202177

203178
TEST_CASE_TEMPLATE("[complex power]", B, BATCH_COMPLEX_TYPES)

0 commit comments

Comments
 (0)