3 #include <valgrind/valgrind.h> 5 #include <boost/multi_array.hpp> 6 #include <boost/test/unit_test.hpp> 16 template <
typename precision_t>
17 void test_plan_complex2complex() {
33 typedef std::complex<precision_t> complex;
39 boost::multi_array<complex, 3> in(boost::extents[F][S][nsamples]);
40 boost::multi_array<complex, 3> tmp(boost::extents[F][S][nsamples]);
41 boost::multi_array<complex, 3> out(boost::extents[F][S][nsamples]);
45 for (
auto subarray : in) {
46 for (
auto vector : subarray) {
47 std::size_t h = nsamples / 2;
48 for (std::size_t i = 0; i != h; ++i) {
49 vector[i] = complex(i - h / 4.0, 0);
50 vector[i + h] = complex(h / 4.0 - i, 0);
65 inv.execute(tmp, out);
70 for (
auto subarray : out) {
71 for (
auto vector : subarray) {
72 for (
auto& element : vector) {
84 template <
typename precision_t>
85 void test_plan_real2complex() {
91 int const nsamples = 1 << 15;
101 typedef std::complex<precision_t> complex;
107 boost::multi_array<precision_t, 3> in(boost::extents[F][S][nsamples]);
108 boost::multi_array<complex, 3> tmp(boost::extents[F][S][nsamples]);
109 boost::multi_array<precision_t, 3> out(boost::extents[F][S][nsamples]);
113 for (
auto subarray : in) {
114 for (
auto vector : subarray) {
115 std::size_t h = nsamples / 2;
116 for (std::size_t i = 0; i != h; ++i) {
117 vector[i] = i - h / 4.0;
118 vector[i + h] = h / 4.0 - i;
131 dir.execute(in, tmp);
133 inv.execute(tmp, out);
137 for (
auto subarray : out) {
138 for (
auto vector : subarray) {
139 for (
auto& element : vector) {
147 BOOST_CHECK_MESSAGE(res,
"collections are not within tolerance=" << tol);
151 template <
typename precision_t>
152 void test_plan_errors() {
158 int const nsamples = 1 << 15;
162 typedef std::complex<precision_t> complex;
164 boost::multi_array<complex, 3> a0(boost::extents[F][S][nsamples]);
165 boost::multi_array<complex, 3> a1(boost::extents[F][S / 2][nsamples]);
166 boost::multi_array<complex, 3> a2(boost::extents[F][S][nsamples / 2]);
167 boost::multi_array<complex, 3> a3(boost::extents[F][S][0]);
168 boost::multi_array<complex, 3> a4(boost::extents[F][S][nsamples]);
178 boost::multi_array<precision_t, 3> b1(boost::extents[F][S / 2][nsamples]);
179 boost::multi_array<precision_t, 3> b2(boost::extents[F][S][nsamples / 2]);
180 boost::multi_array<precision_t, 3> b3(boost::extents[F][S][0]);
189 BOOST_CHECK_THROW(dir.execute(a0, a1), std::exception);
199 test_plan_complex2complex<double>();
207 test_plan_complex2complex<float>();
215 if (RUNNING_ON_VALGRIND > 0) {
216 BOOST_TEST_MESSAGE(
"long double not supported by valgrind, skip test");
219 test_plan_complex2complex<long double>();
228 test_plan_errors<double>();
237 test_plan_errors<float>();
246 if (RUNNING_ON_VALGRIND > 0) {
247 BOOST_TEST_MESSAGE(
"long double not supported by valgrind, skip test");
250 test_plan_errors<long double>();
258 test_plan_real2complex<double>();
266 test_plan_real2complex<float>();
274 if (RUNNING_ON_VALGRIND > 0) {
275 BOOST_TEST_MESSAGE(
"long double not supported by valgrind, skip test");
278 test_plan_real2complex<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.
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_plan_many_complex_double)