Why does the onesided option work only for the last dimension, but not for the last but one in case of the 2D rfft:
z = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]])
np.fft.fft2(z)
Out[31]:
array([[136. +0.j, -8. +8.j, -8. +0.j, -8. -8.j],
[-32.+32.j, 0. +0.j, 0. +0.j, 0. +0.j],
[-32. +0.j, 0. +0.j, 0. +0.j, 0. +0.j],
[-32.-32.j, 0. +0.j, 0. +0.j, 0. +0.j]])
ztorch = torch.tensor(z, dtype=torch.float)
torch.rfft(ztorch, 2)
Out[35]:
tensor([[[136., 0.], [ -8., 8.], [ -8., 0.]],
[[-32., 32.], [ 0., 0.], [ 0., 0.]],
[[-32., 0.], [ 0., 0.], [ 0., 0.]],
[[-32., -32.], [ 0., 0.], [ 0., 0.]]])
Shouldn’t the last line [[-32., -32.], [ 0., 0.], [ 0., 0.]]
be discarded as well for the onesided 2D rfft?