cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: FFTW 3.3.5: Fixed-size Arrays in C cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127:
cannam@127:

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

cannam@127:
cannam@127:
cannam@127: cannam@127:

3.2.3 Fixed-size Arrays in C

cannam@127: cannam@127: cannam@127:

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

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

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

cannam@127:

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

cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: