@@ -346,8 +346,6 @@ plan_irfft
346346
347347# #############################################################################
348348
349- fftshift (x) = circshift (x, div .([size (x)... ],2 ))
350-
351349"""
352350 fftshift(x, [dim])
353351
@@ -363,16 +361,11 @@ If `dim` is not given then the signal is shifted along each dimension.
363361"""
364362fftshift
365363
366- function fftshift (x,dim)
367- s = zeros (Int,ndims (x))
368- for i in dim
369- s[i] = div (size (x,i),2 )
370- end
364+ function fftshift (x, dim = 1 : ndims (x))
365+ s = ntuple (d -> d in dim ? div (size (x,d),2 ) : 0 , ndims (x))
371366 circshift (x, s)
372367end
373368
374- ifftshift (x) = circshift (x, div .([size (x)... ],- 2 ))
375-
376369"""
377370 ifftshift(x, [dim])
378371
@@ -388,11 +381,8 @@ If `dim` is not given then the signal is shifted along each dimension.
388381"""
389382ifftshift
390383
391- function ifftshift (x,dim)
392- s = zeros (Int,ndims (x))
393- for i in dim
394- s[i] = - div (size (x,i),2 )
395- end
384+ function ifftshift (x, dim = 1 : ndims (x))
385+ s = ntuple (d -> d in dim ? - div (size (x,d),2 ) : 0 , ndims (x))
396386 circshift (x, s)
397387end
398388
423413Base. size (x:: Frequencies ) = (x. n,)
424414Base. step (x:: Frequencies ) = x. multiplier
425415
416+ Base. copy (x:: Frequencies ) = x
417+
426418"""
427419 fftfreq(n, fs=1)
428420Return the discrete Fourier transform (DFT) sample frequencies for a DFT of length `n`. The returned
0 commit comments