Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: FFTW 3.3.8: Fixed-size Arrays in C Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82:
Chris@82:

Chris@82: Next: , Previous: , Up: Multi-dimensional Array Format   [Contents][Index]

Chris@82:
Chris@82:
Chris@82: Chris@82:

3.2.3 Fixed-size Arrays in C

Chris@82: Chris@82: Chris@82:

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

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

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

Chris@82:

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

Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: