@@ -344,6 +344,17 @@ plan_irfft
344
344
345
345
# #############################################################################
346
346
347
+ """
348
+ fftshift!(dest, src, [dim])
349
+
350
+ Nonallocating version of [`fftshift`](@ref). Stores the result of the shift of the `src` array into the `dest` array.
351
+ """
352
+ function fftshift! (dest, src, dim = 1 : ndims (src))
353
+ @assert size (dest)== size (src)
354
+ s = ntuple (d -> d in dim ? div (size (dest,d),2 ) : 0 , Val (ndims (dest)))
355
+ circshift! (dest, src, s)
356
+ end
357
+
347
358
"""
348
359
fftshift(x, [dim])
349
360
@@ -356,22 +367,24 @@ swapping the first and second halves, so `fftshift` and [`ifftshift`](@ref) are
356
367
the same.
357
368
358
369
If `dim` is not given then the signal is shifted along each dimension.
370
+
371
+ The output of `fftshift` is allocated. If one desires to store the output in a preallocated array, use [`fftshift!`](@ref) instead.
359
372
"""
360
373
fftshift
361
374
362
375
function fftshift (x, dim = 1 : ndims (x))
363
- s = ntuple (d -> d in dim ? div ( size (x,d), 2 ) : 0 , Val ( ndims (x)) )
364
- circshift ( x, s )
376
+ dest = similar (x )
377
+ fftshift! (dest, x, dim )
365
378
end
366
379
367
380
"""
368
- fftshift !(dest, src, [dim])
381
+ ifftshift !(dest, src, [dim])
369
382
370
- Nonallocating version of [`fftshift `](@ref). Stores the result of the shift of the `src` array into the `dest` array.
383
+ Nonallocating version of [`ifftshift `](@ref). Stores the result of the shift of the `src` array into the `dest` array.
371
384
"""
372
- function fftshift ! (dest, src, dim = 1 : ndims (src))
385
+ function ifftshift ! (dest, src, dim = 1 : ndims (src))
373
386
@assert size (dest)== size (src)
374
- s = ntuple (d -> d in dim ? div (size (dest ,d),2 ) : 0 , Val (ndims (dest )))
387
+ s = ntuple (d -> d in dim ? - div (size (src ,d),2 ) : 0 , Val (ndims (src )))
375
388
circshift! (dest, src, s)
376
389
end
377
390
@@ -387,23 +400,14 @@ swapping the first and second halves, so [`fftshift`](@ref) and `ifftshift` are
387
400
the same.
388
401
389
402
If `dim` is not given then the signal is shifted along each dimension.
403
+
404
+ The output of `ifftshift` is allocated. If one desires to store the output in a preallocated array, use [`ifftshift!`](@ref) instead.
390
405
"""
391
406
ifftshift
392
407
393
408
function ifftshift (x, dim = 1 : ndims (x))
394
- s = ntuple (d -> d in dim ? - div (size (x,d),2 ) : 0 , Val (ndims (x)))
395
- circshift (x, s)
396
- end
397
-
398
- """
399
- ifftshift!(dest, src, [dim])
400
-
401
- Nonallocating version of [`ifftshift`](@ref). Stores the result of the shift of the `src` array into the `dest array`.
402
- """
403
- function ifftshift! (dest, src, dim = 1 : ndims (src))
404
- @assert size (dest)== size (src)
405
- s = ntuple (d -> d in dim ? - div (size (src,d),2 ) : 0 , Val (ndims (src)))
406
- circshift! (dest, src, s)
409
+ dest = similar (x)
410
+ ifftshift! (dest, x, dim)
407
411
end
408
412
409
413
# #############################################################################
0 commit comments