Skip to content

Commit

Permalink
replace i/rfft with _fftpack.drfft, ~1/4 speed-up
Browse files Browse the repository at this point in the history
  • Loading branch information
prisae committed Dec 6, 2016
1 parent 7650f85 commit b27167a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pyfftlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@
"""
import numpy as np
from scipy.special import loggamma
from scipy.fftpack import rfft, irfft
from scipy.fftpack._fftpack import drfft
# from scipy.fftpack import rfft, irfft
# from scipy.fftpack.basic import _raw_fft


def fhti(n, mu, dlnr, q=0, kr=1, kropt=0):
Expand Down Expand Up @@ -594,7 +596,9 @@ def fhtq(a, xsave, tdir=1):
n = a.size

# normal FFT
a = rfft(a)
# a = rfft(a)
# _raw_fft(a, n, -1, 1, 1, _fftpack.drfft)
a = drfft(a, n, 1, 0)

m = np.arange(1, n/2, dtype=int) # index variable
if q == 0: # unbiased (q = 0) transform
Expand Down Expand Up @@ -660,7 +664,9 @@ def fhtq(a, xsave, tdir=1):
a[-1] /= ar

# normal FFT back
a = irfft(a)
# a = irfft(a)
# _raw_fft(a, n, -1, -1, 1, _fftpack.drfft)
a = drfft(a, n, -1, 1)

# reverse the array and at the same time undo the FFTs' multiplication by n
# => Just reverse the array, the rest is already done in drfft.
Expand Down

0 comments on commit b27167a

Please sign in to comment.