mkl_fft icon indicating copy to clipboard operation
mkl_fft copied to clipboard

repeated indices in axes keyword for N-dimensional FFT are ignored

Open vtavana opened this issue 8 months ago • 0 comments

Repeated indices in axes keyword are ignored while the transform over the repeated axis should be performed multiple times. Result from stock NumPy

#  Name  Version   Build              Channel
# ──────────────────────────────────────────────
#  numpy  1.26.4   py310hb13e2d6_0  conda-forge

>>> import numpy
>>> in_arr = [[5, 4, 6, 3, 7], [-1, -3, -4, -7, 0]]
>>> dtype = numpy.complex64
>>> a_np = numpy.array(in_arr, dtype=dtype)
>>> numpy.fft.fft2(a_np, axes=(0,1))   
# array([[10.        +0.j        ,  8.09016994+2.17962758j,
        -3.09016994+9.23305061j, -3.09016994-9.23305061j,
         8.09016994-2.17962758j],
       [40.        +0.j        , -5.85410197+0.j        ,
         0.85410197+0.j        ,  0.85410197+0.j        ,
        -5.85410197+0.j        ]])   
		
>>> numpy.fft.fft2(a_np, axes=(0,1,1))
# array([[ 20.+0.j,  35.+0.j, -20.+0.j,  10.+0.j,   5.+0.j],
       [ 30.+0.j,  35.+0.j,  50.+0.j,  50.+0.j,  35.+0.j]])

Result from mkl_fft package (NumPy from intel channel)

#  Name        Version   Build              Channel
# ────────────────────────────────────────────────────
#  numpy       1.26.4   py310h689b997_1    intel  
#  numpy-base  1.26.4   py310h8eeea18_1    intel 
#  mkl_fft     1.3.8    py310h6b114c4_70   intel

>>> import numpy
>>> in_arr = [[5, 4, 6, 3, 7], [-1, -3, -4, -7, 0]]
>>> dtype = numpy.complex64
>>> a_np = numpy.array(in_arr, dtype=dtype)
>>> numpy.fft.fft2(a_np, axes=(0,1))   
# array([[10.        +0.j      ,  8.09017   +2.179628j,
        -3.09017   +9.233051j, -3.09017   -9.233051j,
         8.09017   -2.179628j],
       [40.        +0.j      , -5.854102  +0.j      ,
         0.85410213+0.j      ,  0.85410213+0.j      ,
        -5.854102  +0.j      ]], dtype=complex64)

>>> numpy.fft.fft2(a_np, axes=(0,1,1))	
# array([[10.        +0.j      ,  8.09017   +2.179628j,
        -3.09017   +9.233051j, -3.09017   -9.233051j,
         8.09017   -2.179628j],
       [40.        +0.j      , -5.854102  +0.j      ,
         0.85410213+0.j      ,  0.85410213+0.j      ,
        -5.854102  +0.j      ]], dtype=complex64)

vtavana avatar May 30 '24 20:05 vtavana