cannam@95: cannam@95: cannam@95: Fixed-size Arrays in C - FFTW 3.3.3 cannam@95: cannam@95: cannam@95: cannam@95: cannam@95: cannam@95: cannam@95: cannam@95: cannam@95: cannam@95: cannam@95: cannam@95: cannam@95: cannam@95:
cannam@95: cannam@95: cannam@95:

cannam@95: Next: , cannam@95: Previous: Column-major Format, cannam@95: Up: Multi-dimensional Array Format cannam@95:


cannam@95:
cannam@95: cannam@95:

3.2.3 Fixed-size Arrays in C

cannam@95: cannam@95:

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

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

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

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