如果數組x
的尾部維數爲奇數,則變換y = irfftn(rfftn(x))
的形狀與輸入數組的形狀不同。這是設計嗎?如果是這樣,動機是什麼?示例代碼如下。爲什麼irfftn(rfftn(x))不等於x?
import numpy as np
shapes = [(10, 10), (11, 11), (10, 11), (11, 10)]
for shape in shapes:
x = np.random.uniform(0, 1, shape)
y = np.fft.irfftn(np.fft.rfftn(x))
if x.shape != y.shape:
print("expected shape %s but got %s" % (shape, y.shape))
# Output
# expected shape (11, 11) but got (11, 10)
# expected shape (10, 11) but got (10, 10)