cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: FFTW 3.3.8: Fixed-size Arrays in C cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167:
cannam@167:

cannam@167: Next: , Previous: , Up: Multi-dimensional Array Format   [Contents][Index]

cannam@167:
cannam@167:
cannam@167: cannam@167:

3.2.3 Fixed-size Arrays in C

cannam@167: cannam@167: cannam@167:

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

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

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

cannam@167:

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

cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: