diff options
author | Joe Darcy <darcy@openjdk.org> | 2024-03-01 19:30:35 +0000 |
---|---|---|
committer | Joe Darcy <darcy@openjdk.org> | 2024-03-01 19:30:35 +0000 |
commit | 7f02f07f754c942735ba15d70858cd1661a658c0 (patch) | |
tree | 00b5fb9897ec7072b053485ba98e78be60654382 | |
parent | 8f0fb27decec28f32e4d88341237189ba4a340fb (diff) |
8316708: Augment WorstCaseTests with more cases
Reviewed-by: rgiulietti
-rw-r--r-- | test/jdk/java/lang/Math/Tests.java | 10 | ||||
-rw-r--r-- | test/jdk/java/lang/Math/WorstCaseTests.java | 151 | ||||
-rw-r--r-- | test/jdk/java/lang/StrictMath/Atan2Tests.java | 21 | ||||
-rw-r--r-- | test/jdk/java/lang/StrictMath/CubeRootTests.java | 15 | ||||
-rw-r--r-- | test/jdk/java/lang/StrictMath/ExpTests.java | 10 | ||||
-rw-r--r-- | test/jdk/java/lang/StrictMath/Expm1Tests.java | 10 | ||||
-rw-r--r-- | test/jdk/java/lang/StrictMath/HyperbolicTests.java | 17 | ||||
-rw-r--r-- | test/jdk/java/lang/StrictMath/HypotTests.java | 7 | ||||
-rw-r--r-- | test/jdk/java/lang/StrictMath/InverseTrigTests.java | 55 | ||||
-rw-r--r-- | test/jdk/java/lang/StrictMath/Log10Tests.java | 9 | ||||
-rw-r--r-- | test/jdk/java/lang/StrictMath/Log1pTests.java | 11 | ||||
-rw-r--r-- | test/jdk/java/lang/StrictMath/LogTests.java | 6 | ||||
-rw-r--r-- | test/jdk/java/lang/StrictMath/TrigTests.java | 17 |
13 files changed, 307 insertions, 32 deletions
diff --git a/test/jdk/java/lang/Math/Tests.java b/test/jdk/java/lang/Math/Tests.java index 60981e318e2..23b7098131b 100644 --- a/test/jdk/java/lang/Math/Tests.java +++ b/test/jdk/java/lang/Math/Tests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -88,10 +88,10 @@ public class Tests { * Return the floating-point value next larger in magnitude. */ public static double nextOut(double d) { - if (d > 0.0) - return Math.nextUp(d); + if (d != 0.0) + return (d > 0.0) ? Math.nextUp(d) : Math.nextDown(d); else - return -Math.nextUp(-d); + return Math.copySign(Double.MIN_VALUE, d); } /** @@ -108,7 +108,7 @@ public class Tests { * <li> If the argument is zero, then the result is -(2<sup>28</sup>). * </ul> * - * @param f floating-point number whose exponent is to be extracted + * @param d floating-point number whose exponent is to be extracted * @return unbiased exponent of the argument. */ public static int ilogb(double d) { diff --git a/test/jdk/java/lang/Math/WorstCaseTests.java b/test/jdk/java/lang/Math/WorstCaseTests.java index 2cffa8fabfc..32e39479b4b 100644 --- a/test/jdk/java/lang/Math/WorstCaseTests.java +++ b/test/jdk/java/lang/Math/WorstCaseTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 4900206 + * @bug 4900206 8316708 * @summary Test worst case behavior of exp, log, sin, cos, etc. * @build Tests * @build WorstCaseTests @@ -32,11 +32,22 @@ */ /** - * Use "Table Maker's Dilemma" results from Jean-Michel Muller and - * Vincent Lefèvre, to test the math library. See - * http://perso.ens-lyon.fr/jean-michel.muller/TMD.html for original + * This test contains two distinct kinds of worst-case inputs: + * + * 1) Exact numerical results that are nearly half-way between + * representable numbers or very close to a representable + * number. (Half-way cases are hardest for round to nearest even; + * close to a representable number cases are hard for directed + * roundings.) + * + * 2) Worst-case errors as observed empirically across different + * implementations that are not correctly rounded. + * + * For the first category, the "Table Maker's Dilemma" results from + * Jean-Michel Muller and Vincent Lefèvre, are used. + * See https://perso.ens-lyon.fr/jean-michel.muller/TMD.html for original * test vectors from 2000 and see - * http://perso.ens-lyon.fr/jean-michel.muller/TMDworstcases.pdf with + * https://perso.ens-lyon.fr/jean-michel.muller/TMDworstcases.pdf with * additional test vectors from 2003. The latter link also contains * some information about the methodology used to produce the test * vectors. @@ -52,6 +63,17 @@ * JDK implementation complies with a 1 ulp bound on the worst-case * values. Therefore, no addition leeway is afforded when testing * sinh and cosh. + * + * For the second category, worst-case observed error inputs for the + * FDLIBM-derived OpenLibm 0.8.1 and other math libraries are added + * from "Accuracy of Mathematical Functions in Single, Double, Double + * Extended, and Quadruple Precision" by Brian Gladman, Vincenzo + * Innocente and Paul Zimmermann. + * + * From https://openlibm.org/, "The OpenLibm code derives from the + * FreeBSD msun and OpenBSD libm implementations, which in turn derive + * from FDLIBM 5.3." Java's StrictMath libraries use the FDLIBM 5.3 + * algorithms. */ public class WorstCaseTests { private WorstCaseTests() {throw new AssertionError("No instances for you.");} @@ -77,6 +99,9 @@ public class WorstCaseTests { } } + /* + * 1 ulp stated error bound + */ private static int testWorstExp() { int failures = 0; double [][] testCases = { @@ -113,6 +138,17 @@ public class WorstCaseTests { {+0x1.A8EAD058BC6B8p3, 0x1.1D71965F516ADp19}, {+0x1.1D5C2DAEBE367p4, 0x1.A8C02E974C314p25}, {+0x1.C44CE0D716A1Ap4, 0x1.B890CA8637AE1p40}, + + // Worst-case observed error for OpenLibm + {+0x1.2e8f20cf3cbe7p+8, 0x1.6a2a59cc78bf7p436}, + // Other worst-case observed errors + {-0x1.49f33ad2c1c58p+9, 0x1.f3ccc815431b5p-953}, + {+0x1.fce66609f7428p+5, 0x1.b59724cb0bc4cp91}, + {+0x1.b97dc8345c55p+5, 0x1.88ab482dafdd7p79}, + {-0x1.18209ecd19a8cp+6, 0x1.f3dcee4c90df9p-102}, + {-0x1.4133f4fd79c1cp-13, 0x1.ffebed256fadp-1}, + {-0x1.74046dfefd9d1p+9, 0x0.0000000000001p-1022}, + {-0x1.49f33ad2c1c58p+9, 0x1.f3ccc815431b5p-953}, }; for(double[] testCase: testCases) { @@ -130,6 +166,9 @@ public class WorstCaseTests { return failures; } + /* + * 1 ulp stated error bound + */ private static int testWorstLog() { int failures = 0; double [][] testCases = { @@ -145,6 +184,19 @@ public class WorstCaseTests { {+0x17.F3825778AAAFp0, +0x3.2D0F907F5E00Cp+0}, {+0x1AC.50B409C8AEEp0, +0x6.0F52F37AECFCCp+0}, {+0x1.DE7CD6751029Ap16, +0x1.76E7E5D7B6EABp+3}, + + // Worst-case observed error for OpenLibm + {+0x1.48ae5a67204f5p+0, 0x1.ffd10abffc3fep-3}, + // Other worst-case observed errors + {+0x1.1211bef8f68e9p+0, +0x1.175caeca67f84p-4}, + {+0x1.008000db2e8bep+0, +0x1.ff83959f5cc1fp-10}, + {+0x1.0ffea3878db6bp+0, +0x1.f07a0cca521efp-5}, + {+0x1.dc0b586f2b26p-1, -0x1.2a3eaaa6e8d72p-4}, + {+0x1.490af72a25a81p-1, -0x1.c4bf7ae48f078p-2}, + {+0x1.5b6e7e4e96f86p+2, +0x1.b11240cba290dp0}, + {+0x1.0ffc349469a2fp+0, +0x1.f030c2507cd81p-5}, + {+0x1.69e7aa6da2df5p-1, -0x1.634508c9adfp-2}, + {+0x1.5556123e8a2bp-1, -0x1.9f300810f7d7cp-2}, }; for(double[] testCase: testCases) { @@ -162,6 +214,9 @@ public class WorstCaseTests { return failures; } + /* + * 1 ulp stated error bound + */ private static int testWorstSin() { int failures = 0; double [][] testCases = { @@ -178,6 +233,19 @@ public class WorstCaseTests { {+0x1.921FB54442D18p-0, +0x1.FFFFFFFFFFFFFp-1}, {+0x1.6756745770A51p+1, +0x1.4FF350E412821p-2}, + + // Worst-case observed error for OpenLibm + {+0x1.4d84db080b9fdp+21, +0x1.6e21c4ff6aec3p-1}, + // Other worst-case observed errors + {-0x1.f8b791cafcdefp+4, -0x1.073ca87470df9p-3 }, + {-0x1.0e16eb809a35dp+944, +0x1.b5e361ed01dacp-2}, + {-0x1.85e624577c23ep-1, -0x1.614ac15b6df5ap-1}, + {-0x1.842d8ec8f752fp+21, -0x1.6ce864edeaffdp-1}, + {-0x1.07e4c92b5349dp+4, +0x1.6a096375ffb23p-1}, + {-0x1.13a5ccd87c9bbp+1008, -0x1.27b3964185d8dp-1}, + {-0x1.11b624b546894p+9, -0x1.6a35f2416aba8p-1}, + {-0x1.1c49ad613ff3bp+19, -0x1.fffe203cfabe1p-2}, + {-0x1.f05e952d81b89p+5, +0x1.6a2319a85a544p-1}, }; for(double[] testCase: testCases) { @@ -195,6 +263,9 @@ public class WorstCaseTests { return failures; } + /* + * 1 ulp stated error bound + */ private static int testWorstAsin() { int failures = 0; double [][] testCases = { @@ -210,6 +281,18 @@ public class WorstCaseTests { {+0x1.1ED06D50F7E88p-1, +0x1.30706F699466Dp-1}, {+0x1.D5B05A89D3E77p-1, +0x1.29517AB4C132Ap+0}, {+0x1.E264357EA0E29p-1, +0x1.3AA301F6EBB1Dp+0}, + + // Worst-case observed error for OpenLibm + {-0x1.004d1c5a9400bp-1, -0x1.0c6e322e8a28bp-1}, + // Other worst-case observed errors + {-0x1.0000045b2c904p-3, -0x1.00abe5252746cp-3}, + {+0x1.6c042a6378102p-1, +0x1.94eda53f72c5ap-1}, + {-0x1.00d44cccfa99p-1, -0x1.0d0a6a0e79e15p-1}, + {+0x1.eae75e3d82b6fp-2, +0x1.fff7d74b1ea4fp-2}, + {-0x1.0239000439deep-1, -0x1.0ea71ea2a7cd7p-1}, + {+0x1.0479b37d95e5cp-1, +0x1.1143fafdc5b2cp-1}, + {-0x1.2ef2481799c7cp-1, -0x1.442d10aa50906p-1}, + {+0x1.df27e1c764802p-2, +0x1.f2a0f0c96deefp-2}, }; for(double[] testCase: testCases) { @@ -227,6 +310,9 @@ public class WorstCaseTests { return failures; } + /* + * 1 ulp stated error bound + */ private static int testWorstCos() { int failures = 0; double [][] testCases = { @@ -243,6 +329,19 @@ public class WorstCaseTests { {+0x1.7CB7648526F99p-1, +0x1.78DAF01036D0Cp-1}, {+0x1.C65A170474549p-1, +0x1.434A3645BE208p-1}, {+0x1.6B8A6273D7C21p+0, +0x1.337FC5B072C52p-3}, + + // Worst-case observed error for OpenLibm + {-0x1.34e729fd08086p+21, +0x1.6a6a0d6a17f0fp-1}, + // Other worst-case observed errors + {-0x1.7120161c92674p+0, +0x1.0741fb7683849p-3}, + {-0x1.d19ebc5567dcdp+311, -0x1.b5d2f45f68958p-2}, + {+0x1.91e60af551108p-1, +0x1.6a32aaa34b118p-1}, + {-0x1.4ae182c1ab422p+21, -0x1.6c9c3831b6e3bp-1}, + {-0x1.34e729fd08086p+21, +0x1.6a6a0d6a17f0fp-1}, + {+0x1.2f29eb4e99fa2p+7, +0x1.6a0751dc5d2bbp-1}, + {-0x1.9200634d4471fp-1, +0x1.6a200b493230cp-1}, + {+0x1.25133ca3904dfp+20, -0x1.fb399cd6fe563p-3}, + {+0x1.2a33ae49ab15dp+1, -0x1.60524e89bbcb2p-1}, }; for(double[] testCase: testCases) { @@ -260,6 +359,9 @@ public class WorstCaseTests { return failures; } + /* + * 1 ulp stated error bound + */ private static int testWorstAcos() { int failures = 0; double [][] testCases = { @@ -267,6 +369,18 @@ public class WorstCaseTests { {+0x1.4182199998587p-1, +0x1.C8A538AE83D1Fp-1}, {+0x1.E45A1C93651ECp-1, +0x1.520DC553F6B23p-2}, {+0x1.F10FC61E2C78Fp-1, +0x1.EFEEF61D39AC1p-3}, + + // Worst-case observed error for OpenLibm + {-0x1.0068b067c6feep-1, +0x1.0c335e2f0726fp1}, + // Other worst-case observed errors + {+0x1.dffffb3488a4p-1, 0x1.6bf3a4a4f4dcbp-2}, + {+0x1.6c05eb219ec46p-1, 0x1.8f4f472807261p-1}, + {+0x1.35b03e336a82bp-1, 0x1.d7a84ec2f6707p-1}, + {-0x1.8d313198a2e03p-53, 0x1.921fb54442d19p0}, + {-0x1.010fd0ad6aa41p-1, 0x1.0c63a8cd23beep1}, + {+0x1.251869c3f7881p-1, 0x1.ec2ff0c102683p-1}, + {+0x1.266637a3d2bbcp-1, 0x1.ea98637533648p-1}, + {-0x1.36b1482765f6dp-1, 0x1.1c8666ca1cab1p1}, }; for(double[] testCase: testCases) { @@ -284,6 +398,9 @@ public class WorstCaseTests { return failures; } + /* + * 1.25 ulp stated error bound + */ private static int testWorstTan() { int failures = 0; double [][] testCases = { @@ -296,6 +413,9 @@ public class WorstCaseTests { {+0x1.D696BFA988DB9p-2, +0x1.FAC71CD34EEA6p-2}, {+0x1.46AC372243536p-1, +0x1.7BA49F739829Ep-1}, {+0x0.A3561B9121A9Bp+0, +0x0.BDD24FB9CC14Fp+0}, + + // Worst-case observed error for OpenLibm, outside of 1 ulp error + // {0x1.3f9605aaeb51bp+21, -0x1.9678ee5d64934p-1}, // 1.02 }; for(double[] testCase: testCases) { @@ -313,6 +433,9 @@ public class WorstCaseTests { return failures; } + /* + * 1 ulp stated error bound + */ private static int testWorstAtan() { int failures = 0; double [][] testCases = { @@ -328,6 +451,19 @@ public class WorstCaseTests { {+0x1.7BA49F739829Fp-1, +0x1.46AC372243536p-1}, {+0x0.BDD24FB9CC14F8p+0, +0x0.A3561B9121A9Bp+0}, + + // Worst-case observed error + {0x1.62ff6a1682c25p-1, +0x1.3666b15c8756ap-1}, + // Other worst-case observed errors + {+0x1.f9004c4fef9eap-4, 0x1.f67727f5618f2p-4}, + {-0x1.ffff8020d3d1dp-7, -0x1.fff4d5e4886c7p-7}, + {+0x1.0103fc4ebaaa8p+1, 0x1.1bd5c375c97b5p0}, + {+0x1.01e0be37af68fp+1, 0x1.1c2d45ec82765p0}, + {-0x1.60370d15396b7p-1, -0x1.348461c347fd9p-1}, + {+0x1.032b4811f3dc5p+0, 0x1.9545fd233ee14p-1}, + {+0x1.52184b1b9bd9bp+0, 0x1.d86de33c93814p-1}, + {-0x1.0684fa9fa7481p+0, -0x1.988f9da70b11ap-1}, + }; for(double[] testCase: testCases) { @@ -345,6 +481,9 @@ public class WorstCaseTests { return failures; } + /* + * 1 ulp stated error bound + */ private static int testWorstPow2() { int failures = 0; double [][] testCases = { diff --git a/test/jdk/java/lang/StrictMath/Atan2Tests.java b/test/jdk/java/lang/StrictMath/Atan2Tests.java index 4ef76b5ed66..c125119fee4 100644 --- a/test/jdk/java/lang/StrictMath/Atan2Tests.java +++ b/test/jdk/java/lang/StrictMath/Atan2Tests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,6 +53,7 @@ public class Atan2Tests { public static void main(String... args) { int failures = 0; + failures += testAtan2(); failures += testAgainstTranslit(); if (failures > 0) { @@ -62,6 +63,24 @@ public class Atan2Tests { } } + private static int testAtan2() { + int failures = 0; + + // Empirical worst-case points in other libraries with larger + // worst-case errors than FDLIBM + double[][] testCases = { + {-0x0.00000000039a2p-1022, 0x0.000fdf02p-1022, -0x1.d0ce6fac85de9p-27}, + { 0x1.9173ea8221453p+842, 0x1.8c6f1b4b72f3ap+842, 0x1.9558272cbbdf9p-1}, + { 0x1.9cde4ff190e45p+931, 0x1.37d91467e558bp+931, 0x1.d909432d6f9c8p-1}, + { 0x1.401ec07d65549p+888, 0x1.3c3976605bb0cp+888, 0x1.95421cda9c65bp-1}, + }; + + for (double[] testCase : testCases) { + failures += testAtan2Case(testCase[0], testCase[1], testCase[2]); + } + return failures; + } + // Initialize shared random number generator private static java.util.Random random = RandomFactory.getRandom(); diff --git a/test/jdk/java/lang/StrictMath/CubeRootTests.java b/test/jdk/java/lang/StrictMath/CubeRootTests.java index 0423f1ff087..474a7760984 100644 --- a/test/jdk/java/lang/StrictMath/CubeRootTests.java +++ b/test/jdk/java/lang/StrictMath/CubeRootTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ import jdk.test.lib.RandomFactory; public class CubeRootTests { private CubeRootTests(){} - public static void main(String [] argv) { + public static void main(String... args) { int failures = 0; failures += testCubeRoot(); @@ -470,7 +470,16 @@ public class CubeRootTests { {0x0.0000000ffffffp-1022, 0x1.ffffff5555552p-351}, {0x0.0000ffffffap-1022, 0x1.ffffffcp-347}, {0x0.0000ffffffff8p-1022, 0x1.ffffffffaaaabp-347}, - {0x0.0fffffffffffbp-1022, 0x1.fffffffffffcbp-343} + {0x0.0fffffffffffbp-1022, 0x1.fffffffffffcbp-343}, + + // Empirical worst-case points in other libraries with + // larger worst-case errors than FDLIBM + { 0x1.7a337e1ba1ec2p-257, 0x1.6f59116ea884dp-86}, + { 0x0.7ffffffffffffp-1022, 0x1.fffffffffffffp-342}, + {-0x1.00ddafe7d9deep-885, -0x1.0049d002f249fp-295}, + { 0x1.fed1fe9f1122dp+11, 0x1.ff9b410e1f8b4p3}, + {-0x1.55cd285f321f6p-64, -0x1.bf7a40bced214p-22}, + { 0x1.fffb101d89c1dp-332, 0x1.965e9bf0fb7fbp-111}, }; for(double[] testCase: testCases) diff --git a/test/jdk/java/lang/StrictMath/ExpTests.java b/test/jdk/java/lang/StrictMath/ExpTests.java index 45e1816da59..9f7d2d1ffd0 100644 --- a/test/jdk/java/lang/StrictMath/ExpTests.java +++ b/test/jdk/java/lang/StrictMath/ExpTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -79,6 +79,14 @@ public class ExpTests { {Math.nextUp(EXP_OVERFLOW_THRESH), Double.POSITIVE_INFINITY}, {Math.nextDown(EXP_UNDERFLOW_THRESH), +0.0}, {EXP_UNDERFLOW_THRESH, +Double.MIN_VALUE}, + + // FDLIBM exp(1.0) does *not* return Math.E + {1.0, Math.nextUp(Math.E)}, + // Cases observed to differ between FDLIBM and other implementations. + {+0x1.2e8f20cf3cbe7p+8, 0x1.6a2a59cc78bf8p436}, + {-0x1.49f33ad2c1c58p+9, 0x1.f3ccc815431b6p-953}, + {+0x1.fce66609f7428p+5, 0x1.b59724cb0bc4cp91}, + {-0x1.49f33ad2c1c58p+9, 0x1.f3ccc815431b6p-953}, }; for(double[] testCase: testCases) diff --git a/test/jdk/java/lang/StrictMath/Expm1Tests.java b/test/jdk/java/lang/StrictMath/Expm1Tests.java index fc2c5bbc813..7e5e9c8de67 100644 --- a/test/jdk/java/lang/StrictMath/Expm1Tests.java +++ b/test/jdk/java/lang/StrictMath/Expm1Tests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -863,6 +863,14 @@ public class Expm1Tests { {0x1.619ffffffdccep9, 0x1.45663d67095d1p1020}, {0x1.621ffffffdccep9, 0x1.ba437b80a6915p1021}, {0x1.629ffffffdccep9, 0x1.2c8c9d8cda0c8p1023}, + + // Empirical worst-case points in other libraries with + // larger worst-case errors than FDLIBM + { 0x1.63be411e096ep-2, 0x1.a95c1f32ed8d5p-2}, + {-0x1.62d7c116d2e32p-1, -0x1.fff3910089df7p-2}, + { 0x1.633f993a730c9p-2, 0x1.a8a8e5d1e41ccp-2}, + { 0x1.a0e95d59498e9p-2, 0x1.01499d91804bdp-1}, + { 0x1.632cfb1033275p-2, 0x1.a88e8f5550a34p-2}, }; for (double[] testCase: testCases) diff --git a/test/jdk/java/lang/StrictMath/HyperbolicTests.java b/test/jdk/java/lang/StrictMath/HyperbolicTests.java index 0314abace7b..68e6a27124c 100644 --- a/test/jdk/java/lang/StrictMath/HyperbolicTests.java +++ b/test/jdk/java/lang/StrictMath/HyperbolicTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -340,6 +340,11 @@ public class HyperbolicTests { {0x1.fffffffffff68p4, 0x1.1f43fcc4b5b83p45}, {0x1.fffffffffffd4p4, 0x1.1f43fcc4b6316p45}, {0x1.0p5, 0x1.1f43fcc4b662cp45}, + // Empirical worst-case points in other libraries with + // larger worst-case errors than FDLIBM + {-0x1.633c654fee2bap+9, -0x1.fdf25fc26e7cp1023}, + {-0x1.633cae1335f26p+9, -0x1.ff149489e50a1p1023}, + { 0x1.9fcba01feb507p-2, 0x1.ab50d8e4d8c56p-2}, }; for (double[] testCase: testCases) @@ -381,6 +386,13 @@ public class HyperbolicTests { {0x1.0p4, 0x1.0f2ebd0a8005cp22}, {0x1.fffffffffffd4p4, 0x1.1f43fcc4b6316p45}, {0x1.0p5, 0x1.1f43fcc4b662cp45}, + // Empirical worst-case points in other libraries with + // larger worst-case errors than FDLIBM + {-0x1.633c654fee2bap+9, 0x1.fdf25fc26e7cp1023}, + { 0x1.ff76fb3f476d5p+0, 0x1.e0976c8f0ebdfp1}, + { 0x1.633cc2ae1c934p+9, 0x1.ff66e0de4dc6fp1023}, + {-0x1.1ff088806d82ep+3, 0x1.f97ccb0aef314p11}, + {-0x1.628af341989dap+9, 0x1.fdf28623ef923p1021}, }; for (double[] testCase: testCases) @@ -450,6 +462,9 @@ public class HyperbolicTests { {0x1.fffffffffffe1p0, 0x1.ed9505e1bc3cfp-1}, {0x1.ffffffffffed8p1, 0x1.ffa81708a0b4p-1}, {0x1.fffffffffff92p1, 0x1.ffa81708a0b41p-1}, + // Empirical worst-case points in other libraries with + // larger worst-case errors than FDLIBM + {-0x1.c41e527b70f43p-3, -0x1.bcea047cc736cp-3}, }; for (double[] testCase: testCases) diff --git a/test/jdk/java/lang/StrictMath/HypotTests.java b/test/jdk/java/lang/StrictMath/HypotTests.java index c714dcf1499..bc7d44102a2 100644 --- a/test/jdk/java/lang/StrictMath/HypotTests.java +++ b/test/jdk/java/lang/StrictMath/HypotTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -705,6 +705,11 @@ public class HypotTests { {0x0.0000000000001p-1022, 0x0.0000000000001p-1022, 0x0.0000000000001p-1022}, {0x0.0000000000002p-1022, 0x0.0000000000001p-1022, 0x0.0000000000002p-1022}, {0x0.0000000000003p-1022, 0x0.0000000000002p-1022, 0x0.0000000000004p-1022}, + + // Empirical worst-case points in other libraries with + // larger worst-case errors than FDLIBM + {0x0.fffffffffffffp-1022, 0x0.0000000000001p-1022, 0x0.fffffffffffffp-1022}, + {0x1.41fcfeeb2e246p+420, 0x1.8d4d41eacdeccp+420, 0x1.ff65325de5517p420}, }; for (double[] testCase: testCases) diff --git a/test/jdk/java/lang/StrictMath/InverseTrigTests.java b/test/jdk/java/lang/StrictMath/InverseTrigTests.java index ca5bc59d2c9..9f92cae6bc4 100644 --- a/test/jdk/java/lang/StrictMath/InverseTrigTests.java +++ b/test/jdk/java/lang/StrictMath/InverseTrigTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,9 +56,9 @@ public class InverseTrigTests { failures += testAgainstTranslitCommon(); - failures += testAgainstTranslitAsin(); - failures += testAgainstTranslitAcos(); - failures += testAgainstTranslitAtan(); + failures += testAsin(); + failures += testAcos(); + failures += testAtan(); if (failures > 0) { System.err.println("Testing the inverse trig functions incurred " @@ -113,7 +113,7 @@ public class InverseTrigTests { /** * Test StrictMath.asin against transliteration port of asin. */ - private static int testAgainstTranslitAsin() { + private static int testAsin() { int failures = 0; // Probe near decision points in the FDLIBM algorithm. @@ -132,13 +132,25 @@ public class InverseTrigTests { failures += testRangeMidpoint(testPoint, Math.ulp(testPoint), 1000, InverseTrigTest.ASIN); } + // Empirical worst-case points in other libraries with larger + // worst-case error than FDLIBM + double [][] testCases = { + {-0x1.00d44cccfa99p-1, -0x1.0d0a6a0e79e15p-1}, + {-0x1.0239000439deep-1, -0x1.0ea71ea2a7cd7p-1}, + {+0x1.0479b37d95e5cp-1, 0x1.1143fafdc5b2cp-1}, + {-0x1.2ef2481799c7cp-1, -0x1.442d10aa50906p-1}, + }; + for (double[] testCase : testCases) { + failures += testAsinCase(testCase[0], testCase[1]); + } + return failures; } /** * Test StrictMath.acos against transliteration port of acos. */ - private static int testAgainstTranslitAcos() { + private static int testAcos() { int failures = 0; // Probe near decision points in the FDLIBM algorithm. @@ -154,13 +166,26 @@ public class InverseTrigTests { failures += testRangeMidpoint(testPoint, Math.ulp(testPoint), 1000, InverseTrigTest.ACOS); } + // Empirical worst-case points in other libraries with larger + // worst-case error than FDLIBM + double [][] testCases = { + {+0x1.35b03e336a82bp-1, 0x1.d7a84ec2f6707p-1}, + {-0x1.8d313198a2e03p-53, 0x1.921fb54442d19p0}, + {-0x1.010fd0ad6aa41p-1, 0x1.0c63a8cd23befp1}, + {+0x1.251869c3f7881p-1, 0x1.ec2ff0c102684p-1}, + {+0x1.266637a3d2bbcp-1, 0x1.ea98637533648p-1}, + }; + for (double[] testCase : testCases) { + failures += testAcosCase(testCase[0], testCase[1]); + } + return failures; } /** * Test StrictMath.atan against transliteration port of atan */ - private static int testAgainstTranslitAtan() { + private static int testAtan() { int failures = 0; // Probe near decision points in the FDLIBM algorithm. @@ -177,7 +202,21 @@ public class InverseTrigTests { }; for (double testPoint : decisionPoints) { - failures += testRangeMidpoint(testPoint, Math.ulp(testPoint), 1000, InverseTrigTest.ATAN); + failures += testRangeMidpoint(testPoint, Math.ulp(testPoint), 1000, InverseTrigTest.ATAN); + } + + // Empirical worst-case points in other libraries with larger + // worst-case error than FDLIBM + double [][] testCases = { + {+0x1.0103fc4ebaaa8p+1, 0x1.1bd5c375c97b5p0}, + {+0x1.01e0be37af68fp+1, 0x1.1c2d45ec82765p0}, + {-0x1.60370d15396b7p-1, -0x1.348461c347fd9p-1}, + {+0x1.032b4811f3dc5p+0, 0x1.9545fd233ee14p-1}, + {+0x1.52184b1b9bd9bp+0, 0x1.d86de33c93814p-1}, + {-0x1.0684fa9fa7481p+0, -0x1.988f9da70b11ap-1}, + }; + for (double[] testCase : testCases) { + failures += testAtanCase(testCase[0], testCase[1]); } return failures; diff --git a/test/jdk/java/lang/StrictMath/Log10Tests.java b/test/jdk/java/lang/StrictMath/Log10Tests.java index 33aec723ec8..6cd8427c438 100644 --- a/test/jdk/java/lang/StrictMath/Log10Tests.java +++ b/test/jdk/java/lang/StrictMath/Log10Tests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -721,6 +721,13 @@ public class Log10Tests { {0x1.3fffffffffadfp25, 0x1.e7d9a8edb474dp2}, {0x1.3fffffffffebdp25, 0x1.e7d9a8edb47a2p2}, {0x1.4p25, 0x1.e7d9a8edb47bfp2}, + + // Empirical worst-case points in other libraries with + // larger worst-case errors than FDLIBM + {0x1.de02157073b31p-1, -0x1.e8cfabf160ec6p-6}, + {0x1.10fdf4211fd45p+0, 0x1.c946e0d48c148p-6}, + {0x1.55535a0140a21p+0, 0x1.ffb56ebe85597p-4}, + {0x1.803dea263187fp-1, -0x1.fea1086f5a316p-4}, }; for (double[] testCase: testCases) diff --git a/test/jdk/java/lang/StrictMath/Log1pTests.java b/test/jdk/java/lang/StrictMath/Log1pTests.java index 4f987b4af16..b8a8592812f 100644 --- a/test/jdk/java/lang/StrictMath/Log1pTests.java +++ b/test/jdk/java/lang/StrictMath/Log1pTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -209,6 +209,15 @@ public class Log1pTests { {0x1.7688bb5394bd3p325, 0x1.c34e8276daa48p7}, {0x1.d42aea2878b45p328, 0x1.c7e96ee5c7f87p7}, {0x1.249ad2594989p332, 0x1.cc845b54b54a6p7}, + + // Empirical worst-case points in other libraries with + // larger worst-case errors than FDLIBM + {-0x1.2bf183e0344b2p-2, -0x1.62ebb44459d79p-2}, + {-0x1.2bf32aaf122e2p-2, -0x1.62ee0a3a4baf9p-2}, + {-0x1.8000000000000p-53, -0x1.8000000000001p-53}, + {-0x1.2e496d25897ecp-2, -0x1.663d81cb08f56p-2}, + {-0x1.ffffffbaefe27p-2, -0x1.62e42faa93817p-1}, + {-0x1.5efad5491a79bp-1022, -0x1.5efad5491a79bp-1022}, }; for (double[] testCase: testCases) diff --git a/test/jdk/java/lang/StrictMath/LogTests.java b/test/jdk/java/lang/StrictMath/LogTests.java index a3e29b5cd08..05b91c60c14 100644 --- a/test/jdk/java/lang/StrictMath/LogTests.java +++ b/test/jdk/java/lang/StrictMath/LogTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,6 +68,10 @@ public class LogTests { {0x1.0000000744b3ap632, 0x1.b611ab2bd53cep8}, {0x1.000000037d81fp766, 0x1.0979b1dbc4a42p9}, {0x1.000000024028p991, 0x1.577455642bb92p9}, + // Empirical worst-case points + {0x1.0ffea3878db6bp+0, 0x1.f07a0cca521fp-5}, + {0x1.490af72a25a81p-1, -0x1.c4bf7ae48f078p-2}, + {0x1.69e7aa6da2df5p-1, -0x1.634508c9adfp-2}, }; for (double[] testCase: testCases) diff --git a/test/jdk/java/lang/StrictMath/TrigTests.java b/test/jdk/java/lang/StrictMath/TrigTests.java index 369b1c2aef9..c4f7dab547f 100644 --- a/test/jdk/java/lang/StrictMath/TrigTests.java +++ b/test/jdk/java/lang/StrictMath/TrigTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -164,6 +164,11 @@ public class TrigTests { {0x1.00000000000fcp299, 0x1.78ad2fd7aef78p-1}, {0x1.0000000000002p300, -0x1.1adaf3550facp-1}, {0x1.00000000001afp1023, 0x1.d1c804ef2eeccp-1}, + // Empirical worst-case points + {-0x1.f8b791cafcdefp+4, -0x1.073ca87470dfap-3}, + {-0x1.0e16eb809a35dp+944, 0x1.b5e361ed01dadp-2}, + {-0x1.842d8ec8f752fp+21, -0x1.6ce864edeaffep-1}, + {-0x1.1c49ad613ff3bp+19, -0x1.fffe203cfabe1p-2}, }; for (double[] testCase: testCases) { @@ -265,7 +270,15 @@ public class TrigTests { {0x1.000000000011cp299, 0x1.8a6f42eaa3d1fp0}, {0x1.000000000001cp300, -0x1.b30fc9f73002cp-1}, {0x1.0000000000013p500, -0x1.c4e46751be12cp-1}, - {0x1.00000000000ep1023, -0x1.d52c4ec04f108p-2} + {0x1.00000000000ep1023, -0x1.d52c4ec04f108p-2}, + // Empirical worst-case points in other libraries with + // larger worst-case errors than FDLIBM + {+0x1.371a47b7e4eb2p+11, 0x1.9ded57c9ff46ap-1}, + {-0x1.a81d98fc58537p+6 , 0x1.ffd83332326fdp-1}, + {-0x1.13a5ccd87c9bbp+1008, -0x1.6a3815320e5cfp-1}, + {-0x1.4d7c8b8320237p+11, -0x1.9dec1f1b36ecdp-1}, + {+0x1.da7a85a88bbecp+11, 0x1.ff7ae7631230ep-1}, + {-0x1.66af736e8555p+18, -0x1.fc3d1cb02536bp-1}, }; for (double[] testCase: testCases) { |