MATH-1630: Runtime switch between JDK and CM implementations of the methods defined in "java.lang.Math".
Default is to use the CM implementations in order to retain previous behaviour. When using the JDK implementations, some unit tests fail (on Java 8). Class "AccurateMath" was moved to "o.a.c.math4.core" package. [Unit tests for that class were not moved because they depend on "legacy" classes.]
This commit is contained in:
parent
39c47671f2
commit
21e230ae83
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math4.legacy.core.jdkmath;
|
||||
package org.apache.commons.math4.core.jdkmath;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
|
@ -14,11 +14,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.commons.math4.legacy.core.jdkmath;
|
||||
package org.apache.commons.math4.core.jdkmath;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
|
||||
/** Class used to compute the classical functions tables.
|
||||
* @since 3.0
|
||||
|
@ -647,12 +646,11 @@ final class AccurateMathCalc {
|
|||
* Check two lengths are equal.
|
||||
* @param expectedLen expected length
|
||||
* @param actual actual length
|
||||
* @exception DimensionMismatchException if the two lengths are not equal
|
||||
* @throws IllegalStateException if the two lengths are not equal
|
||||
*/
|
||||
private static void checkLen(int expectedLen, int actual)
|
||||
throws DimensionMismatchException {
|
||||
private static void checkLen(int expectedLen, int actual) {
|
||||
if (expectedLen != actual) {
|
||||
throw new DimensionMismatchException(actual, expectedLen);
|
||||
throw new IllegalStateException(actual + " != " + expectedLen);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.math4.legacy.core.jdkmath;
|
||||
package org.apache.commons.math4.core.jdkmath;
|
||||
|
||||
/**
|
||||
* Utility class for loading tabulated data used by {@link AccurateMath}.
|
File diff suppressed because it is too large
Load Diff
|
@ -44,6 +44,11 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math4-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math4-legacy-exception</artifactId>
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
|
|||
import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Arrays utilities.
|
||||
|
@ -192,7 +192,7 @@ public final class MathArrays {
|
|||
checkEqualLength(p1, p2);
|
||||
double sum = 0;
|
||||
for (int i = 0; i < p1.length; i++) {
|
||||
sum += AccurateMath.abs(p1[i] - p2[i]);
|
||||
sum += JdkMath.abs(p1[i] - p2[i]);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ public final class MathArrays {
|
|||
checkEqualLength(p1, p2);
|
||||
int sum = 0;
|
||||
for (int i = 0; i < p1.length; i++) {
|
||||
sum += AccurateMath.abs(p1[i] - p2[i]);
|
||||
sum += JdkMath.abs(p1[i] - p2[i]);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ public final class MathArrays {
|
|||
final double dp = p1[i] - p2[i];
|
||||
sum += dp * dp;
|
||||
}
|
||||
return AccurateMath.sqrt(sum);
|
||||
return JdkMath.sqrt(sum);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -247,7 +247,7 @@ public final class MathArrays {
|
|||
final double dp = (double) p1[i] - p2[i];
|
||||
sum += dp * dp;
|
||||
}
|
||||
return AccurateMath.sqrt(sum);
|
||||
return JdkMath.sqrt(sum);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,7 +262,7 @@ public final class MathArrays {
|
|||
checkEqualLength(p1, p2);
|
||||
double max = 0;
|
||||
for (int i = 0; i < p1.length; i++) {
|
||||
max = AccurateMath.max(max, AccurateMath.abs(p1[i] - p2[i]));
|
||||
max = JdkMath.max(max, JdkMath.abs(p1[i] - p2[i]));
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ public final class MathArrays {
|
|||
checkEqualLength(p1, p2);
|
||||
int max = 0;
|
||||
for (int i = 0; i < p1.length; i++) {
|
||||
max = AccurateMath.max(max, AccurateMath.abs(p1[i] - p2[i]));
|
||||
max = JdkMath.max(max, JdkMath.abs(p1[i] - p2[i]));
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
@ -845,7 +845,7 @@ public final class MathArrays {
|
|||
// straightforward implementation of the convolution sum
|
||||
for (int n = 0; n < totalLength; n++) {
|
||||
double yn = 0;
|
||||
int k = AccurateMath.max(0, n + 1 - xLen);
|
||||
int k = JdkMath.max(0, n + 1 - xLen);
|
||||
int j = n - k;
|
||||
while (k < hLen && j >= 0) {
|
||||
yn += x[j--] * h[k++];
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.junit.Test;
|
|||
import org.apache.commons.numbers.core.Sum;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElement<T>> {
|
||||
|
||||
|
@ -113,7 +113,7 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
public void testRemainderField() {
|
||||
for (double x = -3; x < 3; x += 0.2) {
|
||||
for (double y = -3; y < 3; y += 0.2) {
|
||||
checkRelative(AccurateMath.IEEEremainder(x, y), build(x).remainder(build(y)));
|
||||
checkRelative(JdkMath.IEEEremainder(x, y), build(x).remainder(build(y)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
public void testRemainderDouble() {
|
||||
for (double x = -3; x < 3; x += 0.2) {
|
||||
for (double y = -3.2; y < 3.2; y += 0.25) {
|
||||
checkRelative(AccurateMath.IEEEremainder(x, y), build(x).remainder(y));
|
||||
checkRelative(JdkMath.IEEEremainder(x, y), build(x).remainder(y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,42 +130,42 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
@Test
|
||||
public void testCos() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.cos(x), build(x).cos());
|
||||
checkRelative(JdkMath.cos(x), build(x).cos());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcos() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.acos(x), build(x).acos());
|
||||
checkRelative(JdkMath.acos(x), build(x).acos());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSin() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.sin(x), build(x).sin());
|
||||
checkRelative(JdkMath.sin(x), build(x).sin());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsin() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.asin(x), build(x).asin());
|
||||
checkRelative(JdkMath.asin(x), build(x).asin());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTan() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.tan(x), build(x).tan());
|
||||
checkRelative(JdkMath.tan(x), build(x).tan());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAtan() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.atan(x), build(x).atan());
|
||||
checkRelative(JdkMath.atan(x), build(x).atan());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
public void testAtan2() {
|
||||
for (double x = -3; x < 3; x += 0.2) {
|
||||
for (double y = -3; y < 3; y += 0.2) {
|
||||
checkRelative(AccurateMath.atan2(x, y), build(x).atan2(build(y)));
|
||||
checkRelative(JdkMath.atan2(x, y), build(x).atan2(build(y)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,56 +181,56 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
@Test
|
||||
public void testCosh() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.cosh(x), build(x).cosh());
|
||||
checkRelative(JdkMath.cosh(x), build(x).cosh());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcosh() {
|
||||
for (double x = 1.1; x < 5.0; x += 0.05) {
|
||||
checkRelative(AccurateMath.acosh(x), build(x).acosh());
|
||||
checkRelative(JdkMath.acosh(x), build(x).acosh());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSinh() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.sinh(x), build(x).sinh());
|
||||
checkRelative(JdkMath.sinh(x), build(x).sinh());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsinh() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.asinh(x), build(x).asinh());
|
||||
checkRelative(JdkMath.asinh(x), build(x).asinh());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTanh() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.tanh(x), build(x).tanh());
|
||||
checkRelative(JdkMath.tanh(x), build(x).tanh());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAtanh() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.atanh(x), build(x).atanh());
|
||||
checkRelative(JdkMath.atanh(x), build(x).atanh());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSqrt() {
|
||||
for (double x = 0.01; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.sqrt(x), build(x).sqrt());
|
||||
checkRelative(JdkMath.sqrt(x), build(x).sqrt());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCbrt() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.cbrt(x), build(x).cbrt());
|
||||
checkRelative(JdkMath.cbrt(x), build(x).cbrt());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
public void testHypot() {
|
||||
for (double x = -3; x < 3; x += 0.2) {
|
||||
for (double y = -3; y < 3; y += 0.2) {
|
||||
checkRelative(AccurateMath.hypot(x, y), build(x).hypot(build(y)));
|
||||
checkRelative(JdkMath.hypot(x, y), build(x).hypot(build(y)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -249,10 +249,10 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
for (int n = 1; n < 5; ++n) {
|
||||
if (x < 0) {
|
||||
if (n % 2 == 1) {
|
||||
checkRelative(-AccurateMath.pow(-x, 1.0 / n), build(x).rootN(n));
|
||||
checkRelative(-JdkMath.pow(-x, 1.0 / n), build(x).rootN(n));
|
||||
}
|
||||
} else {
|
||||
checkRelative(AccurateMath.pow(x, 1.0 / n), build(x).rootN(n));
|
||||
checkRelative(JdkMath.pow(x, 1.0 / n), build(x).rootN(n));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
public void testPowField() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
for (double y = 0.1; y < 4; y += 0.2) {
|
||||
checkRelative(AccurateMath.pow(x, y), build(x).pow(build(y)));
|
||||
checkRelative(JdkMath.pow(x, y), build(x).pow(build(y)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
public void testPowDouble() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
for (double y = 0.1; y < 4; y += 0.2) {
|
||||
checkRelative(AccurateMath.pow(x, y), build(x).pow(y));
|
||||
checkRelative(JdkMath.pow(x, y), build(x).pow(y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
public void testPowInt() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
for (int n = 0; n < 5; ++n) {
|
||||
checkRelative(AccurateMath.pow(x, n), build(x).pow(n));
|
||||
checkRelative(JdkMath.pow(x, n), build(x).pow(n));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -288,77 +288,77 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
@Test
|
||||
public void testExp() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.exp(x), build(x).exp());
|
||||
checkRelative(JdkMath.exp(x), build(x).exp());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpm1() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.expm1(x), build(x).expm1());
|
||||
checkRelative(JdkMath.expm1(x), build(x).expm1());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLog() {
|
||||
for (double x = 0.01; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.log(x), build(x).log());
|
||||
checkRelative(JdkMath.log(x), build(x).log());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLog1p() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.log1p(x), build(x).log1p());
|
||||
checkRelative(JdkMath.log1p(x), build(x).log1p());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLog10() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.log10(x), build(x).log10());
|
||||
checkRelative(JdkMath.log10(x), build(x).log10());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbs() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.abs(x), build(x).abs());
|
||||
checkRelative(JdkMath.abs(x), build(x).abs());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCeil() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.ceil(x), build(x).ceil());
|
||||
checkRelative(JdkMath.ceil(x), build(x).ceil());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFloor() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.floor(x), build(x).floor());
|
||||
checkRelative(JdkMath.floor(x), build(x).floor());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRint() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.rint(x), build(x).rint());
|
||||
checkRelative(JdkMath.rint(x), build(x).rint());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRound() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
Assert.assertEquals(AccurateMath.round(x), build(x).round());
|
||||
Assert.assertEquals(JdkMath.round(x), build(x).round());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSignum() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
checkRelative(AccurateMath.signum(x), build(x).signum());
|
||||
checkRelative(JdkMath.signum(x), build(x).signum());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
public void testCopySignField() {
|
||||
for (double x = -3; x < 3; x += 0.2) {
|
||||
for (double y = -3; y < 3; y += 0.2) {
|
||||
checkRelative(AccurateMath.copySign(x, y), build(x).copySign(build(y)));
|
||||
checkRelative(JdkMath.copySign(x, y), build(x).copySign(build(y)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
public void testCopySignDouble() {
|
||||
for (double x = -3; x < 3; x += 0.2) {
|
||||
for (double y = -3; y < 3; y += 0.2) {
|
||||
checkRelative(AccurateMath.copySign(x, y), build(x).copySign(y));
|
||||
checkRelative(JdkMath.copySign(x, y), build(x).copySign(y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
public void testScalb() {
|
||||
for (double x = -0.9; x < 0.9; x += 0.05) {
|
||||
for (int n = -100; n < 100; ++n) {
|
||||
checkRelative(AccurateMath.scalb(x, n), build(x).scalb(n));
|
||||
checkRelative(JdkMath.scalb(x, n), build(x).scalb(n));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -514,7 +514,7 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
}
|
||||
|
||||
private void checkRelative(double expected, T obtained) {
|
||||
Assert.assertEquals(expected, obtained.getReal(), 1.0e-15 * (1 + AccurateMath.abs(expected)));
|
||||
Assert.assertEquals(expected, obtained.getReal(), 1.0e-15 * (1 + JdkMath.abs(expected)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.commons.math4.legacy.exception.NotANumberException;
|
|||
import org.apache.commons.math4.legacy.exception.NotPositiveException;
|
||||
import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Test cases for the {@link MathArrays} class.
|
||||
|
@ -394,7 +394,7 @@ public class MathArraysTest {
|
|||
-Double.MAX_VALUE,
|
||||
-1, 0,
|
||||
Double.MIN_VALUE,
|
||||
AccurateMath.ulp(1d),
|
||||
JdkMath.ulp(1d),
|
||||
1, 3, 113, 4769,
|
||||
Double.MAX_VALUE,
|
||||
Double.POSITIVE_INFINITY };
|
||||
|
@ -403,7 +403,7 @@ public class MathArraysTest {
|
|||
-Double.MAX_VALUE,
|
||||
-1, 0,
|
||||
Double.MIN_VALUE,
|
||||
AccurateMath.ulp(1d),
|
||||
JdkMath.ulp(1d),
|
||||
1, 3, 113, 4769,
|
||||
Double.MAX_VALUE,
|
||||
Double.POSITIVE_INFINITY,
|
||||
|
@ -458,7 +458,7 @@ public class MathArraysTest {
|
|||
Assert.assertFalse(MathArrays.equals(new double[] {Double.POSITIVE_INFINITY},
|
||||
new double[] {Double.NEGATIVE_INFINITY}));
|
||||
Assert.assertFalse(MathArrays.equals(new double[] {1d},
|
||||
new double[] {AccurateMath.nextAfter(AccurateMath.nextAfter(1d, 2d), 2d)}));
|
||||
new double[] {JdkMath.nextAfter(JdkMath.nextAfter(1d, 2d), 2d)}));
|
||||
|
||||
}
|
||||
|
||||
|
@ -477,7 +477,7 @@ public class MathArraysTest {
|
|||
Assert.assertFalse(MathArrays.equalsIncludingNaN(new double[] {Double.POSITIVE_INFINITY},
|
||||
new double[] {Double.NEGATIVE_INFINITY}));
|
||||
Assert.assertFalse(MathArrays.equalsIncludingNaN(new double[] {1d},
|
||||
new double[] {AccurateMath.nextAfter(AccurateMath.nextAfter(1d, 2d), 2d)}));
|
||||
new double[] {JdkMath.nextAfter(JdkMath.nextAfter(1d, 2d), 2d)}));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.core.dfp;
|
||||
|
||||
import org.apache.commons.math4.legacy.core.ExtendedFieldElementAbstractTest;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
@ -1570,8 +1570,8 @@ public class DfpTest extends ExtendedFieldElementAbstractTest<Dfp> {
|
|||
DfpField localField = new DfpField(100);
|
||||
Assert.assertEquals(0.0, localField.getZero().toDouble(), Precision.SAFE_MIN);
|
||||
Assert.assertEquals(0.0, localField.newDfp(0.0).toDouble(), Precision.SAFE_MIN);
|
||||
Assert.assertEquals(-1, AccurateMath.copySign(1, localField.newDfp(-0.0).toDouble()), Precision.EPSILON);
|
||||
Assert.assertEquals(+1, AccurateMath.copySign(1, localField.newDfp(+0.0).toDouble()), Precision.EPSILON);
|
||||
Assert.assertEquals(-1, JdkMath.copySign(1, localField.newDfp(-0.0).toDouble()), Precision.EPSILON);
|
||||
Assert.assertEquals(+1, JdkMath.copySign(1, localField.newDfp(+0.0).toDouble()), Precision.EPSILON);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -31,6 +31,10 @@ import org.junit.runner.RunWith;
|
|||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
// Unit test should be moved to module "commons-math-core".
|
||||
// [Currently, it can't be because it depends on "legacy" classes.]
|
||||
import org.apache.commons.math4.core.jdkmath.AccurateMath;
|
||||
|
||||
/**
|
||||
* Test to compare AccurateMath results against StrictMath results for boundary values.
|
||||
* <p>
|
||||
|
|
|
@ -40,9 +40,13 @@ import org.apache.commons.math4.legacy.core.dfp.DfpMath;
|
|||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.rng.simple.RandomSource;
|
||||
|
||||
// Unit test should be moved to module "commons-math-core".
|
||||
// [Currently, it can't be because it depends on "legacy" classes.]
|
||||
import org.apache.commons.math4.core.jdkmath.AccurateMath;
|
||||
|
||||
public class AccurateMathTest {
|
||||
// CHECKSTYLE: stop Regexp
|
||||
// The above comment allowa System.out.print
|
||||
// The above comment allows System.out.print
|
||||
|
||||
private static final double MAX_ERROR_ULP = 0.51;
|
||||
private static final int NUMBER_OF_TRIALS = 1000;
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.legacy.exception.MathInternalError;
|
|||
import org.apache.commons.math4.legacy.exception.NotPositiveException;
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.numbers.combinatorics.FactorialDouble;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/** Class holding "compiled" computation rules for derivative structures.
|
||||
* <p>This class implements the computation rules described in Dan Kalman's paper <a
|
||||
|
@ -199,8 +199,8 @@ public final class DSCompiler {
|
|||
}
|
||||
|
||||
// we need to create more compilers
|
||||
final int maxParameters = AccurateMath.max(parameters, cache == null ? 0 : cache.length);
|
||||
final int maxOrder = AccurateMath.max(order, cache == null ? 0 : cache[0].length);
|
||||
final int maxParameters = JdkMath.max(parameters, cache == null ? 0 : cache.length);
|
||||
final int maxOrder = JdkMath.max(order, cache == null ? 0 : cache[0].length);
|
||||
final DSCompiler[][] newCache = new DSCompiler[maxParameters + 1][maxOrder + 1];
|
||||
|
||||
if (cache != null) {
|
||||
|
@ -212,7 +212,7 @@ public final class DSCompiler {
|
|||
|
||||
// create the array in increasing diagonal order
|
||||
for (int diag = 0; diag <= parameters + order; ++diag) {
|
||||
for (int o = AccurateMath.max(0, diag - parameters); o <= AccurateMath.min(order, diag); ++o) {
|
||||
for (int o = JdkMath.max(0, diag - parameters); o <= JdkMath.min(order, diag); ++o) {
|
||||
final int p = diag - o;
|
||||
if (newCache[p][o] == null) {
|
||||
final DSCompiler valueCompiler = (p == 0) ? null : newCache[p - 1][o];
|
||||
|
@ -610,7 +610,7 @@ public final class DSCompiler {
|
|||
final int destP, final int destO, final int[][] destSizes)
|
||||
throws NumberIsTooLargeException {
|
||||
int[] orders = new int[destP];
|
||||
System.arraycopy(srcDerivativesIndirection[index], 0, orders, 0, AccurateMath.min(srcP, destP));
|
||||
System.arraycopy(srcDerivativesIndirection[index], 0, orders, 0, JdkMath.min(srcP, destP));
|
||||
return getPartialDerivativeIndex(destP, destO, destSizes, orders);
|
||||
}
|
||||
|
||||
|
@ -822,8 +822,8 @@ public final class DSCompiler {
|
|||
final double[] result, final int resultOffset) {
|
||||
|
||||
// compute k such that lhs % rhs = lhs - k rhs
|
||||
final double rem = AccurateMath.IEEEremainder(lhs[lhsOffset], rhs[rhsOffset]);
|
||||
final double k = AccurateMath.rint((lhs[lhsOffset] - rem) / rhs[rhsOffset]);
|
||||
final double rem = JdkMath.IEEEremainder(lhs[lhsOffset], rhs[rhsOffset]);
|
||||
final double k = JdkMath.rint((lhs[lhsOffset] - rem) / rhs[rhsOffset]);
|
||||
|
||||
// set up value
|
||||
result[resultOffset] = rem;
|
||||
|
@ -864,8 +864,8 @@ public final class DSCompiler {
|
|||
Arrays.fill(function, Double.NaN);
|
||||
}
|
||||
} else {
|
||||
function[0] = AccurateMath.pow(a, operand[operandOffset]);
|
||||
final double lnA = AccurateMath.log(a);
|
||||
function[0] = JdkMath.pow(a, operand[operandOffset]);
|
||||
final double lnA = JdkMath.log(a);
|
||||
for (int i = 1; i < function.length; ++i) {
|
||||
function[i] = lnA * function[i - 1];
|
||||
}
|
||||
|
@ -905,7 +905,7 @@ public final class DSCompiler {
|
|||
// create the function value and derivatives
|
||||
// [x^p, px^(p-1), p(p-1)x^(p-2), ... ]
|
||||
double[] function = new double[1 + order];
|
||||
double xk = AccurateMath.pow(operand[operandOffset], p - order);
|
||||
double xk = JdkMath.pow(operand[operandOffset], p - order);
|
||||
for (int i = order; i > 0; --i) {
|
||||
function[i] = xk;
|
||||
xk *= operand[operandOffset];
|
||||
|
@ -947,8 +947,8 @@ public final class DSCompiler {
|
|||
|
||||
if (n > 0) {
|
||||
// strictly positive power
|
||||
final int maxOrder = AccurateMath.min(order, n);
|
||||
double xk = AccurateMath.pow(operand[operandOffset], n - maxOrder);
|
||||
final int maxOrder = JdkMath.min(order, n);
|
||||
double xk = JdkMath.pow(operand[operandOffset], n - maxOrder);
|
||||
for (int i = maxOrder; i > 0; --i) {
|
||||
function[i] = xk;
|
||||
xk *= operand[operandOffset];
|
||||
|
@ -957,7 +957,7 @@ public final class DSCompiler {
|
|||
} else {
|
||||
// strictly negative power
|
||||
final double inv = 1.0 / operand[operandOffset];
|
||||
double xk = AccurateMath.pow(inv, -n);
|
||||
double xk = JdkMath.pow(inv, -n);
|
||||
for (int i = 0; i <= order; ++i) {
|
||||
function[i] = xk;
|
||||
xk *= inv;
|
||||
|
@ -1012,14 +1012,14 @@ public final class DSCompiler {
|
|||
double[] function = new double[1 + order];
|
||||
double xk;
|
||||
if (n == 2) {
|
||||
function[0] = AccurateMath.sqrt(operand[operandOffset]);
|
||||
function[0] = JdkMath.sqrt(operand[operandOffset]);
|
||||
xk = 0.5 / function[0];
|
||||
} else if (n == 3) {
|
||||
function[0] = AccurateMath.cbrt(operand[operandOffset]);
|
||||
function[0] = JdkMath.cbrt(operand[operandOffset]);
|
||||
xk = 1.0 / (3.0 * function[0] * function[0]);
|
||||
} else {
|
||||
function[0] = AccurateMath.pow(operand[operandOffset], 1.0 / n);
|
||||
xk = 1.0 / (n * AccurateMath.pow(function[0], n - 1));
|
||||
function[0] = JdkMath.pow(operand[operandOffset], 1.0 / n);
|
||||
xk = 1.0 / (n * JdkMath.pow(function[0], n - 1));
|
||||
}
|
||||
final double nReciprocal = 1.0 / n;
|
||||
final double xReciprocal = 1.0 / operand[operandOffset];
|
||||
|
@ -1046,7 +1046,7 @@ public final class DSCompiler {
|
|||
|
||||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
Arrays.fill(function, AccurateMath.exp(operand[operandOffset]));
|
||||
Arrays.fill(function, JdkMath.exp(operand[operandOffset]));
|
||||
|
||||
// apply function composition
|
||||
compose(operand, operandOffset, function, result, resultOffset);
|
||||
|
@ -1066,8 +1066,8 @@ public final class DSCompiler {
|
|||
|
||||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
function[0] = AccurateMath.expm1(operand[operandOffset]);
|
||||
Arrays.fill(function, 1, 1 + order, AccurateMath.exp(operand[operandOffset]));
|
||||
function[0] = JdkMath.expm1(operand[operandOffset]);
|
||||
Arrays.fill(function, 1, 1 + order, JdkMath.exp(operand[operandOffset]));
|
||||
|
||||
// apply function composition
|
||||
compose(operand, operandOffset, function, result, resultOffset);
|
||||
|
@ -1087,7 +1087,7 @@ public final class DSCompiler {
|
|||
|
||||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
function[0] = AccurateMath.log(operand[operandOffset]);
|
||||
function[0] = JdkMath.log(operand[operandOffset]);
|
||||
if (order > 0) {
|
||||
double inv = 1.0 / operand[operandOffset];
|
||||
double xk = inv;
|
||||
|
@ -1114,7 +1114,7 @@ public final class DSCompiler {
|
|||
|
||||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
function[0] = AccurateMath.log1p(operand[operandOffset]);
|
||||
function[0] = JdkMath.log1p(operand[operandOffset]);
|
||||
if (order > 0) {
|
||||
double inv = 1.0 / (1.0 + operand[operandOffset]);
|
||||
double xk = inv;
|
||||
|
@ -1141,10 +1141,10 @@ public final class DSCompiler {
|
|||
|
||||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
function[0] = AccurateMath.log10(operand[operandOffset]);
|
||||
function[0] = JdkMath.log10(operand[operandOffset]);
|
||||
if (order > 0) {
|
||||
double inv = 1.0 / operand[operandOffset];
|
||||
double xk = inv / AccurateMath.log(10.0);
|
||||
double xk = inv / JdkMath.log(10.0);
|
||||
for (int i = 1; i <= order; ++i) {
|
||||
function[i] = xk;
|
||||
xk *= -i * inv;
|
||||
|
@ -1169,9 +1169,9 @@ public final class DSCompiler {
|
|||
|
||||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
function[0] = AccurateMath.cos(operand[operandOffset]);
|
||||
function[0] = JdkMath.cos(operand[operandOffset]);
|
||||
if (order > 0) {
|
||||
function[1] = -AccurateMath.sin(operand[operandOffset]);
|
||||
function[1] = -JdkMath.sin(operand[operandOffset]);
|
||||
for (int i = 2; i <= order; ++i) {
|
||||
function[i] = -function[i - 2];
|
||||
}
|
||||
|
@ -1195,9 +1195,9 @@ public final class DSCompiler {
|
|||
|
||||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
function[0] = AccurateMath.sin(operand[operandOffset]);
|
||||
function[0] = JdkMath.sin(operand[operandOffset]);
|
||||
if (order > 0) {
|
||||
function[1] = AccurateMath.cos(operand[operandOffset]);
|
||||
function[1] = JdkMath.cos(operand[operandOffset]);
|
||||
for (int i = 2; i <= order; ++i) {
|
||||
function[i] = -function[i - 2];
|
||||
}
|
||||
|
@ -1221,7 +1221,7 @@ public final class DSCompiler {
|
|||
|
||||
// create the function value and derivatives
|
||||
final double[] function = new double[1 + order];
|
||||
final double t = AccurateMath.tan(operand[operandOffset]);
|
||||
final double t = JdkMath.tan(operand[operandOffset]);
|
||||
function[0] = t;
|
||||
|
||||
if (order > 0) {
|
||||
|
@ -1277,7 +1277,7 @@ public final class DSCompiler {
|
|||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
final double x = operand[operandOffset];
|
||||
function[0] = AccurateMath.acos(x);
|
||||
function[0] = JdkMath.acos(x);
|
||||
if (order > 0) {
|
||||
// the nth order derivative of acos has the form:
|
||||
// dn(acos(x)/dxn = P_n(x) / [1 - x^2]^((2n-1)/2)
|
||||
|
@ -1290,7 +1290,7 @@ public final class DSCompiler {
|
|||
p[0] = -1;
|
||||
final double x2 = x * x;
|
||||
final double f = 1.0 / (1 - x2);
|
||||
double coeff = AccurateMath.sqrt(f);
|
||||
double coeff = JdkMath.sqrt(f);
|
||||
function[1] = coeff * p[0];
|
||||
for (int n = 2; n <= order; ++n) {
|
||||
|
||||
|
@ -1334,7 +1334,7 @@ public final class DSCompiler {
|
|||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
final double x = operand[operandOffset];
|
||||
function[0] = AccurateMath.asin(x);
|
||||
function[0] = JdkMath.asin(x);
|
||||
if (order > 0) {
|
||||
// the nth order derivative of asin has the form:
|
||||
// dn(asin(x)/dxn = P_n(x) / [1 - x^2]^((2n-1)/2)
|
||||
|
@ -1347,7 +1347,7 @@ public final class DSCompiler {
|
|||
p[0] = 1;
|
||||
final double x2 = x * x;
|
||||
final double f = 1.0 / (1 - x2);
|
||||
double coeff = AccurateMath.sqrt(f);
|
||||
double coeff = JdkMath.sqrt(f);
|
||||
function[1] = coeff * p[0];
|
||||
for (int n = 2; n <= order; ++n) {
|
||||
|
||||
|
@ -1391,7 +1391,7 @@ public final class DSCompiler {
|
|||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
final double x = operand[operandOffset];
|
||||
function[0] = AccurateMath.atan(x);
|
||||
function[0] = JdkMath.atan(x);
|
||||
if (order > 0) {
|
||||
// the nth order derivative of atan has the form:
|
||||
// dn(atan(x)/dxn = Q_n(x) / (1 + x^2)^n
|
||||
|
@ -1473,7 +1473,7 @@ public final class DSCompiler {
|
|||
divide(y, yOffset, tmp2, 0, tmp1, 0); // y /(r - x)
|
||||
atan(tmp1, 0, tmp2, 0); // atan(y / (r - x))
|
||||
result[resultOffset] =
|
||||
((tmp2[0] <= 0) ? -AccurateMath.PI : AccurateMath.PI) - 2 * tmp2[0]; // +/-pi - 2 * atan(y / (r - x))
|
||||
((tmp2[0] <= 0) ? -JdkMath.PI : JdkMath.PI) - 2 * tmp2[0]; // +/-pi - 2 * atan(y / (r - x))
|
||||
for (int i = 1; i < tmp2.length; ++i) {
|
||||
result[resultOffset + i] = -2 * tmp2[i]; // +/-pi - 2 * atan(y / (r - x))
|
||||
}
|
||||
|
@ -1481,7 +1481,7 @@ public final class DSCompiler {
|
|||
}
|
||||
|
||||
// fix value to take special cases (+0/+0, +0/-0, -0/+0, -0/-0, +/-infinity) correctly
|
||||
result[resultOffset] = AccurateMath.atan2(y[yOffset], x[xOffset]);
|
||||
result[resultOffset] = JdkMath.atan2(y[yOffset], x[xOffset]);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1498,9 +1498,9 @@ public final class DSCompiler {
|
|||
|
||||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
function[0] = AccurateMath.cosh(operand[operandOffset]);
|
||||
function[0] = JdkMath.cosh(operand[operandOffset]);
|
||||
if (order > 0) {
|
||||
function[1] = AccurateMath.sinh(operand[operandOffset]);
|
||||
function[1] = JdkMath.sinh(operand[operandOffset]);
|
||||
for (int i = 2; i <= order; ++i) {
|
||||
function[i] = function[i - 2];
|
||||
}
|
||||
|
@ -1524,9 +1524,9 @@ public final class DSCompiler {
|
|||
|
||||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
function[0] = AccurateMath.sinh(operand[operandOffset]);
|
||||
function[0] = JdkMath.sinh(operand[operandOffset]);
|
||||
if (order > 0) {
|
||||
function[1] = AccurateMath.cosh(operand[operandOffset]);
|
||||
function[1] = JdkMath.cosh(operand[operandOffset]);
|
||||
for (int i = 2; i <= order; ++i) {
|
||||
function[i] = function[i - 2];
|
||||
}
|
||||
|
@ -1550,7 +1550,7 @@ public final class DSCompiler {
|
|||
|
||||
// create the function value and derivatives
|
||||
final double[] function = new double[1 + order];
|
||||
final double t = AccurateMath.tanh(operand[operandOffset]);
|
||||
final double t = JdkMath.tanh(operand[operandOffset]);
|
||||
function[0] = t;
|
||||
|
||||
if (order > 0) {
|
||||
|
@ -1606,7 +1606,7 @@ public final class DSCompiler {
|
|||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
final double x = operand[operandOffset];
|
||||
function[0] = AccurateMath.acosh(x);
|
||||
function[0] = JdkMath.acosh(x);
|
||||
if (order > 0) {
|
||||
// the nth order derivative of acosh has the form:
|
||||
// dn(acosh(x)/dxn = P_n(x) / [x^2 - 1]^((2n-1)/2)
|
||||
|
@ -1619,7 +1619,7 @@ public final class DSCompiler {
|
|||
p[0] = 1;
|
||||
final double x2 = x * x;
|
||||
final double f = 1.0 / (x2 - 1);
|
||||
double coeff = AccurateMath.sqrt(f);
|
||||
double coeff = JdkMath.sqrt(f);
|
||||
function[1] = coeff * p[0];
|
||||
for (int n = 2; n <= order; ++n) {
|
||||
|
||||
|
@ -1663,7 +1663,7 @@ public final class DSCompiler {
|
|||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
final double x = operand[operandOffset];
|
||||
function[0] = AccurateMath.asinh(x);
|
||||
function[0] = JdkMath.asinh(x);
|
||||
if (order > 0) {
|
||||
// the nth order derivative of asinh has the form:
|
||||
// dn(asinh(x)/dxn = P_n(x) / [x^2 + 1]^((2n-1)/2)
|
||||
|
@ -1676,7 +1676,7 @@ public final class DSCompiler {
|
|||
p[0] = 1;
|
||||
final double x2 = x * x;
|
||||
final double f = 1.0 / (1 + x2);
|
||||
double coeff = AccurateMath.sqrt(f);
|
||||
double coeff = JdkMath.sqrt(f);
|
||||
function[1] = coeff * p[0];
|
||||
for (int n = 2; n <= order; ++n) {
|
||||
|
||||
|
@ -1720,7 +1720,7 @@ public final class DSCompiler {
|
|||
// create the function value and derivatives
|
||||
double[] function = new double[1 + order];
|
||||
final double x = operand[operandOffset];
|
||||
function[0] = AccurateMath.atanh(x);
|
||||
function[0] = JdkMath.atanh(x);
|
||||
if (order > 0) {
|
||||
// the nth order derivative of atanh has the form:
|
||||
// dn(atanh(x)/dxn = Q_n(x) / (1 - x^2)^n
|
||||
|
@ -1806,7 +1806,7 @@ public final class DSCompiler {
|
|||
for (int k = 0; k < orders.length; ++k) {
|
||||
if (orders[k] > 0) {
|
||||
try {
|
||||
term *= AccurateMath.pow(delta[k], orders[k]) / FACTORIAL.value(orders[k]);
|
||||
term *= JdkMath.pow(delta[k], orders[k]) / FACTORIAL.value(orders[k]);
|
||||
} catch (NotPositiveException e) {
|
||||
// this cannot happen
|
||||
throw new MathInternalError(e);
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math4.legacy.core.RealFieldElement;
|
|||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.legacy.exception.MathArithmeticException;
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.math4.legacy.core.MathArrays;
|
||||
|
||||
/** Class representing both the value and the differentials of a function.
|
||||
|
@ -389,7 +389,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
@Override
|
||||
public DerivativeStructure remainder(final double a) {
|
||||
final DerivativeStructure ds = new DerivativeStructure(this);
|
||||
ds.data[0] = AccurateMath.IEEEremainder(ds.data[0], a);
|
||||
ds.data[0] = JdkMath.IEEEremainder(ds.data[0], a);
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
@ -437,7 +437,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
public DerivativeStructure ceil() {
|
||||
return new DerivativeStructure(compiler.getFreeParameters(),
|
||||
compiler.getOrder(),
|
||||
AccurateMath.ceil(data[0]));
|
||||
JdkMath.ceil(data[0]));
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
@ -447,7 +447,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
public DerivativeStructure floor() {
|
||||
return new DerivativeStructure(compiler.getFreeParameters(),
|
||||
compiler.getOrder(),
|
||||
AccurateMath.floor(data[0]));
|
||||
JdkMath.floor(data[0]));
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
@ -457,13 +457,13 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
public DerivativeStructure rint() {
|
||||
return new DerivativeStructure(compiler.getFreeParameters(),
|
||||
compiler.getOrder(),
|
||||
AccurateMath.rint(data[0]));
|
||||
JdkMath.rint(data[0]));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long round() {
|
||||
return AccurateMath.round(data[0]);
|
||||
return JdkMath.round(data[0]);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
@ -473,7 +473,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
public DerivativeStructure signum() {
|
||||
return new DerivativeStructure(compiler.getFreeParameters(),
|
||||
compiler.getOrder(),
|
||||
AccurateMath.signum(data[0]));
|
||||
JdkMath.signum(data[0]));
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
@ -511,7 +511,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
* @return exponent for instance in IEEE754 representation, without bias
|
||||
*/
|
||||
public int getExponent() {
|
||||
return AccurateMath.getExponent(data[0]);
|
||||
return JdkMath.getExponent(data[0]);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
@ -521,7 +521,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
public DerivativeStructure scalb(final int n) {
|
||||
final DerivativeStructure ds = new DerivativeStructure(compiler);
|
||||
for (int i = 0; i < ds.data.length; ++i) {
|
||||
ds.data[i] = AccurateMath.scalb(data[i], n);
|
||||
ds.data[i] = JdkMath.scalb(data[i], n);
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
|
@ -923,7 +923,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
public DerivativeStructure toDegrees() {
|
||||
final DerivativeStructure ds = new DerivativeStructure(compiler);
|
||||
for (int i = 0; i < ds.data.length; ++i) {
|
||||
ds.data[i] = AccurateMath.toDegrees(data[i]);
|
||||
ds.data[i] = JdkMath.toDegrees(data[i]);
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
|
@ -934,7 +934,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
public DerivativeStructure toRadians() {
|
||||
final DerivativeStructure ds = new DerivativeStructure(compiler);
|
||||
for (int i = 0; i < ds.data.length; ++i) {
|
||||
ds.data[i] = AccurateMath.toRadians(data[i]);
|
||||
ds.data[i] = JdkMath.toRadians(data[i]);
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
|
|||
import org.apache.commons.math4.legacy.exception.NotPositiveException;
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/** Univariate functions differentiator using finite differences.
|
||||
* <p>
|
||||
|
@ -156,7 +156,7 @@ public class FiniteDifferencesDifferentiator
|
|||
if (2 * halfSampleSpan >= tUpper - tLower) {
|
||||
throw new NumberIsTooLargeException(2 * halfSampleSpan, tUpper - tLower, false);
|
||||
}
|
||||
final double safety = AccurateMath.ulp(halfSampleSpan);
|
||||
final double safety = JdkMath.ulp(halfSampleSpan);
|
||||
this.tMin = tLower + halfSampleSpan + safety;
|
||||
this.tMax = tUpper - halfSampleSpan - safety;
|
||||
|
||||
|
@ -262,7 +262,7 @@ public class FiniteDifferencesDifferentiator
|
|||
}
|
||||
|
||||
// compute sample position, trying to be centered if possible
|
||||
final double t0 = AccurateMath.max(AccurateMath.min(t.getValue(), tMax), tMin) - halfSampleSpan;
|
||||
final double t0 = JdkMath.max(JdkMath.min(t.getValue(), tMax), tMin) - halfSampleSpan;
|
||||
|
||||
// compute sample points
|
||||
final double[] y = new double[nbPoints];
|
||||
|
@ -305,7 +305,7 @@ public class FiniteDifferencesDifferentiator
|
|||
}
|
||||
|
||||
// compute sample position, trying to be centered if possible
|
||||
final double t0 = AccurateMath.max(AccurateMath.min(t.getValue(), tMax), tMin) - halfSampleSpan;
|
||||
final double t0 = JdkMath.max(JdkMath.min(t.getValue(), tMax), tMin) - halfSampleSpan;
|
||||
|
||||
// compute sample points
|
||||
double[][] y = null;
|
||||
|
@ -359,7 +359,7 @@ public class FiniteDifferencesDifferentiator
|
|||
}
|
||||
|
||||
// compute sample position, trying to be centered if possible
|
||||
final double t0 = AccurateMath.max(AccurateMath.min(t.getValue(), tMax), tMin) - halfSampleSpan;
|
||||
final double t0 = JdkMath.max(JdkMath.min(t.getValue(), tMax), tMin) - halfSampleSpan;
|
||||
|
||||
// compute sample points
|
||||
double[][][] y = null;
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.numbers.core.Precision;
|
|||
import org.apache.commons.math4.legacy.core.Field;
|
||||
import org.apache.commons.math4.legacy.core.FieldElement;
|
||||
import org.apache.commons.math4.legacy.core.RealFieldElement;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* First derivative computation with large number of variables.
|
||||
|
@ -328,7 +328,7 @@ public final class SparseGradient implements RealFieldElement<SparseGradient>, S
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient remainder(final double a) {
|
||||
return new SparseGradient(AccurateMath.IEEEremainder(value, a), derivatives);
|
||||
return new SparseGradient(JdkMath.IEEEremainder(value, a), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -336,8 +336,8 @@ public final class SparseGradient implements RealFieldElement<SparseGradient>, S
|
|||
public SparseGradient remainder(final SparseGradient a) {
|
||||
|
||||
// compute k such that lhs % rhs = lhs - k rhs
|
||||
final double rem = AccurateMath.IEEEremainder(value, a.value);
|
||||
final double k = AccurateMath.rint((value - rem) / a.value);
|
||||
final double rem = JdkMath.IEEEremainder(value, a.value);
|
||||
final double k = JdkMath.rint((value - rem) / a.value);
|
||||
|
||||
return subtract(a.multiply(k));
|
||||
|
||||
|
@ -357,31 +357,31 @@ public final class SparseGradient implements RealFieldElement<SparseGradient>, S
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient ceil() {
|
||||
return createConstant(AccurateMath.ceil(value));
|
||||
return createConstant(JdkMath.ceil(value));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient floor() {
|
||||
return createConstant(AccurateMath.floor(value));
|
||||
return createConstant(JdkMath.floor(value));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient rint() {
|
||||
return createConstant(AccurateMath.rint(value));
|
||||
return createConstant(JdkMath.rint(value));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long round() {
|
||||
return AccurateMath.round(value);
|
||||
return JdkMath.round(value);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient signum() {
|
||||
return createConstant(AccurateMath.signum(value));
|
||||
return createConstant(JdkMath.signum(value));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -409,9 +409,9 @@ public final class SparseGradient implements RealFieldElement<SparseGradient>, S
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient scalb(final int n) {
|
||||
final SparseGradient out = new SparseGradient(AccurateMath.scalb(value, n), Collections.<Integer, Double>emptyMap());
|
||||
final SparseGradient out = new SparseGradient(JdkMath.scalb(value, n), Collections.<Integer, Double>emptyMap());
|
||||
for (Map.Entry<Integer, Double> entry : derivatives.entrySet()) {
|
||||
out.derivatives.put(entry.getKey(), AccurateMath.scalb(entry.getValue(), n));
|
||||
out.derivatives.put(entry.getKey(), JdkMath.scalb(entry.getValue(), n));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
@ -425,8 +425,8 @@ public final class SparseGradient implements RealFieldElement<SparseGradient>, S
|
|||
return createConstant(Double.NaN);
|
||||
} else {
|
||||
|
||||
final int expX = AccurateMath.getExponent(value);
|
||||
final int expY = AccurateMath.getExponent(y.value);
|
||||
final int expX = JdkMath.getExponent(value);
|
||||
final int expY = JdkMath.getExponent(y.value);
|
||||
if (expX > expY + 27) {
|
||||
// y is negligible with respect to x
|
||||
return abs();
|
||||
|
@ -481,14 +481,14 @@ public final class SparseGradient implements RealFieldElement<SparseGradient>, S
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient sqrt() {
|
||||
final double sqrt = AccurateMath.sqrt(value);
|
||||
final double sqrt = JdkMath.sqrt(value);
|
||||
return new SparseGradient(sqrt, 0.5 / sqrt, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient cbrt() {
|
||||
final double cbrt = AccurateMath.cbrt(value);
|
||||
final double cbrt = JdkMath.cbrt(value);
|
||||
return new SparseGradient(cbrt, 1.0 / (3 * cbrt * cbrt), derivatives);
|
||||
}
|
||||
|
||||
|
@ -500,15 +500,15 @@ public final class SparseGradient implements RealFieldElement<SparseGradient>, S
|
|||
} else if (n == 3) {
|
||||
return cbrt();
|
||||
} else {
|
||||
final double root = AccurateMath.pow(value, 1.0 / n);
|
||||
return new SparseGradient(root, 1.0 / (n * AccurateMath.pow(root, n - 1)), derivatives);
|
||||
final double root = JdkMath.pow(value, 1.0 / n);
|
||||
return new SparseGradient(root, 1.0 / (n * JdkMath.pow(root, n - 1)), derivatives);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient pow(final double p) {
|
||||
return new SparseGradient(AccurateMath.pow(value, p), p * AccurateMath.pow(value, p - 1), derivatives);
|
||||
return new SparseGradient(JdkMath.pow(value, p), p * JdkMath.pow(value, p - 1), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -517,7 +517,7 @@ public final class SparseGradient implements RealFieldElement<SparseGradient>, S
|
|||
if (n == 0) {
|
||||
return getField().getOne();
|
||||
} else {
|
||||
final double valueNm1 = AccurateMath.pow(value, n - 1);
|
||||
final double valueNm1 = JdkMath.pow(value, n - 1);
|
||||
return new SparseGradient(value * valueNm1, n * valueNm1, derivatives);
|
||||
}
|
||||
}
|
||||
|
@ -543,28 +543,28 @@ public final class SparseGradient implements RealFieldElement<SparseGradient>, S
|
|||
return x.getField().getZero();
|
||||
}
|
||||
} else {
|
||||
final double ax = AccurateMath.pow(a, x.value);
|
||||
return new SparseGradient(ax, ax * AccurateMath.log(a), x.derivatives);
|
||||
final double ax = JdkMath.pow(a, x.value);
|
||||
return new SparseGradient(ax, ax * JdkMath.log(a), x.derivatives);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient exp() {
|
||||
final double e = AccurateMath.exp(value);
|
||||
final double e = JdkMath.exp(value);
|
||||
return new SparseGradient(e, e, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient expm1() {
|
||||
return new SparseGradient(AccurateMath.expm1(value), AccurateMath.exp(value), derivatives);
|
||||
return new SparseGradient(JdkMath.expm1(value), JdkMath.exp(value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient log() {
|
||||
return new SparseGradient(AccurateMath.log(value), 1.0 / value, derivatives);
|
||||
return new SparseGradient(JdkMath.log(value), 1.0 / value, derivatives);
|
||||
}
|
||||
|
||||
/** Base 10 logarithm.
|
||||
|
@ -572,50 +572,50 @@ public final class SparseGradient implements RealFieldElement<SparseGradient>, S
|
|||
*/
|
||||
@Override
|
||||
public SparseGradient log10() {
|
||||
return new SparseGradient(AccurateMath.log10(value), 1.0 / (AccurateMath.log(10.0) * value), derivatives);
|
||||
return new SparseGradient(JdkMath.log10(value), 1.0 / (JdkMath.log(10.0) * value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient log1p() {
|
||||
return new SparseGradient(AccurateMath.log1p(value), 1.0 / (1.0 + value), derivatives);
|
||||
return new SparseGradient(JdkMath.log1p(value), 1.0 / (1.0 + value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient cos() {
|
||||
return new SparseGradient(AccurateMath.cos(value), -AccurateMath.sin(value), derivatives);
|
||||
return new SparseGradient(JdkMath.cos(value), -JdkMath.sin(value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient sin() {
|
||||
return new SparseGradient(AccurateMath.sin(value), AccurateMath.cos(value), derivatives);
|
||||
return new SparseGradient(JdkMath.sin(value), JdkMath.cos(value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient tan() {
|
||||
final double t = AccurateMath.tan(value);
|
||||
final double t = JdkMath.tan(value);
|
||||
return new SparseGradient(t, 1 + t * t, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient acos() {
|
||||
return new SparseGradient(AccurateMath.acos(value), -1.0 / AccurateMath.sqrt(1 - value * value), derivatives);
|
||||
return new SparseGradient(JdkMath.acos(value), -1.0 / JdkMath.sqrt(1 - value * value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient asin() {
|
||||
return new SparseGradient(AccurateMath.asin(value), 1.0 / AccurateMath.sqrt(1 - value * value), derivatives);
|
||||
return new SparseGradient(JdkMath.asin(value), 1.0 / JdkMath.sqrt(1 - value * value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient atan() {
|
||||
return new SparseGradient(AccurateMath.atan(value), 1.0 / (1 + value * value), derivatives);
|
||||
return new SparseGradient(JdkMath.atan(value), 1.0 / (1 + value * value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -635,12 +635,12 @@ public final class SparseGradient implements RealFieldElement<SparseGradient>, S
|
|||
|
||||
// compute atan2(y, x) = +/- pi - 2 atan(y / (r - x))
|
||||
final SparseGradient tmp = divide(r.subtract(x)).atan().multiply(-2);
|
||||
a = tmp.add(tmp.value <= 0 ? -AccurateMath.PI : AccurateMath.PI);
|
||||
a = tmp.add(tmp.value <= 0 ? -JdkMath.PI : JdkMath.PI);
|
||||
|
||||
}
|
||||
|
||||
// fix value to take special cases (+0/+0, +0/-0, -0/+0, -0/-0, +/-infinity) correctly
|
||||
a.value = AccurateMath.atan2(value, x.value);
|
||||
a.value = JdkMath.atan2(value, x.value);
|
||||
|
||||
return a;
|
||||
|
||||
|
@ -658,52 +658,52 @@ public final class SparseGradient implements RealFieldElement<SparseGradient>, S
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient cosh() {
|
||||
return new SparseGradient(AccurateMath.cosh(value), AccurateMath.sinh(value), derivatives);
|
||||
return new SparseGradient(JdkMath.cosh(value), JdkMath.sinh(value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient sinh() {
|
||||
return new SparseGradient(AccurateMath.sinh(value), AccurateMath.cosh(value), derivatives);
|
||||
return new SparseGradient(JdkMath.sinh(value), JdkMath.cosh(value), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient tanh() {
|
||||
final double t = AccurateMath.tanh(value);
|
||||
final double t = JdkMath.tanh(value);
|
||||
return new SparseGradient(t, 1 - t * t, derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient acosh() {
|
||||
return new SparseGradient(AccurateMath.acosh(value), 1.0 / AccurateMath.sqrt(value * value - 1.0), derivatives);
|
||||
return new SparseGradient(JdkMath.acosh(value), 1.0 / JdkMath.sqrt(value * value - 1.0), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient asinh() {
|
||||
return new SparseGradient(AccurateMath.asinh(value), 1.0 / AccurateMath.sqrt(value * value + 1.0), derivatives);
|
||||
return new SparseGradient(JdkMath.asinh(value), 1.0 / JdkMath.sqrt(value * value + 1.0), derivatives);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public SparseGradient atanh() {
|
||||
return new SparseGradient(AccurateMath.atanh(value), 1.0 / (1.0 - value * value), derivatives);
|
||||
return new SparseGradient(JdkMath.atanh(value), 1.0 / (1.0 - value * value), derivatives);
|
||||
}
|
||||
|
||||
/** Convert radians to degrees, with error of less than 0.5 ULP.
|
||||
* @return instance converted into degrees
|
||||
*/
|
||||
public SparseGradient toDegrees() {
|
||||
return new SparseGradient(AccurateMath.toDegrees(value), AccurateMath.toDegrees(1.0), derivatives);
|
||||
return new SparseGradient(JdkMath.toDegrees(value), JdkMath.toDegrees(1.0), derivatives);
|
||||
}
|
||||
|
||||
/** Convert degrees to radians, with error of less than 0.5 ULP.
|
||||
* @return instance converted into radians
|
||||
*/
|
||||
public SparseGradient toRadians() {
|
||||
return new SparseGradient(AccurateMath.toRadians(value), AccurateMath.toRadians(1.0), derivatives);
|
||||
return new SparseGradient(JdkMath.toRadians(value), JdkMath.toRadians(1.0), derivatives);
|
||||
}
|
||||
|
||||
/** Evaluate Taylor expansion of a sparse gradient.
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.function;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Absolute value function.
|
||||
|
@ -29,6 +29,6 @@ public class Abs implements UnivariateFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.abs(x);
|
||||
return JdkMath.abs(x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Arc-cosine function.
|
||||
|
@ -30,7 +30,7 @@ public class Acos implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.acos(x);
|
||||
return JdkMath.acos(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Hyperbolic arc-cosine function.
|
||||
|
@ -30,7 +30,7 @@ public class Acosh implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.acosh(x);
|
||||
return JdkMath.acosh(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Arc-sine function.
|
||||
|
@ -30,7 +30,7 @@ public class Asin implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.asin(x);
|
||||
return JdkMath.asin(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Hyperbolic arc-sine function.
|
||||
|
@ -30,7 +30,7 @@ public class Asinh implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.asinh(x);
|
||||
return JdkMath.asinh(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Arc-tangent function.
|
||||
|
@ -30,7 +30,7 @@ public class Atan implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.atan(x);
|
||||
return JdkMath.atan(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.function;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.BivariateFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Arc-tangent function.
|
||||
|
@ -29,6 +29,6 @@ public class Atan2 implements BivariateFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double y, double x) {
|
||||
return AccurateMath.atan2(y, x);
|
||||
return JdkMath.atan2(y, x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Hyperbolic arc-tangent function.
|
||||
|
@ -30,7 +30,7 @@ public class Atanh implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.atanh(x);
|
||||
return JdkMath.atanh(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Cube root function.
|
||||
|
@ -30,7 +30,7 @@ public class Cbrt implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.cbrt(x);
|
||||
return JdkMath.cbrt(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.function;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* {@code ceil} function.
|
||||
|
@ -29,6 +29,6 @@ public class Ceil implements UnivariateFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.ceil(x);
|
||||
return JdkMath.ceil(x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Cosine function.
|
||||
|
@ -30,7 +30,7 @@ public class Cos implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.cos(x);
|
||||
return JdkMath.cos(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Hyperbolic cosine function.
|
||||
|
@ -30,7 +30,7 @@ public class Cosh implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.cosh(x);
|
||||
return JdkMath.cosh(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Exponential function.
|
||||
|
@ -30,7 +30,7 @@ public class Exp implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.exp(x);
|
||||
return JdkMath.exp(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* <code>e<sup>x</sup>-1</code> function.
|
||||
|
@ -30,7 +30,7 @@ public class Expm1 implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.expm1(x);
|
||||
return JdkMath.expm1(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.function;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* {@code floor} function.
|
||||
|
@ -29,6 +29,6 @@ public class Floor implements UnivariateFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.floor(x);
|
||||
return JdkMath.floor(x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDiffer
|
|||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
|
||||
/**
|
||||
|
@ -76,7 +76,7 @@ public class Gaussian implements UnivariateDifferentiableFunction {
|
|||
public Gaussian(double mean,
|
||||
double sigma)
|
||||
throws NotStrictlyPositiveException {
|
||||
this(1 / (sigma * AccurateMath.sqrt(2 * Math.PI)), mean, sigma);
|
||||
this(1 / (sigma * JdkMath.sqrt(2 * Math.PI)), mean, sigma);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,7 +194,7 @@ public class Gaussian implements UnivariateDifferentiableFunction {
|
|||
private static double value(double xMinusMean,
|
||||
double norm,
|
||||
double i2s2) {
|
||||
return norm * AccurateMath.exp(-xMinusMean * xMinusMean * i2s2);
|
||||
return norm * JdkMath.exp(-xMinusMean * xMinusMean * i2s2);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
@ -217,7 +217,7 @@ public class Gaussian implements UnivariateDifferentiableFunction {
|
|||
final double[] p = new double[f.length];
|
||||
p[0] = 1;
|
||||
final double u2 = u * u;
|
||||
double coeff = norm * AccurateMath.exp(-0.5 * u2);
|
||||
double coeff = norm * JdkMath.exp(-0.5 * u2);
|
||||
if (coeff <= Precision.SAFE_MIN) {
|
||||
Arrays.fill(f, 0.0);
|
||||
} else {
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStruct
|
|||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* <a href="http://en.wikipedia.org/wiki/Harmonic_oscillator">
|
||||
|
@ -112,7 +112,7 @@ public class HarmonicOscillator implements UnivariateDifferentiableFunction {
|
|||
|
||||
final double xTimesOmegaPlusPhase = omega * x + phase;
|
||||
final double a = HarmonicOscillator.value(xTimesOmegaPlusPhase, 1);
|
||||
final double p = -amplitude * AccurateMath.sin(xTimesOmegaPlusPhase);
|
||||
final double p = -amplitude * JdkMath.sin(xTimesOmegaPlusPhase);
|
||||
final double w = p * x;
|
||||
|
||||
return new double[] { a, w, p };
|
||||
|
@ -147,7 +147,7 @@ public class HarmonicOscillator implements UnivariateDifferentiableFunction {
|
|||
*/
|
||||
private static double value(double xTimesOmegaPlusPhase,
|
||||
double amplitude) {
|
||||
return amplitude * AccurateMath.cos(xTimesOmegaPlusPhase);
|
||||
return amplitude * JdkMath.cos(xTimesOmegaPlusPhase);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
@ -160,9 +160,9 @@ public class HarmonicOscillator implements UnivariateDifferentiableFunction {
|
|||
double[] f = new double[t.getOrder() + 1];
|
||||
|
||||
final double alpha = omega * x + phase;
|
||||
f[0] = amplitude * AccurateMath.cos(alpha);
|
||||
f[0] = amplitude * JdkMath.cos(alpha);
|
||||
if (f.length > 1) {
|
||||
f[1] = -amplitude * omega * AccurateMath.sin(alpha);
|
||||
f[1] = -amplitude * omega * JdkMath.sin(alpha);
|
||||
final double mo2 = - omega * omega;
|
||||
for (int i = 2; i < f.length; ++i) {
|
||||
f[i] = mo2 * f[i - 2];
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Natural logarithm function.
|
||||
|
@ -30,7 +30,7 @@ public class Log implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.log(x);
|
||||
return JdkMath.log(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Base 10 logarithm function.
|
||||
|
@ -31,7 +31,7 @@ public class Log10 implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.log10(x);
|
||||
return JdkMath.log10(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* <code>log(1 + p)</code> function.
|
||||
|
@ -30,7 +30,7 @@ public class Log1p implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.log1p(x);
|
||||
return JdkMath.log1p(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDiffer
|
|||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* <a href="http://en.wikipedia.org/wiki/Generalised_logistic_function">
|
||||
|
@ -147,10 +147,10 @@ public class Logistic implements UnivariateDifferentiableFunction {
|
|||
|
||||
final double mMinusX = param[1] - x;
|
||||
final double oneOverN = 1 / param[5];
|
||||
final double exp = AccurateMath.exp(b * mMinusX);
|
||||
final double exp = JdkMath.exp(b * mMinusX);
|
||||
final double qExp = q * exp;
|
||||
final double qExp1 = qExp + 1;
|
||||
final double factor1 = (param[0] - param[4]) * oneOverN / AccurateMath.pow(qExp1, oneOverN);
|
||||
final double factor1 = (param[0] - param[4]) * oneOverN / JdkMath.pow(qExp1, oneOverN);
|
||||
final double factor2 = -factor1 / qExp1;
|
||||
|
||||
// Components of the gradient.
|
||||
|
@ -159,7 +159,7 @@ public class Logistic implements UnivariateDifferentiableFunction {
|
|||
final double gb = factor2 * mMinusX * qExp;
|
||||
final double gq = factor2 * exp;
|
||||
final double ga = Logistic.value(mMinusX, 0, b, q, 1, oneOverN);
|
||||
final double gn = factor1 * AccurateMath.log(qExp1) * oneOverN;
|
||||
final double gn = factor1 * JdkMath.log(qExp1) * oneOverN;
|
||||
|
||||
return new double[] { gk, gm, gb, gq, ga, gn };
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ public class Logistic implements UnivariateDifferentiableFunction {
|
|||
double q,
|
||||
double a,
|
||||
double oneOverN) {
|
||||
return a + (k - a) / AccurateMath.pow(1 + q * AccurateMath.exp(b * mMinusX), oneOverN);
|
||||
return a + (k - a) / JdkMath.pow(1 + q * JdkMath.exp(b * mMinusX), oneOverN);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDiffer
|
|||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* <a href="http://en.wikipedia.org/wiki/Logit">
|
||||
|
@ -153,7 +153,7 @@ public class Logit implements UnivariateDifferentiableFunction {
|
|||
if (x < lo || x > hi) {
|
||||
throw new OutOfRangeException(x, lo, hi);
|
||||
}
|
||||
return AccurateMath.log((x - lo) / (hi - x));
|
||||
return JdkMath.log((x - lo) / (hi - x));
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
@ -170,7 +170,7 @@ public class Logit implements UnivariateDifferentiableFunction {
|
|||
double[] f = new double[t.getOrder() + 1];
|
||||
|
||||
// function value
|
||||
f[0] = AccurateMath.log((x - lo) / (hi - x));
|
||||
f[0] = JdkMath.log((x - lo) / (hi - x));
|
||||
|
||||
if (Double.isInfinite(f[0])) {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.function;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.BivariateFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Maximum function.
|
||||
|
@ -29,6 +29,6 @@ public class Max implements BivariateFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x, double y) {
|
||||
return AccurateMath.max(x, y);
|
||||
return JdkMath.max(x, y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.function;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.BivariateFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Minimum function.
|
||||
|
@ -29,6 +29,6 @@ public class Min implements BivariateFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x, double y) {
|
||||
return AccurateMath.min(x, y);
|
||||
return JdkMath.min(x, y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.function;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.BivariateFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Power function.
|
||||
|
@ -29,6 +29,6 @@ public class Pow implements BivariateFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x, double y) {
|
||||
return AccurateMath.pow(x, y);
|
||||
return JdkMath.pow(x, y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Power function.
|
||||
|
@ -40,7 +40,7 @@ public class Power implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.pow(x, p);
|
||||
return JdkMath.pow(x, p);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.function;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* {@code rint} function.
|
||||
|
@ -29,6 +29,6 @@ public class Rint implements UnivariateFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.rint(x);
|
||||
return JdkMath.rint(x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStruct
|
|||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* <a href="http://en.wikipedia.org/wiki/Sigmoid_function">
|
||||
|
@ -114,7 +114,7 @@ public class Sigmoid implements UnivariateDifferentiableFunction {
|
|||
DimensionMismatchException {
|
||||
validateParameters(param);
|
||||
|
||||
final double invExp1 = 1 / (1 + AccurateMath.exp(-x));
|
||||
final double invExp1 = 1 / (1 + JdkMath.exp(-x));
|
||||
|
||||
return new double[] { 1 - invExp1, invExp1 };
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ public class Sigmoid implements UnivariateDifferentiableFunction {
|
|||
private static double value(double x,
|
||||
double lo,
|
||||
double hi) {
|
||||
return lo + (hi - lo) / (1 + AccurateMath.exp(-x));
|
||||
return lo + (hi - lo) / (1 + JdkMath.exp(-x));
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
@ -161,7 +161,7 @@ public class Sigmoid implements UnivariateDifferentiableFunction {
|
|||
throws DimensionMismatchException {
|
||||
|
||||
double[] f = new double[t.getOrder() + 1];
|
||||
final double exp = AccurateMath.exp(-t.getValue());
|
||||
final double exp = JdkMath.exp(-t.getValue());
|
||||
if (Double.isInfinite(exp)) {
|
||||
|
||||
// special handling near lower boundary, to avoid NaN
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.function;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* {@code signum} function.
|
||||
|
@ -29,6 +29,6 @@ public class Signum implements UnivariateFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.signum(x);
|
||||
return JdkMath.signum(x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Sine function.
|
||||
|
@ -30,7 +30,7 @@ public class Sin implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.sin(x);
|
||||
return JdkMath.sin(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* <a href="http://en.wikipedia.org/wiki/Sinc_function">Sinc</a> function,
|
||||
|
@ -81,14 +81,14 @@ public class Sinc implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(final double x) {
|
||||
final double scaledX = normalized ? AccurateMath.PI * x : x;
|
||||
if (AccurateMath.abs(scaledX) <= SHORTCUT) {
|
||||
final double scaledX = normalized ? JdkMath.PI * x : x;
|
||||
if (JdkMath.abs(scaledX) <= SHORTCUT) {
|
||||
// use Taylor series
|
||||
final double scaledX2 = scaledX * scaledX;
|
||||
return ((scaledX2 - 20) * scaledX2 + 120) / 120;
|
||||
} else {
|
||||
// use definition expression
|
||||
return AccurateMath.sin(scaledX) / scaledX;
|
||||
return JdkMath.sin(scaledX) / scaledX;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,12 +99,12 @@ public class Sinc implements UnivariateDifferentiableFunction {
|
|||
public DerivativeStructure value(final DerivativeStructure t)
|
||||
throws DimensionMismatchException {
|
||||
|
||||
final double scaledX = (normalized ? AccurateMath.PI : 1) * t.getValue();
|
||||
final double scaledX = (normalized ? JdkMath.PI : 1) * t.getValue();
|
||||
final double scaledX2 = scaledX * scaledX;
|
||||
|
||||
double[] f = new double[t.getOrder() + 1];
|
||||
|
||||
if (AccurateMath.abs(scaledX) <= SHORTCUT) {
|
||||
if (JdkMath.abs(scaledX) <= SHORTCUT) {
|
||||
|
||||
for (int i = 0; i < f.length; ++i) {
|
||||
final int k = i / 2;
|
||||
|
@ -122,8 +122,8 @@ public class Sinc implements UnivariateDifferentiableFunction {
|
|||
} else {
|
||||
|
||||
final double inv = 1 / scaledX;
|
||||
final double cos = AccurateMath.cos(scaledX);
|
||||
final double sin = AccurateMath.sin(scaledX);
|
||||
final double cos = JdkMath.cos(scaledX);
|
||||
final double sin = JdkMath.sin(scaledX);
|
||||
|
||||
f[0] = inv * sin;
|
||||
|
||||
|
@ -182,10 +182,10 @@ public class Sinc implements UnivariateDifferentiableFunction {
|
|||
}
|
||||
|
||||
if (normalized) {
|
||||
double scale = AccurateMath.PI;
|
||||
double scale = JdkMath.PI;
|
||||
for (int i = 1; i < f.length; ++i) {
|
||||
f[i] *= scale;
|
||||
scale *= AccurateMath.PI;
|
||||
scale *= JdkMath.PI;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Hyperbolic sine function.
|
||||
|
@ -30,7 +30,7 @@ public class Sinh implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.sinh(x);
|
||||
return JdkMath.sinh(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Square-root function.
|
||||
|
@ -30,7 +30,7 @@ public class Sqrt implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.sqrt(x);
|
||||
return JdkMath.sqrt(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Tangent function.
|
||||
|
@ -30,7 +30,7 @@ public class Tan implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.tan(x);
|
||||
return JdkMath.tan(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
|
|||
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Hyperbolic tangent function.
|
||||
|
@ -30,7 +30,7 @@ public class Tanh implements UnivariateDifferentiableFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.tanh(x);
|
||||
return JdkMath.tanh(x);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.function;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* {@code ulp} function.
|
||||
|
@ -29,6 +29,6 @@ public class Ulp implements UnivariateFunction {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double value(double x) {
|
||||
return AccurateMath.ulp(x);
|
||||
return JdkMath.ulp(x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.analysis.integration.gauss.GaussIntegrato
|
|||
import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* This algorithm divides the integration interval into equally-sized
|
||||
|
@ -122,10 +122,10 @@ public class IterativeLegendreGaussIntegrator
|
|||
final double t = stage(n);
|
||||
|
||||
// Estimate the error.
|
||||
final double delta = AccurateMath.abs(t - oldt);
|
||||
final double delta = JdkMath.abs(t - oldt);
|
||||
final double limit =
|
||||
AccurateMath.max(getAbsoluteAccuracy(),
|
||||
getRelativeAccuracy() * (AccurateMath.abs(oldt) + AccurateMath.abs(t)) * 0.5);
|
||||
JdkMath.max(getAbsoluteAccuracy(),
|
||||
getRelativeAccuracy() * (JdkMath.abs(oldt) + JdkMath.abs(t)) * 0.5);
|
||||
|
||||
// check convergence
|
||||
if (iterations.getCount() + 1 >= getMinimalIterationCount() &&
|
||||
|
@ -134,8 +134,8 @@ public class IterativeLegendreGaussIntegrator
|
|||
}
|
||||
|
||||
// Prepare next iteration.
|
||||
final double ratio = AccurateMath.min(4, AccurateMath.pow(delta / limit, 0.5 / numberOfPoints));
|
||||
n = AccurateMath.max((int) (ratio * n), n + 1);
|
||||
final double ratio = JdkMath.min(4, JdkMath.pow(delta / limit, 0.5 / numberOfPoints));
|
||||
n = JdkMath.max((int) (ratio * n), n + 1);
|
||||
oldt = t;
|
||||
iterations.increment();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.integration;
|
||||
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Implements the <a href="https://en.wikipedia.org/wiki/Riemann_sum#Midpoint_rule">
|
||||
|
@ -113,7 +113,7 @@ public class MidPointIntegrator extends BaseAbstractUnivariateIntegrator {
|
|||
double diffMaxMin) {
|
||||
// number of points in the previous stage. This stage will contribute
|
||||
// 2*3^{n-1} more points.
|
||||
final long np = (long) AccurateMath.pow(3, n - 1);
|
||||
final long np = (long) JdkMath.pow(3, n - 1);
|
||||
double sum = 0;
|
||||
|
||||
// spacing between adjacent new points
|
||||
|
@ -151,9 +151,9 @@ public class MidPointIntegrator extends BaseAbstractUnivariateIntegrator {
|
|||
final int i = iterations.getCount();
|
||||
final double t = stage(i, oldt, min, diff);
|
||||
if (i >= getMinimalIterationCount()) {
|
||||
final double delta = AccurateMath.abs(t - oldt);
|
||||
final double delta = JdkMath.abs(t - oldt);
|
||||
final double rLimit =
|
||||
getRelativeAccuracy() * (AccurateMath.abs(oldt) + AccurateMath.abs(t)) * 0.5;
|
||||
getRelativeAccuracy() * (JdkMath.abs(oldt) + JdkMath.abs(t)) * 0.5;
|
||||
if ((delta <= rLimit) || (delta <= getAbsoluteAccuracy())) {
|
||||
return t;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.integration;
|
||||
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/RombergIntegration.html">
|
||||
|
@ -120,8 +120,8 @@ public class RombergIntegrator extends BaseAbstractUnivariateIntegrator {
|
|||
}
|
||||
final double s = currentRow[i];
|
||||
if (i >= getMinimalIterationCount()) {
|
||||
final double delta = AccurateMath.abs(s - olds);
|
||||
final double rLimit = getRelativeAccuracy() * (AccurateMath.abs(olds) + AccurateMath.abs(s)) * 0.5;
|
||||
final double delta = JdkMath.abs(s - olds);
|
||||
final double rLimit = getRelativeAccuracy() * (JdkMath.abs(olds) + JdkMath.abs(s)) * 0.5;
|
||||
if ((delta <= rLimit) || (delta <= getAbsoluteAccuracy())) {
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.integration;
|
||||
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Implements <a href="http://mathworld.wolfram.com/SimpsonsRule.html">
|
||||
|
@ -113,8 +113,8 @@ public class SimpsonIntegrator extends BaseAbstractUnivariateIntegrator {
|
|||
final double t = qtrap.stage(this, i + 1); // 1-stage ahead of the iteration
|
||||
final double s = (4 * t - oldt) / 3.0;
|
||||
if (i >= getMinimalIterationCount()) {
|
||||
final double delta = AccurateMath.abs(s - olds);
|
||||
final double rLimit = getRelativeAccuracy() * (AccurateMath.abs(olds) + AccurateMath.abs(s)) * 0.5;
|
||||
final double delta = JdkMath.abs(s - olds);
|
||||
final double rLimit = getRelativeAccuracy() * (JdkMath.abs(olds) + JdkMath.abs(s)) * 0.5;
|
||||
if (delta <= rLimit ||
|
||||
delta <= getAbsoluteAccuracy()) {
|
||||
return s;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.integration;
|
||||
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/TrapezoidalRule.html">
|
||||
|
@ -146,9 +146,9 @@ public class TrapezoidIntegrator extends BaseAbstractUnivariateIntegrator {
|
|||
final int i = iterations.getCount();
|
||||
final double t = stage(this, i);
|
||||
if (i >= getMinimalIterationCount()) {
|
||||
final double delta = AccurateMath.abs(t - oldt);
|
||||
final double delta = JdkMath.abs(t - oldt);
|
||||
final double rLimit =
|
||||
getRelativeAccuracy() * (AccurateMath.abs(oldt) + AccurateMath.abs(t)) * 0.5;
|
||||
getRelativeAccuracy() * (JdkMath.abs(oldt) + JdkMath.abs(t)) * 0.5;
|
||||
if ((delta <= rLimit) || (delta <= getAbsoluteAccuracy())) {
|
||||
return t;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.analysis.integration.gauss;
|
||||
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.math4.legacy.core.Pair;
|
||||
|
||||
/**
|
||||
|
@ -74,8 +74,8 @@ public class HermiteRuleFactory extends BaseRuleFactory<Double> {
|
|||
final Double[] points = new Double[numberOfPoints];
|
||||
final Double[] weights = new Double[numberOfPoints];
|
||||
|
||||
final double sqrtTwoTimesLastNumPoints = AccurateMath.sqrt(2.0 * lastNumPoints);
|
||||
final double sqrtTwoTimesNumPoints = AccurateMath.sqrt(2.0 * numberOfPoints);
|
||||
final double sqrtTwoTimesLastNumPoints = JdkMath.sqrt(2.0 * lastNumPoints);
|
||||
final double sqrtTwoTimesNumPoints = JdkMath.sqrt(2.0 * numberOfPoints);
|
||||
|
||||
// Find i-th root of H[n+1] by bracketing.
|
||||
final int iMax = numberOfPoints / 2;
|
||||
|
@ -96,8 +96,8 @@ public class HermiteRuleFactory extends BaseRuleFactory<Double> {
|
|||
for (int j = 1; j < numberOfPoints; j++) {
|
||||
// Compute H[j+1](a) and H[j+1](b)
|
||||
final double jp1 = j + 1.0;
|
||||
final double s = AccurateMath.sqrt(2 / jp1);
|
||||
final double sm = AccurateMath.sqrt(j / jp1);
|
||||
final double s = JdkMath.sqrt(2 / jp1);
|
||||
final double sm = JdkMath.sqrt(j / jp1);
|
||||
final double hpa = s * a * ha - sm * hma;
|
||||
final double hpb = s * b * hb - sm * hmb;
|
||||
hma = ha;
|
||||
|
@ -121,8 +121,8 @@ public class HermiteRuleFactory extends BaseRuleFactory<Double> {
|
|||
for (int j = 1; j < numberOfPoints; j++) {
|
||||
// Compute H[j+1](c)
|
||||
final double jp1 = j + 1.0;
|
||||
final double s = AccurateMath.sqrt(2 / jp1);
|
||||
final double sm = AccurateMath.sqrt(j / jp1);
|
||||
final double s = JdkMath.sqrt(2 / jp1);
|
||||
final double sm = JdkMath.sqrt(j / jp1);
|
||||
final double hpc = s * c * hc - sm * hmc;
|
||||
hmc = hc;
|
||||
hc = hpc;
|
||||
|
@ -160,7 +160,7 @@ public class HermiteRuleFactory extends BaseRuleFactory<Double> {
|
|||
double hm = H0;
|
||||
for (int j = 1; j < numberOfPoints; j += 2) {
|
||||
final double jp1 = j + 1.0;
|
||||
hm = -AccurateMath.sqrt(j / jp1) * hm;
|
||||
hm = -JdkMath.sqrt(j / jp1) * hm;
|
||||
}
|
||||
final double d = sqrtTwoTimesNumPoints * hm;
|
||||
final double w = 2 / (d * d);
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException;
|
|||
import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.math4.legacy.core.MathArrays;
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
|
||||
|
@ -123,11 +123,11 @@ public class AkimaSplineInterpolator
|
|||
for (int i = 1; i < weights.length; i++) {
|
||||
final double a = differences[i];
|
||||
final double b = differences[i - 1];
|
||||
weights[i] = AccurateMath.abs(a - b) + 0.5 * AccurateMath.abs(a + b);
|
||||
weights[i] = JdkMath.abs(a - b) + 0.5 * JdkMath.abs(a + b);
|
||||
}
|
||||
} else {
|
||||
for (int i = 1; i < weights.length; i++) {
|
||||
weights[i] = AccurateMath.abs(differences[i] - differences[i - 1]);
|
||||
weights[i] = JdkMath.abs(differences[i] - differences[i - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math4.legacy.exception.NotPositiveException;
|
|||
import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
|
||||
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.math4.legacy.core.MathArrays;
|
||||
|
||||
/**
|
||||
|
@ -224,13 +224,13 @@ public class InterpolatingMicrosphere {
|
|||
final double[] diff = MathArrays.ebeSubtract(samplePoints[i], point);
|
||||
final double diffNorm = Norm.L2.of(diff);
|
||||
|
||||
if (AccurateMath.abs(diffNorm) < noInterpolationTolerance) {
|
||||
if (JdkMath.abs(diffNorm) < noInterpolationTolerance) {
|
||||
// No need to interpolate, as the interpolation point is
|
||||
// actually (very close to) one of the sampled points.
|
||||
return sampleValues[i];
|
||||
}
|
||||
|
||||
final double weight = AccurateMath.pow(diffNorm, -exponent);
|
||||
final double weight = JdkMath.pow(diffNorm, -exponent);
|
||||
illuminate(diff, sampleValues[i], weight);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.analysis.interpolation;
|
||||
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Utility class for the {@link MicrosphereProjectionInterpolator} algorithm.
|
||||
|
@ -60,8 +60,8 @@ public class InterpolatingMicrosphere2D extends InterpolatingMicrosphere {
|
|||
for (int i = 0; i < size; i++) {
|
||||
final double angle = i * twopi / size;
|
||||
|
||||
add(new double[] { AccurateMath.cos(angle),
|
||||
AccurateMath.sin(angle) },
|
||||
add(new double[] { JdkMath.cos(angle),
|
||||
JdkMath.sin(angle) },
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.legacy.exception.NotPositiveException;
|
|||
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.math4.legacy.core.MathArrays;
|
||||
|
||||
/**
|
||||
|
@ -296,7 +296,7 @@ public class LoessInterpolator
|
|||
double sumXSquared = 0;
|
||||
double sumY = 0;
|
||||
double sumXY = 0;
|
||||
double denom = AccurateMath.abs(1.0 / (xval[edge] - x));
|
||||
double denom = JdkMath.abs(1.0 / (xval[edge] - x));
|
||||
for (int k = ileft; k <= iright; ++k) {
|
||||
final double xk = xval[k];
|
||||
final double yk = yval[k];
|
||||
|
@ -316,7 +316,7 @@ public class LoessInterpolator
|
|||
final double meanXSquared = sumXSquared / sumWeights;
|
||||
|
||||
final double beta;
|
||||
if (AccurateMath.sqrt(AccurateMath.abs(meanXSquared - meanX * meanX)) < accuracy) {
|
||||
if (JdkMath.sqrt(JdkMath.abs(meanXSquared - meanX * meanX)) < accuracy) {
|
||||
beta = 0;
|
||||
} else {
|
||||
beta = (meanXY - meanX * meanY) / (meanXSquared - meanX * meanX);
|
||||
|
@ -325,7 +325,7 @@ public class LoessInterpolator
|
|||
final double alpha = meanY - beta * meanX;
|
||||
|
||||
res[i] = beta * x + alpha;
|
||||
residuals[i] = AccurateMath.abs(yval[i] - res[i]);
|
||||
residuals[i] = JdkMath.abs(yval[i] - res[i]);
|
||||
}
|
||||
|
||||
// No need to recompute the robustness weights at the last
|
||||
|
@ -343,7 +343,7 @@ public class LoessInterpolator
|
|||
Arrays.sort(sortedResiduals);
|
||||
final double medianResidual = sortedResiduals[n / 2];
|
||||
|
||||
if (AccurateMath.abs(medianResidual) < accuracy) {
|
||||
if (JdkMath.abs(medianResidual) < accuracy) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,7 @@ public class LoessInterpolator
|
|||
* @return <code>(1 - |x|<sup>3</sup>)<sup>3</sup></code> for |x| < 1, 0 otherwise.
|
||||
*/
|
||||
private static double tricube(final double x) {
|
||||
final double absX = AccurateMath.abs(x);
|
||||
final double absX = JdkMath.abs(x);
|
||||
if (absX >= 1.0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDiffer
|
|||
import org.apache.commons.math4.legacy.exception.NoDataException;
|
||||
import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Immutable representation of a real polynomial function with real coefficients.
|
||||
|
@ -167,8 +167,8 @@ public class PolynomialFunction implements UnivariateDifferentiableFunction, Ser
|
|||
*/
|
||||
public PolynomialFunction add(final PolynomialFunction p) {
|
||||
// identify the lowest degree polynomial
|
||||
final int lowLength = AccurateMath.min(coefficients.length, p.coefficients.length);
|
||||
final int highLength = AccurateMath.max(coefficients.length, p.coefficients.length);
|
||||
final int lowLength = JdkMath.min(coefficients.length, p.coefficients.length);
|
||||
final int highLength = JdkMath.max(coefficients.length, p.coefficients.length);
|
||||
|
||||
// build the coefficients array
|
||||
double[] newCoefficients = new double[highLength];
|
||||
|
@ -192,8 +192,8 @@ public class PolynomialFunction implements UnivariateDifferentiableFunction, Ser
|
|||
*/
|
||||
public PolynomialFunction subtract(final PolynomialFunction p) {
|
||||
// identify the lowest degree polynomial
|
||||
int lowLength = AccurateMath.min(coefficients.length, p.coefficients.length);
|
||||
int highLength = AccurateMath.max(coefficients.length, p.coefficients.length);
|
||||
int lowLength = JdkMath.min(coefficients.length, p.coefficients.length);
|
||||
int highLength = JdkMath.max(coefficients.length, p.coefficients.length);
|
||||
|
||||
// build the coefficients array
|
||||
double[] newCoefficients = new double[highLength];
|
||||
|
@ -236,8 +236,8 @@ public class PolynomialFunction implements UnivariateDifferentiableFunction, Ser
|
|||
|
||||
for (int i = 0; i < newCoefficients.length; ++i) {
|
||||
newCoefficients[i] = 0.0;
|
||||
for (int j = AccurateMath.max(0, i + 1 - p.coefficients.length);
|
||||
j < AccurateMath.min(coefficients.length, i + 1);
|
||||
for (int j = JdkMath.max(0, i + 1 - p.coefficients.length);
|
||||
j < JdkMath.min(coefficients.length, i + 1);
|
||||
++j) {
|
||||
newCoefficients[i] += coefficients[j] * p.coefficients[i-j];
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ public class PolynomialFunction implements UnivariateDifferentiableFunction, Ser
|
|||
}
|
||||
}
|
||||
|
||||
double absAi = AccurateMath.abs(coefficients[i]);
|
||||
double absAi = JdkMath.abs(coefficients[i]);
|
||||
if ((absAi - 1) != 0) {
|
||||
s.append(toString(absAi));
|
||||
s.append(' ');
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
|||
import org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException;
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.math4.legacy.core.MathArrays;
|
||||
|
||||
/**
|
||||
|
@ -216,7 +216,7 @@ public class PolynomialFunctionLagrangeForm implements UnivariateFunction {
|
|||
c[i] = y[i];
|
||||
d[i] = y[i];
|
||||
// find out the abscissa closest to z
|
||||
final double dist = AccurateMath.abs(z - x[i]);
|
||||
final double dist = JdkMath.abs(z - x[i]);
|
||||
if (dist < minDist) {
|
||||
nearest = i;
|
||||
minDist = dist;
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Map;
|
|||
|
||||
import org.apache.commons.numbers.fraction.BigFraction;
|
||||
import org.apache.commons.numbers.combinatorics.BinomialCoefficient;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* A collection of static methods that operate on or return polynomials.
|
||||
|
@ -341,7 +341,7 @@ public final class PolynomialsUtils {
|
|||
|
||||
// First polynomial coefficient.
|
||||
for (int i = 0; i < dp1; i++){
|
||||
newCoefficients[0] += coefficients[i] * AccurateMath.pow(shift, i);
|
||||
newCoefficients[0] += coefficients[i] * JdkMath.pow(shift, i);
|
||||
}
|
||||
|
||||
// Superior order.
|
||||
|
@ -349,7 +349,7 @@ public final class PolynomialsUtils {
|
|||
for (int i = 0; i < d; i++) {
|
||||
for (int j = i; j < d; j++){
|
||||
newCoefficients[i + 1] += coeff[j + 1][j - i] *
|
||||
coefficients[j + 1] * AccurateMath.pow(shift, j - i);
|
||||
coefficients[j + 1] * JdkMath.pow(shift, j - i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,7 +370,7 @@ public final class PolynomialsUtils {
|
|||
// case, the lock object is an immutable field that belongs to this
|
||||
// class.
|
||||
synchronized (coefficients) {
|
||||
final int maxDegree = (int) AccurateMath.floor(AccurateMath.sqrt(2.0 * coefficients.size())) - 1;
|
||||
final int maxDegree = (int) JdkMath.floor(JdkMath.sqrt(2.0 * coefficients.size())) - 1;
|
||||
if (degree > maxDegree) {
|
||||
computeUpToDegree(degree, maxDegree, generator, coefficients);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.commons.math4.legacy.analysis.solvers;
|
|||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math4.legacy.exception.ConvergenceException;
|
||||
import org.apache.commons.math4.legacy.exception.MathInternalError;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Base class for all bracketing <em>Secant</em>-based methods for root-finding
|
||||
|
@ -210,7 +210,7 @@ public abstract class BaseSecantSolver
|
|||
// If the function value of the last approximation is too small,
|
||||
// given the function value accuracy, then we can't get closer to
|
||||
// the root than we already are.
|
||||
if (AccurateMath.abs(f1) <= ftol) {
|
||||
if (JdkMath.abs(f1) <= ftol) {
|
||||
switch (allowed) {
|
||||
case ANY_SIDE:
|
||||
return x1;
|
||||
|
@ -241,7 +241,7 @@ public abstract class BaseSecantSolver
|
|||
|
||||
// If the current interval is within the given accuracies, we
|
||||
// are satisfied with the current approximation.
|
||||
if (AccurateMath.abs(x1 - x0) < AccurateMath.max(rtol * AccurateMath.abs(x1),
|
||||
if (JdkMath.abs(x1 - x0) < JdkMath.max(rtol * JdkMath.abs(x1),
|
||||
atol)) {
|
||||
switch (allowed) {
|
||||
case ANY_SIDE:
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.solvers;
|
||||
|
||||
import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/Bisection.html">
|
||||
|
@ -82,7 +82,7 @@ public class BisectionSolver extends AbstractUnivariateSolver {
|
|||
max = m;
|
||||
}
|
||||
|
||||
if (AccurateMath.abs(max - min) <= absoluteAccuracy) {
|
||||
if (JdkMath.abs(max - min) <= absoluteAccuracy) {
|
||||
m = UnivariateSolverUtils.midpoint(min, max);
|
||||
return m;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.exception.NoBracketingException;
|
|||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
|
||||
/**
|
||||
|
@ -199,11 +199,11 @@ public class BracketingNthOrderBrentSolver
|
|||
// current tightest bracketing of the root
|
||||
double xA = x[signChangeIndex - 1];
|
||||
double yA = y[signChangeIndex - 1];
|
||||
double absYA = AccurateMath.abs(yA);
|
||||
double absYA = JdkMath.abs(yA);
|
||||
int agingA = 0;
|
||||
double xB = x[signChangeIndex];
|
||||
double yB = y[signChangeIndex];
|
||||
double absYB = AccurateMath.abs(yB);
|
||||
double absYB = JdkMath.abs(yB);
|
||||
int agingB = 0;
|
||||
|
||||
// search loop
|
||||
|
@ -211,8 +211,8 @@ public class BracketingNthOrderBrentSolver
|
|||
|
||||
// check convergence of bracketing interval
|
||||
final double xTol = getAbsoluteAccuracy() +
|
||||
getRelativeAccuracy() * AccurateMath.max(AccurateMath.abs(xA), AccurateMath.abs(xB));
|
||||
if (((xB - xA) <= xTol) || (AccurateMath.max(absYA, absYB) < getFunctionValueAccuracy())) {
|
||||
getRelativeAccuracy() * JdkMath.max(JdkMath.abs(xA), JdkMath.abs(xB));
|
||||
if (((xB - xA) <= xTol) || (JdkMath.max(absYA, absYB) < getFunctionValueAccuracy())) {
|
||||
switch (allowed) {
|
||||
case ANY_SIDE :
|
||||
return absYA < absYB ? xA : xB;
|
||||
|
@ -332,14 +332,14 @@ public class BracketingNthOrderBrentSolver
|
|||
// the sign change occurs before the inserted point
|
||||
xB = nextX;
|
||||
yB = nextY;
|
||||
absYB = AccurateMath.abs(yB);
|
||||
absYB = JdkMath.abs(yB);
|
||||
++agingA;
|
||||
agingB = 0;
|
||||
} else {
|
||||
// the sign change occurs after the inserted point
|
||||
xA = nextX;
|
||||
yA = nextY;
|
||||
absYA = AccurateMath.abs(yA);
|
||||
absYA = JdkMath.abs(yA);
|
||||
agingA = 0;
|
||||
++agingB;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
|||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/LaguerresMethod.html">
|
||||
|
@ -100,13 +100,13 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
|
|||
|
||||
// Return the initial guess if it is good enough.
|
||||
final double yInitial = computeObjectiveValue(initial);
|
||||
if (AccurateMath.abs(yInitial) <= functionValueAccuracy) {
|
||||
if (JdkMath.abs(yInitial) <= functionValueAccuracy) {
|
||||
return initial;
|
||||
}
|
||||
|
||||
// Return the first endpoint if it is good enough.
|
||||
final double yMin = computeObjectiveValue(min);
|
||||
if (AccurateMath.abs(yMin) <= functionValueAccuracy) {
|
||||
if (JdkMath.abs(yMin) <= functionValueAccuracy) {
|
||||
return min;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
|
|||
|
||||
// Return the second endpoint if it is good enough.
|
||||
final double yMax = computeObjectiveValue(max);
|
||||
if (AccurateMath.abs(yMax) <= functionValueAccuracy) {
|
||||
if (JdkMath.abs(yMax) <= functionValueAccuracy) {
|
||||
return max;
|
||||
}
|
||||
|
||||
|
@ -241,8 +241,8 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
|
|||
*/
|
||||
public boolean isRoot(double min, double max, Complex z) {
|
||||
if (isSequence(min, z.getReal(), max)) {
|
||||
double tolerance = AccurateMath.max(getRelativeAccuracy() * z.abs(), getAbsoluteAccuracy());
|
||||
return (AccurateMath.abs(z.getImaginary()) <= tolerance) ||
|
||||
double tolerance = JdkMath.max(getRelativeAccuracy() * z.abs(), getAbsoluteAccuracy());
|
||||
return (JdkMath.abs(z.getImaginary()) <= tolerance) ||
|
||||
(z.abs() <= getFunctionValueAccuracy());
|
||||
}
|
||||
return false;
|
||||
|
@ -347,7 +347,7 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
|
|||
d2v = d2v.multiply(Complex.ofCartesian(2.0, 0.0));
|
||||
|
||||
// Check for convergence.
|
||||
final double tolerance = AccurateMath.max(relativeAccuracy * z.abs(),
|
||||
final double tolerance = JdkMath.max(relativeAccuracy * z.abs(),
|
||||
absoluteAccuracy);
|
||||
if ((z.subtract(oldz)).abs() <= tolerance) {
|
||||
return z;
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.solvers;
|
|||
import org.apache.commons.math4.legacy.exception.NoBracketingException;
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* This class implements the <a href="http://mathworld.wolfram.com/MullersMethod.html">
|
||||
|
@ -94,15 +94,15 @@ public class MullerSolver extends AbstractUnivariateSolver {
|
|||
|
||||
// check for zeros before verifying bracketing
|
||||
final double fMin = computeObjectiveValue(min);
|
||||
if (AccurateMath.abs(fMin) < functionValueAccuracy) {
|
||||
if (JdkMath.abs(fMin) < functionValueAccuracy) {
|
||||
return min;
|
||||
}
|
||||
final double fMax = computeObjectiveValue(max);
|
||||
if (AccurateMath.abs(fMax) < functionValueAccuracy) {
|
||||
if (JdkMath.abs(fMax) < functionValueAccuracy) {
|
||||
return max;
|
||||
}
|
||||
final double fInitial = computeObjectiveValue(initial);
|
||||
if (AccurateMath.abs(fInitial) < functionValueAccuracy) {
|
||||
if (JdkMath.abs(fInitial) < functionValueAccuracy) {
|
||||
return initial;
|
||||
}
|
||||
|
||||
|
@ -156,17 +156,17 @@ public class MullerSolver extends AbstractUnivariateSolver {
|
|||
final double d012 = (d12 - d01) / (x2 - x0);
|
||||
final double c1 = d01 + (x1 - x0) * d012;
|
||||
final double delta = c1 * c1 - 4 * y1 * d012;
|
||||
final double xplus = x1 + (-2.0 * y1) / (c1 + AccurateMath.sqrt(delta));
|
||||
final double xminus = x1 + (-2.0 * y1) / (c1 - AccurateMath.sqrt(delta));
|
||||
final double xplus = x1 + (-2.0 * y1) / (c1 + JdkMath.sqrt(delta));
|
||||
final double xminus = x1 + (-2.0 * y1) / (c1 - JdkMath.sqrt(delta));
|
||||
// xplus and xminus are two roots of parabola and at least
|
||||
// one of them should lie in (x0, x2)
|
||||
final double x = isSequence(x0, xplus, x2) ? xplus : xminus;
|
||||
final double y = computeObjectiveValue(x);
|
||||
|
||||
// check for convergence
|
||||
final double tolerance = AccurateMath.max(relativeAccuracy * AccurateMath.abs(x), absoluteAccuracy);
|
||||
if (AccurateMath.abs(x - oldx) <= tolerance ||
|
||||
AccurateMath.abs(y) <= functionValueAccuracy) {
|
||||
final double tolerance = JdkMath.max(relativeAccuracy * JdkMath.abs(x), absoluteAccuracy);
|
||||
if (JdkMath.abs(x - oldx) <= tolerance ||
|
||||
JdkMath.abs(y) <= functionValueAccuracy) {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ public class MullerSolver extends AbstractUnivariateSolver {
|
|||
} else {
|
||||
double xm = 0.5 * (x0 + x2);
|
||||
double ym = computeObjectiveValue(xm);
|
||||
if (AccurateMath.signum(y0) + AccurateMath.signum(ym) == 0.0) {
|
||||
if (JdkMath.signum(y0) + JdkMath.signum(ym) == 0.0) {
|
||||
x2 = xm; y2 = ym;
|
||||
} else {
|
||||
x0 = xm; y0 = ym;
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.solvers;
|
|||
import org.apache.commons.math4.legacy.exception.NoBracketingException;
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* This class implements the <a href="http://mathworld.wolfram.com/MullersMethod.html">
|
||||
|
@ -99,12 +99,12 @@ public class MullerSolver2 extends AbstractUnivariateSolver {
|
|||
|
||||
double x0 = min;
|
||||
double y0 = computeObjectiveValue(x0);
|
||||
if (AccurateMath.abs(y0) < functionValueAccuracy) {
|
||||
if (JdkMath.abs(y0) < functionValueAccuracy) {
|
||||
return x0;
|
||||
}
|
||||
double x1 = max;
|
||||
double y1 = computeObjectiveValue(x1);
|
||||
if (AccurateMath.abs(y1) < functionValueAccuracy) {
|
||||
if (JdkMath.abs(y1) < functionValueAccuracy) {
|
||||
return x1;
|
||||
}
|
||||
|
||||
|
@ -127,12 +127,12 @@ public class MullerSolver2 extends AbstractUnivariateSolver {
|
|||
final double denominator;
|
||||
if (delta >= 0.0) {
|
||||
// choose a denominator larger in magnitude
|
||||
double dplus = b + AccurateMath.sqrt(delta);
|
||||
double dminus = b - AccurateMath.sqrt(delta);
|
||||
denominator = AccurateMath.abs(dplus) > AccurateMath.abs(dminus) ? dplus : dminus;
|
||||
double dplus = b + JdkMath.sqrt(delta);
|
||||
double dminus = b - JdkMath.sqrt(delta);
|
||||
denominator = JdkMath.abs(dplus) > JdkMath.abs(dminus) ? dplus : dminus;
|
||||
} else {
|
||||
// take the modulus of (B +/- AccurateMath.sqrt(delta))
|
||||
denominator = AccurateMath.sqrt(b * b - delta);
|
||||
// take the modulus of (B +/- JdkMath.sqrt(delta))
|
||||
denominator = JdkMath.sqrt(b * b - delta);
|
||||
}
|
||||
if (denominator != 0) {
|
||||
x = x2 - 2.0 * c * (x2 - x1) / denominator;
|
||||
|
@ -143,15 +143,15 @@ public class MullerSolver2 extends AbstractUnivariateSolver {
|
|||
}
|
||||
} else {
|
||||
// extremely rare case, get a random number to skip it
|
||||
x = min + AccurateMath.random() * (max - min);
|
||||
x = min + JdkMath.random() * (max - min);
|
||||
oldx = Double.POSITIVE_INFINITY;
|
||||
}
|
||||
final double y = computeObjectiveValue(x);
|
||||
|
||||
// check for convergence
|
||||
final double tolerance = AccurateMath.max(relativeAccuracy * AccurateMath.abs(x), absoluteAccuracy);
|
||||
if (AccurateMath.abs(x - oldx) <= tolerance ||
|
||||
AccurateMath.abs(y) <= functionValueAccuracy) {
|
||||
final double tolerance = JdkMath.max(relativeAccuracy * JdkMath.abs(x), absoluteAccuracy);
|
||||
if (JdkMath.abs(x - oldx) <= tolerance ||
|
||||
JdkMath.abs(y) <= functionValueAccuracy) {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.commons.math4.legacy.analysis.solvers;
|
|||
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
|
||||
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
|
||||
import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Implements <a href="http://mathworld.wolfram.com/NewtonsMethod.html">
|
||||
|
@ -82,7 +82,7 @@ public class NewtonRaphsonSolver extends AbstractUnivariateDifferentiableSolver
|
|||
while (true) {
|
||||
final DerivativeStructure y0 = computeObjectiveValueAndDerivative(x0);
|
||||
x1 = x0 - (y0.getValue() / y0.getPartialDerivative(1));
|
||||
if (AccurateMath.abs(x1 - x0) <= absoluteAccuracy) {
|
||||
if (JdkMath.abs(x1 - x0) <= absoluteAccuracy) {
|
||||
return x1;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.commons.math4.legacy.analysis.solvers;
|
|||
|
||||
import org.apache.commons.math4.legacy.exception.NoBracketingException;
|
||||
import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Implements the <a href="http://mathworld.wolfram.com/RiddersMethod.html">
|
||||
|
@ -95,28 +95,28 @@ public class RiddersSolver extends AbstractUnivariateSolver {
|
|||
// calculate the new root approximation
|
||||
final double x3 = 0.5 * (x1 + x2);
|
||||
final double y3 = computeObjectiveValue(x3);
|
||||
if (AccurateMath.abs(y3) <= functionValueAccuracy) {
|
||||
if (JdkMath.abs(y3) <= functionValueAccuracy) {
|
||||
return x3;
|
||||
}
|
||||
final double delta = 1 - (y1 * y2) / (y3 * y3); // delta > 1 due to bracketing
|
||||
final double correction = (AccurateMath.signum(y2) * AccurateMath.signum(y3)) *
|
||||
(x3 - x1) / AccurateMath.sqrt(delta);
|
||||
final double correction = (JdkMath.signum(y2) * JdkMath.signum(y3)) *
|
||||
(x3 - x1) / JdkMath.sqrt(delta);
|
||||
final double x = x3 - correction; // correction != 0
|
||||
final double y = computeObjectiveValue(x);
|
||||
|
||||
// check for convergence
|
||||
final double tolerance = AccurateMath.max(relativeAccuracy * AccurateMath.abs(x), absoluteAccuracy);
|
||||
if (AccurateMath.abs(x - oldx) <= tolerance) {
|
||||
final double tolerance = JdkMath.max(relativeAccuracy * JdkMath.abs(x), absoluteAccuracy);
|
||||
if (JdkMath.abs(x - oldx) <= tolerance) {
|
||||
return x;
|
||||
}
|
||||
if (AccurateMath.abs(y) <= functionValueAccuracy) {
|
||||
if (JdkMath.abs(y) <= functionValueAccuracy) {
|
||||
return x;
|
||||
}
|
||||
|
||||
// prepare the new interval for next iteration
|
||||
// Ridders' method guarantees x1 < x < x2
|
||||
if (correction > 0.0) { // x1 < x < x3
|
||||
if (AccurateMath.signum(y1) + AccurateMath.signum(y) == 0.0) {
|
||||
if (JdkMath.signum(y1) + JdkMath.signum(y) == 0.0) {
|
||||
x2 = x;
|
||||
y2 = y;
|
||||
} else {
|
||||
|
@ -126,7 +126,7 @@ public class RiddersSolver extends AbstractUnivariateSolver {
|
|||
y2 = y3;
|
||||
}
|
||||
} else { // x3 < x < x2
|
||||
if (AccurateMath.signum(y2) + AccurateMath.signum(y) == 0.0) {
|
||||
if (JdkMath.signum(y2) + JdkMath.signum(y) == 0.0) {
|
||||
x1 = x;
|
||||
y1 = y;
|
||||
} else {
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.solvers;
|
|||
|
||||
import org.apache.commons.math4.legacy.exception.NoBracketingException;
|
||||
import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Implements the <em>Secant</em> method for root-finding (approximating a
|
||||
|
@ -120,13 +120,13 @@ public class SecantSolver extends AbstractUnivariateSolver {
|
|||
// If the function value of the last approximation is too small,
|
||||
// given the function value accuracy, then we can't get closer to
|
||||
// the root than we already are.
|
||||
if (AccurateMath.abs(f1) <= ftol) {
|
||||
if (JdkMath.abs(f1) <= ftol) {
|
||||
return x1;
|
||||
}
|
||||
|
||||
// If the current interval is within the given accuracies, we
|
||||
// are satisfied with the current approximation.
|
||||
if (AccurateMath.abs(x1 - x0) < AccurateMath.max(rtol * AccurateMath.abs(x1), atol)) {
|
||||
if (JdkMath.abs(x1 - x0) < JdkMath.max(rtol * JdkMath.abs(x1), atol)) {
|
||||
return x1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
|
|||
import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Utility routines for {@link UnivariateSolver} objects.
|
||||
|
@ -111,11 +111,11 @@ public final class UnivariateSolverUtils {
|
|||
}
|
||||
|
||||
// find a very small interval bracketing the root
|
||||
final double step = AccurateMath.max(bracketing.getAbsoluteAccuracy(),
|
||||
AccurateMath.abs(baseRoot * bracketing.getRelativeAccuracy()));
|
||||
double xLo = AccurateMath.max(min, baseRoot - step);
|
||||
final double step = JdkMath.max(bracketing.getAbsoluteAccuracy(),
|
||||
JdkMath.abs(baseRoot * bracketing.getRelativeAccuracy()));
|
||||
double xLo = JdkMath.max(min, baseRoot - step);
|
||||
double fLo = f.value(xLo);
|
||||
double xHi = AccurateMath.min(max, baseRoot + step);
|
||||
double xHi = JdkMath.min(max, baseRoot + step);
|
||||
double fHi = f.value(xHi);
|
||||
int remainingEval = maxEval - 2;
|
||||
while (remainingEval > 0) {
|
||||
|
@ -150,14 +150,14 @@ public final class UnivariateSolverUtils {
|
|||
|
||||
// update the lower bound
|
||||
if (changeLo) {
|
||||
xLo = AccurateMath.max(min, xLo - step);
|
||||
xLo = JdkMath.max(min, xLo - step);
|
||||
fLo = f.value(xLo);
|
||||
remainingEval--;
|
||||
}
|
||||
|
||||
// update the higher bound
|
||||
if (changeHi) {
|
||||
xHi = AccurateMath.min(max, xHi + step);
|
||||
xHi = JdkMath.min(max, xHi + step);
|
||||
fHi = f.value(xHi);
|
||||
remainingEval--;
|
||||
}
|
||||
|
@ -325,8 +325,8 @@ public final class UnivariateSolverUtils {
|
|||
final double previousFb = fb;
|
||||
|
||||
delta = r * delta + q;
|
||||
a = AccurateMath.max(initial - delta, lowerBound);
|
||||
b = AccurateMath.min(initial + delta, upperBound);
|
||||
a = JdkMath.max(initial - delta, lowerBound);
|
||||
b = JdkMath.min(initial + delta, upperBound);
|
||||
fa = function.value(a);
|
||||
fb = function.value(b);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.rng.UniformRandomProvider;
|
|||
import org.apache.commons.rng.sampling.distribution.InverseTransformDiscreteSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.DiscreteInverseCumulativeProbabilityFunction;
|
||||
import org.apache.commons.rng.sampling.distribution.DiscreteSampler;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Base class for integer-valued discrete distributions. Default
|
||||
|
@ -90,19 +90,19 @@ public abstract class AbstractIntegerDistribution
|
|||
// use the one-sided Chebyshev inequality to narrow the bracket
|
||||
// cf. AbstractRealDistribution.inverseCumulativeProbability(double)
|
||||
final double mu = getMean();
|
||||
final double sigma = AccurateMath.sqrt(getVariance());
|
||||
final double sigma = JdkMath.sqrt(getVariance());
|
||||
final boolean chebyshevApplies = !(Double.isInfinite(mu) || Double.isNaN(mu) ||
|
||||
Double.isInfinite(sigma) || Double.isNaN(sigma) || sigma == 0.0);
|
||||
if (chebyshevApplies) {
|
||||
double k = AccurateMath.sqrt((1.0 - p) / p);
|
||||
double k = JdkMath.sqrt((1.0 - p) / p);
|
||||
double tmp = mu - k * sigma;
|
||||
if (tmp > lower) {
|
||||
lower = ((int) AccurateMath.ceil(tmp)) - 1;
|
||||
lower = ((int) JdkMath.ceil(tmp)) - 1;
|
||||
}
|
||||
k = 1.0 / k;
|
||||
tmp = mu + k * sigma;
|
||||
if (tmp < upper) {
|
||||
upper = ((int) AccurateMath.ceil(tmp)) - 1;
|
||||
upper = ((int) JdkMath.ceil(tmp)) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ public abstract class AbstractIntegerDistribution
|
|||
*/
|
||||
@Override
|
||||
public double logProbability(int x) {
|
||||
return AccurateMath.log(probability(x));
|
||||
return JdkMath.log(probability(x));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.rng.UniformRandomProvider;
|
|||
import org.apache.commons.rng.sampling.distribution.InverseTransformContinuousSampler;
|
||||
import org.apache.commons.rng.sampling.distribution.ContinuousInverseCumulativeProbabilityFunction;
|
||||
import org.apache.commons.rng.sampling.distribution.ContinuousSampler;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Base class for probability distributions on the reals.
|
||||
|
@ -129,14 +129,14 @@ public abstract class AbstractRealDistribution
|
|||
}
|
||||
|
||||
final double mu = getMean();
|
||||
final double sig = AccurateMath.sqrt(getVariance());
|
||||
final double sig = JdkMath.sqrt(getVariance());
|
||||
final boolean chebyshevApplies;
|
||||
chebyshevApplies = !(Double.isInfinite(mu) || Double.isNaN(mu) ||
|
||||
Double.isInfinite(sig) || Double.isNaN(sig));
|
||||
|
||||
if (lowerBound == Double.NEGATIVE_INFINITY) {
|
||||
if (chebyshevApplies) {
|
||||
lowerBound = mu - sig * AccurateMath.sqrt((1. - p) / p);
|
||||
lowerBound = mu - sig * JdkMath.sqrt((1. - p) / p);
|
||||
} else {
|
||||
lowerBound = -1.0;
|
||||
while (cumulativeProbability(lowerBound) >= p) {
|
||||
|
@ -147,7 +147,7 @@ public abstract class AbstractRealDistribution
|
|||
|
||||
if (upperBound == Double.POSITIVE_INFINITY) {
|
||||
if (chebyshevApplies) {
|
||||
upperBound = mu + sig * AccurateMath.sqrt(p / (1. - p));
|
||||
upperBound = mu + sig * JdkMath.sqrt(p / (1. - p));
|
||||
} else {
|
||||
upperBound = 1.0;
|
||||
while (cumulativeProbability(upperBound) < p) {
|
||||
|
@ -209,7 +209,7 @@ public abstract class AbstractRealDistribution
|
|||
*/
|
||||
@Override
|
||||
public double logDensity(double x) {
|
||||
return AccurateMath.log(density(x));
|
||||
return JdkMath.log(density(x));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
|||
import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary;
|
||||
import org.apache.commons.math4.legacy.stat.descriptive.SummaryStatistics;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* <p>Represents an <a href="http://en.wikipedia.org/wiki/Empirical_distribution_function">
|
||||
|
@ -207,7 +207,7 @@ public final class EmpiricalDistribution extends AbstractRealDistribution
|
|||
* @return the index of the bin containing the value.
|
||||
*/
|
||||
private int findBin(double value) {
|
||||
return Math.min(Math.max((int) AccurateMath.ceil((value - min) / delta) - 1,
|
||||
return Math.min(Math.max((int) JdkMath.ceil((value - min) / delta) - 1,
|
||||
0),
|
||||
binCount - 1);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math4.legacy.linear.NonPositiveDefiniteMatrixException
|
|||
import org.apache.commons.math4.legacy.linear.RealMatrix;
|
||||
import org.apache.commons.math4.legacy.linear.SingularMatrixException;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Implementation of the multivariate normal (Gaussian) distribution.
|
||||
|
@ -120,7 +120,7 @@ public class MultivariateNormalDistribution
|
|||
|
||||
// Scale each eigenvector by the square root of its eigenvalue.
|
||||
for (int row = 0; row < dim; row++) {
|
||||
final double factor = AccurateMath.sqrt(covMatEigenvalues[row]);
|
||||
final double factor = JdkMath.sqrt(covMatEigenvalues[row]);
|
||||
for (int col = 0; col < dim; col++) {
|
||||
tmpMatrix.multiplyEntry(row, col, factor);
|
||||
}
|
||||
|
@ -155,8 +155,8 @@ public class MultivariateNormalDistribution
|
|||
throw new DimensionMismatchException(vals.length, dim);
|
||||
}
|
||||
|
||||
return AccurateMath.pow(2 * AccurateMath.PI, -0.5 * dim) *
|
||||
AccurateMath.pow(covarianceMatrixDeterminant, -0.5) *
|
||||
return JdkMath.pow(2 * JdkMath.PI, -0.5 * dim) *
|
||||
JdkMath.pow(covarianceMatrixDeterminant, -0.5) *
|
||||
getExponentTerm(vals);
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ public class MultivariateNormalDistribution
|
|||
final double[] std = new double[dim];
|
||||
final double[][] s = covarianceMatrix.getData();
|
||||
for (int i = 0; i < dim; i++) {
|
||||
std[i] = AccurateMath.sqrt(s[i][i]);
|
||||
std[i] = JdkMath.sqrt(s[i][i]);
|
||||
}
|
||||
return std;
|
||||
}
|
||||
|
@ -220,6 +220,6 @@ public class MultivariateNormalDistribution
|
|||
for (int i = 0; i < preMultiplied.length; i++) {
|
||||
sum += preMultiplied[i] * centered[i];
|
||||
}
|
||||
return AccurateMath.exp(-0.5 * sum);
|
||||
return JdkMath.exp(-0.5 * sum);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.commons.math4.legacy.linear.Array2DRowRealMatrix;
|
|||
import org.apache.commons.math4.legacy.linear.RealMatrix;
|
||||
import org.apache.commons.math4.legacy.linear.SingularMatrixException;
|
||||
import org.apache.commons.math4.legacy.stat.correlation.Covariance;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.math4.legacy.core.MathArrays;
|
||||
import org.apache.commons.math4.legacy.core.Pair;
|
||||
|
||||
|
@ -166,7 +166,7 @@ public class MultivariateNormalMixtureExpectationMaximization {
|
|||
fittedModel = new MixtureMultivariateNormalDistribution(initialMixture.getComponents());
|
||||
|
||||
while (numIterations++ <= maxIterations &&
|
||||
AccurateMath.abs(previousLogLikelihood - logLikelihood) > threshold) {
|
||||
JdkMath.abs(previousLogLikelihood - logLikelihood) > threshold) {
|
||||
previousLogLikelihood = logLikelihood;
|
||||
double sumLogLikelihood = 0d;
|
||||
|
||||
|
@ -198,7 +198,7 @@ public class MultivariateNormalMixtureExpectationMaximization {
|
|||
|
||||
for (int i = 0; i < n; i++) {
|
||||
final double rowDensity = fittedModel.density(data[i]);
|
||||
sumLogLikelihood += AccurateMath.log(rowDensity);
|
||||
sumLogLikelihood += JdkMath.log(rowDensity);
|
||||
|
||||
for (int j = 0; j < k; j++) {
|
||||
gamma[i][j] = weights[j] * mvns[j].density(data[i]) / rowDensity;
|
||||
|
@ -252,7 +252,7 @@ public class MultivariateNormalMixtureExpectationMaximization {
|
|||
newCovMatArrays);
|
||||
}
|
||||
|
||||
if (AccurateMath.abs(previousLogLikelihood - logLikelihood) > threshold) {
|
||||
if (JdkMath.abs(previousLogLikelihood - logLikelihood) > threshold) {
|
||||
// Did not converge before the maximum number of iterations
|
||||
throw new ConvergenceException();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
|||
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Fits points to a {@link
|
||||
|
@ -173,7 +173,7 @@ public final class GaussianCurveFitter extends SimpleCurveFitter {
|
|||
// TODO: Exceptions should not be used for flow control.
|
||||
fwhmApprox = points[points.length - 1].getX() - points[0].getX();
|
||||
}
|
||||
final double s = fwhmApprox / (2 * AccurateMath.sqrt(2 * AccurateMath.log(2)));
|
||||
final double s = fwhmApprox / (2 * JdkMath.sqrt(2 * JdkMath.log(2)));
|
||||
|
||||
return new double[] { n, points[maxYIdx].getX(), s };
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.exception.MathIllegalStateException;
|
|||
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math4.legacy.exception.ZeroException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Fits points to a {@link
|
||||
|
@ -288,8 +288,8 @@ public final class HarmonicCurveFitter extends SimpleCurveFitter {
|
|||
throw new MathIllegalStateException(LocalizedFormats.ZERO_DENOMINATOR);
|
||||
}
|
||||
|
||||
aOmega[0] = AccurateMath.sqrt(c1 / c2);
|
||||
aOmega[1] = AccurateMath.sqrt(c2 / c3);
|
||||
aOmega[0] = JdkMath.sqrt(c1 / c2);
|
||||
aOmega[1] = JdkMath.sqrt(c2 / c3);
|
||||
}
|
||||
|
||||
return aOmega;
|
||||
|
@ -319,13 +319,13 @@ public final class HarmonicCurveFitter extends SimpleCurveFitter {
|
|||
final double currentYPrime = (currentY - previousY) / (currentX - previousX);
|
||||
|
||||
double omegaX = omega * currentX;
|
||||
double cosine = AccurateMath.cos(omegaX);
|
||||
double sine = AccurateMath.sin(omegaX);
|
||||
double cosine = JdkMath.cos(omegaX);
|
||||
double sine = JdkMath.sin(omegaX);
|
||||
fcMean += omega * currentY * cosine - currentYPrime * sine;
|
||||
fsMean += omega * currentY * sine + currentYPrime * cosine;
|
||||
}
|
||||
|
||||
return AccurateMath.atan2(-fsMean, fcMean);
|
||||
return JdkMath.atan2(-fsMean, fcMean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.linear.DecompositionSolver;
|
|||
import org.apache.commons.math4.legacy.linear.QRDecomposition;
|
||||
import org.apache.commons.math4.legacy.linear.RealMatrix;
|
||||
import org.apache.commons.math4.legacy.linear.RealVector;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* An implementation of {@link Evaluation} that is designed for extension. All of the
|
||||
|
@ -69,7 +69,7 @@ public abstract class AbstractEvaluation implements Evaluation {
|
|||
final int nC = cov.getColumnDimension();
|
||||
final RealVector sig = new ArrayRealVector(nC);
|
||||
for (int i = 0; i < nC; ++i) {
|
||||
sig.setEntry(i, AccurateMath.sqrt(cov.getEntry(i,i)));
|
||||
sig.setEntry(i, JdkMath.sqrt(cov.getEntry(i,i)));
|
||||
}
|
||||
return sig;
|
||||
}
|
||||
|
@ -77,13 +77,13 @@ public abstract class AbstractEvaluation implements Evaluation {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getRMS() {
|
||||
return AccurateMath.sqrt(getReducedChiSquare(1));
|
||||
return JdkMath.sqrt(getReducedChiSquare(1));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double getCost() {
|
||||
return AccurateMath.sqrt(getChiSquare());
|
||||
return JdkMath.sqrt(getChiSquare());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.commons.math4.legacy.linear.RealVector;
|
|||
import org.apache.commons.math4.legacy.optim.AbstractOptimizationProblem;
|
||||
import org.apache.commons.math4.legacy.optim.ConvergenceChecker;
|
||||
import org.apache.commons.math4.legacy.optim.PointVectorValuePair;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.math4.legacy.core.IntegerSequence;
|
||||
import org.apache.commons.math4.legacy.core.Pair;
|
||||
|
||||
|
@ -278,7 +278,7 @@ public final class LeastSquaresFactory {
|
|||
final int dim = m.getRowDimension();
|
||||
final RealMatrix sqrtM = new DiagonalMatrix(dim);
|
||||
for (int i = 0; i < dim; i++) {
|
||||
sqrtM.setEntry(i, i, AccurateMath.sqrt(m.getEntry(i, i)));
|
||||
sqrtM.setEntry(i, i, JdkMath.sqrt(m.getEntry(i, i)));
|
||||
}
|
||||
return sqrtM;
|
||||
} else {
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.fitting.leastsquares.LeastSquaresProblem.
|
|||
import org.apache.commons.math4.legacy.linear.ArrayRealVector;
|
||||
import org.apache.commons.math4.legacy.linear.RealMatrix;
|
||||
import org.apache.commons.math4.legacy.optim.ConvergenceChecker;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.math4.legacy.core.IntegerSequence;
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
|
||||
|
@ -305,7 +305,7 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
final ConvergenceChecker<Evaluation> checker = problem.getConvergenceChecker();
|
||||
|
||||
// arrays shared with the other private methods
|
||||
final int solvedCols = AccurateMath.min(nR, nC);
|
||||
final int solvedCols = JdkMath.min(nR, nC);
|
||||
/* Parameters evolution direction associated with lmPar. */
|
||||
double[] lmDir = new double[nC];
|
||||
/* Levenberg-Marquardt parameter. */
|
||||
|
@ -375,7 +375,7 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
xNorm += xk * xk;
|
||||
diag[k] = dk;
|
||||
}
|
||||
xNorm = AccurateMath.sqrt(xNorm);
|
||||
xNorm = JdkMath.sqrt(xNorm);
|
||||
|
||||
// initialize the step bound delta
|
||||
delta = (xNorm == 0) ? initialStepBoundFactor : (initialStepBoundFactor * xNorm);
|
||||
|
@ -392,7 +392,7 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
for (int i = 0; i <= j; ++i) {
|
||||
sum += weightedJacobian[i][pj] * qtf[i];
|
||||
}
|
||||
maxCosine = AccurateMath.max(maxCosine, AccurateMath.abs(sum) / (s * currentCost));
|
||||
maxCosine = JdkMath.max(maxCosine, JdkMath.abs(sum) / (s * currentCost));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
|
||||
// rescale if necessary
|
||||
for (int j = 0; j < nC; ++j) {
|
||||
diag[j] = AccurateMath.max(diag[j], jacNorm[j]);
|
||||
diag[j] = JdkMath.max(diag[j], jacNorm[j]);
|
||||
}
|
||||
|
||||
// Inner loop.
|
||||
|
@ -436,10 +436,10 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
double s = diag[pj] * lmDir[pj];
|
||||
lmNorm += s * s;
|
||||
}
|
||||
lmNorm = AccurateMath.sqrt(lmNorm);
|
||||
lmNorm = JdkMath.sqrt(lmNorm);
|
||||
// on the first iteration, adjust the initial step bound.
|
||||
if (firstIteration) {
|
||||
delta = AccurateMath.min(delta, lmNorm);
|
||||
delta = JdkMath.min(delta, lmNorm);
|
||||
}
|
||||
|
||||
// Evaluate the function at x + p and calculate its norm.
|
||||
|
@ -486,7 +486,7 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
if ((0.1 * currentCost >= previousCost) || (tmp < 0.1)) {
|
||||
tmp = 0.1;
|
||||
}
|
||||
delta = tmp * AccurateMath.min(delta, 10.0 * lmNorm);
|
||||
delta = tmp * JdkMath.min(delta, 10.0 * lmNorm);
|
||||
lmPar /= tmp;
|
||||
} else if ((lmPar == 0) || (ratio >= 0.75)) {
|
||||
delta = 2 * lmNorm;
|
||||
|
@ -502,7 +502,7 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
double xK = diag[k] * currentPoint[k];
|
||||
xNorm += xK * xK;
|
||||
}
|
||||
xNorm = AccurateMath.sqrt(xNorm);
|
||||
xNorm = JdkMath.sqrt(xNorm);
|
||||
|
||||
// tests for convergence.
|
||||
if (checker != null && checker.converged(iterationCounter.getCount(), previous, current)) {
|
||||
|
@ -523,7 +523,7 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
}
|
||||
|
||||
// Default convergence criteria.
|
||||
if ((AccurateMath.abs(actRed) <= costRelativeTolerance &&
|
||||
if ((JdkMath.abs(actRed) <= costRelativeTolerance &&
|
||||
preRed <= costRelativeTolerance &&
|
||||
ratio <= 2.0) ||
|
||||
delta <= parRelativeTolerance * xNorm) {
|
||||
|
@ -531,7 +531,7 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
}
|
||||
|
||||
// tests for termination and stringent tolerances
|
||||
if (AccurateMath.abs(actRed) <= TWO_EPS &&
|
||||
if (JdkMath.abs(actRed) <= TWO_EPS &&
|
||||
preRed <= TWO_EPS &&
|
||||
ratio <= 2.0) {
|
||||
throw new ConvergenceException(LocalizedFormats.TOO_SMALL_COST_RELATIVE_TOLERANCE,
|
||||
|
@ -655,7 +655,7 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
work1[pj] = s;
|
||||
dxNorm += s * s;
|
||||
}
|
||||
dxNorm = AccurateMath.sqrt(dxNorm);
|
||||
dxNorm = JdkMath.sqrt(dxNorm);
|
||||
double fp = dxNorm - delta;
|
||||
if (fp <= 0.1 * delta) {
|
||||
lmPar = 0;
|
||||
|
@ -697,15 +697,15 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
sum /= diag[pj];
|
||||
sum2 += sum * sum;
|
||||
}
|
||||
double gNorm = AccurateMath.sqrt(sum2);
|
||||
double gNorm = JdkMath.sqrt(sum2);
|
||||
double paru = gNorm / delta;
|
||||
if (paru == 0) {
|
||||
paru = Precision.SAFE_MIN / AccurateMath.min(delta, 0.1);
|
||||
paru = Precision.SAFE_MIN / JdkMath.min(delta, 0.1);
|
||||
}
|
||||
|
||||
// if the input par lies outside of the interval (parl,paru),
|
||||
// set par to the closer endpoint
|
||||
lmPar = AccurateMath.min(paru, AccurateMath.max(lmPar, parl));
|
||||
lmPar = JdkMath.min(paru, JdkMath.max(lmPar, parl));
|
||||
if (lmPar == 0) {
|
||||
lmPar = gNorm / dxNorm;
|
||||
}
|
||||
|
@ -714,9 +714,9 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
|
||||
// evaluate the function at the current value of lmPar
|
||||
if (lmPar == 0) {
|
||||
lmPar = AccurateMath.max(Precision.SAFE_MIN, 0.001 * paru);
|
||||
lmPar = JdkMath.max(Precision.SAFE_MIN, 0.001 * paru);
|
||||
}
|
||||
double sPar = AccurateMath.sqrt(lmPar);
|
||||
double sPar = JdkMath.sqrt(lmPar);
|
||||
for (int j = 0; j < solvedCols; ++j) {
|
||||
int pj = permutation[j];
|
||||
work1[pj] = sPar * diag[pj];
|
||||
|
@ -730,13 +730,13 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
work3[pj] = s;
|
||||
dxNorm += s * s;
|
||||
}
|
||||
dxNorm = AccurateMath.sqrt(dxNorm);
|
||||
dxNorm = JdkMath.sqrt(dxNorm);
|
||||
double previousFP = fp;
|
||||
fp = dxNorm - delta;
|
||||
|
||||
// if the function is small enough, accept the current value
|
||||
// of lmPar, also test for the exceptional cases where parl is zero
|
||||
if (AccurateMath.abs(fp) <= 0.1 * delta ||
|
||||
if (JdkMath.abs(fp) <= 0.1 * delta ||
|
||||
(parl == 0 &&
|
||||
fp <= previousFP &&
|
||||
previousFP < 0)) {
|
||||
|
@ -765,13 +765,13 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
|
||||
// depending on the sign of the function, update parl or paru.
|
||||
if (fp > 0) {
|
||||
parl = AccurateMath.max(parl, lmPar);
|
||||
parl = JdkMath.max(parl, lmPar);
|
||||
} else if (fp < 0) {
|
||||
paru = AccurateMath.min(paru, lmPar);
|
||||
paru = JdkMath.min(paru, lmPar);
|
||||
}
|
||||
|
||||
// compute an improved estimate for lmPar
|
||||
lmPar = AccurateMath.max(parl, lmPar + correction);
|
||||
lmPar = JdkMath.max(parl, lmPar + correction);
|
||||
}
|
||||
|
||||
return lmPar;
|
||||
|
@ -847,13 +847,13 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
final double sin;
|
||||
final double cos;
|
||||
double rkk = weightedJacobian[k][pk];
|
||||
if (AccurateMath.abs(rkk) < AccurateMath.abs(lmDiag[k])) {
|
||||
if (JdkMath.abs(rkk) < JdkMath.abs(lmDiag[k])) {
|
||||
final double cotan = rkk / lmDiag[k];
|
||||
sin = 1.0 / AccurateMath.sqrt(1.0 + cotan * cotan);
|
||||
sin = 1.0 / JdkMath.sqrt(1.0 + cotan * cotan);
|
||||
cos = sin * cotan;
|
||||
} else {
|
||||
final double tan = lmDiag[k] / rkk;
|
||||
cos = 1.0 / AccurateMath.sqrt(1.0 + tan * tan);
|
||||
cos = 1.0 / JdkMath.sqrt(1.0 + tan * tan);
|
||||
sin = cos * tan;
|
||||
}
|
||||
|
||||
|
@ -956,7 +956,7 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
double akk = weightedJacobian[i][k];
|
||||
norm2 += akk * akk;
|
||||
}
|
||||
jacNorm[k] = AccurateMath.sqrt(norm2);
|
||||
jacNorm[k] = JdkMath.sqrt(norm2);
|
||||
}
|
||||
|
||||
// transform the matrix column after column
|
||||
|
@ -989,7 +989,7 @@ public class LevenbergMarquardtOptimizer implements LeastSquaresOptimizer {
|
|||
|
||||
// choose alpha such that Hk.u = alpha ek
|
||||
double akk = weightedJacobian[k][pk];
|
||||
double alpha = (akk > 0) ? -AccurateMath.sqrt(ak2) : AccurateMath.sqrt(ak2);
|
||||
double alpha = (akk > 0) ? -JdkMath.sqrt(ak2) : JdkMath.sqrt(ak2);
|
||||
double betak = 1.0 / (ak2 - akk * alpha);
|
||||
beta[pk] = betak;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
|||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Population of chromosomes which uses elitism (certain percentage of the best
|
||||
|
@ -87,7 +87,7 @@ public class ElitisticListPopulation extends ListPopulation {
|
|||
Collections.sort(oldChromosomes);
|
||||
|
||||
// index of the last "not good enough" chromosome
|
||||
int boundIndex = (int) AccurateMath.ceil((1.0 - getElitismRate()) * oldChromosomes.size());
|
||||
int boundIndex = (int) JdkMath.ceil((1.0 - getElitismRate()) * oldChromosomes.size());
|
||||
for (int i = boundIndex; i < oldChromosomes.size(); i++) {
|
||||
nextGeneration.addChromosome(oldChromosomes.get(i));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
|||
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.rng.UniformRandomProvider;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Order 1 Crossover [OX1] builds offspring from <b>ordered</b> chromosomes by copying a
|
||||
|
@ -111,8 +111,8 @@ public class OrderedCrossover<T> implements CrossoverPolicy {
|
|||
b = random.nextInt(length);
|
||||
} while (a == b);
|
||||
// determine the lower and upper bounds
|
||||
final int lb = AccurateMath.min(a, b);
|
||||
final int ub = AccurateMath.max(a, b);
|
||||
final int lb = JdkMath.min(a, b);
|
||||
final int ub = JdkMath.max(a, b);
|
||||
|
||||
// add the subLists that are between lb and ub
|
||||
child1.addAll(parent1Rep.subList(lb, ub + 1));
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
|||
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Basic implementation of RealMatrix methods regardless of the underlying storage.
|
||||
|
@ -270,9 +270,9 @@ public abstract class AbstractRealMatrix
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void visit(final int row, final int column, final double value) {
|
||||
columnSum += AccurateMath.abs(value);
|
||||
columnSum += JdkMath.abs(value);
|
||||
if (row == endRow) {
|
||||
maxColSum = AccurateMath.max(maxColSum, columnSum);
|
||||
maxColSum = JdkMath.max(maxColSum, columnSum);
|
||||
columnSum = 0;
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ public abstract class AbstractRealMatrix
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double end() {
|
||||
return AccurateMath.sqrt(sum);
|
||||
return JdkMath.sqrt(sum);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
|||
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* This class implements the {@link RealVector} interface with a double array.
|
||||
|
@ -470,7 +470,7 @@ public class ArrayRealVector extends RealVector implements Serializable {
|
|||
for (double a : data) {
|
||||
sum += a * a;
|
||||
}
|
||||
return AccurateMath.sqrt(sum);
|
||||
return JdkMath.sqrt(sum);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -478,7 +478,7 @@ public class ArrayRealVector extends RealVector implements Serializable {
|
|||
public double getL1Norm() {
|
||||
double sum = 0;
|
||||
for (double a : data) {
|
||||
sum += AccurateMath.abs(a);
|
||||
sum += JdkMath.abs(a);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ public class ArrayRealVector extends RealVector implements Serializable {
|
|||
public double getLInfNorm() {
|
||||
double max = 0;
|
||||
for (double a : data) {
|
||||
max = AccurateMath.max(max, AccurateMath.abs(a));
|
||||
max = JdkMath.max(max, JdkMath.abs(a));
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ public class ArrayRealVector extends RealVector implements Serializable {
|
|||
final double delta = data[i] - vData[i];
|
||||
sum += delta * delta;
|
||||
}
|
||||
return AccurateMath.sqrt(sum);
|
||||
return JdkMath.sqrt(sum);
|
||||
} else {
|
||||
checkVectorDimensions(v);
|
||||
double sum = 0;
|
||||
|
@ -512,7 +512,7 @@ public class ArrayRealVector extends RealVector implements Serializable {
|
|||
final double delta = data[i] - v.getEntry(i);
|
||||
sum += delta * delta;
|
||||
}
|
||||
return AccurateMath.sqrt(sum);
|
||||
return JdkMath.sqrt(sum);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -526,7 +526,7 @@ public class ArrayRealVector extends RealVector implements Serializable {
|
|||
double sum = 0;
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
final double delta = data[i] - vData[i];
|
||||
sum += AccurateMath.abs(delta);
|
||||
sum += JdkMath.abs(delta);
|
||||
}
|
||||
return sum;
|
||||
} else {
|
||||
|
@ -534,7 +534,7 @@ public class ArrayRealVector extends RealVector implements Serializable {
|
|||
double sum = 0;
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
final double delta = data[i] - v.getEntry(i);
|
||||
sum += AccurateMath.abs(delta);
|
||||
sum += JdkMath.abs(delta);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ public class ArrayRealVector extends RealVector implements Serializable {
|
|||
double max = 0;
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
final double delta = data[i] - vData[i];
|
||||
max = AccurateMath.max(max, AccurateMath.abs(delta));
|
||||
max = JdkMath.max(max, JdkMath.abs(delta));
|
||||
}
|
||||
return max;
|
||||
} else {
|
||||
|
@ -558,7 +558,7 @@ public class ArrayRealVector extends RealVector implements Serializable {
|
|||
double max = 0;
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
final double delta = data[i] - v.getEntry(i);
|
||||
max = AccurateMath.max(max, AccurateMath.abs(delta));
|
||||
max = JdkMath.max(max, JdkMath.abs(delta));
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.commons.math4.legacy.linear;
|
||||
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -62,7 +62,7 @@ class BiDiagonalTransformer {
|
|||
|
||||
final int m = matrix.getRowDimension();
|
||||
final int n = matrix.getColumnDimension();
|
||||
final int p = AccurateMath.min(m, n);
|
||||
final int p = JdkMath.min(m, n);
|
||||
householderVectors = matrix.getData();
|
||||
main = new double[p];
|
||||
secondary = new double[p - 1];
|
||||
|
@ -266,7 +266,7 @@ class BiDiagonalTransformer {
|
|||
xNormSqr += c * c;
|
||||
}
|
||||
final double[] hK = householderVectors[k];
|
||||
final double a = (hK[k] > 0) ? -AccurateMath.sqrt(xNormSqr) : AccurateMath.sqrt(xNormSqr);
|
||||
final double a = (hK[k] > 0) ? -JdkMath.sqrt(xNormSqr) : JdkMath.sqrt(xNormSqr);
|
||||
main[k] = a;
|
||||
if (a != 0.0) {
|
||||
hK[k] -= a;
|
||||
|
@ -291,7 +291,7 @@ class BiDiagonalTransformer {
|
|||
final double c = hK[j];
|
||||
xNormSqr += c * c;
|
||||
}
|
||||
final double b = (hK[k + 1] > 0) ? -AccurateMath.sqrt(xNormSqr) : AccurateMath.sqrt(xNormSqr);
|
||||
final double b = (hK[k + 1] > 0) ? -JdkMath.sqrt(xNormSqr) : JdkMath.sqrt(xNormSqr);
|
||||
secondary[k] = b;
|
||||
if (b != 0.0) {
|
||||
hK[k + 1] -= b;
|
||||
|
@ -330,7 +330,7 @@ class BiDiagonalTransformer {
|
|||
final double c = hK[j];
|
||||
xNormSqr += c * c;
|
||||
}
|
||||
final double a = (hK[k] > 0) ? -AccurateMath.sqrt(xNormSqr) : AccurateMath.sqrt(xNormSqr);
|
||||
final double a = (hK[k] > 0) ? -JdkMath.sqrt(xNormSqr) : JdkMath.sqrt(xNormSqr);
|
||||
main[k] = a;
|
||||
if (a != 0.0) {
|
||||
hK[k] -= a;
|
||||
|
@ -355,7 +355,7 @@ class BiDiagonalTransformer {
|
|||
final double c = householderVectors[i][k];
|
||||
xNormSqr += c * c;
|
||||
}
|
||||
final double b = (hKp1[k] > 0) ? -AccurateMath.sqrt(xNormSqr) : AccurateMath.sqrt(xNormSqr);
|
||||
final double b = (hKp1[k] > 0) ? -JdkMath.sqrt(xNormSqr) : JdkMath.sqrt(xNormSqr);
|
||||
secondary[k] = b;
|
||||
if (b != 0.0) {
|
||||
hKp1[k] -= b;
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
|||
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.math4.legacy.core.MathArrays;
|
||||
|
||||
/**
|
||||
|
@ -224,11 +224,11 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
int blockIndex = 0;
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int iHeight = pEnd - pStart;
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int jWidth = qEnd - qStart;
|
||||
|
||||
// allocate new block
|
||||
|
@ -273,11 +273,11 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
int blockIndex = 0;
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int iHeight = pEnd - pStart;
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int jWidth = qEnd - qStart;
|
||||
blocks[blockIndex] = MathArrays.buildArray(field, iHeight * jWidth);
|
||||
++blockIndex;
|
||||
|
@ -333,9 +333,9 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
final T[] outBlock = out.blocks[blockIndex];
|
||||
final T[] tBlock = blocks[blockIndex];
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
int k = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
|
@ -404,9 +404,9 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
final T[] outBlock = out.blocks[blockIndex];
|
||||
final T[] tBlock = blocks[blockIndex];
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
int k = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
|
@ -505,12 +505,12 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
for (int iBlock = 0; iBlock < out.blockRows; ++iBlock) {
|
||||
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
|
||||
for (int jBlock = 0; jBlock < out.blockColumns; ++jBlock) {
|
||||
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, m.getColumnDimension());
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, m.getColumnDimension());
|
||||
|
||||
// select current block
|
||||
final T[] outBlock = out.blocks[blockIndex];
|
||||
|
@ -567,7 +567,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
for (int iBlock = 0; iBlock < out.blockRows; ++iBlock) {
|
||||
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
|
||||
for (int jBlock = 0; jBlock < out.blockColumns; ++jBlock) {
|
||||
final int jWidth = out.blockWidth(jBlock);
|
||||
|
@ -627,7 +627,7 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
int regularPos = 0;
|
||||
int lastPos = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
|
@ -804,14 +804,14 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
for (int iBlock = blockStartRow; iBlock < blockEndRow; ++iBlock) {
|
||||
final int iHeight = blockHeight(iBlock);
|
||||
final int firstRow = iBlock * BLOCK_SIZE;
|
||||
final int iStart = AccurateMath.max(row, firstRow);
|
||||
final int iEnd = AccurateMath.min(endRow + 1, firstRow + iHeight);
|
||||
final int iStart = JdkMath.max(row, firstRow);
|
||||
final int iEnd = JdkMath.min(endRow + 1, firstRow + iHeight);
|
||||
|
||||
for (int jBlock = blockStartColumn; jBlock < blockEndColumn; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int firstColumn = jBlock * BLOCK_SIZE;
|
||||
final int jStart = AccurateMath.max(column, firstColumn);
|
||||
final int jEnd = AccurateMath.min(endColumn + 1, firstColumn + jWidth);
|
||||
final int jStart = JdkMath.max(column, firstColumn);
|
||||
final int jEnd = JdkMath.min(endColumn + 1, firstColumn + jWidth);
|
||||
final int jLength = jEnd - jStart;
|
||||
|
||||
// handle one block, row by row
|
||||
|
@ -1226,9 +1226,9 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
final T[] outBlock = out.blocks[blockIndex];
|
||||
final T[] tBlock = blocks[jBlock * blockColumns + iBlock];
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, columns);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, columns);
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, rows);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, rows);
|
||||
int k = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
final int lInc = pEnd - pStart;
|
||||
|
@ -1273,11 +1273,11 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
// perform multiplication block-wise, to ensure good cache behavior
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final T[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
int k = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
T sum = zero;
|
||||
|
@ -1319,11 +1319,11 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
final int jWidth3 = jWidth2 + jWidth;
|
||||
final int jWidth4 = jWidth3 + jWidth;
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final T[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
int k = q - qStart;
|
||||
T sum = zero;
|
||||
|
@ -1355,12 +1355,12 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final T[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
int k = (p - pStart) * jWidth;
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
|
@ -1379,12 +1379,12 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final T[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
int k = (p - pStart) * jWidth;
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
|
@ -1407,14 +1407,14 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
|
||||
for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
|
||||
final int p0 = iBlock * BLOCK_SIZE;
|
||||
final int pStart = AccurateMath.max(startRow, p0);
|
||||
final int pEnd = AccurateMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
final int pStart = JdkMath.max(startRow, p0);
|
||||
final int pEnd = JdkMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int q0 = jBlock * BLOCK_SIZE;
|
||||
final int qStart = AccurateMath.max(startColumn, q0);
|
||||
final int qEnd = AccurateMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final int qStart = JdkMath.max(startColumn, q0);
|
||||
final int qEnd = JdkMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final T[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
int k = (p - p0) * jWidth + qStart - q0;
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
|
@ -1437,14 +1437,14 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
|
||||
for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
|
||||
final int p0 = iBlock * BLOCK_SIZE;
|
||||
final int pStart = AccurateMath.max(startRow, p0);
|
||||
final int pEnd = AccurateMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
final int pStart = JdkMath.max(startRow, p0);
|
||||
final int pEnd = JdkMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int q0 = jBlock * BLOCK_SIZE;
|
||||
final int qStart = AccurateMath.max(startColumn, q0);
|
||||
final int qEnd = AccurateMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final int qStart = JdkMath.max(startColumn, q0);
|
||||
final int qEnd = JdkMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final T[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
int k = (p - p0) * jWidth + qStart - q0;
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
|
@ -1464,10 +1464,10 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
int blockIndex = 0;
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final T[] block = blocks[blockIndex];
|
||||
int k = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
|
@ -1489,10 +1489,10 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
int blockIndex = 0;
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final T[] block = blocks[blockIndex];
|
||||
int k = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
|
@ -1517,13 +1517,13 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
|
||||
for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
|
||||
final int p0 = iBlock * BLOCK_SIZE;
|
||||
final int pStart = AccurateMath.max(startRow, p0);
|
||||
final int pEnd = AccurateMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
final int pStart = JdkMath.max(startRow, p0);
|
||||
final int pEnd = JdkMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int q0 = jBlock * BLOCK_SIZE;
|
||||
final int qStart = AccurateMath.max(startColumn, q0);
|
||||
final int qEnd = AccurateMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final int qStart = JdkMath.max(startColumn, q0);
|
||||
final int qEnd = JdkMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final T[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
int k = (p - p0) * jWidth + qStart - q0;
|
||||
|
@ -1547,13 +1547,13 @@ public class BlockFieldMatrix<T extends FieldElement<T>> extends AbstractFieldMa
|
|||
visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
|
||||
for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
|
||||
final int p0 = iBlock * BLOCK_SIZE;
|
||||
final int pStart = AccurateMath.max(startRow, p0);
|
||||
final int pEnd = AccurateMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
final int pStart = JdkMath.max(startRow, p0);
|
||||
final int pEnd = JdkMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int q0 = jBlock * BLOCK_SIZE;
|
||||
final int qStart = AccurateMath.max(startColumn, q0);
|
||||
final int qEnd = AccurateMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final int qStart = JdkMath.max(startColumn, q0);
|
||||
final int qEnd = JdkMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final T[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
int k = (p - p0) * jWidth + qStart - q0;
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
|||
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
||||
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Cache-friendly implementation of RealMatrix using a flat arrays to store
|
||||
|
@ -215,11 +215,11 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
int blockIndex = 0;
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int iHeight = pEnd - pStart;
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int jWidth = qEnd - qStart;
|
||||
|
||||
// allocate new block
|
||||
|
@ -259,11 +259,11 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
int blockIndex = 0;
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int iHeight = pEnd - pStart;
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int jWidth = qEnd - qStart;
|
||||
blocks[blockIndex] = new double[iHeight * jWidth];
|
||||
++blockIndex;
|
||||
|
@ -317,9 +317,9 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
final double[] outBlock = out.blocks[blockIndex];
|
||||
final double[] tBlock = blocks[blockIndex];
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
int k = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
|
@ -385,9 +385,9 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
final double[] outBlock = out.blocks[blockIndex];
|
||||
final double[] tBlock = blocks[blockIndex];
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
int k = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
|
@ -483,11 +483,11 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
int blockIndex = 0;
|
||||
for (int iBlock = 0; iBlock < out.blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
|
||||
for (int jBlock = 0; jBlock < out.blockColumns; ++jBlock) {
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, m.getColumnDimension());
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, m.getColumnDimension());
|
||||
|
||||
// select current block
|
||||
final double[] outBlock = out.blocks[blockIndex];
|
||||
|
@ -540,7 +540,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
for (int iBlock = 0; iBlock < out.blockRows; ++iBlock) {
|
||||
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
|
||||
for (int jBlock = 0; jBlock < out.blockColumns; ++jBlock) {
|
||||
final int jWidth = out.blockWidth(jBlock);
|
||||
|
@ -597,7 +597,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
int regularPos = 0;
|
||||
int lastPos = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
|
@ -631,13 +631,13 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
for (int j = 0; j < jWidth; ++j) {
|
||||
double sum = 0;
|
||||
for (int i = 0; i < iHeight; ++i) {
|
||||
sum += AccurateMath.abs(block[i * jWidth + j]);
|
||||
sum += JdkMath.abs(block[i * jWidth + j]);
|
||||
}
|
||||
colSums[j] += sum;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < jWidth; ++j) {
|
||||
maxColSum = AccurateMath.max(maxColSum, colSums[j]);
|
||||
maxColSum = JdkMath.max(maxColSum, colSums[j]);
|
||||
}
|
||||
}
|
||||
return maxColSum;
|
||||
|
@ -652,7 +652,7 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
sum2 += entry * entry;
|
||||
}
|
||||
}
|
||||
return AccurateMath.sqrt(sum2);
|
||||
return JdkMath.sqrt(sum2);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -812,14 +812,14 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
for (int iBlock = blockStartRow; iBlock < blockEndRow; ++iBlock) {
|
||||
final int iHeight = blockHeight(iBlock);
|
||||
final int firstRow = iBlock * BLOCK_SIZE;
|
||||
final int iStart = AccurateMath.max(row, firstRow);
|
||||
final int iEnd = AccurateMath.min(endRow + 1, firstRow + iHeight);
|
||||
final int iStart = JdkMath.max(row, firstRow);
|
||||
final int iEnd = JdkMath.min(endRow + 1, firstRow + iHeight);
|
||||
|
||||
for (int jBlock = blockStartColumn; jBlock < blockEndColumn; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int firstColumn = jBlock * BLOCK_SIZE;
|
||||
final int jStart = AccurateMath.max(column, firstColumn);
|
||||
final int jEnd = AccurateMath.min(endColumn + 1, firstColumn + jWidth);
|
||||
final int jStart = JdkMath.max(column, firstColumn);
|
||||
final int jEnd = JdkMath.min(endColumn + 1, firstColumn + jWidth);
|
||||
final int jLength = jEnd - jStart;
|
||||
|
||||
// handle one block, row by row
|
||||
|
@ -1221,9 +1221,9 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
final double[] outBlock = out.blocks[blockIndex];
|
||||
final double[] tBlock = blocks[jBlock * blockColumns + iBlock];
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, columns);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, columns);
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, rows);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, rows);
|
||||
int k = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
final int lInc = pEnd - pStart;
|
||||
|
@ -1266,11 +1266,11 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
// perform multiplication block-wise, to ensure good cache behavior
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final double[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
int k = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
double sum = 0;
|
||||
|
@ -1310,11 +1310,11 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
final int jWidth3 = jWidth2 + jWidth;
|
||||
final int jWidth4 = jWidth3 + jWidth;
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final double[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
int k = q - qStart;
|
||||
double sum = 0;
|
||||
|
@ -1345,12 +1345,12 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final double[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
int k = (p - pStart) * jWidth;
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
|
@ -1369,12 +1369,12 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final double[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
int k = (p - pStart) * jWidth;
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
|
@ -1397,14 +1397,14 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
|
||||
for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
|
||||
final int p0 = iBlock * BLOCK_SIZE;
|
||||
final int pStart = AccurateMath.max(startRow, p0);
|
||||
final int pEnd = AccurateMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
final int pStart = JdkMath.max(startRow, p0);
|
||||
final int pEnd = JdkMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int q0 = jBlock * BLOCK_SIZE;
|
||||
final int qStart = AccurateMath.max(startColumn, q0);
|
||||
final int qEnd = AccurateMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final int qStart = JdkMath.max(startColumn, q0);
|
||||
final int qEnd = JdkMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final double[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
int k = (p - p0) * jWidth + qStart - q0;
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
|
@ -1427,14 +1427,14 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
|
||||
for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
|
||||
final int p0 = iBlock * BLOCK_SIZE;
|
||||
final int pStart = AccurateMath.max(startRow, p0);
|
||||
final int pEnd = AccurateMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
final int pStart = JdkMath.max(startRow, p0);
|
||||
final int pEnd = JdkMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int q0 = jBlock * BLOCK_SIZE;
|
||||
final int qStart = AccurateMath.max(startColumn, q0);
|
||||
final int qEnd = AccurateMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final int qStart = JdkMath.max(startColumn, q0);
|
||||
final int qEnd = JdkMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final double[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
int k = (p - p0) * jWidth + qStart - q0;
|
||||
for (int q = qStart; q < qEnd; ++q) {
|
||||
|
@ -1454,10 +1454,10 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
int blockIndex = 0;
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final double[] block = blocks[blockIndex];
|
||||
int k = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
|
@ -1479,10 +1479,10 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
int blockIndex = 0;
|
||||
for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
|
||||
final int pStart = iBlock * BLOCK_SIZE;
|
||||
final int pEnd = AccurateMath.min(pStart + BLOCK_SIZE, rows);
|
||||
final int pEnd = JdkMath.min(pStart + BLOCK_SIZE, rows);
|
||||
for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
|
||||
final int qStart = jBlock * BLOCK_SIZE;
|
||||
final int qEnd = AccurateMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final int qEnd = JdkMath.min(qStart + BLOCK_SIZE, columns);
|
||||
final double[] block = blocks[blockIndex];
|
||||
int k = 0;
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
|
@ -1508,13 +1508,13 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
|
||||
for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
|
||||
final int p0 = iBlock * BLOCK_SIZE;
|
||||
final int pStart = AccurateMath.max(startRow, p0);
|
||||
final int pEnd = AccurateMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
final int pStart = JdkMath.max(startRow, p0);
|
||||
final int pEnd = JdkMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int q0 = jBlock * BLOCK_SIZE;
|
||||
final int qStart = AccurateMath.max(startColumn, q0);
|
||||
final int qEnd = AccurateMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final int qStart = JdkMath.max(startColumn, q0);
|
||||
final int qEnd = JdkMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final double[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
int k = (p - p0) * jWidth + qStart - q0;
|
||||
|
@ -1539,13 +1539,13 @@ public class BlockRealMatrix extends AbstractRealMatrix implements Serializable
|
|||
visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
|
||||
for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
|
||||
final int p0 = iBlock * BLOCK_SIZE;
|
||||
final int pStart = AccurateMath.max(startRow, p0);
|
||||
final int pEnd = AccurateMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
final int pStart = JdkMath.max(startRow, p0);
|
||||
final int pEnd = JdkMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
|
||||
for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
|
||||
final int jWidth = blockWidth(jBlock);
|
||||
final int q0 = jBlock * BLOCK_SIZE;
|
||||
final int qStart = AccurateMath.max(startColumn, q0);
|
||||
final int qEnd = AccurateMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final int qStart = JdkMath.max(startColumn, q0);
|
||||
final int qEnd = JdkMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
|
||||
final double[] block = blocks[iBlock * blockColumns + jBlock];
|
||||
for (int p = pStart; p < pEnd; ++p) {
|
||||
int k = (p - p0) * jWidth + qStart - q0;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.linear;
|
||||
|
||||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -123,8 +123,8 @@ public class CholeskyDecomposition {
|
|||
final double lIJ = lI[j];
|
||||
final double lJI = lJ[i];
|
||||
final double maxDelta =
|
||||
relativeSymmetryThreshold * AccurateMath.max(AccurateMath.abs(lIJ), AccurateMath.abs(lJI));
|
||||
if (AccurateMath.abs(lIJ - lJI) > maxDelta) {
|
||||
relativeSymmetryThreshold * JdkMath.max(JdkMath.abs(lIJ), JdkMath.abs(lJI));
|
||||
if (JdkMath.abs(lIJ - lJI) > maxDelta) {
|
||||
throw new NonSymmetricMatrixException(i, j, relativeSymmetryThreshold);
|
||||
}
|
||||
lJ[i] = 0;
|
||||
|
@ -141,7 +141,7 @@ public class CholeskyDecomposition {
|
|||
throw new NonPositiveDefiniteMatrixException(ltI[i], i, absolutePositivityThreshold);
|
||||
}
|
||||
|
||||
ltI[i] = AccurateMath.sqrt(ltI[i]);
|
||||
ltI[i] = JdkMath.sqrt(ltI[i]);
|
||||
final double inverse = 1.0 / ltI[i];
|
||||
|
||||
for (int q = order - 1; q > i; --q) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
|
|||
import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
||||
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
|
||||
/**
|
||||
|
@ -313,7 +313,7 @@ public class DiagonalMatrix extends AbstractRealMatrix
|
|||
*/
|
||||
private void ensureZero(final double value) throws NumberIsTooLargeException {
|
||||
if (!Precision.equals(0.0, value, 1)) {
|
||||
throw new NumberIsTooLargeException(AccurateMath.abs(value), 0, true);
|
||||
throw new NumberIsTooLargeException(JdkMath.abs(value), 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.exception.MathArithmeticException;
|
|||
import org.apache.commons.math4.legacy.exception.MathUnsupportedOperationException;
|
||||
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Calculates the eigen decomposition of a real matrix.
|
||||
|
@ -349,7 +349,7 @@ public class EigenDecomposition {
|
|||
if (eigen <= 0) {
|
||||
throw new MathUnsupportedOperationException();
|
||||
}
|
||||
sqrtEigenValues[i] = AccurateMath.sqrt(eigen);
|
||||
sqrtEigenValues[i] = JdkMath.sqrt(eigen);
|
||||
}
|
||||
final RealMatrix sqrtEigen = MatrixUtils.createRealDiagonalMatrix(sqrtEigenValues);
|
||||
final RealMatrix v = getV();
|
||||
|
@ -487,7 +487,7 @@ public class EigenDecomposition {
|
|||
// Looping over all values (in case they are not sorted in decreasing
|
||||
// order of their norm).
|
||||
for (int i = 0; i < realEigenvalues.length; ++i) {
|
||||
largestEigenvalueNorm = AccurateMath.max(largestEigenvalueNorm, eigenvalueNorm(i));
|
||||
largestEigenvalueNorm = JdkMath.max(largestEigenvalueNorm, eigenvalueNorm(i));
|
||||
}
|
||||
// Corner case: zero matrix, all exactly 0 eigenvalues
|
||||
if (largestEigenvalueNorm == 0.0) {
|
||||
|
@ -510,7 +510,7 @@ public class EigenDecomposition {
|
|||
private double eigenvalueNorm(int i) {
|
||||
final double re = realEigenvalues[i];
|
||||
final double im = imagEigenvalues[i];
|
||||
return AccurateMath.sqrt(re * re + im * im);
|
||||
return JdkMath.sqrt(re * re + im * im);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -577,20 +577,20 @@ public class EigenDecomposition {
|
|||
// Determine the largest main and secondary value in absolute term.
|
||||
double maxAbsoluteValue = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (AccurateMath.abs(realEigenvalues[i]) > maxAbsoluteValue) {
|
||||
maxAbsoluteValue = AccurateMath.abs(realEigenvalues[i]);
|
||||
if (JdkMath.abs(realEigenvalues[i]) > maxAbsoluteValue) {
|
||||
maxAbsoluteValue = JdkMath.abs(realEigenvalues[i]);
|
||||
}
|
||||
if (AccurateMath.abs(e[i]) > maxAbsoluteValue) {
|
||||
maxAbsoluteValue = AccurateMath.abs(e[i]);
|
||||
if (JdkMath.abs(e[i]) > maxAbsoluteValue) {
|
||||
maxAbsoluteValue = JdkMath.abs(e[i]);
|
||||
}
|
||||
}
|
||||
// Make null any main and secondary value too small to be significant
|
||||
if (maxAbsoluteValue != 0) {
|
||||
for (int i=0; i < n; i++) {
|
||||
if (AccurateMath.abs(realEigenvalues[i]) <= Precision.EPSILON * maxAbsoluteValue) {
|
||||
if (JdkMath.abs(realEigenvalues[i]) <= Precision.EPSILON * maxAbsoluteValue) {
|
||||
realEigenvalues[i] = 0;
|
||||
}
|
||||
if (AccurateMath.abs(e[i]) <= Precision.EPSILON * maxAbsoluteValue) {
|
||||
if (JdkMath.abs(e[i]) <= Precision.EPSILON * maxAbsoluteValue) {
|
||||
e[i]=0;
|
||||
}
|
||||
}
|
||||
|
@ -601,9 +601,9 @@ public class EigenDecomposition {
|
|||
int m;
|
||||
do {
|
||||
for (m = j; m < n - 1; m++) {
|
||||
double delta = AccurateMath.abs(realEigenvalues[m]) +
|
||||
AccurateMath.abs(realEigenvalues[m + 1]);
|
||||
if (AccurateMath.abs(e[m]) + delta == delta) {
|
||||
double delta = JdkMath.abs(realEigenvalues[m]) +
|
||||
JdkMath.abs(realEigenvalues[m + 1]);
|
||||
if (JdkMath.abs(e[m]) + delta == delta) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ public class EigenDecomposition {
|
|||
}
|
||||
its++;
|
||||
double q = (realEigenvalues[j + 1] - realEigenvalues[j]) / (2 * e[j]);
|
||||
double t = AccurateMath.sqrt(1 + q * q);
|
||||
double t = JdkMath.sqrt(1 + q * q);
|
||||
if (q < 0.0) {
|
||||
q = realEigenvalues[m] - realEigenvalues[j] + e[j] / (q - t);
|
||||
} else {
|
||||
|
@ -627,15 +627,15 @@ public class EigenDecomposition {
|
|||
for (i = m - 1; i >= j; i--) {
|
||||
double p = s * e[i];
|
||||
double h = c * e[i];
|
||||
if (AccurateMath.abs(p) >= AccurateMath.abs(q)) {
|
||||
if (JdkMath.abs(p) >= JdkMath.abs(q)) {
|
||||
c = q / p;
|
||||
t = AccurateMath.sqrt(c * c + 1.0);
|
||||
t = JdkMath.sqrt(c * c + 1.0);
|
||||
e[i + 1] = p * t;
|
||||
s = 1.0 / t;
|
||||
c *= s;
|
||||
} else {
|
||||
s = p / q;
|
||||
t = AccurateMath.sqrt(s * s + 1.0);
|
||||
t = JdkMath.sqrt(s * s + 1.0);
|
||||
e[i + 1] = q * t;
|
||||
c = 1.0 / t;
|
||||
s *= c;
|
||||
|
@ -690,14 +690,14 @@ public class EigenDecomposition {
|
|||
// Determine the largest eigen value in absolute term.
|
||||
maxAbsoluteValue = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (AccurateMath.abs(realEigenvalues[i]) > maxAbsoluteValue) {
|
||||
maxAbsoluteValue=AccurateMath.abs(realEigenvalues[i]);
|
||||
if (JdkMath.abs(realEigenvalues[i]) > maxAbsoluteValue) {
|
||||
maxAbsoluteValue=JdkMath.abs(realEigenvalues[i]);
|
||||
}
|
||||
}
|
||||
// Make null any eigen value too small to be significant
|
||||
if (maxAbsoluteValue != 0.0) {
|
||||
for (int i=0; i < n; i++) {
|
||||
if (AccurateMath.abs(realEigenvalues[i]) < Precision.EPSILON * maxAbsoluteValue) {
|
||||
if (JdkMath.abs(realEigenvalues[i]) < Precision.EPSILON * maxAbsoluteValue) {
|
||||
realEigenvalues[i] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -732,7 +732,7 @@ public class EigenDecomposition {
|
|||
} else {
|
||||
final double x = matT[i + 1][i + 1];
|
||||
final double p = 0.5 * (matT[i][i] - x);
|
||||
final double z = AccurateMath.sqrt(AccurateMath.abs(p * p + matT[i + 1][i] * matT[i][i + 1]));
|
||||
final double z = JdkMath.sqrt(JdkMath.abs(p * p + matT[i + 1][i] * matT[i][i + 1]));
|
||||
realEigenvalues[i] = x + p;
|
||||
imagEigenvalues[i] = z;
|
||||
realEigenvalues[i + 1] = x + p;
|
||||
|
@ -773,8 +773,8 @@ public class EigenDecomposition {
|
|||
// compute matrix norm
|
||||
double norm = 0.0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = AccurateMath.max(i - 1, 0); j < n; j++) {
|
||||
norm += AccurateMath.abs(matrixT[i][j]);
|
||||
for (int j = JdkMath.max(i - 1, 0); j < n; j++) {
|
||||
norm += JdkMath.abs(matrixT[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -822,7 +822,7 @@ public class EigenDecomposition {
|
|||
imagEigenvalues[i] * imagEigenvalues[i];
|
||||
double t = (x * s - z * r) / q;
|
||||
matrixT[i][idx] = t;
|
||||
if (AccurateMath.abs(x) > AccurateMath.abs(z)) {
|
||||
if (JdkMath.abs(x) > JdkMath.abs(z)) {
|
||||
matrixT[i + 1][idx] = (-r - w * t) / x;
|
||||
} else {
|
||||
matrixT[i + 1][idx] = (-s - y * t) / z;
|
||||
|
@ -830,7 +830,7 @@ public class EigenDecomposition {
|
|||
}
|
||||
|
||||
// Overflow control
|
||||
double t = AccurateMath.abs(matrixT[i][idx]);
|
||||
double t = JdkMath.abs(matrixT[i][idx]);
|
||||
if ((Precision.EPSILON * t) * t > 1) {
|
||||
for (int j = i; j <= idx; j++) {
|
||||
matrixT[j][idx] /= t;
|
||||
|
@ -843,7 +843,7 @@ public class EigenDecomposition {
|
|||
int l = idx - 1;
|
||||
|
||||
// Last vector component imaginary so matrix is triangular
|
||||
if (AccurateMath.abs(matrixT[idx][idx - 1]) > AccurateMath.abs(matrixT[idx - 1][idx])) {
|
||||
if (JdkMath.abs(matrixT[idx][idx - 1]) > JdkMath.abs(matrixT[idx - 1][idx])) {
|
||||
matrixT[idx - 1][idx - 1] = q / matrixT[idx][idx - 1];
|
||||
matrixT[idx - 1][idx] = -(matrixT[idx][idx] - p) / matrixT[idx][idx - 1];
|
||||
} else {
|
||||
|
@ -884,15 +884,15 @@ public class EigenDecomposition {
|
|||
final double vi = (realEigenvalues[i] - p) * 2.0 * q;
|
||||
if (Precision.equals(vr, 0.0) && Precision.equals(vi, 0.0)) {
|
||||
vr = Precision.EPSILON * norm *
|
||||
(AccurateMath.abs(w) + AccurateMath.abs(q) + AccurateMath.abs(x) +
|
||||
AccurateMath.abs(y) + AccurateMath.abs(z));
|
||||
(JdkMath.abs(w) + JdkMath.abs(q) + JdkMath.abs(x) +
|
||||
JdkMath.abs(y) + JdkMath.abs(z));
|
||||
}
|
||||
final Complex c = cdiv(x * r - z * ra + q * sa,
|
||||
x * s - z * sa - q * ra, vr, vi);
|
||||
matrixT[i][idx - 1] = c.getReal();
|
||||
matrixT[i][idx] = c.getImaginary();
|
||||
|
||||
if (AccurateMath.abs(x) > (AccurateMath.abs(z) + AccurateMath.abs(q))) {
|
||||
if (JdkMath.abs(x) > (JdkMath.abs(z) + JdkMath.abs(q))) {
|
||||
matrixT[i + 1][idx - 1] = (-ra - w * matrixT[i][idx - 1] +
|
||||
q * matrixT[i][idx]) / x;
|
||||
matrixT[i + 1][idx] = (-sa - w * matrixT[i][idx] -
|
||||
|
@ -906,8 +906,8 @@ public class EigenDecomposition {
|
|||
}
|
||||
|
||||
// Overflow control
|
||||
double t = AccurateMath.max(AccurateMath.abs(matrixT[i][idx - 1]),
|
||||
AccurateMath.abs(matrixT[i][idx]));
|
||||
double t = JdkMath.max(JdkMath.abs(matrixT[i][idx - 1]),
|
||||
JdkMath.abs(matrixT[i][idx]));
|
||||
if ((Precision.EPSILON * t) * t > 1) {
|
||||
for (int j = i; j <= idx; j++) {
|
||||
matrixT[j][idx - 1] /= t;
|
||||
|
@ -923,7 +923,7 @@ public class EigenDecomposition {
|
|||
for (int j = n - 1; j >= 0; j--) {
|
||||
for (int i = 0; i <= n - 1; i++) {
|
||||
z = 0.0;
|
||||
for (int k = 0; k <= AccurateMath.min(j, n - 1); k++) {
|
||||
for (int k = 0; k <= JdkMath.min(j, n - 1); k++) {
|
||||
z += matrixP[i][k] * matrixT[k][j];
|
||||
}
|
||||
matrixP[i][j] = z;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.commons.math4.legacy.linear;
|
||||
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
|
||||
/**
|
||||
|
@ -184,7 +184,7 @@ class HessenbergTransformer {
|
|||
// Scale column.
|
||||
double scale = 0;
|
||||
for (int i = m; i <= high; i++) {
|
||||
scale += AccurateMath.abs(householderVectors[i][m - 1]);
|
||||
scale += JdkMath.abs(householderVectors[i][m - 1]);
|
||||
}
|
||||
|
||||
if (!Precision.equals(scale, 0)) {
|
||||
|
@ -194,7 +194,7 @@ class HessenbergTransformer {
|
|||
ort[i] = householderVectors[i][m - 1] / scale;
|
||||
h += ort[i] * ort[i];
|
||||
}
|
||||
final double g = (ort[m] > 0) ? -AccurateMath.sqrt(h) : AccurateMath.sqrt(h);
|
||||
final double g = (ort[m] > 0) ? -JdkMath.sqrt(h) : JdkMath.sqrt(h);
|
||||
|
||||
h -= ort[m] * g;
|
||||
ort[m] -= g;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math4.legacy.linear;
|
||||
|
||||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Calculates the LUP-decomposition of a square matrix.
|
||||
|
@ -127,14 +127,14 @@ public class LUDecomposition {
|
|||
luRow[col] = sum;
|
||||
|
||||
// maintain best permutation choice
|
||||
if (AccurateMath.abs(sum) > largest) {
|
||||
largest = AccurateMath.abs(sum);
|
||||
if (JdkMath.abs(sum) > largest) {
|
||||
largest = JdkMath.abs(sum);
|
||||
max = row;
|
||||
}
|
||||
}
|
||||
|
||||
// Singularity check
|
||||
if (AccurateMath.abs(lu[max][col]) < singularityThreshold) {
|
||||
if (JdkMath.abs(lu[max][col]) < singularityThreshold) {
|
||||
singular = true;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
|||
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.legacy.exception.ZeroException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.math4.legacy.core.MathArrays;
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
|
||||
|
@ -412,8 +412,8 @@ public final class MatrixUtils {
|
|||
for (int j = i + 1; j < rows; j++) {
|
||||
final double mij = matrix.getEntry(i, j);
|
||||
final double mji = matrix.getEntry(j, i);
|
||||
if (AccurateMath.abs(mij - mji) >
|
||||
AccurateMath.max(AccurateMath.abs(mij), AccurateMath.abs(mji)) * relativeTolerance) {
|
||||
if (JdkMath.abs(mij - mji) >
|
||||
JdkMath.max(JdkMath.abs(mij), JdkMath.abs(mji)) * relativeTolerance) {
|
||||
if (raiseException) {
|
||||
throw new NonSymmetricMatrixException(i, j, relativeTolerance);
|
||||
} else {
|
||||
|
@ -845,7 +845,7 @@ public final class MatrixUtils {
|
|||
int rows = rm.getRowDimension();
|
||||
for( int i = 0 ; i < rows ; i++ ){
|
||||
double diag = rm.getEntry(i, i);
|
||||
if( AccurateMath.abs(diag) < Precision.SAFE_MIN ){
|
||||
if( JdkMath.abs(diag) < Precision.SAFE_MIN ){
|
||||
throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
|
||||
}
|
||||
double bi = b.getEntry(i)/diag;
|
||||
|
@ -890,7 +890,7 @@ public final class MatrixUtils {
|
|||
int rows = rm.getRowDimension();
|
||||
for( int i = rows-1 ; i >-1 ; i-- ){
|
||||
double diag = rm.getEntry(i, i);
|
||||
if( AccurateMath.abs(diag) < Precision.SAFE_MIN ){
|
||||
if( JdkMath.abs(diag) < Precision.SAFE_MIN ){
|
||||
throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
|
||||
}
|
||||
double bi = b.getEntry(i)/diag;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.commons.math4.legacy.linear;
|
||||
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
@ -151,7 +151,7 @@ class OpenIntToDoubleHashMap implements Serializable { // Not in public API.
|
|||
if (expectedSize == 0) {
|
||||
return 1;
|
||||
}
|
||||
final int capacity = (int) AccurateMath.ceil(expectedSize / LOAD_FACTOR);
|
||||
final int capacity = (int) JdkMath.ceil(expectedSize / LOAD_FACTOR);
|
||||
final int powerOfTwo = Integer.highestOneBit(capacity);
|
||||
if (powerOfTwo == capacity) {
|
||||
return capacity;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.NoSuchElementException;
|
|||
|
||||
import org.apache.commons.math4.legacy.core.Field;
|
||||
import org.apache.commons.math4.legacy.core.FieldElement;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
|
||||
/**
|
||||
* Open addressed map from int to FieldElement.
|
||||
|
@ -163,7 +163,7 @@ class OpenIntToFieldHashMap<T extends FieldElement<T>> implements Serializable {
|
|||
if (expectedSize == 0) {
|
||||
return 1;
|
||||
}
|
||||
final int capacity = (int) AccurateMath.ceil(expectedSize / LOAD_FACTOR);
|
||||
final int capacity = (int) JdkMath.ceil(expectedSize / LOAD_FACTOR);
|
||||
final int powerOfTwo = Integer.highestOneBit(capacity);
|
||||
if (powerOfTwo == capacity) {
|
||||
return capacity;
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.exception.MathArithmeticException;
|
|||
import org.apache.commons.math4.legacy.exception.NotPositiveException;
|
||||
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
|
||||
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.core.jdkmath.JdkMath;
|
||||
import org.apache.commons.math4.legacy.linear.OpenIntToDoubleHashMap.Iterator;
|
||||
|
||||
/**
|
||||
|
@ -225,7 +225,7 @@ public class OpenMapRealVector extends SparseRealVector
|
|||
* @since 2.1
|
||||
*/
|
||||
protected boolean isDefaultValue(double value) {
|
||||
return AccurateMath.abs(value) < epsilon;
|
||||
return JdkMath.abs(value) < epsilon;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -401,7 +401,7 @@ public class OpenMapRealVector extends SparseRealVector
|
|||
res += value * value;
|
||||
}
|
||||
}
|
||||
return AccurateMath.sqrt(res);
|
||||
return JdkMath.sqrt(res);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
@ -439,7 +439,7 @@ public class OpenMapRealVector extends SparseRealVector
|
|||
Iterator iter = entries.iterator();
|
||||
while (iter.hasNext()) {
|
||||
iter.advance();
|
||||
double delta = AccurateMath.abs(iter.value() - v.getEntry(iter.key()));
|
||||
double delta = JdkMath.abs(iter.value() - v.getEntry(iter.key()));
|
||||
max += delta;
|
||||
}
|
||||
iter = v.getEntries().iterator();
|
||||
|
@ -447,8 +447,8 @@ public class OpenMapRealVector extends SparseRealVector
|
|||
iter.advance();
|
||||
int key = iter.key();
|
||||
if (!entries.containsKey(key)) {
|
||||
double delta = AccurateMath.abs(iter.value());
|
||||
max += AccurateMath.abs(delta);
|
||||
double delta = JdkMath.abs(iter.value());
|
||||
max += JdkMath.abs(delta);
|
||||
}
|
||||
}
|
||||
return max;
|
||||
|
@ -480,7 +480,7 @@ public class OpenMapRealVector extends SparseRealVector
|
|||
Iterator iter = entries.iterator();
|
||||
while (iter.hasNext()) {
|
||||
iter.advance();
|
||||
double delta = AccurateMath.abs(iter.value() - v.getEntry(iter.key()));
|
||||
double delta = JdkMath.abs(iter.value() - v.getEntry(iter.key()));
|
||||
if (delta > max) {
|
||||
max = delta;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue