【问题标题】:numpy fftn order of individual ffts单个ffts的numpy fftn顺序
【发布时间】:2019-09-10 11:22:13
【问题描述】:

fft2 和 fftn 提供了轴参数,允许指定在哪些轴上执行转换。该方法是否服从命令?

给定一个二维 numpy 数组

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

fft2(a,axis=(0,1)

不同于

fft2(a,axis=(1,0)

我的数据跨行但不是跨列相关...

【问题讨论】:

  • 由于 FFT 是线性可分的,因此执行顺序无关紧要。

标签: python numpy fft


【解决方案1】:

DFT 是可分离的,这意味着计算 2D DFT 与沿每个轴计算两个单独的 1D DFT 相同:

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

并且由于nested summations of the DFTs commute,操作顺序无关紧要

tmp = np.fft.fft(a, axis=1)
out3 = np.fft.fft(tmp, axis=0)

np.allclose(out1, out3) # True

这意味着axes参数的顺序也不重要

out4 = np.fft.fft2(a, axes=(1, 0))

np.allclose(out1, out4) # True

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-20
    • 1970-01-01
    • 2012-03-31
    • 2017-10-28
    • 1970-01-01
    • 2020-03-22
    • 2021-11-06
    • 1970-01-01
    相关资源
    最近更新 更多