Class FastCosineTransformer
- java.lang.Object
-
- org.apache.commons.math.transform.FastCosineTransformer
-
- All Implemented Interfaces:
RealTransformer
public class FastCosineTransformer extends Object implements RealTransformer
Implements the Fast Cosine Transform for transformation of one-dimensional data sets. For reference, see Fast Fourier Transforms, ISBN 0849371635, chapter 3.FCT is its own inverse, up to a multiplier depending on conventions. The equations are listed in the comments of the corresponding methods.
Different from FFT and FST, FCT requires the length of data set to be power of 2 plus one. Users should especially pay attention to the function transformation on how this affects the sampling.
As of version 2.0 this no longer implements Serializable
- Since:
- 1.2
-
-
Constructor Summary
Constructors Constructor Description FastCosineTransformer()
Construct a default transformer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double[]
inversetransform(double[] f)
Inversely transform the given real data set.double[]
inversetransform(UnivariateRealFunction f, double min, double max, int n)
Inversely transform the given real function, sampled on the given interval.double[]
inversetransform2(double[] f)
Inversely transform the given real data set.double[]
inversetransform2(UnivariateRealFunction f, double min, double max, int n)
Inversely transform the given real function, sampled on the given interval.double[]
transform(double[] f)
Transform the given real data set.double[]
transform(UnivariateRealFunction f, double min, double max, int n)
Transform the given real function, sampled on the given interval.double[]
transform2(double[] f)
Transform the given real data set.double[]
transform2(UnivariateRealFunction f, double min, double max, int n)
Transform the given real function, sampled on the given interval.
-
-
-
Method Detail
-
transform
public double[] transform(double[] f) throws IllegalArgumentException
Transform the given real data set.The formula is Fn = (1/2) [f0 + (-1)n fN] + ∑k=1N-1 fk cos(π nk/N)
- Specified by:
transform
in interfaceRealTransformer
- Parameters:
f
- the real data array to be transformed- Returns:
- the real transformed array
- Throws:
IllegalArgumentException
- if any parameters are invalid
-
transform
public double[] transform(UnivariateRealFunction f, double min, double max, int n) throws FunctionEvaluationException, IllegalArgumentException
Transform the given real function, sampled on the given interval.The formula is Fn = (1/2) [f0 + (-1)n fN] + ∑k=1N-1 fk cos(π nk/N)
- Specified by:
transform
in interfaceRealTransformer
- Parameters:
f
- the function to be sampled and transformedmin
- the lower bound for the intervalmax
- the upper bound for the intervaln
- the number of sample points- Returns:
- the real transformed array
- Throws:
FunctionEvaluationException
- if function cannot be evaluated at some pointIllegalArgumentException
- if any parameters are invalid
-
transform2
public double[] transform2(double[] f) throws IllegalArgumentException
Transform the given real data set.The formula is Fn = √(1/2N) [f0 + (-1)n fN] + √(2/N) ∑k=1N-1 fk cos(π nk/N)
- Parameters:
f
- the real data array to be transformed- Returns:
- the real transformed array
- Throws:
IllegalArgumentException
- if any parameters are invalid
-
transform2
public double[] transform2(UnivariateRealFunction f, double min, double max, int n) throws FunctionEvaluationException, IllegalArgumentException
Transform the given real function, sampled on the given interval.The formula is Fn = √(1/2N) [f0 + (-1)n fN] + √(2/N) ∑k=1N-1 fk cos(π nk/N)
- Parameters:
f
- the function to be sampled and transformedmin
- the lower bound for the intervalmax
- the upper bound for the intervaln
- the number of sample points- Returns:
- the real transformed array
- Throws:
FunctionEvaluationException
- if function cannot be evaluated at some pointIllegalArgumentException
- if any parameters are invalid
-
inversetransform
public double[] inversetransform(double[] f) throws IllegalArgumentException
Inversely transform the given real data set.The formula is fk = (1/N) [F0 + (-1)k FN] + (2/N) ∑n=1N-1 Fn cos(π nk/N)
- Specified by:
inversetransform
in interfaceRealTransformer
- Parameters:
f
- the real data array to be inversely transformed- Returns:
- the real inversely transformed array
- Throws:
IllegalArgumentException
- if any parameters are invalid
-
inversetransform
public double[] inversetransform(UnivariateRealFunction f, double min, double max, int n) throws FunctionEvaluationException, IllegalArgumentException
Inversely transform the given real function, sampled on the given interval.The formula is fk = (1/N) [F0 + (-1)k FN] + (2/N) ∑n=1N-1 Fn cos(π nk/N)
- Specified by:
inversetransform
in interfaceRealTransformer
- Parameters:
f
- the function to be sampled and inversely transformedmin
- the lower bound for the intervalmax
- the upper bound for the intervaln
- the number of sample points- Returns:
- the real inversely transformed array
- Throws:
FunctionEvaluationException
- if function cannot be evaluated at some pointIllegalArgumentException
- if any parameters are invalid
-
inversetransform2
public double[] inversetransform2(double[] f) throws IllegalArgumentException
Inversely transform the given real data set.The formula is fk = √(1/2N) [F0 + (-1)k FN] + √(2/N) ∑n=1N-1 Fn cos(π nk/N)
- Parameters:
f
- the real data array to be inversely transformed- Returns:
- the real inversely transformed array
- Throws:
IllegalArgumentException
- if any parameters are invalid
-
inversetransform2
public double[] inversetransform2(UnivariateRealFunction f, double min, double max, int n) throws FunctionEvaluationException, IllegalArgumentException
Inversely transform the given real function, sampled on the given interval.The formula is fk = √(1/2N) [F0 + (-1)k FN] + √(2/N) ∑n=1N-1 Fn cos(π nk/N)
- Parameters:
f
- the function to be sampled and inversely transformedmin
- the lower bound for the intervalmax
- the upper bound for the intervaln
- the number of sample points- Returns:
- the real inversely transformed array
- Throws:
FunctionEvaluationException
- if function cannot be evaluated at some pointIllegalArgumentException
- if any parameters are invalid
-
-