Skip to content

Commit

Permalink
switch to sp_fft
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevdp committed May 9, 2024
1 parent e2d1e1c commit c7a3d77
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scipy/signal/windows/_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -1624,13 +1624,13 @@ def chebwin(M, at, sym=True, *, array_namespace=None):
# Appropriate IDFT and filling up
# depending on even/odd M
if M % 2:
w = xp.real(xp.fft.fft(p))
w = xp.real(sp_fft.fft(p))
n = (M + 1) // 2
w = w[:n]
w = xp.concat((w[n - 1:0:-1], w))
else:
p = p * xp.exp(1.j * xp.pi / M * xp.arange(M))
w = xp.real(xp.fft.fft(p))
w = xp.real(sp_fft.fft(p))
n = M // 2 + 1
w = xp.concat((w[n - 1:0:-1], w[1:n]))
w = w / xp.max(w)
Expand Down Expand Up @@ -2162,7 +2162,7 @@ def dpss(M, NW, Kmax=None, sym=True, norm=None, return_ratios=False,
if norm == 'approximate':
correction = M**2 / float(M**2 + NW)
else:
s = xp.fft.rfft(windows[0])
s = sp_fft.rfft(windows[0])
shift = -(1 - 1./M) * xp.arange(1, M//2 + 1)
s[1:] *= 2 * xp.exp(-1j * xp.pi * shift)
correction = M / s.real.sum()
Expand Down Expand Up @@ -2282,8 +2282,8 @@ def _fftautocorr(x, *, array_namespace=None):

N = x.shape[-1]
use_N = sp_fft.next_fast_len(2*N-1)
x_fft = xp.fft.rfft(x, n=use_N, axis=-1)
cxy = xp.fft.irfft(x_fft * x_fft.conj(), n=use_N)[:, :N]
x_fft = sp_fft.rfft(x, use_N, axis=-1)
cxy = sp_fft.irfft(x_fft * x_fft.conj(), n=use_N)[:, :N]
# Or equivalently (but in most cases slower):
# cxy = xp.array([xp.convolve(xx, yy[::-1], mode='full')
# for xx, yy in zip(x, x)])[:, N-1:2*N-1]
Expand Down

0 comments on commit c7a3d77

Please sign in to comment.