org.apache.commons.math.transform

## Class FastFourierTransformer.RootsOfUnity

- java.lang.Object
- - org.apache.commons.math.transform.FastFourierTransformer.RootsOfUnity

- All Implemented Interfaces:
    Serializable
  Enclosing class:
    FastFourierTransformer

      private static class FastFourierTransformer.RootsOfUnity
      extends Object
      implements Serializable

  Computes the nth roots of unity. A cache of already computed values is maintained.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private boolean` | `isForward` Forward/reverse indicator.
    `private int` | `omegaCount` Number of roots of unity.
    `private double[]` | `omegaImaginaryForward` Imaginary part of the roots for forward transform.
    `private double[]` | `omegaImaginaryInverse` Imaginary part of the roots for reverse transform.
    `private double[]` | `omegaReal` Real part of the roots.
    `private static long` | `serialVersionUID` Serializable version id.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FastFourierTransformer.RootsOfUnity()` Build an engine for computing then th roots of unity

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `computeOmega(int n)` Computes the nth roots of unity.
    `double` | `getOmegaImaginary(int k)` Get the imaginary part of the kth nth root of unity
    `double` | `getOmegaReal(int k)` Get the real part of the kth nth root of unity
    `boolean` | `isForward()` Check if computation has been done for forward or reverse transform.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### serialVersionUID

          private static final long serialVersionUID

      Serializable version id.
      See Also:
        Constant Field Values

    - #### omegaCount

          private int omegaCount

      Number of roots of unity.

    - #### omegaReal

          private double[] omegaReal

      Real part of the roots.

    - #### omegaImaginaryForward

          private double[] omegaImaginaryForward

      Imaginary part of the roots for forward transform.

    - #### omegaImaginaryInverse

          private double[] omegaImaginaryInverse

      Imaginary part of the roots for reverse transform.

    - #### isForward

          private boolean isForward

      Forward/reverse indicator.

  - ### Constructor Detail

    - #### FastFourierTransformer.RootsOfUnity

          public FastFourierTransformer.RootsOfUnity()

      Build an engine for computing then th roots of unity

  - ### Method Detail

    - #### isForward

          public boolean isForward()
                            throws IllegalStateException

      Check if computation has been done for forward or reverse transform.
      Returns:
        true if computation has been done for forward transform
      Throws:
        `IllegalStateException` - if no roots of unity have been computed yet

    - #### computeOmega

          public void computeOmega(int n)
                            throws IllegalArgumentException

      Computes the nth roots of unity.

      The computed omega[] = { 1, w, w2, ... w(n-1) } where w = exp(-2 π i / n), i = &sqrt;(-1).

      Note that n is positive for forward transform and negative for inverse transform.

      Parameters:
        `n` - number of roots of unity to compute, positive for forward transform, negative for inverse transform
      Throws:
        `IllegalArgumentException` - if n = 0

    - #### getOmegaReal

          public double getOmegaReal(int k)
                              throws IllegalStateException,
                                     IllegalArgumentException

      Get the real part of the kth nth root of unity
      Parameters:
        `k` - index of the nth root of unity
      Returns:
        real part of the kth nth root of unity
      Throws:
        `IllegalStateException` - if no roots of unity have been computed yet
        `IllegalArgumentException` - if k is out of range

    - #### getOmegaImaginary

          public double getOmegaImaginary(int k)
                                   throws IllegalStateException,
                                          IllegalArgumentException

      Get the imaginary part of the kth nth root of unity
      Parameters:
        `k` - index of the nth root of unity
      Returns:
        imaginary part of the kth nth root of unity
      Throws:
        `IllegalStateException` - if no roots of unity have been computed yet
        `IllegalArgumentException` - if k is out of range

Copyright (c) 2003-2013 Apache Software Foundation