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>
