示例#1
0
文件: fft.py 项目: cygnine/spyctral
def ifft(f,gamma=0.,delta=0.,scale=1.):
    from numpy import sqrt, roll, arange, exp, sign
    from numpy.fft import ifft as ift
    from scipy import pi
    from spyctral.common.indexing import integer_range
    from connection import int_connection_backward

    try: 
        from pymbolic.algorithm import ifft
    except:
        from numpy.fft import ifft

    N = f.size
    ks = integer_range(N)
    fx = int_connection_backward(f,0,0,gamma,delta)

    flags = ks!=0
    flags2 = ((ks%2)==1)

    fx[flags2] *= -1
    fx[flags] /= exp(-1j*ks[flags]*pi/N)

    fx = roll(fx,-(N-1)/2)

    if fx.dtype==object:
        import pymbolic.algorithm as pyalg
        return 1/sqrt(2*pi)*pyalg.sym_fft(fx,sign=-1)
    else:
        return N/float(sqrt(2*pi)*ift(fx))
示例#2
0
文件: fft.py 项目: cygnine/spyctral
def ifft_online(f,overhead):

    from numpy.fft import ifft as ift
    from numpy import roll
    from connection import int_connection_backward_online

    try:
        from pymbolic.algorithm import fft
    except:
        from numpy.fft import fft

    fx = int_connection_backward_online(f,overhead[1])
    fx /= overhead[0]
    N = fx.size

    fx = roll(fx,-(N/2))

    if fx.dtype==object:
        import pymbolic.algorithm as pyalg
        return pyalg.sym_fft(fx,sign=-1)/float(N)
    else:
        return ift(fx)