Skip to content

Incorrect result for integer input #109

Description

@vtavana

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions