Chris@10: Chris@10: Chris@10: Fixed-size Arrays in C - FFTW 3.3.3 Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10:
Chris@10: Chris@10: Chris@10:

Chris@10: Next: , Chris@10: Previous: Column-major Format, Chris@10: Up: Multi-dimensional Array Format Chris@10:


Chris@10:
Chris@10: Chris@10:

3.2.3 Fixed-size Arrays in C

Chris@10: Chris@10:

Chris@10: A multi-dimensional array whose size is declared at compile time in C Chris@10: is already in row-major order. You don't have to do anything Chris@10: special to transform it. For example: Chris@10: Chris@10:

     {
Chris@10:           fftw_complex data[N0][N1][N2];
Chris@10:           fftw_plan plan;
Chris@10:           ...
Chris@10:           plan = fftw_plan_dft_3d(N0, N1, N2, &data[0][0][0], &data[0][0][0],
Chris@10:                                   FFTW_FORWARD, FFTW_ESTIMATE);
Chris@10:           ...
Chris@10:      }
Chris@10: 
Chris@10:

This will plan a 3d in-place transform of size N0 x N1 x N2. Chris@10: Notice how we took the address of the zero-th element to pass to the Chris@10: planner (we could also have used a typecast). Chris@10: Chris@10:

However, we tend to discourage users from declaring their Chris@10: arrays in this way, for two reasons. First, this allocates the array Chris@10: on the stack (“automatic” storage), which has a very limited size on Chris@10: most operating systems (declaring an array with more than a few Chris@10: thousand elements will often cause a crash). (You can get around this Chris@10: limitation on many systems by declaring the array as Chris@10: static and/or global, but that has its own drawbacks.) Chris@10: Second, it may not optimally align the array for use with a SIMD Chris@10: FFTW (see SIMD alignment and fftw_malloc). Instead, we recommend Chris@10: using fftw_malloc, as described below. Chris@10: Chris@10: Chris@10: Chris@10: