Let's say I have three-dimensional complex array $X[m,n,p]$, $m \in \{0, 1, \ldots, M-1\}$, $n \in \{0, 1, \ldots, N-1\}$, $p \in \{0, 1, \ldots, P-1\}$; i.e. $X \in \mathbb C^{M \times N \times P}$. I would like to take a three-dimensional DFT of this array; along dimensions $m$ and $n$ I would like to use the forward transform, and along dimension $p$ I would like to use the inverse transform.

Every multidimensional FFT implementation I've looked at (FFTW, MKL, numpy.fft) just has one parameter to specify as "forward" or "backwards/inverse", implying that the same transform is applied in each dimension.

Is there an "easy" way to do this mixed-direction FFT directly without having to break it up into two steps (i.e. doing a 2D forward transform and then a set of 1D inverse transforms)?

Either a conceptual answer (e.g. "conjugate this then do this") or a "programming" answer (e.g. "use this flag in MKL") would be fine.

  • 1
    $\begingroup$ Somehow you have to "flip" the sign of the imaginary part to change the direction of the transform. Each one of the subsequent "dimensional" applications of the DFT is applied over the previous step transformed data. Can you predict what the sign of the $m,n$ $\mathbb{C}$omplex element is going to be so that you can pre-flip it in preparation for the third application of the FFT? (So that you can do the whole process with 1-way applications of the FFT). I don't think that this is doable without breaking the process in more than one parts....or did I not get it right (?) $\endgroup$
    – A_A
    Commented Mar 11, 2019 at 22:38
  • $\begingroup$ @A_A yes, I think you're right that I may have over-constrained the problem. $\endgroup$
    – Robert L.
    Commented Mar 12, 2019 at 20:37

1 Answer 1


if I understood it right, given your 3D volumetric data $x[m,n,p]$, first you want to take a 2D forward DFT (via 2D FFT) in the first two variables $m,n$ (i.e., for each m-n plane along 3rd dimension) and then take a 1D inverse DFT of vectors along the third dimension.

Note that in the first operation you replace each data plane with frequency plane and create a new volumetric data, then you will be taking inverse DFT of this resulting volume, the MATLAB/OCTAVE code below demonstrates a simple example:

A = zeros(2,2,3);      % create a 3D data array
A(:,:,1) = [1,2;3,4];  % first plane of 3D data
A(:,:,2) = [1,2;3,4];  % second plane of 3D data
A(:,:,3) = [1,2;3,4];  % third plane of 3D data

B = fft2(A)        % it'll take 2D-DFT independently for each plane of A

C = ifft(B,[],3)  % we indicate that ifft() be taken along 3rd dimension...

As you can see, since after the first step we have same frequency data for each plane of B, the third step produced impulses for each vector of C along 3rd dimension, due to inverse DFT.

I believe this is easy enough? But still in two steps (you can merge them into one line but still two calls)...

  • 1
    $\begingroup$ yes, this does it, thank you. I didn't realize at the time that I could just use ifft along a dimension and was thinking I'd manually have to do an ifft for each $(m,n)$. $\endgroup$
    – Robert L.
    Commented Mar 12, 2019 at 20:36
  • $\begingroup$ oh that's good to hear ;-) $\endgroup$
    – Fat32
    Commented Mar 12, 2019 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.