Chris@19: Chris@19:
Chris@19:Chris@19: Next: Dynamic Arrays in C, Chris@19: Previous: Column-major Format, Chris@19: Up: Multi-dimensional Array Format Chris@19:
Chris@19: A multi-dimensional array whose size is declared at compile time in C Chris@19: is already in row-major order. You don't have to do anything Chris@19: special to transform it. For example: Chris@19: Chris@19:
{ Chris@19: fftw_complex data[N0][N1][N2]; Chris@19: fftw_plan plan; Chris@19: ... Chris@19: plan = fftw_plan_dft_3d(N0, N1, N2, &data[0][0][0], &data[0][0][0], Chris@19: FFTW_FORWARD, FFTW_ESTIMATE); Chris@19: ... Chris@19: } Chris@19:Chris@19:
This will plan a 3d in-place transform of size N0 x N1 x N2
.
Chris@19: Notice how we took the address of the zero-th element to pass to the
Chris@19: planner (we could also have used a typecast).
Chris@19:
Chris@19:
However, we tend to discourage users from declaring their
Chris@19: arrays in this way, for two reasons. First, this allocates the array
Chris@19: on the stack (“automatic” storage), which has a very limited size on
Chris@19: most operating systems (declaring an array with more than a few
Chris@19: thousand elements will often cause a crash). (You can get around this
Chris@19: limitation on many systems by declaring the array as
Chris@19: static
and/or global, but that has its own drawbacks.)
Chris@19: Second, it may not optimally align the array for use with a SIMD
Chris@19: FFTW (see SIMD alignment and fftw_malloc). Instead, we recommend
Chris@19: using fftw_malloc
, as described below.
Chris@19:
Chris@19:
Chris@19:
Chris@19: