Class RootsOfUnity

    • Constructor Detail

      • RootsOfUnity

        public RootsOfUnity()
        Build an engine for computing the n-th roots of unity.
    • Method Detail

      • isCounterClockWise

        public boolean isCounterClockWise()
                                   throws MathIllegalStateException
        Returns 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.
        Returns:
        true if the roots of unity are stored in counter-clockwise order
        Throws:
        MathIllegalStateException - if no roots of unity have been computed yet
      • computeRoots

        public void computeRoots​(int n)
                          throws MathIllegalArgumentException
        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.
        • If n > 0, then the roots are stored in counter-clockwise order.
        • If n < 0, then the roots are stored in clockwise order.
        Parameters:
        n - the (signed) number of roots of unity to be computed
        Throws:
        MathIllegalArgumentException - if n = 0
      • getNumberOfRoots

        public int getNumberOfRoots()
        Returns the number of roots of unity currently stored.

        If 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.

        Returns:
        the number of roots of unity currently stored