JayBeams  0.1
Another project to have fun coding.
ut_aligned_multi_array.cpp
Go to the documentation of this file.
2 
3 #include <boost/test/unit_test.hpp>
4 
5 /**
6  * Helper functions to test aligned arrays
7  */
8 namespace {
9 
10 std::size_t check_dynamic_size(int F, int S, int N) {
11  jb::fftw::aligned_multi_array<float, 4> A(boost::extents[F][S][4][N]);
12  return A.num_elements();
13 }
14 
15 } // anonymous namespace
16 
17 BOOST_AUTO_TEST_CASE(multiarray_basic) {
18  int const F = 2;
19  int const S = 128;
20  int const N = 16384;
21 
22  auto actual = check_dynamic_size(F, S, N);
23  BOOST_CHECK_EQUAL(actual, std::size_t(F * S * 4 * N));
24 
25  jb::fftw::aligned_multi_array<int, 4> A(boost::extents[F][S][4][N]);
26  boost::multi_array_ref<int, 2> R(A.data(), boost::extents[F * S * 4][N]);
27 
28  BOOST_CHECK_EQUAL(R.size(), std::size_t(F * S * 4));
29  BOOST_CHECK_EQUAL(R[0].size(), std::size_t(N));
30  BOOST_CHECK_EQUAL(R.num_elements(), std::size_t(F * S * 4 * N));
31 
32  A[0][0][0][0] = 100;
33  BOOST_CHECK_EQUAL(A[0][0][0][0], 100);
34 
35  R[0][0] = 200;
36  BOOST_CHECK_EQUAL(A[0][0][0][0], 200);
37 
38  boost::multi_array_ref<int, 2> R2(R);
39  R2[0][0] = 300;
40  BOOST_CHECK_EQUAL(A[0][0][0][0], 300);
41 
42  for (auto const& v : R) {
43  BOOST_CHECK_EQUAL(v.size(), N);
44  }
45 }
boost::multi_array< value_type, num_dims, jb::fftw::allocator< value_type > > aligned_multi_array
Alias boost::multi_array with properly allocated storage for FFTW3.
BOOST_AUTO_TEST_CASE(multiarray_basic)