Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect result for integer input #109

Closed
vtavana opened this issue Jul 18, 2024 · 0 comments · Fixed by #111
Closed

Incorrect result for integer input #109

vtavana opened this issue Jul 18, 2024 · 0 comments · Fixed by #111

Comments

@vtavana
Copy link
Collaborator

vtavana commented Jul 18, 2024

Following example returns correct result for float dtype (results similar to stock NumPy) but incorrect result for integer dtype:

#  Name        Version   Build              Channel
# ────────────────────────────────────────────────────
#  numpy       1.26.4   py311h689b997_3  intel  
#  numpy-base  1.26.4   py311h913173e_3  intel
#  mkl_fft  1.3.8    py311h977b55c_72  intel

import numpy
b=numpy.array([[5, 7, 6, 5], [4, 6, 4, 8], [9, 3, 7, 5]], dtype=numpy.float32)
res1 = numpy.fft.fftn(b, axes=(0,), s=None, norm="forward")
res1
# array([[ 6.        +0.j       ,  5.3333335 +0.j       , # correct result
#         5.666667  +0.j       ,  6.        +0.j       ],
#       [-0.5       +1.4433756j,  0.8333334 -0.8660254j,
#         0.16666667+0.8660254j, -0.5       -0.8660254j],
#       [-0.5       -1.4433756j,  0.8333334 +0.8660254j,
#         0.16666667-0.8660254j, -0.5       +0.8660254j]], dtype=complex64)

import numpy
b=numpy.array([[5, 7, 6, 5], [4, 6, 4, 8], [9, 3, 7, 5]])
res2 = numpy.fft.fftn(b, axes=(0,), s=None, norm="forward")
res2
# array([[10.39230485+0.j ,  9.23760431+0.j ,  9.81495458+0.j , # incorrect result
#        10.39230485+0.j ],
#       [-0.8660254 +2.5j,  1.44337567-1.5j,  0.28867513+1.5j,
#       -0.8660254 -1.5j],
#       [-0.8660254 -2.5j,  1.44337567+1.5j,  0.28867513-1.5j,
#        -0.8660254 +1.5j]])

Note that the result of integer res2 is 1.73 times of res1. So, this seems to be an issue in scaling?
For norm="ortho", the result are different as well but for norm=None or "backward", the result are the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant