Remove unused class.

This commit is contained in:
Gilles Sadowski 2021-05-26 23:33:08 +02:00
parent 2650a4786c
commit 0e81847e45
3 changed files with 1 additions and 150 deletions

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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));
}
}
}
}