Core.Type
— MethodCartesianIndex(i::AbstractFFTIndex, inds::Tuple)
CartesianIndex(i::AbstractFFTIndex, A)
Constructs a CartesianIndex
corresponding to the the index i
using information from A
or a set of axes ax
.
FFTIndexing.AbstractFFTIndex
— TypeAbstractFFTIndex{D}
Supertype for array indices that correspond to the frequency bins constructed by performing a Fourier transform of an array. This includes FFTIndex{D}
and NormalizedFFTIndex{D}
.
Usage
AbstractFFTIndex{D}
serves as an index for any object indexable by CartesianIndex{D}
. Although there is no direct method of converting an AbstractFFTIndex{D}
to a CartesianIndex{D}
, as that requires information about the array being indexed, instances of this type can be used as an
Indexing an array with an AbstractFFTIndex{D}
is guaranteed to be an inbounds access.
Interface
For types T<:AbstractFFTIndex{D}
:
- The length of an
AbstractFFTIndex{D}
is alwaysD
. - The type constructors should accept a
Tuple{Vararg{Integer}}
. You will likely want to define
constructors that infer type parameters from the input. This will automatically define T(x::Vararg{Integer,D})
.
Tuple(::T)
should be defined, returning the index as aNTuple{D,Int}
.convert(::Type{<:FFTIndex}, ::T)
should be defined. This is to allow for types that encode
information about normalization factors to be converted to an FFTIndex
used by generic indexing methods. This will also automatically define (::Type{<:FFTIndex})(::T)
.
Like CartesianIndex{D}
in Julia 1.10 and up, AbstractFFTIndex{D}
is a scalar type. To iterate through its components, convert it to a Tuple
with the Tuple
constructor.
FFTIndexing.FFTAxis
— TypeFFTAxis <: AbstractVector{Int}
The one-dimensional counterpart to FFTIndices
, supporting only a single dimension. Its elements are plain Int
types rather than the CartesianIndex
of FFTIndices
.
This type serves as an analog to Base.OneTo
which is usually returned by axes
; this package provides fftaxes
to serve the same purpose.
Examples
julia> FFTAxis(4)
4-element FFTAxis:
0
1
-2
-1
FFTIndexing.FFTIndex
— TypeFFTIndex{D} <: AbstractFFTIndex{D}
A index for an array corresponding to an FFT frequency bin along each dimension of an array. These frequency bins are integer values which are easily converted to corresponding array indices.
FFTIndexing.FFTIndices
— TypeFFTIndices{D} <: AbstractArray{FFTIndex{D},D}
An iterable object defining a range of CartesianIndices corresponding to FFT indices. This can be used to convert a Cartesian array index to an FFT bin index, or vice versa.
An array of FFTIndex{D}
objects which correspond to all valid indices of an indexable object.
The outputs use the convention where frequencies at or above the Nyquist frequency for that dimension are negative, matching the output of FFTW.fftfreq
.
Examples
julia> FFTIndices(4)
4-element FFTIndices{1}:
FFTIndex(0,)
FFTIndex(1,)
FFTIndex(-2,)
FFTIndex(-1,)
julia> FFTIndices(3, 3)
3×3 FFTIndices{2}:
FFTIndex(0, 0) FFTIndex(0, 1) FFTIndex(0, -1)
FFTIndex(1, 0) FFTIndex(1, 1) FFTIndex(1, -1)
FFTIndex(-1, 0) FFTIndex(-1, 1) FFTIndex(-1, -1)
FFTIndexing._cartesian_tuple
— MethodFFTIndex._cartesian_tuple(i::AbstractFFTIndex, ax::Tuple)
Generates a Tuple
which may be used to construct a CartesianIndex
that performs the same indexing as i
. This function is provided separately in case the CartesianIndex
does not need to be constructed and a raw Tuple
is desired.
FFTIndexing.fftaxes
— Methodfftaxes(a, d) -> FFTAxis
Returns an FFTAxis
associated with an object a
along dimension d
. This is calculated from size(a, d)
.
FFTIndexing.fftaxes
— Methodfftaxes(a) -> NTuple{D,FFTAxis}
Returns a set of FFTAxis
objects associated with an object a
. This is calculated from size(a)
.