3 #include <valgrind/valgrind.h> 5 #include <boost/test/unit_test.hpp> 13 template <
typename precision_t>
14 void test_plan_complex2complex() {
18 typedef std::complex<precision_t> complex;
20 std::vector<complex> in(nsamples);
21 std::vector<complex> tmp(nsamples);
22 std::vector<complex> out(nsamples);
24 std::size_t h = nsamples / 2;
25 for (std::size_t i = 0; i != h; ++i) {
26 in[i] = complex(i - h / 4.0, 0);
27 in[i + h] = complex(h / 4.0 - i, 0);
34 inv.execute(tmp, out);
35 for (std::size_t i = 0; i != std::size_t(nsamples); ++i) {
41 template <
typename precision_t>
42 void test_plan_real2complex() {
43 int nsamples = 1 << 15;
46 typedef std::complex<precision_t> complex;
48 std::vector<precision_t> in(nsamples);
49 std::vector<complex> tmp(nsamples);
50 std::vector<precision_t> out(nsamples);
52 std::size_t h = nsamples / 2;
53 for (std::size_t i = 0; i != h; ++i) {
55 in[i + h] = h / 4.0 - i;
62 inv.execute(tmp, out);
63 for (std::size_t i = 0; i != std::size_t(nsamples); ++i) {
69 template <
typename precision_t>
70 void test_plan_errors() {
71 int nsamples = 1 << 15;
73 typedef std::complex<precision_t> complex;
75 std::vector<complex> in(nsamples);
76 std::vector<complex> tmp(nsamples);
77 std::vector<complex> err(nsamples / 2);
83 BOOST_CHECK_THROW(dir.execute(in, err), std::exception);
92 test_plan_complex2complex<double>();
99 test_plan_real2complex<double>();
106 test_plan_errors<double>();
113 test_plan_complex2complex<float>();
120 test_plan_real2complex<float>();
127 test_plan_errors<float>();
134 if (RUNNING_ON_VALGRIND > 0) {
135 BOOST_TEST_MESSAGE(
"long double not supported by valgrind, skip test");
138 test_plan_complex2complex<long double>();
145 if (RUNNING_ON_VALGRIND > 0) {
146 BOOST_TEST_MESSAGE(
"long double not supported by valgrind, skip test");
149 test_plan_real2complex<long double>();
156 if (RUNNING_ON_VALGRIND > 0) {
157 BOOST_TEST_MESSAGE(
"long double not supported by valgrind, skip test");
160 test_plan_errors<long double>();
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.
BOOST_AUTO_TEST_CASE(fftw_plan_complex_double)
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.