public class FourierExpTransform
extends java.lang.Object
Class embodying the classic Discrete Fourier Transform (DFT). Although this is a discrete transform, it is not a Fast Fourier Transform (FFT). Specifically, we do not exploit the dyadic nature of the transform kernel. In fact, we explicitly compute both the forward and inverse kernels which, in the discrete version, are matrices. Thus, the transform can potentially be expensive for large signal sizes (of order O(N²)). The advantage here is that we may consider arbitrary signal sizes N > 0. That is, N does not need to be a power of 2 as with the FFT, requiring the given signal to be padded accordingly.
The transform performed here is given by
[f^] = [K]·[f]
where [f^] is the complex vector of DFT data, [K] is the complex symmetric matrix
kernel, and [f] is the real vector (e.i., type double[]
) of input function
values. The elements
Kmn of the matrix kernel are given by
Kmn = z-mn/N½
where N is the size of the data vector [f], indices m, n range over the
values 0,…,N-1, and z is the generator of the transform kernel given by
z ≡ ei2π/N
The factor 1/N½ is a normalization
constant; specifically, the value of the L2 norm
||ei2πn/N||.
The inverse transform (back to the "time" domain) is given by
[f] = [K-1]·[f^]
where the elements Kmn-1 of the kernel are given by
Kmn-1 = zmn/N½
Clearly [K-1]·[K] = [I] where [I] is the
N×N identity matrix.
From the value of Kmn and z it can be inferred that the stride in [f^] is 1/T, where T is the length of the time interval over which f is taken. Because the DFT considers both positive and negative frequency components, the largest frequency we can see is ½N/T, corresponding to the discrete frequency N/2. Referring to the definition of z, the positive (discrete) frequency components cover the indices n = 0,…,floor(N/2) while the negative frequency components are located at the indices n = floor(N/2)+1,…,N-1 (in reverse order). Topologically, the positive frequencies {n} occur for zn on the top half-plane and the negative frequencies {n} occur for zn on the bottom half-plane.
Constructor and Description |
---|
FourierExpTransform(int szData)
Create a new sine transform object for transforming data vectors of
size szData.
|
Modifier and Type | Method and Description |
---|---|
double |
compFreqStrideFromInterval(double dblDelta)
Compute and return the value of the frequency stride for this transform
given the time stride (time interval between data points).
|
double |
compFreqStrideFromPeriod(double dblPeriod)
Compute and return the value of the frequency stride for this transform
given the total time period over which the data is taken.
|
int |
getDataSize()
Return the expected size of the data, which is also the dimensions of the
kernel.
|
JSci.maths.Complex |
getKernelGenerator()
Return the exponential transform generator.
|
double[] |
inverse(JSci.maths.vectors.AbstractComplexVector vecTrans)
Compute and return the Fourier exponential transform of the given function.
|
double[] |
powerSpectrum(double[] arrFunc)
Compute and return the discrete power spectrum for the given function.
|
java.lang.String |
toString()
Write out contents to string.
|
JSci.maths.vectors.AbstractComplexVector |
transform(double[] arrFunc)
Compute and return the Fourier exponential transform of the given function.
|
public FourierExpTransform(int szData)
double[]
object of the appropriate size.szData
- FourierSineTransform.transform(double[])
public int getDataSize()
public JSci.maths.Complex getKernelGenerator()
Return the exponential transform generator. All the inverse transform kernel elements are multiples of the this value while all forward transform kernel elements are multiples of the inverse of this value.
Note that z lies on the unit circle of the complex plane.
public double compFreqStrideFromPeriod(double dblPeriod)
dblPeriod
- total length of the data windowpublic double compFreqStrideFromInterval(double dblDelta)
dblDelta
- time interval between data pointspublic JSci.maths.vectors.AbstractComplexVector transform(double[] arrFunc) throws java.lang.IllegalArgumentException
Compute and return the Fourier exponential transform of the given function.
The returned values are ordered so that the lowest frequency components come first. That is, the components are indexed according to their discrete frequency. Note also that the zero-frequency component of a sine transform is identically zero, as is the Nth component. Thus, the first and last values will always be zero.
arrFunc
- vector array of function values (zero values on either end)java.lang.IllegalArgumentException
- invalid function dimensionpublic double[] inverse(JSci.maths.vectors.AbstractComplexVector vecTrans) throws java.lang.IllegalArgumentException
Compute and return the Fourier exponential transform of the given function.
The returned values are ordered so that the lowest frequency components come first. That is, the components are indexed according to their discrete frequency. Note also that the zero-frequency component of a sine transform is identically zero, as is the Nth component. Thus, the first and last values will always be zero.
vecTrans
- vector array of inverse transform values (zero values on either end)java.lang.IllegalArgumentException
- invalid function dimensionpublic double[] powerSpectrum(double[] arrFunc) throws java.lang.IllegalArgumentException
Compute and return the discrete power spectrum for the given function. The power spectrum is the square of the frequency spectrum and, therefore, is always real and positive.
The returned values are ordered so that the lowest frequency components are located at the end points. Specifically, due to the nature of the discrete Fourier transform the spectrum has the topology of the circle. The frequency N - 1 is actually the negative frequency -1. Thus, the negative frequency -n is located at index N - n. The largest frequency is at index N/2.
arrFunc
- discrete functionjava.lang.IllegalArgumentException
- invalid function dimensionpublic java.lang.String toString()
toString
in class java.lang.Object
Object.toString()