public class FourierSineTransform
extends java.lang.Object
This class encapsulates many aspects of the Fourier sine transform. Although this is a discrete transform, it is not a Fast Fourier Transform (FFT). Specifically, we do not fully exploit the dyadic nature of the transform kernel. In fact, we explicitly compute this kernel which, in the discrete version, is a matrix. Thus, this transform can potentially be quite expensive for large data sets. What we have here then, is essentially a convenient wrapper around a real, symmetric matrix which makes this class look like a magical transformer.
The advantages of the sine transform are that it only involves real numbers (i.e., primitives
of type double
). The transform is somewhat generalized in that we assume a base
frequency of π rather than 2π so that we can transform even
functions as well as odd ones. (The FFT has "positive" and "negative" frequencies.)
The only caveat is that the function f being transformed
is assumed to have value zero at the boundaries (as does the sine kernel). There are two
approaches here, either we pad the given function by zero (adding two data points), or we
construct the transform so that the recovered function (via inverse transform) always has a
zero values at the boundaries. Here we choose the later, preferring not to change the dimensions
of the data.
The transform performed here is given by
[f^] = [K]·[f]
From the value of Kmn we see that the stride in [f^] is 1/2T, where T is the period of the interval over which f is defined. Thus, the largest frequency we can see is (N-1)/2T. Also, we see that there is no specific DC component. That is, the DC (or zero-frequency) component of the signal has a projection upon all the odd-frequency components in this general Fourier sine transform. Thus, it cannot be identified separately as in the traditional Fourier transform.
Constructor and Description |
---|
FourierSineTransform(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.
|
double[] |
powerSpectrum(double[] arrFunc)
Compute and return the discrete power spectrum for the given function.
|
double[] |
transform(double[] arrFunc)
Compute and return the Fourier sine transform of the given function.
|
public FourierSineTransform(int szData)
double[]
object of the appropriate size.szData
- transform(double[])
public int getDataSize()
public double compFreqStrideFromPeriod(double dblPeriod)
dblPeriod
- total length of the data windowpublic double compFreqStrideFromInterval(double dblDelta)
dblDelta
- time interval between data pointspublic double[] transform(double[] arrFunc) throws java.lang.IllegalArgumentException
Compute and return the Fourier sine transform of the given function. Note that this transform is essential dual to itself, thus, the transform and the inverse transform are the same operation. This fact follows from the normalization used so that the transform matrix is essentially a root of unity.
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[] 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 positive.
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
- discrete functionjava.lang.IllegalArgumentException
- invalid function dimension