Class FastSineTransformer

java.lang.Object
org.apache.commons.math.transform.FastSineTransformer
All Implemented Interfaces:
RealTransformer

public class FastSineTransformer extends Object implements RealTransformer
Implements the Fast Sine Transform for transformation of one-dimensional data sets. For reference, see Fast Fourier Transforms, ISBN 0849371635, chapter 3.

FST is its own inverse, up to a multiplier depending on conventions. The equations are listed in the comments of the corresponding methods.

Similar to FFT, we also require the length of data set to be power of 2. In addition, the first element must be 0 and it's enforced in function transformation after sampling.

As of version 2.0 this no longer implements Serializable

Since:
1.2
Version:
$Revision: 1070725 $ $Date: 2011-02-15 02:31:12 +0100 (mar. 15 févr. 2011) $
  • Constructor Details

    • FastSineTransformer

      public FastSineTransformer()
      Construct a default transformer.
  • Method Details

    • transform

      public double[] transform(double[] f) throws IllegalArgumentException
      Transform the given real data set.

      The formula is Fn = ∑k=0N-1 fk sin(π nk/N)

      Specified by:
      transform in interface RealTransformer
      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 = ∑k=0N-1 fk sin(π nk/N)

      Specified by:
      transform in interface RealTransformer
      Parameters:
      f - the function to be sampled and transformed
      min - the lower bound for the interval
      max - the upper bound for the interval
      n - the number of sample points
      Returns:
      the real transformed array
      Throws:
      FunctionEvaluationException - if function cannot be evaluated at some point
      IllegalArgumentException - if any parameters are invalid
    • transform2

      public double[] transform2(double[] f) throws IllegalArgumentException
      Transform the given real data set.

      The formula is Fn = √(2/N) ∑k=0N-1 fk sin(π 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 = √(2/N) ∑k=0N-1 fk sin(π nk/N)

      Parameters:
      f - the function to be sampled and transformed
      min - the lower bound for the interval
      max - the upper bound for the interval
      n - the number of sample points
      Returns:
      the real transformed array
      Throws:
      FunctionEvaluationException - if function cannot be evaluated at some point
      IllegalArgumentException - if any parameters are invalid
    • inversetransform

      public double[] inversetransform(double[] f) throws IllegalArgumentException
      Inversely transform the given real data set.

      The formula is fk = (2/N) ∑n=0N-1 Fn sin(π nk/N)

      Specified by:
      inversetransform in interface RealTransformer
      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 = (2/N) ∑n=0N-1 Fn sin(π nk/N)

      Specified by:
      inversetransform in interface RealTransformer
      Parameters:
      f - the function to be sampled and inversely transformed
      min - the lower bound for the interval
      max - the upper bound for the interval
      n - the number of sample points
      Returns:
      the real inversely transformed array
      Throws:
      FunctionEvaluationException - if function cannot be evaluated at some point
      IllegalArgumentException - if any parameters are invalid
    • inversetransform2

      public double[] inversetransform2(double[] f) throws IllegalArgumentException
      Inversely transform the given real data set.

      The formula is fk = √(2/N) ∑n=0N-1 Fn sin(π 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 = √(2/N) ∑n=0N-1 Fn sin(π nk/N)

      Parameters:
      f - the function to be sampled and inversely transformed
      min - the lower bound for the interval
      max - the upper bound for the interval
      n - the number of sample points
      Returns:
      the real inversely transformed array
      Throws:
      FunctionEvaluationException - if function cannot be evaluated at some point
      IllegalArgumentException - if any parameters are invalid
    • fst

      protected double[] fst(double[] f) throws IllegalArgumentException
      Perform the FST algorithm (including inverse).
      Parameters:
      f - the real data array to be transformed
      Returns:
      the real transformed array
      Throws:
      IllegalArgumentException - if any parameters are invalid