diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 2d8e52a94..da6844b96 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,4 +1,49 @@ + Apache Commons Numbers 1.2 RELEASE NOTES + +The Apache Commons Numbers team is pleased to announce the release of Apache Commons Numbers 1.2. + +The Apache Commons Numbers project provides number types and utilities. + +New features, updates and bug fixes. Requires Java 8. + +Changes in this version include: + +New features: +o NUMBERS-206: "Selection": Add selection of the k-th ordered element from an array. +o NUMBERS-205: "Addition/Multiplication": Introduces isZero to Addition and isOne to Multiplication + interfaces. Override the default implementation in implementing classes to avoid + expensive equals(Object) operations. Thanks to Harald Kirsch. +o NUMBERS-203: "DDField": Add a field for the DD number. +o NUMBERS-193: "DD": Add an extended precision floating-point number. A double-double (DD) number + is an unevaluated sum of two IEEE double precision numbers capable of representing + at least 106 bits of significand. +o NUMBERS-192: "Sum": Add subtract(Sum) method. +o NUMBERS-191: "Stirling": Compute Stirling numbers of the first kind. +o NUMBERS-29: Add "Stirling" class to compute Stirling numbers of the second kind. + +Fixed Bugs: +o NUMBERS-204: "Sum": Correct sub-normal round-off computation in sum of products. +o NUMBERS-201: "FP64": Make equals consistent with hashCode. +o NUMBERS-200: "Sum": Avoid a NaN result when combining Sum instances with infinite sums + of the same sign. Thanks to Anirudh Joshi. + +Changes: +o "ArithmeticUtils": Improve performance of GCD for longs. Thanks to Matthias Langer. +o "ArithmeticUtils": Improve performance of remainderUnsigned and divideUnsigned. + Thanks to Sebb, Alex Herbert. +o NUMBERS-199: "Precision": Document inaccurate decimal value representation when converting + to and from a double in the round method. + + +For complete information on Apache Commons Numbers, including instructions on how to submit bug +reports, patches, or suggestions for improvement, see the Apache Commons Numbers website: + +http://commons.apache.org/proper/commons-numbers/ + + +============================================================================= + Apache Commons Numbers 1.1 RELEASE NOTES The Apache Commons Numbers team is pleased to announce the release of diff --git a/commons-numbers-angle/pom.xml b/commons-numbers-angle/pom.xml index 935e2703f..1fed9127f 100644 --- a/commons-numbers-angle/pom.xml +++ b/commons-numbers-angle/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-angle diff --git a/commons-numbers-angle/src/site/site.xml b/commons-numbers-angle/src/site/site.xml index f00f802a4..49e567efd 100644 --- a/commons-numbers-angle/src/site/site.xml +++ b/commons-numbers-angle/src/site/site.xml @@ -28,12 +28,12 @@ + - diff --git a/commons-numbers-arrays/pom.xml b/commons-numbers-arrays/pom.xml index 944bd3ba3..ebcf879da 100644 --- a/commons-numbers-arrays/pom.xml +++ b/commons-numbers-arrays/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-arrays diff --git a/commons-numbers-arrays/src/site/site.xml b/commons-numbers-arrays/src/site/site.xml index 829746422..fc1257bce 100644 --- a/commons-numbers-arrays/src/site/site.xml +++ b/commons-numbers-arrays/src/site/site.xml @@ -28,12 +28,12 @@ + - diff --git a/commons-numbers-bom/pom.xml b/commons-numbers-bom/pom.xml index 7c02f4485..7b1895436 100644 --- a/commons-numbers-bom/pom.xml +++ b/commons-numbers-bom/pom.xml @@ -21,11 +21,11 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-bom - 1.2-SNAPSHOT + 1.2 Apache Commons Numbers (Bill of Materials) pom diff --git a/commons-numbers-bom/src/site/xdoc/index.xml b/commons-numbers-bom/src/site/xdoc/index.xml index 4ef8f81c1..4051161f4 100644 --- a/commons-numbers-bom/src/site/xdoc/index.xml +++ b/commons-numbers-bom/src/site/xdoc/index.xml @@ -60,7 +60,7 @@ org.apache.commons commons-numbers-bom - 1.1 + 1.2 pom import diff --git a/commons-numbers-combinatorics/pom.xml b/commons-numbers-combinatorics/pom.xml index 0823f5fec..bc28f85aa 100644 --- a/commons-numbers-combinatorics/pom.xml +++ b/commons-numbers-combinatorics/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-combinatorics diff --git a/commons-numbers-combinatorics/src/site/site.xml b/commons-numbers-combinatorics/src/site/site.xml index 1bd05daf2..f0eeb4faf 100644 --- a/commons-numbers-combinatorics/src/site/site.xml +++ b/commons-numbers-combinatorics/src/site/site.xml @@ -28,12 +28,12 @@ + - diff --git a/commons-numbers-complex-streams/LICENSE b/commons-numbers-complex-streams/LICENSE deleted file mode 100644 index 261eeb9e9..000000000 --- a/commons-numbers-complex-streams/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - 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. diff --git a/commons-numbers-complex-streams/NOTICE b/commons-numbers-complex-streams/NOTICE deleted file mode 100644 index 179baf5ac..000000000 --- a/commons-numbers-complex-streams/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -Apache Commons Numbers -Copyright 2001-2023 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). - diff --git a/commons-numbers-complex-streams/README.md b/commons-numbers-complex-streams/README.md deleted file mode 100644 index befe78e42..000000000 --- a/commons-numbers-complex-streams/README.md +++ /dev/null @@ -1,105 +0,0 @@ - - -Apache Commons Numbers Complex Streams -=================== - -[![Build Status](https://github.com/apache/commons-numbers/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-numbers/actions/workflows/maven.yml) -[![Coverage Status](https://codecov.io/gh/apache/commons-numbers/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/commons-numbers) -[![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/) -[![Javadocs](https://javadoc.io/badge/org.apache.commons/commons-numbers-complex-streams/1.1.svg)](https://javadoc.io/doc/org.apache.commons/commons-numbers-complex-streams/1.1) - -Arrays, streams and collections of complex numbers. - -Documentation -------------- - -More information can be found on the [Apache Commons Numbers homepage](https://commons.apache.org/proper/commons-numbers). -The [Javadoc](https://commons.apache.org/proper/commons-numbers/commons-numbers-complex-streams/apidocs) can be browsed. -Questions related to the usage of Apache Commons Numbers 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 - - org.apache.commons - commons-numbers-complex-streams - 1.1 - -``` - -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```. - -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` file for required notices and attributions. - -Donations ---------- -You like Apache Commons Numbers? 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 diff --git a/commons-numbers-complex-streams/pom.xml b/commons-numbers-complex-streams/pom.xml deleted file mode 100644 index 21bc7c2fa..000000000 --- a/commons-numbers-complex-streams/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - 4.0.0 - - - org.apache.commons - commons-numbers-parent - 1.2-SNAPSHOT - - - commons-numbers-complex-streams - Apache Commons Numbers Complex Streams - - Arrays, streams and collections of complex numbers. - - - - org.apache.commons.numbers.complex.streams - - org.apache.commons.numbers.complex.streams - - org.apache.commons.numbers.complex.streams - - ${basedir}/.. - - ${numbers.build.outputTimestamp} - complex-streams - - - - - org.apache.commons - commons-numbers-complex - - - - org.apache.commons - commons-numbers-core - test - - - - org.apache.commons - commons-math3 - test - - - - - 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 deleted file mode 100644 index fcd197529..000000000 --- a/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/ComplexUtils.java +++ /dev/null @@ -1,1624 +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.streams; - -import org.apache.commons.numbers.complex.Complex; - -/** - * Static implementations of common {@link Complex} utilities functions. - */ -public final class ComplexUtils { - /** Dimension X. */ - private static final int DIM_X = 0; - /** Dimension Y. */ - private static final int DIM_Y = 1; - /** Dimension Z. */ - private static final int DIM_Z = 2; - - /** - * Utility class. - */ - private ComplexUtils() {} - - /** - * Creates a complex number from the given polar representation. - *

- * If either {@code r} or {@code theta} is NaN, or {@code theta} is - * infinite, {@code Complex(NaN, NaN)} is returned. - *

