diff options
author | Martynas Venckus <martynas@cvs.openbsd.org> | 2011-05-30 20:23:36 +0000 |
---|---|---|
committer | Martynas Venckus <martynas@cvs.openbsd.org> | 2011-05-30 20:23:36 +0000 |
commit | efdf89924a8689115496c1593b1f1f846f3d49ad (patch) | |
tree | 5d85a4b69db843d90b3cbe70bb8b07a42993be9b /regress/lib | |
parent | c0afed1c962ca1f5d2caea522e991d5956ee02a2 (diff) |
Import regression test vectors from the Cephes math library. This
covers C99 double, extended and quadruple precision functions.
Stephen relicensed this under the right license.
Testvect contains special values from C9X section F.9. Monot
contains test vectors synthesized around NPTS points, which are
near the boundaries where the algorithms (likely) change their
methods; helping to detect coding/monotonicity errors.
Note that a lot of extended and quadruple precision tests are if0'd
for now; since our math library is incomplete. Hopefully this
will change soon. (-;
Diffstat (limited to 'regress/lib')
-rw-r--r-- | regress/lib/libm/cephes/Makefile | 9 | ||||
-rw-r--r-- | regress/lib/libm/cephes/cephes.c | 50 | ||||
-rw-r--r-- | regress/lib/libm/cephes/cephes.h | 13 | ||||
-rw-r--r-- | regress/lib/libm/cephes/const.c | 263 | ||||
-rw-r--r-- | regress/lib/libm/cephes/mconf.h | 212 | ||||
-rw-r--r-- | regress/lib/libm/cephes/monot.c | 341 | ||||
-rw-r--r-- | regress/lib/libm/cephes/monotl.c | 475 | ||||
-rw-r--r-- | regress/lib/libm/cephes/monotll.c | 810 | ||||
-rw-r--r-- | regress/lib/libm/cephes/polevll.c | 194 | ||||
-rw-r--r-- | regress/lib/libm/cephes/testvect.c | 556 | ||||
-rw-r--r-- | regress/lib/libm/cephes/testvectl.c | 522 | ||||
-rw-r--r-- | regress/lib/libm/cephes/testvectll.c | 551 |
12 files changed, 3996 insertions, 0 deletions
diff --git a/regress/lib/libm/cephes/Makefile b/regress/lib/libm/cephes/Makefile new file mode 100644 index 00000000000..97523155e3b --- /dev/null +++ b/regress/lib/libm/cephes/Makefile @@ -0,0 +1,9 @@ +# $OpenBSD: Makefile,v 1.1 2011/05/30 20:23:35 martynas Exp $ + +PROG = cephes +SRCS = cephes.c const.c monot.c monotl.c monotll.c polevll.c \ + testvect.c testvectl.c testvectll.c +LDADD = -lm +DPADD = ${LIBM} + +.include <bsd.regress.mk> diff --git a/regress/lib/libm/cephes/cephes.c b/regress/lib/libm/cephes/cephes.c new file mode 100644 index 00000000000..e7a09208186 --- /dev/null +++ b/regress/lib/libm/cephes/cephes.c @@ -0,0 +1,50 @@ +/* $OpenBSD: cephes.c,v 1.1 2011/05/30 20:23:35 martynas Exp $ */ + +/* + * Written by Martynas Venckus. Public domain + */ + +#include <float.h> +#include <stdio.h> + +#include "cephes.h" + +int +main(void) +{ + int retval = 0; + + printf("=> Testing monot (double precision):\n"); + retval |= monot(); + putchar('\n'); + +#if LDBL_MANT_DIG == 64 + printf("=> Testing monotl (extended precision):\n"); + retval |= monotl(); + putchar('\n'); +#endif /* LDBL_MANT_DIG == 64 */ + +#if LDBL_MANT_DIG == 113 + printf("=> Testing monotll (quadruple precision):\n"); + retval |= monotll(); + putchar('\n'); +#endif /* LDBL_MANT_DIG == 113 */ + + printf("=> Testing testvect (double precision):\n"); + retval |= testvect(); + putchar('\n'); + +#if LDBL_MANT_DIG == 64 + printf("=> Testing testvectl (extended precision):\n"); + retval |= testvectl(); + putchar('\n'); +#endif /* LDBL_MANT_DIG == 64 */ + +#if LDBL_MANT_DIG == 113 + printf("=> Testing testvectll (quadruple precision):\n"); + retval |= testvectll(); + putchar('\n'); +#endif /* LDBL_MANT_DIG == 113 */ + + return (retval); +} diff --git a/regress/lib/libm/cephes/cephes.h b/regress/lib/libm/cephes/cephes.h new file mode 100644 index 00000000000..878ca6de7a2 --- /dev/null +++ b/regress/lib/libm/cephes/cephes.h @@ -0,0 +1,13 @@ +/* $OpenBSD: cephes.h,v 1.1 2011/05/30 20:23:35 martynas Exp $ */ + +/* + * Written by Martynas Venckus. Public domain + */ + +int monot(void); +int monotl(void); +int monotll(void); + +int testvect(void); +int testvectl(void); +int testvectll(void); diff --git a/regress/lib/libm/cephes/const.c b/regress/lib/libm/cephes/const.c new file mode 100644 index 00000000000..b419990e961 --- /dev/null +++ b/regress/lib/libm/cephes/const.c @@ -0,0 +1,263 @@ +/* $OpenBSD: const.c,v 1.1 2011/05/30 20:23:35 martynas Exp $ */ + +/* + * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* const.c + * + * Globally declared constants + * + * + * + * SYNOPSIS: + * + * extern double nameofconstant; + * + * + * + * + * DESCRIPTION: + * + * This file contains a number of mathematical constants and + * also some needed size parameters of the computer arithmetic. + * The values are supplied as arrays of hexadecimal integers + * for IEEE arithmetic; arrays of octal constants for DEC + * arithmetic; and in a normal decimal scientific notation for + * other machines. The particular notation used is determined + * by a symbol (DEC, IBMPC, or UNK) defined in the include file + * mconf.h. + * + * The default size parameters are as follows. + * + * For DEC and UNK modes: + * MACHEP = 1.38777878078144567553E-17 2**-56 + * MAXLOG = 8.8029691931113054295988E1 log(2**127) + * MINLOG = -8.872283911167299960540E1 log(2**-128) + * MAXNUM = 1.701411834604692317316873e38 2**127 + * + * For IEEE arithmetic (IBMPC): + * MACHEP = 1.11022302462515654042E-16 2**-53 + * MAXLOG = 7.09782712893383996843E2 log(2**1024) + * MINLOG = -7.08396418532264106224E2 log(2**-1022) + * MAXNUM = 1.7976931348623158E308 2**1024 + * + * The global symbols for mathematical constants are + * PI = 3.14159265358979323846 pi + * PIO2 = 1.57079632679489661923 pi/2 + * PIO4 = 7.85398163397448309616E-1 pi/4 + * SQRT2 = 1.41421356237309504880 sqrt(2) + * SQRTH = 7.07106781186547524401E-1 sqrt(2)/2 + * LOG2E = 1.4426950408889634073599 1/log(2) + * SQ2OPI = 7.9788456080286535587989E-1 sqrt( 2/pi ) + * LOGE2 = 6.93147180559945309417E-1 log(2) + * LOGSQ2 = 3.46573590279972654709E-1 log(2)/2 + * THPIO4 = 2.35619449019234492885 3*pi/4 + * TWOOPI = 6.36619772367581343075535E-1 2/pi + * + * These lists are subject to change. + */ + +#include "mconf.h" + +#ifdef UNK +#if 1 +double MACHEP = 1.11022302462515654042E-16; /* 2**-53 */ +#else +double MACHEP = 1.38777878078144567553E-17; /* 2**-56 */ +#endif +double UFLOWTHRESH = 2.22507385850720138309E-308; /* 2**-1022 */ +#ifdef DENORMAL +double MAXLOG = 7.09782712893383996732E2; /* log(MAXNUM) */ +/* double MINLOG = -7.44440071921381262314E2; */ /* log(2**-1074) */ +double MINLOG = -7.451332191019412076235E2; /* log(2**-1075) */ +#else +double MAXLOG = 7.08396418532264106224E2; /* log 2**1022 */ +double MINLOG = -7.08396418532264106224E2; /* log 2**-1022 */ +#endif +double MAXNUM = 1.79769313486231570815E308; /* 2**1024*(1-MACHEP) */ +double PI = 3.14159265358979323846; /* pi */ +double PIO2 = 1.57079632679489661923; /* pi/2 */ +double PIO4 = 7.85398163397448309616E-1; /* pi/4 */ +double SQRT2 = 1.41421356237309504880; /* sqrt(2) */ +double SQRTH = 7.07106781186547524401E-1; /* sqrt(2)/2 */ +double LOG2E = 1.4426950408889634073599; /* 1/log(2) */ +double SQ2OPI = 7.9788456080286535587989E-1; /* sqrt( 2/pi ) */ +double LOGE2 = 6.93147180559945309417E-1; /* log(2) */ +double LOGSQ2 = 3.46573590279972654709E-1; /* log(2)/2 */ +double THPIO4 = 2.35619449019234492885; /* 3*pi/4 */ +double TWOOPI = 6.36619772367581343075535E-1; /* 2/pi */ +#ifdef INFINITIES +double INFINITY = 1.0/0.0; /* 99e999; */ +#else +double INFINITY = 1.79769313486231570815E308; /* 2**1024*(1-MACHEP) */ +#endif +#ifdef NANS +double NAN = 1.0/0.0 - 1.0/0.0; +#else +double NAN = 0.0; +#endif +#ifdef MINUSZERO +double NEGZERO = -0.0; +#else +double NEGZERO = 0.0; +#endif +#endif + +#ifdef IBMPC + /* 2**-53 = 1.11022302462515654042E-16 */ +unsigned short MACHEP[4] = {0x0000,0x0000,0x0000,0x3ca0}; +unsigned short UFLOWTHRESH[4] = {0x0000,0x0000,0x0000,0x0010}; +#ifdef DENORMAL + /* log(MAXNUM) = 7.09782712893383996732224E2 */ +unsigned short MAXLOG[4] = {0x39ef,0xfefa,0x2e42,0x4086}; + /* log(2**-1074) = - -7.44440071921381262314E2 */ +/*unsigned short MINLOG[4] = {0x71c3,0x446d,0x4385,0xc087};*/ +unsigned short MINLOG[4] = {0x3052,0xd52d,0x4910,0xc087}; +#else + /* log(2**1022) = 7.08396418532264106224E2 */ +unsigned short MAXLOG[4] = {0xbcd2,0xdd7a,0x232b,0x4086}; + /* log(2**-1022) = - 7.08396418532264106224E2 */ +unsigned short MINLOG[4] = {0xbcd2,0xdd7a,0x232b,0xc086}; +#endif + /* 2**1024*(1-MACHEP) = 1.7976931348623158E308 */ +unsigned short MAXNUM[4] = {0xffff,0xffff,0xffff,0x7fef}; +unsigned short PI[4] = {0x2d18,0x5444,0x21fb,0x4009}; +unsigned short PIO2[4] = {0x2d18,0x5444,0x21fb,0x3ff9}; +unsigned short PIO4[4] = {0x2d18,0x5444,0x21fb,0x3fe9}; +unsigned short SQRT2[4] = {0x3bcd,0x667f,0xa09e,0x3ff6}; +unsigned short SQRTH[4] = {0x3bcd,0x667f,0xa09e,0x3fe6}; +unsigned short LOG2E[4] = {0x82fe,0x652b,0x1547,0x3ff7}; +unsigned short SQ2OPI[4] = {0x3651,0x33d4,0x8845,0x3fe9}; +unsigned short LOGE2[4] = {0x39ef,0xfefa,0x2e42,0x3fe6}; +unsigned short LOGSQ2[4] = {0x39ef,0xfefa,0x2e42,0x3fd6}; +unsigned short THPIO4[4] = {0x21d2,0x7f33,0xd97c,0x4002}; +unsigned short TWOOPI[4] = {0xc883,0x6dc9,0x5f30,0x3fe4}; +#ifdef INFINITIES +unsigned short INFINITY[4] = {0x0000,0x0000,0x0000,0x7ff0}; +#else +unsigned short INFINITY[4] = {0xffff,0xffff,0xffff,0x7fef}; +#endif +#ifdef NANS +unsigned short NAN[4] = {0x0000,0x0000,0x0000,0x7ffc}; +#else +unsigned short NAN[4] = {0x0000,0x0000,0x0000,0x0000}; +#endif +#ifdef MINUSZERO +unsigned short NEGZERO[4] = {0x0000,0x0000,0x0000,0x8000}; +#else +unsigned short NEGZERO[4] = {0x0000,0x0000,0x0000,0x0000}; +#endif +#endif + +#ifdef MIEEE + /* 2**-53 = 1.11022302462515654042E-16 */ +unsigned short MACHEP[4] = {0x3ca0,0x0000,0x0000,0x0000}; +unsigned short UFLOWTHRESH[4] = {0x0010,0x0000,0x0000,0x0000}; +#ifdef DENORMAL + /* log(2**1024) = 7.09782712893383996843E2 */ +unsigned short MAXLOG[4] = {0x4086,0x2e42,0xfefa,0x39ef}; + /* log(2**-1074) = - -7.44440071921381262314E2 */ +/* unsigned short MINLOG[4] = {0xc087,0x4385,0x446d,0x71c3}; */ +unsigned short MINLOG[4] = {0xc087,0x4910,0xd52d,0x3052}; +#else + /* log(2**1022) = 7.08396418532264106224E2 */ +unsigned short MAXLOG[4] = {0x4086,0x232b,0xdd7a,0xbcd2}; + /* log(2**-1022) = - 7.08396418532264106224E2 */ +unsigned short MINLOG[4] = {0xc086,0x232b,0xdd7a,0xbcd2}; +#endif + /* 2**1024*(1-MACHEP) = 1.7976931348623158E308 */ +unsigned short MAXNUM[4] = {0x7fef,0xffff,0xffff,0xffff}; +unsigned short PI[4] = {0x4009,0x21fb,0x5444,0x2d18}; +unsigned short PIO2[4] = {0x3ff9,0x21fb,0x5444,0x2d18}; +unsigned short PIO4[4] = {0x3fe9,0x21fb,0x5444,0x2d18}; +unsigned short SQRT2[4] = {0x3ff6,0xa09e,0x667f,0x3bcd}; +unsigned short SQRTH[4] = {0x3fe6,0xa09e,0x667f,0x3bcd}; +unsigned short LOG2E[4] = {0x3ff7,0x1547,0x652b,0x82fe}; +unsigned short SQ2OPI[4] = {0x3fe9,0x8845,0x33d4,0x3651}; +unsigned short LOGE2[4] = {0x3fe6,0x2e42,0xfefa,0x39ef}; +unsigned short LOGSQ2[4] = {0x3fd6,0x2e42,0xfefa,0x39ef}; +unsigned short THPIO4[4] = {0x4002,0xd97c,0x7f33,0x21d2}; +unsigned short TWOOPI[4] = {0x3fe4,0x5f30,0x6dc9,0xc883}; +#ifdef INFINITIES +unsigned short INFINITY[4] = {0x7ff0,0x0000,0x0000,0x0000}; +#else +unsigned short INFINITY[4] = {0x7fef,0xffff,0xffff,0xffff}; +#endif +#ifdef NANS +unsigned short NAN[4] = {0x7ff8,0x0000,0x0000,0x0000}; +#else +unsigned short NAN[4] = {0x0000,0x0000,0x0000,0x0000}; +#endif +#ifdef MINUSZERO +unsigned short NEGZERO[4] = {0x8000,0x0000,0x0000,0x0000}; +#else +unsigned short NEGZERO[4] = {0x0000,0x0000,0x0000,0x0000}; +#endif +#endif + +#ifdef DEC + /* 2**-56 = 1.38777878078144567553E-17 */ +unsigned short MACHEP[4] = {0022200,0000000,0000000,0000000}; +unsigned short UFLOWTHRESH[4] = {0x0080,0x0000,0x0000,0x0000}; + /* log 2**127 = 88.029691931113054295988 */ +unsigned short MAXLOG[4] = {041660,007463,0143742,025733,}; + /* log 2**-128 = -88.72283911167299960540 */ +unsigned short MINLOG[4] = {0141661,071027,0173721,0147572,}; + /* 2**127 = 1.701411834604692317316873e38 */ +unsigned short MAXNUM[4] = {077777,0177777,0177777,0177777,}; +unsigned short PI[4] = {040511,007732,0121041,064302,}; +unsigned short PIO2[4] = {040311,007732,0121041,064302,}; +unsigned short PIO4[4] = {040111,007732,0121041,064302,}; +unsigned short SQRT2[4] = {040265,002363,031771,0157145,}; +unsigned short SQRTH[4] = {040065,002363,031771,0157144,}; +unsigned short LOG2E[4] = {040270,0125073,024534,013761,}; +unsigned short SQ2OPI[4] = {040114,041051,0117241,0131204,}; +unsigned short LOGE2[4] = {040061,071027,0173721,0147572,}; +unsigned short LOGSQ2[4] = {037661,071027,0173721,0147572,}; +unsigned short THPIO4[4] = {040426,0145743,0174631,007222,}; +unsigned short TWOOPI[4] = {040042,0174603,067116,042025,}; +/* Approximate infinity by MAXNUM. */ +unsigned short INFINITY[4] = {077777,0177777,0177777,0177777,}; +unsigned short NAN[4] = {0000000,0000000,0000000,0000000}; +#ifdef MINUSZERO +unsigned short NEGZERO[4] = {0000000,0000000,0000000,0100000}; +#else +unsigned short NEGZERO[4] = {0000000,0000000,0000000,0000000}; +#endif +#endif + +#ifndef UNK +extern unsigned short MACHEP[]; +extern unsigned short UFLOWTHRESH[]; +extern unsigned short MAXLOG[]; +extern unsigned short UNDLOG[]; +extern unsigned short MINLOG[]; +extern unsigned short MAXNUM[]; +extern unsigned short PI[]; +extern unsigned short PIO2[]; +extern unsigned short PIO4[]; +extern unsigned short SQRT2[]; +extern unsigned short SQRTH[]; +extern unsigned short LOG2E[]; +extern unsigned short SQ2OPI[]; +extern unsigned short LOGE2[]; +extern unsigned short LOGSQ2[]; +extern unsigned short THPIO4[]; +extern unsigned short TWOOPI[]; +extern unsigned short INFINITY[]; +extern unsigned short NAN[]; +extern unsigned short NEGZERO[]; +#endif diff --git a/regress/lib/libm/cephes/mconf.h b/regress/lib/libm/cephes/mconf.h new file mode 100644 index 00000000000..d90a61c5aa7 --- /dev/null +++ b/regress/lib/libm/cephes/mconf.h @@ -0,0 +1,212 @@ +/* $OpenBSD: mconf.h,v 1.1 2011/05/30 20:23:35 martynas Exp $ */ + +/* + * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* mconf.h + * + * Common include file for math routines + * + * + * + * SYNOPSIS: + * + * #include "mconf.h" + * + * + * + * DESCRIPTION: + * + * This file contains definitions for error codes that are + * passed to the common error handling routine mtherr() + * (which see). + * + * The file also includes a conditional assembly definition + * for the type of computer arithmetic (IEEE, DEC, Motorola + * IEEE, or UNKnown). + * + * For Digital Equipment PDP-11 and VAX computers, certain + * IBM systems, and others that use numbers with a 56-bit + * significand, the symbol DEC should be defined. In this + * mode, most floating point constants are given as arrays + * of octal integers to eliminate decimal to binary conversion + * errors that might be introduced by the compiler. + * + * For little-endian computers, such as IBM PC, that follow the + * IEEE Standard for Binary Floating Point Arithmetic (ANSI/IEEE + * Std 754-1985), the symbol IBMPC should be defined. These + * numbers have 53-bit significands. In this mode, constants + * are provided as arrays of hexadecimal 16 bit integers. + * + * Big-endian IEEE format is denoted MIEEE. On some RISC + * systems such as Sun SPARC, double precision constants + * must be stored on 8-byte address boundaries. Since integer + * arrays may be aligned differently, the MIEEE configuration + * may fail on such machines. + * + * To accommodate other types of computer arithmetic, all + * constants are also provided in a normal decimal radix + * which one can hope are correctly converted to a suitable + * format by the available C language compiler. To invoke + * this mode, define the symbol UNK. + * + * An important difference among these modes is a predefined + * set of machine arithmetic constants for each. The numbers + * MACHEP (the machine roundoff error), MAXNUM (largest number + * represented), and several other parameters are preset by + * the configuration symbol. Check the file const.c to + * ensure that these values are correct for your computer. + * + * Configurations NANS, INFINITIES, MINUSZERO, and DENORMAL + * may fail on many systems. Verify that they are supposed + * to work on your computer. + */ + +/* Define if the `long double' type works. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if your processor stores words with the most significant + byte first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef WORDS_BIGENDIAN */ + +/* Define if floating point words are bigendian. */ +/* #undef FLOAT_WORDS_BIGENDIAN */ + +/* The number of bytes in a int. */ +#define SIZEOF_INT 4 + +/* Define if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Name of package */ +#define PACKAGE "cephes" + +/* Version number of package */ +#define VERSION "2.7" + +/* Constant definitions for math error conditions + */ + +#define DOMAIN 1 /* argument domain error */ +#define SING 2 /* argument singularity */ +#define OVERFLOW 3 /* overflow range error */ +#define UNDERFLOW 4 /* underflow range error */ +#define TLOSS 5 /* total loss of precision */ +#define PLOSS 6 /* partial loss of precision */ + +#define EDOM 33 +#define ERANGE 34 +/* Complex numeral. */ +typedef struct + { + double r; + double i; + } cmplx; + +#ifdef HAVE_LONG_DOUBLE +/* Long double complex numeral. */ +typedef struct + { + long double r; + long double i; + } cmplxl; +#endif + + +/* Type of computer arithmetic */ + +/* PDP-11, Pro350, VAX: + */ +/* #define DEC 1 */ + +/* Intel IEEE, low order words come first: + */ +/* #define IBMPC 1 */ + +/* Motorola IEEE, high order words come first + * (Sun 680x0 workstation): + */ +/* #define MIEEE 1 */ + +/* UNKnown arithmetic, invokes coefficients given in + * normal decimal format. Beware of range boundary + * problems (MACHEP, MAXLOG, etc. in const.c) and + * roundoff problems in pow.c: + * (Sun SPARCstation) + */ +#define UNK 1 + +/* If you define UNK, then be sure to set BIGENDIAN properly. */ +#ifdef FLOAT_WORDS_BIGENDIAN +#define BIGENDIAN 1 +#else +#define BIGENDIAN 0 +#endif +/* Define this `volatile' if your compiler thinks + * that floating point arithmetic obeys the associative + * and distributive laws. It will defeat some optimizations + * (but probably not enough of them). + * + * #define VOLATILE volatile + */ +#define VOLATILE + +/* For 12-byte long doubles on an i386, pad a 16-bit short 0 + * to the end of real constants initialized by integer arrays. + * + * #define XPD 0, + * + * Otherwise, the type is 10 bytes long and XPD should be + * defined blank (e.g., Microsoft C). + * + * #define XPD + */ +#define XPD 0, + +/* Define to support tiny denormal numbers, else undefine. */ +#define DENORMAL 1 + +/* Define to ask for infinity support, else undefine. */ +#define INFINITIES 1 + +/* Define to ask for support of numbers that are Not-a-Number, + else undefine. This may automatically define INFINITIES in some files. */ +#define NANS 1 + +/* Define to distinguish between -0.0 and +0.0. */ +#define MINUSZERO 1 + +/* Define 1 for ANSI C atan2() function + See atan.c and clog.c. */ +#define ANSIC 1 + +/* Get ANSI function prototypes, if you want them. */ +#if 1 +/* #ifdef __STDC__ */ +#define ANSIPROT 1 +int mtherr ( char *, int ); +#else +int mtherr(); +#endif + +/* Variable for error reporting. See mtherr.c. */ +extern int merror; diff --git a/regress/lib/libm/cephes/monot.c b/regress/lib/libm/cephes/monot.c new file mode 100644 index 00000000000..b3a72d341c4 --- /dev/null +++ b/regress/lib/libm/cephes/monot.c @@ -0,0 +1,341 @@ +/* $OpenBSD: monot.c,v 1.1 2011/05/30 20:23:35 martynas Exp $ */ + +/* + * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* monot.c + Floating point function test vectors. + + Arguments and function values are synthesized for NPTS points in + the vicinity of each given tabulated test point. The points are + chosen to be near and on either side of the likely function algorithm + domain boundaries. Since the function programs change their methods + at these points, major coding errors or monotonicity failures might be + detected. + + August, 1998 + S. L. Moshier */ + + +#include <stdio.h> + +/* Avoid including math.h. */ +double frexp (double, int *); +double ldexp (double, int); + +/* Number of test points to generate on each side of tabulated point. */ +#define NPTS 100 + +/* Functions of one variable. */ +double exp (double); +double log (double); +double sin (double); +double cos (double); +double tan (double); +double atan (double); +double asin (double); +double acos (double); +double sinh (double); +double cosh (double); +double tanh (double); +double asinh (double); +double acosh (double); +double atanh (double); +double gamma (double); +double fabs (double); +double floor (double); +#if 0 +double polylog (int, double); +#endif + +struct oneargument + { + char *name; /* Name of the function. */ + double (*func) (double); + double arg1; /* Function argument, assumed exact. */ + double answer1; /* Exact, close to function value. */ + double answer2; /* answer1 + answer2 has extended precision. */ + double derivative; /* dy/dx evaluated at x = arg1. */ + int thresh; /* Error report threshold. 2 = 1 ULP approx. */ + }; + +/* Add this to error threshold test[i].thresh. */ +#define OKERROR 0 + +/* Unit of relative error in test[i].thresh. */ +static double MACHEP = 1.1102230246251565404236316680908203125e-16; + + +/* extern double MACHEP; */ + +#if 0 +double w_polylog_3 (double x) {return polylog (3, x);} +#endif + +static struct oneargument test1[] = +{ + {"exp", exp, 1.0, 2.7182769775390625, + 4.85091998273536028747e-6, 2.71828182845904523536, 2}, + {"exp", exp, -1.0, 3.678741455078125e-1, + 5.29566362982159552377e-6, 3.678794411714423215955e-1, 2}, + {"exp", exp, 0.5, 1.648712158203125, + 9.1124970031468486507878e-6, 1.64872127070012814684865, 2}, + {"exp", exp, -0.5, 6.065216064453125e-1, + 9.0532673209236037995e-6, 6.0653065971263342360e-1, 2}, + {"exp", exp, 2.0, 7.3890533447265625, + 2.75420408772723042746e-6, 7.38905609893065022723, 2}, + {"exp", exp, -2.0, 1.353302001953125e-1, + 5.08304130019189399949e-6, 1.3533528323661269189e-1, 2}, + {"log", log, 1.41421356237309492343, 3.465728759765625e-1, + 7.1430341006605745676897e-7, 7.0710678118654758708668e-1, 2}, + {"log", log, 7.07106781186547461715e-1, -3.46588134765625e-1, + 1.45444856522566402246e-5, 1.41421356237309517417, 2}, + {"sin", sin, 7.85398163397448278999e-1, 7.0709228515625e-1, + 1.4496030297502751942956e-5, 7.071067811865475460497e-1, 2}, + {"sin", sin, -7.85398163397448501044e-1, -7.071075439453125e-1, + 7.62758764840238811175e-7, 7.07106781186547389040e-1, 2}, + {"sin", sin, 1.570796326794896558, 9.999847412109375e-1, + 1.52587890625e-5, 6.12323399573676588613e-17, 2}, + {"sin", sin, -1.57079632679489678004, -1.0, + 1.29302922820150306903e-32, -1.60812264967663649223e-16, 2}, + {"sin", sin, 4.712388980384689674, -1.0, + 1.68722975549458979398e-32, -1.83697019872102976584e-16, 2}, + {"sin", sin, -4.71238898038468989604, 9.999847412109375e-1, + 1.52587890625e-5, 3.83475850529283315008e-17, 2}, + {"cos", cos, 3.92699081698724139500E-1, 9.23873901367187500000E-1, + 5.63114409926198633370E-6, -3.82683432365089757586E-1, 2}, + {"cos", cos, 7.85398163397448278999E-1, 7.07092285156250000000E-1, + 1.44960302975460497458E-5, -7.07106781186547502752E-1, 2}, + {"cos", cos, 1.17809724509617241850E0, 3.82675170898437500000E-1, + 8.26146665231415693919E-6, -9.23879532511286738554E-1, 2}, + {"cos", cos, 1.96349540849362069750E0, -3.82690429687500000000E-1, + 6.99732241029898567203E-6, -9.23879532511286785419E-1, 2}, + {"cos", cos, 2.35619449019234483700E0, -7.07107543945312500000E-1, + 7.62758765040545859856E-7, -7.07106781186547589348E-1, 2}, + {"cos", cos, 2.74889357189106897650E0, -9.23889160156250000000E-1, + 9.62764496328487887036E-6, -3.82683432365089870728E-1, 2}, + {"cos", cos, 3.14159265358979311600E0, -1.00000000000000000000E0, + 7.49879891330928797323E-33, -1.22464679914735317723E-16, 2}, + {"tan", tan, 7.85398163397448278999E-1, 9.999847412109375e-1, + 1.52587890624387676600E-5, 1.99999999999999987754E0, 2}, + {"tan", tan, 1.17809724509617241850E0, 2.41419982910156250000E0, + 1.37332715322352112604E-5, 6.82842712474618858345E0, 2}, + {"tan", tan, 1.96349540849362069750E0, -2.41421508789062500000E0, + 1.52551752942854759743E-6, 6.82842712474619262118E0, 2}, + {"tan", tan, 2.35619449019234483700E0, -1.00001525878906250000E0, + 1.52587890623163029801E-5, 2.00000000000000036739E0, 2}, + {"tan", tan, 2.74889357189106897650E0, -4.14215087890625000000E-1, + 1.52551752982565655126E-6, 1.17157287525381000640E0, 2}, + {"atan", atan, 4.14213562373094923430E-1, 3.92684936523437500000E-1, + 1.41451752865477964149E-5, 8.53553390593273837869E-1, 2}, + {"atan", atan, 1.0, 7.85385131835937500000E-1, + 1.30315615108096156608E-5, 0.5, 2}, + {"atan", atan, 2.41421356237309492343E0, 1.17808532714843750000E0, + 1.19179477349460632350E-5, 1.46446609406726250782E-1, 2}, + {"atan", atan, -2.41421356237309514547E0, -1.17810058593750000000E0, + 3.34084132752141908545E-6, 1.46446609406726227789E-1, 2}, + {"atan", atan, -1.0, -7.85400390625000000000E-1, + 2.22722755169038433915E-6, 0.5, 2}, + {"atan", atan, -4.14213562373095145475E-1, -3.92700195312500000000E-1, + 1.11361377576267665972E-6, 8.53553390593273703853E-1, 2}, + {"asin", asin, 3.82683432365089615246E-1, 3.92684936523437500000E-1, + 1.41451752864854321970E-5, 1.08239220029239389286E0, 2}, + {"asin", asin, 0.5, 5.23590087890625000000E-1, + 8.68770767387307710723E-6, 1.15470053837925152902E0, 2}, + {"asin", asin, 7.07106781186547461715E-1, 7.85385131835937500000E-1, + 1.30315615107209645016E-5, 1.41421356237309492343E0, 2}, + {"asin", asin, 9.23879532511286738483E-1, 1.17808532714843750000E0, + 1.19179477349183147612E-5, 2.61312592975275276483E0, 2}, + {"asin", asin, -0.5, -5.23605346679687500000E-1, + 6.57108138862692289277E-6, 1.15470053837925152902E0, 2}, + {"acos", acos, 1.95090322016128192573E-1, 1.37443542480468750000E0, + 1.13611408471185777914E-5, -1.01959115820831832232E0, 2}, + {"acos", acos, 3.82683432365089615246E-1, 1.17808532714843750000E0, + 1.19179477351337991247E-5, -1.08239220029239389286E0, 2}, + {"acos", acos, 0.5, 1.04719543457031250000E0, + 2.11662628524615421446E-6, -1.15470053837925152902E0, 2}, + {"acos", acos, 7.07106781186547461715E-1, 7.85385131835937500000E-1, + 1.30315615108982668201E-5, -1.41421356237309492343E0, 2}, + {"acos", acos, 9.23879532511286738483E-1, 3.92684936523437500000E-1, + 1.41451752867009165605E-5, -2.61312592975275276483E0, 2}, + {"acos", acos, 9.80785280403230430579E-1, 1.96334838867187500000E-1, + 1.47019821746724723933E-5, -5.12583089548300990774E0, 2}, + {"acos", acos, -0.5, 2.09439086914062500000E0, + 4.23325257049230842892E-6, -1.15470053837925152902E0, 2}, + {"sinh", sinh, 1.0, 1.17518615722656250000E0, + 1.50364172389568823819E-5, 1.54308063481524377848E0, 2}, + {"sinh", sinh, 7.09089565712818057364E2, 4.49423283712885057274E307, + 4.25947714184369757620E208, 4.49423283712885057274E307, 2}, + {"sinh", sinh, 2.22044604925031308085E-16, 0.00000000000000000000E0, + 2.22044604925031308085E-16, 1.00000000000000000000E0, 2}, + {"cosh", cosh, 7.09089565712818057364E2, 4.49423283712885057274E307, + 4.25947714184369757620E208, 4.49423283712885057274E307, 2}, + {"cosh", cosh, 1.0, 1.54307556152343750000E0, + 5.07329180627847790562E-6, 1.17520119364380145688E0, 2}, + {"cosh", cosh, 0.5, 1.12762451171875000000E0, + 1.45348763078522622516E-6, 5.21095305493747361622E-1, 2}, + {"tanh", tanh, 0.5, 4.62112426757812500000E-1, + 4.73050219725850231848E-6, 7.86447732965927410150E-1, 2}, + {"tanh", tanh, 5.49306144334054780032E-1, 4.99984741210937500000E-1, + 1.52587890624507506378E-5, 7.50000000000000049249E-1, 2}, + {"tanh", tanh, 0.625, 5.54595947265625000000E-1, + 3.77508375729399903910E-6, 6.92419147969988069631E-1, 2}, + {"asinh", asinh, 0.5, 4.81201171875000000000E-1, + 1.06531846034474977589E-5, 8.94427190999915878564E-1, 2}, + {"asinh", asinh, 1.0, 8.81362915039062500000E-1, + 1.06719804805252326093E-5, 7.07106781186547524401E-1, 2}, + {"asinh", asinh, 2.0, 1.44363403320312500000E0, + 1.44197568534249327674E-6, 4.47213595499957939282E-1, 2}, + {"acosh", acosh, 2.0, 1.31695556640625000000E0, + 2.33051856670862504635E-6, 5.77350269189625764509E-1, 2}, + {"acosh", acosh, 1.5, 9.62417602539062500000E-1, + 6.04758014439499551783E-6, 8.94427190999915878564E-1, 2}, + {"acosh", acosh, 1.03125, 2.49343872070312500000E-1, + 9.62177257298785143908E-6, 3.96911150685467059809E0, 2}, + {"atanh", atanh, 0.5, 5.49301147460937500000E-1, + 4.99687311734569762262E-6, 1.33333333333333333333E0, 2}, +#if 0 + {"polylog_3", w_polylog_3, 0.875, 1.01392710208892822265625, + 1.21106784918910854520955967e-8, 1.4149982649102631253520580, 2}, + {"polylog_3", w_polylog_3, 8.0000000000000004440892e-1, + 9.10605847835540771484375e-1, 7.570301035551561731571421485488e-9, + 1.343493250010310486342647, 2}, +#endif +#if 0 + {"gamma", gamma, 1.0, 1.0, + 0.0, -5.772156649015328606e-1, 2}, + {"gamma", gamma, 2.0, 1.0, + 0.0, 4.2278433509846713939e-1, 2}, + {"gamma", gamma, 3.0, 2.0, + 0.0, 1.845568670196934279, 2}, + {"gamma", gamma, 4.0, 6.0, + 0.0, 7.536706010590802836, 2}, +#endif + {"null", NULL, 0.0, 0.0, 0.0, 2}, +}; + +/* These take care of extra-precise floating point register problems. */ +static volatile double volat1; +static volatile double volat2; + + +/* Return the next nearest floating point value to X + in the direction of UPDOWN (+1 or -1). + (Fails if X is denormalized.) */ + +static double +nextval (x, updown) + double x; + int updown; +{ + double m; + int i; + + volat1 = x; + m = 0.25 * MACHEP * volat1 * updown; + volat2 = volat1 + m; + if (volat2 != volat1) + printf ("successor failed\n"); + + for (i = 2; i < 10; i++) + { + volat2 = volat1 + i * m; + if (volat1 != volat2) + return volat2; + } + + printf ("nextval failed\n"); + return volat1; +} + + + + +int +monot () +{ + double (*fun1) (double); + int i, j, errs, tests; + double x, x0, y, dy, err; + + /* Set math coprocessor to double precision. */ + /* dprec (); */ + errs = 0; + tests = 0; + i = 0; + + for (;;) + { + fun1 = test1[i].func; + if (fun1 == NULL) + break; + volat1 = test1[i].arg1; + x0 = volat1; + x = volat1; + for (j = 0; j <= NPTS; j++) + { + volat1 = x - x0; + dy = volat1 * test1[i].derivative; + dy = test1[i].answer2 + dy; + volat1 = test1[i].answer1 + dy; + volat2 = (*(fun1)) (x); + if (volat2 != volat1) + { + /* Report difference between program result + and extended precision function value. */ + err = volat2 - test1[i].answer1; + err = err - dy; + err = err / volat1; + if (fabs (err) > ((OKERROR + test1[i].thresh) * MACHEP)) + { + printf ("%d %s(%.16e) = %.16e, rel err = %.3e\n", + j, test1[i].name, x, volat2, err); + errs += 1; + } + } + x = nextval (x, 1); + tests += 1; + } + + x = x0; + x = nextval (x, -1); + for (j = 1; j < NPTS; j++) + { + volat1 = x - x0; + dy = volat1 * test1[i].derivative; + dy = test1[i].answer2 + dy; + volat1 = test1[i].answer1 + dy; + volat2 = (*(fun1)) (x); + if (volat2 != volat1) + { + err = volat2 - test1[i].answer1; + err = err - dy; + err = err / volat1; + if (fabs (err) > ((OKERROR + test1[i].thresh) * MACHEP)) + { + printf ("%d %s(%.16e) = %.16e, rel err = %.3e\n", + j, test1[i].name, x, volat2, err); + errs += 1; + } + } + x = nextval (x, -1); + tests += 1; + } + i += 1; + } + printf ("%d errors in %d tests\n", errs, tests); + return (errs); +} diff --git a/regress/lib/libm/cephes/monotl.c b/regress/lib/libm/cephes/monotl.c new file mode 100644 index 00000000000..ea190904313 --- /dev/null +++ b/regress/lib/libm/cephes/monotl.c @@ -0,0 +1,475 @@ +/* $OpenBSD: monotl.c,v 1.1 2011/05/30 20:23:35 martynas Exp $ */ + +/* + * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* monotl.c + Floating point function test vectors. + + Arguments and function values are synthesized for NPTS points in + the vicinity of each given tabulated test point. The points are + chosen to be near and on either side of the likely function algorithm + domain boundaries. Since the function programs change their methods + at these points, major coding errors or monotonicity failures might be + detected. + + August, 1998 + S. L. Moshier */ + +#include <float.h> + +#if LDBL_MANT_DIG == 64 +/* Unit of error tolerance in test[i].thresh. */ +static long double MACHEPL = + 5.42101086242752217003726400434970855712890625E-20L; +/* How many times the above error to allow before printing a complaint. + If TOL < 0, consider absolute error instead of relative error. */ +#define TOL 8 +/* Number of test points to generate on each side of tabulated point. */ +#define NPTS 100 + + + +#include <stdio.h> + + +/* Avoid including math.h. */ +long double frexpl (long double, int *); +long double ldexpl (long double, int); + +/* Functions of one variable. */ +long double expl (long double); +long double logl (long double); +long double sinl (long double); +long double cosl (long double); +long double tanl (long double); +long double atanl (long double); +long double asinl (long double); +long double acosl (long double); +long double sinhl (long double); +long double coshl (long double); +long double tanhl (long double); +long double asinhl (long double); +long double acoshl (long double); +long double atanhl (long double); +#if 1 +long double lgaml (long double); +long double gammal (long double); +#define lgammal lgaml +#else +long double lgammal (long double); +long double tgammal (long double); +#define lgammal lgaml +#define gammal tgammal +#endif +long double fabsl (long double); +long double floorl (long double); +long double j0l (long double); +long double y0l (long double); +long double j1l (long double); +long double y1l (long double); + +/* Data structure of the test. */ +struct oneargument + { + char *name; /* Name of the function. */ + long double (*func) (long double); /* Function call. */ + long double arg1; /* Function argument, assumed exact. */ + long double answer1; /* Exact number, close to function value. */ + long double answer2; /* answer1 + answer2 has extended precision. */ + long double derivative; /* dy/dx evaluated at x = arg1. */ + /* Error report threshold. 2 => 1 ulp approximately + if thresh < 0 then consider absolute error instead of relative error. */ + int thresh; + + }; + + + +static struct oneargument test1[] = +{ +#if 0 + {"exp", expl, 1.0L, 2.7182769775390625L, + 4.85091998273536028747e-6L, 2.71828182845904523536L, TOL}, + {"exp", expl, -1.0L, 3.678741455078125e-1L, + 5.29566362982159552377e-6L, 3.678794411714423215955e-1L, TOL}, + {"exp", expl, 0.5L, 1.648712158203125L, + 9.1124970031468486507878e-6L, 1.64872127070012814684865L, TOL}, + {"exp", expl, -0.5L, 6.065216064453125e-1L, + 9.0532673209236037995e-6L, 6.0653065971263342360e-1L, TOL}, + {"exp", expl, 2.0L, 7.3890533447265625L, + 2.75420408772723042746e-6L, 7.38905609893065022723L, TOL}, + {"exp", expl, -2.0L, 1.353302001953125e-1L, + 5.08304130019189399949e-6L, 1.3533528323661269189e-1L, TOL}, + {"log", logl, 1.41421356237309492343L, 3.465728759765625e-1L, + 7.1430341006605745676897e-7L, 7.0710678118654758708668e-1L, TOL}, + {"log", logl, 7.07106781186547461715e-1L, -3.46588134765625e-1L, + 1.45444856522566402246e-5L, 1.41421356237309517417L, TOL}, +#endif + {"sin", sinl, 7.85398163397448278999e-1L, 7.0709228515625e-1L, + 1.4496030297502751942956e-5L, 7.071067811865475460497e-1L, TOL}, + {"sin", sinl, -7.85398163397448501044e-1L, -7.071075439453125e-1L, + 7.62758764840238811175e-7L, 7.07106781186547389040e-1L, TOL}, + {"sin", sinl, 1.570796326794896558L, 9.999847412109375e-1L, + 1.52587890625e-5L, 6.12323399573676588613e-17L, TOL}, + {"sin", sinl, -1.57079632679489678004L, -1.0L, + 1.29302922820150306903e-32L, -1.60812264967663649223e-16L, TOL}, + {"sin", sinl, 4.712388980384689674L, -1.0L, + 1.68722975549458979398e-32L, -1.83697019872102976584e-16L, TOL}, + {"sin", sinl, -4.71238898038468989604L, 9.999847412109375e-1L, + 1.52587890625e-5L, 3.83475850529283315008e-17L, TOL}, + {"cos", cosl, 3.92699081698724139500E-1L, 9.23873901367187500000E-1L, + 5.63114409926198633370E-6L, -3.82683432365089757586E-1L, TOL}, + {"cos", cosl, 7.85398163397448278999E-1L, 7.07092285156250000000E-1L, + 1.44960302975460497458E-5L, -7.07106781186547502752E-1L, TOL}, + {"cos", cosl, 1.17809724509617241850E0L, 3.82675170898437500000E-1L, + 8.26146665231415693919E-6L, -9.23879532511286738554E-1L, TOL}, + {"cos", cosl, 1.96349540849362069750E0L, -3.82690429687500000000E-1L, + 6.99732241029898567203E-6L, -9.23879532511286785419E-1L, TOL}, + {"cos", cosl, 2.35619449019234483700E0L, -7.07107543945312500000E-1L, + 7.62758765040545859856E-7L, -7.07106781186547589348E-1L, TOL}, + {"cos", cosl, 2.74889357189106897650E0L, -9.23889160156250000000E-1L, + 9.62764496328487887036E-6L, -3.82683432365089870728E-1L, TOL}, + {"cos", cosl, 3.14159265358979311600E0L, -1.00000000000000000000E0L, + 7.49879891330928797323E-33L, -1.22464679914735317723E-16L, TOL}, + {"tan", tanl, 7.85398163397448278999E-1L, 9.999847412109375e-1L, + 1.52587890624387676600E-5L, 1.99999999999999987754E0L, TOL}, + {"tan", tanl, 1.17809724509617241850E0L, 2.41419982910156250000E0L, + 1.37332715322352112604E-5L, 6.82842712474618858345E0L, TOL}, + {"tan", tanl, 1.96349540849362069750E0L, -2.41421508789062500000E0L, + 1.52551752942854759743E-6L, 6.82842712474619262118E0L, TOL}, + {"tan", tanl, 2.35619449019234483700E0L, -1.00001525878906250000E0L, + 1.52587890623163029801E-5L, 2.00000000000000036739E0L, TOL}, + {"tan", tanl, 2.74889357189106897650E0L, -4.14215087890625000000E-1L, + 1.52551752982565655126E-6L, 1.17157287525381000640E0L, TOL}, + {"atan", atanl, 4.14213562373094923430E-1L, 3.92684936523437500000E-1L, + 1.41451752865477964149E-5L, 8.53553390593273837869E-1L, TOL}, + {"atan", atanl, 1.0L, 7.85385131835937500000E-1L, + 1.30315615108096156608E-5L, 0.5L, TOL}, + {"atan", atanl, 2.41421356237309492343E0L, 1.17808532714843750000E0L, + 1.19179477349460632350E-5L, 1.46446609406726250782E-1L, TOL}, + {"atan", atanl, -2.41421356237309514547E0L, -1.17810058593750000000E0L, + 3.34084132752141908545E-6L, 1.46446609406726227789E-1L, TOL}, + {"atan", atanl, -1.0L, -7.85400390625000000000E-1L, + 2.22722755169038433915E-6L, 0.5L, TOL}, + {"atan", atanl, -4.14213562373095145475E-1L, -3.92700195312500000000E-1L, + 1.11361377576267665972E-6L, 8.53553390593273703853E-1L, TOL}, + {"asin", asinl, 3.82683432365089615246E-1L, 3.92684936523437500000E-1L, + 1.41451752864854321970E-5L, 1.08239220029239389286E0L, TOL}, + {"asin", asinl, 0.5L, 5.23590087890625000000E-1L, + 8.68770767387307710723E-6L, 1.15470053837925152902E0L, TOL}, + {"asin", asinl, 7.07106781186547461715E-1L, 7.85385131835937500000E-1L, + 1.30315615107209645016E-5L, 1.41421356237309492343E0L, TOL}, + {"asin", asinl, 9.23879532511286738483E-1L, 1.17808532714843750000E0L, + 1.19179477349183147612E-5L, 2.61312592975275276483E0L, TOL}, + {"asin", asinl, -0.5L, -5.23605346679687500000E-1L, + 6.57108138862692289277E-6L, 1.15470053837925152902E0L, TOL}, + {"asin", asinl, 1.16415321826934814453125e-10L, + 1.16415321826934814453125e-10L, 2.629536350736706018055e-31L, + 1.0000000000000000000067762L, TOL}, + {"asin", asinl, 1.0000000000000000000183779E-10L, + 9.9999999979890480394928431E-11L, 2.0109519607076028264987890E-20L, + 1.0L, TOL}, + {"asin", asinl, 1.0000000000000000000007074E-8L, + 9.9999999999948220585910263E-9L, 5.1781080827147808155022014E-21L, + 1.0L, TOL}, + {"asin", asinl, 0.97499847412109375L, 1.346710205078125L, + 3.969526822009922560999e-6L, 4.500216008585875735254L, TOL}, + {"acos", acosl, 1.95090322016128192573E-1L, 1.37443542480468750000E0L, + 1.13611408471185777914E-5L, -1.01959115820831832232E0L, TOL}, + {"acos", acosl, 3.82683432365089615246E-1L, 1.17808532714843750000E0L, + 1.19179477351337991247E-5L, -1.08239220029239389286E0L, TOL}, + {"acos", acosl, 0.5L, 1.04719543457031250000E0L, + 2.11662628524615421446E-6L, -1.15470053837925152902E0L, TOL}, + {"acos", acosl, 7.07106781186547461715E-1L, 7.85385131835937500000E-1L, + 1.30315615108982668201E-5L, -1.41421356237309492343E0L, TOL}, + {"acos", acosl, 9.23879532511286738483E-1L, 3.92684936523437500000E-1L, + 1.41451752867009165605E-5L, -2.61312592975275276483E0L, TOL}, + {"acos", acosl, 9.80785280403230430579E-1L, 1.96334838867187500000E-1L, + 1.47019821746724723933E-5L, -5.12583089548300990774E0L, TOL}, + {"acos", acosl, -0.5L, 2.09439086914062500000E0L, + 4.23325257049230842892E-6L, -1.15470053837925152902E0L, TOL}, +#if 0 + {"sinh", sinhl, 1.0L, 1.17518615722656250000E0L, + 1.50364172389568823819E-5L, 1.54308063481524377848E0L, TOL}, + {"sinh", sinhl, 7.09089565712818057364E2L, 4.49423283712885057274E307L, + 1.70878916528708958045E289L, 4.49423283712885057274E307L, TOL}, + {"sinh", sinhl, 2.22044604925031308085E-16L, 0.00000000000000000000E0L, + 2.22044604925031308085E-16L, 1.00000000000000000000E0L, TOL}, + {"sinh", sinhl, 3.7252902984619140625e-9L, 3.7252902984619140625e-9L, + 8.616464714094038285889380656847999229E-27L, + 1.00000000000000000693889L, TOL}, + {"sinh", sinhl, 2.3283064365386962890625e-10L, 2.3283064365386962890625e-10L, + 2.103629080589364814436978072135626630E-30, + 1.000000000000000000027105L, TOL}, + {"cosh", coshl, 7.09089565712818057364E2L, 4.49423283712885057274E307L, + 1.70878916528708958045E289L, 4.49423283712885057274E307L, TOL}, + {"cosh", coshl, 1.0L, 1.54307556152343750000E0L, + 5.07329180627847790562E-6L, 1.17520119364380145688E0L, TOL}, + {"cosh", coshl, 0.5L, 1.12762451171875000000E0L, + 1.45348763078522622516E-6L, 5.21095305493747361622E-1L, TOL}, + {"tanh", tanhl, 0.5L, 4.62112426757812500000E-1L, + 4.73050219725850231848E-6L, 7.86447732965927410150E-1L, TOL}, + {"tanh", tanhl, 5.49306144334054780032E-1L, 4.99984741210937500000E-1L, + 1.52587890624507506378E-5L, 7.50000000000000049249E-1L, TOL}, + {"tanh", tanhl, 0.625L, 5.54595947265625000000E-1L, + 3.77508375729399903910E-6L, 6.92419147969988069631E-1L, TOL}, + {"asinh", asinhl, 0.5L, 4.81201171875000000000E-1L, + 1.06531846034474977589E-5L, 8.94427190999915878564E-1L, TOL}, + {"asinh", asinhl, 1.0L, 8.81362915039062500000E-1L, + 1.06719804805252326093E-5L, 7.07106781186547524401E-1L, TOL}, + {"asinh", asinhl, 2.0L, 1.44363403320312500000E0L, + 1.44197568534249327674E-6L, 4.47213595499957939282E-1L, TOL}, + {"acosh", acoshl, 2.0L, 1.31695556640625000000E0L, + 2.33051856670862504635E-6L, 5.77350269189625764509E-1L, TOL}, + {"acosh", acoshl, 1.5L, 9.62417602539062500000E-1L, + 6.04758014439499551783E-6L, 8.94427190999915878564E-1L, TOL}, + {"acosh", acoshl, 1.03125L, 2.49343872070312500000E-1L, + 9.62177257298785143908E-6L, 3.96911150685467059809E0L, TOL}, + {"atanh", atanhl, 0.5L, 5.49301147460937500000E-1L, + 4.99687311734569762262E-6L, 1.33333333333333333333E0L, TOL}, +#endif + +#if 0 + {"j0", j0l, 8.0L, 1.71646118164062500000E-1L, + 4.68897349140609086941E-6L, -2.34636346853914624381E-1, -4}, + {"j0", j0l, 4.54541015625L, -3.09783935546875000000E-1L, + 7.07472668157686463367E-6L, 2.42993657373627558460E-1L, -4}, + {"j0", j0l, 2.85711669921875L, -2.07901000976562500000E-1L, + 1.15237285263902751582E-5L, -3.90402225324501311651E-1L, -4}, + {"j0", j0l, 2.0L, 2.23876953125000000000E-1L, + 1.38260162356680518275E-5L, -5.76724807756873387202E-1L, -4}, + {"j0", j0l, 1.16415321826934814453125e-10L, 9.99984741210937500000E-1L, + 1.52587890624999966119E-5L, 9.99999999999999999997E-1L, -4}, + {"j0", j0l, -2.0L, 2.23876953125000000000E-1L, + 1.38260162356680518275E-5L, 5.76724807756873387202E-1L, -4}, + {"y0", y0l, 8.0L, 2.23510742187500000000E-1L, + 1.07472000662205273234E-5L, 1.58060461731247494256E-1L, -4}, + {"y0", y0l, 4.54541015625L, -2.08114624023437500000E-1L, + 1.45018823856668874574E-5L, -2.88887645307401250876E-1L, -4}, + {"y0", y0l, 2.85711669921875L, 4.20303344726562500000E-1L, + 1.32781607563122276008E-5L, -2.82488638474982469213E-1, -4}, + {"y0", y0l, 2.0L, 5.10360717773437500000E-1L, + 1.49548763076195966066E-5L, 1.07032431540937546888E-1L, -4}, + {"y0", y0l, 1.16415321826934814453125e-10L, -1.46357574462890625000E1L, + 3.54110537011061127637E-6L, 5.46852220461145271913E9L, -4}, + {"j1", j1l, 8.0L, 2.34634399414062500000E-1L, + 1.94743985212438127665E-6L,1.42321263780814578043E-1, -4}, + {"j1", j1l, 4.54541015625L, -2.42996215820312500000E-1L, + 2.55844668494153980076E-6L, -2.56317734136211337012E-1, -4}, + {"j1", j1l, 2.85711669921875L, 3.90396118164062500000E-1L, + 6.10716043881165077013E-6L, -3.44531507106757980441E-1L, -4}, + {"j1", j1l, 2.0L, 5.76721191406250000000E-1L, + 3.61635062338720244824E-6L, -6.44716247372010255494E-2L, -4}, + {"j1", j1l, 1.16415321826934814453125e-10L, + 5.820677273504770710133016109466552734375e-11L, + 8.881784197001251337312921818461805735896e-16L, + 4.99999999999999999997E-1L, -4}, + {"j1", j1l, -2.0L, -5.76721191406250000000E-1L, + -3.61635062338720244824E-6L, -6.44716247372010255494E-2L, -4}, + {"y1", y1l, 8.0L, -1.58065795898437500000E-1L, + 5.33416719000574444473E-6L, 2.43279047103972157309E-1L, -4}, + {"y1", y1l, 4.54541015625L, 2.88879394531250000000E-1L, + 8.25077615125087585195E-6L, -2.71656024771791736625E-1L, -4}, + {"y1", y1l, 2.85711669921875L, 2.82485961914062500000E-1, + 2.67656091996921314433E-6L, 3.21444694221532719737E-1, -4}, + {"y1", y1l, 2.0L, -1.07040405273437500000E-1L, + 7.97373249995311162923E-6L, 5.63891888420213893041E-1, -4}, + {"y1", y1l, 1.16415321826934814453125e-10L, -5.46852220500000000000E9L, + 3.88547280871200700671E-1L, 4.69742480525120196168E19L, -4}, +#endif + +#if 0 + {"gamma", gammal, 1.0L, 1.0L, + 0.0L, -5.772156649015328606e-1L, TOL}, + {"gamma", gammal, 2.0L, 1.0L, + 0.0L, 4.2278433509846713939e-1L, TOL}, + {"gamma", gammal, 3.0L, 2.0L, + 0.0L, 1.845568670196934279L, TOL}, + {"gamma", gammal, 4.0L, 6.0L, + 0.0L, 7.536706010590802836L, TOL}, +#endif + +#if 0 + {"lgamma", lgammal, 8.0L, 8.525146484375L, + 1.48766904143001655310E-5, 2.01564147795560999654E0L, TOL}, + {"lgamma", lgammal, 8.99993896484375e-1L, 6.6375732421875e-2L, + 5.11505711292524166220E-6L, -7.54938684259372234258E-1, -TOL}, + {"lgamma", lgammal, 7.31597900390625e-1L, 2.2369384765625e-1L, + 5.21506341809849792422E-6L,-1.13355566660398608343E0L, -TOL}, + {"lgamma", lgammal, 2.31639862060546875e-1L, 1.3686676025390625L, + 1.12609441752996145670E-5L, -4.56670961813812679012E0, -TOL}, + {"lgamma", lgammal, 1.73162841796875L, -8.88214111328125e-2L, + 3.36207740803753034508E-6L, 2.33339034686200586920E-1L, -TOL}, + {"lgamma", lgammal, 1.23162841796875L,-9.3902587890625e-2L, + 1.28765089229009648104E-5L, -2.49677345775751390414E-1L, -TOL}, + {"lgamma", lgammal, 7.3786976294838206464e19L, 3.301798506038663053312e21L, + -1.656137564136932662487046269677E5L, 4.57477139169563904215E1L, TOL}, + {"lgamma", lgammal, 1.0L, 0.0L, + 0.0L, -5.77215664901532860607E-1L, -TOL}, + {"lgamma", lgammal, 2.0L, 0.0L, + 0.0L, 4.22784335098467139393E-1L, -TOL}, + {"lgamma", lgammal, 1.08420217248550443401E-19L,4.36682586669921875e1L, + 1.37082843669932230418E-5L, -9.22337203685477580858E18L, TOL}, + {"lgamma", lgammal, -0.5L, 1.2655029296875L, + 9.19379714539648894580E-6L, 3.64899739785765205590E-2L, TOL}, + {"lgamma", lgammal, -1.5L, 8.6004638671875e-1L, + 6.28657731014510932682E-7L, 7.03156640645243187226E-1L, TOL}, + {"lgamma", lgammal, -2.5L, -5.6243896484375E-2L, + 1.79986700949327405470E-7, 1.10315664064524318723E0L, -TOL}, + {"lgamma", lgammal, -3.5L, -1.30902099609375L, + 1.43111007079536392848E-5L, 1.38887092635952890151E0L, TOL}, +#endif + + {"null", NULL, 0.0L, 0.0L, 0.0L, 1}, +}; + +/* These take care of extra-precise floating point register problems. */ +static volatile long double volat1; +static volatile long double volat2; + + +/* Return the next nearest floating point value to X + in the direction of UPDOWN (+1 or -1). + (Might fail if X is denormalized.) */ + +static long double +nextval (x, updown) + long double x; + int updown; +{ + long double m; + int i; + + volat1 = x; + m = 0.25L * MACHEPL * volat1 * updown; + volat2 = volat1 + m; + if (volat2 != volat1) + printf ("successor failed\n"); + + for (i = 2; i < 10; i++) + { + volat2 = volat1 + i * m; + if (volat1 != volat2) + return volat2; + } + + printf ("nextval failed\n"); + return volat1; +} + + + + +int +monotl () +{ + long double (*fun1) (long double); + int i, j, errs, tests, err_thresh; + long double x, x0, dy, err; + + errs = 0; + tests = 0; + i = 0; + + for (;;) + { + /* Function call reference. */ + fun1 = test1[i].func; + if (fun1 == NULL) + break; + /* Function argument. */ + volat1 = test1[i].arg1; + /* x0 is the given argument, x scans from slightly below to above x0. */ + x0 = volat1; + x = volat1; + for (j = 0; j <= NPTS; j++) + { + /* delta x */ + volat1 = x - x0; + /* delta y */ + dy = volat1 * test1[i].derivative; + /* y + delta y */ + dy = test1[i].answer2 + dy; + volat1 = test1[i].answer1 + dy; + /* Run the function under test. */ + volat2 = (*(fun1)) (x); + if (volat2 != volat1) + { + /* Estimate difference between program result + and extended precision function value. */ + err = volat2 - test1[i].answer1; + err = err - dy; + /* Compare difference with reporting threshold. */ + err_thresh = test1[i].thresh; + if (err_thresh >= 0) + err = err / volat1; /* relative error */ + else + { + err_thresh = -err_thresh; /* absolute error */ + /* ...but relative error if function value > 1 */ + if (fabsl(volat1) > 1.0L) + err = err / volat1; + } + if (fabsl (err) > (err_thresh * MACHEPL)) + { + printf ("%d %s(%.19Le) = %.19Le, rel err = %.3Le\n", + j, test1[i].name, x, volat2, err); + errs += 1; + } + } + x = nextval (x, 1); + tests += 1; + } + + x = x0; + x = nextval (x, -1); + for (j = 1; j < NPTS; j++) + { + volat1 = x - x0; + dy = volat1 * test1[i].derivative; + dy = test1[i].answer2 + dy; + volat1 = test1[i].answer1 + dy; + volat2 = (*(fun1)) (x); + if (volat2 != volat1) + { + err = volat2 - test1[i].answer1; + err = err - dy; + err_thresh = test1[i].thresh; + if (err_thresh >= 0) + err = err / volat1; /* relative error */ + else + { + err_thresh = -err_thresh; + if (fabsl(volat1) > 1.0L) + err = err / volat1; + } + if (fabsl (err) > (err_thresh * MACHEPL)) + { + printf ("%d %s(%.19Le) = %.19Le, rel err = %.3Le\n", + j, test1[i].name, x, volat2, err); + errs += 1; + } + } + x = nextval (x, -1); + tests += 1; + } + i += 1; + } + printf ("%d errors in %d tests\n", errs, tests); + return (errs); +} +#endif /* LDBL_MANT_DIG == 64 */ diff --git a/regress/lib/libm/cephes/monotll.c b/regress/lib/libm/cephes/monotll.c new file mode 100644 index 00000000000..ceccdc5da4e --- /dev/null +++ b/regress/lib/libm/cephes/monotll.c @@ -0,0 +1,810 @@ +/* $OpenBSD: monotll.c,v 1.1 2011/05/30 20:23:35 martynas Exp $ */ + +/* + * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* monotll.c + Floating point function test vectors. + 128-bit long double version. + + Arguments and function values are synthesized for NPTS points in + the vicinity of each given tabulated test point. The points are + chosen to be near and on either side of the likely function algorithm + domain boundaries. Since the function programs change their methods + at these points, major coding errors or monotonicity failures might be + detected. + + August, 1998 + S. L. Moshier */ + +#include <float.h> + +#if LDBL_MANT_DIG == 113 +/* Unit of error tolerance in test[i].thresh. */ +static long double MACHEPL = 1.9259299443872358530559779425849273185381E-34L; +/* How many times the above error to allow before printing a complaint. + If TOL < 0, consider absolute error instead of relative error. */ +#define TOL 4 +/* Number of test points to generate on each side of tabulated point. */ +#define NPTS 100 + + + +#include <stdio.h> +#include <string.h> + +/* Avoid including math.h. */ +long double frexpl (long double, int *); +long double ldexpl (long double, int); + +/* Functions of one variable. */ +long double expl (long double); +long double expm1l (long double); +long double logl (long double); +long double log1pl (long double); +long double sinl (long double); +long double cosl (long double); +long double tanl (long double); +long double atanl (long double); +long double asinl (long double); +long double acosl (long double); +long double sinhl (long double); +long double coshl (long double); +long double tanhl (long double); +long double asinhl (long double); +long double acoshl (long double); +long double atanhl (long double); +long double gammal (long double); +long double lgammal (long double); +long double tgammal (long double); +long double fabsl (long double); +long double floorl (long double); +long double j0l (long double); +long double y0l (long double); +long double j1l (long double); +long double y1l (long double); +long double jnl (int, long double); +long double ynl (int, long double); + +/* Data structure of the test. */ +struct oneargument + { + char *name; /* Name of the function. */ + long double (*func) (long double); /* Function call. */ + long double arg1; /* Function argument, assumed exact. */ + long double answer1; /* Exact number, close to function value. */ + long double answer2; /* answer1 + answer2 has extended precision. */ + long double derivative; /* dy/dx evaluated at x = arg1. */ + /* Error report threshold. 2 => 1 ulp approximately + if thresh < 0 then consider absolute error instead of relative error. */ + int thresh; + + }; + + + +static struct oneargument test1[] = +{ +#if 0 + {"exp", expl, 1.0L, 2.7182769775390625L, + 4.85091998273536028747135266249775725E-6L, + 2.71828182845904523536028747135266250E0L, TOL}, + {"exp", expl, -1.0L, 3.678741455078125e-1L, + 5.29566362982159552377016146086744581E-6L, + 3.67879441171442321595523770161460867E-1L, TOL}, + {"exp", expl, 0.5L, 1.648712158203125L, + 9.11249700314684865078781416357165378E-6L, + 1.64872127070012814684865078781416357L, TOL}, + {"exp", expl, -0.5L, 6.065216064453125e-1L, + 9.05326732092360379953499118045344192E-6L, + 6.06530659712633423603799534991180453E-1L, TOL}, + {"exp", expl, 2.0L, 7.3890533447265625L, + 2.75420408772723042746057500781318032E-6L, + 7.38905609893065022723042746057500781E0L, TOL}, + {"exp", expl, -2.0L, 1.353302001953125e-1L, + 5.08304130019189399949497248440340763E-6L, + 1.35335283236612691893999494972484403E-1L, TOL}, + {"expm1", expm1l, 1.0L, 1.7182769775390625L, + 4.85091998273536028747135266249775725E-6L, + 2.71828182845904523536028747135266250E0L, TOL}, + {"expm1", expm1l, 0.5L, 0.648712158203125L, + 9.11249700314684865078781416357165378E-6L, + 1.64872127070012814684865078781416357L, TOL}, + {"expm1", expm1l, 2.0L, 6.3890533447265625L, + 2.75420408772723042746057500781318032E-6L, + 7.38905609893065022723042746057500781E0L, TOL}, + {"log", logl, 1.41421356237309504880168872420969798L, + 3.465728759765625E-1L, + 7.14303410154708616060729088217412434E-7L, + 7.07106781186547524400844362104849086E-1L, TOL}, + {"log", logl, 7.07106781186547524400844362104848992E-1L, + -3.46588134765625E-1L, + 1.45444856523452913839392709116493369E-5L, + 1.41421356237309504880168872420969817E0L, TOL}, + {"log1p", log1pl, 0.41421356237309504880168872420969798L, + 3.465728759765625E-1L, + 7.14303410154708616060729088217412434E-7L, + 7.07106781186547524400844362104849086E-1L, TOL}, +#endif + {"sin", sinl, 7.85398163397448309615660845819875699E-1L, + 7.0709228515625E-1L, + 1.44960302975244008443621048490239551E-5L, + 7.07106781186547524400844362104849055E-1, TOL}, + {"sin", sinl, -7.85398163397448309615660845819875699E-1L, + -7.071075439453125E-1L, + 7.62758764975599155637895150976044903E-7L, + 7.07106781186547524400844362104849055E-1L, TOL}, + {"sin", sinl, 1.57079632679489661923132169163975140E0L, + 9.999847412109375E-1L, + 1.52587890625E-5L, + 0.0L, TOL}, + {"sin", sinl, -1.57079632679489661923132169163975140E0L, + -1.0L, + 0.0L, + 0.0L, TOL}, + {"sin", sinl, 4.71238898038468985769396507491925433E0L, + -1.0L, + 0.0L, + 0.0L, TOL}, + {"sin", sinl, -4.71238898038468985769396507491925420E0L, + 1.0L, + 0.0L, + 0.0L, TOL}, + {"cos", cosl, 3.92699081698724154807830422909937850E-1L, + 9.238739013671875E-1L, + 5.63114409925612818318939678829097061E-6L, + -3.82683432365089771728459984030398857E-1L, TOL}, + {"cos", cosl, 7.85398163397448309615660845819875699E-1L, + 7.0709228515625E-1L, + 1.44960302975244008443621048490546146E-5L, + -7.07106781186547524400844362104849024E-1L, TOL}, + {"cos", cosl, 1.17809724509617246442349126872981355E0L, + 3.826751708984375E-1L, + 8.26146665227172845998403039889680525E-6L, + -9.23879532511286756128183189396788274E-1L, TOL}, + {"cos", cosl, 1.96349540849362077403915211454968925E0L, + -3.826904296875E-1L, + 6.99732241022827154001596960118331183E-6L, + -9.23879532511286756128183189396788308E-1L, TOL}, + {"cos", cosl, 2.35619449019234492884698253745962710E0L, + -7.071075439453125E-1L, + 7.62758764975599155637895151006704382E-7L, + -7.07106781186547524400844362104849085E-1L, TOL}, + {"cos", cosl, 2.74889357189106908365481296036956495E0L, + -9.2388916015625E-1L, + 9.62764496324387181681060321174221497E-6L, + -3.82683432365089771728459984030398937E-1L, TOL}, + {"cos", cosl, 3.14159265358979323846264338327950280E0L, + -1.0L, + 0.0L, + 0.0L, TOL}, + {"tan", tanl, 7.8539816339744830961566084581987569936977E-1L, + 9.999847412109375E-1L, + 1.5258789062499999999999999999956640949349E-5L, + 2.0L, TOL}, + {"tan", tanl, 1.1780972450961724644234912687298135490547E0L, + 2.4141998291015625L, + 1.3733271532548801688724209697856514083701E-5L, + 6.8284271247461900976033774484193950849601E0L, TOL}, + {"tan", tanl, 1.96349540849362077403915211454968925E0L, + -2.414215087890625L, + 1.52551752995119831127579030155133768E-6L, + 6.82842712474619009760337744841939794E0L, TOL}, + {"tan", tanl, 2.35619449019234492884698253745962710E0L, + -1.0000152587890625L, + 1.52587890624999999999999999998699228E-5L, + 2.0L, TOL}, + {"tan", tanl, 2.74889357189106908365481296036956495E0L, + -4.14215087890625E-1L, + 1.52551752995119831127579030183253332E-6L, + 1.17157287525380990239662255158060392E0L, TOL}, + {"atan", atanl, 4.14213562373095048801688724209698081E-1L, + 3.926849365234375E-1L, + 1.41451752866548078304229099378622950E-5L, + 8.53553390593273762200422181052424518E-1L, TOL}, + {"atan", atanl, 1.0L, + 7.853851318359375E-1L, + 1.30315615108096156608458198757210493E-5L, + 0.5L, TOL}, + {"atan", atanl, 2.41421356237309504880168872420969818E0L, + 1.1780853271484375L, + 1.19179477349644234912687298135959800E-5L, + 1.46446609406726237799577818947575470E-1L, TOL}, + {"atan", atanl, -2.41421356237309504880168872420969818E0L, + -1.1781005859375L, + 3.34084132753557650873127018640402003E-6L, + 1.46446609406726237799577818947575470E-1L, TOL}, + {"atan", atanl, -1.0L, + -7.85400390625E-1L, + 2.22722755169038433915418012427895071E-6L, + 0.5L, TOL}, + {"atan", atanl, -4.14213562373095048801688724209698081E-1L, + -3.927001953125E-1L, + 1.11361377584519216957709006213770502E-6L, + 8.53553390593273762200422181052424518E-1L, TOL}, + {"asin", asinl, 3.82683432365089771728459984030398880E-1L, + 3.926849365234375E-1L, + 1.41451752866548078304229099378750938E-5L, + 1.08239220029239396879944641073277885E0L, TOL}, + {"asin", asinl, 0.5L, + 5.23590087890625E-1L, + 8.68770767387307710723054658381403286E-6L, + 1.15470053837925152901829756100391491E0L, TOL}, + {"asin", asinl, 7.07106781186547524400844362104848992E-1L, + 7.853851318359375E-1L, + 1.30315615108096156608458198756544240E-5L, + 1.41421356237309504880168872420969798E0L, TOL}, + {"asin", asinl, 9.23879532511286756128183189396788310E-1L, + 1.1780853271484375L, + 1.19179477349644234912687298136415266E-5L, + 2.61312592975275305571328634685437469E0L, TOL}, + {"asin", asinl, -0.5L, + -5.236053466796875E-1L, + 6.57108138862692289276945341618596714E-6L, + 1.15470053837925152901829756100391491E0L, TOL}, + {"asin", asinl, 1.16415321826934814453125E-10L, + 1.16415321826934814453125E-10L, + 2.62953635073670601805513180586984061E-31L, + 1.00000000000000000000677626357803440E0L, TOL}, + {"asin", asinl, 0.625L, + 6.751251220703125E-1L, + 6.41086671914720905626529438801420419E-6L, + 1.28102523044069706786602935814149630E0L, TOL}, + {"asin", asinl, 9.74999999999999999999999999999999981E-1L, + 1.346710205078125L, + 1.08364149523595315129076204973231659E-5L, + 4.50035160370409562029946413944745541E0L, TOL}, + {"acos", acosl, 1.95090322016128267848284868477022248E-1L, + 1.3744354248046875L, + 1.13611408470418274064801847825042255E-5L, + -1.01959115820831833788387960797568783E0L, TOL}, + {"acos", acosl, 3.82683432365089771728459984030398880E-1L, + 1.1780853271484375L, + 1.19179477349644234912687298135670048E-5L, + -1.08239220029239396879944641073277885E0L, TOL}, + {"acos", acosl, 0.5L, + 1.0471954345703125L, + 2.11662628524615421446109316762806572E-6L, + -1.15470053837925152901829756100391491E0L, TOL}, + {"acos", acosl, 7.07106781186547524400844362104848992E-1L, + 7.853851318359375E-1L, + 1.30315615108096156608458198757876746E-5L, + -1.41421356237309504880168872420969798E0L, TOL}, + {"acos", acosl, 9.23879532511286756128183189396788310E-1L, + 3.926849365234375E-1L, + 1.41451752866548078304229099378005720E-5L, + -2.61312592975275305571328634685437469E0L, TOL}, + {"acos", acosl, 9.80785280403230449126182236134239047E-1L, + 1.963348388671875E-1L, + 1.47019821745774039152114549688769794E-5L, + -5.12583089548301235759217259235540119E0L, TOL}, + {"acos", acosl, -0.5L, + 2.094390869140625L, + 4.23325257049230842892218633525613145E-6L, + -1.15470053837925152901829756100391491E0L, TOL}, +#if 0 + {"sinh", sinhl, 1.0L, + 1.1751861572265625L, + 1.50364172389568823818505956008151557E-5L, + 1.54308063481524377847790562075706168E0L, TOL}, + {"sinh", sinhl, 11355.5L, + 2.13776152623792146713900550884909252E4931L, + 9.07106102767577900425552629248457689E4896L, + 2.13776152623792146713900550884909261E4931L, TOL}, + {"sinh", sinhl, 2.22044604925031308084726333618164062E-16L, + 2.22044604925031308084726333618164062E-16L, + 1.82460737542293889443193956157541613E-48L, + 1.00000000000000000000000000000002465E0L, TOL}, + {"sinh", sinhl, 40.0L, + 1.17692633418509992E17L, 7.039499553745174001302586809814832360E-1L, + 1.176926334185099927039499553745174044E17L, TOL}, + {"sinh", sinhl, 6.938893903907228377647697925567626953E-18L, /* 2^-57 */ + 6.938893903907228377647697925567626953E-18L, + 5.568259812692074262792784306565587261E-53L, 1.0L, TOL}, + {"sinh", sinhl, 11356.375L, + 5.1282233096855457613267954696602303826729E4931L, + 6.8582733554584347269625352341976754246942E4896L, + 5.1282233096855457613267954696602304512556E4931L, TOL}, + {"cosh", coshl, 40.0L, + 1.176926334185099927039499553745174054E17L, + -1.036733679609227143506056540471143597E-18L, + 1.176926334185099927039499553745174001E17L, TOL}, + {"cosh", coshl, 6.938893903907228377647697925567626953E-18L, + 1.0L, 2.407412430484044816319972428231159158E-35L, + 6.938893903907228377647697925567627009E-18L, TOL}, + {"cosh", coshl, 11356.375L, + 5.128223309685545761326795469660230383E4931L, + 6.858273355458434726962535234197675425E4896L, + 5.128223309685545761326795469660230451E4931L, TOL}, + {"cosh", coshl, 11355.5L, + 2.13776152623792146713900550884909252E4931L, + 9.07106102767577900425552629248457689E4896L, + 2.13776152623792146713900550884909261E4931L, TOL}, + {"cosh", coshl, 1.0L, + 1.5430755615234375L, + 5.07329180627847790562075706168260153E-6L, + 1.17520119364380145688238185059560082E0L, TOL}, + {"cosh", coshl, 0.5L, + 1.12762451171875L, + 1.45348763078522622516140267201254785E-6L, + 5.21095305493747361622425626411491559E-1L, TOL}, + {"tanh", tanhl, 0.5L, + 4.621124267578125E-1L, + 4.73050219725850231848364367254873029E-6L, + 7.86447732965927410149698934343636102E-1L, TOL}, + {"tanh", tanhl, 5.49306144334054845697622618461262805E-1L, + 4.999847412109375E-1L, + 1.52587890624999999999999999999648170E-5L, + 7.50000000000000000000000000000000035E-1L, TOL}, + {"tanh", tanhl, 0.625L, + 5.54595947265625E-1L, + 3.77508375729399903909532308359605810E-6L, + 6.92419147969988069630753311573341685E-1L, TOL}, + {"tanh", tanhl, 40.0L, + 1.0L, + -3.609702775690830344624256714700054777E-35L, + 7.219405551381660689248513429400109424E-35L, TOL}, + {"tanh", tanhl, 6.9388939039072283776476979255676269531250E-18L, /* 2^-57 */ + 6.9388939039072283776476979255676269531250E-18L, + -1.1136519625384148525585568613131174280582E-52L, + 9.9999999999999999999999999999999995185175E-1L, TOL}, + {"tanh", tanhl, 2.775557561562891351059079170227050781E-17L, /* 2^-55 */ + 2.775557561562891351059079170227050781E-17L, + -7.127372560245855056374763912403949481E-51L, + 9.999999999999999999999999999999992296E-1L, TOL}, + {"tanh", tanhl, 1.0L, + 7.615814208984375e-1L, + 1.273505732738811945828260479359041277E-5L, + 4.199743416140260693944967390417014449E-1L, TOL}, + {"asinh", asinhl, 0.5L, + 4.81201171875E-1L, + 1.06531846034474977589134243684231352E-5L, + 8.94427190999915878563669467492510494E-1L, TOL}, + {"asinh", asinhl, 1.0L, + 8.813629150390625E-1L, + 1.06719804805252326093249797923090282E-5L, + 7.07106781186547524400844362104849039E-1L, TOL}, + {"asinh", asinhl, 2.0L, + 1.443634033203125L, + 1.44197568534249327674027310526940555E-6L, + 4.47213595499957939281834733746255247E-1L, TOL}, + {"asinh", asinhl, 1.3877787807814456755295395851135253906250E-17L, /*2^-56*/ + 1.3877787807814456755295395851135253906250E-17L, + -4.4546078501536594102342274452524694119585E-52L, + 9.9999999999999999999999999999999990370350E-1L, TOL}, + {"asinh", asinhl, 1.8014398509481984E16L, + 38.1230926513671875L, + 2.2794298045179477666801997120145244851447E-6L, + 5.5511151231257827021181583404540930096529E-17L, TOL}, + {"acosh", acoshl, 2.0L, + 1.31695556640625L, + 2.33051856670862504634730796844402698E-6L, + 5.77350269189625764509148780501957456E-1L, TOL}, + {"acosh", acoshl, 1.5L, + 9.624176025390625E-1L, + 6.04758014439499551782684873684627037E-6L, + 8.94427190999915878563669467492510494E-1L, TOL}, + {"acosh", acoshl, 1.03125L, + 2.493438720703125E-1L, + 9.62177257298785143907541001884302707E-6L, + 3.96911150685467059808817882107262579E0L, TOL}, + {"acosh", acoshl, 2.68435456e8L, /* 2 ^ 28 */ + 20.10125732421875L, + 1.091201966396963028457033350626731006E-5L, + 3.725290298461914088349394142282115109E-9L, TOL}, + {"acosh", acoshl, 1.8014398509481984e16L, /* 2 ^ 54 */ + 38.1230926513671875L, + 2.279429804517947766680199710473780530E-6L, + 5.551115123125782702118158340454110115E-17L, TOL}, + {"acosh", acoshl, 1.073741824e9L, /* 2^30 */ + 21.487548828125L, + 1.376923330459171735533070637272346848E-5L, + 9.313225746154785160288967834731580446E-10L, TOL}, + {"atanh", atanhl, 0.5L, + 5.493011474609375E-1L, + 4.99687311734569762261846126285232375E-6L, + 1.33333333333333333333333333333333333E0L, TOL}, + {"atanh", atanhl, 6.938893903907228377647697925567626953125E-18, + 6.938893903907228377647697925567626953125E-18, /* 2^-57 */ + 1.1136519625384148525585568613131174816786E-52, 1.0, TOL}, + {"j0", j0l, 16.0L, -1.749114990234375e-1L, + 1.24250398083151715974822741805925455E-5L, + -9.03971756613041862386833024580760244E-2L, -2}, + {"j0", j0l, 8.0L, 1.716461181640625E-1L, + 4.68897349140609086940785197200106842E-6L, + -2.34636346853914624381276651590454612E-1L, -2}, + {"j0", j0l, 5.33333333333333333333333333333333333E0L, + -6.427001953125e-2L, + 2.71515994768793872858212682917411767E-6L, + 3.46125605116223455248039758589625114E-1L, -2}, + {"j0", j0l, 4.0L, -3.9715576171875e-1L, + 5.95185490262771340923154830195802438E-6L, + 6.60433280235491361431854208032750287E-2L, -2}, + {"j0", j0l, 3.2L, -3.201904296875e-1L, + 2.26003037709271056745460231434000663E-6L, + -2.61343248780504837362986742359905319E-1L, -2}, + {"j0", j0l, 2.66666666666666666666666666666666667E0L, + -1.275634765625e-1L, + 2.48895584953746034929481550434723427E-6L, + -4.51651148392987785778929732830311060E-1L, -2}, + {"j0", j0l, 2.28571428571428571428571428571428571E0L, + 6.3262939453125e-2L, + 7.41898014310740285267270594759284975E-6L, + -5.42395540605083481518545728422177515E-1L, -2}, + {"j0", j0l, 2.0L, + 2.23876953125e-1L, + 1.38260162356680518274546499486258252E-5L, + -5.76724807756873387202448242269137087E-1L, -2}, + {"y0", y0l, 16.0L, + 9.58099365234375e-2L, + 1.06055727490314207096590322941832776E-6L, + -1.77975168939416859630601904359871915E-1L, -2}, + {"y0", y0l, 8.0L, + 2.235107421875e-1L, + 1.07472000662205273234004986203592748E-5L, + 1.58060461731247494255555266187483550E-1L, -2}, + {"y0", y0l, 5.33333333333333333333333333333333333E0L, + -3.387451171875e-1L, + 1.48763307492243286439161163883136261E-5L, + -3.30338692743198039852173817311267913E-2L, -2}, + {"y0", y0l, 4.0L, + -1.69525146484375E-2L, + 1.17753233725080963648655528467817595E-5L, + -3.97925710557100005253979972450791852E-1L, -2}, + {"y0", y0l, 3.2L, + 3.070526123046875E-1L, + 6.37827715583546999256417236405953385E-7L, + -3.70711338441274693924314235987044508E-1L, -2}, + {"y0", y0l, 2.66666666666666666666666666666666667E0L, + 4.67864990234375E-1L, + 1.52461165366402773840048623192120982E-5L, + -2.14907152209457967672108494960545800E-1L, -2}, + {"y0", y0l, 2.28571428571428571428571428571428571E0L, + 5.18768310546875E-1L, + 3.23404086137065314580351322765266943E-6L, + -4.51747395962233519705260050662299281E-2L, -2}, + {"y0", y0l, 2.0L, + 5.103607177734375E-1L, + 1.49548763076195966065927271578732681E-5L, + 1.07032431540937546888370772277476637E-1L, -2}, + {"j1", j1l, 16.0L, + 9.039306640625e-2L, + 4.1092550541862386833024580760244495945291E-6L, + -1.8054889746246069646832022412944915898260E-1L, -2}, + {"j1", j1l, 8.0L, + 2.346343994140625e-1L, + 1.9474398521243812766515904546115487521615E-6L, + 1.4232126378081457804320982640316517462483E-1L, -2}, + {"j1", j1l, 5.3333333333333333333333333333333330765427E0L, + -3.4613037109375e-1L, + 4.7659775265447519602414103748858036315250E-6L, + 6.3124658798958579773603686238379727242328E-4L, -2}, + {"j1", j1l, 4.0L, + -6.60552978515625e-2L, + 1.1969828013363856814579196724971272576580E-5L, + -3.8063897785796008825079441325087928479376E-1L, -2}, + {"j1", j1l, 3.2000000000000000000000000000000001540744E0L, + 2.613372802734375e-1L, + 5.9685070673373629867423599052573498655055E-6L, + -4.0185793490103066896536590238515608924925E-1L, -2}, + {"j1", j1l, 2.6666666666666666666666666666666665382713E0L, + 4.516448974609375e-1L, + 6.2509320502857789297328303110978154167062E-6L, + -2.9693016825402088220674935499586226461144E-1L, -2}, + {"j1", j1l, 2.2857142857142857142857142857142856042326E0L, + 5.42388916015625e-1L, + 6.6245894584815185457284221775341820978577E-6L, + -1.7402769058145591576151108347875503008807E-1L, -2}, + {"j1", j1l, 2.0L, + 5.7672119140625e-1L, + 3.6163506233872024482422691370869203026897E-6L, + -6.4471624737201025549396666484619917634997E-2L, -2}, + {"y1", y1l, 16.0L, + 1.779632568359375e-1L, + 1.1912103479359630601904359871915459722520E-5L, + 8.4687549021998849415158346880737423611524E-2L, -2}, + {"y1", y1l, 8.0L, + -1.580657958984375e-1L, + 5.3341671900057444447338125164496726559505E-6L, + 2.4327904710397215730926780877205580306573E-1L, -2}, + {"y1", y1l, 5.3333333333333333333333333333333330765427E0L, + 3.302001953125e-2L, + 1.3849743069803985217381731126879849266308E-5L, + -3.4492409134568573891858434295819796816112E-1L, -2}, + {"y1", y1l, 4.0L, + 3.97918701171875e-1L, + 7.0093852250052539799724507918522711891816E-6L, + -1.1642216696433999321713012755985118130829E-1L, -2}, + {"y1", y1l, 3.2000000000000000000000000000000001540744E0L, + 3.70697021484375e-1L, + 1.4316956899693924314235987044537888863453E-5L, + 1.9120595686950474169565105767128493632383E-1L, -2}, + {"y1", y1l, 2.6666666666666666666666666666666665382713E0L, + 2.1490478515625e-1L, + 2.3670532079676721084949605457501811641711E-6L, + 3.8729005427236490240034331925211457949310E-1L, -2}, + {"y1", y1l, 2.2857142857142857142857142857142856042326E0L, + 4.5166015625e-2L, + 8.7239712233519705260050662298731987015100E-6L, + 4.9900759601438865416604067629675208716502E-1L, -2}, + {"y1", y1l, 2.0L, + -1.070404052734375e-1L, + 7.9737324999531116292277225233633125191018E-6L, + 5.6389188842021389304079197886589619161188E-1L, -2}, + {"jnl", NULL, 6.9388939039072283776476979255676269531250E-18L, + 6.9602982143332406209530299018670212642178E-54L, + 2.6551531852207537950481339962774251294400E-59L, + 3.0092655e-36L, -2}, +#endif +#if 0 + {"lgamma", lgammal, 8.0L, 8.525146484375L, + 1.4876690414300165531036347125050759667737E-5L, + 2.0156414779556099965363450527747404656959E0L, 4}, + {"lgamma", lgammal, 0.125L, 2.0194091796875E0L, + 9.1778662963453202905211670995899482809521E-6L, + -8.3884926632958548678027429230863429642684E0L, 4}, + {"lgamma", lgammal, 0.375L, 8.63067626953125E-1L, + 6.3553175224624050890941340154953324706293E-6L, + -2.7539990491451395757640192188045680759926E0L, 4}, + {"lgamma", lgammal, 0.625L, 3.608245849609375E-1L, + 4.9105280026811849576858227794878573691202E-6L, + -1.4527087645765665672107816120233772668729E0L, 4}, + {"lgamma", lgammal, 0.875L, 8.5845947265625E-2L, + 1.2759959709323502365583769487702269719126E-5L, + -8.0401707154769538232421854974614639758707E-1L, 4}, + {"lgamma", lgammal, 1.0L, 0.0L, + 0.0L, -5.7721566490153286060651209008240239144696E-1L, -4}, + {"lgamma", lgammal, 1.125L, -6.0028076171875E-2L, + 4.8920458354170685941567925698857217805491E-6L, + -3.8849266329585486780274292308634296426837E-1L, 4}, + {"lgamma", lgammal, 1.375L, -1.17767333984375E-1L, + 1.2063243296225548637966682011495753460784E-5L, + -8.7332382478472909097352552137901409325952E-2L, 4}, + {"lgamma", lgammal, 1.625L, -1.091766357421875E-1L, + 2.5019853921275340206546744374231564700714E-6L, + 1.4729123542343343278921838797662273312715E-1L, 4}, + {"lgamma", lgammal, 1.875L, -4.76837158203125E-2L, + 1.1030421124200356021962838137727680303452E-5L, + 3.3884007130944747481863859311099645955579E-1L, 4}, + {"lgamma", lgammal, 2.375L, 2.0068359375E-1L, + 1.4866627455841358885180272611091348667235E-5L, + 6.3994034479425436362992017513482586340132E-1L, 4}, + {"lgamma", lgammal, 2.75L, 4.752044677734375E-1L, + 1.0199141499630313102466395428861742242065E-5L, + 8.1890102497543259227787514194472409043081E-1L, 4}, + {"lgamma", lgammal, 3.5L, 1.2009735107421875E0L, + 9.1604886724816021881450712995770238915468E-8L, + 1.1031566406452431872256903336679111259463E0L, 4}, + {"lgamma", lgammal, 4.5L, 2.4537353515625E0L, + 1.2192799422205041425034357161573318235107E-6L, + 1.3888709263595289015114046193821968402320E0L, 4}, + {"lgamma", lgammal, 5.5L, 3.9578094482421875E0L, + 4.5193765287938774008558225909985513044920E-6L, + 1.6110931485817511237336268416044190624542E0L, 4}, + {"lgamma", lgammal, 6.5L, 5.6625518798828125E0L, + 1.0179974329028522112312329543730297511212E-5L, + 1.7929113303999329419154450234226008806361E0L, 4}, + {"lgamma", lgammal, 7.5L, 7.53436279296875E0L, + 1.4437899829551583676324366857670272790220E-6L, + 1.9467574842460867880692911772687547267899E0L, 4}, + {"lgamma", lgammal, 8.5L, 9.54925537109375E0L, + 1.1886207247711737140081127222543124870800E-5L, + 2.0800908175794201214026245106020880601232E0L, 4}, + {"lgamma", lgammal, 9.5L, 1.16893310546875E1L, + 2.3661097684825694425775421725106375736779E-6L, + 2.1977378764029495331673303929550292365938E0L, 4}, + {"lgamma", lgammal, 10.5L, 1.394061279296875E1L, + 1.2426435013633161237887971849479799452805E-5L, + 2.3030010342976863752725935508497660786991E0L, 4}, + {"lgamma", lgammal, 11.5L, 1.62919921875E1L, + 8.2890672413202446037468793783460085279579E-6L, + 2.3982391295357816133678316460878613167943E0L, 4}, + {"lgamma", lgammal, 12.5L, 1.8734344482421875E1L, + 3.0295145707016341244572313978963754081384E-6L, + 2.4851956512749120481504403417400352298378E0L, 4}, + {"lgamma", lgammal, 13.5L, 2.126007080078125E1L, + 5.3554634511414184110022255966073511107125E-6L, + 2.5651956512749120481504403417400352298378E0, 4}, + {"lgamma", lgammal, -0.5L, 1.2655029296875E0L, + 9.1937971453964889457971347059238991475408E-6L, + 3.6489973978576520559023667001244459279636E-2L, 4}, + {"lgamma", lgammal, -1.5L, 8.6004638671875E-1L, + 6.2865773101451093268167035678732715711736E-7L, + 7.0315664064524318722569033366791112594630E-1L, 4}, + {"lgamma", lgammal, -2.5L, -5.6243896484375E-2L, + 1.7998670094932740546990234571587705589745E-7L, + 1.1031566406452431872256903336679111259463E0L, -4}, + {"lgamma", lgammal, -3.5L,-1.30902099609375E0L, + 1.4311100707953639284847917342554315471302E-5L, + 1.3888709263595289015114046193821968402320E0L, -4}, + {"lgamma", lgammal, 1.0e18L, 4.0446531673037733888E19L, + 8.5508840451951888057681732252156677289759E8L, + 4.1446531673892822311823846184318555736736E1, 4}, +#endif /* 0 */ +#if 0 +#define gammal tgammal /* Yuck. */ + {"gamma", gammal, 1.0L, 1.0L, + 0.0L, -5.772156649015328606e-1L, 4}, + {"gamma", gammal, 2.0L, 1.0L, + 0.0L, 4.2278433509846713939e-1L, 4}, + {"gamma", gammal, 3.0L, 2.0L, + 0.0L, 1.845568670196934279L, 4}, + {"gamma", gammal, 4.0L, 6.0L, + 0.0L, 7.536706010590802836L, 4}, +#endif + {NULL, NULL, 0.0L, 0.0L, 0.0L, 1}, +}; + +/* These take care of extra-precise floating point register problems. */ +static volatile long double volat1; +static volatile long double volat2; + + +/* Return the next nearest floating point value to X + in the direction of UPDOWN (+1 or -1). + (Might fail if X is denormalized.) */ + +static long double +nextval (x, updown) + long double x; + int updown; +{ + long double m; + int i; + + volat1 = x; + m = 0.25L * MACHEPL * volat1 * updown; + volat2 = volat1 + m; + if (volat2 != volat1) + printf ("successor failed\n"); + + for (i = 2; i < 10; i++) + { + volat2 = volat1 + i * m; + if (volat1 != volat2) + return volat2; + } + + printf ("nextval failed\n"); + return volat1; +} + + + + +int +monotll () +{ + long double (*fun1) (long double); + int i, j, errs, tests, err_thresh; + long double x, x0, dy, err; + + errs = 0; + tests = 0; + i = 0; + + for (;;) + { + /* Function call reference. */ + fun1 = test1[i].func; + if (test1[i].name == NULL) + break; + /* + if (fun1 == NULL) + break; + */ + /* Function argument. */ + volat1 = test1[i].arg1; + /* x0 is the given argument, x scans from slightly below to above x0. */ + x0 = volat1; + x = volat1; + for (j = 0; j <= NPTS; j++) + { + /* delta x */ + volat1 = x - x0; + /* delta y */ + dy = volat1 * test1[i].derivative; + /* y + delta y */ + dy = test1[i].answer2 + dy; + volat1 = test1[i].answer1 + dy; + /* Run the function under test. */ + if (fun1 == NULL) + { +#if 0 + if (! strcmp (test1[i].name, "jnl")) + volat2 = jnl (3, x); + else +#endif + break; + } + else + volat2 = (*(fun1)) (x); + if (volat2 != volat1) + { + /* Estimate difference between program result + and extended precision function value. */ + err = volat2 - test1[i].answer1; + err = err - dy; + /* Compare difference with reporting threshold. */ + err_thresh = test1[i].thresh; + if (err_thresh >= 0) + err = err / volat1; /* relative error */ + else + { + err_thresh = -err_thresh; /* absolute error */ + /* ...but relative error if function value > 1 */ + if (fabsl(volat1) > 1.0L) + err = err / volat1; + } + if (fabsl (err) > (err_thresh * MACHEPL)) + { + printf ("%d %s(%.36Le) = %.36Le, rel err = %.3Le\n", + j, test1[i].name, x, volat2, err); + errs += 1; + } + } + x = nextval (x, 1); + tests += 1; + } + + x = x0; + x = nextval (x, -1); + for (j = 1; j < NPTS; j++) + { + volat1 = x - x0; + dy = volat1 * test1[i].derivative; + dy = test1[i].answer2 + dy; + volat1 = test1[i].answer1 + dy; + if (fun1 == NULL) + { +#if 0 + if (! strcmp (test1[i].name, "jnl")) + volat2 = jnl (3, x); + else +#endif + break; + } + else + volat2 = (*(fun1)) (x); + if (volat2 != volat1) + { + err = volat2 - test1[i].answer1; + err = err - dy; + err_thresh = test1[i].thresh; + if (err_thresh >= 0) + err = err / volat1; /* relative error */ + else + { + err_thresh = -err_thresh; + if (fabsl(volat1) > 1.0L) + err = err / volat1; + } + if (fabsl (err) > (err_thresh * MACHEPL)) + { + printf ("%d %s(%.36Le) = %.36Le, rel err = %.3Le\n", + j, test1[i].name, x, volat2, err); + errs += 1; + } + } + x = nextval (x, -1); + tests += 1; + } + i += 1; + } + printf ("%d errors in %d tests\n", errs, tests); + return (errs); +} +#endif /* LDBL_MANT_DIG == 113 */ diff --git a/regress/lib/libm/cephes/polevll.c b/regress/lib/libm/cephes/polevll.c new file mode 100644 index 00000000000..0dff338b2b0 --- /dev/null +++ b/regress/lib/libm/cephes/polevll.c @@ -0,0 +1,194 @@ +/* $OpenBSD: polevll.c,v 1.1 2011/05/30 20:23:35 martynas Exp $ */ + +/* + * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* polevll.c + * p1evll.c + * + * Evaluate polynomial + * + * + * + * SYNOPSIS: + * + * int N; + * long double x, y, coef[N+1], polevl[]; + * + * y = polevll( x, coef, N ); + * + * + * + * DESCRIPTION: + * + * Evaluates polynomial of degree N: + * + * 2 N + * y = C + C x + C x +...+ C x + * 0 1 2 N + * + * Coefficients are stored in reverse order: + * + * coef[0] = C , ..., coef[N] = C . + * N 0 + * + * The function p1evll() assumes that coef[N] = 1.0 and is + * omitted from the array. Its calling arguments are + * otherwise the same as polevll(). + * + * This module also contains the following globally declared constants: + * MAXNUML = 1.189731495357231765021263853E4932L; + * MACHEPL = 5.42101086242752217003726400434970855712890625E-20L; + * MAXLOGL = 1.1356523406294143949492E4L; + * MINLOGL = -1.1355137111933024058873E4L; + * LOGE2L = 6.9314718055994530941723E-1L; + * LOG2EL = 1.4426950408889634073599E0L; + * PIL = 3.1415926535897932384626L; + * PIO2L = 1.5707963267948966192313L; + * PIO4L = 7.8539816339744830961566E-1L; + * + * SPEED: + * + * In the interest of speed, there are no checks for out + * of bounds arithmetic. This routine is used by most of + * the functions in the library. Depending on available + * equipment features, the user may wish to rewrite the + * program in microcode or assembly language. + * + */ + +#include "mconf.h" + +#if UNK +/* almost 2^16384 */ +long double MAXNUML = 1.189731495357231765021263853E4932L; +/* 2^-64 */ +long double MACHEPL = 5.42101086242752217003726400434970855712890625E-20L; +/* log( MAXNUML ) */ +long double MAXLOGL = 1.1356523406294143949492E4L; +#ifdef DENORMAL +/* log(smallest denormal number = 2^-16446) */ +long double MINLOGL = -1.13994985314888605586758E4L; +#else +/* log( underflow threshold = 2^(-16382) ) */ +long double MINLOGL = -1.1355137111933024058873E4L; +#endif +long double LOGE2L = 6.9314718055994530941723E-1L; +long double LOG2EL = 1.4426950408889634073599E0L; +long double PIL = 3.1415926535897932384626L; +long double PIO2L = 1.5707963267948966192313L; +long double PIO4L = 7.8539816339744830961566E-1L; +#ifdef INFINITIES +long double NANL = 0.0L / 0.0L; +long double INFINITYL = 1.0L / 0.0L; +#else +long double INFINITYL = 1.189731495357231765021263853E4932L; +long double NANL = 0.0L; +#endif +#endif +#if IBMPC +short MAXNUML[] = {0xffff,0xffff,0xffff,0xffff,0x7ffe, XPD}; +short MAXLOGL[] = {0x79ab,0xd1cf,0x17f7,0xb172,0x400c, XPD}; +#ifdef INFINITIES +short INFINITYL[] = {0,0,0,0x8000,0x7fff, XPD}; +short NANL[] = {0,0,0,0xc000,0x7fff, XPD}; +#else +short INFINITYL[] = {0xffff,0xffff,0xffff,0xffff,0x7ffe, XPD}; +long double NANL = 0.0L; +#endif +#ifdef DENORMAL +short MINLOGL[] = {0xbaaa,0x09e2,0xfe7f,0xb21d,0xc00c, XPD}; +#else +short MINLOGL[] = {0xeb2f,0x1210,0x8c67,0xb16c,0xc00c, XPD}; +#endif +short MACHEPL[] = {0x0000,0x0000,0x0000,0x8000,0x3fbf, XPD}; +short LOGE2L[] = {0x79ac,0xd1cf,0x17f7,0xb172,0x3ffe, XPD}; +short LOG2EL[] = {0xf0bc,0x5c17,0x3b29,0xb8aa,0x3fff, XPD}; +short PIL[] = {0xc235,0x2168,0xdaa2,0xc90f,0x4000, XPD}; +short PIO2L[] = {0xc235,0x2168,0xdaa2,0xc90f,0x3fff, XPD}; +short PIO4L[] = {0xc235,0x2168,0xdaa2,0xc90f,0x3ffe, XPD}; +#endif +#if MIEEE +long MAXNUML[] = {0x7ffe0000,0xffffffff,0xffffffff}; +long MAXLOGL[] = {0x400c0000,0xb17217f7,0xd1cf79ab}; +#ifdef INFINITIES +long INFINITY[] = {0x7fff0000,0x80000000,0x00000000}; +long NANL[] = {0x7fff0000,0xffffffff,0xffffffff}; +#else +long INFINITYL[] = {0x7ffe0000,0xffffffff,0xffffffff}; +long double NANL = 0.0L; +#endif +#ifdef DENORMAL +long MINLOGL[] = {0xc00c0000,0xb21dfe7f,0x09e2baaa}; +#else +long MINLOGL[] = {0xc00c0000,0xb16c8c67,0x1210eb2f}; +#endif +long MACHEPL[] = {0x3fbf0000,0x80000000,0x00000000}; +long LOGE2L[] = {0x3ffe0000,0xb17217f7,0xd1cf79ac}; +long LOG2EL[] = {0x3fff0000,0xb8aa3b29,0x5c17f0bc}; +long PIL[] = {0x40000000,0xc90fdaa2,0x2168c235}; +long PIO2L[] = {0x3fff0000,0xc90fdaa2,0x2168c235}; +long PIO4L[] = {0x3ffe0000,0xc90fdaa2,0x2168c235}; +#endif + +#ifdef MINUSZERO +long double NEGZEROL = -0.0L; +#else +long double NEGZEROL = 0.0L; +#endif + +/* Polynomial evaluator: + * P[0] x^n + P[1] x^(n-1) + ... + P[n] + */ +long double polevll( x, p, n ) +long double x; +void *p; +int n; +{ +register long double y; +register long double *P = (long double *)p; + +y = *P++; +do + { + y = y * x + *P++; + } +while( --n ); +return(y); +} + + + +/* Polynomial evaluator: + * x^n + P[0] x^(n-1) + P[1] x^(n-2) + ... + P[n] + */ +long double p1evll( x, p, n ) +long double x; +void *p; +int n; +{ +register long double y; +register long double *P = (long double *)p; + +n -= 1; +y = x + *P++; +do + { + y = y * x + *P++; + } +while( --n ); +return( y ); +} diff --git a/regress/lib/libm/cephes/testvect.c b/regress/lib/libm/cephes/testvect.c new file mode 100644 index 00000000000..638320074e7 --- /dev/null +++ b/regress/lib/libm/cephes/testvect.c @@ -0,0 +1,556 @@ +/* $OpenBSD: testvect.c,v 1.1 2011/05/30 20:23:35 martynas Exp $ */ + +/* + * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* Test vectors for math functions. + See C9X section F.9. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int __isfinite (double); + +/* C9X spells lgam lgamma. */ +#define GLIBC2 1 + +extern double PI; +static double MPI, PIO2, MPIO2, PIO4, MPIO4, THPIO4, MTHPIO4; + +#if 0 +#define PI 3.141592653589793238463E0 +#define PIO2 1.570796326794896619231E0 +#define PIO4 7.853981633974483096157E-1 +#define THPIO4 2.35619449019234492884698 +#define SQRT2 1.414213562373095048802E0 +#define SQRTH 7.071067811865475244008E-1 +#define INF (1.0/0.0) +#define MINF (-1.0/0.0) +#endif + +extern double MACHEP, SQRTH, SQRT2; +extern double NAN, INFINITY, NEGZERO; +static double INF, MINF; +static double ZERO, MZERO, HALF, MHALF, ONE, MONE, TWO, MTWO, THREE, MTHREE; +/* #define NAN (1.0/0.0 - 1.0/0.0) */ + +/* Functions of one variable. */ +double log (double); +double exp ( double); +double atan (double); +double sin (double); +double cos (double); +double tan (double); +double acos (double); +double asin (double); +double acosh (double); +double asinh (double); +double atanh (double); +double sinh (double); +double cosh (double); +double tanh (double); +double exp2 (double); +double expm1 (double); +double log10 (double); +double log1p (double); +double log2 (double); +double fabs (double); +double erf (double); +double erfc (double); +double tgamma (double); +double floor (double); +double ceil (double); +double cbrt (double); +#if GLIBC2 +double lgamma (double); +#else +double lgam (double); +#endif + +struct oneargument + { + char *name; /* Name of the function. */ + double (*func) (double); + double *arg1; + double *answer; + int thresh; /* Error report threshold. */ + }; + +static struct oneargument test1[] = +{ + {"atan", atan, &ONE, &PIO4, 0}, + {"sin", sin, &PIO2, &ONE, 0}, +#if 0 + {"cos", cos, &PIO4, &SQRTH, 0}, + {"sin", sin, 32767., 1.8750655394138942394239E-1, 0}, + {"cos", cos, 32767., 9.8226335176928229845654E-1, 0}, + {"tan", tan, 32767., 1.9089234430221485740826E-1, 0}, + {"sin", sin, 8388607., 9.9234509376961249835628E-1, 0}, + {"cos", cos, 8388607., -1.2349580912475928183718E-1, 0}, + {"tan", tan, 8388607., -8.0354556223613614748329E0, 0}, + /* + {"sin", sin, 2147483647., -7.2491655514455639054829E-1, 0}, + {"cos", cos, 2147483647., -6.8883669187794383467976E-1, 0}, + {"tan", tan, 2147483647., 1.0523779637351339136698E0, 0}, + */ + {"cos", cos, &PIO2, 6.1232339957367574e-17, 1}, + {"sin", sin, &PIO4, &SQRTH, 1}, +#endif + {"acos", acos, &NAN, &NAN, 0}, + {"acos", acos, &ONE, &ZERO, 0}, + {"acos", acos, &TWO, &NAN, 0}, + {"acos", acos, &MTWO, &NAN, 0}, + {"asin", asin, &NAN, &NAN, 0}, + {"asin", asin, &ZERO, &ZERO, 0}, + {"asin", asin, &MZERO, &MZERO, 0}, + {"asin", asin, &TWO, &NAN, 0}, + {"asin", asin, &MTWO, &NAN, 0}, + {"atan", atan, &NAN, &NAN, 0}, + {"atan", atan, &ZERO, &ZERO, 0}, + {"atan", atan, &MZERO, &MZERO, 0}, + {"atan", atan, &INF, &PIO2, 0}, + {"atan", atan, &MINF, &MPIO2, 0}, + {"cos", cos, &NAN, &NAN, 0}, + {"cos", cos, &ZERO, &ONE, 0}, + {"cos", cos, &MZERO, &ONE, 0}, + {"cos", cos, &INF, &NAN, 0}, + {"cos", cos, &MINF, &NAN, 0}, + {"sin", sin, &NAN, &NAN, 0}, + {"sin", sin, &MZERO, &MZERO, 0}, + {"sin", sin, &ZERO, &ZERO, 0}, + {"sin", sin, &INF, &NAN, 0}, + {"sin", sin, &MINF, &NAN, 0}, + {"tan", tan, &NAN, &NAN, 0}, + {"tan", tan, &ZERO, &ZERO, 0}, + {"tan", tan, &MZERO, &MZERO, 0}, + {"tan", tan, &INF, &NAN, 0}, + {"tan", tan, &MINF, &NAN, 0}, + {"acosh", acosh, &NAN, &NAN, 0}, + {"acosh", acosh, &ONE, &ZERO, 0}, + {"acosh", acosh, &INF, &INF, 0}, + {"acosh", acosh, &HALF, &NAN, 0}, + {"acosh", acosh, &MONE, &NAN, 0}, + {"asinh", asinh, &NAN, &NAN, 0}, + {"asinh", asinh, &ZERO, &ZERO, 0}, + {"asinh", asinh, &MZERO, &MZERO, 0}, + {"asinh", asinh, &INF, &INF, 0}, + {"asinh", asinh, &MINF, &MINF, 0}, + {"atanh", atanh, &NAN, &NAN, 0}, + {"atanh", atanh, &ZERO, &ZERO, 0}, + {"atanh", atanh, &MZERO, &MZERO, 0}, + {"atanh", atanh, &ONE, &INF, 0}, + {"atanh", atanh, &MONE, &MINF, 0}, + {"atanh", atanh, &TWO, &NAN, 0}, + {"atanh", atanh, &MTWO, &NAN, 0}, + {"cosh", cosh, &NAN, &NAN, 0}, + {"cosh", cosh, &ZERO, &ONE, 0}, + {"cosh", cosh, &MZERO, &ONE, 0}, + {"cosh", cosh, &INF, &INF, 0}, + {"cosh", cosh, &MINF, &INF, 0}, + {"sinh", sinh, &NAN, &NAN, 0}, + {"sinh", sinh, &ZERO, &ZERO, 0}, + {"sinh", sinh, &MZERO, &MZERO, 0}, + {"sinh", sinh, &INF, &INF, 0}, + {"sinh", sinh, &MINF, &MINF, 0}, + {"tanh", tanh, &NAN, &NAN, 0}, + {"tanh", tanh, &ZERO, &ZERO, 0}, + {"tanh", tanh, &MZERO, &MZERO, 0}, + {"tanh", tanh, &INF, &ONE, 0}, + {"tanh", tanh, &MINF, &MONE, 0}, + {"exp", exp, &NAN, &NAN, 0}, + {"exp", exp, &ZERO, &ONE, 0}, + {"exp", exp, &MZERO, &ONE, 0}, + {"exp", exp, &INF, &INF, 0}, + {"exp", exp, &MINF, &ZERO, 0}, +#if !GLIBC2 + {"exp2", exp2, &NAN, &NAN, 0}, + {"exp2", exp2, &ZERO, &ONE, 0}, + {"exp2", exp2, &MZERO, &ONE, 0}, + {"exp2", exp2, &INF, &INF, 0}, + {"exp2", exp2, &MINF, &ZERO, 0}, +#endif + {"expm1", expm1, &NAN, &NAN, 0}, + {"expm1", expm1, &ZERO, &ZERO, 0}, + {"expm1", expm1, &MZERO, &MZERO, 0}, + {"expm1", expm1, &INF, &INF, 0}, + {"expm1", expm1, &MINF, &MONE, 0}, + {"log", log, &NAN, &NAN, 0}, + {"log", log, &ZERO, &MINF, 0}, + {"log", log, &MZERO, &MINF, 0}, + {"log", log, &ONE, &ZERO, 0}, + {"log", log, &MONE, &NAN, 0}, + {"log", log, &INF, &INF, 0}, + {"log10", log10, &NAN, &NAN, 0}, + {"log10", log10, &ZERO, &MINF, 0}, + {"log10", log10, &MZERO, &MINF, 0}, + {"log10", log10, &ONE, &ZERO, 0}, + {"log10", log10, &MONE, &NAN, 0}, + {"log10", log10, &INF, &INF, 0}, + {"log1p", log1p, &NAN, &NAN, 0}, + {"log1p", log1p, &ZERO, &ZERO, 0}, + {"log1p", log1p, &MZERO, &MZERO, 0}, + {"log1p", log1p, &MONE, &MINF, 0}, + {"log1p", log1p, &MTWO, &NAN, 0}, + {"log1p", log1p, &INF, &INF, 0}, +#if !GLIBC2 + {"log2", log2, &NAN, &NAN, 0}, + {"log2", log2, &ZERO, &MINF, 0}, + {"log2", log2, &MZERO, &MINF, 0}, + {"log2", log2, &MONE, &NAN, 0}, + {"log2", log2, &INF, &INF, 0}, +#endif + /* {"fabs", fabs, NAN, NAN, 0}, */ + {"fabs", fabs, &ONE, &ONE, 0}, + {"fabs", fabs, &MONE, &ONE, 0}, + {"fabs", fabs, &ZERO, &ZERO, 0}, + {"fabs", fabs, &MZERO, &ZERO, 0}, + {"fabs", fabs, &INF, &INF, 0}, + {"fabs", fabs, &MINF, &INF, 0}, + {"cbrt", cbrt, &NAN, &NAN, 0}, + {"cbrt", cbrt, &ZERO, &ZERO, 0}, + {"cbrt", cbrt, &MZERO, &MZERO, 0}, + {"cbrt", cbrt, &INF, &INF, 0}, + {"cbrt", cbrt, &MINF, &MINF, 0}, + {"erf", erf, &NAN, &NAN, 0}, + {"erf", erf, &ZERO, &ZERO, 0}, + {"erf", erf, &MZERO, &MZERO, 0}, + {"erf", erf, &INF, &ONE, 0}, + {"erf", erf, &MINF, &MONE, 0}, + {"erfc", erfc, &NAN, &NAN, 0}, + {"erfc", erfc, &INF, &ZERO, 0}, + {"erfc", erfc, &MINF, &TWO, 0}, + {"tgamma", tgamma, &NAN, &NAN, 0}, + {"tgamma", tgamma, &INF, &INF, 0}, + {"tgamma", tgamma, &MONE, &NAN, 0}, + {"tgamma", tgamma, &ZERO, &INF, 0}, + {"tgamma", tgamma, &MINF, &NAN, 0}, +#if GLIBC2 + {"lgamma", lgamma, &NAN, &NAN, 0}, + {"lgamma", lgamma, &INF, &INF, 0}, + {"lgamma", lgamma, &MONE, &INF, 0}, + {"lgamma", lgamma, &ZERO, &INF, 0}, + {"lgamma", lgamma, &MINF, &INF, 0}, +#else + {"lgam", lgam, &NAN, &NAN, 0}, + {"lgam", lgam, &INF, &INF, 0}, + {"lgam", lgam, &MONE, &INF, 0}, + {"lgam", lgam, &ZERO, &INF, 0}, + {"lgam", lgam, &MINF, &INF, 0}, +#endif + {"ceil", ceil, &NAN, &NAN, 0}, + {"ceil", ceil, &ZERO, &ZERO, 0}, + {"ceil", ceil, &MZERO, &MZERO, 0}, + {"ceil", ceil, &INF, &INF, 0}, + {"ceil", ceil, &MINF, &MINF, 0}, + {"floor", floor, &NAN, &NAN, 0}, + {"floor", floor, &ZERO, &ZERO, 0}, + {"floor", floor, &MZERO, &MZERO, 0}, + {"floor", floor, &INF, &INF, 0}, + {"floor", floor, &MINF, &MINF, 0}, + {"null", NULL, &ZERO, &ZERO, 0}, +}; + +/* Functions of two variables. */ +double atan2 (double, double); +double pow (double, double); + +struct twoarguments + { + char *name; /* Name of the function. */ + double (*func) (double, double); + double *arg1; + double *arg2; + double *answer; + int thresh; + }; + +static struct twoarguments test2[] = +{ + {"atan2", atan2, &ZERO, &ONE, &ZERO, 0}, + {"atan2", atan2, &MZERO, &ONE, &MZERO, 0}, + {"atan2", atan2, &ZERO, &ZERO, &ZERO, 0}, + {"atan2", atan2, &MZERO, &ZERO, &MZERO, 0}, + {"atan2", atan2, &ZERO, &MONE, &PI, 0}, + {"atan2", atan2, &MZERO, &MONE, &MPI, 0}, + {"atan2", atan2, &ZERO, &MZERO, &PI, 0}, + {"atan2", atan2, &MZERO, &MZERO, &MPI, 0}, + {"atan2", atan2, &ONE, &ZERO, &PIO2, 0}, + {"atan2", atan2, &ONE, &MZERO, &PIO2, 0}, + {"atan2", atan2, &MONE, &ZERO, &MPIO2, 0}, + {"atan2", atan2, &MONE, &MZERO, &MPIO2, 0}, + {"atan2", atan2, &ONE, &INF, &ZERO, 0}, + {"atan2", atan2, &MONE, &INF, &MZERO, 0}, + {"atan2", atan2, &INF, &ONE, &PIO2, 0}, + {"atan2", atan2, &INF, &MONE, &PIO2, 0}, + {"atan2", atan2, &MINF, &ONE, &MPIO2, 0}, + {"atan2", atan2, &MINF, &MONE, &MPIO2, 0}, + {"atan2", atan2, &ONE, &MINF, &PI, 0}, + {"atan2", atan2, &MONE, &MINF, &MPI, 0}, + {"atan2", atan2, &INF, &INF, &PIO4, 0}, + {"atan2", atan2, &MINF, &INF, &MPIO4, 0}, + {"atan2", atan2, &INF, &MINF, &THPIO4, 0}, + {"atan2", atan2, &MINF, &MINF, &MTHPIO4, 0}, + {"atan2", atan2, &ONE, &ONE, &PIO4, 0}, + {"atan2", atan2, &NAN, &ONE, &NAN, 0}, + {"atan2", atan2, &ONE, &NAN, &NAN, 0}, + {"atan2", atan2, &NAN, &NAN, &NAN, 0}, + {"pow", pow, &ONE, &ZERO, &ONE, 0}, + {"pow", pow, &ONE, &MZERO, &ONE, 0}, + {"pow", pow, &MONE, &ZERO, &ONE, 0}, + {"pow", pow, &MONE, &MZERO, &ONE, 0}, + {"pow", pow, &INF, &ZERO, &ONE, 0}, + {"pow", pow, &INF, &MZERO, &ONE, 0}, + {"pow", pow, &NAN, &ZERO, &ONE, 0}, + {"pow", pow, &NAN, &MZERO, &ONE, 0}, + {"pow", pow, &TWO, &INF, &INF, 0}, + {"pow", pow, &MTWO, &INF, &INF, 0}, + {"pow", pow, &HALF, &INF, &ZERO, 0}, + {"pow", pow, &MHALF, &INF, &ZERO, 0}, + {"pow", pow, &TWO, &MINF, &ZERO, 0}, + {"pow", pow, &MTWO, &MINF, &ZERO, 0}, + {"pow", pow, &HALF, &MINF, &INF, 0}, + {"pow", pow, &MHALF, &MINF, &INF, 0}, + {"pow", pow, &INF, &HALF, &INF, 0}, + {"pow", pow, &INF, &TWO, &INF, 0}, + {"pow", pow, &INF, &MHALF, &ZERO, 0}, + {"pow", pow, &INF, &MTWO, &ZERO, 0}, + {"pow", pow, &MINF, &THREE, &MINF, 0}, + {"pow", pow, &MINF, &TWO, &INF, 0}, + {"pow", pow, &MINF, &MTHREE, &MZERO, 0}, + {"pow", pow, &MINF, &MTWO, &ZERO, 0}, + {"pow", pow, &NAN, &ONE, &NAN, 0}, + {"pow", pow, &ONE, &NAN, &NAN, 0}, + {"pow", pow, &NAN, &NAN, &NAN, 0}, + {"pow", pow, &ONE, &INF, &NAN, 0}, + {"pow", pow, &MONE, &INF, &NAN, 0}, + {"pow", pow, &ONE, &MINF, &NAN, 0}, + {"pow", pow, &MONE, &MINF, &NAN, 0}, + {"pow", pow, &MTWO, &HALF, &NAN, 0}, + {"pow", pow, &ZERO, &MTHREE, &INF, 0}, + {"pow", pow, &MZERO, &MTHREE, &MINF, 0}, + {"pow", pow, &ZERO, &MHALF, &INF, 0}, + {"pow", pow, &MZERO, &MHALF, &INF, 0}, + {"pow", pow, &ZERO, &THREE, &ZERO, 0}, + {"pow", pow, &MZERO, &THREE, &MZERO, 0}, + {"pow", pow, &ZERO, &HALF, &ZERO, 0}, + {"pow", pow, &MZERO, &HALF, &ZERO, 0}, + {"null", NULL, &ZERO, &ZERO, &ZERO, 0}, +}; + +/* Integer functions of one variable. */ + +int isnan (double); +int __signbit (double); + +struct intans + { + char *name; /* Name of the function. */ + int (*func) (double); + double *arg1; + int ianswer; + }; + +static struct intans test3[] = +{ + {"isfinite", __isfinite, &ZERO, 1}, + {"isfinite", __isfinite, &INF, 0}, + {"isfinite", __isfinite, &MINF, 0}, + {"isnan", isnan, &NAN, 1}, + {"isnan", isnan, &INF, 0}, + {"isnan", isnan, &ZERO, 0}, + {"isnan", isnan, &MZERO, 0}, + {"signbit", __signbit, &MZERO, 1}, + {"signbit", __signbit, &MONE, 1}, + {"signbit", __signbit, &ZERO, 0}, + {"signbit", __signbit, &ONE, 0}, + {"signbit", __signbit, &MINF, 1}, + {"signbit", __signbit, &INF, 0}, + {"null", NULL, &ZERO, 0}, +}; + +static volatile double x1; +static volatile double x2; +static volatile double y; +static volatile double answer; + +static void +pvec(x) +double x; +{ + union + { + double d; + unsigned short s[4]; + } u; + int i; + + u.d = x; + for (i = 0; i < 4; i++) + printf ("0x%04x ", u.s[i]); + printf ("\n"); +} + + +int +testvect () +{ + int i, nerrors, k, ianswer, ntests; + double (*fun1) (double); + double (*fun2) (double, double); + int (*fun3) (double); + double e; + union + { + double d; + char c[8]; + } u, v; + + ZERO = 0.0; + MZERO = NEGZERO; + HALF = 0.5; + MHALF = -HALF; + ONE = 1.0; + MONE = -ONE; + TWO = 2.0; + MTWO = -TWO; + THREE = 3.0; + MTHREE = -THREE; + INF = INFINITY; + MINF = -INFINITY; + MPI = -PI; + PIO2 = 0.5 * PI; + MPIO2 = -PIO2; + PIO4 = 0.5 * PIO2; + MPIO4 = -PIO4; + THPIO4 = 3.0 * PIO4; + MTHPIO4 = -THPIO4; + + nerrors = 0; + ntests = 0; + i = 0; + for (;;) + { + fun1 = test1[i].func; + if (fun1 == NULL) + break; + x1 = *(test1[i].arg1); + y = (*(fun1)) (x1); + answer = *(test1[i].answer); + if (test1[i].thresh == 0) + { + v.d = answer; + u.d = y; + if (memcmp(u.c, v.c, 8) != 0) + { + if( isnan(v.d) && isnan(u.d) ) + goto nxttest1; + goto wrongone; + } + else + goto nxttest1; + } + if (y != answer) + { + e = y - answer; + if (answer != 0.0) + e = e / answer; + if (e < 0) + e = -e; + if (e > test1[i].thresh * MACHEP) + { +wrongone: + printf ("%s (%.16e) = %.16e\n should be %.16e\n", + test1[i].name, x1, y, answer); + nerrors += 1; + } + } +nxttest1: + ntests += 1; + i += 1; + } + + i = 0; + for (;;) + { + fun2 = test2[i].func; + if (fun2 == NULL) + break; + x1 = *(test2[i].arg1); + x2 = *(test2[i].arg2); + y = (*(fun2)) (x1, x2); + answer = *(test2[i].answer); + if (test2[i].thresh == 0) + { + v.d = answer; + u.d = y; + if (memcmp(u.c, v.c, 8) != 0) + { + if( isnan(v.d) && isnan(u.d) ) + goto nxttest2; +#if 0 + if( isnan(v.d) ) + pvec(v.d); + if( isnan(u.d) ) + pvec(u.d); +#endif + goto wrongtwo; + } + else + goto nxttest2; + } + if (y != answer) + { + e = y - answer; + if (answer != 0.0) + e = e / answer; + if (e < 0) + e = -e; + if (e > test2[i].thresh * MACHEP) + { +wrongtwo: + printf ("%s (%.16e, %.16e) = %.16e\n should be %.16e\n", + test2[i].name, x1, x2, y, answer); + nerrors += 1; + } + } +nxttest2: + ntests += 1; + i += 1; + } + + + i = 0; + for (;;) + { + fun3 = test3[i].func; + if (fun3 == NULL) + break; + x1 = *(test3[i].arg1); + k = (*(fun3)) (x1); + ianswer = test3[i].ianswer; + if (k != ianswer) + { + printf ("%s (%.16e) = %d\n should be. %d\n", + test3[i].name, x1, k, ianswer); + nerrors += 1; + } + ntests += 1; + i += 1; + } + + printf ("%d errors in %d tests\n", nerrors, ntests); + return (nerrors); +} diff --git a/regress/lib/libm/cephes/testvectl.c b/regress/lib/libm/cephes/testvectl.c new file mode 100644 index 00000000000..d3b3ee762b1 --- /dev/null +++ b/regress/lib/libm/cephes/testvectl.c @@ -0,0 +1,522 @@ +/* $OpenBSD: testvectl.c,v 1.1 2011/05/30 20:23:35 martynas Exp $ */ + +/* + * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* Test vectors for math functions. + See C9X section F.9. + + On some systems it may be necessary to modify the default exception + settings of the floating point arithmetic unit. */ + +#include <float.h> + +#if LDBL_MANT_DIG == 64 +#include <stdio.h> +#include <string.h> +int __isfinitel (long double); + +/* Some compilers will not accept these expressions. */ + +#define ZINF 1 +#define ZMINF 2 +#define ZNANL 3 +#define ZPIL 4 +#define ZPIO2L 4 + +extern long double INFINITYL, NANL, NEGZEROL; +long double MINFL; +extern long double PIL, PIO2L, PIO4L, MACHEPL; +long double MPIL; +long double MPIO2L; +long double MPIO4L; +long double THPIO4L = 2.35619449019234492884698L; +long double MTHPIO4L = -2.35619449019234492884698L; +long double SQRT2L = 1.414213562373095048802E0L; +long double SQRTHL = 7.071067811865475244008E-1L; +long double ZEROL = 0.0L; +long double HALFL = 0.5L; +long double MHALFL = -0.5L; +long double ONEL = 1.0L; +long double MONEL = -1.0L; +long double TWOL = 2.0L; +long double MTWOL = -2.0L; +long double THREEL = 3.0L; +long double MTHREEL = -3.0L; + +/* Functions of one variable. */ +long double logl (long double); +long double expl (long double); +long double atanl (long double); +long double sinl (long double); +long double cosl (long double); +long double tanl (long double); +long double acosl (long double); +long double asinl (long double); +long double acoshl (long double); +long double asinhl (long double); +long double atanhl (long double); +long double sinhl (long double); +long double coshl (long double); +long double tanhl (long double); +long double exp2l (long double); +long double expm1l (long double); +long double log10l (long double); +long double log1pl (long double); +long double log2l (long double); +long double fabsl (long double); +long double erfl (long double); +long double erfcl (long double); +long double gammal (long double); +long double lgaml (long double); +long double floorl (long double); +long double ceill (long double); +long double cbrtl (long double); + +struct oneargument + { + char *name; /* Name of the function. */ + long double (*func) (long double); + long double *arg1; + long double *answer; + int thresh; /* Error report threshold. */ + }; + +#if 0 + {"sinl", sinl, 32767.L, 1.8750655394138942394239E-1L, 0}, + {"cosl", cosl, 32767.L, 9.8226335176928229845654E-1L, 0}, + {"tanl", tanl, 32767.L, 1.9089234430221485740826E-1L, 0}, + {"sinl", sinl, 8388607.L, 9.9234509376961249835628E-1L, 0}, + {"cosl", cosl, 8388607.L, -1.2349580912475928183718E-1L, 0}, + {"tanl", tanl, 8388607.L, -8.0354556223613614748329E0L, 0}, + {"sinl", sinl, 2147483647.L, -7.2491655514455639054829E-1L, 0}, + {"cosl", cosl, 2147483647.L, -6.8883669187794383467976E-1L, 0}, + {"tanl", tanl, 2147483647.L, 1.0523779637351339136698E0L, 0}, + {"sinl", sinl, PIO4L, 7.0710678118654752440084E-1L, 0}, + {"cosl", cosl, PIO2L, -2.50827880633416613471e-20L, 0}, +#endif + +static struct oneargument test1[] = +{ + {"atanl", atanl, &ONEL, &PIO4L, 0}, + {"sinl", sinl, &PIO2L, &ONEL, 0}, + {"cosl", cosl, &PIO4L, &SQRTHL, 0}, + {"acosl", acosl, &NANL, &NANL, 0}, + {"acosl", acosl, &ONEL, &ZEROL, 0}, + {"acosl", acosl, &TWOL, &NANL, 0}, + {"acosl", acosl, &MTWOL, &NANL, 0}, + {"asinl", asinl, &NANL, &NANL, 0}, + {"asinl", asinl, &ZEROL, &ZEROL, 0}, + {"asinl", asinl, &NEGZEROL, &NEGZEROL, 0}, + {"asinl", asinl, &TWOL, &NANL, 0}, + {"asinl", asinl, &MTWOL, &NANL, 0}, + {"atanl", atanl, &NANL, &NANL, 0}, + {"atanl", atanl, &ZEROL, &ZEROL, 0}, + {"atanl", atanl, &NEGZEROL, &NEGZEROL, 0}, + {"atanl", atanl, &INFINITYL, &PIO2L, 0}, + {"atanl", atanl, &MINFL, &MPIO2L, 0}, + {"cosl", cosl, &NANL, &NANL, 0}, + {"cosl", cosl, &ZEROL, &ONEL, 0}, + {"cosl", cosl, &NEGZEROL, &ONEL, 0}, + {"cosl", cosl, &INFINITYL, &NANL, 0}, + {"cosl", cosl, &MINFL, &NANL, 0}, + {"sinl", sinl, &NANL, &NANL, 0}, + {"sinl", sinl, &NEGZEROL, &NEGZEROL, 0}, + {"sinl", sinl, &ZEROL, &ZEROL, 0}, + {"sinl", sinl, &INFINITYL, &NANL, 0}, + {"sinl", sinl, &MINFL, &NANL, 0}, + {"tanl", tanl, &NANL, &NANL, 0}, + {"tanl", tanl, &ZEROL, &ZEROL, 0}, + {"tanl", tanl, &NEGZEROL, &NEGZEROL, 0}, + {"tanl", tanl, &INFINITYL, &NANL, 0}, + {"tanl", tanl, &MINFL, &NANL, 0}, +#if 0 + {"acoshl", acoshl, &NANL, &NANL, 0}, + {"acoshl", acoshl, &ONEL, &ZEROL, 0}, + {"acoshl", acoshl, &INFINITYL, &INFINITYL, 0}, + {"acoshl", acoshl, &HALFL, &NANL, 0}, + {"acoshl", acoshl, &MONEL, &NANL, 0}, + {"asinhl", asinhl, &NANL, &NANL, 0}, + {"asinhl", asinhl, &ZEROL, &ZEROL, 0}, + {"asinhl", asinhl, &NEGZEROL, &NEGZEROL, 0}, + {"asinhl", asinhl, &INFINITYL, &INFINITYL, 0}, + {"asinhl", asinhl, &MINFL, &MINFL, 0}, + {"atanhl", atanhl, &NANL, &NANL, 0}, + {"atanhl", atanhl, &ZEROL, &ZEROL, 0}, + {"atanhl", atanhl, &NEGZEROL, &NEGZEROL, 0}, + {"atanhl", atanhl, &ONEL, &INFINITYL, 0}, + {"atanhl", atanhl, &MONEL, &MINFL, 0}, + {"atanhl", atanhl, &TWOL, &NANL, 0}, + {"atanhl", atanhl, &MTWOL, &NANL, 0}, + {"coshl", coshl, &NANL, &NANL, 0}, + {"coshl", coshl, &ZEROL, &ONEL, 0}, + {"coshl", coshl, &NEGZEROL, &ONEL, 0}, + {"coshl", coshl, &INFINITYL, &INFINITYL, 0}, + {"coshl", coshl, &MINFL, &INFINITYL, 0}, + {"sinhl", sinhl, &NANL, &NANL, 0}, + {"sinhl", sinhl, &ZEROL, &ZEROL, 0}, + {"sinhl", sinhl, &NEGZEROL, &NEGZEROL, 0}, + {"sinhl", sinhl, &INFINITYL, &INFINITYL, 0}, + {"sinhl", sinhl, &MINFL, &MINFL, 0}, + {"tanhl", tanhl, &NANL, &NANL, 0}, + {"tanhl", tanhl, &ZEROL, &ZEROL, 0}, + {"tanhl", tanhl, &NEGZEROL, &NEGZEROL, 0}, + {"tanhl", tanhl, &INFINITYL, &ONEL, 0}, + {"tanhl", tanhl, &MINFL, &MONEL, 0}, + {"expl", expl, &NANL, &NANL, 0}, + {"expl", expl, &ZEROL, &ONEL, 0}, + {"expl", expl, &NEGZEROL, &ONEL, 0}, + {"expl", expl, &INFINITYL, &INFINITYL, 0}, + {"expl", expl, &MINFL, &ZEROL, 0}, +#endif + {"exp2l", exp2l, &NANL, &NANL, 0}, + {"exp2l", exp2l, &ZEROL, &ONEL, 0}, + {"exp2l", exp2l, &NEGZEROL, &ONEL, 0}, + {"exp2l", exp2l, &INFINITYL, &INFINITYL, 0}, + {"exp2l", exp2l, &MINFL, &ZEROL, 0}, +#if 0 + {"expm1l", expm1l, &NANL, &NANL, 0}, + {"expm1l", expm1l, &ZEROL, &ZEROL, 0}, + {"expm1l", expm1l, &NEGZEROL, &NEGZEROL, 0}, + {"expm1l", expm1l, &INFINITYL, &INFINITYL, 0}, + {"expm1l", expm1l, &MINFL, &MONEL, 0}, + {"logl", logl, &NANL, &NANL, 0}, + {"logl", logl, &ZEROL, &MINFL, 0}, + {"logl", logl, &NEGZEROL, &MINFL, 0}, + {"logl", logl, &ONEL, &ZEROL, 0}, + {"logl", logl, &MONEL, &NANL, 0}, + {"logl", logl, &INFINITYL, &INFINITYL, 0}, + {"log10l", log10l, &NANL, &NANL, 0}, + {"log10l", log10l, &ZEROL, &MINFL, 0}, + {"log10l", log10l, &NEGZEROL, &MINFL, 0}, + {"log10l", log10l, &ONEL, &ZEROL, 0}, + {"log10l", log10l, &MONEL, &NANL, 0}, + {"log10l", log10l, &INFINITYL, &INFINITYL, 0}, + {"log1pl", log1pl, &NANL, &NANL, 0}, + {"log1pl", log1pl, &ZEROL, &ZEROL, 0}, + {"log1pl", log1pl, &NEGZEROL, &NEGZEROL, 0}, + {"log1pl", log1pl, &MONEL, &MINFL, 0}, + {"log1pl", log1pl, &MTWOL, &NANL, 0}, + {"log1pl", log1pl, &INFINITYL, &INFINITYL, 0}, + {"log2l", log2l, &NANL, &NANL, 0}, + {"log2l", log2l, &ZEROL, &MINFL, 0}, + {"log2l", log2l, &NEGZEROL, &MINFL, 0}, + {"log2l", log2l, &MONEL, &NANL, 0}, + {"log2l", log2l, &INFINITYL, &INFINITYL, 0}, +#endif + /* {"fabsl", fabsl, &NANL, &NANL, 0}, */ + {"fabsl", fabsl, &ONEL, &ONEL, 0}, + {"fabsl", fabsl, &MONEL, &ONEL, 0}, + {"fabsl", fabsl, &ZEROL, &ZEROL, 0}, + {"fabsl", fabsl, &NEGZEROL, &ZEROL, 0}, + {"fabsl", fabsl, &INFINITYL, &INFINITYL, 0}, + {"fabsl", fabsl, &MINFL, &INFINITYL, 0}, +#if 0 + {"cbrtl", cbrtl, &NANL, &NANL, 0}, + {"cbrtl", cbrtl, &ZEROL, &ZEROL, 0}, + {"cbrtl", cbrtl, &NEGZEROL, &NEGZEROL, 0}, + {"cbrtl", cbrtl, &INFINITYL, &INFINITYL, 0}, + {"cbrtl", cbrtl, &MINFL, &MINFL, 0}, + {"erfl", erfl, &NANL, &NANL, 0}, + {"erfl", erfl, &ZEROL, &ZEROL, 0}, + {"erfl", erfl, &NEGZEROL, &NEGZEROL, 0}, + {"erfl", erfl, &INFINITYL, &ONEL, 0}, + {"erfl", erfl, &MINFL, &MONEL, 0}, + {"erfcl", erfcl, &NANL, &NANL, 0}, + {"erfcl", erfcl, &INFINITYL, &ZEROL, 0}, + {"erfcl", erfcl, &MINFL, &TWOL, 0}, + {"gammal", gammal, &NANL, &NANL, 0}, + {"gammal", gammal, &INFINITYL, &INFINITYL, 0}, + {"gammal", gammal, &MONEL, &NANL, 0}, + {"gammal", gammal, &ZEROL, &NANL, 0}, + {"gammal", gammal, &MINFL, &NANL, 0}, + {"lgaml", lgaml, &NANL, &NANL, 0}, + {"lgaml", lgaml, &INFINITYL, &INFINITYL, 0}, + {"lgaml", lgaml, &MONEL, &INFINITYL, 0}, + {"lgaml", lgaml, &ZEROL, &INFINITYL, 0}, + {"lgaml", lgaml, &MINFL, &INFINITYL, 0}, + {"ceill", ceill, &NANL, &NANL, 0}, + {"ceill", ceill, &ZEROL, &ZEROL, 0}, + {"ceill", ceill, &NEGZEROL, &NEGZEROL, 0}, + {"ceill", ceill, &INFINITYL, &INFINITYL, 0}, + {"ceill", ceill, &MINFL, &MINFL, 0}, + {"floorl", floorl, &NANL, &NANL, 0}, + {"floorl", floorl, &ZEROL, &ZEROL, 0}, + {"floorl", floorl, &NEGZEROL, &NEGZEROL, 0}, + {"floorl", floorl, &INFINITYL, &INFINITYL, 0}, + {"floorl", floorl, &MINFL, &MINFL, 0}, +#endif + {"null", NULL, &ZEROL, &ZEROL, 0}, +}; + +/* Functions of two variables. */ +long double atan2l (long double, long double); +long double powl (long double, long double); + +struct twoarguments + { + char *name; /* Name of the function. */ + long double (*func) (long double, long double); + long double *arg1; + long double *arg2; + long double *answer; + int thresh; + }; + +static struct twoarguments test2[] = +{ + {"atan2l", atan2l, &ZEROL, &ONEL, &ZEROL, 0}, + {"atan2l", atan2l, &NEGZEROL, &ONEL,&NEGZEROL, 0}, + {"atan2l", atan2l, &ZEROL, &ZEROL, &ZEROL, 0}, + {"atan2l", atan2l, &NEGZEROL, &ZEROL, &NEGZEROL, 0}, + {"atan2l", atan2l, &ZEROL, &MONEL, &PIL, 0}, + {"atan2l", atan2l, &NEGZEROL, &MONEL, &MPIL, 0}, + {"atan2l", atan2l, &ZEROL, &NEGZEROL, &PIL, 0}, + {"atan2l", atan2l, &NEGZEROL, &NEGZEROL, &MPIL, 0}, + {"atan2l", atan2l, &ONEL, &ZEROL, &PIO2L, 0}, + {"atan2l", atan2l, &ONEL, &NEGZEROL, &PIO2L, 0}, + {"atan2l", atan2l, &MONEL, &ZEROL, &MPIO2L, 0}, + {"atan2l", atan2l, &MONEL, &NEGZEROL, &MPIO2L, 0}, + {"atan2l", atan2l, &ONEL, &INFINITYL, &ZEROL, 0}, + {"atan2l", atan2l, &MONEL, &INFINITYL, &NEGZEROL, 0}, + {"atan2l", atan2l, &INFINITYL, &ONEL, &PIO2L, 0}, + {"atan2l", atan2l, &INFINITYL, &MONEL, &PIO2L, 0}, + {"atan2l", atan2l, &MINFL, &ONEL, &MPIO2L, 0}, + {"atan2l", atan2l, &MINFL, &MONEL, &MPIO2L, 0}, + {"atan2l", atan2l, &ONEL, &MINFL, &PIL, 0}, + {"atan2l", atan2l, &MONEL, &MINFL, &MPIL, 0}, + {"atan2l", atan2l, &INFINITYL, &INFINITYL, &PIO4L, 0}, + {"atan2l", atan2l, &MINFL, &INFINITYL, &MPIO4L, 0}, + {"atan2l", atan2l, &INFINITYL, &MINFL, &THPIO4L, 0}, + {"atan2l", atan2l, &MINFL, &MINFL, &MTHPIO4L, 0}, + {"atan2l", atan2l, &ONEL, &ONEL, &PIO4L, 0}, + {"atan2l", atan2l, &NANL, &ONEL, &NANL, 0}, + {"atan2l", atan2l, &ONEL, &NANL, &NANL, 0}, + {"atan2l", atan2l, &NANL, &NANL, &NANL, 0}, +#if 0 + {"powl", powl, &ONEL, &ZEROL, &ONEL, 0}, + {"powl", powl, &ONEL, &NEGZEROL, &ONEL, 0}, + {"powl", powl, &MONEL, &ZEROL, &ONEL, 0}, + {"powl", powl, &MONEL, &NEGZEROL, &ONEL, 0}, + {"powl", powl, &INFINITYL, &ZEROL, &ONEL, 0}, + {"powl", powl, &INFINITYL, &NEGZEROL, &ONEL, 0}, + {"powl", powl, &NANL, &ZEROL, &ONEL, 0}, + {"powl", powl, &NANL, &NEGZEROL, &ONEL, 0}, + {"powl", powl, &TWOL, &INFINITYL, &INFINITYL, 0}, + {"powl", powl, &MTWOL, &INFINITYL, &INFINITYL, 0}, + {"powl", powl, &HALFL, &INFINITYL, &ZEROL, 0}, + {"powl", powl, &MHALFL, &INFINITYL, &ZEROL, 0}, + {"powl", powl, &TWOL, &MINFL, &ZEROL, 0}, + {"powl", powl, &MTWOL, &MINFL, &ZEROL, 0}, + {"powl", powl, &HALFL, &MINFL, &INFINITYL, 0}, + {"powl", powl, &MHALFL, &MINFL, &INFINITYL, 0}, + {"powl", powl, &INFINITYL, &HALFL, &INFINITYL, 0}, + {"powl", powl, &INFINITYL, &TWOL, &INFINITYL, 0}, + {"powl", powl, &INFINITYL, &MHALFL, &ZEROL, 0}, + {"powl", powl, &INFINITYL, &MTWOL, &ZEROL, 0}, + {"powl", powl, &MINFL, &THREEL, &MINFL, 0}, + {"powl", powl, &MINFL, &TWOL, &INFINITYL, 0}, + {"powl", powl, &MINFL, &MTHREEL, &NEGZEROL, 0}, + {"powl", powl, &MINFL, &MTWOL, &ZEROL, 0}, + {"powl", powl, &NANL, &ONEL, &NANL, 0}, + {"powl", powl, &ONEL, &NANL, &NANL, 0}, + {"powl", powl, &NANL, &NANL, &NANL, 0}, + {"powl", powl, &ONEL, &INFINITYL, &NANL, 0}, + {"powl", powl, &MONEL, &INFINITYL, &NANL, 0}, + {"powl", powl, &ONEL, &MINFL, &NANL, 0}, + {"powl", powl, &MONEL, &MINFL, &NANL, 0}, + {"powl", powl, &MTWOL, &HALFL, &NANL, 0}, + {"powl", powl, &ZEROL, &MTHREEL, &INFINITYL, 0}, + {"powl", powl, &NEGZEROL, &MTHREEL, &MINFL, 0}, + {"powl", powl, &ZEROL, &MHALFL, &INFINITYL, 0}, + {"powl", powl, &NEGZEROL, &MHALFL, &INFINITYL, 0}, + {"powl", powl, &ZEROL, &THREEL, &ZEROL, 0}, + {"powl", powl, &NEGZEROL, &THREEL, &NEGZEROL, 0}, + {"powl", powl, &ZEROL, &HALFL, &ZEROL, 0}, + {"powl", powl, &NEGZEROL, &HALFL, &ZEROL, 0}, +#endif + {"null", NULL, &ZEROL, &ZEROL, &ZEROL, 0}, +}; + +/* Integer functions of one variable. */ + +int __isnanl (long double); +int __signbitl (long double); + +struct intans + { + char *name; /* Name of the function. */ + int (*func) (long double); + long double *arg1; + int ianswer; + }; + +static struct intans test3[] = +{ + {"isfinitel", __isfinitel, &ZEROL, 1}, + {"isfinitel", __isfinitel, &INFINITYL, 0}, + {"isfinitel", __isfinitel, &MINFL, 0}, + {"isnanl", __isnanl, &NANL, 1}, + {"isnanl", __isnanl, &INFINITYL, 0}, + {"isnanl", __isnanl, &ZEROL, 0}, + {"isnanl", __isnanl, &NEGZEROL, 0}, + {"signbitl", __signbitl, &NEGZEROL, 1}, + {"signbitl", __signbitl, &MONEL, 1}, + {"signbitl", __signbitl, &ZEROL, 0}, + {"signbitl", __signbitl, &ONEL, 0}, + {"signbitl", __signbitl, &MINFL, 1}, + {"signbitl", __signbitl, &INFINITYL, 0}, + {"null", NULL, &ZEROL, 0}, +}; + +static volatile long double x1; +static volatile long double x2; +static volatile long double y; +static volatile long double answer; + +int +testvectl () +{ + int i, nerrors, k, ianswer, ntests; + long double (*fun1) (long double); + long double (*fun2) (long double, long double); + int (*fun3) (long double); + long double e; + union + { + long double d; + char c[12]; + } u, v; + + /* This masks off fpu exceptions on i386. */ + /* setfpu(0x137f); */ + nerrors = 0; + ntests = 0; + MINFL = -INFINITYL; + MPIL = -PIL; + MPIO2L = -PIO2L; + MPIO4L = -PIO4L; + i = 0; + for (;;) + { + fun1 = test1[i].func; + if (fun1 == NULL) + break; + x1 = *(test1[i].arg1); + y = (*(fun1)) (x1); + answer = *(test1[i].answer); + if (test1[i].thresh == 0) + { + v.d = answer; + u.d = y; + if (memcmp(u.c, v.c, 10) != 0) + { + /* O.K. if both are NaNs of some sort. */ + if (__isnanl(v.d) && __isnanl(u.d)) + goto nxttest1; + goto wrongone; + } + else + goto nxttest1; + } + if (y != answer) + { + e = y - answer; + if (answer != 0.0L) + e = e / answer; + if (e < 0) + e = -e; + if (e > test1[i].thresh * MACHEPL) + { +wrongone: + printf ("%s (%.20Le) = %.20Le\n should be %.20Le\n", + test1[i].name, x1, y, answer); + nerrors += 1; + } + } +nxttest1: + ntests += 1; + i += 1; + } + + i = 0; + for (;;) + { + fun2 = test2[i].func; + if (fun2 == NULL) + break; + x1 = *(test2[i].arg1); + x2 = *(test2[i].arg2); + y = (*(fun2)) (x1, x2); + answer = *(test2[i].answer); + if (test2[i].thresh == 0) + { + v.d = answer; + u.d = y; + if (memcmp(u.c, v.c, 10) != 0) + { + /* O.K. if both are NaNs of some sort. */ + if (__isnanl(v.d) && __isnanl(u.d)) + goto nxttest2; + goto wrongtwo; + } + else + goto nxttest2; + } + if (y != answer) + { + e = y - answer; + if (answer != 0.0L) + e = e / answer; + if (e < 0) + e = -e; + if (e > test2[i].thresh * MACHEPL) + { +wrongtwo: + printf ("%s (%.20Le, %.20Le) = %.20Le\n should be %.20Le\n", + test2[i].name, x1, x2, y, answer); + nerrors += 1; + } + } +nxttest2: + ntests += 1; + i += 1; + } + + + i = 0; + for (;;) + { + fun3 = test3[i].func; + if (fun3 == NULL) + break; + x1 = *(test3[i].arg1); + k = (*(fun3)) (x1); + ianswer = test3[i].ianswer; + if (k != ianswer) + { + printf ("%s (%.20Le) = %d\n should be. %d\n", + test3[i].name, x1, k, ianswer); + nerrors += 1; + } + ntests += 1; + i += 1; + } + + printf ("%d errors in %d tests\n", nerrors, ntests); + return (nerrors); +} +#endif /* LDBL_MANT_DIG == 64 */ diff --git a/regress/lib/libm/cephes/testvectll.c b/regress/lib/libm/cephes/testvectll.c new file mode 100644 index 00000000000..8164d6a1259 --- /dev/null +++ b/regress/lib/libm/cephes/testvectll.c @@ -0,0 +1,551 @@ +/* $OpenBSD: testvectll.c,v 1.1 2011/05/30 20:23:35 martynas Exp $ */ + +/* + * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* Test vectors for math functions. + See C9X section F.9. + + On some systems it may be necessary to modify the default exception + settings of the floating point arithmetic unit. */ + +#include <float.h> + +#if LDBL_MANT_DIG == 113 +#include <stdio.h> +#include <string.h> +int __isfinitel (long double); + +/* Some compilers will not accept these expressions. */ + +#define ZINF 1 +#define ZMINF 2 +#define ZNANL 3 +#define ZPIL 4 +#define ZPIO2L 4 + +/* +extern long double INFINITYL, NANL, NEGZEROL; +*/ +long double INFINITYL, NANL, NEGZEROL; +long double MINFL; +extern long double PIL, PIO2L, PIO4L, MACHEPL; +long double MPIL; +long double MPIO2L; +long double MPIO4L; +long double THPIO4L = 2.35619449019234492884698L; +long double MTHPIO4L = -2.35619449019234492884698L; +long double SQRT2L = 1.414213562373095048802E0L; +long double SQRTHL = 7.071067811865475244008E-1L; +long double ZEROL = 0.0L; +long double HALFL = 0.5L; +long double MHALFL = -0.5L; +long double ONEL = 1.0L; +long double MONEL = -1.0L; +long double TWOL = 2.0L; +long double MTWOL = -2.0L; +long double THREEL = 3.0L; +long double MTHREEL = -3.0L; + +/* Functions of one variable. */ +long double logl (long double); +long double expl (long double); +long double atanl (long double); +long double sinl (long double); +long double cosl (long double); +long double tanl (long double); +long double acosl (long double); +long double asinl (long double); +long double acoshl (long double); +long double asinhl (long double); +long double atanhl (long double); +long double sinhl (long double); +long double coshl (long double); +long double tanhl (long double); +long double exp2l (long double); +long double expm1l (long double); +long double log10l (long double); +long double log1pl (long double); +long double log2l (long double); +long double fabsl (long double); +long double erfl (long double); +long double erfcl (long double); +long double gammal (long double); +long double floorl (long double); +long double ceill (long double); +long double cbrtl (long double); + +/* long double lgaml (long double); */ +long double lgammal (long double); +#define lgaml lgammal + +struct oneargument + { + char *name; /* Name of the function. */ + long double (*func) (long double); + long double *arg1; + long double *answer; + int thresh; /* Error report threshold. */ + }; + +#if 0 + {"sinl", sinl, 32767.L, 1.8750655394138942394239E-1L, 0}, + {"cosl", cosl, 32767.L, 9.8226335176928229845654E-1L, 0}, + {"tanl", tanl, 32767.L, 1.9089234430221485740826E-1L, 0}, + {"sinl", sinl, 8388607.L, 9.9234509376961249835628E-1L, 0}, + {"cosl", cosl, 8388607.L, -1.2349580912475928183718E-1L, 0}, + {"tanl", tanl, 8388607.L, -8.0354556223613614748329E0L, 0}, + {"sinl", sinl, 2147483647.L, -7.2491655514455639054829E-1L, 0}, + {"cosl", cosl, 2147483647.L, -6.8883669187794383467976E-1L, 0}, + {"tanl", tanl, 2147483647.L, 1.0523779637351339136698E0L, 0}, + {"sinl", sinl, PIO4L, 7.0710678118654752440084E-1L, 0}, + {"cosl", cosl, PIO2L, -2.50827880633416613471e-20L, 0}, +#endif + +static struct oneargument test1[] = +{ + {"atanl", atanl, &ONEL, &PIO4L, 0}, + {"sinl", sinl, &PIO2L, &ONEL, 0}, + {"cosl", cosl, &PIO4L, &SQRTHL, 0}, + {"acosl", acosl, &NANL, &NANL, 0}, + {"acosl", acosl, &ONEL, &ZEROL, 0}, + {"acosl", acosl, &TWOL, &NANL, 0}, + {"acosl", acosl, &MTWOL, &NANL, 0}, + {"asinl", asinl, &NANL, &NANL, 0}, + {"asinl", asinl, &ZEROL, &ZEROL, 0}, + {"asinl", asinl, &NEGZEROL, &NEGZEROL, 0}, + {"asinl", asinl, &TWOL, &NANL, 0}, + {"asinl", asinl, &MTWOL, &NANL, 0}, + {"atanl", atanl, &NANL, &NANL, 0}, + {"atanl", atanl, &ZEROL, &ZEROL, 0}, + {"atanl", atanl, &NEGZEROL, &NEGZEROL, 0}, + {"atanl", atanl, &INFINITYL, &PIO2L, 0}, + {"atanl", atanl, &MINFL, &MPIO2L, 0}, + {"cosl", cosl, &NANL, &NANL, 0}, + {"cosl", cosl, &ZEROL, &ONEL, 0}, + {"cosl", cosl, &NEGZEROL, &ONEL, 0}, + {"cosl", cosl, &INFINITYL, &NANL, 0}, + {"cosl", cosl, &MINFL, &NANL, 0}, + {"sinl", sinl, &NANL, &NANL, 0}, + {"sinl", sinl, &NEGZEROL, &NEGZEROL, 0}, + {"sinl", sinl, &ZEROL, &ZEROL, 0}, + {"sinl", sinl, &INFINITYL, &NANL, 0}, + {"sinl", sinl, &MINFL, &NANL, 0}, + {"tanl", tanl, &NANL, &NANL, 0}, + {"tanl", tanl, &ZEROL, &ZEROL, 0}, + {"tanl", tanl, &NEGZEROL, &NEGZEROL, 0}, + {"tanl", tanl, &INFINITYL, &NANL, 0}, + {"tanl", tanl, &MINFL, &NANL, 0}, +#if 0 + {"acoshl", acoshl, &NANL, &NANL, 0}, + {"acoshl", acoshl, &ONEL, &ZEROL, 0}, + {"acoshl", acoshl, &INFINITYL, &INFINITYL, 0}, + {"acoshl", acoshl, &HALFL, &NANL, 0}, + {"acoshl", acoshl, &MONEL, &NANL, 0}, + {"asinhl", asinhl, &NANL, &NANL, 0}, + {"asinhl", asinhl, &ZEROL, &ZEROL, 0}, + {"asinhl", asinhl, &NEGZEROL, &NEGZEROL, 0}, + {"asinhl", asinhl, &INFINITYL, &INFINITYL, 0}, + {"asinhl", asinhl, &MINFL, &MINFL, 0}, + {"atanhl", atanhl, &NANL, &NANL, 0}, + {"atanhl", atanhl, &ZEROL, &ZEROL, 0}, + {"atanhl", atanhl, &NEGZEROL, &NEGZEROL, 0}, + {"atanhl", atanhl, &ONEL, &INFINITYL, 0}, + {"atanhl", atanhl, &MONEL, &MINFL, 0}, + {"atanhl", atanhl, &TWOL, &NANL, 0}, + {"atanhl", atanhl, &MTWOL, &NANL, 0}, + {"coshl", coshl, &NANL, &NANL, 0}, + {"coshl", coshl, &ZEROL, &ONEL, 0}, + {"coshl", coshl, &NEGZEROL, &ONEL, 0}, + {"coshl", coshl, &INFINITYL, &INFINITYL, 0}, + {"coshl", coshl, &MINFL, &INFINITYL, 0}, + {"sinhl", sinhl, &NANL, &NANL, 0}, + {"sinhl", sinhl, &ZEROL, &ZEROL, 0}, + {"sinhl", sinhl, &NEGZEROL, &NEGZEROL, 0}, + {"sinhl", sinhl, &INFINITYL, &INFINITYL, 0}, + {"sinhl", sinhl, &MINFL, &MINFL, 0}, + {"tanhl", tanhl, &NANL, &NANL, 0}, + {"tanhl", tanhl, &ZEROL, &ZEROL, 0}, + {"tanhl", tanhl, &NEGZEROL, &NEGZEROL, 0}, + {"tanhl", tanhl, &INFINITYL, &ONEL, 0}, + {"tanhl", tanhl, &MINFL, &MONEL, 0}, + {"expl", expl, &NANL, &NANL, 0}, + {"expl", expl, &ZEROL, &ONEL, 0}, + {"expl", expl, &NEGZEROL, &ONEL, 0}, + {"expl", expl, &INFINITYL, &INFINITYL, 0}, + {"expl", expl, &MINFL, &ZEROL, 0}, +#endif + {"exp2l", exp2l, &NANL, &NANL, 0}, + {"exp2l", exp2l, &ZEROL, &ONEL, 0}, + {"exp2l", exp2l, &NEGZEROL, &ONEL, 0}, + {"exp2l", exp2l, &INFINITYL, &INFINITYL, 0}, + {"exp2l", exp2l, &MINFL, &ZEROL, 0}, +#if 0 + {"expm1l", expm1l, &NANL, &NANL, 0}, + {"expm1l", expm1l, &ZEROL, &ZEROL, 0}, + {"expm1l", expm1l, &NEGZEROL, &NEGZEROL, 0}, + {"expm1l", expm1l, &INFINITYL, &INFINITYL, 0}, + {"expm1l", expm1l, &MINFL, &MONEL, 0}, + {"logl", logl, &NANL, &NANL, 0}, + {"logl", logl, &ZEROL, &MINFL, 0}, + {"logl", logl, &NEGZEROL, &MINFL, 0}, + {"logl", logl, &ONEL, &ZEROL, 0}, + {"logl", logl, &MONEL, &NANL, 0}, + {"logl", logl, &INFINITYL, &INFINITYL, 0}, + {"log10l", log10l, &NANL, &NANL, 0}, + {"log10l", log10l, &ZEROL, &MINFL, 0}, + {"log10l", log10l, &NEGZEROL, &MINFL, 0}, + {"log10l", log10l, &ONEL, &ZEROL, 0}, + {"log10l", log10l, &MONEL, &NANL, 0}, + {"log10l", log10l, &INFINITYL, &INFINITYL, 0}, + {"log1pl", log1pl, &NANL, &NANL, 0}, + {"log1pl", log1pl, &ZEROL, &ZEROL, 0}, + {"log1pl", log1pl, &NEGZEROL, &NEGZEROL, 0}, + {"log1pl", log1pl, &MONEL, &MINFL, 0}, + {"log1pl", log1pl, &MTWOL, &NANL, 0}, + {"log1pl", log1pl, &INFINITYL, &INFINITYL, 0}, + {"log2l", log2l, &NANL, &NANL, 0}, + {"log2l", log2l, &ZEROL, &MINFL, 0}, + {"log2l", log2l, &NEGZEROL, &MINFL, 0}, + {"log2l", log2l, &MONEL, &NANL, 0}, + {"log2l", log2l, &INFINITYL, &INFINITYL, 0}, +#endif + /* {"fabsl", fabsl, &NANL, &NANL, 0}, */ + {"fabsl", fabsl, &ONEL, &ONEL, 0}, + {"fabsl", fabsl, &MONEL, &ONEL, 0}, + {"fabsl", fabsl, &ZEROL, &ZEROL, 0}, + {"fabsl", fabsl, &NEGZEROL, &ZEROL, 0}, + {"fabsl", fabsl, &INFINITYL, &INFINITYL, 0}, + {"fabsl", fabsl, &MINFL, &INFINITYL, 0}, +#if 0 + {"cbrtl", cbrtl, &NANL, &NANL, 0}, + {"cbrtl", cbrtl, &ZEROL, &ZEROL, 0}, + {"cbrtl", cbrtl, &NEGZEROL, &NEGZEROL, 0}, + {"cbrtl", cbrtl, &INFINITYL, &INFINITYL, 0}, + {"cbrtl", cbrtl, &MINFL, &MINFL, 0}, + {"erfl", erfl, &NANL, &NANL, 0}, + {"erfl", erfl, &ZEROL, &ZEROL, 0}, + {"erfl", erfl, &NEGZEROL, &NEGZEROL, 0}, + {"erfl", erfl, &INFINITYL, &ONEL, 0}, + {"erfl", erfl, &MINFL, &MONEL, 0}, + {"erfcl", erfcl, &NANL, &NANL, 0}, + {"erfcl", erfcl, &INFINITYL, &ZEROL, 0}, + {"erfcl", erfcl, &MINFL, &TWOL, 0}, + {"gammal", gammal, &NANL, &NANL, 0}, + {"gammal", gammal, &INFINITYL, &INFINITYL, 0}, + {"gammal", gammal, &MONEL, &NANL, 0}, + {"gammal", gammal, &ZEROL, &NANL, 0}, + {"gammal", gammal, &MINFL, &NANL, 0}, + {"lgaml", lgaml, &NANL, &NANL, 0}, + {"lgaml", lgaml, &INFINITYL, &INFINITYL, 0}, + {"lgaml", lgaml, &MONEL, &INFINITYL, 0}, + {"lgaml", lgaml, &ZEROL, &INFINITYL, 0}, + {"lgaml", lgaml, &MINFL, &INFINITYL, 0}, + {"ceill", ceill, &NANL, &NANL, 0}, + {"ceill", ceill, &ZEROL, &ZEROL, 0}, + {"ceill", ceill, &NEGZEROL, &NEGZEROL, 0}, + {"ceill", ceill, &INFINITYL, &INFINITYL, 0}, + {"ceill", ceill, &MINFL, &MINFL, 0}, + {"floorl", floorl, &NANL, &NANL, 0}, + {"floorl", floorl, &ZEROL, &ZEROL, 0}, + {"floorl", floorl, &NEGZEROL, &NEGZEROL, 0}, + {"floorl", floorl, &INFINITYL, &INFINITYL, 0}, + {"floorl", floorl, &MINFL, &MINFL, 0}, +#endif + {"null", NULL, &ZEROL, &ZEROL, 0}, +}; + +/* Functions of two variables. */ +long double atan2l (long double, long double); +long double powl (long double, long double); + +struct twoarguments + { + char *name; /* Name of the function. */ + long double (*func) (long double, long double); + long double *arg1; + long double *arg2; + long double *answer; + int thresh; + }; + +static struct twoarguments test2[] = +{ + {"atan2l", atan2l, &ZEROL, &ONEL, &ZEROL, 0}, + {"atan2l", atan2l, &NEGZEROL, &ONEL,&NEGZEROL, 0}, + {"atan2l", atan2l, &ZEROL, &ZEROL, &ZEROL, 0}, + {"atan2l", atan2l, &NEGZEROL, &ZEROL, &NEGZEROL, 0}, + {"atan2l", atan2l, &ZEROL, &MONEL, &PIL, 0}, + {"atan2l", atan2l, &NEGZEROL, &MONEL, &MPIL, 0}, + {"atan2l", atan2l, &ZEROL, &NEGZEROL, &PIL, 0}, + {"atan2l", atan2l, &NEGZEROL, &NEGZEROL, &MPIL, 0}, + {"atan2l", atan2l, &ONEL, &ZEROL, &PIO2L, 0}, + {"atan2l", atan2l, &ONEL, &NEGZEROL, &PIO2L, 0}, + {"atan2l", atan2l, &MONEL, &ZEROL, &MPIO2L, 0}, + {"atan2l", atan2l, &MONEL, &NEGZEROL, &MPIO2L, 0}, + {"atan2l", atan2l, &ONEL, &INFINITYL, &ZEROL, 0}, + {"atan2l", atan2l, &MONEL, &INFINITYL, &NEGZEROL, 0}, + {"atan2l", atan2l, &INFINITYL, &ONEL, &PIO2L, 0}, + {"atan2l", atan2l, &INFINITYL, &MONEL, &PIO2L, 0}, + {"atan2l", atan2l, &MINFL, &ONEL, &MPIO2L, 0}, + {"atan2l", atan2l, &MINFL, &MONEL, &MPIO2L, 0}, + {"atan2l", atan2l, &ONEL, &MINFL, &PIL, 0}, + {"atan2l", atan2l, &MONEL, &MINFL, &MPIL, 0}, + {"atan2l", atan2l, &INFINITYL, &INFINITYL, &PIO4L, 0}, + {"atan2l", atan2l, &MINFL, &INFINITYL, &MPIO4L, 0}, + {"atan2l", atan2l, &INFINITYL, &MINFL, &THPIO4L, 0}, + {"atan2l", atan2l, &MINFL, &MINFL, &MTHPIO4L, 0}, + {"atan2l", atan2l, &ONEL, &ONEL, &PIO4L, 0}, + {"atan2l", atan2l, &NANL, &ONEL, &NANL, 0}, + {"atan2l", atan2l, &ONEL, &NANL, &NANL, 0}, + {"atan2l", atan2l, &NANL, &NANL, &NANL, 0}, +#if 0 + {"powl", powl, &ONEL, &ZEROL, &ONEL, 0}, + {"powl", powl, &ONEL, &NEGZEROL, &ONEL, 0}, + {"powl", powl, &MONEL, &ZEROL, &ONEL, 0}, + {"powl", powl, &MONEL, &NEGZEROL, &ONEL, 0}, + {"powl", powl, &INFINITYL, &ZEROL, &ONEL, 0}, + {"powl", powl, &INFINITYL, &NEGZEROL, &ONEL, 0}, + {"powl", powl, &NANL, &ZEROL, &ONEL, 0}, + {"powl", powl, &NANL, &NEGZEROL, &ONEL, 0}, + {"powl", powl, &TWOL, &INFINITYL, &INFINITYL, 0}, + {"powl", powl, &MTWOL, &INFINITYL, &INFINITYL, 0}, + {"powl", powl, &HALFL, &INFINITYL, &ZEROL, 0}, + {"powl", powl, &MHALFL, &INFINITYL, &ZEROL, 0}, + {"powl", powl, &TWOL, &MINFL, &ZEROL, 0}, + {"powl", powl, &MTWOL, &MINFL, &ZEROL, 0}, + {"powl", powl, &HALFL, &MINFL, &INFINITYL, 0}, + {"powl", powl, &MHALFL, &MINFL, &INFINITYL, 0}, + {"powl", powl, &INFINITYL, &HALFL, &INFINITYL, 0}, + {"powl", powl, &INFINITYL, &TWOL, &INFINITYL, 0}, + {"powl", powl, &INFINITYL, &MHALFL, &ZEROL, 0}, + {"powl", powl, &INFINITYL, &MTWOL, &ZEROL, 0}, + {"powl", powl, &MINFL, &THREEL, &MINFL, 0}, + {"powl", powl, &MINFL, &TWOL, &INFINITYL, 0}, + {"powl", powl, &MINFL, &MTHREEL, &NEGZEROL, 0}, + {"powl", powl, &MINFL, &MTWOL, &ZEROL, 0}, + {"powl", powl, &NANL, &ONEL, &NANL, 0}, + {"powl", powl, &ONEL, &NANL, &NANL, 0}, + {"powl", powl, &NANL, &NANL, &NANL, 0}, + {"powl", powl, &ONEL, &INFINITYL, &NANL, 0}, + {"powl", powl, &MONEL, &INFINITYL, &NANL, 0}, + {"powl", powl, &ONEL, &MINFL, &NANL, 0}, + {"powl", powl, &MONEL, &MINFL, &NANL, 0}, + {"powl", powl, &MTWOL, &HALFL, &NANL, 0}, + {"powl", powl, &ZEROL, &MTHREEL, &INFINITYL, 0}, + {"powl", powl, &NEGZEROL, &MTHREEL, &MINFL, 0}, + {"powl", powl, &ZEROL, &MHALFL, &INFINITYL, 0}, + {"powl", powl, &NEGZEROL, &MHALFL, &INFINITYL, 0}, + {"powl", powl, &ZEROL, &THREEL, &ZEROL, 0}, + {"powl", powl, &NEGZEROL, &THREEL, &NEGZEROL, 0}, + {"powl", powl, &ZEROL, &HALFL, &ZEROL, 0}, + {"powl", powl, &NEGZEROL, &HALFL, &ZEROL, 0}, +#endif + {"null", NULL, &ZEROL, &ZEROL, &ZEROL, 0}, +}; + +/* Integer functions of one variable. */ + +int __isnanl (long double); +int __signbitl (long double); + +struct intans + { + char *name; /* Name of the function. */ + int (*func) (long double); + long double *arg1; + int ianswer; + }; + +static struct intans test3[] = +{ + {"isfinitel", __isfinitel, &ZEROL, 1}, + {"isfinitel", __isfinitel, &INFINITYL, 0}, + {"isfinitel", __isfinitel, &MINFL, 0}, + {"isnanl", __isnanl, &NANL, 1}, + {"isnanl", __isnanl, &INFINITYL, 0}, + {"isnanl", __isnanl, &ZEROL, 0}, + {"isnanl", __isnanl, &NEGZEROL, 0}, + {"signbitl", __signbitl, &NEGZEROL, 1}, + {"signbitl", __signbitl, &MONEL, 1}, + {"signbitl", __signbitl, &ZEROL, 0}, + {"signbitl", __signbitl, &ONEL, 0}, + {"signbitl", __signbitl, &MINFL, 1}, + {"signbitl", __signbitl, &INFINITYL, 0}, + {"null", NULL, &ZEROL, 0}, +}; + +static volatile long double x1; +static volatile long double x2; +static volatile long double y; +static volatile long double answer; + +/* Print bits of a long double. */ +static void pvec (char *str, long double x) +{ + union + { + long double d; + unsigned int i[4]; + } u; + int i; + + u.d = x; + printf ("%s ", str); + for (i = 0; i < 4; i++) + printf ("%08x ", u.i[i]); + printf ("\n"); +} + +int +testvectll () +{ + int i, nerrors, k, ianswer, ntests; + long double (*fun1) (long double); + long double (*fun2) (long double, long double); + int (*fun3) (long double); + long double e; + union + { + long double d; + char c[16]; + } u, v; + + INFINITYL = ONEL/ZEROL; + pvec ("Infinity = ", INFINITYL); + NANL = INFINITYL - INFINITYL; + pvec ("Nan = ", NANL); + NEGZEROL = -ZEROL; + pvec ("-0.0 = ", NEGZEROL); + /* This masks off fpu exceptions on i386. */ + /* setfpu(0x137f); */ + nerrors = 0; + ntests = 0; + MINFL = -INFINITYL; + MPIL = -PIL; + MPIO2L = -PIO2L; + MPIO4L = -PIO4L; + i = 0; + for (;;) + { + fun1 = test1[i].func; + if (fun1 == NULL) + break; + x1 = *(test1[i].arg1); + y = (*(fun1)) (x1); + answer = *(test1[i].answer); + if (test1[i].thresh == 0) + { + v.d = answer; + u.d = y; + if (memcmp(u.c, v.c, 16) != 0) + { + /* O.K. if both are NaNs of some sort. */ + if (__isnanl(v.d) && __isnanl(u.d)) + goto nxttest1; + goto wrongone; + } + else + goto nxttest1; + } + if (y != answer) + { + e = y - answer; + if (answer != 0.0L) + e = e / answer; + if (e < 0) + e = -e; + if (e > test1[i].thresh * MACHEPL) + { +wrongone: + printf ("%s (%.20Le) = %.20Le\n should be %.20Le\n", + test1[i].name, x1, y, answer); + nerrors += 1; + } + } +nxttest1: + ntests += 1; + i += 1; + } + + i = 0; + for (;;) + { + fun2 = test2[i].func; + if (fun2 == NULL) + break; + x1 = *(test2[i].arg1); + x2 = *(test2[i].arg2); + y = (*(fun2)) (x1, x2); + answer = *(test2[i].answer); + if (test2[i].thresh == 0) + { + v.d = answer; + u.d = y; + if (memcmp(u.c, v.c, 16) != 0) + { + /* O.K. if both are NaNs of some sort. */ + if (__isnanl(v.d) && __isnanl(u.d)) + goto nxttest2; + goto wrongtwo; + } + else + goto nxttest2; + } + if (y != answer) + { + e = y - answer; + if (answer != 0.0L) + e = e / answer; + if (e < 0) + e = -e; + if (e > test2[i].thresh * MACHEPL) + { +wrongtwo: + printf ("%s (%.20Le, %.20Le) = %.20Le\n should be %.20Le\n", + test2[i].name, x1, x2, y, answer); + nerrors += 1; + } + } +nxttest2: + ntests += 1; + i += 1; + } + + + i = 0; + for (;;) + { + fun3 = test3[i].func; + if (fun3 == NULL) + break; + x1 = *(test3[i].arg1); + k = (*(fun3)) (x1); + ianswer = test3[i].ianswer; + if (k != ianswer) + { + printf ("%s (%.20Le) = %d\n should be. %d\n", + test3[i].name, x1, k, ianswer); + nerrors += 1; + } + ntests += 1; + i += 1; + } + + printf ("%d errors in %d tests\n", nerrors, ntests); + return (nerrors); +} +#endif /* LDBL_MANT_DIG == 113 */ |