Some Utility Functions
FourierTools.δ — Function
δ([T,] sz, pos=FourierTools.fft_center.(sz))Return an array which has 1 at pos in the array of size sz.
Examples
julia> δ((3, 3))
3×3 Matrix{Int64}:
0 0 0
0 1 0
0 0 0
julia> δ(Float32, (4, 3))
4×3 Matrix{Float32}:
0.0 0.0 0.0
0.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 0.0
julia> δ(Float32, (3, 3), (1,1))
3×3 Matrix{Float32}:
1.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0Missing docstring for FourierTools.select_region. Check Documenter's build log for details.
FourierTools.center_set! — Function
center_set!(arr_large, arr_small)Puts the arr_small central into arr_large. The convention, where the center is, is the same as the definition as for FFT based centered. Function works both for even and uneven arrays.
Examples
julia> FourierTools.center_set!([1, 1, 1, 1, 1, 1], [5, 5, 5])
6-element Array{Int64,1}:
1
1
5
5
5
1FourierTools.get_indices_around_center — Function
get_indices_around_center(i_in, i_out)A function which provides two output indices i1 and i2 where i2 - i1 = i_out The indices are chosen such that the set i1:i2 cuts the interval 1:i_in in a way that the center frequency stays at the center position. Works for both odd and even indices
FourierTools.center_extract — Function
center_extract(arr, new_size_array)Extracts a center of an array. new_size_array must be list of sizes indicating the output size of each dimension. Centered means that a center frequency stays at the center position. Works for even and uneven. If length(new_size_array) < length(ndims(arr)) the remaining dimensions are untouched and copied.
Examples
julia> FourierTools.center_extract([1 2; 3 4], [1])
1×2 view(::Matrix{Int64}, 2:2, 1:2) with eltype Int64:
3 4
julia> FourierTools.center_extract([1 2; 3 4], [1, 1])
1×1 view(::Matrix{Int64}, 2:2, 2:2) with eltype Int64:
4
julia> FourierTools.center_extract([1 2 3; 3 4 5; 6 7 8], [2 2])
2×2 view(::Matrix{Int64}, 1:2, 1:2) with eltype Int64:
1 2
3 4FourierTools.odd_view — Function
odd_view(arr)creates a view of arr that for each even dimension excludes the starting index yielding a view of the array with only odd dimensions. This is useful for operations in Fourier-space which should leave the first index unaltered such as reverse! Note that an array reversal can also be achieved by using two ffts instead of one fft and one ifft.
Examples
julia> odd_view([1 2 3; 4 5 6])
1×3 view(::Matrix{Int64}, 2:2, 1:3) with eltype Int64:
4 5 6FourierTools.fourier_reverse! — Function
fourier_reverse!(arr; dims=1:ndims(arr))reverses the dimensions of the input array arr in place. This effectively mirrors these array. Note that for even-sized dimensions the first index is excluded from the reverse operation along this dimensions.
Example
julia> a = [1 2 3;4 5 6;7 8 9;10 11 12]
4×3 Matrix{Int64}:
1 2 3
4 5 6
7 8 9
10 11 12
julia> fourier_reverse!(a);
julia> a
4×3 Matrix{Int64}:
3 2 1
12 11 10
9 8 7
6 5 4FourierTools.get_indexrange_around_center — Function
get_indexrange_around_center(arr_1, arr_2)A function which provides a range of output indices i1:i2 where i2 - i1 = i_out The indices are chosen in a way that the set i1:i2 cuts the interval 1:i_in such that the center frequency stays at the center position. Works for both odd and even indices