|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmath.fourierTransforms.SigProc
public final class SigProc
Class SigProc
contains methods to perform basic signal
processing tasks, such as FFTs, convolutions, correlations, etc.
Field Summary | |
---|---|
static boolean |
NO_NORM
Constant to specify no cross-correlation normalization. |
static boolean |
NORM
Constant to specify that cross-correlations should be normalized so that the coefficients at zero lag are exactly 1.0. |
Constructor Summary | |
---|---|
SigProc()
|
Method Summary | |
---|---|
static double[] |
calcFreq(double fs,
int fftSize)
This method calculates the frequency associated with each element of the output array from an FFT, taking into account the ambiguities above the Nyquist frequency. |
static double[] |
calcLags(ComplexBusted[] za,
ComplexBusted[] zb)
This method calculates the lags associated with each position in the output of a cross correlation. |
static double[] |
calcLags(double[] xa,
double[] xb)
This method calculates the lags associated with each position in the output of a cross correlation. |
static ComplexBusted[] |
conv(ComplexBusted[] za,
ComplexBusted[] zb)
This method calculates the convolution of two arrays of arbitrary length, returning the result in an array of length za.length + zb.length - 1 . |
static ComplexBusted[] |
correl(ComplexBusted[] za,
ComplexBusted[] zb)
This method calculates the cross-correlation between two Complex
arrays. |
static ComplexBusted[] |
correl(ComplexBusted[] za,
ComplexBusted[] zb,
boolean norm)
This method calculates the cross-correlation between two Complex
arrays. |
static double[] |
correl(double[] xa,
double[] xb)
This method calculates the cross-correlation between two double
arrays. |
static double[] |
correl(double[] xa,
double[] xb,
boolean normalize)
This method calculates the cross-correlation between two double
arrays. |
static ComplexBusted[] |
fft(ComplexBusted[] z)
This method calculates the Fast Fourier Transform of a Complex
array, provided that the length of the array is a power of 2. |
static ComplexBusted[] |
fft(ComplexBusted[] z,
int size)
This method calculates the Fast Fourier Transform of a Complex
array, provided that the length of the array is a power of 2. |
static ComplexBusted[] |
fftswap(ComplexBusted[] z)
This method shifts the output of an FFT so that the dc component appears in the middle of the spectrum. |
static double[] |
fftswap(double[] d)
This method shifts the output of an FFT so that the dc component appears in the middle of the spectrum. |
static ComplexBusted[] |
ifft(ComplexBusted[] z)
This method calculates the inverse Fast Fourier Transform of a Complex
array, provided that the length of the array is a power of 2. |
static ComplexBusted[] |
ifft(ComplexBusted[] z,
int size)
This method calculates the inverse Fast Fourier Transform of a Complex
array, provided that the length of the array is a power of 2. |
static int |
nextMul(int arraySize)
This method calculates the power of two greater than or equal to a given input size. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean NO_NORM
public static final boolean NORM
Constructor Detail |
---|
public SigProc()
Method Detail |
---|
public static double[] calcFreq(double fs, int fftSize)
fs
- The sampling frequency of the input data to the FFTfftSize
- The size of the FFT.
public static ComplexBusted[] correl(ComplexBusted[] za, ComplexBusted[] zb)
Complex
arrays. It can also be used to generate the autocorrelation by simply
using the same array for both arguments. Note that this algorithm returns
the auto- or cross-correlations for all possible lags. It is possible to
reduce the computational load if fewer lags are required. For that case, you
should consider using a different algorithm.
This algorithm accepts input arrays za
and zb
of
arbitrary length. It returns an array whose length za.length + zb.length - 1
.
The resulting array has zero lag in the element with index za.length/2 - 1
.
This algorithm is designed so that if zb
lags za
,
(is shifted to the right of it), then the peak of the cross correlation function
will appear at indices greater than za.length/2 - 1
. If
zb
leads za
, then the peak of the cross
correlation function will appear at indices less than
za.length/2 - 1
.
Method calcLags
may be used to calculate the lag associated
with each position in the output array.
za
- Input array 1.zb
- Input array 2.
za
and zb
.calcLags(math.complex.ComplexBusted[], math.complex.ComplexBusted[])
public static double[] correl(double[] xa, double[] xb)
double
arrays. It can also be used to generate the autocorrelation by simply
using the same array for both arguments. Note that this algorithm returns
the auto- or cross-correlations for all possible lags. It is possible to
reduce the computational load if fewer lags are required. For that case, you
should consider using a different algorithm.
This algorithm accepts input arrays xa
and xb
of
arbitrary length. It returns an array whose length xa.length + xb.length - 1
.
The resulting array has zero lag in the element with index xa.length/2 - 1
.
This algorithm is designed so that if xb
lags xa
,
(is shifted to the right of it), then the peak of the cross correlation function
will appear at indices greater than xa.length/2 - 1
. If
xb
leads xa
, then the peak of the cross
correlation function will appear at indices less than
xa.length/2 - 1
.
Method calcLags
may be used to calculate the lag associated
with each position in the output array.
xa
- Input array 1.xb
- Input array 2.
xa
and xb
.calcLags(double[],double[])
public static ComplexBusted[] correl(ComplexBusted[] za, ComplexBusted[] zb, boolean norm)
Complex
arrays. It can also be used to generate the autocorrelation by simply
using the same array for both arguments. Note that this algorithm returns
the auto- or cross-correlations for all possible lags. It is possible to
reduce the computational load if fewer lags are required. For that case, you
should consider using a different algorithm.
The third input parameter specifies the type of normalization to be applied
to the cross correlation. The value NONORM
specifies that no
normalization should be performed. The value NORM
specifies that
the output cross correlation should be divided by the constant
With this normalization, the peak of the cross correlation function will be 1.0 if and only if the two arrays are identical except for lag. If the two arrays differ, the cross-correlation will be less than 1.0, and the size of the value will be a measure of the similarity between the two arrays.constant = 1 / sqrt( sum(abs(za)^2) * sum(abs(zb)^2) );
This algorithm accepts input arrays za
and zb
of
arbitrary length. It returns an array whose length za.length + zb.length - 1
.
The resulting array has zero lag in the element with index za.length/2 - 1
.
This algorithm is designed so that if zb
lags za
,
(is shifted to the right of it), then the peak of the cross correlation function
will appear at indices greater than za.length/2 - 1
. If
zb
leads za
, then the peak of the cross
correlation function will appear at indices less than
za.length/2 - 1
.
Method calcLags
may be used to calculate the lag associated
with each position in the output array.
za
- Input array 1.zb
- Input array 2.
za
and zb
.calcLags(math.complex.ComplexBusted[], math.complex.ComplexBusted[])
public static double[] correl(double[] xa, double[] xb, boolean normalize)
double
arrays. It can also be used to generate the autocorrelation by simply
using the same array for both arguments. Note that this algorithm returns
the auto- or cross-correlations for all possible lags. It is possible to
reduce the computational load if fewer lags are required. For that case, you
should consider using a different algorithm.
The third input parameter specifies the type of normalixation to be applied
to the cross correlation. The value NONORM
specifies that no
normalixation should be performed. The value NORM
specifies that
the output cross correlation should be divided by the constant
With this normalixation, the peak of the cross correlation function will be 1.0 if and only if the two arrays are identical except for lag. If the two arrays differ, the cross-correlation will be less than 1.0, and the size of the value will be a measure of the similarity between the two arrays.constant = 1 / sqrt( sum(abs(xa)^2) * sum(abs(xb)^2) );
This algorithm accepts input arrays xa
and xb
of
arbitrary length. It returns an array whose length xa.length + xb.length - 1
.
The resulting array has zero lag in the element with index xa.length/2 - 1
.
This algorithm is designed so that if xb
lags xa
,
(is shifted to the right of it), then the peak of the cross correlation function
will appear at indices greater than xa.length/2 - 1
. If
xb
leads xa
, then the peak of the cross
correlation function will appear at indices less than
xa.length/2 - 1
.
Method calcLags
may be used to calculate the lag associated
with each position in the output array.
xa
- Input array 1.xb
- Input array 2.
xa
and xb
.calcLags(double[],double[])
public static ComplexBusted[] conv(ComplexBusted[] za, ComplexBusted[] zb)
za.length + zb.length - 1
.
za
- Input array 1.zb
- Input array 2.
za
and zb
.public static ComplexBusted[] fft(ComplexBusted[] z) throws math.fourierTransforms.SigProc.InvalidArraySizeException
Complex
array, provided that the length of the array is a power of 2. If the array
length is not a power of two, the method throws an
InvalidArraySizeException
. This method does not destroy its
input data.
z
- The input array.
z
.
InvalidArraySizeException
- if the array length is not a
power of 2
math.fourierTransforms.SigProc.InvalidArraySizeException
public static ComplexBusted[] fft(ComplexBusted[] z, int size) throws math.fourierTransforms.SigProc.InvalidArraySizeException
Complex
array, provided that the length of the array is a power of 2. If the array
length is not a power of two, the method throws an
InvalidArraySizeException
. This method does not destroy its
input data.
z
- The input array.
z
.
InvalidArraySizeException
- if the array length is not a
power of 2
math.fourierTransforms.SigProc.InvalidArraySizeException
public static ComplexBusted[] fftswap(ComplexBusted[] z)
z
- The input array.
z
swapped.public static double[] fftswap(double[] d)
d
- The input array.
d
swapped.public static ComplexBusted[] ifft(ComplexBusted[] z) throws math.fourierTransforms.SigProc.InvalidArraySizeException
Complex
array, provided that the length of the array is a power of 2. If the array
lengty is not a power of two, the method throws an
InvalidArraySizeException
. This method does not destroy its
input data.
z
- The input array.
z
.
InvalidArraySizeException
- if the array length is not a
power of 2
math.fourierTransforms.SigProc.InvalidArraySizeException
public static ComplexBusted[] ifft(ComplexBusted[] z, int size) throws math.fourierTransforms.SigProc.InvalidArraySizeException
Complex
array, provided that the length of the array is a power of 2. If the array
lengty is not a power of two, the method throws an
InvalidArraySizeException
. This method does not destroy its
input data.
z
- The input array.
z
.
InvalidArraySizeException
- if the array length is not a
power of 2
math.fourierTransforms.SigProc.InvalidArraySizeException
public static int nextMul(int arraySize)
arraySize
- The input size
int
containing the required power of two.public static double[] calcLags(double[] xa, double[] xb)
xa
- The input values for array 1xb
- The input values for array 2
za
and zb
public static double[] calcLags(ComplexBusted[] za, ComplexBusted[] zb)
za
- The input values for array 1zb
- The input values for array 2
za
and zb
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |