0

fft2 and fftn provide the axis parameter which allows to specify over which axes to perform the transform. Does the method obey order?

Given a 2-dimensional numpy array

a = np.array([[1,2],[3,4]])

is

fft2(a,axis=(0,1) 

different from

fft2(a,axis=(1,0) 

I have data which is correlated across lines but not columns...

1
  • 1
    As the FFT is linear and separable, the order of execution does not matter. Commented Sep 10, 2019 at 11:27

1 Answer 1

4

The DFT is separable, which means calculating the 2D DFT is the same as calculating two individual 1D DFTs along each axis:

import numpy as np a = np.arange(25).reshape(5, 5) out1 = np.fft.fft2(a) tmp = np.fft.fft(a, axis=0) out2 = np.fft.fft(tmp, axis=1) np.allclose(out1, out2) # True 

And since the nested summations of the DFTs commute, the order of operations does not matter

tmp = np.fft.fft(a, axis=1) out3 = np.fft.fft(tmp, axis=0) np.allclose(out1, out3) # True 

Which means the order of the axes parameter does not matter either

out4 = np.fft.fft2(a, axes=(1, 0)) np.allclose(out1, out4) # True 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.