Package fftManager
Class FastFFT
java.lang.Object
fftManager.FastFFT
FFT Wrapper which uses the edu.emory.mathcs.jtransforms.fft
transforms library for the actual FFT calculations.
These are simple wrappers to use the transforms library with standard PAMGUARD transform classes.
These are simple wrappers to use the transforms library with standard PAMGUARD transform classes.
- Author:
- Doug Gillespie
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
In place fft of complex data.void
In lace FFT of a 2D complex array.void
fft
(ComplexArray x) In place complex fft of complex data.void
Inverse FFT for Complex data.void
ifft
(ComplexArray x, int n) Inverse FFT for Complex data.void
ifft
(ComplexArray x, int n, boolean scale) Inverse FFT for Complex data.static int
log2
(int num) static int
nextBinaryExp
(int sourceNumber) Finds the next highest binary exponential of the input integer.static int
nextBinaryExp
(int startPower, int sourceNumber) Finds the next highest binary exponential of the input integer.double[]
Inverse transform of what was real data.rfft
(double[] x, int n) FFT of real data.Complex[]
Fast FFT function for real data.rfftFull
(double[] x, int n)
-
Constructor Details
-
FastFFT
public FastFFT()
-
-
Method Details
-
rfft
Fast FFT function for real data.- Parameters:
x
- real data arrayy
- preallocated Complex array for output data (can be null)m
- log2 of the FFT length (sorry !)- Returns:
- Complex FFT data.
-
rfft
FFT of real data. Will return only the first half of the FFT, since second is simply complex conjugate of the first.- Parameters:
x
- waveform (will be padded or truncated to length n)n
- length of FFT- Returns:
- Complex spectrum
-
rfftFull
-
fft
In place fft of complex data.- Parameters:
x
- complex array
-
fft
In place complex fft of complex data.- Parameters:
x
- Complex data array.
-
fft
In lace FFT of a 2D complex array. Will use the multithreading abilities of the JTransofrms library.- Parameters:
x
-
-
ifft
Inverse FFT for Complex data.
I FFT is performed 'in place' so data are overwritten- Parameters:
x
- Complex Datam
- log2 of the FFT length (sorry !)
-
ifft
Inverse FFT for Complex data.
I FFT is performed 'in place' so data are overwritten- Parameters:
x
- ComplexArray - the input data.n
- the FFT length
-
realInverse
Inverse transform of what was real data. Will automatically assume a second half complex conj of the first half. This can be used to transform back data used in cross correlations rather than trying to fill in the second half of the conjugate, which is not really possible with the missing middle point of the FFT.- Parameters:
x
- Complex input data, which originally came from real.- Returns:
- real data array 2x the length of the Complex input (i.e. same length as double array within complex input).
-
ifft
Inverse FFT for Complex data.
I FFT is performed 'in place' so data are overwritten- Parameters:
x
- ComplexArray - the input datan
- the FFT lengthscale
- - true for scaling to be performed
-
nextBinaryExp
public static int nextBinaryExp(int sourceNumber) Finds the next highest binary exponential of the input integer. If the input is itself a binary exponential, then the result is itself. E.g. given 7 returns 8, 8 returns 8, 9 returns 16. Notes has limit of 2^100. Matlab calls this function nextpow2; it's also akin to frexp in C.- Parameters:
sourceNumber
-- Returns:
- The next highest 2^ of the input, unless input is itself a binary exponential.
-
nextBinaryExp
public static int nextBinaryExp(int startPower, int sourceNumber) Finds the next highest binary exponential of the input integer. If the input is itself a binary exponential, then the result is itself. E.g. given 7 returns 8, 8 returns 8, 9 returns 16. Notes has limit of 2^100. Matlab calls this function nextpow2; it's also akin to frexp in C.- Parameters:
startPower
- power of 2 to start at (e,g. 1 will return a minimum of 2)sourceNumber
-- Returns:
- The next highest 2^ of the input, unless input is itself a binary exponential.
-
log2
public static int log2(int num) - Parameters:
FFTlength
-- Returns:
- log2 of FFTlength, -1 if not natural power of 2
-