3 #include <valgrind/valgrind.h> 5 #include <boost/test/unit_test.hpp> 10 template <
typename precision_t>
11 void test_fftw_traits() {
15 using fftw_complex_type =
typename tested::fftw_complex_type;
17 fftw_complex_type* in =
static_cast<fftw_complex_type*
>(
18 tested::allocate(nsamples *
sizeof(fftw_complex_type)));
19 fftw_complex_type* tmp =
static_cast<fftw_complex_type*
>(
20 tested::allocate(nsamples *
sizeof(fftw_complex_type)));
21 fftw_complex_type* out =
static_cast<fftw_complex_type*
>(
22 tested::allocate(nsamples *
sizeof(fftw_complex_type)));
24 std::size_t h = nsamples / 2;
25 for (std::size_t i = 0; i != h; ++i) {
26 in[i][0] = i - h / 4.0;
28 in[i + h][0] = h / 4.0 - i;
32 using plan_type =
typename tested::fftw_plan_type;
34 nsamples, in, tmp, FFTW_ESTIMATE | FFTW_UNALIGNED | FFTW_PRESERVE_INPUT);
36 nsamples, tmp, out, FFTW_ESTIMATE | FFTW_UNALIGNED | FFTW_PRESERVE_INPUT);
38 tested::execute_plan(dir, in, tmp);
39 tested::execute_plan(inv, tmp, out);
40 for (std::size_t i = 0; i != std::size_t(nsamples); ++i) {
45 BOOST_CHECK_MESSAGE(res,
"collections are not within tolerance=" << tol);
47 tested::destroy_plan(inv);
48 tested::destroy_plan(dir);
60 test_fftw_traits<double>();
67 test_fftw_traits<float>();
74 if (RUNNING_ON_VALGRIND > 0) {
75 BOOST_TEST_MESSAGE(
"long double not supported by valgrind, skip test");
78 test_fftw_traits<long double>();
Wrap fftw_* types and operations to treat floating point values generically.
plan< in_array_type, out_array_type > create_forward_plan(in_array_type const &in, out_array_type &out, int flags=default_plan_flags)
Create a plan to compute many DFTs given the input and output arrays.
plan< in_array_type, out_array_type > create_backward_plan(in_array_type const &in, out_array_type &out, int flags=default_plan_flags)
Create a plan to compute many inverse DFT given the input and output arrays.
bool check_collection_close_enough(collection_t const &a, collection_t const &b, int tol=1, int max_differences_printed=JB_TESTING_MAX_DIFFERENCES_PRINTED)
Given two collections of numbers of the same value type, find the differences that are out of a given...
std::size_t nsamples(container_type const &a)
Count the elements in the last dimension of a vector-like container.
BOOST_AUTO_TEST_CASE(fftw_traits_double)