API
Usage
SlidingDFTs.sdft
— Functionsdft(method, x[, safe=true])
Return an iterator to produce a sliding DFT of x
using the given method
. If safe == true
(the default behavior), this iterator produces a new vector at each iteration.
Set the optional argument safe=false
to improve performance by reducing allocations, at the expense of unexpected behavior if the resulting vector is mutated between iterations.
Sliding DFT methods
SlidingDFTs.SDFT
— TypeSDFT(n)
Basic method to compute a Sliding Discrete Fourier Transform of window length n
[1], through the recursive formula:
\[X_{i+1}[k] = \exp(j2{\pi}k/n) \cdot (X_{i}[k] + x[i+n] - x[i])\]
The transfer function for the k
-th bin of this method is:
$ H(z) = \frac{1 - z^{-n}}{1 - \exp(j2{\pi}k/n) z^{-1}} $
References
[1] Jacobsen, E. and Lyons, R. "The sliding DFT," IEEE Signal Processing Magazine, 20(2), 74-80 (2003), DOI: 10.1109/MSP.2003.1184347
Implementation
SlidingDFTs.dataoffsets
— Methoddataoffsets(method)
Return an integer or a vector of integers with the offsets of data samples that are needed by the given method to compute a sliding DFT.
If the code of SlidingDFTs.updatepdf!
that dispatches on the type of method
uses the function SlidingDFTs.previousdata
, this function must return the integers that are used as the third argument (offset
) of that function.
If that function is not needed (no past samples are used), this one may return nothing
to reduce memory allocations.
SlidingDFTs.dftback
— Methoddftback(method)
Return an integer or a vector of positive integers with the indices of the previous iterations that are needed by the given method to compute a sliding DFT.
If the code of SlidingDFTs.updatepdf!
for the type of method
uses the function SlidingDFTs.previousdft
, this function must return the integers that are used as the third argument (back
) of that function.
If that function is not needed, this one may return nothing
to reduce memory allocations.
SlidingDFTs.iterationcount
— Methoditerationcount(state)
Return the number of iterations done for the sliding DFT represented by state
.
If the DFT computed in the most recent iteration corresponds to the fragment of the data series between its positions i
and i+n
, then this function returns the number i
.
SlidingDFTs.nextdata
— Methodnextdata(state)
Return the next value after the fragment of the data series that was used in the most recent iteration of the sliding DFT represented by state
.
If the DFT computed in the most recent iteration corresponds to the fragment of the data series between its positions i
and i+n
, then this function returns the i+n+1
-th value.
There is no defined behavior if such value does not exist (i.e. if the end of a finite data series was reached).
SlidingDFTs.previousdata
— Functionpreviousdata(state[, offset=0])
Return the first value of the fragment of the data series that was used in the most recent iteration of the sliding DFT represented by state
, or at offset
positions after the beginning of that fragment.
If the DFT computed in the most recent iteration corresponds to the fragment of the data series between its positions i
and i+n
, then this function returns the i+offset
-th value.
SlidingDFTs.previousdft
— Functionpreviousdft(state[, back=0])
Return the DFT computed in the most recent iteration of the sliding DFT represented by state
, or in a number of previous iterations equal to back
.
If the DFT computed in the most recent iteration corresponds to the fragment of the data series between its positions i
and i+n
, then this function returns its DFT for the fragment between i-back
and i+n-back
.
SlidingDFTs.updatedft!
— Functionupdatedft!(dft, x, method, state)
Update the values of a sliding Discrete Fourier Transform (DFT) of a data series, according to the algorithm of the provided method, for a given state of the sliding DFT.
dft
is a mutable collection of complex values with length equal to windowlength(method)
, containing the value returned by the last iteration of the sliding DFT.
x
is the data series for which the sliding DFT is computed, at least as long as windowlength(method)
.
method
is the object that defines the method to compute the sliding DFT.
state
is an object generated automatically at each iteration of an object created by sdft(method, x)
, containing the information that is needed to compute the new values of the sliding DFT, together with x
. That information can be extracted from state
with the following functions:
SlidingDFTs.previousdft
to get the DFTs of previous iterations.SlidingDFTs.previousdata
to get a previous value of the data series.SlidingDFTs.nextdata
to get the next value of the data series.
SlidingDFTs.windowlength
— FunctionSlidingDFTs.windowlength(method)
Return the length of the window used by method
.