问题
I have a 3-dimensional array U(z,y,x) and I want to perform a complex Fourier transform in z for all values of y and x. I am planning to use the FFTW library. I figured out from the FFTW manual that there is a way to perform multiple 1d transforms at once(mentioned below).
CALL dfftw_plan_many_dft(PLAN, rank, n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, FFTW_MEASURE)
I don't clearly understand what inembed
and outembed
means. Could you provide more insight into this as I am new to Fortran and I am not entirely sure how to use this?
EDIT1: updated the Fortran code
回答1:
It's described here actually quite well: http://www.fftw.org/fftw3_doc/Advanced-Complex-DFTs.html
inembed
and outembed
allow one to embed the incoming and outgoing data into a larger dataset:
Imagine that you would like to FFT the sub-matrix of in
denoted by the O
elements. And possibly outembed the result into the out
variable's O
fields.
X X X X X X X X X X X
X X X X X X O O X X X
in = X O O X X out = X O O X X X
X O O X X
X X X X X
inembed
then would be [2, 1] (column-major) and outmbed
[1, 1]. Then stride would take you from slice to slice / volume to volume etc. Using stride
and embed
you tell FFTW, how to find the O
elements for each sub-data to transform and equally, where to put them in a larger dataset.
Hope this explains it. If you already now the the BLAS interface, you will find that inembed
and outembed
correspond to LDA
, LDB
of many routines. Of course BLAS routines are limited to matrices, i.e. assume 2 dimensional operations. FFTs you may of course do in as many dimensions as you like.
If you set inembed
and outembed
as NULL
, then FFTW assumes that there are no X
fields in either input our output respectively.
来源:https://stackoverflow.com/questions/61735200/fft-multiple-1d-transforms-using-fftw