public class RootsOfUnity
extends java.lang.Object
implements java.io.Serializable
n
-th roots of
unity.Modifier and Type | Field and Description |
---|---|
private boolean |
isCounterClockWise
|
private int |
omegaCount
Number of roots of unity.
|
private double[] |
omegaImaginaryClockwise
Imaginary part of the
n -th roots of unity, for negative values
of n . |
private double[] |
omegaImaginaryCounterClockwise
Imaginary part of the
n -th roots of unity, for positive values
of n . |
private double[] |
omegaReal
Real part of the roots.
|
private static long |
serialVersionUID
Serializable version id.
|
Constructor and Description |
---|
RootsOfUnity()
Build an engine for computing the
n -th roots of unity. |
Modifier and Type | Method and Description |
---|---|
void |
computeRoots(int n)
Computes the
n -th roots of unity. |
double |
getImaginary(int k)
Get the imaginary part of the
k -th n -th root of unity. |
int |
getNumberOfRoots()
Returns the number of roots of unity currently stored.
|
double |
getReal(int k)
Get the real part of the
k -th n -th root of unity. |
boolean |
isCounterClockWise()
|
private static final long serialVersionUID
private int omegaCount
private double[] omegaReal
private double[] omegaImaginaryCounterClockwise
n
-th roots of unity, for positive values
of n
. In this array, the roots are stored in counter-clockwise
order.private double[] omegaImaginaryClockwise
n
-th roots of unity, for negative values
of n
. In this array, the roots are stored in clockwise order.private boolean isCounterClockWise
true
if computeRoots(int)
was called with a positive
value of its argument n
. In this case, counter-clockwise ordering
of the roots of unity should be used.public RootsOfUnity()
n
-th roots of unity.public boolean isCounterClockWise() throws MathIllegalStateException
true
if computeRoots(int)
was called with a
positive value of its argument n
. If true
, then
counter-clockwise ordering of the roots of unity should be used.true
if the roots of unity are stored in
counter-clockwise orderMathIllegalStateException
- if no roots of unity have been computed
yetpublic void computeRoots(int n) throws ZeroException
Computes the n
-th roots of unity. The roots are stored in
omega[]
, such that omega[k] = w ^ k
, where
k = 0, ..., n - 1
, w = exp(2 * pi * i / n)
and
i = sqrt(-1)
.
Note that n
can be positive of negative
abs(n)
is always the number of roots of unity.n > 0
, then the roots are stored in counter-clockwise order.n < 0
, then the roots are stored in clockwise order.
n
- the (signed) number of roots of unity to be computedZeroException
- if n = 0
public double getReal(int k) throws MathIllegalStateException, MathIllegalArgumentException
k
-th n
-th root of unity.k
- index of the n
-th root of unityk
-th n
-th root of unityMathIllegalStateException
- if no roots of unity have been
computed yetMathIllegalArgumentException
- if k
is out of rangepublic double getImaginary(int k) throws MathIllegalStateException, OutOfRangeException
k
-th n
-th root of unity.k
- index of the n
-th root of unityk
-th n
-th root of unityMathIllegalStateException
- if no roots of unity have been
computed yetOutOfRangeException
- if k
is out of rangepublic int getNumberOfRoots()
computeRoots(int)
was called with n
, then this method
returns abs(n)
. If no roots of unity have been computed yet, this
method returns 0.Copyright (c) 2003-2014 Apache Software Foundation