This is an automated email from the ASF dual-hosted git repository. erans pushed a commit to branch modularized_master in repository https://gitbox.apache.org/repos/asf/commons-math.git
commit 0e81847e45d91cde337e22b8c4a5e223659eb90c Author: Gilles Sadowski <[email protected]> AuthorDate: Wed May 26 23:33:08 2021 +0200 Remove unused class. --- .../apache/commons/math4/legacy/util/FastMath.java | 2 +- .../commons/math4/legacy/util/MathUtils.java | 57 -------------- .../commons/math4/legacy/util/MathUtilsTest.java | 92 ---------------------- 3 files changed, 1 insertion(+), 150 deletions(-) diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/util/FastMath.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/util/FastMath.java index f697f30..07175f4 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/util/FastMath.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/util/FastMath.java @@ -1464,7 +1464,7 @@ public class FastMath { * @param x Argument, must be greater than 0. * @return the value of the logarithm, i.e. the number {@code y} such that * <code>base<sup>y</sup> = x</code>. - * @since 1.2 (previously in {@code MathUtils}, moved as of version 3.0) + * @since 3.0 */ public static double log(double base, double x) { return log(x) / log(base); diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/util/MathUtils.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/util/MathUtils.java deleted file mode 100644 index 47cf8bf..0000000 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/util/MathUtils.java +++ /dev/null @@ -1,57 +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.math4.legacy.util; - -import org.apache.commons.math4.legacy.exception.NotFiniteNumberException; -import org.apache.commons.math4.legacy.exception.NullArgumentException; -import org.apache.commons.math4.legacy.exception.util.Localizable; -import org.apache.commons.math4.legacy.exception.util.LocalizedFormats; - -/** - * Miscellaneous utility functions. - * - */ -public final class MathUtils { - /** - * Class contains only static methods. - */ - private MathUtils() {} - - /** - * <p>Reduce {@code |a - offset|} to the primary interval - * {@code [0, |period|)}.</p> - * - * <p>Specifically, the value returned is <br> - * {@code a - |period| * floor((a - offset) / |period|) - offset}.</p> - * - * <p>If any of the parameters are {@code NaN} or infinite, the result is - * {@code NaN}.</p> - * - * @param a Value to reduce. - * @param period Period. - * @param offset Value that will be mapped to {@code 0}. - * @return the value, within the interval {@code [0 |period|)}, - * that corresponds to {@code a}. - */ - public static double reduce(double a, - double period, - double offset) { - final double p = FastMath.abs(period); - return a - p * FastMath.floor((a - offset) / p) - offset; - } -} diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/util/MathUtilsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/util/MathUtilsTest.java deleted file mode 100644 index 5743964..0000000 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/util/MathUtilsTest.java +++ /dev/null @@ -1,92 +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.math4.legacy.util; - -import org.junit.Assert; -import org.junit.Test; - -import org.apache.commons.numbers.angle.PlaneAngleRadians; - -/** - * Test cases for the MathUtils class. - * - */ -public final class MathUtilsTest { - @Test - public void testReduce() { - final double period = -12.222; - final double offset = 13; - - final double delta = 1.5; - - double orig = offset + 122456789 * period + delta; - double expected = delta; - Assert.assertEquals(expected, - MathUtils.reduce(orig, period, offset), - 1e-7); - Assert.assertEquals(expected, - MathUtils.reduce(orig, -period, offset), - 1e-7); - - orig = offset - 123356789 * period - delta; - expected = FastMath.abs(period) - delta; - Assert.assertEquals(expected, - MathUtils.reduce(orig, period, offset), - 1e-6); - Assert.assertEquals(expected, - MathUtils.reduce(orig, -period, offset), - 1e-6); - - orig = offset - 123446789 * period + delta; - expected = delta; - Assert.assertEquals(expected, - MathUtils.reduce(orig, period, offset), - 1e-6); - Assert.assertEquals(expected, - MathUtils.reduce(orig, -period, offset), - 1e-6); - - Assert.assertTrue(Double.isNaN(MathUtils.reduce(orig, Double.NaN, offset))); - Assert.assertTrue(Double.isNaN(MathUtils.reduce(Double.NaN, period, offset))); - Assert.assertTrue(Double.isNaN(MathUtils.reduce(orig, period, Double.NaN))); - Assert.assertTrue(Double.isNaN(MathUtils.reduce(orig, period, - Double.POSITIVE_INFINITY))); - Assert.assertTrue(Double.isNaN(MathUtils.reduce(Double.POSITIVE_INFINITY, - period, offset))); - Assert.assertTrue(Double.isNaN(MathUtils.reduce(orig, - Double.POSITIVE_INFINITY, offset))); - Assert.assertTrue(Double.isNaN(MathUtils.reduce(orig, - Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY))); - Assert.assertTrue(Double.isNaN(MathUtils.reduce(Double.POSITIVE_INFINITY, - period, Double.POSITIVE_INFINITY))); - Assert.assertTrue(Double.isNaN(MathUtils.reduce(Double.POSITIVE_INFINITY, - Double.POSITIVE_INFINITY, offset))); - Assert.assertTrue(Double.isNaN(MathUtils.reduce(Double.POSITIVE_INFINITY, - Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY))); - } - - @Test - public void testReduceComparedWithNormalize() { - final double period = 2 * Math.PI; - for (double a = -15; a <= 15; a += 0.5) { - for (double center = -15; center <= 15; center += 1) { - final double nA = PlaneAngleRadians.normalize(a, center); - final double offset = center - Math.PI; - final double r = MathUtils.reduce(a, period, offset) + offset; - Assert.assertEquals("a=" + a + " center=" + center, - nA, r, 52 * Math.ulp(nA)); - } - } - } -}