- * 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. - * - * 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 }
-     * 
- * - * @param r the modulus of the complex number to create - * @param theta the argument of the complex number to create - * @return {@code Complex} - * @throws IllegalArgumentException if {@code r} is negative - */ - 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[]} - * @throws IllegalArgumentException if any element in {@code r} is negative - */ - 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[][]} - * @throws IllegalArgumentException if any element in {@code r} is negative - */ - 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} - * @throws IllegalArgumentException if any element in {@code r} is negative - */ - 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}. - */ - public static Complex extractComplexFromRealArray(double[] real, int index) { - return Complex.ofCartesian(real[index], 0); - } - - /** - * 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 - */ - public static Complex extractComplexFromRealArray(float[] real, int index) { - return Complex.ofCartesian(real[index], 0); - } - - /** - * 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 - */ - 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 - */ - 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}. - */ - 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}. - */ - 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}. - */ - 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}. - */ - 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}. - */ - 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}. - */ - 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. - */ - 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[]}. - */ - 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 - */ - public static Complex[] real2Complex(double[] real) { - int index = 0; - final Complex[] c = new Complex[real.length]; - for (final double d : real) { - c[index] = Complex.ofCartesian(d, 0); - 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 - */ - public static Complex[] real2Complex(float[] real) { - int index = 0; - final Complex[] c = new Complex[real.length]; - for (final float d : real) { - c[index] = Complex.ofCartesian(d, 0); - 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 - */ - 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 - */ - 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 - */ - 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 - */ - 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 - */ - 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 - */ - public static double[] complex2Real(Complex[] c) { - int index = 0; - final double[] d = new double[c.length]; - for (final 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 - */ - public static float[] complex2RealFloat(Complex[] c) { - int index = 0; - final float[] f = new float[c.length]; - for (final 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 - */ - public static double[][] complex2Real(Complex[][] c) { - final int length = c.length; - final 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 - */ - public static float[][] complex2RealFloat(Complex[][] c) { - final int length = c.length; - final 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 - */ - public static double[][][] complex2Real(Complex[][][] c) { - final int length = c.length; - final 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 - */ - public static float[][][] complex2RealFloat(Complex[][][] c) { - final int length = c.length; - final 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 - */ - public static double[][][][] complex2Real(Complex[][][][] c) { - final int length = c.length; - final 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 - */ - public static float[][][][] complex2RealFloat(Complex[][][][] c) { - final int length = c.length; - final 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 - */ - public static Complex[] imaginary2Complex(double[] imaginary) { - int index = 0; - final Complex[] c = new Complex[imaginary.length]; - for (final 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 - */ - public static Complex[] imaginary2Complex(float[] imaginary) { - int index = 0; - final Complex[] c = new Complex[imaginary.length]; - for (final 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 - */ - public static Complex[][] imaginary2Complex(double[][] i) { - final int w = i.length; - final 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 - */ - public static Complex[][][] imaginary2Complex(double[][][] i) { - final int w = i.length; - final 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 - */ - public static Complex[][][][] imaginary2Complex(double[][][][] i) { - final int w = i.length; - final 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 - */ - public static double[] complex2Imaginary(Complex[] c) { - int index = 0; - final double[] i = new double[c.length]; - for (final 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 - */ - public static float[] complex2ImaginaryFloat(Complex[] c) { - int index = 0; - final float[] f = new float[c.length]; - for (final 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 - */ - public static double[][] complex2Imaginary(Complex[][] c) { - final int length = c.length; - final 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 - */ - public static float[][] complex2ImaginaryFloat(Complex[][] c) { - final int length = c.length; - final 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 - */ - public static double[][][] complex2Imaginary(Complex[][][] c) { - final int length = c.length; - final 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 - */ - public static float[][][] complex2ImaginaryFloat(Complex[][][] c) { - final int length = c.length; - final 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 - */ - public static double[][][][] complex2Imaginary(Complex[][][][] c) { - final int length = c.length; - final 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 - */ - public static float[][][][] complex2ImaginaryFloat(Complex[][][][] c) { - final int length = c.length; - final 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 - */ - 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 - */ - 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 - */ - public static double[] complex2Interleaved(Complex[] c) { - int index = 0; - final double[] i = new double[c.length * 2]; - for (final Complex cc : c) { - final int real = index * 2; - final 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 - */ - public static float[] complex2InterleavedFloat(Complex[] c) { - int index = 0; - final float[] f = new float[c.length * 2]; - for (final Complex cc : c) { - final int real = index * 2; - final 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 - * @throws IllegalArgumentException if {@code interleavedDim} is not 0 or 1 - */ - 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 - */ - 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 - * @throws IllegalArgumentException if {@code interleavedDim} is not 0, 1, or 2 - */ - public static double[][][] complex2Interleaved(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; - 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 - * @throws IllegalArgumentException if {@code interleavedDim} is not in the range {@code [0, 3]} - */ - public static double[][][][] complex2Interleaved(Complex[][][][] c, int interleavedDim) { - if (interleavedDim > 3 || interleavedDim < 0) { - throw new IndexOutOfRangeException(interleavedDim); - } - final int w = c.length; - final int h = c[0].length; - final int d = c[0][0].length; - final int v = c[0][0][0].length; - double[][][][] i; - if (interleavedDim == DIM_X) { - 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 == DIM_Y) { - 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 == DIM_Z) { - 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 - */ - 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 - */ - 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 - * @throws IllegalArgumentException if {@code interleavedDim} is not 0 or 1 - */ - 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 - */ - 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 - * @throws IllegalArgumentException if {@code interleavedDim} is not 0, 1, or 2 - */ - 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 - */ - 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 - * @throws IllegalArgumentException if {@code interleavedDim} is not 0 or 1 - */ - 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 - */ - 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 - * @throws IllegalArgumentException if {@code interleavedDim} is not 0, 1, or 2 - */ - 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 == DIM_X) { - 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 == DIM_Y) { - 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 - * @throws IllegalArgumentException if {@code interleavedDim} is not in the range {@code [0, 3]} - */ - public static Complex[][][][] interleaved2Complex(double[][][][] i, int interleavedDim) { - if (interleavedDim > 3 || 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 - */ - 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 - * @throws IllegalArgumentException if {@code interleavedDim} is not 0 or 1 - */ - 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 - */ - 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 - * @throws IllegalArgumentException if {@code interleavedDim} is not 0, 1, or 2 - */ - 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 - */ - 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 - */ - 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 - */ - public static Complex[][] split2Complex(double[][] real, double[][] imag) { - final int length = real.length; - final 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 - */ - public static Complex[][][] split2Complex(double[][][] real, double[][][] imag) { - final int length = real.length; - final 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 - */ - public static Complex[][][][] split2Complex(double[][][][] real, double[][][][] imag) { - final int length = real.length; - final 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 - */ - 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 - */ - public static Complex[][] split2Complex(float[][] real, float[][] imag) { - final int length = real.length; - final 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 - */ - public static Complex[][][] split2Complex(float[][][] real, float[][][] imag) { - final int length = real.length; - final 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 - */ - 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 - */ - 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 - */ - 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[]} - */ - 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 - */ - 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].arg(); - } - return i; - } - - /** - * Exception to be throw when a negative value is passed as the modulus. - */ - private static class NegativeModulusException extends IllegalArgumentException { - /** Serializable version identifier. */ - private static final long serialVersionUID = 20181205L; - - /** - * @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 { - /** Serializable version identifier. */ - private static final long serialVersionUID = 20181205L; - - /** - * @param i Wrong index. - */ - IndexOutOfRangeException(int i) { - super("Out of range: " + i); - } - } -} 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 deleted file mode 100644 index 0b7c1cd98..000000000 --- a/commons-numbers-complex-streams/src/main/java/org/apache/commons/numbers/complex/streams/package-info.java +++ /dev/null @@ -1,20 +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. - */ -/** - * Complex numbers collections. - */ -package org.apache.commons.numbers.complex.streams; diff --git a/commons-numbers-complex-streams/src/site/resources/profile.jacoco b/commons-numbers-complex-streams/src/site/resources/profile.jacoco deleted file mode 100644 index a12755f3b..000000000 --- a/commons-numbers-complex-streams/src/site/resources/profile.jacoco +++ /dev/null @@ -1,17 +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. -# ----------------------------------------------------------------------------- -# -# Empty file used to automatically trigger JaCoCo profile from commons parent pom diff --git a/commons-numbers-complex-streams/src/site/site.xml b/commons-numbers-complex-streams/src/site/site.xml deleted file mode 100644 index b788a3785..000000000 --- a/commons-numbers-complex-streams/src/site/site.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - Apache Commons Numbers - - https://commons.apache.org/proper/commons-numbers/images/commons_numbers.small.png - https://commons.apache.org/proper/commons-numbers/index.html - - - - - - - - - - - diff --git a/commons-numbers-complex-streams/src/site/xdoc/index.xml b/commons-numbers-complex-streams/src/site/xdoc/index.xml deleted file mode 100644 index c295d953a..000000000 --- a/commons-numbers-complex-streams/src/site/xdoc/index.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - Commons Numbers Complex - - - - -
-

- Commons Numbers provides utilities such as complex numbers and fractions. -

- -

- The "complex-stream" module contains... -

-
- - - -
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 deleted file mode 100644 index ffafec5b4..000000000 --- a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/ComplexUtilsTest.java +++ /dev/null @@ -1,772 +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.streams; - -import org.apache.commons.numbers.complex.Complex; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Tests for {@link ComplexUtils}. - */ -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; // interleaved real array with consecutive vals, - // 'interleaved' length - private static float[] f; // real array with consecutive vals - private static float[] fi; // interleaved real array with consecutive 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 - private static String msg; // error message for AssertEquals - // CHECKSTYLE: stop MultipleVariableDeclarations - private static Complex[][] c2d, cr2d, ci2d; // for 2d methods - private static Complex[][][] c3d, cr3d, ci3d; // for 3d methods - private static Complex[][][][] c4d, cr4d, ci4d; // for 3d methods - private static double[][] di2d0, di2d1, sr2d, si2d; - private static double[][][] di3d0, di3d1, di3d2, sr3d, si3d; - private static double[][][][] di4d0, di4d1, di4d2, di4d3, sr4d, si4d; - private static float[][] fi2d0, fi2d1, sfr2d, sfi2d; - private static float[][][] fi3d0, fi3d1, fi3d2, sfr3d, sfi3d; - private static float[][][][] sfr4d, sfi4d; - // CHECKSTYLE: resume MultipleVariableDeclarations - - // CHECKSTYLE: stop MethodLength - 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]; - c4d = new Complex[10][10][10][10]; - cr4d = new Complex[10][10][10][10]; - ci4d = new Complex[10][10][10][10]; - sr2d = new double[10][10]; - sr3d = new double[10][10][10]; - sr4d = new double[10][10][10][10]; - si2d = new double[10][10]; - si3d = new double[10][10][10]; - si4d = new double[10][10][10][10]; - sfr2d = new float[10][10]; - sfr3d = new float[10][10][10]; - sfr4d = new float[10][10][10][10]; - sfi2d = new float[10][10]; - sfi3d = new float[10][10][10]; - sfi4d = new float[10][10][10][10]; - di2d0 = new double[20][10]; - di2d1 = new double[10][20]; - di3d0 = new double[20][10][10]; - di3d1 = new double[10][20][10]; - di3d2 = new double[10][10][20]; - di4d0 = new double[20][10][10][10]; - di4d1 = new double[10][20][10][10]; - di4d2 = new double[10][10][20][10]; - di4d3 = new double[10][10][10][20]; - fi2d0 = new float[20][10]; - fi2d1 = new float[10][20]; - fi3d0 = new float[20][10][10]; - fi3d1 = new float[10][20][10]; - fi3d2 = new float[10][10][20]; - for (int i = 0; i < 20; i += 2) { - int halfI = i / 2; - - // Complex arrays - c[halfI] = Complex.ofCartesian(i, i + 1); - cr[halfI] = Complex.ofCartesian(halfI, 0); - ci[halfI] = Complex.ofCartesian(0, halfI); - - // standalone - split equivalent to c - sr[halfI] = i; - si[halfI] = i + 1; - sfr[halfI] = i; - sfi[halfI] = i + 1; - - // depending on method used equivalents to cr or ci - d[halfI] = halfI; - f[halfI] = halfI; - - // interleaved - all equivalent to c2d - di[i] = i; - di[i + 1] = i + 1; - fi[i] = i; - fi[i + 1] = i + 1; - } - for (int i = 0; i < 10; i++) { - for (int j = 0; j < 20; j += 2) { - int halfJ = j / 2; - int real = 10 * i + j; - int imaginary = 10 * i + j + 1; - - // Complex arrays - c2d[i][halfJ] = Complex.ofCartesian(real, imaginary); - cr2d[i][halfJ] = Complex.ofCartesian(real, 0); - ci2d[i][halfJ] = Complex.ofCartesian(0, imaginary); - - // standalone - split equivalent to c2d, standalone equivalent to cr2d or ci2d - sr2d[i][halfJ] = real; - si2d[i][halfJ] = imaginary; - sfr2d[i][halfJ] = real; - sfi2d[i][halfJ] = imaginary; - - // interleaved - all equivalent to c2d - di2d0[j][i] = 10 * halfJ + 2 * i; - di2d0[j + 1][i] = di2d0[j][i] + 1; - di2d1[i][j] = real; - di2d1[i][j + 1] = imaginary; - fi2d0[j][i] = 10 * halfJ + 2 * i; - fi2d0[j + 1][i] = fi2d0[j][i] + 1; - fi2d1[i][j] = real; - fi2d1[i][j + 1] = imaginary; - } - } - for (int i = 0; i < 10; i++) { - for (int j = 0; j < 10; j++) { - for (int k = 0; k < 20; k += 2) { - int halfK = k / 2; - int real = 100 * i + 10 * j + k; - int imaginary = 100 * i + 10 * j + k + 1; - - // Complex arrays - c3d[i][j][halfK] = Complex.ofCartesian(real, imaginary); - cr3d[i][j][halfK] = Complex.ofCartesian(real, 0); - ci3d[i][j][halfK] = Complex.ofCartesian(0, imaginary); - - // standalone - split equivalent to c3d, standalone equivalent to cr3d or ci3d - sr3d[i][j][halfK] = real; - si3d[i][j][halfK] = imaginary; - sfr3d[i][j][halfK] = real; - sfi3d[i][j][halfK] = imaginary; - - // interleaved - all equivalent to c3d - di3d0[k][i][j] = 100 * halfK + 10 * i + 2 * j; - di3d0[k + 1][i][j] = di3d0[k][i][j] + 1; - di3d1[j][k][i] = 100 * j + 10 * halfK + 2 * i; - di3d1[j][k + 1][i] = di3d1[j][k][i] + 1; - di3d2[i][j][k] = real; - di3d2[i][j][k + 1] = imaginary; - fi3d0[k][i][j] = 100 * halfK + 10 * i + 2 * j; - fi3d0[k + 1][i][j] = fi3d0[k][i][j] + 1; - fi3d1[j][k][i] = 100 * j + 10 * halfK + 2 * i; - fi3d1[j][k + 1][i] = fi3d1[j][k][i] + 1; - fi3d2[i][j][k] = real; - fi3d2[i][j][k + 1] = imaginary; - } - } - } - for (int i = 0; i < 10; i++) { - for (int j = 0; j < 10; j++) { - for (int k = 0; k < 10; k++) { - for (int l = 0; l < 20; l += 2) { - int halfL = l / 2; - int real = 1000 * i + 100 * j + 10 * k + l; - int imaginary = 1000 * i + 100 * j + 10 * k + l + 1; - - // Complex arrays - c4d[i][j][k][halfL] = Complex.ofCartesian(real, imaginary); - cr4d[i][j][k][halfL] = Complex.ofCartesian(real, 0); - ci4d[i][j][k][halfL] = Complex.ofCartesian(0, imaginary); - - // standalone - split equivalent to c4d, standalone equivalent to cr4d or ci4d - sr4d[i][j][k][halfL] = real; - si4d[i][j][k][halfL] = imaginary; - sfr4d[i][j][k][halfL] = real; - sfi4d[i][j][k][halfL] = imaginary; - - // interleaved - all equivalent to c4d - di4d0[l][i][j][k] = 1000 * halfL + 100 * i + 10 * j + 2 * k; - di4d0[l + 1][i][j][k] = di4d0[l][i][j][k] + 1; - di4d1[k][l][i][j] = 1000 * k + 100 * halfL + 10 * i + 2 * j; - di4d1[k][l + 1][i][j] = di4d1[k][l][i][j] + 1; - di4d2[j][k][l][i] = 1000 * j + 100 * k + 10 * halfL + 2 * i; - di4d2[j][k][l + 1][i] = di4d2[j][k][l][i] + 1; - di4d3[i][j][k][l] = real; - di4d3[i][j][k][l + 1] = imaginary; - } - } - } - } - msg = ""; - } - // CHECKSTYLE: resume MethodLength - - @Test - 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); - } - } - // 1D - double[] r1D = new double[11]; - double[] theta1D = new double[11]; - for (int i = 0; i < 11; i++) { - r1D[i] = i; - } - theta1D[5] = 0; - for (int i = 1; i < 5; i++) { - theta1D[5 + i] = theta1D[5 + i - 1] + pi / 6; - theta1D[5 - i] = theta1D[5 + i + 1] - pi / 6; - } - Complex[] observed1D = ComplexUtils.polar2Complex(r1D, theta1D); - Assertions.assertEquals(r1D.length, observed1D.length); - for (int i = 0; i < r1D.length; i++) { - Assertions.assertEquals(ComplexUtils.polar2Complex(r1D[i], theta1D[i]), observed1D[i]); - } - - // 2D - double[][] theta2D = new double[3][4]; - double[][] r2D = new double[3][4]; - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 4; j++) { - r2D[i][j] = i + j; - theta2D[i][j] = i * j; - } - } - Complex[][] observed2D = ComplexUtils.polar2Complex(r2D, theta2D); - Assertions.assertEquals(r2D.length, observed2D.length); - for (int i = 0; i < r2D.length; i++) { - TestUtils.assertSame(msg, ComplexUtils.polar2Complex(r2D[i], theta2D[i]), observed2D[i]); - } - - // 3D - double[][][] theta3D = new double[3][4][3]; - double[][][] r3D = new double[3][4][3]; - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 4; j++) { - for (int k = 0; k < 3; k++) { - r3D[i][j][k] = i + j + k; - theta3D[i][j][k] = i * j * k; - } - } - } - Complex[][][] observed3D = ComplexUtils.polar2Complex(r3D, theta3D); - Assertions.assertEquals(r3D.length, observed3D.length); - for (int i = 0; i < r3D.length; i++) { - TestUtils.assertSame(msg, ComplexUtils.polar2Complex(r3D[i], theta3D[i]), observed3D[i]); - } - } - - private Complex altPolar(double r, double theta) { - return Complex.I.multiply(Complex.ofCartesian(theta, 0)).exp().multiply(Complex.ofCartesian(r, 0)); - } - - @Test - void testPolar2ComplexIllegalModulus() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.polar2Complex(-1, 0) - ); - } - - @Test - void testPolar2ComplexIllegalModulus1D() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.polar2Complex(new double[]{0, -1, 2}, new double[]{0, 1, 2}) - ); - } - - @Test - void testPolar2ComplexIllegalModulus2D() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.polar2Complex(new double[][]{{0, 2, 2}, {0, -1, 2}}, new double[][]{{0, 1, 2}, {0, 1, 2}}) - ); - } - - @Test - void testPolar2ComplexIllegalModulus3D() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.polar2Complex(new double[][][]{{{0, 2, 2}}, {{0, -1, 2}}}, new double[][][]{{{0, 1, 2}}, {{0, 1, 2}}}) - ); - } - - @Test - void testPolar2ComplexNaN() { - TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(nan, 1)); - TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(1, nan)); - TestUtils.assertSame(NAN, ComplexUtils.polar2Complex(nan, nan)); - } - - @Test - 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 - 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++) { - Assertions.assertEquals(real[i], complex[i].getReal()); - } - } - - // EXTRACTION METHODS - - @Test - void testExtractionMethods() { - setArrays(); - // Extract complex from real double array, index 3 - TestUtils.assertSame(Complex.ofCartesian(3, 0), ComplexUtils.extractComplexFromRealArray(d, 3)); - // Extract complex from real float array, index 3 - TestUtils.assertSame(Complex.ofCartesian(3, 0), ComplexUtils.extractComplexFromRealArray(f, 3)); - // Extract complex from real double array, index 3 - TestUtils.assertSame(Complex.ofCartesian(0, 3), ComplexUtils.extractComplexFromImaginaryArray(d, 3)); - // Extract complex from real float array, index 3 - TestUtils.assertSame(Complex.ofCartesian(0, 3), ComplexUtils.extractComplexFromImaginaryArray(f, 3)); - // Extract real double from complex array, index 3 - Assertions.assertEquals(6, ComplexUtils.extractRealFromComplexArray(c, 3)); - // Extract real float from complex array, index 3 - Assertions.assertEquals(6, ComplexUtils.extractRealFloatFromComplexArray(c, 3)); - // Extract real double from complex array, index 3 - Assertions.assertEquals(7, ComplexUtils.extractImaginaryFromComplexArray(c, 3)); - // Extract real float from complex array, index 3 - Assertions.assertEquals(7, ComplexUtils.extractImaginaryFloatFromComplexArray(c, 3)); - // Extract complex from interleaved double array, index 3 - TestUtils.assertSame(Complex.ofCartesian(6, 7), ComplexUtils.extractComplexFromInterleavedArray(d, 3)); - // Extract interleaved double array from complex array, index 3 - Assertions.assertArrayEquals(new double[]{6d, 7d}, ComplexUtils.extractInterleavedFromComplexArray(c, 3)); - // Extract interleaved float array from complex array, index 3 - Assertions.assertArrayEquals(new float[]{6f, 7f}, ComplexUtils.extractInterleavedFloatFromComplexArray(c, 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 - Assertions.assertArrayEquals(new double[] {6, 7}, ComplexUtils.extractInterleavedFromComplexArray(c, 3), - Math.ulp(1), msg); - // Extract interleaved float from complex array, index 3 - Assertions.assertArrayEquals(new double[] {6, 7}, ComplexUtils.extractInterleavedFromComplexArray(c, 3), - Math.ulp(1), msg); - } - // REAL <-> COMPLEX - - @Test - void testRealToComplex() { - setArrays(); - // 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 - TestUtils.assertEquals(msg, cr2d, ComplexUtils.real2Complex(sr2d), 0); - TestUtils.assertEquals(msg, cr2d, ComplexUtils.real2Complex(sfr2d), 0); - - // 3d - TestUtils.assertEquals(msg, cr3d, ComplexUtils.real2Complex(sr3d), 0); - TestUtils.assertEquals(msg, cr3d, ComplexUtils.real2Complex(sfr3d), 0); - - // 4d - TestUtils.assertEquals(msg, cr4d, ComplexUtils.real2Complex(sr4d), 0); - } - - @Test - void testComplexToReal() { - setArrays(); - // Real complex to double, whole array - Assertions.assertArrayEquals(sr, ComplexUtils.complex2Real(c), Math.ulp(1.0), msg); - // Real complex to float, whole array - Assertions.assertArrayEquals(sfr, ComplexUtils.complex2RealFloat(c), Math.ulp(1.0f), msg); - - // 2d - TestUtils.assertEquals(msg, sr2d, ComplexUtils.complex2Real(cr2d), 0); - TestUtils.assertEquals(msg, sfr2d, ComplexUtils.complex2RealFloat(cr2d), 0); - - // 3d - TestUtils.assertEquals(msg, sr3d, ComplexUtils.complex2Real(cr3d), 0); - TestUtils.assertEquals(msg, sfr3d, ComplexUtils.complex2RealFloat(cr3d), 0); - - // 4d - TestUtils.assertEquals(msg, sr4d, ComplexUtils.complex2Real(cr4d), 0); - TestUtils.assertEquals(msg, sfr4d, ComplexUtils.complex2RealFloat(cr4d), 0); - } - - // IMAGINARY <-> COMPLEX - - @Test - 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 - TestUtils.assertEquals(msg, ci2d, ComplexUtils.imaginary2Complex(si2d), 0); - - // 3d - TestUtils.assertEquals(msg, ci3d, ComplexUtils.imaginary2Complex(si3d), 0); - - // 4d - TestUtils.assertEquals(msg, ci4d, ComplexUtils.imaginary2Complex(si4d), 0); - } - - @Test - void testComplexToImaginary() { - setArrays(); - // Imaginary complex to double, whole array - Assertions.assertArrayEquals(si, ComplexUtils.complex2Imaginary(c), Math.ulp(1.0), msg); - // Imaginary complex to float, whole array - Assertions.assertArrayEquals(sfi, ComplexUtils.complex2ImaginaryFloat(c), Math.ulp(1.0f), msg); - - // 2d - TestUtils.assertEquals(msg, si2d, ComplexUtils.complex2Imaginary(ci2d), 0); - TestUtils.assertEquals(msg, sfi2d, ComplexUtils.complex2ImaginaryFloat(ci2d), 0); - - // 3d - TestUtils.assertEquals(msg, si3d, ComplexUtils.complex2Imaginary(ci3d), 0); - TestUtils.assertEquals(msg, sfi3d, ComplexUtils.complex2ImaginaryFloat(ci3d), 0); - - // 4d - TestUtils.assertEquals(msg, si4d, ComplexUtils.complex2Imaginary(ci4d), 0); - TestUtils.assertEquals(msg, sfi4d, ComplexUtils.complex2ImaginaryFloat(ci4d), 0); - } - - // INTERLEAVED <-> COMPLEX - - @Test - void testComplex2InterleavedIllegalIndex2Dmin() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.complex2Interleaved(c2d, -1) - ); - } - - @Test - void testComplex2InterleavedIllegalIndex2Dmax() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.complex2Interleaved(c2d, 2) - ); - } - - @Test - void testComplex2InterleavedIllegalIndex3Dmin() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.complex2Interleaved(c3d, -1) - ); - } - - @Test - void testComplex2InterleavedIllegalIndex3Dmax() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.complex2Interleaved(c3d, 3) - ); - } - - @Test - void testComplex2InterleavedIllegalIndex4Dmin() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.complex2Interleaved(c4d, -1) - ); - } - - @Test - void testComplex2InterleavedIllegalIndex4Dmax() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.complex2Interleaved(c4d, 4) - ); - } - - @Test - void testComplex2InterleavedFloatIllegalIndex2Dmin() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.complex2InterleavedFloat(c2d, -1) - ); - } - - @Test - void testComplex2InterleavedFloatIllegalIndex2Dmax() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.complex2InterleavedFloat(c2d, 2) - ); - } - - @Test - void testComplex2InterleavedFloatIllegalIndex3Dmin() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.complex2InterleavedFloat(c3d, -1) - ); - } - - @Test - void testComplex2InterleavedFloatIllegalIndex3Dmax() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.complex2InterleavedFloat(c3d, 3) - ); - } - - @Test - void testInterleaved2ComplexIllegalIndex2Dmin() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.interleaved2Complex(di2d0, -1) - ); - } - - @Test - void testInterleaved2ComplexIllegalIndex2Dmax() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.interleaved2Complex(di2d0, 2) - ); - } - - @Test - void testInterleaved2ComplexIllegalIndex3Dmin() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.interleaved2Complex(di3d0, -1) - ); - } - - @Test - void testInterleaved2ComplexIllegalIndex3Dmax() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.interleaved2Complex(di3d0, 3) - ); - } - - @Test - void testInterleaved2ComplexIllegalIndex4Dmin() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.interleaved2Complex(di4d0, -1) - ); - } - - @Test - void testInterleaved2ComplexIllegalIndex4Dmax() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.interleaved2Complex(di4d0, 4) - ); - } - - @Test - void testInterleaved2ComplexFloatIllegalIndex2Dmin() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.interleaved2Complex(fi2d0, -1) - ); - } - - @Test - void testInterleaved2ComplexFloatIllegalIndex2Dmax() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.interleaved2Complex(fi2d0, 2) - ); - } - - @Test - void testInterleaved2ComplexFloatIllegalIndex3Dmin() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.interleaved2Complex(fi3d0, -1) - ); - } - - @Test - void testInterleaved2ComplexFloatIllegalIndex3Dmax() { - Assertions.assertThrows(IllegalArgumentException.class, - () -> ComplexUtils.interleaved2Complex(fi3d0, 3) - ); - } - - @Test - 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 - TestUtils.assertSame(msg, c2d, ComplexUtils.interleaved2Complex(di2d0, 0)); - TestUtils.assertSame(msg, c2d, ComplexUtils.interleaved2Complex(di2d1, 1)); - TestUtils.assertSame(msg, c2d, ComplexUtils.interleaved2Complex(di2d1)); - - TestUtils.assertSame(msg, c2d, ComplexUtils.interleaved2Complex(fi2d0, 0)); - TestUtils.assertSame(msg, c2d, ComplexUtils.interleaved2Complex(fi2d1, 1)); - TestUtils.assertSame(msg, c2d, ComplexUtils.interleaved2Complex(fi2d1)); - - // 3d - TestUtils.assertSame(msg, c3d, ComplexUtils.interleaved2Complex(di3d0, 0)); - TestUtils.assertSame(msg, c3d, ComplexUtils.interleaved2Complex(di3d1, 1)); - TestUtils.assertSame(msg, c3d, ComplexUtils.interleaved2Complex(di3d2, 2)); - TestUtils.assertSame(msg, c3d, ComplexUtils.interleaved2Complex(di3d2)); - - TestUtils.assertSame(msg, c3d, ComplexUtils.interleaved2Complex(fi3d0, 0)); - TestUtils.assertSame(msg, c3d, ComplexUtils.interleaved2Complex(fi3d1, 1)); - TestUtils.assertSame(msg, c3d, ComplexUtils.interleaved2Complex(fi3d2, 2)); - TestUtils.assertSame(msg, c3d, ComplexUtils.interleaved2Complex(fi3d2)); - - // 4d - TestUtils.assertSame(msg, c4d, ComplexUtils.interleaved2Complex(di4d0, 0)); - TestUtils.assertSame(msg, c4d, ComplexUtils.interleaved2Complex(di4d1, 1)); - TestUtils.assertSame(msg, c4d, ComplexUtils.interleaved2Complex(di4d2, 2)); - TestUtils.assertSame(msg, c4d, ComplexUtils.interleaved2Complex(di4d3, 3)); - } - - @Test - void testComplexToInterleaved() { - setArrays(); - Assertions.assertArrayEquals(di, ComplexUtils.complex2Interleaved(c), Math.ulp(1.0), msg); - // Interleaved complex to float, whole array - Assertions.assertArrayEquals(fi, ComplexUtils.complex2InterleavedFloat(c), Math.ulp(1.0f), msg); - - // 2d - TestUtils.assertEquals(msg, di2d0, ComplexUtils.complex2Interleaved(c2d, 0), 0); - TestUtils.assertEquals(msg, di2d1, ComplexUtils.complex2Interleaved(c2d, 1), 0); - TestUtils.assertEquals(msg, di2d1, ComplexUtils.complex2Interleaved(c2d), 0); - - TestUtils.assertEquals(msg, fi2d0, ComplexUtils.complex2InterleavedFloat(c2d, 0), 0); - TestUtils.assertEquals(msg, fi2d1, ComplexUtils.complex2InterleavedFloat(c2d, 1), 0); - TestUtils.assertEquals(msg, fi2d1, ComplexUtils.complex2InterleavedFloat(c2d), 0); - - // 3d - TestUtils.assertEquals(msg, di3d0, ComplexUtils.complex2Interleaved(c3d, 0), 0); - TestUtils.assertEquals(msg, di3d1, ComplexUtils.complex2Interleaved(c3d, 1), 0); - TestUtils.assertEquals(msg, di3d2, ComplexUtils.complex2Interleaved(c3d, 2), 0); - TestUtils.assertEquals(msg, di3d2, ComplexUtils.complex2Interleaved(c3d), 0); - - TestUtils.assertEquals(msg, fi3d0, ComplexUtils.complex2InterleavedFloat(c3d, 0), 0); - TestUtils.assertEquals(msg, fi3d1, ComplexUtils.complex2InterleavedFloat(c3d, 1), 0); - TestUtils.assertEquals(msg, fi3d2, ComplexUtils.complex2InterleavedFloat(c3d, 2), 0); - TestUtils.assertEquals(msg, fi3d2, ComplexUtils.complex2InterleavedFloat(c3d), 0); - - // 4d - TestUtils.assertEquals(msg, di4d0, ComplexUtils.complex2Interleaved(c4d, 0), 0); - TestUtils.assertEquals(msg, di4d1, ComplexUtils.complex2Interleaved(c4d, 1), 0); - TestUtils.assertEquals(msg, di4d2, ComplexUtils.complex2Interleaved(c4d, 2), 0); - TestUtils.assertEquals(msg, di4d3, ComplexUtils.complex2Interleaved(c4d, 3), 0); - TestUtils.assertEquals(msg, di4d3, ComplexUtils.complex2Interleaved(c4d), 0); - } - - // SPLIT TO COMPLEX - @Test - void testSplit2Complex() { - setArrays(); - // Split double to complex, whole array - TestUtils.assertEquals(msg, c, ComplexUtils.split2Complex(sr, si), Math.ulp(1.0)); - - TestUtils.assertSame(msg, c2d, ComplexUtils.split2Complex(sr2d, si2d)); - TestUtils.assertSame(msg, c3d, ComplexUtils.split2Complex(sr3d, si3d)); - TestUtils.assertSame(msg, c4d, ComplexUtils.split2Complex(sr4d, si4d)); - TestUtils.assertSame(msg, c2d, ComplexUtils.split2Complex(sfr2d, sfi2d)); - TestUtils.assertSame(msg, c3d, ComplexUtils.split2Complex(sfr3d, sfi3d)); - } - - // INITIALIZATION METHODS - - @Test - void testInitialize() { - Complex[] complexes = new Complex[10]; - ComplexUtils.initialize(complexes); - for (Complex cc : complexes) { - TestUtils.assertEquals(Complex.ofCartesian(0, 0), cc, Math.ulp(0)); - } - } - - @Test - void testInitialize2d() { - Complex[][] complexes = new Complex[10][10]; - ComplexUtils.initialize(complexes); - for (Complex[] c1 : complexes) { - for (Complex c0 : c1) { - TestUtils.assertEquals(Complex.ofCartesian(0, 0), c0, Math.ulp(0)); - } - } - } - - @Test - void testInitialize3d() { - Complex[][][] complexes = new Complex[10][10][10]; - ComplexUtils.initialize(complexes); - for (Complex[][] c2 : complexes) { - for (Complex[] c1 : c2) { - for (Complex c0 : c1) { - TestUtils.assertEquals(Complex.ofCartesian(0, 0), c0, Math.ulp(0)); - } - } - } - } - - @Test - void testAbs() { - setArrays(); - double[] observed = ComplexUtils.abs(c); - Assertions.assertEquals(c.length, observed.length); - for (int i = 0; i < c.length; i++) { - Assertions.assertEquals(c[i].abs(), observed[i]); - } - } - - @Test - void testArg() { - setArrays(); - double[] observed = ComplexUtils.arg(c); - Assertions.assertEquals(c.length, observed.length); - for (int i = 0; i < c.length; i++) { - Assertions.assertEquals(c[i].arg(), observed[i]); - } - } -} 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 deleted file mode 100644 index ba99de469..000000000 --- a/commons-numbers-complex-streams/src/test/java/org/apache/commons/numbers/complex/streams/TestUtils.java +++ /dev/null @@ -1,208 +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.streams; - -import org.apache.commons.numbers.complex.Complex; -import org.apache.commons.numbers.core.Precision; - -import org.junit.jupiter.api.Assertions; - -/** - * Test utilities. - */ -@SuppressWarnings("WeakerAccess") -final class TestUtils { - /** - * Collection of static methods used in math unit tests. - */ - private TestUtils() { - super(); - } - - /** - * 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(String msg, Complex[] expected, Complex[] actual) { - assertEquals(msg, expected, actual, 0); - } - - /** - * 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(String msg, Complex[][] expected, Complex[][] actual) { - assertEquals(msg, expected, actual, 0); - } - - /** - * 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(String msg, Complex[][][] expected, Complex[][][] actual) { - assertEquals(msg, expected, actual, 0); - } - - /** - * 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(String msg, Complex[][][][] expected, Complex[][][][] actual) { - assertEquals(msg, 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) { - Assertions.assertEquals(expected.getReal(), actual.getReal()); - Assertions.assertEquals(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) { - Assertions.assertEquals(expected.getReal(), actual.getReal(), delta, "Real Values Differ"); - Assertions.assertEquals(expected.getImaginary(), actual.getImaginary(), delta, "Imaginary Values Differ"); - } - - /** verifies that two 2D arrays are close (sup norm) */ - public static void assertEquals(String msg, double[][] expected, double[][] observed, double tolerance) { - assertArrayLengthsEqual(msg, expected.length, observed.length); - for (int i = 0; i < expected.length; i++) { - Assertions.assertArrayEquals(expected[i], observed[i], tolerance, msg + "[" + i + "]"); - } - } - - /** verifies that two 3D arrays are close (sup norm) */ - public static void assertEquals(String msg, double[][][] expected, double[][][] observed, double tolerance) { - assertArrayLengthsEqual(msg, expected.length, observed.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance); - } - } - - /** verifies that two 4D arrays are close (sup norm) */ - public static void assertEquals(String msg, double[][][][] expected, double[][][][] observed, double tolerance) { - assertArrayLengthsEqual(msg, expected.length, observed.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance); - } - } - - /** verifies that two 4D arrays are close (sup norm) */ - public static void assertEquals(String msg, float[][][][] expected, float[][][][] observed, float tolerance) { - assertArrayLengthsEqual(msg, expected.length, observed.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance); - } - } - - /** verifies that two 2D arrays are close (sup norm) */ - public static void assertEquals(String msg, float[][] expected, float[][] observed, float tolerance) { - assertArrayLengthsEqual(msg, expected.length, observed.length); - for (int i = 0; i < expected.length; i++) { - Assertions.assertArrayEquals(expected[i], observed[i], tolerance, msg + "[" + i + "]"); - } - } - - /** verifies that two 3D arrays are close (sup norm) */ - public static void assertEquals(String msg, float[][][] expected, float[][][] observed, float tolerance) { - assertArrayLengthsEqual(msg, expected.length, observed.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance); - } - } - - /** verifies that two arrays are close (sup norm) */ - public static void assertEquals(String msg, Complex[] expected, Complex[] observed, double tolerance) { - assertArrayLengthsEqual(msg, expected.length, observed.length); - StringBuilder out = new StringBuilder(msg); - boolean failure = false; - for (int i = 0; i < expected.length; i++) { - if (!Precision.equalsIncludingNaN(expected[i].getReal(), observed[i].getReal(), tolerance)) { - failure = true; - out.append("\n[").append(i).append("] "); - out.append("Real elements differ. "); - out.append(" expected = "); - out.append(expected[i].getReal()); - out.append(" observed = "); - out.append(observed[i].getReal()); - } - if (!Precision.equalsIncludingNaN(expected[i].getImaginary(), observed[i].getImaginary(), tolerance)) { - failure = true; - out.append("\n[").append(i).append("] "); - out.append("Imaginary elements differ. "); - out.append(" expected = "); - out.append(expected[i].getImaginary()); - out.append(" observed = "); - out.append(observed[i].getImaginary()); - } - } - if (failure) { - Assertions.fail(out.toString()); - } - } - - /** verifies that two 2D arrays are close (sup norm) */ - public static void assertEquals(String msg, Complex[][] expected, Complex[][] observed, double tolerance) { - assertArrayLengthsEqual(msg, expected.length, observed.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance); - } - } - - /** verifies that two 3D arrays are close (sup norm) */ - public static void assertEquals(String msg, Complex[][][] expected, Complex[][][] observed, double tolerance) { - assertArrayLengthsEqual(msg, expected.length, observed.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance); - } - } - - /** verifies that two 4D arrays are close (sup norm) */ - public static void assertEquals(String msg, Complex[][][][] expected, Complex[][][][] observed, double tolerance) { - assertArrayLengthsEqual(msg, expected.length, observed.length); - for (int i = 0; i < expected.length; i++) { - assertEquals(msg + "[" + i + "]", expected[i], observed[i], tolerance); - } - } - - /** - * Assert that the given array lengths are the same - * @param msg Initial message - * @param expectedLength expected array length - * @param observedLength observed array length - */ - private static void assertArrayLengthsEqual(String msg, int expectedLength, int observedLength) { - if (expectedLength != observedLength) { - StringBuilder out = new StringBuilder(msg); - if (msg != null && msg.length() > 0) { - out.append("\n"); - } - out.append("Arrays not same length. \n"); - out.append("expected has length ").append(expectedLength); - out.append(" observed has length = ").append(observedLength); - Assertions.fail(out.toString()); - } - - } -} diff --git a/commons-numbers-complex/pom.xml b/commons-numbers-complex/pom.xml index 76b88ebdd..64c8f25ba 100644 --- a/commons-numbers-complex/pom.xml +++ b/commons-numbers-complex/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-complex diff --git a/commons-numbers-complex/src/site/site.xml b/commons-numbers-complex/src/site/site.xml index d02437fb6..c2946e3bb 100644 --- a/commons-numbers-complex/src/site/site.xml +++ b/commons-numbers-complex/src/site/site.xml @@ -28,12 +28,12 @@ + - diff --git a/commons-numbers-core/pom.xml b/commons-numbers-core/pom.xml index d95db42ab..8d781a08c 100644 --- a/commons-numbers-core/pom.xml +++ b/commons-numbers-core/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-core diff --git a/commons-numbers-core/src/site/site.xml b/commons-numbers-core/src/site/site.xml index 409ad3eb8..bff901176 100644 --- a/commons-numbers-core/src/site/site.xml +++ b/commons-numbers-core/src/site/site.xml @@ -28,12 +28,12 @@ + - diff --git a/commons-numbers-docs/pom.xml b/commons-numbers-docs/pom.xml index 7e8e457d9..b2684f5e0 100644 --- a/commons-numbers-docs/pom.xml +++ b/commons-numbers-docs/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-docs @@ -61,57 +61,57 @@ org.apache.commons commons-numbers-angle - 1.2-SNAPSHOT + 1.2 org.apache.commons commons-numbers-arrays - 1.2-SNAPSHOT + 1.2 org.apache.commons commons-numbers-combinatorics - 1.2-SNAPSHOT + 1.2 org.apache.commons commons-numbers-complex - 1.2-SNAPSHOT + 1.2 org.apache.commons commons-numbers-core - 1.2-SNAPSHOT + 1.2 org.apache.commons commons-numbers-field - 1.2-SNAPSHOT + 1.2 org.apache.commons commons-numbers-fraction - 1.2-SNAPSHOT + 1.2 org.apache.commons commons-numbers-gamma - 1.2-SNAPSHOT + 1.2 org.apache.commons commons-numbers-primes - 1.2-SNAPSHOT + 1.2 org.apache.commons commons-numbers-quaternion - 1.2-SNAPSHOT + 1.2 org.apache.commons commons-numbers-rootfinder - 1.2-SNAPSHOT + 1.2 diff --git a/commons-numbers-examples/examples-jmh/pom.xml b/commons-numbers-examples/examples-jmh/pom.xml index 1df0a51a6..bf1c3b0d1 100644 --- a/commons-numbers-examples/examples-jmh/pom.xml +++ b/commons-numbers-examples/examples-jmh/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-examples - 1.2-SNAPSHOT + 1.2 commons-numbers-examples-jmh diff --git a/commons-numbers-examples/pom.xml b/commons-numbers-examples/pom.xml index 959c46647..5c134c32e 100644 --- a/commons-numbers-examples/pom.xml +++ b/commons-numbers-examples/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-examples diff --git a/commons-numbers-field/pom.xml b/commons-numbers-field/pom.xml index a5210491a..f28d071f3 100644 --- a/commons-numbers-field/pom.xml +++ b/commons-numbers-field/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-field diff --git a/commons-numbers-field/src/site/site.xml b/commons-numbers-field/src/site/site.xml index f1aab2861..2d2f50c2d 100644 --- a/commons-numbers-field/src/site/site.xml +++ b/commons-numbers-field/src/site/site.xml @@ -28,12 +28,12 @@ + - diff --git a/commons-numbers-fraction/pom.xml b/commons-numbers-fraction/pom.xml index aa9a13b31..6075fea6d 100644 --- a/commons-numbers-fraction/pom.xml +++ b/commons-numbers-fraction/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-fraction diff --git a/commons-numbers-fraction/src/site/site.xml b/commons-numbers-fraction/src/site/site.xml index e51f58343..87e834026 100644 --- a/commons-numbers-fraction/src/site/site.xml +++ b/commons-numbers-fraction/src/site/site.xml @@ -28,12 +28,12 @@ + - diff --git a/commons-numbers-gamma/pom.xml b/commons-numbers-gamma/pom.xml index 71d01af6a..60f164ba8 100644 --- a/commons-numbers-gamma/pom.xml +++ b/commons-numbers-gamma/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-gamma diff --git a/commons-numbers-gamma/src/site/site.xml b/commons-numbers-gamma/src/site/site.xml index d5f5fbe24..bc45ab74b 100644 --- a/commons-numbers-gamma/src/site/site.xml +++ b/commons-numbers-gamma/src/site/site.xml @@ -28,12 +28,12 @@ + - diff --git a/commons-numbers-primes/pom.xml b/commons-numbers-primes/pom.xml index ebe3ea681..4c1d3bee2 100644 --- a/commons-numbers-primes/pom.xml +++ b/commons-numbers-primes/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-primes diff --git a/commons-numbers-primes/src/site/site.xml b/commons-numbers-primes/src/site/site.xml index 1f39d2e20..10bc56c80 100644 --- a/commons-numbers-primes/src/site/site.xml +++ b/commons-numbers-primes/src/site/site.xml @@ -28,12 +28,12 @@ + - diff --git a/commons-numbers-quaternion/pom.xml b/commons-numbers-quaternion/pom.xml index ee668bbbc..02f56d846 100644 --- a/commons-numbers-quaternion/pom.xml +++ b/commons-numbers-quaternion/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-quaternion diff --git a/commons-numbers-quaternion/src/site/site.xml b/commons-numbers-quaternion/src/site/site.xml index 699cd8721..4a8e33967 100644 --- a/commons-numbers-quaternion/src/site/site.xml +++ b/commons-numbers-quaternion/src/site/site.xml @@ -28,12 +28,12 @@ + - diff --git a/commons-numbers-rootfinder/pom.xml b/commons-numbers-rootfinder/pom.xml index c70b6792d..30201e6d7 100644 --- a/commons-numbers-rootfinder/pom.xml +++ b/commons-numbers-rootfinder/pom.xml @@ -21,7 +21,7 @@ org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers-rootfinder diff --git a/commons-numbers-rootfinder/src/site/site.xml b/commons-numbers-rootfinder/src/site/site.xml index 48ec5ada7..11d11c8af 100644 --- a/commons-numbers-rootfinder/src/site/site.xml +++ b/commons-numbers-rootfinder/src/site/site.xml @@ -28,12 +28,12 @@ + - diff --git a/dist-archive/pom.xml b/dist-archive/pom.xml index e1bf4f89c..acbfab0fa 100644 --- a/dist-archive/pom.xml +++ b/dist-archive/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.commons commons-numbers-parent - 1.2-SNAPSHOT + 1.2 commons-numbers diff --git a/pom.xml b/pom.xml index cfed56fb3..5f4b60182 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ commons-numbers-parent - 1.2-SNAPSHOT + 1.2 pom Apache Commons Numbers The Apache Commons Numbers project provides number types and utilities. diff --git a/src/changes/changes.xml b/src/changes/changes.xml index a4bc804ee..932def674 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -53,7 +53,7 @@ If the output is not quite correct, check for invisible trailing spaces! - diff --git a/src/site/resources/release-notes/RELEASE-NOTES-1.2.txt b/src/site/resources/release-notes/RELEASE-NOTES-1.2.txt new file mode 100644 index 000000000..da6844b96 --- /dev/null +++ b/src/site/resources/release-notes/RELEASE-NOTES-1.2.txt @@ -0,0 +1,216 @@ + + Apache Commons Numbers 1.2 RELEASE NOTES + +The Apache Commons Numbers team is pleased to announce the release of Apache Commons Numbers 1.2. + +The Apache Commons Numbers project provides number types and utilities. + +New features, updates and bug fixes. Requires Java 8. + +Changes in this version include: + +New features: +o NUMBERS-206: "Selection": Add selection of the k-th ordered element from an array. +o NUMBERS-205: "Addition/Multiplication": Introduces isZero to Addition and isOne to Multiplication + interfaces. Override the default implementation in implementing classes to avoid + expensive equals(Object) operations. Thanks to Harald Kirsch. +o NUMBERS-203: "DDField": Add a field for the DD number. +o NUMBERS-193: "DD": Add an extended precision floating-point number. A double-double (DD) number + is an unevaluated sum of two IEEE double precision numbers capable of representing + at least 106 bits of significand. +o NUMBERS-192: "Sum": Add subtract(Sum) method. +o NUMBERS-191: "Stirling": Compute Stirling numbers of the first kind. +o NUMBERS-29: Add "Stirling" class to compute Stirling numbers of the second kind. + +Fixed Bugs: +o NUMBERS-204: "Sum": Correct sub-normal round-off computation in sum of products. +o NUMBERS-201: "FP64": Make equals consistent with hashCode. +o NUMBERS-200: "Sum": Avoid a NaN result when combining Sum instances with infinite sums + of the same sign. Thanks to Anirudh Joshi. + +Changes: +o "ArithmeticUtils": Improve performance of GCD for longs. Thanks to Matthias Langer. +o "ArithmeticUtils": Improve performance of remainderUnsigned and divideUnsigned. + Thanks to Sebb, Alex Herbert. +o NUMBERS-199: "Precision": Document inaccurate decimal value representation when converting + to and from a double in the round method. + + +For complete information on Apache Commons Numbers, including instructions on how to submit bug +reports, patches, or suggestions for improvement, see the Apache Commons Numbers website: + +http://commons.apache.org/proper/commons-numbers/ + + +============================================================================= + + Apache Commons Numbers 1.1 RELEASE NOTES + +The Apache Commons Numbers team is pleased to announce the release of +commons-numbers-parent-1.1 + +The Apache Commons Numbers project provides number types and utilities. + +New features, updates and bug fixes. Adds a commons-numbers-bom module. Requires Java 8. + +Changes in this version include: + +New features: +o NUMBERS-70: Add a user guide. +o NUMBERS-190: Add a Bill of Materials (BOM) to aid in dependency management when referencing + multiple Apache Commons Numbers artifacts. The BOM should be used to ensure all + imported artifacts are compatible. +o NUMBERS-181: Updated support for the beta functions. "RegularizedBeta": Added the + complement and derivative of the regularized beta function. + Added "IncompleteBeta" and "Beta" classes. + Functionality is ported from the Boost C++ library. +o NUMBERS-180: "GammaRatio": Compute the ratio of two gamma functions. +o NUMBERS-177: "Erfcx": Compute a scaled complementary error function: + erfcx(z) = erfc(z) * exp(z*z). +o NUMBERS-175: "GeneralizedContinuedFraction": A continued fraction class to compute using a + generator. Allows evaluation of continued fractions from a regular series where + coefficients can be computed iteratively from the previous coefficients. + +Fixed Bugs: +o NUMBERS-185: "Precision": Allow Precision.compareTo using a maxUlps to be used for sorting. + This corrects handling of NaN comparisons. +o NUMBERS-182: "LogBeta": Avoid overflow for tiny arguments. +o "BrentSolver": Avoid overflow creating the initial value between the lower and upper. +o NUMBERS-173: "ContinuedFraction": Set a minimum bound on the relative error epsilon. Prevents + an infinite loop when the epsilon is zero. +o "FactorialDouble": Prevent caching values that are infinite. The cache will support + factorials up to 170. +o NUMBERS-170: "RegularizedBeta": Detect edge cases for arguments that can be evaluated by + exploiting properties of the regularized beta function. +o NUMBERS-168: "BrentSolver": Identify brackets with small objective values. +o Fix wrong javadoc. Thanks to Arturo Bernal. + +Changes: +o NUMBERS-184: "Precision": Reduce number of operations in Precision.equals using a maxUlps. +o NUMBERS-183: Improve the binomial coefficient classes. Avoid recursive method calls. + Avoid overflow for BinomialCoefficientDouble for large results close to infinity. + Use precomputed factorials and the LogBeta function for efficiency. +o NUMBERS-178: "Factorial/FactorialDouble": Tabulate all factorials with exact 64-bit double + representations of n! up to n=170. This change deprecates the FactorialDouble + class and removes obsolete caching functionality. +o NUMBERS-176: "ContinuedFraction": Update to use a shared implementation with + GeneralizedContinuedFraction. +o NUMBERS-174: "Gamma/LogGamma/RegularizedGamma": Update the gamma function implementations to + increase accuracy and support for extreme values. + Functionality is ported from the Boost C++ library. +o NUMBERS-172: "Erf/Erfc": Use a rational function approximation accurate to 53-bits of precision. + This replaces the use of the regularized gamma functions P and Q and increases accuracy + at extreme limits of the function. Execution speed is improved. + Functionality is ported from the Boost C++ library. +o NUMBERS-171: "InverseErfc": Support full range of [0, 2]. This lowers the supported + minimum value from 2^-53 to double min value. Execution speed is improved. + Functionality is ported from the Boost C++ library. + + +For complete information on Apache Commons Numbers, including instructions on how to submit bug +reports, patches, or suggestions for improvement, see the Apache Commons Numbers website: + +http://commons.apache.org/proper/commons-numbers/ + + +============================================================================= + + Apache Commons Numbers 1.0 RELEASE NOTES + +The Apache Commons Numbers team is pleased to announce the release of +commons-numbers-parent-1.0 + +The Apache Commons Numbers project provides number types and utilities. + +This is the first official release of Apache Commons Numbers. + +Apache Commons Numbers 1.0 contains the following library modules: + commons-numbers-angle (requires Java 8+) + commons-numbers-arrays (requires Java 8+) + commons-numbers-combinatorics (requires Java 8+) + commons-numbers-complex (requires Java 8+) + commons-numbers-core (requires Java 8+) + commons-numbers-field (requires Java 8+) + commons-numbers-fraction (requires Java 8+) + commons-numbers-gamma (requires Java 8+) + commons-numbers-primes (requires Java 8+) + commons-numbers-quaternion (requires Java 8+) + commons-numbers-rootfinder (requires Java 8+) +N.B. the Performance testing module requires Java 9+. (The unit tests require Java 8+) + +Changes in this version include: + + +Fixed Bugs: +o NUMBERS-153: Use iterative implementation of "trigamma" function. Thanks to Dmitriy Golovashkin + for reporting. Thanks to Gilles Sadowski. +o NUMBERS-150: "Fraction/BigFraction": Fixed pow(int) to handle Integer.MIN_VALUE and throw + ArithmeticException for negative exponents to a fraction of zero. Thanks to Jin Xu. +o NUMBERS-147: Fixed Fraction/BigFraction from(double, int) to support Integer.MIN_VALUE as max + denominator. Thanks to Alex Herbert. + +Changes: +o NUMBERS-163: Combined "LinearCombination" and "Summation" into single "Sum" class. Thanks to + Matt Juntunen. +o NUMBERS-164: Added SortInPlace utility, original from Commons Math. Thanks to Gilles Sadowski. +o NUMBERS-159: Moved "Norms", "LinearCombination", and "Summation" from commons-numbers-arrays + module to commons-numbers-core module. Moved "CosAngle" from commons-numbers-arrays module + to commons-numbers-angle module. Thanks to Matt Juntunen. +o NUMBERS-156: Replaced "SafeNorm" with "Norms". Added "Summation" class for extended precision + summation. Thanks to Matt Juntunen. +o NUMBERS-161: "Angle" replaces "PlaneAngle" and "PlaneAngleRadians". Thanks to Gilles Sadowski. +o NUMBERS-158: Replace angle normalize method with normalizer method that returns operator + instance. Thanks to Gilles Sadowski. +o NUMBERS-157: Adding Reduce operation originally from Commons Math to commons-numbers-angle + module. Thanks to Gilles Sadowski. +o NUMBERS-142: "LinearCombination": Update to use the dot2s algorithm. Avoids construction of an + intermediate array for array dot products. Update the hi-lo splitting algorithm + to use Dekker's split to ensure the product round-off is computed to exact precision. + Thanks to Alex Herbert. +o NUMBERS-154: Precision compareTo method now handles NaN properly to ensure consistent sorting. + Thanks to Gilles Sadowski. +o NUMBERS-149: "Fraction": Port tests from commons-lang Fraction to demonstrate functional + compatibility between the lang and numbers implementation of Fraction. Thanks to Jin Xu. +o NUMBERS-151: "ArithmeticUtils": Refine pow(int, int) and pow(long, int) for edge cases. + Thanks to Jin Xu. + + +For complete information on Apache Commons Numbers, including instructions on how to submit bug +reports, patches, or suggestions for improvement, see the Apache Commons Numbers website: + +http://commons.apache.org/proper/commons-numbers/ + + +============================================================================= + + Apache Commons Numbers 1.0-beta1 RELEASE NOTES + +The Apache Commons Numbers team is pleased to announce the release of +commons-numbers-parent-1.0-beta1 + +The Apache Commons Numbers project provides number types and utilities. + +This is a beta release of Apache Commons Numbers. No guarantees are made regarding the stability +of the API or compatibility with future releases. + +Apache Commons Numbers 1.0-beta1 contains the following library modules: + commons-numbers-angle (requires Java 8+) + commons-numbers-arrays (requires Java 8+) + commons-numbers-combinatorics (requires Java 8+) + commons-numbers-complex (requires Java 8+) + commons-numbers-core (requires Java 8+) + commons-numbers-field (requires Java 8+) + commons-numbers-fraction (requires Java 8+) + commons-numbers-gamma (requires Java 8+) + commons-numbers-primes (requires Java 8+) + commons-numbers-quaternion (requires Java 8+) + commons-numbers-rootfinder (requires Java 8+) + +No changes defined in this version. + +For complete information on Apache Commons Numbers, including instructions on how to submit bug +reports, patches, or suggestions for improvement, see the Apache Commons Numbers website: + +http://commons.apache.org/proper/commons-numbers/ + + diff --git a/src/site/xdoc/download_numbers.xml b/src/site/xdoc/download_numbers.xml index 5fd700bea..daf6a6f7f 100644 --- a/src/site/xdoc/download_numbers.xml +++ b/src/site/xdoc/download_numbers.xml @@ -107,38 +107,38 @@ limitations under the License. failing that using the SHA512 hash (*.sha512 checksum files).

- The KEYS + The KEYS file contains the public PGP keys used by Apache Commons developers to sign releases.

-
+
- - - + + + - - - + + +
commons-numbers-1.1-bin.tar.gzsha512pgpcommons-numbers-1.2-bin.tar.gzsha512pgp
commons-numbers-1.1-bin.zipsha512pgpcommons-numbers-1.2-bin.zipsha512pgp
- - - + + + - - - + + +
commons-numbers-1.1-src.tar.gzsha512pgpcommons-numbers-1.2-src.tar.gzsha512pgp
commons-numbers-1.1-src.zipsha512pgpcommons-numbers-1.2-src.zipsha512pgp
diff --git a/src/site/xdoc/release-history.xml b/src/site/xdoc/release-history.xml index e5c425ad1..9dcfca9fb 100644 --- a/src/site/xdoc/release-history.xml +++ b/src/site/xdoc/release-history.xml @@ -25,7 +25,10 @@ limitations under the License. - + + + +
VersionRelease date (YYYY-MM-DD)Required Java VersionRelease notes
1.02022-11-018+release notes for 1.11.22024-08-128+release notes for 1.2
1.12022-11-018+release notes for 1.1
1.02021-07-178+release notes for 1.0