Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: FFTW 3.3.5: Fixed-size Arrays in C Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42:
Chris@42:

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

Chris@42:
Chris@42:
Chris@42: Chris@42:

3.2.3 Fixed-size Arrays in C

Chris@42: Chris@42: Chris@42:

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

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

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

Chris@42:

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

Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: