You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2018/05/19 12:44:47 UTC

[1/4] commons-numbers git commit: Removed spurious file.

Repository: commons-numbers
Updated Branches:
  refs/heads/master 65b5d844c -> 404189559


Removed spurious file.


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/8e0af85b
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/8e0af85b
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/8e0af85b

Branch: refs/heads/master
Commit: 8e0af85b674c00c777d5233e5cd8c4214e756e99
Parents: 65b5d84
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Sat May 19 14:28:52 2018 +0200
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Sat May 19 14:28:52 2018 +0200

----------------------------------------------------------------------
 .../commons/numbers/complex/Complex.java.orig   | 1347 ------------------
 1 file changed, 1347 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/8e0af85b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java.orig
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java.orig b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java.orig
deleted file mode 100644
index 3e31177..0000000
--- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java.orig
+++ /dev/null
@@ -1,1347 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.numbers.complex;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.commons.numbers.core.Precision;
-/**
- * Representation of a Complex number, i.e. a number which has both a
- * real and imaginary part.
- * <p>
- * Implementations of arithmetic operations handle {@code NaN} and
- * infinite values according to the rules for {@link java.lang.Double}, i.e.
- * {@link #equals} is an equivalence relation for all instances that have
- * a {@code NaN} in either real or imaginary part, e.g. the following are
- * considered equal:
- * <ul>
- *  <li>{@code 1 + NaNi}</li>
- *  <li>{@code NaN + i}</li>
- *  <li>{@code NaN + NaNi}</li>
- * </ul><p>
- * Note that this contradicts the IEEE-754 standard for floating
- * point numbers (according to which the test {@code x == x} must fail if
- * {@code x} is {@code NaN}). The method
- * {@link org.apache.commons.numbers.core.Precision#equals(double,double,int)
- * equals for primitive double} in class {@code Precision} conforms with
- * IEEE-754 while this class conforms with the standard behavior for Java
- * object types.</p>
- *
- */
-public class Complex implements Serializable  {
-    /** The square root of -1. A number representing "0.0 + 1.0i" */
-    public static final Complex I = new Complex(0, 1);
-    // CHECKSTYLE: stop ConstantName
-    /** A complex number representing "NaN + NaNi" */
-    public static final Complex NAN = new Complex(Double.NaN, Double.NaN);
-    // CHECKSTYLE: resume ConstantName
-    /** A complex number representing "+INF + INFi" */
-    public static final Complex INF = new Complex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
-    /** A complex number representing "1.0 + 0.0i" */
-    public static final Complex ONE = new Complex(1, 0);
-    /** A complex number representing "0.0 + 0.0i" */
-    public static final Complex ZERO = new Complex(0, 0);
-
-    /** Serializable version identifier */
-    private static final long serialVersionUID = 20180201L;
-
-    /** The imaginary part. */
-    private final double imaginary;
-    /** The real part. */
-    private final double real;
-
-    /**
-     * Create a complex number given only the real part.
-     *
-     * @param real Real part.
-     */
-    public Complex(double real) {
-        this(real, 0);
-    }
-
-     /**
-     * Create a complex number given the real and imaginary parts.
-     *
-     * @param real Real part.
-     * @param imaginary Imaginary part.
-     */
-    public Complex(double real, double imaginary) {
-        this.real = real;
-        this.imaginary = imaginary;
-    }
-
-     /**
-     * Creates a Complex from its polar representation.
-     *
-     * If {@code r} is infinite and {@code theta} is finite, infinite or NaN
-     * values may be returned in parts of the result, following the rules for
-     * double arithmetic.
-     *
-     * <pre>
-     * Examples:
-     * {@code
-     * polar2Complex(INFINITY, \(\pi\)) = INFINITY + INFINITY i
-     * polar2Complex(INFINITY, 0) = INFINITY + NaN i
-     * polar2Complex(INFINITY, \(-\frac{\pi}{4}\)) = INFINITY - INFINITY i
-     * polar2Complex(INFINITY, \(5\frac{\pi}{4}\)) = -INFINITY - INFINITY i }
-     * </pre>
-     *
-     * @param r the modulus of the complex number to create
-     * @param theta the argument of the complex number to create
-     * @return {@code Complex}
-     */
-    public Complex polar(double r, double theta) {
-        checkNotNegative(r);
-        return new Complex(r * Math.cos(theta), r * Math.sin(theta));
-    }
-
-    /**
-     * For a real constructor argument x, returns a new Complex object c
-     * where {@code c = cos(x) + i sin (x)}
-     *
-     * @param x {@code double} to build the cis number
-     * @return {@code Complex}
-     */
-    public Complex cis(double x) {
-        return new Complex(Math.cos(x), Math.sin(x));
-    }
-
-    /**
-     * Returns true if either real or imaginary component of the Complex
-     * is NaN
-     *
-     * @return {@code boolean}
-     */
-    public boolean isNaN() {
-        if (Double.isNaN(real) ||
-            Double.isNaN(imaginary)) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * Returns true if either real or imaginary component of the Complex
-     * is Infinite
-     *
-     * @return {@code boolean}
-     */
-    public boolean isInfinite() {
-        if (Double.isInfinite(real) ||
-            Double.isInfinite(imaginary)) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * Returns projection of this complex number onto the Riemann sphere,
-     * i.e. all infinities (including those with an NaN component)
-     * project onto real infinity, as described in the
-     * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/cproj.html">
-     * IEEE and ISO C standards</a>.
-     * <p>
-     *
-     *
-     * @return {@code Complex} projected onto the Riemann sphere.
-     */
-    public Complex proj() {
-        if (Double.isInfinite(real) ||
-            Double.isInfinite(imaginary)) {
-            return new Complex(Double.POSITIVE_INFINITY);
-        } else {
-            return this;
-        }
-    }
-
-     /**
-     * Return the absolute value of this complex number.
-<<<<<<< HEAD
-     * This code follows the <a href="http://www.iso-9899.info/wiki/The_Standard">ISO C Standard</a>, Annex G,
-     * in calculating the returned value (i.e. the hypot(x,y) method)
-     * and in handling of NaNs.
-=======
-     * Returns {@code NaN} if either real or imaginary part is {@code NaN}
-     * and {@code Double.POSITIVE_INFINITY} if neither part is {@code NaN},
-     * but at least one part is infinite.
-     * This code follows the
-     * <a href="http://www.iso-9899.info/wiki/The_Standard">ISO C Standard</a>,
-     * Annex G, in calculating the returned value (i.e. the hypot(x,y) method).
->>>>>>> 910cd934b4dab73766954ce595cc5bb2dc79e4c8
-     *
-     * @return the absolute value.
-     */
-    public double abs() {
-        if (Math.abs(real) < Math.abs(imaginary)) {
-            final double q = real / imaginary;
-            return Math.abs(imaginary) * Math.sqrt(1 + q * q);
-        } else {
-            if (real == 0) {
-                return Math.abs(imaginary);
-            }
-            final double q = imaginary / real;
-            return Math.abs(real) * Math.sqrt(1 + q * q);
-        }
-    }
-
-    /**
-     * Return the norm of this complex number, defined as the square of the magnitude
-     * in the <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/cproj.html">
-     * IEEE and ISO C standards</a>.
-     *
-     * @return the norm.
-     */
-    public double norm() {
-        final double a = abs();
-        return a * a;
-    }
-
-    /**
-     * Returns a {@code Complex} whose value is
-     * {@code (this + addend)}.
-     * Uses the definitional formula
-     * <p>
-     *   {@code (a + bi) + (c + di) = (a+c) + (b+d)i}
-     * </p>
-     *
-     * @param  addend Value to be added to this {@code Complex}.
-     * @return {@code this + addend}.
-     */
-    public Complex add(Complex addend) {
-        return new Complex(real + addend.real,
-                           imaginary + addend.imaginary);
-    }
-
-    /**
-     * Returns a {@code Complex} whose value is {@code (this + addend)},
-     * with {@code addend} interpreted as a real number.
-     *
-     * @param addend Value to be added to this {@code Complex}.
-     * @return {@code this + addend}.
-     * @see #add(Complex)
-     */
-    public Complex add(double addend) {
-        return new Complex(real + addend, imaginary);
-    }
-
-     /**
-     * Returns the conjugate of this complex number.
-     * The conjugate of {@code a + bi} is {@code a - bi}.
-     *
-     * @return the conjugate of this complex object.
-     */
-    public Complex conjugate() {
-        return new Complex(real, -imaginary);
-    }
-
-     /**
-     * Returns the conjugate of this complex number.
-     * C++11 grammar.
-     * @return the conjugate of this complex object.
-     */
-    public Complex conj() {
-        return conjugate();
-    }
-
-
-    /**
-     * Returns a {@code Complex} whose value is
-     * {@code (this / divisor)}.
-     * Implements the definitional formula
-     * <pre>
-     *  <code>
-     *    a + bi          ac + bd + (bc - ad)i
-     *    ----------- = -------------------------
-     *    c + di         c<sup>2</sup> + d<sup>2</sup>
-     *  </code>
-     * </pre>
-     * but uses
-     * <a href="http://doi.acm.org/10.1145/1039813.1039814">
-     * prescaling of operands</a> to limit the effects of overflows and
-     * underflows in the computation.
-     * <p>
-     * {@code Infinite} and {@code NaN} values are handled according to the
-     * following rules, applied in the order presented:
-     * <ul>
-     *  <li>If {@code divisor} equals {@link #ZERO}, {@link #NAN} is returned.
-     *  </li>
-     *  <li>If {@code this} and {@code divisor} are both infinite,
-     *   {@link #NAN} is returned.
-     *  </li>
-     *  <li>If {@code this} is finite (i.e., has no {@code Infinite} or
-     *   {@code NaN} parts) and {@code divisor} is infinite (one or both parts
-     *   infinite), {@link #ZERO} is returned.
-     *  </li>
-     *  <li>If {@code this} is infinite and {@code divisor} is finite,
-     *   {@code NaN} values are returned in the parts of the result if the
-     *   {@link java.lang.Double} rules applied to the definitional formula
-     *   force {@code NaN} results.
-     *  </li>
-     * </ul>
-     *
-     * @param divisor Value by which this {@code Complex} is to be divided.
-     * @return {@code this / divisor}.
-     */
-    public Complex divide(Complex divisor) {
-
-        final double c = divisor.real;
-        final double d = divisor.imaginary;
-        if (c == 0 &&
-            d == 0) {
-            return NAN;
-        }
-
-        if ((Double.isInfinite(c) ||
-             Double.isInfinite(d)) &&
-            (Double.isInfinite(real) ||
-             Double.isInfinite(imaginary))) {
-            return ZERO;
-        }
-
-        if (Math.abs(c) < Math.abs(d)) {
-            final double q = c / d;
-            final double denominator = c * q + d;
-            return new Complex((real * q + imaginary) / denominator,
-                               (imaginary * q - real) / denominator);
-        } else {
-            final double q = d / c;
-            final double denominator = d * q + c;
-            return new Complex((imaginary * q + real) / denominator,
-                               (imaginary - real * q) / denominator);
-        }
-    }
-
-    /**
-     * Returns a {@code Complex} whose value is {@code (this / divisor)},
-     * with {@code divisor} interpreted as a real number.
-     *
-     * @param  divisor Value by which this {@code Complex} is to be divided.
-     * @return {@code this / divisor}.
-     * @see #divide(Complex)
-     */
-    public Complex divide(double divisor) {
-        if (divisor == 0d) {
-            return NAN;
-        }
-        if (Double.isInfinite(divisor)) {
-            return !(Double.isInfinite(real) ||
-                     Double.isInfinite(imaginary)) ? ZERO : NAN;
-        }
-        return new Complex(real / divisor,
-                           imaginary  / divisor);
-    }
-
-    /**
-     * Returns the multiplicative inverse of this instance.
-     *
-     * @return {@code 1 / this}.
-     * @see #divide(Complex)
-     */
-    public Complex reciprocal() {
-        if (Math.abs(real) < Math.abs(imaginary)) {
-            final double q = real / imaginary;
-            final double scale = 1. / (real * q + imaginary);
-            double scaleQ = 0;
-            if (q != 0 &&
-                scale != 0) {
-                scaleQ = scale * q;
-            }
-            return new Complex(scaleQ, -scale);
-        } else {
-            final double q = imaginary / real;
-            final double scale = 1. / (imaginary * q + real);
-            double scaleQ = 0;
-            if (q != 0 &&
-                scale != 0) {
-                scaleQ = scale * q;
-            }
-            return new Complex(scale, -scaleQ);
-        }
-    }
-
-    /**
-     * Test for equality with another object.
-     * If both the real and imaginary parts of two complex numbers
-     * are exactly the same, and neither is {@code Double.NaN}, the two
-     * Complex objects are considered to be equal.
-     * The behavior is the same as for JDK's {@link Double#equals(Object)
-     * Double}:
-     * <ul>
-     *  <li>All {@code NaN} values are considered to be equal,
-     *   i.e, if either (or both) real and imaginary parts of the complex
-     *   number are equal to {@code Double.NaN}, the complex number is equal
-     *   to {@code NaN}.
-     *  </li>
-     *  <li>
-     *   Instances constructed with different representations of zero (i.e.
-     *   either "0" or "-0") are <em>not</em> considered to be equal.
-     *  </li>
-     * </ul>
-     *
-     * @param other Object to test for equality with this instance.
-     * @return {@code true} if the objects are equal, {@code false} if object
-     * is {@code null}, not an instance of {@code Complex}, or not equal to
-     * this instance.
-     */
-    @Override
-    public boolean equals(Object other) {
-        if (this == other) {
-            return true;
-        }
-        if (other instanceof Complex){
-            Complex c = (Complex) other;
-            return equals(real, c.real) &&
-                equals(imaginary, c.imaginary);
-        }
-        return false;
-    }
-
-    /**
-     * Test for the floating-point equality between Complex objects.
-     * It returns {@code true} if both arguments are equal or within the
-     * range of allowed error (inclusive).
-     *
-     * @param x First value (cannot be {@code null}).
-     * @param y Second value (cannot be {@code null}).
-     * @param maxUlps {@code (maxUlps - 1)} is the number of floating point
-     * values between the real (resp. imaginary) parts of {@code x} and
-     * {@code y}.
-     * @return {@code true} if there are fewer than {@code maxUlps} floating
-     * point values between the real (resp. imaginary) parts of {@code x}
-     * and {@code y}.
-     *
-     * @see Precision#equals(double,double,int)
-     */
-    public static boolean equals(Complex x,
-                                 Complex y,
-                                 int maxUlps) {
-        return Precision.equals(x.real, y.real, maxUlps) &&
-            Precision.equals(x.imaginary, y.imaginary, maxUlps);
-    }
-
-    /**
-     * Returns {@code true} iff the values are equal as defined by
-     * {@link #equals(Complex,Complex,int) equals(x, y, 1)}.
-     *
-     * @param x First value (cannot be {@code null}).
-     * @param y Second value (cannot be {@code null}).
-     * @return {@code true} if the values are equal.
-     */
-    public static boolean equals(Complex x,
-                                 Complex y) {
-        return equals(x, y, 1);
-    }
-
-    /**
-     * Returns {@code true} if, both for the real part and for the imaginary
-     * part, there is no double value strictly between the arguments or the
-     * difference between them is within the range of allowed error
-     * (inclusive).  Returns {@code false} if either of the arguments is NaN.
-     *
-     * @param x First value (cannot be {@code null}).
-     * @param y Second value (cannot be {@code null}).
-     * @param eps Amount of allowed absolute error.
-     * @return {@code true} if the values are two adjacent floating point
-     * numbers or they are within range of each other.
-     *
-     * @see Precision#equals(double,double,double)
-     */
-    public static boolean equals(Complex x,
-                                 Complex y,
-                                 double eps) {
-        return Precision.equals(x.real, y.real, eps) &&
-            Precision.equals(x.imaginary, y.imaginary, eps);
-    }
-
-    /**
-     * Returns {@code true} if, both for the real part and for the imaginary
-     * part, there is no double value strictly between the arguments or the
-     * relative difference between them is smaller or equal to the given
-     * tolerance. Returns {@code false} if either of the arguments is NaN.
-     *
-     * @param x First value (cannot be {@code null}).
-     * @param y Second value (cannot be {@code null}).
-     * @param eps Amount of allowed relative error.
-     * @return {@code true} if the values are two adjacent floating point
-     * numbers or they are within range of each other.
-     *
-     * @see Precision#equalsWithRelativeTolerance(double,double,double)
-     */
-    public static boolean equalsWithRelativeTolerance(Complex x, Complex y,
-                                                      double eps) {
-        return Precision.equalsWithRelativeTolerance(x.real, y.real, eps) &&
-            Precision.equalsWithRelativeTolerance(x.imaginary, y.imaginary, eps);
-    }
-
-    /**
-     * Get a hash code for the complex number.
-     * Any {@code Double.NaN} value in real or imaginary part produces
-     * the same hash code {@code 7}.
-     *
-     * @return a hash code value for this object.
-     */
-    @Override
-    public int hashCode() {
-        if (Double.isNaN(real) ||
-            Double.isNaN(imaginary)) {
-            return 7;
-        }
-        return 37 * (17 * hash(imaginary) + hash(real));
-    }
-
-    /**
-     * @param d Value.
-     * @return a hash code for the given value.
-     */
-    private int hash(double d) {
-        final long v = Double.doubleToLongBits(d);
-        return (int) (v ^ (v >>> 32));
-        //return new Double(d).hashCode();
-    }
-
-    /**
-     * Access the imaginary part.
-     *
-     * @return the imaginary part.
-     */
-    public double getImaginary() {
-        return imaginary;
-    }
-    /**
-     * Access the imaginary part (C++ grammar)
-     *
-     * @return the imaginary part.
-     */
-    public double imag() {
-        return imaginary;
-    }
-
-    /**
-     * Access the real part.
-     *
-     * @return the real part.
-     */
-    public double getReal() {
-        return real;
-    }
-
-     /**
-     * Access the real part (C++ grammar)
-     *
-     * @return the real part.
-     */
-    public double real() {
-        return real;
-    }
-
-    /**
-     * Returns a {@code Complex} whose value is {@code this * factor}.
-     * Implements the definitional formula:
-     *
-     *   {@code (a + bi)(c + di) = (ac - bd) + (ad + bc)i}
-     *
-     * Returns finite values in components of the result per the definitional
-     * formula in all remaining cases.
-     *
-     * @param  factor value to be multiplied by this {@code Complex}.
-     * @return {@code this * factor}.
-     */
-    public Complex multiply(Complex factor) {
-        return new Complex(real * factor.real - imaginary * factor.imaginary,
-                           real * factor.imaginary + imaginary * factor.real);
-    }
-
-    /**
-     * Returns a {@code Complex} whose value is {@code this * factor}, with {@code factor}
-     * interpreted as a integer number.
-     *
-     * @param  factor value to be multiplied by this {@code Complex}.
-     * @return {@code this * factor}.
-     * @see #multiply(Complex)
-     */
-    public Complex multiply(final int factor) {
-        return new Complex(real * factor, imaginary * factor);
-    }
-
-    /**
-     * Returns a {@code Complex} whose value is {@code this * factor}, with {@code factor}
-     * interpreted as a real number.
-     *
-     * @param  factor value to be multiplied by this {@code Complex}.
-     * @return {@code this * factor}.
-     * @see #multiply(Complex)
-     */
-    public Complex multiply(double factor) {
-        return new Complex(real * factor, imaginary * factor);
-    }
-
-    /**
-     * Returns a {@code Complex} whose value is {@code (-this)}.
-     *
-     * @return {@code -this}.
-     */
-    public Complex negate() {
-        return new Complex(-real, -imaginary);
-    }
-
-    /**
-     * Returns a {@code Complex} whose value is
-     * {@code (this - subtrahend)}.
-     * Uses the definitional formula
-     * <p>
-     *  {@code (a + bi) - (c + di) = (a-c) + (b-d)i}
-     * </p>
-     *
-     * @param  subtrahend value to be subtracted from this {@code Complex}.
-     * @return {@code this - subtrahend}.
-     */
-    public Complex subtract(Complex subtrahend) {
-        return new Complex(real - subtrahend.real,
-                           imaginary - subtrahend.imaginary);
-    }
-
-    /**
-     * Returns a {@code Complex} whose value is
-     * {@code (this - subtrahend)}.
-     *
-     * @param  subtrahend value to be subtracted from this {@code Complex}.
-     * @return {@code this - subtrahend}.
-     * @see #subtract(Complex)
-     */
-    public Complex subtract(double subtrahend) {
-        return new Complex(real - subtrahend, imaginary);
-    }
-
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/InverseCosine.html">
-     * inverse cosine</a> of this complex number.
-     * Implements the formula:
-     * <p>
-     *  {@code acos(z) = -i (log(z + i (sqrt(1 - z<sup>2</sup>))))}
-     * </p>
-     *
-     * @return the inverse cosine of this complex number.
-     */
-    public Complex acos() {
-        if (real == 0 &&
-            Double.isNaN(imaginary)) {
-            return new Complex(Math.PI * 0.5, Double.NaN);
-        } else if (neitherInfiniteNorZeroNorNaN(real) &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Math.PI * 0.5, Double.NEGATIVE_INFINITY);
-        } else if (real == Double.NEGATIVE_INFINITY &&
-                   imaginary == 1) {
-            return new Complex(Math.PI, Double.NEGATIVE_INFINITY);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   imaginary == 1) {
-            return new Complex(0, Double.NEGATIVE_INFINITY);
-        } else if (real == Double.NEGATIVE_INFINITY &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Math.PI * 0.75, Double.NEGATIVE_INFINITY);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Math.PI * 0.25, Double.NEGATIVE_INFINITY);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.NaN , Double.POSITIVE_INFINITY);
-        } else if (real == Double.NEGATIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.NaN, Double.NEGATIVE_INFINITY);
-        } else if (Double.isNaN(real) &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.NaN, Double.NEGATIVE_INFINITY);
-        }
-        return add(sqrt1z().multiply(I)).log().multiply(I.negate());
-    }
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/InverseSine.html">
-     * inverse sine</a> of this complex number.
-     * <p>
-     *  {@code asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz))}
-     * </p><p>
-     * @return the inverse sine of this complex number
-     */
-    public Complex asin() {
-        return sqrt1z().add(multiply(I)).log().multiply(I.negate());
-    }
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/InverseTangent.html">
-     * inverse tangent</a> of this complex number.
-     * Implements the formula:
-     * <p>
-     * {@code atan(z) = (i/2) log((i + z)/(i - z))}
-     * </p><p>
-     * @return the inverse tangent of this complex number
-     */
-    public Complex atan() {
-        return add(I).divide(I.subtract(this)).log().multiply(I.multiply(0.5));
-    }
-
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/InverseHyperbolicSine.html">
-     * inverse hyperbolic sine</a> of this complex number.
-     * Implements the formula:
-     * <p>
-     * {@code asinh(z) = log(z+sqrt(z^2+1))}
-     * </p><p>
-     * @return the inverse hyperbolic cosine of this complex number
-     */
-    public Complex asinh(){
-        if (neitherInfiniteNorZeroNorNaN(real) &&
-            imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Math.PI * 0.5);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   !Double.isInfinite(imaginary) && !Double.isNaN(imaginary)) {
-            return new Complex(Double.POSITIVE_INFINITY, 0);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Math.PI * 0.25);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.POSITIVE_INFINITY,  Double.NaN);
-        } else if (Double.isNaN(real) &&
-                   imaginary == 0) {
-            return new Complex(Double.NaN, 0);
-        } else if (Double.isNaN(real) &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
-        }
-        return square().add(ONE).sqrt().add(this).log();
-    }
-
-   /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/InverseHyperbolicTangent.html">
-     * inverse hyperbolic tangent</a> of this complex number.
-     * Implements the formula:
-     * <p>
-     * {@code atanh(z) = log((1+z)/(1-z))/2}
-     * </p><p>
-     * @return the inverse hyperbolic cosine of this complex number
-     */
-    public Complex atanh(){
-        if (real == 0 &&
-            Double.isNaN(imaginary)) {
-            return new Complex(0, Double.NaN);
-        } else if (neitherInfiniteNorZeroNorNaN(real) &&
-                   imaginary == 0) {
-            return new Complex(Double.POSITIVE_INFINITY, 0);
-        } else if (neitherInfiniteNorZeroNorNaN(real) &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(0, Math.PI * 0.5);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   neitherInfiniteNorZeroNorNaN(imaginary)) {
-            return new Complex(0, Math.PI * 0.5);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(0, Math.PI * 0.5);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(0, Double.NaN);
-        } else if (Double.isNaN(real) &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(0, Math.PI * 0.5);
-        }
-        return add(ONE).divide(ONE.subtract(this)).log().multiply(0.5);
-    }
-   /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/InverseHyperbolicCosine.html">
-     * inverse hyperbolic cosine</a> of this complex number.
-     * Implements the formula:
-     * <p>
-     * {@code acosh(z) = log(z+sqrt(z^2-1))}
-     * </p><p>
-     * @return the inverse hyperbolic cosine of this complex number
-     */
-    public Complex acosh() {
-        return square().subtract(ONE).sqrt().add(this).log();
-    }
-
-    /**
-     * Compute the square of this complex number.
-     *
-     * @return square of this complex number
-     */
-    public Complex square() {
-        return multiply(this);
-    }
-
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/Cosine.html">
-     * cosine</a> of this complex number.
-     * Implements the formula:
-     * <p>
-     *  {@code cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i}
-     * </p><p>
-     * where the (real) functions on the right-hand side are
-     * {@link Math#sin}, {@link Math#cos},
-     * {@link Math#cosh} and {@link Math#sinh}.
-     * </p><p>
-     *
-     * @return the cosine of this complex number.
-     */
-    public Complex cos() {
-        return new Complex(Math.cos(real) * Math.cosh(imaginary),
-                           -Math.sin(real) * Math.sinh(imaginary));
-    }
-
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/HyperbolicCosine.html">
-     * hyperbolic cosine</a> of this complex number.
-     * Implements the formula:
-     * <pre>
-     *  <code>
-     *   cosh(a + bi) = cosh(a)cos(b) + sinh(a)sin(b)i
-     *  </code>
-     * </pre>
-     * where the (real) functions on the right-hand side are
-     * {@link Math#sin}, {@link Math#cos},
-     * {@link Math#cosh} and {@link Math#sinh}.
-     * <p>
-     *
-     * @return the hyperbolic cosine of this complex number.
-     */
-    public Complex cosh() {
-        if (real == 0 &&
-            imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.NaN, 0);
-        } else if (real == 0 &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.NaN, 0);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   imaginary == 0) {
-            return new Complex(Double.POSITIVE_INFINITY, 0);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
-        } else if (Double.isNaN(real) &&
-                   imaginary == 0) {
-            return new Complex(Double.NaN, 0);
-        }
-
-        return new Complex(Math.cosh(real) * Math.cos(imaginary),
-                           Math.sinh(real) * Math.sin(imaginary));
-    }
-
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/ExponentialFunction.html">
-     * exponential function</a> of this complex number.
-     * Implements the formula:
-     * <pre>
-     *  <code>
-     *   exp(a + bi) = exp(a)cos(b) + exp(a)sin(b)i
-     *  </code>
-     * </pre>
-     * where the (real) functions on the right-hand side are
-     * {@link Math#exp}, {@link Math#cos}, and
-     * {@link Math#sin}.
-     *
-     * @return <code><i>e</i><sup>this</sup></code>.
-     */
-    public Complex exp() {
-        if (real == Double.POSITIVE_INFINITY &&
-            imaginary == 0) {
-            return new Complex(Double.POSITIVE_INFINITY, 0);
-        } else if (real == Double.NEGATIVE_INFINITY &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return Complex.ZERO;
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
-        } else if (real == Double.NEGATIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return Complex.ZERO;
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
-        } else if (Double.isNaN(real) &&
-                   imaginary == 0) {
-            return new Complex(Double.NaN, 0);
-        }
-        double expReal = Math.exp(real);
-        return new Complex(expReal *  Math.cos(imaginary),
-                           expReal * Math.sin(imaginary));
-    }
-
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/NaturalLogarithm.html">
-     * natural logarithm</a> of this complex number.
-     * Implements the formula:
-     * <pre>
-     *  <code>
-     *   log(a + bi) = ln(|a + bi|) + arg(a + bi)i
-     *  </code>
-     * </pre>
-     * where ln on the right hand side is {@link Math#log},
-     * {@code |a + bi|} is the modulus, {@link Complex#abs},  and
-     * {@code arg(a + bi) = }{@link Math#atan2}(b, a).
-     *
-     * @return the value <code>ln &nbsp; this</code>, the natural logarithm
-     * of {@code this}.
-     */
-    public Complex log() {
-        if (real == Double.POSITIVE_INFINITY &&
-            imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Math.PI * 0.25);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
-        } else if (Double.isNaN(real) &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
-        }
-        return new Complex(Math.log(abs()),
-                           Math.atan2(imaginary, real));
-    }
-
-    /**
-     * Compute the base 10 or
-     * <a href="http://mathworld.wolfram.com/CommonLogarithm.html">
-     * common logarithm</a> of this complex number.
-     *
-     *  @return the base 10 logarithm of <code>this</code>.
-    */
-    public Complex log10() {
-        return new Complex(Math.log(abs()) / Math.log(10),
-                           Math.atan2(imaginary, real));
-    }
-
-    /**
-     * Returns of value of this complex number raised to the power of {@code x}.
-     * Implements the formula:
-     * <pre>
-     *  <code>
-     *   y<sup>x</sup> = exp(x&middot;log(y))
-     *  </code>
-     * </pre>
-     * where {@code exp} and {@code log} are {@link #exp} and
-     * {@link #log}, respectively.
-     *
-     * @param  x exponent to which this {@code Complex} is to be raised.
-     * @return <code> this<sup>x</sup></code>.
-     */
-    public Complex pow(Complex x) {
-        if (real == 0 &&
-            imaginary == 0) {
-            if (x.real > 0 &&
-                x.imaginary == 0) {
-                // 0 raised to positive number is 0
-                return ZERO;
-            } else {
-                // 0 raised to anything else is NaN
-                return NAN;
-            }
-        }
-        return log().multiply(x).exp();
-    }
-
-    /**
-     * Returns of value of this complex number raised to the power of {@code x}.
-     *
-     * @param  x exponent to which this {@code Complex} is to be raised.
-     * @return <code>this<sup>x</sup></code>.
-     * @see #pow(Complex)
-     */
-     public Complex pow(double x) {
-        if (real == 0 &&
-            imaginary == 0) {
-            if (x > 0) {
-                // 0 raised to positive number is 0
-                return ZERO;
-            } else {
-                // 0 raised to anything else is NaN
-                return NAN;
-            }
-        }
-        return log().multiply(x).exp();
-    }
-
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/Sine.html">
-     * sine</a>
-     * of this complex number.
-     * Implements the formula:
-     * <pre>
-     *  <code>
-     *   sin(a + bi) = sin(a)cosh(b) - cos(a)sinh(b)i
-     *  </code>
-     * </pre>
-     * where the (real) functions on the right-hand side are
-     * {@link Math#sin}, {@link Math#cos},
-     * {@link Math#cosh} and {@link Math#sinh}.
-     *
-     * @return the sine of this complex number.
-     */
-    public Complex sin() {
-        return new Complex(Math.sin(real) * Math.cosh(imaginary),
-                           Math.cos(real) * Math.sinh(imaginary));
-    }
-
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/HyperbolicSine.html">
-     * hyperbolic sine</a> of this complex number.
-     * Implements the formula:
-     * <pre>
-     *  <code>
-     *   sinh(a + bi) = sinh(a)cos(b)) + cosh(a)sin(b)i
-     *  </code>
-     * </pre>
-     * where the (real) functions on the right-hand side are
-     * {@link Math#sin}, {@link Math#cos},
-     * {@link Math#cosh} and {@link Math#sinh}.
-     *
-     * @return the hyperbolic sine of {@code this}.
-     */
-    public Complex sinh() {
-        if (real == 0 &&
-            imaginary == 0) {
-            return Complex.ZERO;
-        } else if (real == 0 &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(0, Double.NaN);
-        } else if (real == 0 &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(0, Double.NaN);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   imaginary == 0) {
-            return new Complex(Double.POSITIVE_INFINITY, 0);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
-        } else if (Double.isNaN(real) &&
-                   imaginary == 0) {
-            return new Complex(Double.NaN, 0);
-        }
-        return new Complex(Math.sinh(real) * Math.cos(imaginary),
-                           Math.cosh(real) * Math.sin(imaginary));
-    }
-
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/SquareRoot.html">
-     * square root</a> of this complex number.
-     * Implements the following algorithm to compute {@code sqrt(a + bi)}:
-     * <ol><li>Let {@code t = sqrt((|a| + |a + bi|) / 2)}</li>
-     * <li><pre>if {@code  a &#8805; 0} return {@code t + (b/2t)i}
-     *  else return {@code |b|/2t + sign(b)t i }</pre></li>
-     * </ol>
-     * where <ul>
-     * <li>{@code |a| = }{@link Math#abs}(a)</li>
-     * <li>{@code |a + bi| = }{@link Complex#abs}(a + bi)</li>
-     * <li>{@code sign(b) =  }{@link Math#copySign(double,double) copySign(1d, b)}
-     * </ul>
-     *
-     * @return the square root of {@code this}.
-     */
-    public Complex sqrt() {
-        if (real == 0 &&
-            imaginary == 0) {
-            return ZERO;
-        } else if (neitherInfiniteNorZeroNorNaN(real) &&
-                   imaginary == Double.POSITIVE_INFINITY) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
-        } else if (real == Double.NEGATIVE_INFINITY &&
-                   neitherInfiniteNorZeroNorNaN(imaginary)) {
-            return new Complex(0, Double.NaN);
-        } else if (real == Double.NEGATIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.NaN, Double.POSITIVE_INFINITY);
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
-        }
-
-        final double t = Math.sqrt(0.5 * (Math.abs(real) + abs()));
-        if (real >= 0) {
-            return new Complex(t, 0.5 * imaginary / t);
-        } else {
-            return new Complex(0.5 * Math.abs(imaginary) / t,
-                               Math.copySign(1d, imaginary) * t);
-        }
-    }
-
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/SquareRoot.html">
-     * square root</a> of <code>1 - this<sup>2</sup></code> for this complex
-     * number.
-     * Computes the result directly as
-     * {@code sqrt(ONE.subtract(z.multiply(z)))}.
-     *
-     * @return the square root of <code>1 - this<sup>2</sup></code>.
-     */
-    public Complex sqrt1z() {
-        return ONE.subtract(square()).sqrt();
-    }
-
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/Tangent.html">
-     * tangent</a> of this complex number.
-     * Implements the formula:
-     * <pre>
-     *  <code>
-     *   tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i
-     *  </code>
-     * </pre>
-     * where the (real) functions on the right-hand side are
-     * {@link Math#sin}, {@link Math#cos}, {@link Math#cosh} and
-     * {@link Math#sinh}.
-     *
-     * @return the tangent of {@code this}.
-     */
-    public Complex tan() {
-        if (imaginary > 20) {
-            return ONE;
-        }
-        if (imaginary < -20) {
-            return new Complex(0, -1);
-        }
-
-        final double real2 = 2 * real;
-        final double imaginary2 = 2 * imaginary;
-        final double d = Math.cos(real2) + Math.cosh(imaginary2);
-
-        return new Complex(Math.sin(real2) / d,
-                           Math.sinh(imaginary2) / d);
-    }
-
-    /**
-     * Compute the
-     * <a href="http://mathworld.wolfram.com/HyperbolicTangent.html">
-     * hyperbolic tangent</a> of this complex number.
-     * Implements the formula:
-     * <pre>
-     *  <code>
-     *   tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i
-     *  </code>
-     * </pre>
-     * where the (real) functions on the right-hand side are
-     * {@link Math#sin}, {@link Math#cos}, {@link Math#cosh} and
-     * {@link Math#sinh}.
-     *
-     * @return the hyperbolic tangent of {@code this}.
-     */
-    public Complex tanh() {
-        if (real == Double.POSITIVE_INFINITY &&
-            imaginary == Double.POSITIVE_INFINITY) {
-            return ONE;
-        } else if (real == Double.POSITIVE_INFINITY &&
-                   Double.isNaN(imaginary)) {
-            return ONE;
-        } else if (Double.isNaN(real) &&
-                   imaginary == 0) {
-            return new Complex(Double.NaN, 0);
-        }
-        final double real2 = 2 * real;
-        final double imaginary2 = 2 * imaginary;
-        final double d = Math.cosh(real2) + Math.cos(imaginary2);
-
-        return new Complex(Math.sinh(real2) / d,
-                           Math.sin(imaginary2) / d);
-    }
-
-   /**
-     * Compute the argument of this complex number.
-     * The argument is the angle phi between the positive real axis and
-     * the point representing this number in the complex plane.
-     * The value returned is between -PI (not inclusive)
-     * and PI (inclusive), with negative values returned for numbers with
-     * negative imaginary parts.
-     * <p>
-     * If either real or imaginary part (or both) is NaN, NaN is returned.
-     * Infinite parts are handled as {@code Math.atan2} handles them,
-     * essentially treating finite parts as zero in the presence of an
-     * infinite coordinate and returning a multiple of pi/4 depending on
-     * the signs of the infinite parts.
-     * See the javadoc for {@code Math.atan2} for full details.
-     *
-     * @return the argument of {@code this}.
-     */
-    public double getArgument() {
-        return Math.atan2(imaginary, real);
-    }
-
-    /**
-     * Compute the argument of this complex number.
-     * C++11 syntax
-     *
-     * @return the argument of {@code this}.
-     */
-    public double arg() {
-        return getArgument();
-    }
-
-    /**
-     * Computes the n-th roots of this complex number.
-     * The nth roots are defined by the formula:
-     * <pre>
-     *  <code>
-     *   z<sub>k</sub> = abs<sup>1/n</sup> (cos(phi + 2&pi;k/n) + i (sin(phi + 2&pi;k/n))
-     *  </code>
-     * </pre>
-     * for <i>{@code k=0, 1, ..., n-1}</i>, where {@code abs} and {@code phi}
-     * are respectively the {@link #abs() modulus} and
-     * {@link #getArgument() argument} of this complex number.
-     * <p>
-     * If one or both parts of this complex number is NaN, a list with just
-     * one element, {@link #NAN} is returned.
-     * if neither part is NaN, but at least one part is infinite, the result
-     * is a one-element list containing {@link #INF}.
-     *
-     * @param n Degree of root.
-     * @return a List of all {@code n}-th roots of {@code this}.
-     */
-    public List<Complex> nthRoot(int n) {
-        if (n <= 0) {
-            throw new IllegalArgumentException("cannot compute nth root for null or negative n: {0}");
-        }
-
-        final List<Complex> result = new ArrayList<Complex>();
-
-        // nth root of abs -- faster / more accurate to use a solver here?
-        final double nthRootOfAbs = Math.pow(abs(), 1d / n);
-
-        // Compute nth roots of complex number with k = 0, 1, ... n-1
-        final double nthPhi = getArgument() / n;
-        final double slice = 2 * Math.PI / n;
-        double innerPart = nthPhi;
-        for (int k = 0; k < n ; k++) {
-            // inner part
-            final double realPart = nthRootOfAbs *  Math.cos(innerPart);
-            final double imaginaryPart = nthRootOfAbs *  Math.sin(innerPart);
-            result.add(createComplex(realPart, imaginaryPart));
-            innerPart += slice;
-        }
-
-        return result;
-    }
-
-    /**
-     * Create a complex number given the real and imaginary parts.
-     *
-     * @param realPart Real part.
-     * @param imaginaryPart Imaginary part.
-     * @return a new complex number instance.
-     * @see #valueOf(double, double)
-     */
-    protected Complex createComplex(double realPart,
-                                    double imaginaryPart) {
-        return new Complex(realPart, imaginaryPart);
-    }
-
-    /**
-     * Create a complex number given the real and imaginary parts.
-     *
-     * @param realPart Real part.
-     * @param imaginaryPart Imaginary part.
-     * @return a Complex instance.
-     */
-    public static Complex valueOf(double realPart,
-                                  double imaginaryPart) {
-        return new Complex(realPart, imaginaryPart);
-    }
-
-    /**
-     * Create a complex number given only the real part.
-     *
-     * @param realPart Real part.
-     * @return a Complex instance.
-     */
-    public static Complex valueOf(double realPart) {
-        return new Complex(realPart);
-    }
-
-    /**
-     * Resolve the transient fields in a deserialized Complex Object.
-     * Subclasses will need to override {@link #createComplex} to
-     * deserialize properly.
-     *
-     * @return A Complex instance with all fields resolved.
-     */
-    protected final Object readResolve() {
-        return new Complex(real, imaginary);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String toString() {
-        return "(" + real + ", " + imaginary + ")";
-    }
-
-    /**
-     * Check that the argument is positive and throw a RuntimeException
-     * if it is not.
-     * @param arg {@code double} to check
-     */
-    private static void checkNotNegative(double arg) {
-        if (arg <= 0) {
-            throw new IllegalArgumentException("Complex: Non-positive argument");
-        }
-    }
-
-    /**
-     * Returns {@code true} if the values are equal according to semantics of
-     * {@link Double#equals(Object)}.
-     *
-     * @param x Value
-     * @param y Value
-     * @return {@code new Double(x).equals(new Double(y))}
-     */
-    private static boolean equals(double x, double y) {
-        return new Double(x).equals(new Double(y));
-    }
-
-    /**
-     * Check that a value meets all the following conditions:
-     * <ul>
-     *  <li>it is not {@code NaN},</li>
-     *  <li>it is not infinite,</li>
-     *  <li>it is not zero,</li>
-     * </ul>
-     *
-     * @param d Value.
-     * @return {@code true} if {@code d} meets all the conditions and
-     * {@code false} otherwise.
-     */
-    private static boolean neitherInfiniteNorZeroNorNaN(double d) {
-        return !Double.isNaN(d) &&
-            !Double.isInfinite(d) &&
-            d != 0;
-    }
-}


[4/4] commons-numbers git commit: NUMBERS-54: Create module "commons-numbers-complex-streams".

Posted by er...@apache.org.
NUMBERS-54: Create module "commons-numbers-complex-streams".

Class "ComplexUtils" moved over to the new module.


Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/40418955
Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/40418955
Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/40418955

Branch: refs/heads/master
Commit: 40418955926ced67c155cf03009a0f4b54c8440b
Parents: 8e0af85
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
Authored: Sat May 19 14:42:42 2018 +0200
Committer: Gilles Sadowski <gi...@harfang.homelinux.org>
Committed: Sat May 19 14:42:42 2018 +0200

----------------------------------------------------------------------
 commons-numbers-complex-streams/LICENSE.txt     |  201 ++
 commons-numbers-complex-streams/NOTICE.txt      |    6 +
 commons-numbers-complex-streams/README.md       |  105 ++
 commons-numbers-complex-streams/pom.xml         |   60 +
 .../numbers/complex/streams/ComplexUtils.java   | 1742 ++++++++++++++++++
 .../numbers/complex/streams/package-info.java   |   20 +
 .../src/site/resources/profile.jacoco           |   17 +
 .../complex/streams/ComplexUtilsTest.java       |  476 +++++
 .../numbers/complex/streams/TestUtils.java      |  410 +++++
 .../commons/numbers/complex/ComplexUtils.java   | 1740 -----------------
 .../commons/numbers/complex/ComplexTest.java    |    5 +-
 .../numbers/complex/ComplexUtilsTest.java       |  476 -----
 pom.xml                                         |    6 +
 13 files changed, 3045 insertions(+), 2219 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/commons-numbers-complex-streams/LICENSE.txt
----------------------------------------------------------------------
diff --git a/commons-numbers-complex-streams/LICENSE.txt b/commons-numbers-complex-streams/LICENSE.txt
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/commons-numbers-complex-streams/LICENSE.txt
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/commons-numbers-complex-streams/NOTICE.txt
----------------------------------------------------------------------
diff --git a/commons-numbers-complex-streams/NOTICE.txt b/commons-numbers-complex-streams/NOTICE.txt
new file mode 100644
index 0000000..9091baa
--- /dev/null
+++ b/commons-numbers-complex-streams/NOTICE.txt
@@ -0,0 +1,6 @@
+Apache Commons Numbers
+Copyright 2001-2017 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/commons-numbers-complex-streams/README.md
----------------------------------------------------------------------
diff --git a/commons-numbers-complex-streams/README.md b/commons-numbers-complex-streams/README.md
new file mode 100644
index 0000000..30a03eb
--- /dev/null
+++ b/commons-numbers-complex-streams/README.md
@@ -0,0 +1,105 @@
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!---
+ +======================================================================+
+ |****                                                              ****|
+ |****      THIS FILE IS GENERATED BY THE COMMONS BUILD PLUGIN      ****|
+ |****                    DO NOT EDIT DIRECTLY                      ****|
+ |****                                                              ****|
+ +======================================================================+
+ | TEMPLATE FILE: readme-md-template.md                                 |
+ | commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
+ +======================================================================+
+ |                                                                      |
+ | 1) Re-generate using: mvn commons:readme-md                          |
+ |                                                                      |
+ | 2) Set the following properties in the component's pom:              |
+ |    - commons.componentid (required, alphabetic, lower case)          |
+ |    - commons.release.version (required)                              |
+ |                                                                      |
+ | 3) Example Properties                                                |
+ |                                                                      |
+ |  <properties>                                                        |
+ |    <commons.componentid>math</commons.componentid>                   |
+ |    <commons.release.version>1.2</commons.release.version>            |
+ |  </properties>                                                       |
+ |                                                                      |
+ +======================================================================+
+--->
+Apache Commons Numbers Complex Streams
+===================
+
+[![Build Status](https://travis-ci.org/apache/commons-numbers-complex-streams.svg?branch=master)](https://travis-ci.org/apache/commons-numbers-complex-streams)
+[![Coverage Status](https://coveralls.io/repos/apache/commons-numbers-complex-streams/badge.svg?branch=master)](https://coveralls.io/r/apache/commons-numbers-complex-streams)
+[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-numbers-complex-streams/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-numbers-complex-streams/)
+[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
+
+Arrays, streams and collections of complex numbers.
+
+Documentation
+-------------
+
+More information can be found on the [Apache Commons Numbers Complex Streams homepage](https://commons.apache.org/proper/commons-numbers).
+The [JavaDoc](https://commons.apache.org/proper/commons-numbers/javadocs/api-release) can be browsed.
+Questions related to the usage of Apache Commons Numbers Complex Streams should be posted to the [user mailing list][ml].
+
+Where can I get the latest release?
+-----------------------------------
+You can download source and binaries from our [download page](https://commons.apache.org/proper/commons-numbers/download_numbers.cgi).
+
+Alternatively you can pull it from the central Maven repositories:
+
+```xml
+<dependency>
+  <groupId>org.apache.commons</groupId>
+  <artifactId>commons-numbers-complex-streams</artifactId>
+  <version>1.0</version>
+</dependency>
+```
+
+Contributing
+------------
+
+We accept Pull Requests via GitHub. The [developer mailing list][ml] is the main channel of communication for contributors.
+There are some guidelines which will make applying PRs easier for us:
++ No tabs! Please use spaces for indentation.
++ Respect the code style.
++ Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
++ Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running ```mvn clean test```.
+
+If you plan to contribute on a regular basis, please consider filing a [contributor license agreement](https://www.apache.org/licenses/#clas).
+You can learn more about contributing via GitHub in our [contribution guidelines](CONTRIBUTING.md).
+
+License
+-------
+This code is under the [Apache Licence v2](https://www.apache.org/licenses/LICENSE-2.0).
+
+See the `NOTICE.txt` file for required notices and attributions.
+
+Donations
+---------
+You like Apache Commons Numbers Complex Streams? Then [donate back to the ASF](https://www.apache.org/foundation/contributing.html) to support the development.
+
+Additional Resources
+--------------------
+
++ [Apache Commons Homepage](https://commons.apache.org/)
++ [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/NUMBERS)
++ [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
++ `#apache-commons` IRC channel on `irc.freenode.org`
+
+[ml]:https://commons.apache.org/mail-lists.html

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/commons-numbers-complex-streams/pom.xml
----------------------------------------------------------------------
diff --git a/commons-numbers-complex-streams/pom.xml b/commons-numbers-complex-streams/pom.xml
new file mode 100644
index 0000000..f388537
--- /dev/null
+++ b/commons-numbers-complex-streams/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.commons</groupId>
+    <artifactId>commons-numbers-parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.commons</groupId>
+  <artifactId>commons-numbers-complex-streams</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Apache Commons Numbers Complex Streams</name>
+
+  <description>Arrays, streams and collections of complex numbers.</description>
+
+  <properties>
+    <!-- This value must reflect the current name of the base package. -->
+    <commons.osgi.symbolicName>org.apache.commons.numbers.complex.streams</commons.osgi.symbolicName>
+    <!-- OSGi -->
+    <commons.osgi.export>org.apache.commons.numbers.complex.streams</commons.osgi.export>
+    <!-- Workaround to avoid duplicating config files. -->
+    <numbers.parent.dir>${basedir}/..</numbers.parent.dir>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-numbers-complex</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-math3</artifactId>
+      <version>3.6.1</version>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/ComplexUtils.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/ComplexUtils.java b/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/ComplexUtils.java
new file mode 100644
index 0000000..5c0d7d1
--- /dev/null
+++ b/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/ComplexUtils.java
@@ -0,0 +1,1742 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.numbers.complex.streams;
+
+import org.apache.commons.numbers.complex.Complex;
+
+/**
+ * Static implementations of common {@link Complex} utilities functions.
+ */
+public class ComplexUtils {
+
+    /**
+     * Utility class.
+     */
+    private ComplexUtils() {}
+
+    /**
+     * Creates a complex number from the given polar representation.
+     * <p>
+     * If either {@code r} or {@code theta} is NaN, or {@code theta} is
+     * infinite, {@link Complex#NAN} is returned.
+     * <p>
+     * If {@code r} is infinite and {@code theta} is finite, infinite or NaN
+     * values may be returned in parts of the result, following the rules for
+     * double arithmetic.
+     *
+     * <pre>
+     * Examples:
+     * {@code
+     * polar2Complex(INFINITY, \(\pi\)) = INFINITY + INFINITY i
+     * polar2Complex(INFINITY, 0) = INFINITY + NaN i
+     * polar2Complex(INFINITY, \(-\frac{\pi}{4}\)) = INFINITY - INFINITY i
+     * polar2Complex(INFINITY, \(5\frac{\pi}{4}\)) = -INFINITY - INFINITY i }
+     * </pre>
+     *
+     * @param r the modulus of the complex number to create
+     * @param theta the argument of the complex number to create
+     * @return {@code Complex}
+     * @since 1.1
+     */
+    public static Complex polar2Complex(double r, double theta) {
+        if (r < 0) {
+            throw new NegativeModulusException(r);
+        }
+        return Complex.ofCartesian(r * Math.cos(theta), r * Math.sin(theta));
+    }
+
+    /**
+     * Creates {@code Complex[]} array given {@code double[]} arrays of r and
+     * theta.
+     *
+     * @param r {@code double[]} of moduli
+     * @param theta {@code double[]} of arguments
+     * @return {@code Complex[]}
+     * @since 1.0
+     */
+    public static Complex[] polar2Complex(double[] r, double[] theta) {
+        final int length = r.length;
+        final Complex[] c = new Complex[length];
+        for (int x = 0; x < length; x++) {
+            if (r[x] < 0) {
+                throw new NegativeModulusException(r[x]);
+            }
+            c[x] = Complex.ofCartesian(r[x] * Math.cos(theta[x]), r[x] * Math.sin(theta[x]));
+        }
+        return c;
+    }
+
+    /**
+     * Creates {@code Complex[][]} array given {@code double[][]} arrays of r
+     * and theta.
+     *
+     * @param r {@code double[]} of moduli
+     * @param theta {@code double[]} of arguments
+     * @return {@code Complex[][]}
+     * @since 1.0
+     */
+    public static Complex[][] polar2Complex(double[][] r, double[][] theta) {
+        final int length = r.length;
+        final Complex[][] c = new Complex[length][];
+        for (int x = 0; x < length; x++) {
+            c[x] = polar2Complex(r[x], theta[x]);
+        }
+        return c;
+    }
+
+    /**
+     * Creates {@code Complex[][][]} array given {@code double[][][]} arrays of
+     * r and theta.
+     *
+     * @param r array of moduli
+     * @param theta array of arguments
+     * @return {@code Complex}
+     * @since 1.0
+     */
+    public static Complex[][][] polar2Complex(double[][][] r, double[][][] theta) {
+        final int length = r.length;
+        final Complex[][][] c = new Complex[length][][];
+        for (int x = 0; x < length; x++) {
+            c[x] = polar2Complex(r[x], theta[x]);
+        }
+        return c;
+    }
+
+    /**
+     * Returns double from array {@code real[]} at entry {@code index} as a
+     * {@code Complex}.
+     *
+     * @param real array of real numbers
+     * @param index location in the array
+     * @return {@code Complex}.
+     *
+     * @since 1.0
+     */
+    public static Complex extractComplexFromRealArray(double[] real, int index) {
+        return Complex.ofReal(real[index]);
+    }
+
+    /**
+     * Returns float from array {@code real[]} at entry {@code index} as a
+     * {@code Complex}.
+     *
+     * @param real array of real numbers
+     * @param index location in the array
+     * @return {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex extractComplexFromRealArray(float[] real, int index) {
+        return Complex.ofReal(real[index]);
+    }
+
+    /**
+     * Returns double from array {@code imaginary[]} at entry {@code index} as a
+     * {@code Complex}.
+     *
+     * @param imaginary array of imaginary numbers
+     * @param index location in the array
+     * @return {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex extractComplexFromImaginaryArray(double[] imaginary, int index) {
+        return Complex.ofCartesian(0, imaginary[index]);
+    }
+
+    /**
+     * Returns float from array {@code imaginary[]} at entry {@code index} as a
+     * {@code Complex}.
+     *
+     * @param imaginary array of imaginary numbers
+     * @param index location in the array
+     * @return {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex extractComplexFromImaginaryArray(float[] imaginary, int index) {
+        return Complex.ofCartesian(0, imaginary[index]);
+    }
+
+    /**
+     * Returns real component of Complex from array {@code Complex[]} at entry
+     * {@code index} as a {@code double}.
+     *
+     * @param complex array of complex numbers
+     * @param index location in the array
+     * @return {@code double}.
+     *
+     * @since 1.0
+     */
+    public static double extractRealFromComplexArray(Complex[] complex, int index) {
+        return complex[index].getReal();
+    }
+
+    /**
+     * Returns real component of array {@code Complex[]} at entry {@code index}
+     * as a {@code float}.
+     *
+     * @param complex array of complex numbers
+     * @param index location in the array
+     * @return {@code float}.
+     *
+     * @since 1.0
+     */
+    public static float extractRealFloatFromComplexArray(Complex[] complex, int index) {
+        return (float) complex[index].getReal();
+    }
+
+    /**
+     * Returns imaginary component of Complex from array {@code Complex[]} at
+     * entry {@code index} as a {@code double}.
+     *
+     * @param complex array of complex numbers
+     * @param index location in the array
+     * @return {@code double}.
+     *
+     * @since 1.0
+     */
+    public static double extractImaginaryFromComplexArray(Complex[] complex, int index) {
+        return complex[index].getImaginary();
+    }
+
+    /**
+     * Returns imaginary component of array {@code Complex[]} at entry
+     * {@code index} as a {@code float}.
+     *
+     * @param complex array of complex numbers
+     * @param index location in the array
+     * @return {@code float}.
+     *
+     * @since 1.0
+     */
+    public static float extractImaginaryFloatFromComplexArray(Complex[] complex, int index) {
+        return (float) complex[index].getImaginary();
+    }
+
+    /**
+     * Returns a Complex object from interleaved {@code double[]} array at entry
+     * {@code index}.
+     *
+     * @param d array of interleaved complex numbers alternating real and imaginary values
+     * @param index location in the array This is the location by complex number, e.g. index number 5 in the array will return {@code Complex.ofCartesian(d[10], d[11])}
+     * @return {@code Complex}.
+     *
+     * @since 1.0
+     */
+    public static Complex extractComplexFromInterleavedArray(double[] d, int index) {
+        return Complex.ofCartesian(d[index * 2], d[index * 2 + 1]);
+    }
+
+    /**
+     * Returns a Complex object from interleaved {@code float[]} array at entry
+     * {@code index}.
+     *
+     * @param f float array of interleaved complex numbers alternating real and imaginary values
+     * @param index location in the array This is the location by complex number, e.g. index number 5 in the {@code float[]} array will return new {@code Complex(d[10], d[11])}
+     * @return {@code Complex}.
+     *
+     * @since 1.0
+     */
+    public static Complex extractComplexFromInterleavedArray(float[] f, int index) {
+        return Complex.ofCartesian(f[index * 2], f[index * 2 + 1]);
+    }
+
+    /**
+     * Returns values of Complex object from array {@code Complex[]} at entry
+     * {@code index} as a size 2 {@code double} of the form {real, imag}.
+     *
+     * @param complex array of complex numbers
+     * @param index location in the array
+     * @return size 2 array.
+     *
+     * @since 1.0
+     */
+    public static double[] extractInterleavedFromComplexArray(Complex[] complex, int index) {
+        return new double[] { complex[index].getReal(), complex[index].getImaginary() };
+    }
+
+    /**
+     * Returns Complex object from array {@code Complex[]} at entry
+     * {@code index} as a size 2 {@code float} of the form {real, imag}.
+     *
+     * @param complex {@code Complex} array
+     * @param index location in the array
+     * @return size 2 {@code float[]}.
+     *
+     * @since 1.0
+     */
+    public static float[] extractInterleavedFloatFromComplexArray(Complex[] complex, int index) {
+        return new float[] { (float) complex[index].getReal(), (float) complex[index].getImaginary() };
+    }
+
+    /**
+     * Converts a {@code double[]} array to a {@code Complex[]} array.
+     *
+     * @param real array of numbers to be converted to their {@code Complex} equivalent
+     * @return {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[] real2Complex(double[] real) {
+        int index = 0;
+        final Complex c[] = new Complex[real.length];
+        for (double d : real) {
+            c[index] = Complex.ofReal(d);
+            index++;
+        }
+        return c;
+    }
+
+    /**
+     * Converts a {@code float[]} array to a {@code Complex[]} array.
+     *
+     * @param real array of numbers to be converted to their {@code Complex} equivalent
+     * @return {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[] real2Complex(float[] real) {
+        int index = 0;
+        final Complex c[] = new Complex[real.length];
+        for (float d : real) {
+            c[index] = Complex.ofReal(d);
+            index++;
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 2D real {@code double[][]} array to a 2D {@code Complex[][]}
+     * array.
+     *
+     * @param d 2D array
+     * @return 2D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][] real2Complex(double[][] d) {
+        final int w = d.length;
+        final Complex[][] c = new Complex[w][];
+        for (int n = 0; n < w; n++) {
+            c[n] = ComplexUtils.real2Complex(d[n]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 2D real {@code float[][]} array to a 2D {@code Complex[][]}
+     * array.
+     *
+     * @param d 2D array
+     * @return 2D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][] real2Complex(float[][] d) {
+        final int w = d.length;
+        final Complex[][] c = new Complex[w][];
+        for (int n = 0; n < w; n++) {
+            c[n] = ComplexUtils.real2Complex(d[n]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 3D real {@code double[][][]} array to a {@code Complex [][][]}
+     * array.
+     *
+     * @param d 3D complex interleaved array
+     * @return 3D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][] real2Complex(double[][][] d) {
+        final int w = d.length;
+        final Complex[][][] c = new Complex[w][][];
+        for (int x = 0; x < w; x++) {
+            c[x] = ComplexUtils.real2Complex(d[x]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 3D real {@code float[][][]} array to a {@code Complex [][][]}
+     * array.
+     *
+     * @param d 3D complex interleaved array
+     * @return 3D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][] real2Complex(float[][][] d) {
+        final int w = d.length;
+        final Complex[][][] c = new Complex[w][][];
+        for (int x = 0; x < w; x++) {
+            c[x] = ComplexUtils.real2Complex(d[x]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 4D real {@code double[][][][]} array to a {@code Complex [][][][]}
+     * array.
+     *
+     * @param d 4D complex interleaved array
+     * @return 4D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][][] real2Complex(double[][][][] d) {
+        final int w = d.length;
+        final Complex[][][][] c = new Complex[w][][][];
+        for (int x = 0; x < w; x++) {
+            c[x] = ComplexUtils.real2Complex(d[x]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts real component of {@code Complex[]} array to a {@code double[]}
+     * array.
+     *
+     * @param c {@code Complex} array
+     * @return array of the real component
+     *
+     * @since 1.0
+     */
+    public static double[] complex2Real(Complex[] c) {
+        int index = 0;
+        final double d[] = new double[c.length];
+        for (Complex cc : c) {
+            d[index] = cc.getReal();
+            index++;
+        }
+        return d;
+    }
+
+    /**
+     * Converts real component of {@code Complex[]} array to a {@code float[]}
+     * array.
+     *
+     * @param c {@code Complex} array
+     * @return {@code float[]} array of the real component
+     *
+     * @since 1.0
+     */
+    public static float[] complex2RealFloat(Complex[] c) {
+        int index = 0;
+        final float f[] = new float[c.length];
+        for (Complex cc : c) {
+            f[index] = (float) cc.getReal();
+            index++;
+        }
+        return f;
+    }
+
+    /**
+     * Converts real component of a 2D {@code Complex[][]} array to a 2D
+     * {@code double[][]} array.
+     *
+     * @param c 2D {@code Complex} array
+     * @return {@code double[][]} of real component
+     * @since 1.0
+     */
+    public static double[][] complex2Real(Complex[][] c) {
+        final int length = c.length;
+        double[][] d = new double[length][];
+        for (int n = 0; n < length; n++) {
+            d[n] = complex2Real(c[n]);
+        }
+        return d;
+    }
+
+    /**
+     * Converts real component of a 2D {@code Complex[][]} array to a 2D
+     * {@code float[][]} array.
+     *
+     * @param c 2D {@code Complex} array
+     * @return {@code float[][]} of real component
+     * @since 1.0
+     */
+    public static float[][] complex2RealFloat(Complex[][] c) {
+        final int length = c.length;
+        float[][] f = new float[length][];
+        for (int n = 0; n < length; n++) {
+            f[n] = complex2RealFloat(c[n]);
+        }
+        return f;
+    }
+
+    /**
+     * Converts real component of a 3D {@code Complex[][][]} array to a 3D
+     * {@code double[][][]} array.
+     *
+     * @param c 3D complex interleaved array
+     * @return array of real component
+     *
+     * @since 1.0
+     */
+    public static double[][][] complex2Real(Complex[][][] c) {
+        final int length = c.length;
+        double[][][] d = new double[length][][];
+        for (int n = 0; n < length; n++) {
+            d[n] = complex2Real(c[n]);
+        }
+        return d;
+    }
+
+    /**
+     * Converts real component of a 3D {@code Complex[][][]} array to a 3D
+     * {@code float[][][]} array.
+     *
+     * @param c 3D {@code Complex} array
+     * @return {@code float[][][]} of real component
+     * @since 1.0
+     */
+    public static float[][][] complex2RealFloat(Complex[][][] c) {
+        final int length = c.length;
+        float[][][] f = new float[length][][];
+        for (int n = 0; n < length; n++) {
+            f[n] = complex2RealFloat(c[n]);
+        }
+        return f;
+    }
+
+    /**
+     * Converts real component of a 4D {@code Complex[][][][]} array to a 4D
+     * {@code double[][][][]} array.
+     *
+     * @param c 4D complex interleaved array
+     * @return array of real component
+     *
+     * @since 1.0
+     */
+    public static double[][][][] complex2Real(Complex[][][][] c) {
+        final int length = c.length;
+        double[][][][] d = new double[length][][][];
+        for (int n = 0; n < length; n++) {
+            d[n] = complex2Real(c[n]);
+        }
+        return d;
+    }
+
+    /**
+     * Converts real component of a 4D {@code Complex[][][][]} array to a 4D
+     * {@code float[][][][]} array.
+     *
+     * @param c 4D {@code Complex} array
+     * @return {@code float[][][][]} of real component
+     * @since 1.0
+     */
+    public static float[][][][] complex2RealFloat(Complex[][][][] c) {
+        final int length = c.length;
+        float[][][][] f = new float[length][][][];
+        for (int n = 0; n < length; n++) {
+            f[n] = complex2RealFloat(c[n]);
+        }
+        return f;
+    }
+
+    /**
+     * Converts a {@code double[]} array to an imaginary {@code Complex[]}
+     * array.
+     *
+     * @param imaginary array of numbers to be converted to their {@code Complex} equivalent
+     * @return {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[] imaginary2Complex(double[] imaginary) {
+        int index = 0;
+        final Complex c[] = new Complex[imaginary.length];
+        for (double d : imaginary) {
+            c[index] = Complex.ofCartesian(0, d);
+            index++;
+        }
+        return c;
+    }
+
+    /**
+     * Converts a {@code float[]} array to an imaginary {@code Complex[]} array.
+     *
+     * @param imaginary array of numbers to be converted to their {@code Complex} equivalent
+     * @return {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[] imaginary2Complex(float[] imaginary) {
+        int index = 0;
+        final Complex c[] = new Complex[imaginary.length];
+        for (float d : imaginary) {
+            c[index] = Complex.ofCartesian(0, d);
+            index++;
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 2D imaginary array {@code double[][]} to a 2D
+     * {@code Complex[][]} array.
+     *
+     * @param i 2D array
+     * @return 2D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][] imaginary2Complex(double[][] i) {
+        int w = i.length;
+        Complex[][] c = new Complex[w][];
+        for (int n = 0; n < w; n++) {
+            c[n] = ComplexUtils.imaginary2Complex(i[n]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 3D imaginary array {@code double[][][]} to a {@code Complex[]}
+     * array.
+     *
+     * @param i 3D complex imaginary array
+     * @return 3D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][] imaginary2Complex(double[][][] i) {
+        int w = i.length;
+        Complex[][][] c = new Complex[w][][];
+        for (int n = 0; n < w; n++) {
+            c[n] = ComplexUtils.imaginary2Complex(i[n]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 4D imaginary array {@code double[][][][]} to a 4D {@code Complex[][][][]}
+     * array.
+     *
+     * @param i 4D complex imaginary array
+     * @return 4D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][][] imaginary2Complex(double[][][][] i) {
+        int w = i.length;
+        Complex[][][][] c = new Complex[w][][][];
+        for (int n = 0; n < w; n++) {
+            c[n] = ComplexUtils.imaginary2Complex(i[n]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts imaginary part of a {@code Complex[]} array to a
+     * {@code double[]} array.
+     *
+     * @param c {@code Complex} array.
+     * @return array of the imaginary component
+     *
+     * @since 1.0
+     */
+    public static double[] complex2Imaginary(Complex[] c) {
+        int index = 0;
+        final double i[] = new double[c.length];
+        for (Complex cc : c) {
+            i[index] = cc.getImaginary();
+            index++;
+        }
+        return i;
+    }
+
+    /**
+     * Converts imaginary component of a {@code Complex[]} array to a
+     * {@code float[]} array.
+     *
+     * @param c {@code Complex} array.
+     * @return {@code float[]} array of the imaginary component
+     *
+     * @since 1.0
+     */
+    public static float[] complex2ImaginaryFloat(Complex[] c) {
+        int index = 0;
+        final float f[] = new float[c.length];
+        for (Complex cc : c) {
+            f[index] = (float) cc.getImaginary();
+            index++;
+        }
+        return f;
+    }
+
+    /**
+     * Converts imaginary component of a 2D {@code Complex[][]} array to a 2D
+     * {@code double[][]} array.
+     *
+     * @param c 2D {@code Complex} array
+     * @return {@code double[][]} of imaginary component
+     * @since 1.0
+     */
+    public static double[][] complex2Imaginary(Complex[][] c) {
+        final int length = c.length;
+        double[][] i = new double[length][];
+        for (int n = 0; n < length; n++) {
+            i[n] = complex2Imaginary(c[n]);
+        }
+        return i;
+    }
+
+    /**
+     * Converts imaginary component of a 2D {@code Complex[][]} array to a 2D
+     * {@code float[][]} array.
+     *
+     * @param c 2D {@code Complex} array
+     * @return {@code float[][]} of imaginary component
+     * @since 1.0
+     */
+    public static float[][] complex2ImaginaryFloat(Complex[][] c) {
+        final int length = c.length;
+        float[][] f = new float[length][];
+        for (int n = 0; n < length; n++) {
+            f[n] = complex2ImaginaryFloat(c[n]);
+        }
+        return f;
+    }
+
+    /**
+     * Converts imaginary component of a 3D {@code Complex[][][]} array to a 3D
+     * {@code double[][][]} array.
+     *
+     * @param c 3D complex interleaved array
+     * @return 3D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static double[][][] complex2Imaginary(Complex[][][] c) {
+        final int length = c.length;
+        double[][][] i = new double[length][][];
+        for (int n = 0; n < length; n++) {
+            i[n] = complex2Imaginary(c[n]);
+        }
+        return i;
+    }
+
+    /**
+     * Converts imaginary component of a 3D {@code Complex[][][]} array to a 3D
+     * {@code float[][][]} array.
+     *
+     * @param c 3D {@code Complex} array
+     * @return {@code float[][][]} of imaginary component
+     * @since 1.0
+     */
+    public static float[][][] complex2ImaginaryFloat(Complex[][][] c) {
+        final int length = c.length;
+        float[][][] f = new float[length][][];
+        for (int n = 0; n < length; n++) {
+            f[n] = complex2ImaginaryFloat(c[n]);
+        }
+        return f;
+    }
+
+    /**
+     * Converts imaginary component of a 4D {@code Complex[][][][]} array to a 4D
+     * {@code double[][][][]} array.
+     *
+     * @param c 4D complex interleaved array
+     * @return 4D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static double[][][][] complex2Imaginary(Complex[][][][] c) {
+        final int length = c.length;
+        double[][][][] i = new double[length][][][];
+        for (int n = 0; n < length; n++) {
+            i[n] = complex2Imaginary(c[n]);
+        }
+        return i;
+    }
+
+    /**
+     * Converts imaginary component of a 4D {@code Complex[][][][]} array to a 4D
+     * {@code float[][][][]} array.
+     *
+     * @param c 4D {@code Complex} array
+     * @return {@code float[][][][]} of imaginary component
+     * @since 1.0
+     */
+    public static float[][][][] complex2ImaginaryFloat(Complex[][][][] c) {
+        final int length = c.length;
+        float[][][][] f = new float[length][][][];
+        for (int n = 0; n < length; n++) {
+            f[n] = complex2ImaginaryFloat(c[n]);
+        }
+        return f;
+    }
+
+    // INTERLEAVED METHODS
+
+    /**
+     * Converts a complex interleaved {@code double[]} array to a
+     * {@code Complex[]} array
+     *
+     * @param interleaved array of numbers to be converted to their {@code Complex} equivalent
+     * @return {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[] interleaved2Complex(double[] interleaved) {
+        final int length = interleaved.length / 2;
+        final Complex c[] = new Complex[length];
+        for (int n = 0; n < length; n++) {
+            c[n] = Complex.ofCartesian(interleaved[n * 2], interleaved[n * 2 + 1]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a complex interleaved {@code float[]} array to a
+     * {@code Complex[]} array
+     *
+     * @param interleaved float[] array of numbers to be converted to their {@code Complex} equivalent
+     * @return {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[] interleaved2Complex(float[] interleaved) {
+        final int length = interleaved.length / 2;
+        final Complex c[] = new Complex[length];
+        for (int n = 0; n < length; n++) {
+            c[n] = Complex.ofCartesian(interleaved[n * 2], interleaved[n * 2 + 1]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a {@code Complex[]} array to an interleaved complex
+     * {@code double[]} array
+     *
+     * @param c Complex array
+     * @return complex interleaved array alternating real and
+     *         imaginary values
+     *
+     * @since 1.0
+     */
+    public static double[] complex2Interleaved(Complex[] c) {
+        int index = 0;
+        final double i[] = new double[c.length * 2];
+        for (Complex cc : c) {
+            int real = index * 2;
+            int imag = index * 2 + 1;
+            i[real] = cc.getReal();
+            i[imag] = cc.getImaginary();
+            index++;
+        }
+        return i;
+    }
+
+    /**
+     * Converts a {@code Complex[]} array to an interleaved complex
+     * {@code float[]} array
+     *
+     * @param c Complex array
+     * @return complex interleaved {@code float[]} alternating real and
+     *         imaginary values
+     *
+     * @since 1.0
+     */
+    public static float[] complex2InterleavedFloat(Complex[] c) {
+        int index = 0;
+        final float f[] = new float[c.length * 2];
+        for (Complex cc : c) {
+            int real = index * 2;
+            int imag = index * 2 + 1;
+            f[real] = (float) cc.getReal();
+            f[imag] = (float) cc.getImaginary();
+            index++;
+        }
+        return f;
+    }
+
+    /**
+     * Converts a 2D {@code Complex[][]} array to an interleaved complex
+     * {@code double[][]} array.
+     *
+     * @param c 2D Complex array
+     * @param interleavedDim Depth level of the array to interleave
+     * @return complex interleaved array alternating real and
+     *         imaginary values
+     *
+     * @since 1.0
+     */
+    public static double[][] complex2Interleaved(Complex[][] c, int interleavedDim) {
+        if (interleavedDim > 1 || interleavedDim < 0) {
+            throw new IndexOutOfRangeException(interleavedDim);
+        }
+        final int w = c.length;
+        final int h = c[0].length;
+        double[][] i;
+        if (interleavedDim == 0) {
+            i = new double[2 * w][h];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    i[x * 2][y] = c[x][y].getReal();
+                    i[x * 2 + 1][y] = c[x][y].getImaginary();
+                }
+            }
+        } else {
+            i = new double[w][2 * h];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    i[x][y * 2] = c[x][y].getReal();
+                    i[x][y * 2 + 1] = c[x][y].getImaginary();
+                }
+            }
+        }
+        return i;
+    }
+
+    /**
+     * Converts a 2D {@code Complex[][]} array to an interleaved complex
+     * {@code double[][]} array. The second d level of the array is assumed
+     * to be interleaved.
+     *
+     * @param c 2D Complex array
+     * @return complex interleaved array alternating real and
+     *         imaginary values
+     *
+     * @since 1.0
+     */
+    public static double[][] complex2Interleaved(Complex[][] c) {
+        return complex2Interleaved(c, 1);
+    }
+
+    /**
+     * Converts a 3D {@code Complex[][][]} array to an interleaved complex
+     * {@code double[][][]} array.
+     *
+     * @param c 3D Complex array
+     * @param interleavedDim Depth level of the array to interleave
+     * @return complex interleaved array alternating real and
+     *         imaginary values
+     *
+     * @since 1.0
+     */
+    public static double[][][] complex2Interleaved(Complex[][][] c, int interleavedDim) {
+        if (interleavedDim > 2 || interleavedDim < 0) {
+            throw new IndexOutOfRangeException(interleavedDim);
+        }
+        int w = c.length;
+        int h = c[0].length;
+        int d = c[0][0].length;
+        double[][][] i;
+        if (interleavedDim == 0) {
+            i = new double[2 * w][h][d];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        i[x * 2][y][z] = c[x][y][z].getReal();
+                        i[x * 2 + 1][y][z] = c[x][y][z].getImaginary();
+                    }
+                }
+            }
+        } else if (interleavedDim == 1) {
+            i = new double[w][2 * h][d];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        i[x][y * 2][z] = c[x][y][z].getReal();
+                        i[x][y * 2 + 1][z] = c[x][y][z].getImaginary();
+                    }
+                }
+            }
+        } else {
+            i = new double[w][h][2 * d];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        i[x][y][z * 2] = c[x][y][z].getReal();
+                        i[x][y][z * 2 + 1] = c[x][y][z].getImaginary();
+                    }
+                }
+            }
+        }
+        return i;
+    }
+
+    /**
+     * Converts a 4D {@code Complex[][][][]} array to an interleaved complex
+     * {@code double[][][][]} array.
+     *
+     * @param c 4D Complex array
+     * @param interleavedDim Depth level of the array to interleave
+     * @return complex interleaved array alternating real and
+     *         imaginary values
+     *
+     * @since 1.0
+     */
+    public static double[][][][] complex2Interleaved(Complex[][][][] c, int interleavedDim) {
+        if (interleavedDim > 3 || interleavedDim < 0) {
+            throw new IndexOutOfRangeException(interleavedDim);
+        }
+        int w = c.length;
+        int h = c[0].length;
+        int d = c[0][0].length;
+        int v = c[0][0][0].length;
+        double[][][][] i;
+        if (interleavedDim == 0) {
+            i = new double[2 * w][h][d][v];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        for (int t = 0; t > v; t++) {
+                            i[x * 2][y][z][t] = c[x][y][z][t].getReal();
+                            i[x * 2 + 1][y][z][t] = c[x][y][z][t].getImaginary();
+                        }
+                    }
+                }
+            }
+        } else if (interleavedDim == 1) {
+            i = new double[w][2 * h][d][v];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        for (int t = 0; t > v; t++) {
+                            i[x][y * 2][z][t] = c[x][y][z][t].getReal();
+                            i[x][y * 2 + 1][z][t] = c[x][y][z][t].getImaginary();
+                        }
+                    }
+                }
+            }
+        } else if (interleavedDim == 2) {
+            i = new double[w][h][2 * d][v];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        for (int t = 0; t > v; t++) {
+                        i[x][y][z * 2][t] = c[x][y][z][t].getReal();
+                        i[x][y][z * 2 + 1][t] = c[x][y][z][t].getImaginary();
+                        }
+                    }
+                }
+            }
+        } else {
+            i = new double[w][h][d][2 * v];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        for (int t = 0; t > v; t++) {
+                        i[x][y][z][t * 2] = c[x][y][z][t].getReal();
+                        i[x][y][z][t * 2 + 1] = c[x][y][z][t].getImaginary();
+                        }
+                    }
+                }
+            }
+        }
+        return i;
+    }
+
+    /**
+     * Converts a 3D {@code Complex[][][]} array to an interleaved complex
+     * {@code double[][][]} array. The third level of the array is
+     * interleaved.
+     *
+     * @param c 3D Complex array
+     * @return complex interleaved array alternating real and
+     *         imaginary values
+     *
+     * @since 1.0
+     */
+    public static double[][][] complex2Interleaved(Complex[][][] c) {
+        return complex2Interleaved(c, 2);
+    }
+
+    /**
+     * Converts a 4D {@code Complex[][][][]} array to an interleaved complex
+     * {@code double[][][][]} array. The fourth level of the array is
+     * interleaved.
+     *
+     * @param c 4D Complex array
+     * @return complex interleaved array alternating real and
+     *         imaginary values
+     *
+     * @since 1.0
+     */
+    public static double[][][][] complex2Interleaved(Complex[][][][] c) {
+        return complex2Interleaved(c, 3);
+    }
+
+    /**
+     * Converts a 2D {@code Complex[][]} array to an interleaved complex
+     * {@code float[][]} array.
+     *
+     * @param c 2D Complex array
+     * @param interleavedDim Depth level of the array to interleave
+     * @return complex interleaved {@code float[][]} alternating real and
+     *         imaginary values
+     *
+     * @since 1.0
+     */
+    public static float[][] complex2InterleavedFloat(Complex[][] c, int interleavedDim) {
+        if (interleavedDim > 1 || interleavedDim < 0) {
+            throw new IndexOutOfRangeException(interleavedDim);
+        }
+        final int w = c.length;
+        final int h = c[0].length;
+        float[][] i;
+        if (interleavedDim == 0) {
+            i = new float[2 * w][h];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    i[x * 2][y] = (float) c[x][y].getReal();
+                    i[x * 2 + 1][y] = (float) c[x][y].getImaginary();
+                }
+            }
+        } else {
+            i = new float[w][2 * h];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    i[x][y * 2] = (float) c[x][y].getReal();
+                    i[x][y * 2 + 1] = (float) c[x][y].getImaginary();
+                }
+            }
+        }
+        return i;
+    }
+
+    /**
+     * Converts a 2D {@code Complex[][]} array to an interleaved complex
+     * {@code float[][]} array. The second d level of the array is assumed
+     * to be interleaved.
+     *
+     * @param c 2D Complex array
+     *
+     * @return complex interleaved {@code float[][]} alternating real and
+     *         imaginary values
+     *
+     * @since 1.0
+     */
+    public static float[][] complex2InterleavedFloat(Complex[][] c) {
+        return complex2InterleavedFloat(c, 1);
+    }
+
+    /**
+     * Converts a 3D {@code Complex[][][]} array to an interleaved complex
+     * {@code float[][][]} array.
+     *
+     * @param c 3D Complex array
+     * @param interleavedDim Depth level of the array to interleave
+     * @return complex interleaved {@code float[][][]} alternating real and
+     *         imaginary values
+     *
+     * @since 1.0
+     */
+    public static float[][][] complex2InterleavedFloat(Complex[][][] c, int interleavedDim) {
+        if (interleavedDim > 2 || interleavedDim < 0) {
+            throw new IndexOutOfRangeException(interleavedDim);
+        }
+        final int w = c.length;
+        final int h = c[0].length;
+        final int d = c[0][0].length;
+        float[][][] i;
+        if (interleavedDim == 0) {
+            i = new float[2 * w][h][d];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        i[x * 2][y][z] = (float) c[x][y][z].getReal();
+                        i[x * 2 + 1][y][z] = (float) c[x][y][z].getImaginary();
+                    }
+                }
+            }
+        } else if (interleavedDim == 1) {
+            i = new float[w][2 * h][d];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        i[x][y * 2][z] = (float) c[x][y][z].getReal();
+                        i[x][y * 2 + 1][z] = (float) c[x][y][z].getImaginary();
+                    }
+                }
+            }
+        } else {
+            i = new float[w][h][2 * d];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        i[x][y][z * 2] = (float) c[x][y][z].getReal();
+                        i[x][y][z * 2 + 1] = (float) c[x][y][z].getImaginary();
+                    }
+                }
+            }
+        }
+        return i;
+    }
+
+    /**
+     * Converts a 3D {@code Complex[][][]} array to an interleaved complex
+     * {@code float[][][]} array. The third d level of the array is
+     * interleaved.
+     *
+     * @param c 2D Complex array
+     *
+     * @return complex interleaved {@code float[][][]} alternating real and
+     *         imaginary values
+     *
+     * @since 1.0
+     */
+    public static float[][][] complex2InterleavedFloat(Complex[][][] c) {
+        return complex2InterleavedFloat(c, 2);
+    }
+
+    /**
+     * Converts a 2D interleaved complex {@code double[][]} array to a
+     * {@code Complex[][]} array.
+     *
+     * @param i 2D complex interleaved array
+     * @param interleavedDim Depth level of the array to interleave
+     * @return 2D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][] interleaved2Complex(double[][] i, int interleavedDim) {
+        if (interleavedDim > 1 || interleavedDim < 0) {
+            throw new IndexOutOfRangeException(interleavedDim);
+        }
+        final int w = i.length;
+        final int h = i[0].length;
+        Complex[][] c;
+        if (interleavedDim == 0) {
+            c = new Complex[w / 2][h];
+            for (int x = 0; x < w / 2; x++) {
+                for (int y = 0; y < h; y++) {
+                    c[x][y] = Complex.ofCartesian(i[x * 2][y], i[x * 2 + 1][y]);
+                }
+            }
+        } else {
+            c = new Complex[w][h / 2];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h / 2; y++) {
+                    c[x][y] = Complex.ofCartesian(i[x][y * 2], i[x][y * 2 + 1]);
+                }
+            }
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 2D interleaved complex {@code double[][]} array to a
+     * {@code Complex[][]} array. The second d level of the array is assumed
+     * to be interleaved.
+     *
+     * @param d 2D complex interleaved array
+     * @return 2D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][] interleaved2Complex(double[][] d) {
+        return interleaved2Complex(d, 1);
+    }
+
+    /**
+     * Converts a 3D interleaved complex {@code double[][][]} array to a
+     * {@code Complex[][][]} array.
+     *
+     * @param i 3D complex interleaved array
+     * @param interleavedDim Depth level of the array to interleave
+     * @return 3D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][] interleaved2Complex(double[][][] i, int interleavedDim) {
+        if (interleavedDim > 2 || interleavedDim < 0) {
+            throw new IndexOutOfRangeException(interleavedDim);
+        }
+        final int w = i.length;
+        final int h = i[0].length;
+        final int d = i[0][0].length;
+        Complex[][][] c;
+        if (interleavedDim == 0) {
+            c = new Complex[w / 2][h][d];
+            for (int x = 0; x < w / 2; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        c[x][y][z] = Complex.ofCartesian(i[x * 2][y][z], i[x * 2 + 1][y][z]);
+                    }
+                }
+            }
+        } else if (interleavedDim == 1) {
+            c = new Complex[w][h / 2][d];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h / 2; y++) {
+                    for (int z = 0; z < d; z++) {
+                        c[x][y][z] = Complex.ofCartesian(i[x][y * 2][z], i[x][y * 2 + 1][z]);
+                    }
+                }
+            }
+        } else {
+            c = new Complex[w][h][d / 2];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d / 2; z++) {
+                        c[x][y][z] = Complex.ofCartesian(i[x][y][z * 2], i[x][y][z * 2 + 1]);
+                    }
+                }
+            }
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 4D interleaved complex {@code double[][][][]} array to a
+     * {@code Complex[][][][]} array.
+     *
+     * @param i 4D complex interleaved array
+     * @param interleavedDim Depth level of the array to interleave
+     * @return 4D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][][] interleaved2Complex(double[][][][] i, int interleavedDim) {
+        if (interleavedDim > 2 || interleavedDim < 0) {
+            throw new IndexOutOfRangeException(interleavedDim);
+        }
+        final int w = i.length;
+        final int h = i[0].length;
+        final int d = i[0][0].length;
+        final int v = i[0][0][0].length;
+        Complex[][][][] c;
+        if (interleavedDim == 0) {
+            c = new Complex[w / 2][h][d][v];
+            for (int x = 0; x < w / 2; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        for (int t = 0; t < v; t++) {
+                            c[x][y][z][t] = Complex.ofCartesian(i[x * 2][y][z][t], i[x * 2 + 1][y][z][t]);
+                        }
+                    }
+                }
+            }
+        } else if (interleavedDim == 1) {
+            c = new Complex[w][h / 2][d][v];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h / 2; y++) {
+                    for (int z = 0; z < d; z++) {
+                        for (int t = 0; t < v; t++) {
+                            c[x][y][z][t] = Complex.ofCartesian(i[x][y * 2][z][t], i[x][y * 2 + 1][z][t]);
+                        }
+                    }
+                }
+            }
+        } else if (interleavedDim == 2) {
+            c = new Complex[w][h][d / 2][v];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d / 2; z++) {
+                        for (int t = 0; t < v; t++) {
+                            c[x][y][z][t] = Complex.ofCartesian(i[x][y][z * 2][t], i[x][y][z * 2 + 1][t]);
+                        }
+                    }
+                }
+            }
+        } else {
+            c = new Complex[w][h][d][v / 2];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        for (int t = 0; t < v / 2; t++) {
+                            c[x][y][z][t] = Complex.ofCartesian(i[x][y][z][t * 2], i[x][y][z][t * 2 + 1]);
+                        }
+                    }
+                }
+            }
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 3D interleaved complex {@code double[][][]} array to a
+     * {@code Complex[][][]} array. The third d level is assumed to be
+     * interleaved.
+     *
+     * @param d 3D complex interleaved array
+     * @return 3D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][] interleaved2Complex(double[][][] d) {
+        return interleaved2Complex(d, 2);
+    }
+
+    /**
+     * Converts a 2D interleaved complex {@code float[][]} array to a
+     * {@code Complex[][]} array.
+     *
+     * @param i 2D complex interleaved float array
+     * @param interleavedDim Depth level of the array to interleave
+     * @return 2D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][] interleaved2Complex(float[][] i, int interleavedDim) {
+        if (interleavedDim > 1 || interleavedDim < 0) {
+            throw new IndexOutOfRangeException(interleavedDim);
+        }
+        final int w = i.length;
+        final int h = i[0].length;
+        Complex[][] c;
+        if (interleavedDim == 0) {
+            c = new Complex[w / 2][h];
+            for (int x = 0; x < w / 2; x++) {
+                for (int y = 0; y < h; y++) {
+                    c[x][y] = Complex.ofCartesian(i[x * 2][y], i[x * 2 + 1][y]);
+                }
+            }
+        } else {
+            c = new Complex[w][h / 2];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h / 2; y++) {
+                    c[x][y] = Complex.ofCartesian(i[x][y * 2], i[x][y * 2 + 1]);
+                }
+            }
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 2D interleaved complex {@code float[][]} array to a
+     * {@code Complex[][]} array. The second d level of the array is assumed
+     * to be interleaved.
+     *
+     * @param d 2D complex interleaved float array
+     * @return 2D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][] interleaved2Complex(float[][] d) {
+        return interleaved2Complex(d, 1);
+    }
+
+    /**
+     * Converts a 3D interleaved complex {@code float[][][]} array to a
+     * {@code Complex[][][]} array.
+     *
+     * @param i 3D complex interleaved float array
+     * @param interleavedDim Depth level of the array to interleave
+     * @return 3D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][] interleaved2Complex(float[][][] i, int interleavedDim) {
+        if (interleavedDim > 2 || interleavedDim < 0) {
+            throw new IndexOutOfRangeException(interleavedDim);
+        }
+        final int w = i.length;
+        final int h = i[0].length;
+        final int d = i[0][0].length;
+        Complex[][][] c;
+        if (interleavedDim == 0) {
+            c = new Complex[w / 2][h][d];
+            for (int x = 0; x < w/2; x ++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d; z++) {
+                        c[x][y][z] = Complex.ofCartesian(i[x * 2][y][z], i[x * 2 + 1][y][z]);
+                    }
+                }
+            }
+        } else if (interleavedDim == 1) {
+            c = new Complex[w][h / 2][d];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h/2; y ++) {
+                    for (int z = 0; z < d; z++) {
+                        c[x][y][z] = Complex.ofCartesian(i[x][y * 2][z], i[x][y * 2 + 1][z]);
+                    }
+                }
+            }
+        } else {
+            c = new Complex[w][h][d / 2];
+            for (int x = 0; x < w; x++) {
+                for (int y = 0; y < h; y++) {
+                    for (int z = 0; z < d/2; z++) {
+                        c[x][y][z] = Complex.ofCartesian(i[x][y][z * 2], i[x][y][z * 2 + 1]);
+                    }
+                }
+            }
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 3D interleaved complex {@code float[][][]} array to a
+     * {@code Complex[]} array. The third level of the array is assumed to
+     * be interleaved.
+     *
+     * @param d 3D complex interleaved float array
+     * @return 3D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][] interleaved2Complex(float[][][] d) {
+        return interleaved2Complex(d, 2);
+    }
+
+    // SPLIT METHODS
+
+    /**
+     * Converts a split complex array {@code double[] r, double[] i} to a
+     * {@code Complex[]} array.
+     *
+     * @param real real component
+     * @param imag imaginary component
+     * @return {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[] split2Complex(double[] real, double[] imag) {
+        final int length = real.length;
+        final Complex[] c = new Complex[length];
+        for (int n = 0; n < length; n++) {
+            c[n] = Complex.ofCartesian(real[n], imag[n]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 2D split complex array {@code double[][] r, double[][] i} to a
+     * 2D {@code Complex[][]} array.
+     *
+     * @param real real component
+     * @param imag imaginary component
+     * @return 2D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][] split2Complex(double[][] real, double[][] imag) {
+        final int length = real.length;
+        Complex[][] c = new Complex[length][];
+        for (int x = 0; x < length; x++) {
+            c[x] = split2Complex(real[x], imag[x]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 3D split complex array {@code double[][][] r, double[][][] i}
+     * to a 3D {@code Complex[][][]} array.
+     *
+     * @param real real component
+     * @param imag imaginary component
+     * @return 3D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][] split2Complex(double[][][] real, double[][][] imag) {
+        final int length = real.length;
+        Complex[][][] c = new Complex[length][][];
+        for (int x = 0; x < length; x++) {
+            c[x] = split2Complex(real[x], imag[x]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 4D split complex array {@code double[][][][] r, double[][][][] i}
+     * to a 4D {@code Complex[][][][]} array.
+     *
+     * @param real real component
+     * @param imag imaginary component
+     * @return 4D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][][] split2Complex(double[][][][] real, double[][][][] imag) {
+        final int length = real.length;
+        Complex[][][][] c = new Complex[length][][][];
+        for (int x = 0; x < length; x++) {
+            c[x] = split2Complex(real[x], imag[x]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a split complex array {@code float[] r, float[] i} to a
+     * {@code Complex[]} array.
+     *
+     * @param real real component
+     * @param imag imaginary component
+     * @return {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[] split2Complex(float[] real, float[] imag) {
+        final int length = real.length;
+        final Complex[] c = new Complex[length];
+        for (int n = 0; n < length; n++) {
+            c[n] = Complex.ofCartesian(real[n], imag[n]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 2D split complex array {@code float[][] r, float[][] i} to a
+     * 2D {@code Complex[][]} array.
+     *
+     * @param real real component
+     * @param imag imaginary component
+     * @return 2D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][] split2Complex(float[][] real, float[][] imag) {
+        final int length = real.length;
+        Complex[][] c = new Complex[length][];
+        for (int x = 0; x < length; x++) {
+            c[x] = split2Complex(real[x], imag[x]);
+        }
+        return c;
+    }
+
+    /**
+     * Converts a 3D split complex array {@code float[][][] r, float[][][] i} to
+     * a 3D {@code Complex[][][]} array.
+     *
+     * @param real real component
+     * @param imag imaginary component
+     * @return 3D {@code Complex} array
+     *
+     * @since 1.0
+     */
+    public static Complex[][][] split2Complex(float[][][] real, float[][][] imag) {
+        final int length = real.length;
+        Complex[][][] c = new Complex[length][][];
+        for (int x = 0; x < length; x++) {
+            c[x] = split2Complex(real[x], imag[x]);
+        }
+        return c;
+    }
+
+    // MISC
+
+    /**
+     * Initializes a {@code Complex[]} array to zero, to avoid
+     * NullPointerExceptions.
+     *
+     * @param c Complex array
+     * @return c
+     *
+     * @since 1.0
+     */
+    public static Complex[] initialize(Complex[] c) {
+        final int length = c.length;
+        for (int x = 0; x < length; x++) {
+            c[x] = Complex.ZERO;
+        }
+        return c;
+    }
+
+    /**
+     * Initializes a {@code Complex[][]} array to zero, to avoid
+     * NullPointerExceptions.
+     *
+     * @param c {@code Complex} array
+     * @return c
+     *
+     * @since 1.0
+     */
+    public static Complex[][] initialize(Complex[][] c) {
+        final int length = c.length;
+        for (int x = 0; x < length; x++) {
+            c[x] = initialize(c[x]);
+        }
+        return c;
+    }
+
+    /**
+     * Initializes a {@code Complex[][][]} array to zero, to avoid
+     * NullPointerExceptions.
+     *
+     * @param c {@code Complex} array
+     * @return c
+     *
+     * @since 1.0
+     */
+    public static Complex[][][] initialize(Complex[][][] c) {
+        final int length = c.length;
+        for (int x = 0; x < length; x++) {
+            c[x] = initialize(c[x]);
+        }
+        return c;
+    }
+
+    /**
+     * Returns {@code double[]} containing absolute values (magnitudes) of a
+     * {@code Complex[]} array.
+     *
+     * @param c {@code Complex} array
+     * @return {@code double[]}
+     *
+     * @since 1.0
+     */
+    public static double[] abs(Complex[] c) {
+        final int length = c.length;
+        final double[] i = new double[length];
+        for (int x = 0; x < length; x++) {
+            i[x] = c[x].abs();
+        }
+        return i;
+    }
+
+    /**
+     * Returns {@code double[]} containing arguments (phase angles) of a
+     * {@code Complex[]} array.
+     *
+     * @param c {@code Complex} array
+     * @return {@code double[]} array
+     *
+     * @since 1.0
+     */
+    public static double[] arg(Complex[] c) {
+        final int length = c.length;
+        final double[] i = new double[length];
+        for (int x = 0; x < length; x++) {
+            i[x] = c[x].getArgument();
+        }
+        return i;
+    }
+
+    /**
+     * Exception to be throw when a negative value is passed as the modulus.
+     */
+    private static class NegativeModulusException extends IllegalArgumentException {
+        /**
+         * @param r Wrong modulus.
+         */
+        NegativeModulusException(double r) {
+            super("Modulus is negative: " + r);
+        }
+    }
+
+    /**
+     * Exception to be throw when an out-of-range index value is passed.
+     */
+    private static class IndexOutOfRangeException extends IllegalArgumentException {
+        /**
+         * @param i Wrong index.
+         */
+        IndexOutOfRangeException(int i) {
+            super("Out of range: " + i);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/package-info.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/package-info.java b/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/package-info.java
new file mode 100644
index 0000000..0b7c1cd
--- /dev/null
+++ b/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Complex numbers collections.
+ */
+package org.apache.commons.numbers.complex.streams;

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/commons-numbers-complex-streams/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/commons-numbers-complex-streams/src/site/resources/profile.jacoco b/commons-numbers-complex-streams/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..a12755f
--- /dev/null
+++ b/commons-numbers-complex-streams/src/site/resources/profile.jacoco
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------------
+#
+# Empty file used to automatically trigger JaCoCo profile from commons parent pom


[3/4] commons-numbers git commit: NUMBERS-54: Create module "commons-numbers-complex-streams".

Posted by er...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java
new file mode 100644
index 0000000..d348571
--- /dev/null
+++ b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java
@@ -0,0 +1,476 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.numbers.complex.streams;
+
+import org.apache.commons.numbers.complex.Complex;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ */
+public class ComplexUtilsTest {
+
+    private static final double inf = Double.POSITIVE_INFINITY;
+    private static final double negInf = Double.NEGATIVE_INFINITY;
+    private static final double nan = Double.NaN;
+    private static final double pi = Math.PI;
+
+    private static final Complex negInfInf = Complex.ofCartesian(negInf, inf);
+    private static final Complex infNegInf = Complex.ofCartesian(inf, negInf);
+    private static final Complex infInf = Complex.ofCartesian(inf, inf);
+    private static final Complex negInfNegInf = Complex.ofCartesian(negInf, negInf);
+    private static final Complex infNaN = Complex.ofCartesian(inf, nan);
+    private static final Complex NAN = Complex.ofCartesian(nan, nan);
+
+    private static Complex c[]; // complex array with real values even and imag
+                                // values odd
+    private static Complex cr[]; // complex array with real values consecutive
+    private static Complex ci[]; // complex array with imag values consecutive
+    private static double d[]; // real array with consecutive vals
+    private static double di[]; // real array with consecutive vals,
+                                // 'interleaved' length
+    private static float f[]; // real array with consecutive vals
+    private static float fi[]; // real array with consec vals, interleaved
+                               // length
+    private static double sr[]; // real component of split array, evens
+    private static double si[]; // imag component of split array, odds
+    private static float sfr[]; // real component of split array, float, evens
+    private static float sfi[]; // imag component of split array, float, odds
+    static Complex ans1, ans2; // answers to single value extraction methods
+    static Complex[] ansArrayc1r, ansArrayc1i, ansArrayc2r, ansArrayc2i, ansArrayc3, ansArrayc4; // answers
+                                                                                                 // to
+                                                                                                 // range
+                                                                                                 // extraction
+                                                                                                 // methods
+    static double[] ansArrayd1r, ansArrayd2r, ansArrayd1i, ansArrayd2i, ansArraydi1, ansArraydi2;
+    static float[] ansArrayf1r, ansArrayf2r, ansArrayf1i, ansArrayf2i, ansArrayfi1, ansArrayfi2;
+    static String msg; // error message for AssertEquals
+    static Complex[][] c2d, cr2d, ci2d; // for 2d methods
+    static Complex[][][] c3d, cr3d, ci3d; // for 3d methods
+    static double[][] d2d, di2d, sr2d, si2d;
+    static double[][][] d3d, di3d, sr3d, si3d;
+    static float[][] f2d, fi2d, sfr2d, sfi2d;
+    static float[][][] f3d, fi3d, sfr3d, sfi3d;
+
+    private static void setArrays() { // initial setup method
+        c = new Complex[10];
+        cr = new Complex[10];
+        ci = new Complex[10];
+        d = new double[10];
+        f = new float[10];
+        di = new double[20];
+        fi = new float[20];
+        sr = new double[10];
+        si = new double[10];
+        sfr = new float[10];
+        sfi = new float[10];
+        c2d = new Complex[10][10];
+        cr2d = new Complex[10][10];
+        ci2d = new Complex[10][10];
+        c3d = new Complex[10][10][10];
+        cr3d = new Complex[10][10][10];
+        ci3d = new Complex[10][10][10];
+        d2d = new double[10][10];
+        d3d = new double[10][10][10];
+        f2d = new float[10][10];
+        f3d = new float[10][10][10];
+        sr2d = new double[10][10];
+        sr3d = new double[10][10][10];
+        si2d = new double[10][10];
+        si3d = new double[10][10][10];
+        sfr2d = new float[10][10];
+        sfr3d = new float[10][10][10];
+        sfi2d = new float[10][10];
+        sfi3d = new float[10][10][10];
+        di2d = new double[10][20];
+        di3d = new double[10][10][20];
+        fi2d = new float[10][20];
+        fi3d = new float[10][10][20];
+        for (int i = 0; i < 20; i += 2) {
+            d[i / 2] = i / 2;
+            f[i / 2] = i / 2;
+            di[i] = i;
+            di[i + 1] = i + 1;
+            fi[i] = i;
+            fi[i + 1] = i + 1;
+            c[i / 2] = Complex.ofCartesian(i, i + 1);
+            cr[i / 2] = Complex.ofReal(i / 2);
+            ci[i / 2] = Complex.ofCartesian(0, i / 2);
+            sr[i / 2] = i;
+            si[i / 2] = i + 1;
+            sfr[i / 2] = i;
+            sfi[i / 2] = i + 1;
+        }
+        for (int i = 0; i < 10; i++) {
+            for (int j = 0; j < 20; j += 2) {
+                d2d[i][j / 2] = 10 * i + j / 2;
+                f2d[i][j / 2] = 10 * i + j / 2;
+                sr2d[i][j / 2] = 10 * i + j;
+                si2d[i][j / 2] = 10 * i + j + 1;
+                sfr2d[i][j / 2] = 10 * i + j;
+                sfi2d[i][j / 2] = 10 * i + j + 1;
+                di2d[i][j] = 10 * i + j;
+                di2d[i][j + 1] = 10 * i + j + 1;
+                fi2d[i][j] = 10 * i + j;
+                fi2d[i][j + 1] = 10 * i + j + 1;
+                c2d[i][j / 2] = Complex.ofCartesian(10 * i + j, 10 * i + j + 1);
+                cr2d[i][j / 2] = Complex.ofReal(10 * i + j / 2);
+                ci2d[i][j / 2] = Complex.ofCartesian(0, 10 * i + j / 2);
+            }
+        }
+        for (int i = 0; i < 10; i++) {
+            for (int j = 0; j < 10; j++) {
+                for (int k = 0; k < 20; k += 2) {
+                    d3d[i][j][k / 2] = 100 * i + 10 * j + k / 2;
+                    f3d[i][j][k / 2] = 100 * i + 10 * j + k / 2;
+                    sr3d[i][j][k / 2] = 100 * i + 10 * j + k;
+                    si3d[i][j][k / 2] = 100 * i + 10 * j + k + 1;
+                    sfr3d[i][j][k / 2] = 100 * i + 10 * j + k;
+                    sfi3d[i][j][k / 2] = 100 * i + 10 * j + k + 1;
+                    di3d[i][j][k] = 100 * i + 10 * j + k;
+                    di3d[i][j][k + 1] = 100 * i + 10 * j + k + 1;
+                    fi3d[i][j][k] = 100 * i + 10 * j + k;
+                    fi3d[i][j][k + 1] = 100 * i + 10 * j + k + 1;
+                    c3d[i][j][k / 2] = Complex.ofCartesian(100 * i + 10 * j + k, 100 * i + 10 * j + k + 1);
+                    cr3d[i][j][k / 2] = Complex.ofReal(100 * i + 10 * j + k / 2);
+                    ci3d[i][j][k / 2] = Complex.ofCartesian(0, 100 * i + 10 * j + k / 2);
+                }
+            }
+        }
+        ansArrayc1r = new Complex[] { Complex.ofReal(3), Complex.ofReal(4), Complex.ofReal(5), Complex.ofReal(6), Complex.ofReal(7) };
+        ansArrayc2r = new Complex[] { Complex.ofReal(3), Complex.ofReal(5), Complex.ofReal(7) };
+        ansArrayc1i = new Complex[] { Complex.ofCartesian(0, 3), Complex.ofCartesian(0, 4), Complex.ofCartesian(0, 5), Complex.ofCartesian(0, 6),
+                Complex.ofCartesian(0, 7) };
+        ansArrayc2i = new Complex[] { Complex.ofCartesian(0, 3), Complex.ofCartesian(0, 5), Complex.ofCartesian(0, 7) };
+        ansArrayc3 = new Complex[] { Complex.ofCartesian(6, 7), Complex.ofCartesian(8, 9), Complex.ofCartesian(10, 11), Complex.ofCartesian(12, 13),
+                Complex.ofCartesian(14, 15) };
+        ansArrayc4 = new Complex[] { Complex.ofCartesian(6, 7), Complex.ofCartesian(10, 11), Complex.ofCartesian(14, 15) };
+        ansArrayd1r = new double[] { 6, 8, 10, 12, 14 };
+        ansArrayd1i = new double[] { 7, 9, 11, 13, 15 };
+        ansArrayd2r = new double[] { 6, 10, 14 };
+        ansArrayd2i = new double[] { 7, 11, 15 };
+        ansArrayf1r = new float[] { 6, 8, 10, 12, 14 };
+        ansArrayf1i = new float[] { 7, 9, 11, 13, 15 };
+        ansArrayf2r = new float[] { 6, 10, 14 };
+        ansArrayf2i = new float[] { 7, 11, 15 };
+        ansArraydi1 = new double[] { 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+        ansArrayfi1 = new float[] { 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+        ansArraydi2 = new double[] { 6, 7, 10, 11, 14, 15 };
+        ansArrayfi2 = new float[] { 6, 7, 10, 11, 14, 15 };
+        msg = "";
+    }
+
+    @Test
+    public void testPolar2Complex() {
+        TestUtils.assertEquals(Complex.ONE, ComplexUtils.polar2Complex(1, 0), 10e-12);
+        TestUtils.assertEquals(Complex.ZERO, ComplexUtils.polar2Complex(0, 1), 10e-12);
+        TestUtils.assertEquals(Complex.ZERO, ComplexUtils.polar2Complex(0, -1), 10e-12);
+        TestUtils.assertEquals(Complex.I, ComplexUtils.polar2Complex(1, pi / 2), 10e-12);
+        TestUtils.assertEquals(Complex.I.negate(), ComplexUtils.polar2Complex(1, -pi / 2), 10e-12);
+        double r = 0;
+        for (int i = 0; i < 5; i++) {
+            r += i;
+            double theta = 0;
+            for (int j = 0; j < 20; j++) {
+                theta += pi / 6;
+                TestUtils.assertEquals(altPolar(r, theta), ComplexUtils.polar2Complex(r, theta), 10e-12);
+            }
+            theta = -2 * pi;
+            for (int j = 0; j < 20; j++) {
+                theta -= pi / 6;
+                TestUtils.assertEquals(altPolar(r, theta), ComplexUtils.polar2Complex(r, theta), 10e-12);
+            }
+        }
+    }
+
+    protected Complex altPolar(double r, double theta) {
+        return Complex.I.multiply(Complex.ofCartesian(theta, 0)).exp().multiply(Complex.ofCartesian(r, 0));
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testPolar2ComplexIllegalModulus() {
+        ComplexUtils.polar2Complex(-1, 0);
+    }
+
+    @Test
+    public void testPolar2ComplexNaN() {
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(nan, 1));
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, nan));
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(nan, nan));
+    }
+
+    @Test
+    public void testPolar2ComplexInf() {
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, inf));
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, negInf));
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(inf, inf));
+        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(inf, negInf));
+        TestUtils.assertSame(infInf, ComplexUtils.polar2Complex(inf, pi / 4));
+        TestUtils.assertSame(infNaN, ComplexUtils.polar2Complex(inf, 0));
+        TestUtils.assertSame(infNegInf, ComplexUtils.polar2Complex(inf, -pi / 4));
+        TestUtils.assertSame(negInfInf, ComplexUtils.polar2Complex(inf, 3 * pi / 4));
+        TestUtils.assertSame(negInfNegInf, ComplexUtils.polar2Complex(inf, 5 * pi / 4));
+    }
+
+    @Test
+    public void testCExtract() {
+        final double[] real = new double[] { negInf, -123.45, 0, 1, 234.56, pi, inf };
+        final Complex[] complex = ComplexUtils.real2Complex(real);
+
+        for (int i = 0; i < real.length; i++) {
+            Assert.assertEquals(real[i], complex[i].getReal(), 0d);
+        }
+    }
+
+    // EXTRACTION METHODS
+
+    @Test
+    public void testExtractionMethods() {
+        setArrays();
+        // Extract complex from real double array, index 3
+        TestUtils.assertSame(Complex.ofReal(3), ComplexUtils.extractComplexFromRealArray(d, 3));
+        // Extract complex from real float array, index 3
+        TestUtils.assertSame(Complex.ofReal(3), ComplexUtils.extractComplexFromRealArray(f, 3));
+        // Extract real double from complex array, index 3
+        TestUtils.assertSame(6, ComplexUtils.extractRealFromComplexArray(c, 3));
+        // Extract real float from complex array, index 3
+        TestUtils.assertSame(6, ComplexUtils.extractRealFloatFromComplexArray(c, 3));
+        // Extract complex from interleaved double array, index 3
+        TestUtils.assertSame(Complex.ofCartesian(6, 7), ComplexUtils.extractComplexFromInterleavedArray(d, 3));
+        // Extract complex from interleaved float array, index 3
+        TestUtils.assertSame(Complex.ofCartesian(6, 7), ComplexUtils.extractComplexFromInterleavedArray(f, 3));
+        // Extract interleaved double from complex array, index 3
+        TestUtils.assertEquals(msg, new double[] { 6, 7 }, ComplexUtils.extractInterleavedFromComplexArray(c, 3),
+                Math.ulp(1));
+        // Extract interleaved float from complex array, index 3
+        TestUtils.assertEquals(msg, new double[] { 6, 7 }, ComplexUtils.extractInterleavedFromComplexArray(c, 3),
+                Math.ulp(1));
+        if (!msg.equals("")) {
+            throw new RuntimeException(msg);
+        }
+    }
+    // REAL <-> COMPLEX
+
+    @Test
+    public void testRealToComplex() {
+        setArrays();
+        // Real double to complex, range 3-7, increment 1, entered as ints
+        // Real double to complex, whole array
+        TestUtils.assertEquals(msg, cr, ComplexUtils.real2Complex(d),Math.ulp(1.0));
+        // Real float to complex, whole array
+        TestUtils.assertEquals(msg, cr, ComplexUtils.real2Complex(f),Math.ulp(1.0));
+        // 2d
+        for (int i = 0; i < 10; i++) {
+            // Real double to complex, 2d
+            TestUtils.assertEquals(msg, cr2d[i], ComplexUtils.real2Complex(d2d[i]),Math.ulp(1.0));
+            // Real float to complex, 2d
+            TestUtils.assertEquals(msg, cr2d[i], ComplexUtils.real2Complex(f2d[i]),Math.ulp(1.0));
+        }
+        // 3d
+        for (int i = 0; i < 10; i++) {
+            for (int j = 0; j < 10; j++) {
+                // Real double to complex, 3d
+                TestUtils.assertEquals(msg, cr3d[i][j], ComplexUtils.real2Complex(d3d[i][j]),Math.ulp(1.0));
+                // Real float to complex, 3d
+                TestUtils.assertEquals(msg, cr3d[i][j], ComplexUtils.real2Complex(f3d[i][j]),Math.ulp(1.0));
+            }
+        }
+        if (!msg.equals("")) {
+            throw new RuntimeException(msg);
+        }
+    }
+
+    @Test
+    public void testComplexToReal() {
+        setArrays();
+        // Real complex to double, whole array
+        TestUtils.assertEquals(msg, sr, ComplexUtils.complex2Real(c),Math.ulp(1.0));
+        // Real complex to float, whole array
+        TestUtils.assertEquals(msg, sfr, ComplexUtils.complex2RealFloat(c),Math.ulp(1.0f));
+        // 2d
+        for (int i = 0; i < 10; i++) {
+            // Real complex to double, 2d
+            TestUtils.assertEquals(msg, sr2d[i], ComplexUtils.complex2Real(c2d[i]),Math.ulp(1.0));
+            // Real complex to float, 2d
+            TestUtils.assertEquals(msg, sfr2d[i], ComplexUtils.complex2RealFloat(c2d[i]),Math.ulp(1.0f));
+        }
+        // 3d
+        for (int i = 0; i < 10; i++) {
+            for (int j = 0; j < 10; j++) {
+                // Real complex to double, 3d
+                TestUtils.assertEquals(msg, sr3d[i][j], ComplexUtils.complex2Real(c3d[i][j]),Math.ulp(1.0));
+                // Real complex to float, 3d
+                TestUtils.assertEquals(msg, sfr3d[i][j], ComplexUtils.complex2RealFloat(c3d[i][j]),Math.ulp(1.0f));
+            }
+        }
+        if (!msg.equals("")) {
+            throw new RuntimeException(msg);
+        }
+    }
+
+    // IMAGINARY <-> COMPLEX
+
+    @Test
+    public void testImaginaryToComplex() {
+        setArrays();
+        // Imaginary double to complex, whole array
+        TestUtils.assertEquals(msg, ci, ComplexUtils.imaginary2Complex(d),Math.ulp(1.0));
+        // Imaginary float to complex, whole array
+        TestUtils.assertEquals(msg, ci, ComplexUtils.imaginary2Complex(f),Math.ulp(1.0));
+        // 2d
+        for (int i = 0; i < 10; i++) {
+            // Imaginary double to complex, 2d
+            TestUtils.assertEquals(msg, ci2d[i], ComplexUtils.imaginary2Complex(d2d[i]),Math.ulp(1.0));
+            // Imaginary float to complex, 2d
+            TestUtils.assertEquals(msg, ci2d[i], ComplexUtils.imaginary2Complex(f2d[i]),Math.ulp(1.0));
+        }
+        // 3d
+        for (int i = 0; i < 10; i++) {
+            for (int j = 0; j < 10; j++) {
+                // Imaginary double to complex, 3d
+                TestUtils.assertEquals(msg, ci3d[i][j], ComplexUtils.imaginary2Complex(d3d[i][j]),Math.ulp(1.0));
+                // Imaginary float to complex, 3d
+                TestUtils.assertEquals(msg, ci3d[i][j], ComplexUtils.imaginary2Complex(f3d[i][j]),Math.ulp(1.0));
+            }
+        }
+        if (!msg.equals("")) {
+            throw new RuntimeException(msg);
+        }
+    }
+
+    @Test
+    public void testComplexToImaginary() {
+        setArrays();
+        // Imaginary complex to double, whole array
+        TestUtils.assertEquals(msg, si, ComplexUtils.complex2Imaginary(c),Math.ulp(1.0));
+        // Imaginary complex to float, whole array
+        TestUtils.assertEquals(msg, sfi, ComplexUtils.complex2ImaginaryFloat(c),Math.ulp(1.0f));
+        // 2d
+        for (int i = 0; i < 10; i++) {
+            // Imaginary complex to double, 2d
+            TestUtils.assertEquals(msg, si2d[i], ComplexUtils.complex2Imaginary(c2d[i]),Math.ulp(1.0));
+            // Imaginary complex to float, 2d
+            TestUtils.assertEquals(msg, sfi2d[i], ComplexUtils.complex2ImaginaryFloat(c2d[i]),Math.ulp(1.0f));
+        }
+        // 3d
+        for (int i = 0; i < 10; i++) {
+            for (int j = 0; j < 10; j++) {
+                // Imaginary complex to double, 3d
+                TestUtils.assertEquals(msg, si3d[i][j], ComplexUtils.complex2Imaginary(c3d[i][j]),Math.ulp(1.0));
+                // Imaginary complex to float, 3d
+                TestUtils.assertEquals(msg, sfi3d[i][j], ComplexUtils.complex2ImaginaryFloat(c3d[i][j]),Math.ulp(1.0f));
+            }
+        }
+        if (!msg.equals("")) {
+            throw new RuntimeException(msg);
+        }
+    }
+
+    // INTERLEAVED <-> COMPLEX
+
+    @Test
+    public void testInterleavedToComplex() {
+        setArrays();
+        // Interleaved double to complex, whole array
+        TestUtils.assertEquals(msg, c, ComplexUtils.interleaved2Complex(di),Math.ulp(1.0));
+        // Interleaved float to complex, whole array
+        TestUtils.assertEquals(msg, c, ComplexUtils.interleaved2Complex(fi),Math.ulp(1.0));
+        // 2d
+        for (int i = 0; i < 10; i++) {
+            // Interleaved double to complex, 2d
+            TestUtils.assertEquals(msg, c2d[i], ComplexUtils.interleaved2Complex(di2d[i]),Math.ulp(1.0));
+            // Interleaved float to complex, 2d
+            TestUtils.assertEquals(msg, c2d[i], ComplexUtils.interleaved2Complex(fi2d[i]),Math.ulp(1.0));
+        }
+        // 3d
+        for (int i = 0; i < 10; i++) {
+            for (int j = 0; j < 10; j++) {
+                // Interleaved double to complex, 3d
+                TestUtils.assertEquals(msg, c3d[i][j], ComplexUtils.interleaved2Complex(di3d[i][j]),Math.ulp(1.0));
+                // Interleaved float to complex, 3d
+                TestUtils.assertEquals(msg, c3d[i][j], ComplexUtils.interleaved2Complex(fi3d[i][j]),Math.ulp(1.0));
+            }
+        }
+        if (!msg.equals("")) {
+            throw new RuntimeException(msg);
+        }
+    }
+
+    @Test
+    public void testComplexToInterleaved() {
+        setArrays();
+        TestUtils.assertEquals(msg, di, ComplexUtils.complex2Interleaved(c),Math.ulp(1.0));
+        // Interleaved complex to float, whole array
+        TestUtils.assertEquals(msg, fi, ComplexUtils.complex2InterleavedFloat(c),Math.ulp(1.0f));
+        // 2d
+        for (int i = 0; i < 10; i++) {
+            // Interleaved complex to double, 2d
+            TestUtils.assertEquals(msg, di2d[i], ComplexUtils.complex2Interleaved(c2d[i]),Math.ulp(1.0));
+            // Interleaved complex to float, 2d
+            TestUtils.assertEquals(msg, fi2d[i], ComplexUtils.complex2InterleavedFloat(c2d[i]),Math.ulp(1.0f));
+        }
+        // 3d
+        for (int i = 0; i < 10; i++) {
+            for (int j = 0; j < 10; j++) {
+                // Interleaved complex to double, 3d
+                TestUtils.assertEquals(msg, di3d[i][j], ComplexUtils.complex2Interleaved(c3d[i][j]),Math.ulp(1.0));
+                // Interleaved complex to float, 3d
+                TestUtils.assertEquals(msg, fi3d[i][j], ComplexUtils.complex2InterleavedFloat(c3d[i][j]),Math.ulp(1.0f));
+            }
+        }
+        if (!msg.equals("")) {
+            throw new RuntimeException(msg);
+        }
+    }
+
+    // SPLIT TO COMPLEX
+    @Test
+    public void testSplit2Complex() {
+        setArrays();
+        // Split double to complex, whole array
+        TestUtils.assertEquals(msg, c, ComplexUtils.split2Complex(sr, si),Math.ulp(1.0));
+
+        // 2d
+        for (int i = 0; i < 10; i++) {
+            // Split double to complex, 2d
+            TestUtils.assertEquals(msg, c2d[i], ComplexUtils.split2Complex(sr2d[i], si2d[i]),Math.ulp(1.0));
+        }
+        // 3d
+        for (int i = 0; i < 10; i++) {
+            for (int j = 0; j < 10; j++) {
+                // Split double to complex, 3d
+                TestUtils.assertEquals(msg, c3d[i][j], ComplexUtils.split2Complex(sr3d[i][j], si3d[i][j]),Math.ulp(1.0));
+            }
+        }
+        if (!msg.equals("")) {
+            throw new RuntimeException(msg);
+        }
+    }
+
+    // INITIALIZATION METHODS
+
+    @Test
+    public void testInitialize() {
+        Complex[] c = new Complex[10];
+        ComplexUtils.initialize(c);
+        for (Complex cc : c) {
+            TestUtils.assertEquals(Complex.ofCartesian(0, 0), cc, Math.ulp(0));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java
new file mode 100644
index 0000000..ec370ff
--- /dev/null
+++ b/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java
@@ -0,0 +1,410 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.numbers.complex.streams;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.apache.commons.numbers.complex.Complex;
+import org.apache.commons.numbers.core.Precision;
+
+import org.junit.Assert;
+
+/**
+ * Test utilities.
+ * TODO: Cleanup (remove unused and obsolete methods).
+ */
+class TestUtils {
+    /**
+     * Collection of static methods used in math unit tests.
+     */
+    private TestUtils() {
+        super();
+    }
+
+    /**
+     * Verifies that expected and actual are within delta, or are both NaN or
+     * infinities of the same sign.
+     */
+    public static void assertEquals(double expected, double actual, double delta) {
+        Assert.assertEquals(null, expected, actual, delta);
+    }
+
+    /**
+     * Verifies that expected and actual are within delta, or are both NaN or
+     * infinities of the same sign.
+     */
+    public static void assertEquals(String msg, double expected, double actual, double delta) {
+        // check for NaN
+        if(Double.isNaN(expected)){
+            Assert.assertTrue("" + actual + " is not NaN.",
+                Double.isNaN(actual));
+        } else {
+            Assert.assertEquals(msg, expected, actual, delta);
+        }
+    }
+
+    /**
+     * Verifies that the two arguments are exactly the same, either
+     * both NaN or infinities of same sign, or identical floating point values.
+     */
+    public static void assertSame(double expected, double actual) {
+     Assert.assertEquals(expected, actual, 0);
+    }
+
+    /**
+     * Verifies that real and imaginary parts of the two complex arguments
+     * are exactly the same.  Also ensures that NaN / infinite components match.
+     */
+    public static void assertSame(Complex expected, Complex actual) {
+        assertSame(expected.getReal(), actual.getReal());
+        assertSame(expected.getImaginary(), actual.getImaginary());
+    }
+
+    /**
+     * Verifies that real and imaginary parts of the two complex arguments
+     * differ by at most delta.  Also ensures that NaN / infinite components match.
+     */
+    public static void assertEquals(Complex expected, Complex actual, double delta) {
+        Assert.assertEquals(expected.getReal(), actual.getReal(), delta);
+        Assert.assertEquals(expected.getImaginary(), actual.getImaginary(), delta);
+    }
+
+    /**
+     * Verifies that two double arrays have equal entries, up to tolerance
+     */
+    public static void assertEquals(double expected[], double observed[], double tolerance) {
+        assertEquals("Array comparison failure", expected, observed, tolerance);
+    }
+
+    /**
+     * Serializes an object to a bytes array and then recovers the object from the bytes array.
+     * Returns the deserialized object.
+     *
+     * @param o  object to serialize and recover
+     * @return  the recovered, deserialized object
+     */
+    public static Object serializeAndRecover(Object o) {
+        try {
+            // serialize the Object
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            ObjectOutputStream so = new ObjectOutputStream(bos);
+            so.writeObject(o);
+
+            // deserialize the Object
+            ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+            ObjectInputStream si = new ObjectInputStream(bis);
+            return si.readObject();
+        } catch (IOException ioe) {
+            return null;
+        } catch (ClassNotFoundException cnfe) {
+            return null;
+        }
+    }
+
+    /**
+     * Verifies that serialization preserves equals and hashCode.
+     * Serializes the object, then recovers it and checks equals and hash code.
+     *
+     * @param object  the object to serialize and recover
+     */
+    public static void checkSerializedEquality(Object object) {
+        Object object2 = serializeAndRecover(object);
+        Assert.assertEquals("Equals check", object, object2);
+        Assert.assertEquals("HashCode check", object.hashCode(), object2.hashCode());
+    }
+
+    /**
+     * Verifies that the relative error in actual vs. expected is less than or
+     * equal to relativeError.  If expected is infinite or NaN, actual must be
+     * the same (NaN or infinity of the same sign).
+     *
+     * @param expected expected value
+     * @param actual  observed value
+     * @param relativeError  maximum allowable relative error
+     */
+    public static void assertRelativelyEquals(double expected, double actual,
+            double relativeError) {
+        assertRelativelyEquals(null, expected, actual, relativeError);
+    }
+
+    /**
+     * Verifies that the relative error in actual vs. expected is less than or
+     * equal to relativeError.  If expected is infinite or NaN, actual must be
+     * the same (NaN or infinity of the same sign).
+     *
+     * @param msg  message to return with failure
+     * @param expected expected value
+     * @param actual  observed value
+     * @param relativeError  maximum allowable relative error
+     */
+    public static void assertRelativelyEquals(String msg, double expected,
+            double actual, double relativeError) {
+        if (Double.isNaN(expected)) {
+            Assert.assertTrue(msg, Double.isNaN(actual));
+        } else if (Double.isNaN(actual)) {
+            Assert.assertTrue(msg, Double.isNaN(expected));
+        } else if (Double.isInfinite(actual) || Double.isInfinite(expected)) {
+            Assert.assertEquals(expected, actual, relativeError);
+        } else if (expected == 0.0) {
+            Assert.assertEquals(msg, actual, expected, relativeError);
+        } else {
+            double absError = Math.abs(expected) * relativeError;
+            Assert.assertEquals(msg, expected, actual, absError);
+        }
+    }
+
+    /**
+     * Fails iff values does not contain a number within epsilon of z.
+     *
+     * @param msg  message to return with failure
+     * @param values complex array to search
+     * @param z  value sought
+     * @param epsilon  tolerance
+     */
+    public static void assertContains(String msg, Complex[] values,
+                                      Complex z, double epsilon) {
+        for (Complex value : values) {
+            if (Precision.equals(value.getReal(), z.getReal(), epsilon) &&
+                Precision.equals(value.getImaginary(), z.getImaginary(), epsilon)) {
+                return;
+            }
+        }
+        Assert.fail(msg + " Unable to find " + z);
+    }
+
+    /**
+     * Fails iff values does not contain a number within epsilon of z.
+     *
+     * @param values complex array to search
+     * @param z  value sought
+     * @param epsilon  tolerance
+     */
+    public static void assertContains(Complex[] values,
+            Complex z, double epsilon) {
+        assertContains(null, values, z, epsilon);
+    }
+
+    /**
+     * Fails iff values does not contain a number within epsilon of x.
+     *
+     * @param msg  message to return with failure
+     * @param values double array to search
+     * @param x value sought
+     * @param epsilon  tolerance
+     */
+    public static void assertContains(String msg, double[] values,
+            double x, double epsilon) {
+        for (double value : values) {
+            if (Precision.equals(value, x, epsilon)) {
+                return;
+            }
+        }
+        Assert.fail(msg + " Unable to find " + x);
+    }
+
+    /**
+     * Fails iff values does not contain a number within epsilon of x.
+     *
+     * @param values double array to search
+     * @param x value sought
+     * @param epsilon  tolerance
+     */
+    public static void assertContains(double[] values, double x,
+            double epsilon) {
+       assertContains(null, values, x, epsilon);
+    }
+
+    /** verifies that two arrays are close (sup norm) */
+    public static void assertEquals(String msg, double[] expected, double[] observed, double tolerance) {
+        StringBuilder out = new StringBuilder(msg);
+        if (expected.length != observed.length) {
+            out.append("\n Arrays not same length. \n");
+            out.append("expected has length ");
+            out.append(expected.length);
+            out.append(" observed length = ");
+            out.append(observed.length);
+            Assert.fail(out.toString());
+        }
+        boolean failure = false;
+        for (int i=0; i < expected.length; i++) {
+            if (!equalsIncludingNaN(expected[i], observed[i], tolerance)) {
+                failure = true;
+                out.append("\n Elements at index ");
+                out.append(i);
+                out.append(" differ. ");
+                out.append(" expected = ");
+                out.append(expected[i]);
+                out.append(" observed = ");
+                out.append(observed[i]);
+            }
+        }
+        if (failure) {
+            Assert.fail(out.toString());
+        }
+    }
+
+    /** verifies that two arrays are close (sup norm) */
+    public static void assertEquals(String msg, float[] expected, float[] observed, float tolerance) {
+        StringBuilder out = new StringBuilder(msg);
+        if (expected.length != observed.length) {
+            out.append("\n Arrays not same length. \n");
+            out.append("expected has length ");
+            out.append(expected.length);
+            out.append(" observed length = ");
+            out.append(observed.length);
+            Assert.fail(out.toString());
+        }
+        boolean failure = false;
+        for (int i=0; i < expected.length; i++) {
+            if (!equalsIncludingNaN(expected[i], observed[i], tolerance)) {
+                failure = true;
+                out.append("\n Elements at index ");
+                out.append(i);
+                out.append(" differ. ");
+                out.append(" expected = ");
+                out.append(expected[i]);
+                out.append(" observed = ");
+                out.append(observed[i]);
+            }
+        }
+        if (failure) {
+            Assert.fail(out.toString());
+        }
+    }
+
+    /** verifies that two arrays are close (sup norm) */
+    public static void assertEquals(String msg, Complex[] expected, Complex[] observed, double tolerance) {
+        StringBuilder out = new StringBuilder(msg);
+        if (expected.length != observed.length) {
+            out.append("\n Arrays not same length. \n");
+            out.append("expected has length ");
+            out.append(expected.length);
+            out.append(" observed length = ");
+            out.append(observed.length);
+            Assert.fail(out.toString());
+        }
+        boolean failure = false;
+        for (int i=0; i < expected.length; i++) {
+            if (!equalsIncludingNaN(expected[i].getReal(), observed[i].getReal(), tolerance)) {
+                failure = true;
+                out.append("\n Real elements at index ");
+                out.append(i);
+                out.append(" differ. ");
+                out.append(" expected = ");
+                out.append(expected[i].getReal());
+                out.append(" observed = ");
+                out.append(observed[i].getReal());
+            }
+            if (!equalsIncludingNaN(expected[i].getImaginary(), observed[i].getImaginary(), tolerance)) {
+                failure = true;
+                out.append("\n Imaginary elements at index ");
+                out.append(i);
+                out.append(" differ. ");
+                out.append(" expected = ");
+                out.append(expected[i].getImaginary());
+                out.append(" observed = ");
+                out.append(observed[i].getImaginary());
+            }
+        }
+        if (failure) {
+            Assert.fail(out.toString());
+        }
+    }
+
+    /**
+     * Updates observed counts of values in quartiles.
+     * counts[0] <-> 1st quartile ... counts[3] <-> top quartile
+     */
+    public static void updateCounts(double value, long[] counts, double[] quartiles) {
+        if (value < quartiles[0]) {
+            counts[0]++;
+        } else if (value > quartiles[2]) {
+            counts[3]++;
+        } else if (value > quartiles[1]) {
+            counts[2]++;
+        } else {
+            counts[1]++;
+        }
+    }
+
+    /**
+     * Eliminates points with zero mass from densityPoints and densityValues parallel
+     * arrays.  Returns the number of positive mass points and collapses the arrays so
+     * that the first <returned value> elements of the input arrays represent the positive
+     * mass points.
+     */
+    public static int eliminateZeroMassPoints(int[] densityPoints, double[] densityValues) {
+        int positiveMassCount = 0;
+        for (int i = 0; i < densityValues.length; i++) {
+            if (densityValues[i] > 0) {
+                positiveMassCount++;
+            }
+        }
+        if (positiveMassCount < densityValues.length) {
+            int[] newPoints = new int[positiveMassCount];
+            double[] newValues = new double[positiveMassCount];
+            int j = 0;
+            for (int i = 0; i < densityValues.length; i++) {
+                if (densityValues[i] > 0) {
+                    newPoints[j] = densityPoints[i];
+                    newValues[j] = densityValues[i];
+                    j++;
+                }
+            }
+            System.arraycopy(newPoints,0,densityPoints,0,positiveMassCount);
+            System.arraycopy(newValues,0,densityValues,0,positiveMassCount);
+        }
+        return positiveMassCount;
+    }
+
+    /**
+     * Returns true if the arguments are both NaN, are equal or are within the range
+     * of allowed error (inclusive).
+     *
+     * @param x first value
+     * @param y second value
+     * @param eps the amount of absolute error to allow.
+     * @return {@code true} if the values are equal or within range of each other,
+     * or both are NaN.
+     * @since 2.2
+     */
+    private static boolean equalsIncludingNaN(double x, double y, double eps) {
+        return equalsIncludingNaN(x, y) || (Math.abs(y - x) <= eps);
+    }
+
+    /**
+     * Returns true if the arguments are both NaN or they are
+     * equal as defined by {@link #equals(double,double) equals(x, y, 1)}.
+     *
+     * @param x first value
+     * @param y second value
+     * @return {@code true} if the values are equal or both are NaN.
+     * @since 2.2
+     */
+    private static boolean equalsIncludingNaN(double x, double y) {
+        return (x != x || y != y) ? !(x != x ^ y != y) : Precision.equals(x, y, 1);
+    }
+
+
+}
+
+


[2/4] commons-numbers git commit: NUMBERS-54: Create module "commons-numbers-complex-streams".

Posted by er...@apache.org.
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
deleted file mode 100644
index 4684cea..0000000
--- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/ComplexUtils.java
+++ /dev/null
@@ -1,1740 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.numbers.complex;
-
-/**
- * Static implementations of common {@link Complex} utilities functions.
- */
-public class ComplexUtils {
-
-    /**
-     * Utility class.
-     */
-    private ComplexUtils() {}
-
-    /**
-     * Creates a complex number from the given polar representation.
-     * <p>
-     * If either {@code r} or {@code theta} is NaN, or {@code theta} is
-     * infinite, {@link Complex#NAN} is returned.
-     * <p>
-     * If {@code r} is infinite and {@code theta} is finite, infinite or NaN
-     * values may be returned in parts of the result, following the rules for
-     * double arithmetic.
-     *
-     * <pre>
-     * Examples:
-     * {@code
-     * polar2Complex(INFINITY, \(\pi\)) = INFINITY + INFINITY i
-     * polar2Complex(INFINITY, 0) = INFINITY + NaN i
-     * polar2Complex(INFINITY, \(-\frac{\pi}{4}\)) = INFINITY - INFINITY i
-     * polar2Complex(INFINITY, \(5\frac{\pi}{4}\)) = -INFINITY - INFINITY i }
-     * </pre>
-     *
-     * @param r the modulus of the complex number to create
-     * @param theta the argument of the complex number to create
-     * @return {@code Complex}
-     * @since 1.1
-     */
-    public static Complex polar2Complex(double r, double theta) {
-        if (r < 0) {
-            throw new NegativeModulusException(r);
-        }
-        return Complex.ofCartesian(r * Math.cos(theta), r * Math.sin(theta));
-    }
-
-    /**
-     * Creates {@code Complex[]} array given {@code double[]} arrays of r and
-     * theta.
-     *
-     * @param r {@code double[]} of moduli
-     * @param theta {@code double[]} of arguments
-     * @return {@code Complex[]}
-     * @since 1.0
-     */
-    public static Complex[] polar2Complex(double[] r, double[] theta) {
-        final int length = r.length;
-        final Complex[] c = new Complex[length];
-        for (int x = 0; x < length; x++) {
-            if (r[x] < 0) {
-                throw new NegativeModulusException(r[x]);
-            }
-            c[x] = Complex.ofCartesian(r[x] * Math.cos(theta[x]), r[x] * Math.sin(theta[x]));
-        }
-        return c;
-    }
-
-    /**
-     * Creates {@code Complex[][]} array given {@code double[][]} arrays of r
-     * and theta.
-     *
-     * @param r {@code double[]} of moduli
-     * @param theta {@code double[]} of arguments
-     * @return {@code Complex[][]}
-     * @since 1.0
-     */
-    public static Complex[][] polar2Complex(double[][] r, double[][] theta) {
-        final int length = r.length;
-        final Complex[][] c = new Complex[length][];
-        for (int x = 0; x < length; x++) {
-            c[x] = polar2Complex(r[x], theta[x]);
-        }
-        return c;
-    }
-
-    /**
-     * Creates {@code Complex[][][]} array given {@code double[][][]} arrays of
-     * r and theta.
-     *
-     * @param r array of moduli
-     * @param theta array of arguments
-     * @return {@code Complex}
-     * @since 1.0
-     */
-    public static Complex[][][] polar2Complex(double[][][] r, double[][][] theta) {
-        final int length = r.length;
-        final Complex[][][] c = new Complex[length][][];
-        for (int x = 0; x < length; x++) {
-            c[x] = polar2Complex(r[x], theta[x]);
-        }
-        return c;
-    }
-
-    /**
-     * Returns double from array {@code real[]} at entry {@code index} as a
-     * {@code Complex}.
-     *
-     * @param real array of real numbers
-     * @param index location in the array
-     * @return {@code Complex}.
-     *
-     * @since 1.0
-     */
-    public static Complex extractComplexFromRealArray(double[] real, int index) {
-        return Complex.ofReal(real[index]);
-    }
-
-    /**
-     * Returns float from array {@code real[]} at entry {@code index} as a
-     * {@code Complex}.
-     *
-     * @param real array of real numbers
-     * @param index location in the array
-     * @return {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex extractComplexFromRealArray(float[] real, int index) {
-        return Complex.ofReal(real[index]);
-    }
-
-    /**
-     * Returns double from array {@code imaginary[]} at entry {@code index} as a
-     * {@code Complex}.
-     *
-     * @param imaginary array of imaginary numbers
-     * @param index location in the array
-     * @return {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex extractComplexFromImaginaryArray(double[] imaginary, int index) {
-        return Complex.ofCartesian(0, imaginary[index]);
-    }
-
-    /**
-     * Returns float from array {@code imaginary[]} at entry {@code index} as a
-     * {@code Complex}.
-     *
-     * @param imaginary array of imaginary numbers
-     * @param index location in the array
-     * @return {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex extractComplexFromImaginaryArray(float[] imaginary, int index) {
-        return Complex.ofCartesian(0, imaginary[index]);
-    }
-
-    /**
-     * Returns real component of Complex from array {@code Complex[]} at entry
-     * {@code index} as a {@code double}.
-     *
-     * @param complex array of complex numbers
-     * @param index location in the array
-     * @return {@code double}.
-     *
-     * @since 1.0
-     */
-    public static double extractRealFromComplexArray(Complex[] complex, int index) {
-        return complex[index].getReal();
-    }
-
-    /**
-     * Returns real component of array {@code Complex[]} at entry {@code index}
-     * as a {@code float}.
-     *
-     * @param complex array of complex numbers
-     * @param index location in the array
-     * @return {@code float}.
-     *
-     * @since 1.0
-     */
-    public static float extractRealFloatFromComplexArray(Complex[] complex, int index) {
-        return (float) complex[index].getReal();
-    }
-
-    /**
-     * Returns imaginary component of Complex from array {@code Complex[]} at
-     * entry {@code index} as a {@code double}.
-     *
-     * @param complex array of complex numbers
-     * @param index location in the array
-     * @return {@code double}.
-     *
-     * @since 1.0
-     */
-    public static double extractImaginaryFromComplexArray(Complex[] complex, int index) {
-        return complex[index].getImaginary();
-    }
-
-    /**
-     * Returns imaginary component of array {@code Complex[]} at entry
-     * {@code index} as a {@code float}.
-     *
-     * @param complex array of complex numbers
-     * @param index location in the array
-     * @return {@code float}.
-     *
-     * @since 1.0
-     */
-    public static float extractImaginaryFloatFromComplexArray(Complex[] complex, int index) {
-        return (float) complex[index].getImaginary();
-    }
-
-    /**
-     * Returns a Complex object from interleaved {@code double[]} array at entry
-     * {@code index}.
-     *
-     * @param d array of interleaved complex numbers alternating real and imaginary values
-     * @param index location in the array This is the location by complex number, e.g. index number 5 in the array will return {@code Complex.ofCartesian(d[10], d[11])}
-     * @return {@code Complex}.
-     *
-     * @since 1.0
-     */
-    public static Complex extractComplexFromInterleavedArray(double[] d, int index) {
-        return Complex.ofCartesian(d[index * 2], d[index * 2 + 1]);
-    }
-
-    /**
-     * Returns a Complex object from interleaved {@code float[]} array at entry
-     * {@code index}.
-     *
-     * @param f float array of interleaved complex numbers alternating real and imaginary values
-     * @param index location in the array This is the location by complex number, e.g. index number 5 in the {@code float[]} array will return new {@code Complex(d[10], d[11])}
-     * @return {@code Complex}.
-     *
-     * @since 1.0
-     */
-    public static Complex extractComplexFromInterleavedArray(float[] f, int index) {
-        return Complex.ofCartesian(f[index * 2], f[index * 2 + 1]);
-    }
-
-    /**
-     * Returns values of Complex object from array {@code Complex[]} at entry
-     * {@code index} as a size 2 {@code double} of the form {real, imag}.
-     *
-     * @param complex array of complex numbers
-     * @param index location in the array
-     * @return size 2 array.
-     *
-     * @since 1.0
-     */
-    public static double[] extractInterleavedFromComplexArray(Complex[] complex, int index) {
-        return new double[] { complex[index].getReal(), complex[index].getImaginary() };
-    }
-
-    /**
-     * Returns Complex object from array {@code Complex[]} at entry
-     * {@code index} as a size 2 {@code float} of the form {real, imag}.
-     *
-     * @param complex {@code Complex} array
-     * @param index location in the array
-     * @return size 2 {@code float[]}.
-     *
-     * @since 1.0
-     */
-    public static float[] extractInterleavedFloatFromComplexArray(Complex[] complex, int index) {
-        return new float[] { (float) complex[index].getReal(), (float) complex[index].getImaginary() };
-    }
-
-    /**
-     * Converts a {@code double[]} array to a {@code Complex[]} array.
-     *
-     * @param real array of numbers to be converted to their {@code Complex} equivalent
-     * @return {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[] real2Complex(double[] real) {
-        int index = 0;
-        final Complex c[] = new Complex[real.length];
-        for (double d : real) {
-            c[index] = Complex.ofReal(d);
-            index++;
-        }
-        return c;
-    }
-
-    /**
-     * Converts a {@code float[]} array to a {@code Complex[]} array.
-     *
-     * @param real array of numbers to be converted to their {@code Complex} equivalent
-     * @return {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[] real2Complex(float[] real) {
-        int index = 0;
-        final Complex c[] = new Complex[real.length];
-        for (float d : real) {
-            c[index] = Complex.ofReal(d);
-            index++;
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 2D real {@code double[][]} array to a 2D {@code Complex[][]}
-     * array.
-     *
-     * @param d 2D array
-     * @return 2D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][] real2Complex(double[][] d) {
-        final int w = d.length;
-        final Complex[][] c = new Complex[w][];
-        for (int n = 0; n < w; n++) {
-            c[n] = ComplexUtils.real2Complex(d[n]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 2D real {@code float[][]} array to a 2D {@code Complex[][]}
-     * array.
-     *
-     * @param d 2D array
-     * @return 2D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][] real2Complex(float[][] d) {
-        final int w = d.length;
-        final Complex[][] c = new Complex[w][];
-        for (int n = 0; n < w; n++) {
-            c[n] = ComplexUtils.real2Complex(d[n]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 3D real {@code double[][][]} array to a {@code Complex [][][]}
-     * array.
-     *
-     * @param d 3D complex interleaved array
-     * @return 3D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][] real2Complex(double[][][] d) {
-        final int w = d.length;
-        final Complex[][][] c = new Complex[w][][];
-        for (int x = 0; x < w; x++) {
-            c[x] = ComplexUtils.real2Complex(d[x]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 3D real {@code float[][][]} array to a {@code Complex [][][]}
-     * array.
-     *
-     * @param d 3D complex interleaved array
-     * @return 3D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][] real2Complex(float[][][] d) {
-        final int w = d.length;
-        final Complex[][][] c = new Complex[w][][];
-        for (int x = 0; x < w; x++) {
-            c[x] = ComplexUtils.real2Complex(d[x]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 4D real {@code double[][][][]} array to a {@code Complex [][][][]}
-     * array.
-     *
-     * @param d 4D complex interleaved array
-     * @return 4D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][][] real2Complex(double[][][][] d) {
-        final int w = d.length;
-        final Complex[][][][] c = new Complex[w][][][];
-        for (int x = 0; x < w; x++) {
-            c[x] = ComplexUtils.real2Complex(d[x]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts real component of {@code Complex[]} array to a {@code double[]}
-     * array.
-     *
-     * @param c {@code Complex} array
-     * @return array of the real component
-     *
-     * @since 1.0
-     */
-    public static double[] complex2Real(Complex[] c) {
-        int index = 0;
-        final double d[] = new double[c.length];
-        for (Complex cc : c) {
-            d[index] = cc.getReal();
-            index++;
-        }
-        return d;
-    }
-
-    /**
-     * Converts real component of {@code Complex[]} array to a {@code float[]}
-     * array.
-     *
-     * @param c {@code Complex} array
-     * @return {@code float[]} array of the real component
-     *
-     * @since 1.0
-     */
-    public static float[] complex2RealFloat(Complex[] c) {
-        int index = 0;
-        final float f[] = new float[c.length];
-        for (Complex cc : c) {
-            f[index] = (float) cc.getReal();
-            index++;
-        }
-        return f;
-    }
-
-    /**
-     * Converts real component of a 2D {@code Complex[][]} array to a 2D
-     * {@code double[][]} array.
-     *
-     * @param c 2D {@code Complex} array
-     * @return {@code double[][]} of real component
-     * @since 1.0
-     */
-    public static double[][] complex2Real(Complex[][] c) {
-        final int length = c.length;
-        double[][] d = new double[length][];
-        for (int n = 0; n < length; n++) {
-            d[n] = complex2Real(c[n]);
-        }
-        return d;
-    }
-
-    /**
-     * Converts real component of a 2D {@code Complex[][]} array to a 2D
-     * {@code float[][]} array.
-     *
-     * @param c 2D {@code Complex} array
-     * @return {@code float[][]} of real component
-     * @since 1.0
-     */
-    public static float[][] complex2RealFloat(Complex[][] c) {
-        final int length = c.length;
-        float[][] f = new float[length][];
-        for (int n = 0; n < length; n++) {
-            f[n] = complex2RealFloat(c[n]);
-        }
-        return f;
-    }
-
-    /**
-     * Converts real component of a 3D {@code Complex[][][]} array to a 3D
-     * {@code double[][][]} array.
-     *
-     * @param c 3D complex interleaved array
-     * @return array of real component
-     *
-     * @since 1.0
-     */
-    public static double[][][] complex2Real(Complex[][][] c) {
-        final int length = c.length;
-        double[][][] d = new double[length][][];
-        for (int n = 0; n < length; n++) {
-            d[n] = complex2Real(c[n]);
-        }
-        return d;
-    }
-
-    /**
-     * Converts real component of a 3D {@code Complex[][][]} array to a 3D
-     * {@code float[][][]} array.
-     *
-     * @param c 3D {@code Complex} array
-     * @return {@code float[][][]} of real component
-     * @since 1.0
-     */
-    public static float[][][] complex2RealFloat(Complex[][][] c) {
-        final int length = c.length;
-        float[][][] f = new float[length][][];
-        for (int n = 0; n < length; n++) {
-            f[n] = complex2RealFloat(c[n]);
-        }
-        return f;
-    }
-
-    /**
-     * Converts real component of a 4D {@code Complex[][][][]} array to a 4D
-     * {@code double[][][][]} array.
-     *
-     * @param c 4D complex interleaved array
-     * @return array of real component
-     *
-     * @since 1.0
-     */
-    public static double[][][][] complex2Real(Complex[][][][] c) {
-        final int length = c.length;
-        double[][][][] d = new double[length][][][];
-        for (int n = 0; n < length; n++) {
-            d[n] = complex2Real(c[n]);
-        }
-        return d;
-    }
-
-    /**
-     * Converts real component of a 4D {@code Complex[][][][]} array to a 4D
-     * {@code float[][][][]} array.
-     *
-     * @param c 4D {@code Complex} array
-     * @return {@code float[][][][]} of real component
-     * @since 1.0
-     */
-    public static float[][][][] complex2RealFloat(Complex[][][][] c) {
-        final int length = c.length;
-        float[][][][] f = new float[length][][][];
-        for (int n = 0; n < length; n++) {
-            f[n] = complex2RealFloat(c[n]);
-        }
-        return f;
-    }
-
-    /**
-     * Converts a {@code double[]} array to an imaginary {@code Complex[]}
-     * array.
-     *
-     * @param imaginary array of numbers to be converted to their {@code Complex} equivalent
-     * @return {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[] imaginary2Complex(double[] imaginary) {
-        int index = 0;
-        final Complex c[] = new Complex[imaginary.length];
-        for (double d : imaginary) {
-            c[index] = Complex.ofCartesian(0, d);
-            index++;
-        }
-        return c;
-    }
-
-    /**
-     * Converts a {@code float[]} array to an imaginary {@code Complex[]} array.
-     *
-     * @param imaginary array of numbers to be converted to their {@code Complex} equivalent
-     * @return {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[] imaginary2Complex(float[] imaginary) {
-        int index = 0;
-        final Complex c[] = new Complex[imaginary.length];
-        for (float d : imaginary) {
-            c[index] = Complex.ofCartesian(0, d);
-            index++;
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 2D imaginary array {@code double[][]} to a 2D
-     * {@code Complex[][]} array.
-     *
-     * @param i 2D array
-     * @return 2D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][] imaginary2Complex(double[][] i) {
-        int w = i.length;
-        Complex[][] c = new Complex[w][];
-        for (int n = 0; n < w; n++) {
-            c[n] = ComplexUtils.imaginary2Complex(i[n]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 3D imaginary array {@code double[][][]} to a {@code Complex[]}
-     * array.
-     *
-     * @param i 3D complex imaginary array
-     * @return 3D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][] imaginary2Complex(double[][][] i) {
-        int w = i.length;
-        Complex[][][] c = new Complex[w][][];
-        for (int n = 0; n < w; n++) {
-            c[n] = ComplexUtils.imaginary2Complex(i[n]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 4D imaginary array {@code double[][][][]} to a 4D {@code Complex[][][][]}
-     * array.
-     *
-     * @param i 4D complex imaginary array
-     * @return 4D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][][] imaginary2Complex(double[][][][] i) {
-        int w = i.length;
-        Complex[][][][] c = new Complex[w][][][];
-        for (int n = 0; n < w; n++) {
-            c[n] = ComplexUtils.imaginary2Complex(i[n]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts imaginary part of a {@code Complex[]} array to a
-     * {@code double[]} array.
-     *
-     * @param c {@code Complex} array.
-     * @return array of the imaginary component
-     *
-     * @since 1.0
-     */
-    public static double[] complex2Imaginary(Complex[] c) {
-        int index = 0;
-        final double i[] = new double[c.length];
-        for (Complex cc : c) {
-            i[index] = cc.getImaginary();
-            index++;
-        }
-        return i;
-    }
-
-    /**
-     * Converts imaginary component of a {@code Complex[]} array to a
-     * {@code float[]} array.
-     *
-     * @param c {@code Complex} array.
-     * @return {@code float[]} array of the imaginary component
-     *
-     * @since 1.0
-     */
-    public static float[] complex2ImaginaryFloat(Complex[] c) {
-        int index = 0;
-        final float f[] = new float[c.length];
-        for (Complex cc : c) {
-            f[index] = (float) cc.getImaginary();
-            index++;
-        }
-        return f;
-    }
-
-    /**
-     * Converts imaginary component of a 2D {@code Complex[][]} array to a 2D
-     * {@code double[][]} array.
-     *
-     * @param c 2D {@code Complex} array
-     * @return {@code double[][]} of imaginary component
-     * @since 1.0
-     */
-    public static double[][] complex2Imaginary(Complex[][] c) {
-        final int length = c.length;
-        double[][] i = new double[length][];
-        for (int n = 0; n < length; n++) {
-            i[n] = complex2Imaginary(c[n]);
-        }
-        return i;
-    }
-
-    /**
-     * Converts imaginary component of a 2D {@code Complex[][]} array to a 2D
-     * {@code float[][]} array.
-     *
-     * @param c 2D {@code Complex} array
-     * @return {@code float[][]} of imaginary component
-     * @since 1.0
-     */
-    public static float[][] complex2ImaginaryFloat(Complex[][] c) {
-        final int length = c.length;
-        float[][] f = new float[length][];
-        for (int n = 0; n < length; n++) {
-            f[n] = complex2ImaginaryFloat(c[n]);
-        }
-        return f;
-    }
-
-    /**
-     * Converts imaginary component of a 3D {@code Complex[][][]} array to a 3D
-     * {@code double[][][]} array.
-     *
-     * @param c 3D complex interleaved array
-     * @return 3D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static double[][][] complex2Imaginary(Complex[][][] c) {
-        final int length = c.length;
-        double[][][] i = new double[length][][];
-        for (int n = 0; n < length; n++) {
-            i[n] = complex2Imaginary(c[n]);
-        }
-        return i;
-    }
-
-    /**
-     * Converts imaginary component of a 3D {@code Complex[][][]} array to a 3D
-     * {@code float[][][]} array.
-     *
-     * @param c 3D {@code Complex} array
-     * @return {@code float[][][]} of imaginary component
-     * @since 1.0
-     */
-    public static float[][][] complex2ImaginaryFloat(Complex[][][] c) {
-        final int length = c.length;
-        float[][][] f = new float[length][][];
-        for (int n = 0; n < length; n++) {
-            f[n] = complex2ImaginaryFloat(c[n]);
-        }
-        return f;
-    }
-
-    /**
-     * Converts imaginary component of a 4D {@code Complex[][][][]} array to a 4D
-     * {@code double[][][][]} array.
-     *
-     * @param c 4D complex interleaved array
-     * @return 4D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static double[][][][] complex2Imaginary(Complex[][][][] c) {
-        final int length = c.length;
-        double[][][][] i = new double[length][][][];
-        for (int n = 0; n < length; n++) {
-            i[n] = complex2Imaginary(c[n]);
-        }
-        return i;
-    }
-
-    /**
-     * Converts imaginary component of a 4D {@code Complex[][][][]} array to a 4D
-     * {@code float[][][][]} array.
-     *
-     * @param c 4D {@code Complex} array
-     * @return {@code float[][][][]} of imaginary component
-     * @since 1.0
-     */
-    public static float[][][][] complex2ImaginaryFloat(Complex[][][][] c) {
-        final int length = c.length;
-        float[][][][] f = new float[length][][][];
-        for (int n = 0; n < length; n++) {
-            f[n] = complex2ImaginaryFloat(c[n]);
-        }
-        return f;
-    }
-
-    // INTERLEAVED METHODS
-
-    /**
-     * Converts a complex interleaved {@code double[]} array to a
-     * {@code Complex[]} array
-     *
-     * @param interleaved array of numbers to be converted to their {@code Complex} equivalent
-     * @return {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[] interleaved2Complex(double[] interleaved) {
-        final int length = interleaved.length / 2;
-        final Complex c[] = new Complex[length];
-        for (int n = 0; n < length; n++) {
-            c[n] = Complex.ofCartesian(interleaved[n * 2], interleaved[n * 2 + 1]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a complex interleaved {@code float[]} array to a
-     * {@code Complex[]} array
-     *
-     * @param interleaved float[] array of numbers to be converted to their {@code Complex} equivalent
-     * @return {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[] interleaved2Complex(float[] interleaved) {
-        final int length = interleaved.length / 2;
-        final Complex c[] = new Complex[length];
-        for (int n = 0; n < length; n++) {
-            c[n] = Complex.ofCartesian(interleaved[n * 2], interleaved[n * 2 + 1]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a {@code Complex[]} array to an interleaved complex
-     * {@code double[]} array
-     *
-     * @param c Complex array
-     * @return complex interleaved array alternating real and
-     *         imaginary values
-     *
-     * @since 1.0
-     */
-    public static double[] complex2Interleaved(Complex[] c) {
-        int index = 0;
-        final double i[] = new double[c.length * 2];
-        for (Complex cc : c) {
-            int real = index * 2;
-            int imag = index * 2 + 1;
-            i[real] = cc.getReal();
-            i[imag] = cc.getImaginary();
-            index++;
-        }
-        return i;
-    }
-
-    /**
-     * Converts a {@code Complex[]} array to an interleaved complex
-     * {@code float[]} array
-     *
-     * @param c Complex array
-     * @return complex interleaved {@code float[]} alternating real and
-     *         imaginary values
-     *
-     * @since 1.0
-     */
-    public static float[] complex2InterleavedFloat(Complex[] c) {
-        int index = 0;
-        final float f[] = new float[c.length * 2];
-        for (Complex cc : c) {
-            int real = index * 2;
-            int imag = index * 2 + 1;
-            f[real] = (float) cc.getReal();
-            f[imag] = (float) cc.getImaginary();
-            index++;
-        }
-        return f;
-    }
-
-    /**
-     * Converts a 2D {@code Complex[][]} array to an interleaved complex
-     * {@code double[][]} array.
-     *
-     * @param c 2D Complex array
-     * @param interleavedDim Depth level of the array to interleave
-     * @return complex interleaved array alternating real and
-     *         imaginary values
-     *
-     * @since 1.0
-     */
-    public static double[][] complex2Interleaved(Complex[][] c, int interleavedDim) {
-        if (interleavedDim > 1 || interleavedDim < 0) {
-            throw new IndexOutOfRangeException(interleavedDim);
-        }
-        final int w = c.length;
-        final int h = c[0].length;
-        double[][] i;
-        if (interleavedDim == 0) {
-            i = new double[2 * w][h];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    i[x * 2][y] = c[x][y].getReal();
-                    i[x * 2 + 1][y] = c[x][y].getImaginary();
-                }
-            }
-        } else {
-            i = new double[w][2 * h];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    i[x][y * 2] = c[x][y].getReal();
-                    i[x][y * 2 + 1] = c[x][y].getImaginary();
-                }
-            }
-        }
-        return i;
-    }
-
-    /**
-     * Converts a 2D {@code Complex[][]} array to an interleaved complex
-     * {@code double[][]} array. The second d level of the array is assumed
-     * to be interleaved.
-     *
-     * @param c 2D Complex array
-     * @return complex interleaved array alternating real and
-     *         imaginary values
-     *
-     * @since 1.0
-     */
-    public static double[][] complex2Interleaved(Complex[][] c) {
-        return complex2Interleaved(c, 1);
-    }
-
-    /**
-     * Converts a 3D {@code Complex[][][]} array to an interleaved complex
-     * {@code double[][][]} array.
-     *
-     * @param c 3D Complex array
-     * @param interleavedDim Depth level of the array to interleave
-     * @return complex interleaved array alternating real and
-     *         imaginary values
-     *
-     * @since 1.0
-     */
-    public static double[][][] complex2Interleaved(Complex[][][] c, int interleavedDim) {
-        if (interleavedDim > 2 || interleavedDim < 0) {
-            throw new IndexOutOfRangeException(interleavedDim);
-        }
-        int w = c.length;
-        int h = c[0].length;
-        int d = c[0][0].length;
-        double[][][] i;
-        if (interleavedDim == 0) {
-            i = new double[2 * w][h][d];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        i[x * 2][y][z] = c[x][y][z].getReal();
-                        i[x * 2 + 1][y][z] = c[x][y][z].getImaginary();
-                    }
-                }
-            }
-        } else if (interleavedDim == 1) {
-            i = new double[w][2 * h][d];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        i[x][y * 2][z] = c[x][y][z].getReal();
-                        i[x][y * 2 + 1][z] = c[x][y][z].getImaginary();
-                    }
-                }
-            }
-        } else {
-            i = new double[w][h][2 * d];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        i[x][y][z * 2] = c[x][y][z].getReal();
-                        i[x][y][z * 2 + 1] = c[x][y][z].getImaginary();
-                    }
-                }
-            }
-        }
-        return i;
-    }
-
-    /**
-     * Converts a 4D {@code Complex[][][][]} array to an interleaved complex
-     * {@code double[][][][]} array.
-     *
-     * @param c 4D Complex array
-     * @param interleavedDim Depth level of the array to interleave
-     * @return complex interleaved array alternating real and
-     *         imaginary values
-     *
-     * @since 1.0
-     */
-    public static double[][][][] complex2Interleaved(Complex[][][][] c, int interleavedDim) {
-        if (interleavedDim > 3 || interleavedDim < 0) {
-            throw new IndexOutOfRangeException(interleavedDim);
-        }
-        int w = c.length;
-        int h = c[0].length;
-        int d = c[0][0].length;
-        int v = c[0][0][0].length;
-        double[][][][] i;
-        if (interleavedDim == 0) {
-            i = new double[2 * w][h][d][v];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        for (int t = 0; t > v; t++) {
-                            i[x * 2][y][z][t] = c[x][y][z][t].getReal();
-                            i[x * 2 + 1][y][z][t] = c[x][y][z][t].getImaginary();
-                        }
-                    }
-                }
-            }
-        } else if (interleavedDim == 1) {
-            i = new double[w][2 * h][d][v];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        for (int t = 0; t > v; t++) {
-                            i[x][y * 2][z][t] = c[x][y][z][t].getReal();
-                            i[x][y * 2 + 1][z][t] = c[x][y][z][t].getImaginary();
-                        }
-                    }
-                }
-            }
-        } else if (interleavedDim == 2) {
-            i = new double[w][h][2 * d][v];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        for (int t = 0; t > v; t++) {
-                        i[x][y][z * 2][t] = c[x][y][z][t].getReal();
-                        i[x][y][z * 2 + 1][t] = c[x][y][z][t].getImaginary();
-                        }
-                    }
-                }
-            }
-        } else {
-            i = new double[w][h][d][2 * v];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        for (int t = 0; t > v; t++) {
-                        i[x][y][z][t * 2] = c[x][y][z][t].getReal();
-                        i[x][y][z][t * 2 + 1] = c[x][y][z][t].getImaginary();
-                        }
-                    }
-                }
-            }
-        }
-        return i;
-    }
-
-    /**
-     * Converts a 3D {@code Complex[][][]} array to an interleaved complex
-     * {@code double[][][]} array. The third level of the array is
-     * interleaved.
-     *
-     * @param c 3D Complex array
-     * @return complex interleaved array alternating real and
-     *         imaginary values
-     *
-     * @since 1.0
-     */
-    public static double[][][] complex2Interleaved(Complex[][][] c) {
-        return complex2Interleaved(c, 2);
-    }
-
-    /**
-     * Converts a 4D {@code Complex[][][][]} array to an interleaved complex
-     * {@code double[][][][]} array. The fourth level of the array is
-     * interleaved.
-     *
-     * @param c 4D Complex array
-     * @return complex interleaved array alternating real and
-     *         imaginary values
-     *
-     * @since 1.0
-     */
-    public static double[][][][] complex2Interleaved(Complex[][][][] c) {
-        return complex2Interleaved(c, 3);
-    }
-
-    /**
-     * Converts a 2D {@code Complex[][]} array to an interleaved complex
-     * {@code float[][]} array.
-     *
-     * @param c 2D Complex array
-     * @param interleavedDim Depth level of the array to interleave
-     * @return complex interleaved {@code float[][]} alternating real and
-     *         imaginary values
-     *
-     * @since 1.0
-     */
-    public static float[][] complex2InterleavedFloat(Complex[][] c, int interleavedDim) {
-        if (interleavedDim > 1 || interleavedDim < 0) {
-            throw new IndexOutOfRangeException(interleavedDim);
-        }
-        final int w = c.length;
-        final int h = c[0].length;
-        float[][] i;
-        if (interleavedDim == 0) {
-            i = new float[2 * w][h];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    i[x * 2][y] = (float) c[x][y].getReal();
-                    i[x * 2 + 1][y] = (float) c[x][y].getImaginary();
-                }
-            }
-        } else {
-            i = new float[w][2 * h];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    i[x][y * 2] = (float) c[x][y].getReal();
-                    i[x][y * 2 + 1] = (float) c[x][y].getImaginary();
-                }
-            }
-        }
-        return i;
-    }
-
-    /**
-     * Converts a 2D {@code Complex[][]} array to an interleaved complex
-     * {@code float[][]} array. The second d level of the array is assumed
-     * to be interleaved.
-     *
-     * @param c 2D Complex array
-     *
-     * @return complex interleaved {@code float[][]} alternating real and
-     *         imaginary values
-     *
-     * @since 1.0
-     */
-    public static float[][] complex2InterleavedFloat(Complex[][] c) {
-        return complex2InterleavedFloat(c, 1);
-    }
-
-    /**
-     * Converts a 3D {@code Complex[][][]} array to an interleaved complex
-     * {@code float[][][]} array.
-     *
-     * @param c 3D Complex array
-     * @param interleavedDim Depth level of the array to interleave
-     * @return complex interleaved {@code float[][][]} alternating real and
-     *         imaginary values
-     *
-     * @since 1.0
-     */
-    public static float[][][] complex2InterleavedFloat(Complex[][][] c, int interleavedDim) {
-        if (interleavedDim > 2 || interleavedDim < 0) {
-            throw new IndexOutOfRangeException(interleavedDim);
-        }
-        final int w = c.length;
-        final int h = c[0].length;
-        final int d = c[0][0].length;
-        float[][][] i;
-        if (interleavedDim == 0) {
-            i = new float[2 * w][h][d];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        i[x * 2][y][z] = (float) c[x][y][z].getReal();
-                        i[x * 2 + 1][y][z] = (float) c[x][y][z].getImaginary();
-                    }
-                }
-            }
-        } else if (interleavedDim == 1) {
-            i = new float[w][2 * h][d];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        i[x][y * 2][z] = (float) c[x][y][z].getReal();
-                        i[x][y * 2 + 1][z] = (float) c[x][y][z].getImaginary();
-                    }
-                }
-            }
-        } else {
-            i = new float[w][h][2 * d];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        i[x][y][z * 2] = (float) c[x][y][z].getReal();
-                        i[x][y][z * 2 + 1] = (float) c[x][y][z].getImaginary();
-                    }
-                }
-            }
-        }
-        return i;
-    }
-
-    /**
-     * Converts a 3D {@code Complex[][][]} array to an interleaved complex
-     * {@code float[][][]} array. The third d level of the array is
-     * interleaved.
-     *
-     * @param c 2D Complex array
-     *
-     * @return complex interleaved {@code float[][][]} alternating real and
-     *         imaginary values
-     *
-     * @since 1.0
-     */
-    public static float[][][] complex2InterleavedFloat(Complex[][][] c) {
-        return complex2InterleavedFloat(c, 2);
-    }
-
-    /**
-     * Converts a 2D interleaved complex {@code double[][]} array to a
-     * {@code Complex[][]} array.
-     *
-     * @param i 2D complex interleaved array
-     * @param interleavedDim Depth level of the array to interleave
-     * @return 2D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][] interleaved2Complex(double[][] i, int interleavedDim) {
-        if (interleavedDim > 1 || interleavedDim < 0) {
-            throw new IndexOutOfRangeException(interleavedDim);
-        }
-        final int w = i.length;
-        final int h = i[0].length;
-        Complex[][] c;
-        if (interleavedDim == 0) {
-            c = new Complex[w / 2][h];
-            for (int x = 0; x < w / 2; x++) {
-                for (int y = 0; y < h; y++) {
-                    c[x][y] = Complex.ofCartesian(i[x * 2][y], i[x * 2 + 1][y]);
-                }
-            }
-        } else {
-            c = new Complex[w][h / 2];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h / 2; y++) {
-                    c[x][y] = Complex.ofCartesian(i[x][y * 2], i[x][y * 2 + 1]);
-                }
-            }
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 2D interleaved complex {@code double[][]} array to a
-     * {@code Complex[][]} array. The second d level of the array is assumed
-     * to be interleaved.
-     *
-     * @param d 2D complex interleaved array
-     * @return 2D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][] interleaved2Complex(double[][] d) {
-        return interleaved2Complex(d, 1);
-    }
-
-    /**
-     * Converts a 3D interleaved complex {@code double[][][]} array to a
-     * {@code Complex[][][]} array.
-     *
-     * @param i 3D complex interleaved array
-     * @param interleavedDim Depth level of the array to interleave
-     * @return 3D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][] interleaved2Complex(double[][][] i, int interleavedDim) {
-        if (interleavedDim > 2 || interleavedDim < 0) {
-            throw new IndexOutOfRangeException(interleavedDim);
-        }
-        final int w = i.length;
-        final int h = i[0].length;
-        final int d = i[0][0].length;
-        Complex[][][] c;
-        if (interleavedDim == 0) {
-            c = new Complex[w / 2][h][d];
-            for (int x = 0; x < w / 2; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        c[x][y][z] = Complex.ofCartesian(i[x * 2][y][z], i[x * 2 + 1][y][z]);
-                    }
-                }
-            }
-        } else if (interleavedDim == 1) {
-            c = new Complex[w][h / 2][d];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h / 2; y++) {
-                    for (int z = 0; z < d; z++) {
-                        c[x][y][z] = Complex.ofCartesian(i[x][y * 2][z], i[x][y * 2 + 1][z]);
-                    }
-                }
-            }
-        } else {
-            c = new Complex[w][h][d / 2];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d / 2; z++) {
-                        c[x][y][z] = Complex.ofCartesian(i[x][y][z * 2], i[x][y][z * 2 + 1]);
-                    }
-                }
-            }
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 4D interleaved complex {@code double[][][][]} array to a
-     * {@code Complex[][][][]} array.
-     *
-     * @param i 4D complex interleaved array
-     * @param interleavedDim Depth level of the array to interleave
-     * @return 4D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][][] interleaved2Complex(double[][][][] i, int interleavedDim) {
-        if (interleavedDim > 2 || interleavedDim < 0) {
-            throw new IndexOutOfRangeException(interleavedDim);
-        }
-        final int w = i.length;
-        final int h = i[0].length;
-        final int d = i[0][0].length;
-        final int v = i[0][0][0].length;
-        Complex[][][][] c;
-        if (interleavedDim == 0) {
-            c = new Complex[w / 2][h][d][v];
-            for (int x = 0; x < w / 2; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        for (int t = 0; t < v; t++) {
-                            c[x][y][z][t] = Complex.ofCartesian(i[x * 2][y][z][t], i[x * 2 + 1][y][z][t]);
-                        }
-                    }
-                }
-            }
-        } else if (interleavedDim == 1) {
-            c = new Complex[w][h / 2][d][v];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h / 2; y++) {
-                    for (int z = 0; z < d; z++) {
-                        for (int t = 0; t < v; t++) {
-                            c[x][y][z][t] = Complex.ofCartesian(i[x][y * 2][z][t], i[x][y * 2 + 1][z][t]);
-                        }
-                    }
-                }
-            }
-        } else if (interleavedDim == 2) {
-            c = new Complex[w][h][d / 2][v];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d / 2; z++) {
-                        for (int t = 0; t < v; t++) {
-                            c[x][y][z][t] = Complex.ofCartesian(i[x][y][z * 2][t], i[x][y][z * 2 + 1][t]);
-                        }
-                    }
-                }
-            }
-        } else {
-            c = new Complex[w][h][d][v / 2];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        for (int t = 0; t < v / 2; t++) {
-                            c[x][y][z][t] = Complex.ofCartesian(i[x][y][z][t * 2], i[x][y][z][t * 2 + 1]);
-                        }
-                    }
-                }
-            }
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 3D interleaved complex {@code double[][][]} array to a
-     * {@code Complex[][][]} array. The third d level is assumed to be
-     * interleaved.
-     *
-     * @param d 3D complex interleaved array
-     * @return 3D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][] interleaved2Complex(double[][][] d) {
-        return interleaved2Complex(d, 2);
-    }
-
-    /**
-     * Converts a 2D interleaved complex {@code float[][]} array to a
-     * {@code Complex[][]} array.
-     *
-     * @param i 2D complex interleaved float array
-     * @param interleavedDim Depth level of the array to interleave
-     * @return 2D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][] interleaved2Complex(float[][] i, int interleavedDim) {
-        if (interleavedDim > 1 || interleavedDim < 0) {
-            throw new IndexOutOfRangeException(interleavedDim);
-        }
-        final int w = i.length;
-        final int h = i[0].length;
-        Complex[][] c;
-        if (interleavedDim == 0) {
-            c = new Complex[w / 2][h];
-            for (int x = 0; x < w / 2; x++) {
-                for (int y = 0; y < h; y++) {
-                    c[x][y] = Complex.ofCartesian(i[x * 2][y], i[x * 2 + 1][y]);
-                }
-            }
-        } else {
-            c = new Complex[w][h / 2];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h / 2; y++) {
-                    c[x][y] = Complex.ofCartesian(i[x][y * 2], i[x][y * 2 + 1]);
-                }
-            }
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 2D interleaved complex {@code float[][]} array to a
-     * {@code Complex[][]} array. The second d level of the array is assumed
-     * to be interleaved.
-     *
-     * @param d 2D complex interleaved float array
-     * @return 2D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][] interleaved2Complex(float[][] d) {
-        return interleaved2Complex(d, 1);
-    }
-
-    /**
-     * Converts a 3D interleaved complex {@code float[][][]} array to a
-     * {@code Complex[][][]} array.
-     *
-     * @param i 3D complex interleaved float array
-     * @param interleavedDim Depth level of the array to interleave
-     * @return 3D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][] interleaved2Complex(float[][][] i, int interleavedDim) {
-        if (interleavedDim > 2 || interleavedDim < 0) {
-            throw new IndexOutOfRangeException(interleavedDim);
-        }
-        final int w = i.length;
-        final int h = i[0].length;
-        final int d = i[0][0].length;
-        Complex[][][] c;
-        if (interleavedDim == 0) {
-            c = new Complex[w / 2][h][d];
-            for (int x = 0; x < w/2; x ++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d; z++) {
-                        c[x][y][z] = Complex.ofCartesian(i[x * 2][y][z], i[x * 2 + 1][y][z]);
-                    }
-                }
-            }
-        } else if (interleavedDim == 1) {
-            c = new Complex[w][h / 2][d];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h/2; y ++) {
-                    for (int z = 0; z < d; z++) {
-                        c[x][y][z] = Complex.ofCartesian(i[x][y * 2][z], i[x][y * 2 + 1][z]);
-                    }
-                }
-            }
-        } else {
-            c = new Complex[w][h][d / 2];
-            for (int x = 0; x < w; x++) {
-                for (int y = 0; y < h; y++) {
-                    for (int z = 0; z < d/2; z++) {
-                        c[x][y][z] = Complex.ofCartesian(i[x][y][z * 2], i[x][y][z * 2 + 1]);
-                    }
-                }
-            }
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 3D interleaved complex {@code float[][][]} array to a
-     * {@code Complex[]} array. The third level of the array is assumed to
-     * be interleaved.
-     *
-     * @param d 3D complex interleaved float array
-     * @return 3D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][] interleaved2Complex(float[][][] d) {
-        return interleaved2Complex(d, 2);
-    }
-
-    // SPLIT METHODS
-
-    /**
-     * Converts a split complex array {@code double[] r, double[] i} to a
-     * {@code Complex[]} array.
-     *
-     * @param real real component
-     * @param imag imaginary component
-     * @return {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[] split2Complex(double[] real, double[] imag) {
-        final int length = real.length;
-        final Complex[] c = new Complex[length];
-        for (int n = 0; n < length; n++) {
-            c[n] = Complex.ofCartesian(real[n], imag[n]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 2D split complex array {@code double[][] r, double[][] i} to a
-     * 2D {@code Complex[][]} array.
-     *
-     * @param real real component
-     * @param imag imaginary component
-     * @return 2D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][] split2Complex(double[][] real, double[][] imag) {
-        final int length = real.length;
-        Complex[][] c = new Complex[length][];
-        for (int x = 0; x < length; x++) {
-            c[x] = split2Complex(real[x], imag[x]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 3D split complex array {@code double[][][] r, double[][][] i}
-     * to a 3D {@code Complex[][][]} array.
-     *
-     * @param real real component
-     * @param imag imaginary component
-     * @return 3D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][] split2Complex(double[][][] real, double[][][] imag) {
-        final int length = real.length;
-        Complex[][][] c = new Complex[length][][];
-        for (int x = 0; x < length; x++) {
-            c[x] = split2Complex(real[x], imag[x]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 4D split complex array {@code double[][][][] r, double[][][][] i}
-     * to a 4D {@code Complex[][][][]} array.
-     *
-     * @param real real component
-     * @param imag imaginary component
-     * @return 4D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][][] split2Complex(double[][][][] real, double[][][][] imag) {
-        final int length = real.length;
-        Complex[][][][] c = new Complex[length][][][];
-        for (int x = 0; x < length; x++) {
-            c[x] = split2Complex(real[x], imag[x]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a split complex array {@code float[] r, float[] i} to a
-     * {@code Complex[]} array.
-     *
-     * @param real real component
-     * @param imag imaginary component
-     * @return {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[] split2Complex(float[] real, float[] imag) {
-        final int length = real.length;
-        final Complex[] c = new Complex[length];
-        for (int n = 0; n < length; n++) {
-            c[n] = Complex.ofCartesian(real[n], imag[n]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 2D split complex array {@code float[][] r, float[][] i} to a
-     * 2D {@code Complex[][]} array.
-     *
-     * @param real real component
-     * @param imag imaginary component
-     * @return 2D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][] split2Complex(float[][] real, float[][] imag) {
-        final int length = real.length;
-        Complex[][] c = new Complex[length][];
-        for (int x = 0; x < length; x++) {
-            c[x] = split2Complex(real[x], imag[x]);
-        }
-        return c;
-    }
-
-    /**
-     * Converts a 3D split complex array {@code float[][][] r, float[][][] i} to
-     * a 3D {@code Complex[][][]} array.
-     *
-     * @param real real component
-     * @param imag imaginary component
-     * @return 3D {@code Complex} array
-     *
-     * @since 1.0
-     */
-    public static Complex[][][] split2Complex(float[][][] real, float[][][] imag) {
-        final int length = real.length;
-        Complex[][][] c = new Complex[length][][];
-        for (int x = 0; x < length; x++) {
-            c[x] = split2Complex(real[x], imag[x]);
-        }
-        return c;
-    }
-
-    // MISC
-
-    /**
-     * Initializes a {@code Complex[]} array to zero, to avoid
-     * NullPointerExceptions.
-     *
-     * @param c Complex array
-     * @return c
-     *
-     * @since 1.0
-     */
-    public static Complex[] initialize(Complex[] c) {
-        final int length = c.length;
-        for (int x = 0; x < length; x++) {
-            c[x] = Complex.ZERO;
-        }
-        return c;
-    }
-
-    /**
-     * Initializes a {@code Complex[][]} array to zero, to avoid
-     * NullPointerExceptions.
-     *
-     * @param c {@code Complex} array
-     * @return c
-     *
-     * @since 1.0
-     */
-    public static Complex[][] initialize(Complex[][] c) {
-        final int length = c.length;
-        for (int x = 0; x < length; x++) {
-            c[x] = initialize(c[x]);
-        }
-        return c;
-    }
-
-    /**
-     * Initializes a {@code Complex[][][]} array to zero, to avoid
-     * NullPointerExceptions.
-     *
-     * @param c {@code Complex} array
-     * @return c
-     *
-     * @since 1.0
-     */
-    public static Complex[][][] initialize(Complex[][][] c) {
-        final int length = c.length;
-        for (int x = 0; x < length; x++) {
-            c[x] = initialize(c[x]);
-        }
-        return c;
-    }
-
-    /**
-     * Returns {@code double[]} containing absolute values (magnitudes) of a
-     * {@code Complex[]} array.
-     *
-     * @param c {@code Complex} array
-     * @return {@code double[]}
-     *
-     * @since 1.0
-     */
-    public static double[] abs(Complex[] c) {
-        final int length = c.length;
-        final double[] i = new double[length];
-        for (int x = 0; x < length; x++) {
-            i[x] = c[x].abs();
-        }
-        return i;
-    }
-
-    /**
-     * Returns {@code double[]} containing arguments (phase angles) of a
-     * {@code Complex[]} array.
-     *
-     * @param c {@code Complex} array
-     * @return {@code double[]} array
-     *
-     * @since 1.0
-     */
-    public static double[] arg(Complex[] c) {
-        final int length = c.length;
-        final double[] i = new double[length];
-        for (int x = 0; x < length; x++) {
-            i[x] = c[x].getArgument();
-        }
-        return i;
-    }
-
-    /**
-     * Exception to be throw when a negative value is passed as the modulus.
-     */
-    private static class NegativeModulusException extends IllegalArgumentException {
-        /**
-         * @param r Wrong modulus.
-         */
-        NegativeModulusException(double r) {
-            super("Modulus is negative: " + r);
-        }
-    }
-
-    /**
-     * Exception to be throw when an out-of-range index value is passed.
-     */
-    private static class IndexOutOfRangeException extends IllegalArgumentException {
-        /**
-         * @param i Wrong index.
-         */
-        IndexOutOfRangeException(int i) {
-            super("Out of range: " + i);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
index ad73c14..a45fff6 100644
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
@@ -20,7 +20,6 @@ package org.apache.commons.numbers.complex;
 import java.util.List;
 
 import org.apache.commons.numbers.complex.Complex;
-import org.apache.commons.numbers.complex.ComplexUtils;
 import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -599,8 +598,8 @@ public class ComplexTest {
             double theta = 0;
             for (int j = 0; j < 11; j++) {
                 theta += pi / 12;
-                Complex z = ComplexUtils.polar2Complex(r, theta);
-                Complex sqrtz = ComplexUtils.polar2Complex(Math.sqrt(r), theta / 2);
+                Complex z = Complex.ofPolar(r, theta);
+                Complex sqrtz = Complex.ofPolar(Math.sqrt(r), theta / 2);
                 TestUtils.assertEquals(sqrtz, z.sqrt(), tol);
             }
         }

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexUtilsTest.java
----------------------------------------------------------------------
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexUtilsTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexUtilsTest.java
deleted file mode 100644
index 7f2cac2..0000000
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexUtilsTest.java
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.numbers.complex;
-
-import org.apache.commons.numbers.complex.Complex;
-import org.apache.commons.numbers.complex.ComplexUtils;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- */
-public class ComplexUtilsTest {
-
-    private static final double inf = Double.POSITIVE_INFINITY;
-    private static final double negInf = Double.NEGATIVE_INFINITY;
-    private static final double nan = Double.NaN;
-    private static final double pi = Math.PI;
-
-    private static final Complex negInfInf = Complex.ofCartesian(negInf, inf);
-    private static final Complex infNegInf = Complex.ofCartesian(inf, negInf);
-    private static final Complex infInf = Complex.ofCartesian(inf, inf);
-    private static final Complex negInfNegInf = Complex.ofCartesian(negInf, negInf);
-    private static final Complex infNaN = Complex.ofCartesian(inf, nan);
-    private static final Complex NAN = Complex.ofCartesian(nan, nan);
-
-    private static Complex c[]; // complex array with real values even and imag
-                                // values odd
-    private static Complex cr[]; // complex array with real values consecutive
-    private static Complex ci[]; // complex array with imag values consecutive
-    private static double d[]; // real array with consecutive vals
-    private static double di[]; // real array with consecutive vals,
-                                // 'interleaved' length
-    private static float f[]; // real array with consecutive vals
-    private static float fi[]; // real array with consec vals, interleaved
-                               // length
-    private static double sr[]; // real component of split array, evens
-    private static double si[]; // imag component of split array, odds
-    private static float sfr[]; // real component of split array, float, evens
-    private static float sfi[]; // imag component of split array, float, odds
-    static Complex ans1, ans2; // answers to single value extraction methods
-    static Complex[] ansArrayc1r, ansArrayc1i, ansArrayc2r, ansArrayc2i, ansArrayc3, ansArrayc4; // answers
-                                                                                                 // to
-                                                                                                 // range
-                                                                                                 // extraction
-                                                                                                 // methods
-    static double[] ansArrayd1r, ansArrayd2r, ansArrayd1i, ansArrayd2i, ansArraydi1, ansArraydi2;
-    static float[] ansArrayf1r, ansArrayf2r, ansArrayf1i, ansArrayf2i, ansArrayfi1, ansArrayfi2;
-    static String msg; // error message for AssertEquals
-    static Complex[][] c2d, cr2d, ci2d; // for 2d methods
-    static Complex[][][] c3d, cr3d, ci3d; // for 3d methods
-    static double[][] d2d, di2d, sr2d, si2d;
-    static double[][][] d3d, di3d, sr3d, si3d;
-    static float[][] f2d, fi2d, sfr2d, sfi2d;
-    static float[][][] f3d, fi3d, sfr3d, sfi3d;
-
-    private static void setArrays() { // initial setup method
-        c = new Complex[10];
-        cr = new Complex[10];
-        ci = new Complex[10];
-        d = new double[10];
-        f = new float[10];
-        di = new double[20];
-        fi = new float[20];
-        sr = new double[10];
-        si = new double[10];
-        sfr = new float[10];
-        sfi = new float[10];
-        c2d = new Complex[10][10];
-        cr2d = new Complex[10][10];
-        ci2d = new Complex[10][10];
-        c3d = new Complex[10][10][10];
-        cr3d = new Complex[10][10][10];
-        ci3d = new Complex[10][10][10];
-        d2d = new double[10][10];
-        d3d = new double[10][10][10];
-        f2d = new float[10][10];
-        f3d = new float[10][10][10];
-        sr2d = new double[10][10];
-        sr3d = new double[10][10][10];
-        si2d = new double[10][10];
-        si3d = new double[10][10][10];
-        sfr2d = new float[10][10];
-        sfr3d = new float[10][10][10];
-        sfi2d = new float[10][10];
-        sfi3d = new float[10][10][10];
-        di2d = new double[10][20];
-        di3d = new double[10][10][20];
-        fi2d = new float[10][20];
-        fi3d = new float[10][10][20];
-        for (int i = 0; i < 20; i += 2) {
-            d[i / 2] = i / 2;
-            f[i / 2] = i / 2;
-            di[i] = i;
-            di[i + 1] = i + 1;
-            fi[i] = i;
-            fi[i + 1] = i + 1;
-            c[i / 2] = Complex.ofCartesian(i, i + 1);
-            cr[i / 2] = Complex.ofReal(i / 2);
-            ci[i / 2] = Complex.ofCartesian(0, i / 2);
-            sr[i / 2] = i;
-            si[i / 2] = i + 1;
-            sfr[i / 2] = i;
-            sfi[i / 2] = i + 1;
-        }
-        for (int i = 0; i < 10; i++) {
-            for (int j = 0; j < 20; j += 2) {
-                d2d[i][j / 2] = 10 * i + j / 2;
-                f2d[i][j / 2] = 10 * i + j / 2;
-                sr2d[i][j / 2] = 10 * i + j;
-                si2d[i][j / 2] = 10 * i + j + 1;
-                sfr2d[i][j / 2] = 10 * i + j;
-                sfi2d[i][j / 2] = 10 * i + j + 1;
-                di2d[i][j] = 10 * i + j;
-                di2d[i][j + 1] = 10 * i + j + 1;
-                fi2d[i][j] = 10 * i + j;
-                fi2d[i][j + 1] = 10 * i + j + 1;
-                c2d[i][j / 2] = Complex.ofCartesian(10 * i + j, 10 * i + j + 1);
-                cr2d[i][j / 2] = Complex.ofReal(10 * i + j / 2);
-                ci2d[i][j / 2] = Complex.ofCartesian(0, 10 * i + j / 2);
-            }
-        }
-        for (int i = 0; i < 10; i++) {
-            for (int j = 0; j < 10; j++) {
-                for (int k = 0; k < 20; k += 2) {
-                    d3d[i][j][k / 2] = 100 * i + 10 * j + k / 2;
-                    f3d[i][j][k / 2] = 100 * i + 10 * j + k / 2;
-                    sr3d[i][j][k / 2] = 100 * i + 10 * j + k;
-                    si3d[i][j][k / 2] = 100 * i + 10 * j + k + 1;
-                    sfr3d[i][j][k / 2] = 100 * i + 10 * j + k;
-                    sfi3d[i][j][k / 2] = 100 * i + 10 * j + k + 1;
-                    di3d[i][j][k] = 100 * i + 10 * j + k;
-                    di3d[i][j][k + 1] = 100 * i + 10 * j + k + 1;
-                    fi3d[i][j][k] = 100 * i + 10 * j + k;
-                    fi3d[i][j][k + 1] = 100 * i + 10 * j + k + 1;
-                    c3d[i][j][k / 2] = Complex.ofCartesian(100 * i + 10 * j + k, 100 * i + 10 * j + k + 1);
-                    cr3d[i][j][k / 2] = Complex.ofReal(100 * i + 10 * j + k / 2);
-                    ci3d[i][j][k / 2] = Complex.ofCartesian(0, 100 * i + 10 * j + k / 2);
-                }
-            }
-        }
-        ansArrayc1r = new Complex[] { Complex.ofReal(3), Complex.ofReal(4), Complex.ofReal(5), Complex.ofReal(6), Complex.ofReal(7) };
-        ansArrayc2r = new Complex[] { Complex.ofReal(3), Complex.ofReal(5), Complex.ofReal(7) };
-        ansArrayc1i = new Complex[] { Complex.ofCartesian(0, 3), Complex.ofCartesian(0, 4), Complex.ofCartesian(0, 5), Complex.ofCartesian(0, 6),
-                Complex.ofCartesian(0, 7) };
-        ansArrayc2i = new Complex[] { Complex.ofCartesian(0, 3), Complex.ofCartesian(0, 5), Complex.ofCartesian(0, 7) };
-        ansArrayc3 = new Complex[] { Complex.ofCartesian(6, 7), Complex.ofCartesian(8, 9), Complex.ofCartesian(10, 11), Complex.ofCartesian(12, 13),
-                Complex.ofCartesian(14, 15) };
-        ansArrayc4 = new Complex[] { Complex.ofCartesian(6, 7), Complex.ofCartesian(10, 11), Complex.ofCartesian(14, 15) };
-        ansArrayd1r = new double[] { 6, 8, 10, 12, 14 };
-        ansArrayd1i = new double[] { 7, 9, 11, 13, 15 };
-        ansArrayd2r = new double[] { 6, 10, 14 };
-        ansArrayd2i = new double[] { 7, 11, 15 };
-        ansArrayf1r = new float[] { 6, 8, 10, 12, 14 };
-        ansArrayf1i = new float[] { 7, 9, 11, 13, 15 };
-        ansArrayf2r = new float[] { 6, 10, 14 };
-        ansArrayf2i = new float[] { 7, 11, 15 };
-        ansArraydi1 = new double[] { 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
-        ansArrayfi1 = new float[] { 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
-        ansArraydi2 = new double[] { 6, 7, 10, 11, 14, 15 };
-        ansArrayfi2 = new float[] { 6, 7, 10, 11, 14, 15 };
-        msg = "";
-    }
-
-    @Test
-    public void testPolar2Complex() {
-        TestUtils.assertEquals(Complex.ONE, ComplexUtils.polar2Complex(1, 0), 10e-12);
-        TestUtils.assertEquals(Complex.ZERO, ComplexUtils.polar2Complex(0, 1), 10e-12);
-        TestUtils.assertEquals(Complex.ZERO, ComplexUtils.polar2Complex(0, -1), 10e-12);
-        TestUtils.assertEquals(Complex.I, ComplexUtils.polar2Complex(1, pi / 2), 10e-12);
-        TestUtils.assertEquals(Complex.I.negate(), ComplexUtils.polar2Complex(1, -pi / 2), 10e-12);
-        double r = 0;
-        for (int i = 0; i < 5; i++) {
-            r += i;
-            double theta = 0;
-            for (int j = 0; j < 20; j++) {
-                theta += pi / 6;
-                TestUtils.assertEquals(altPolar(r, theta), ComplexUtils.polar2Complex(r, theta), 10e-12);
-            }
-            theta = -2 * pi;
-            for (int j = 0; j < 20; j++) {
-                theta -= pi / 6;
-                TestUtils.assertEquals(altPolar(r, theta), ComplexUtils.polar2Complex(r, theta), 10e-12);
-            }
-        }
-    }
-
-    protected Complex altPolar(double r, double theta) {
-        return Complex.I.multiply(Complex.ofCartesian(theta, 0)).exp().multiply(Complex.ofCartesian(r, 0));
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testPolar2ComplexIllegalModulus() {
-        ComplexUtils.polar2Complex(-1, 0);
-    }
-
-    @Test
-    public void testPolar2ComplexNaN() {
-        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(nan, 1));
-        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, nan));
-        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(nan, nan));
-    }
-
-    @Test
-    public void testPolar2ComplexInf() {
-        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, inf));
-        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, negInf));
-        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(inf, inf));
-        TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(inf, negInf));
-        TestUtils.assertSame(infInf, ComplexUtils.polar2Complex(inf, pi / 4));
-        TestUtils.assertSame(infNaN, ComplexUtils.polar2Complex(inf, 0));
-        TestUtils.assertSame(infNegInf, ComplexUtils.polar2Complex(inf, -pi / 4));
-        TestUtils.assertSame(negInfInf, ComplexUtils.polar2Complex(inf, 3 * pi / 4));
-        TestUtils.assertSame(negInfNegInf, ComplexUtils.polar2Complex(inf, 5 * pi / 4));
-    }
-
-    @Test
-    public void testCExtract() {
-        final double[] real = new double[] { negInf, -123.45, 0, 1, 234.56, pi, inf };
-        final Complex[] complex = ComplexUtils.real2Complex(real);
-
-        for (int i = 0; i < real.length; i++) {
-            Assert.assertEquals(real[i], complex[i].getReal(), 0d);
-        }
-    }
-
-    // EXTRACTION METHODS
-
-    @Test
-    public void testExtractionMethods() {
-        setArrays();
-        // Extract complex from real double array, index 3
-        TestUtils.assertSame(Complex.ofReal(3), ComplexUtils.extractComplexFromRealArray(d, 3));
-        // Extract complex from real float array, index 3
-        TestUtils.assertSame(Complex.ofReal(3), ComplexUtils.extractComplexFromRealArray(f, 3));
-        // Extract real double from complex array, index 3
-        TestUtils.assertSame(6, ComplexUtils.extractRealFromComplexArray(c, 3));
-        // Extract real float from complex array, index 3
-        TestUtils.assertSame(6, ComplexUtils.extractRealFloatFromComplexArray(c, 3));
-        // Extract complex from interleaved double array, index 3
-        TestUtils.assertSame(Complex.ofCartesian(6, 7), ComplexUtils.extractComplexFromInterleavedArray(d, 3));
-        // Extract complex from interleaved float array, index 3
-        TestUtils.assertSame(Complex.ofCartesian(6, 7), ComplexUtils.extractComplexFromInterleavedArray(f, 3));
-        // Extract interleaved double from complex array, index 3
-        TestUtils.assertEquals(msg, new double[] { 6, 7 }, ComplexUtils.extractInterleavedFromComplexArray(c, 3),
-                Math.ulp(1));
-        // Extract interleaved float from complex array, index 3
-        TestUtils.assertEquals(msg, new double[] { 6, 7 }, ComplexUtils.extractInterleavedFromComplexArray(c, 3),
-                Math.ulp(1));
-        if (!msg.equals("")) {
-            throw new RuntimeException(msg);
-        }
-    }
-    // REAL <-> COMPLEX
-
-    @Test
-    public void testRealToComplex() {
-        setArrays();
-        // Real double to complex, range 3-7, increment 1, entered as ints
-        // Real double to complex, whole array
-        TestUtils.assertEquals(msg, cr, ComplexUtils.real2Complex(d),Math.ulp(1.0));
-        // Real float to complex, whole array
-        TestUtils.assertEquals(msg, cr, ComplexUtils.real2Complex(f),Math.ulp(1.0));
-        // 2d
-        for (int i = 0; i < 10; i++) {
-            // Real double to complex, 2d
-            TestUtils.assertEquals(msg, cr2d[i], ComplexUtils.real2Complex(d2d[i]),Math.ulp(1.0));
-            // Real float to complex, 2d
-            TestUtils.assertEquals(msg, cr2d[i], ComplexUtils.real2Complex(f2d[i]),Math.ulp(1.0));
-        }
-        // 3d
-        for (int i = 0; i < 10; i++) {
-            for (int j = 0; j < 10; j++) {
-                // Real double to complex, 3d
-                TestUtils.assertEquals(msg, cr3d[i][j], ComplexUtils.real2Complex(d3d[i][j]),Math.ulp(1.0));
-                // Real float to complex, 3d
-                TestUtils.assertEquals(msg, cr3d[i][j], ComplexUtils.real2Complex(f3d[i][j]),Math.ulp(1.0));
-            }
-        }
-        if (!msg.equals("")) {
-            throw new RuntimeException(msg);
-        }
-    }
-
-    @Test
-    public void testComplexToReal() {
-        setArrays();
-        // Real complex to double, whole array
-        TestUtils.assertEquals(msg, sr, ComplexUtils.complex2Real(c),Math.ulp(1.0));
-        // Real complex to float, whole array
-        TestUtils.assertEquals(msg, sfr, ComplexUtils.complex2RealFloat(c),Math.ulp(1.0f));
-        // 2d
-        for (int i = 0; i < 10; i++) {
-            // Real complex to double, 2d
-            TestUtils.assertEquals(msg, sr2d[i], ComplexUtils.complex2Real(c2d[i]),Math.ulp(1.0));
-            // Real complex to float, 2d
-            TestUtils.assertEquals(msg, sfr2d[i], ComplexUtils.complex2RealFloat(c2d[i]),Math.ulp(1.0f));
-        }
-        // 3d
-        for (int i = 0; i < 10; i++) {
-            for (int j = 0; j < 10; j++) {
-                // Real complex to double, 3d
-                TestUtils.assertEquals(msg, sr3d[i][j], ComplexUtils.complex2Real(c3d[i][j]),Math.ulp(1.0));
-                // Real complex to float, 3d
-                TestUtils.assertEquals(msg, sfr3d[i][j], ComplexUtils.complex2RealFloat(c3d[i][j]),Math.ulp(1.0f));
-            }
-        }
-        if (!msg.equals("")) {
-            throw new RuntimeException(msg);
-        }
-    }
-
-    // IMAGINARY <-> COMPLEX
-
-    @Test
-    public void testImaginaryToComplex() {
-        setArrays();
-        // Imaginary double to complex, whole array
-        TestUtils.assertEquals(msg, ci, ComplexUtils.imaginary2Complex(d),Math.ulp(1.0));
-        // Imaginary float to complex, whole array
-        TestUtils.assertEquals(msg, ci, ComplexUtils.imaginary2Complex(f),Math.ulp(1.0));
-        // 2d
-        for (int i = 0; i < 10; i++) {
-            // Imaginary double to complex, 2d
-            TestUtils.assertEquals(msg, ci2d[i], ComplexUtils.imaginary2Complex(d2d[i]),Math.ulp(1.0));
-            // Imaginary float to complex, 2d
-            TestUtils.assertEquals(msg, ci2d[i], ComplexUtils.imaginary2Complex(f2d[i]),Math.ulp(1.0));
-        }
-        // 3d
-        for (int i = 0; i < 10; i++) {
-            for (int j = 0; j < 10; j++) {
-                // Imaginary double to complex, 3d
-                TestUtils.assertEquals(msg, ci3d[i][j], ComplexUtils.imaginary2Complex(d3d[i][j]),Math.ulp(1.0));
-                // Imaginary float to complex, 3d
-                TestUtils.assertEquals(msg, ci3d[i][j], ComplexUtils.imaginary2Complex(f3d[i][j]),Math.ulp(1.0));
-            }
-        }
-        if (!msg.equals("")) {
-            throw new RuntimeException(msg);
-        }
-    }
-
-    @Test
-    public void testComplexToImaginary() {
-        setArrays();
-        // Imaginary complex to double, whole array
-        TestUtils.assertEquals(msg, si, ComplexUtils.complex2Imaginary(c),Math.ulp(1.0));
-        // Imaginary complex to float, whole array
-        TestUtils.assertEquals(msg, sfi, ComplexUtils.complex2ImaginaryFloat(c),Math.ulp(1.0f));
-        // 2d
-        for (int i = 0; i < 10; i++) {
-            // Imaginary complex to double, 2d
-            TestUtils.assertEquals(msg, si2d[i], ComplexUtils.complex2Imaginary(c2d[i]),Math.ulp(1.0));
-            // Imaginary complex to float, 2d
-            TestUtils.assertEquals(msg, sfi2d[i], ComplexUtils.complex2ImaginaryFloat(c2d[i]),Math.ulp(1.0f));
-        }
-        // 3d
-        for (int i = 0; i < 10; i++) {
-            for (int j = 0; j < 10; j++) {
-                // Imaginary complex to double, 3d
-                TestUtils.assertEquals(msg, si3d[i][j], ComplexUtils.complex2Imaginary(c3d[i][j]),Math.ulp(1.0));
-                // Imaginary complex to float, 3d
-                TestUtils.assertEquals(msg, sfi3d[i][j], ComplexUtils.complex2ImaginaryFloat(c3d[i][j]),Math.ulp(1.0f));
-            }
-        }
-        if (!msg.equals("")) {
-            throw new RuntimeException(msg);
-        }
-    }
-
-    // INTERLEAVED <-> COMPLEX
-
-    @Test
-    public void testInterleavedToComplex() {
-        setArrays();
-        // Interleaved double to complex, whole array
-        TestUtils.assertEquals(msg, c, ComplexUtils.interleaved2Complex(di),Math.ulp(1.0));
-        // Interleaved float to complex, whole array
-        TestUtils.assertEquals(msg, c, ComplexUtils.interleaved2Complex(fi),Math.ulp(1.0));
-        // 2d
-        for (int i = 0; i < 10; i++) {
-            // Interleaved double to complex, 2d
-            TestUtils.assertEquals(msg, c2d[i], ComplexUtils.interleaved2Complex(di2d[i]),Math.ulp(1.0));
-            // Interleaved float to complex, 2d
-            TestUtils.assertEquals(msg, c2d[i], ComplexUtils.interleaved2Complex(fi2d[i]),Math.ulp(1.0));
-        }
-        // 3d
-        for (int i = 0; i < 10; i++) {
-            for (int j = 0; j < 10; j++) {
-                // Interleaved double to complex, 3d
-                TestUtils.assertEquals(msg, c3d[i][j], ComplexUtils.interleaved2Complex(di3d[i][j]),Math.ulp(1.0));
-                // Interleaved float to complex, 3d
-                TestUtils.assertEquals(msg, c3d[i][j], ComplexUtils.interleaved2Complex(fi3d[i][j]),Math.ulp(1.0));
-            }
-        }
-        if (!msg.equals("")) {
-            throw new RuntimeException(msg);
-        }
-    }
-
-    @Test
-    public void testComplexToInterleaved() {
-        setArrays();
-        TestUtils.assertEquals(msg, di, ComplexUtils.complex2Interleaved(c),Math.ulp(1.0));
-        // Interleaved complex to float, whole array
-        TestUtils.assertEquals(msg, fi, ComplexUtils.complex2InterleavedFloat(c),Math.ulp(1.0f));
-        // 2d
-        for (int i = 0; i < 10; i++) {
-            // Interleaved complex to double, 2d
-            TestUtils.assertEquals(msg, di2d[i], ComplexUtils.complex2Interleaved(c2d[i]),Math.ulp(1.0));
-            // Interleaved complex to float, 2d
-            TestUtils.assertEquals(msg, fi2d[i], ComplexUtils.complex2InterleavedFloat(c2d[i]),Math.ulp(1.0f));
-        }
-        // 3d
-        for (int i = 0; i < 10; i++) {
-            for (int j = 0; j < 10; j++) {
-                // Interleaved complex to double, 3d
-                TestUtils.assertEquals(msg, di3d[i][j], ComplexUtils.complex2Interleaved(c3d[i][j]),Math.ulp(1.0));
-                // Interleaved complex to float, 3d
-                TestUtils.assertEquals(msg, fi3d[i][j], ComplexUtils.complex2InterleavedFloat(c3d[i][j]),Math.ulp(1.0f));
-            }
-        }
-        if (!msg.equals("")) {
-            throw new RuntimeException(msg);
-        }
-    }
-
-    // SPLIT TO COMPLEX
-    @Test
-    public void testSplit2Complex() {
-        setArrays();
-        // Split double to complex, whole array
-        TestUtils.assertEquals(msg, c, ComplexUtils.split2Complex(sr, si),Math.ulp(1.0));
-
-        // 2d
-        for (int i = 0; i < 10; i++) {
-            // Split double to complex, 2d
-            TestUtils.assertEquals(msg, c2d[i], ComplexUtils.split2Complex(sr2d[i], si2d[i]),Math.ulp(1.0));
-        }
-        // 3d
-        for (int i = 0; i < 10; i++) {
-            for (int j = 0; j < 10; j++) {
-                // Split double to complex, 3d
-                TestUtils.assertEquals(msg, c3d[i][j], ComplexUtils.split2Complex(sr3d[i][j], si3d[i][j]),Math.ulp(1.0));
-            }
-        }
-        if (!msg.equals("")) {
-            throw new RuntimeException(msg);
-        }
-    }
-
-    // INITIALIZATION METHODS
-
-    @Test
-    public void testInitialize() {
-        Complex[] c = new Complex[10];
-        ComplexUtils.initialize(c);
-        for (Complex cc : c) {
-            TestUtils.assertEquals(Complex.ofCartesian(0, 0), cc, Math.ulp(0));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/40418955/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 15f9908..433ee42 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,6 +81,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
+      <artifactId>commons-numbers-complex</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
       <artifactId>commons-numbers-core</artifactId>
       <version>${project.version}</version>
       <type>test-jar</type>
@@ -595,6 +600,7 @@
   <modules>
     <module>commons-numbers-core</module>
     <module>commons-numbers-complex</module>
+    <module>commons-numbers-complex-streams</module>
     <module>commons-numbers-primes</module>
     <module>commons-numbers-quaternion</module>
     <module>commons-numbers-fraction</module>