I would like to know how a 3d complex array is laid out in a computer's memory? An example in Fortran would be of some help.
I'm trying to do a 1-dimensional sine transformation of a 3d complex array and I'm using a routine from FFTW. http://www.fftw.org/fftw3_doc/Advanced-Complex-DFTs.html#Advanced-Complex-DFTs
So I need to figure out the values for the parameters(i.e.howmany, istride and idist) in the FFT routine. Thanks.
Complex Fortran scalar values are stored as pairs of values [real, imaginary]. All Fortran arrays are column-major order, that means that the first index is the most frequently changing one. And each element of a complex array is a (real, imaginary) pair.
A Fortran array
complex(c_float_complex) :: A(nx, ny, nz)
is like a C array
float A[nz][ny][nx][2]
(yes, I know there is an optional complex type in modern C as well).
So the sequence goes like this:
(re(1,1,1),im(1,1,1)), (re(2,1,1,),im(2,1,1)), (re(3,1,1,),im(3,1,1)) ... (re(nx,1,1,),im(nx,1,1)), (re(1,2,1),im(1,2,1)) ...
Se the column-major order link for more details.