This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Move tests of lgamma from libm-test.inc to auto-libm-test-in
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Thu, 5 Dec 2013 16:51:56 +0000
- Subject: Move tests of lgamma from libm-test.inc to auto-libm-test-in
- Authentication-results: sourceware.org; auth=none
This patch moves tests of lgamma to auto-libm-test-in, adding the
necessary support for this function to gen-auto-libm-tests and
removing M_* macros that are no longer required from libm-test.inc.
Tested x86_64 and x86 and ulps updated accordingly.
(auto-libm-test-out diffs omitted below.)
2013-12-05 Joseph Myers <joseph@codesourcery.com>
* math/auto-libm-test-in: Add tests of lgamma.
* math/auto-libm-test-out: Regenerated.
* math/libm-test.inc (M_LOG_SQRT_PIl): Remove macro.
(M_LOG_2_SQRT_PIl): Likewise.
(lgamma_test_data): Use AUTO_TESTS_f_f1.
* math/gen-auto-libm-tests.c (func_calc_method): Add value
mpfr_f_f1.
(func_calc_desc): Add mpfr_f_f1 union field.
(ARGS1): New macro.
(ARGS2): Likewise.
(ARGS3): Likewise.
(ARGS4): Likewise.
(RET1): Likewise.
(RET2): Likewise.
(CALC): Likewise.
(FUNC): Likewise.
(FUNC_mpfr_f_f): Use new macros FUNC, ARGS1, RET1 and CALC.
(test_functions): Add lgamma.
(calc_generic_results): Handle mpfr_f_f1.
* sysdeps/i386/fpu/libm-test-ulps: Update.
* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index cda7816..8ec0ded 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -282,6 +282,62 @@ j1 0x1p1023
j1 0x1p16382
j1 0x1p16383
+lgamma max
+lgamma 1
+lgamma 3
+lgamma 0.5
+lgamma -0.5
+lgamma 0.7
+lgamma 1.2
+lgamma 0x1p-5
+lgamma -0x1p-5
+lgamma 0x1p-10
+lgamma -0x1p-10
+lgamma 0x1p-15
+lgamma -0x1p-15
+lgamma 0x1p-20
+lgamma -0x1p-20
+lgamma 0x1p-25
+lgamma -0x1p-25
+lgamma 0x1p-30
+lgamma -0x1p-30
+lgamma 0x1p-40
+lgamma -0x1p-40
+lgamma 0x1p-50
+lgamma -0x1p-50
+lgamma 0x1p-60
+lgamma -0x1p-60
+lgamma 0x1p-64
+lgamma -0x1p-64
+lgamma 0x1p-70
+lgamma -0x1p-70
+lgamma 0x1p-100
+lgamma -0x1p-100
+lgamma 0x1p-126
+lgamma -0x1p-126
+lgamma 0x1p-149
+lgamma -0x1p-149
+lgamma 0x1p-200
+lgamma -0x1p-200
+lgamma 0x1p-500
+lgamma -0x1p-500
+lgamma 0x1p-1000
+lgamma -0x1p-1000
+lgamma 0x1p-1022
+lgamma -0x1p-1022
+lgamma 0x1p-1074
+lgamma -0x1p-1074
+lgamma 0x1p-5000
+lgamma -0x1p-5000
+lgamma 0x1p-10000
+lgamma -0x1p-10000
+lgamma 0x1p-16382
+lgamma -0x1p-16382
+lgamma 0x1p-16445
+lgamma -0x1p-16445
+lgamma 0x1p-16494
+lgamma -0x1p-16494
+
log 1
log e
log 1/e
diff --git a/math/gen-auto-libm-tests.c b/math/gen-auto-libm-tests.c
index 5c631e0..87585b9 100644
--- a/math/gen-auto-libm-tests.c
+++ b/math/gen-auto-libm-tests.c
@@ -392,6 +392,9 @@ typedef enum
{
/* MPFR function with a single argument and result. */
mpfr_f_f,
+ /* MPFR function with a single argument and floating-point and
+ integer results. */
+ mpfr_f_f1,
} func_calc_method;
/* Description of how to calculate a function. */
@@ -403,6 +406,7 @@ typedef struct
union
{
int (*mpfr_f_f) (mpfr_t, const mpfr_t, mpfr_rnd_t);
+ int (*mpfr_f_f1) (mpfr_t, int *, const mpfr_t, mpfr_rnd_t);
} func;
} func_calc_desc;
@@ -435,12 +439,22 @@ typedef struct
input_test *tests;
} test_function;
-#define FUNC_mpfr_f_f(NAME, MPFR_FUNC, EXACT) \
- { \
- NAME, 1, { type_fp }, 1, { type_fp }, EXACT, false, \
- { mpfr_f_f, { .mpfr_f_f = MPFR_FUNC } }, 0, 0, NULL \
+#define ARGS1(T1) 1, { T1 }
+#define ARGS2(T1, T2) 2, { T1, T2 }
+#define ARGS3(T1, T2, T3) 3, { T1, T2, T3 }
+#define ARGS4(T1, T2, T3, T4) 4, { T1, T2, T3, T4 }
+#define RET1(T1) 1, { T1 }
+#define RET2(T1, T2) 2, { T1, T2 }
+#define CALC(TYPE, FN) { TYPE, { .TYPE = FN } }
+#define FUNC(NAME, ARGS, RET, EXACT, COMPLEX_FN, CALC) \
+ { \
+ NAME, ARGS, RET, EXACT, COMPLEX_FN, CALC, 0, 0, NULL \
}
+#define FUNC_mpfr_f_f(NAME, MPFR_FUNC, EXACT) \
+ FUNC (NAME, ARGS1 (type_fp), RET1 (type_fp), EXACT, false, \
+ CALC (mpfr_f_f, MPFR_FUNC))
+
/* List of functions handled by this program. */
static test_function test_functions[] =
{
@@ -461,6 +475,8 @@ static test_function test_functions[] =
FUNC_mpfr_f_f ("expm1", mpfr_expm1, false),
FUNC_mpfr_f_f ("j0", mpfr_j0, false),
FUNC_mpfr_f_f ("j1", mpfr_j1, false),
+ FUNC ("lgamma", ARGS1 (type_fp), RET2 (type_fp, type_int), false, false,
+ CALC (mpfr_f_f1, mpfr_lgamma)),
FUNC_mpfr_f_f ("log", mpfr_log, false),
FUNC_mpfr_f_f ("log10", mpfr_log10, false),
FUNC_mpfr_f_f ("log1p", mpfr_log1p, false),
@@ -1250,6 +1266,18 @@ calc_generic_results (generic_value *outputs, generic_value *inputs,
adjust_real (outputs[0].value.f, inexact);
break;
+ case mpfr_f_f1:
+ assert (inputs[0].type == gtype_fp);
+ outputs[0].type = gtype_fp;
+ outputs[1].type = gtype_int;
+ mpfr_init (outputs[0].value.f);
+ int i = 0;
+ inexact = calc->func.mpfr_f_f1 (outputs[0].value.f, &i,
+ inputs[0].value.f, MPFR_RNDZ);
+ adjust_real (outputs[0].value.f, inexact);
+ mpz_init_set_si (outputs[1].value.i, i);
+ break;
+
default:
abort ();
}
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 1d12d91..cb87e3c 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -281,8 +281,6 @@ struct ulp_data
/* Various constants (we must supply them precalculated for accuracy). */
#define M_PI_6l .52359877559829887307710723054658383L
-#define M_LOG_SQRT_PIl 0.57236494292470008707171367567652933L /* log(sqrt(M_PIl)) */
-#define M_LOG_2_SQRT_PIl 1.265512123484645396488945797134706L /* log(2*sqrt(M_PIl)) */
#define M_PI_34l 2.356194490192344928846982537459627163L /* 3*pi/4 */
#define M_PI_34_LOG10El 1.023282265381381010614337719073516828L
#define M_PI2_LOG10El 0.682188176920920673742891812715677885L
@@ -9702,71 +9700,8 @@ static const struct test_f_f1_data lgamma_test_data[] =
TEST_f_f1 (lgamma, -3, plus_infty, IGNORE, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE),
TEST_f_f1 (lgamma, minus_infty, plus_infty, IGNORE),
TEST_f_f1 (lgamma, -max_value, plus_infty, IGNORE, DIVIDE_BY_ZERO_EXCEPTION|ERRNO_ERANGE),
- TEST_f_f1 (lgamma, max_value, plus_infty, 1, OVERFLOW_EXCEPTION|ERRNO_ERANGE),
-
- TEST_f_f1 (lgamma, 1, 0, 1),
-
- TEST_f_f1 (lgamma, 3, M_LN2l, 1),
-
- TEST_f_f1 (lgamma, 0.5, M_LOG_SQRT_PIl, 1),
- TEST_f_f1 (lgamma, -0.5, M_LOG_2_SQRT_PIl, -1),
- TEST_f_f1 (lgamma, 0.7L, 0.260867246531666514385732417016759578L, 1),
- TEST_f_f1 (lgamma, 1.2L, -0.853740900033158497197028392998854470e-1L, 1),
-
- TEST_f_f1 (lgamma, 0x1p-5L, 3.4484891277979584796832693452686366085801e+00L, 1),
- TEST_f_f1 (lgamma, -0x1p-5L, 3.4845895751341394376217526729956836492792e+00L, -1),
- TEST_f_f1 (lgamma, 0x1p-10L, 6.9309089024194618895406190646600805357273e+00L, 1),
- TEST_f_f1 (lgamma, -0x1p-10L, 6.9320362775113082175565786721095494761582e+00L, -1),
- TEST_f_f1 (lgamma, 0x1p-15L, 1.0397190093941001762077888432721419773538e+01L, 1),
- TEST_f_f1 (lgamma, -0x1p-15L, 1.0397225324389321751118257981741350715545e+01L, -1),
- TEST_f_f1 (lgamma, 0x1p-20L, 1.3862943060723899573457963336920089012399e+01L, 1),
- TEST_f_f1 (lgamma, -0x1p-20L, 1.3862944161675408862049886226750366625112e+01L, -1),
- TEST_f_f1 (lgamma, 0x1p-25L, 1.7328679496796266133304874243201700664713e+01L, 1),
- TEST_f_f1 (lgamma, -0x1p-25L, 1.7328679531201000798551671833865469674673e+01L, -1),
- TEST_f_f1 (lgamma, 0x1p-30L, 2.0794415416260785304085859198055798098863e+01L, 1),
- TEST_f_f1 (lgamma, -0x1p-30L, 2.0794415417335933262374820960532606449975e+01L, -1),
- TEST_f_f1 (lgamma, 0x1p-40L, 2.7725887222397287402100277256545578941303e+01L, 1),
- TEST_f_f1 (lgamma, -0x1p-40L, 2.7725887222398337351278293820766115529596e+01L, -1),
- TEST_f_f1 (lgamma, 0x1p-50L, 3.4657359027997264958191108994508978906983e+01L, 1),
- TEST_f_f1 (lgamma, -0x1p-50L, 3.4657359027997265983532103151309975524744e+01L, -1),
- TEST_f_f1 (lgamma, 0x1p-60L, 4.1588830833596718564533272505187468598519e+01L, 1),
- TEST_f_f1 (lgamma, -0x1p-60L, 4.1588830833596718565534582069793719571779e+01L, -1),
- TEST_f_f1 (lgamma, 0x1p-64L, 4.4361419555836499802671564849429355013920e+01L, 1),
- TEST_f_f1 (lgamma, -0x1p-64L, 4.4361419555836499802734146697217245699749e+01L, -1),
- TEST_f_f1 (lgamma, 0x1p-70L, 4.8520302639196171659205759581386516869302e+01L, 1),
- TEST_f_f1 (lgamma, -0x1p-70L, 4.8520302639196171659206737422758202661268e+01L, -1),
- TEST_f_f1 (lgamma, 0x1p-100L, 6.9314718055994530941723212145817201464678e+01L, 1),
- TEST_f_f1 (lgamma, -0x1p-100L, 6.9314718055994530941723212145818112150422e+01L, -1),
- TEST_f_f1 (lgamma, 0x1p-126L, 8.7336544750553108986571247303730247577506e+01L, 1),
- TEST_f_f1 (lgamma, -0x1p-126L, 8.7336544750553108986571247303730247577520e+01L, -1),
- TEST_f_f1 (lgamma, 0x1p-149L, 1.0327892990343185110316758609726830864325e+02L, 1),
- TEST_f_f1 (lgamma, -0x1p-149L, 1.0327892990343185110316758609726830864325e+02L, -1),
-#ifndef TEST_FLOAT
- TEST_f_f1 (lgamma, 0x1p-200L, 1.3862943611198906188344642429163531361510e+02L, 1),
- TEST_f_f1 (lgamma, -0x1p-200L, 1.3862943611198906188344642429163531361510e+02L, -1),
- TEST_f_f1 (lgamma, 0x1p-500L, 3.4657359027997265470861606072908828403775e+02L, 1),
- TEST_f_f1 (lgamma, -0x1p-500L, 3.4657359027997265470861606072908828403775e+02L, -1),
- TEST_f_f1 (lgamma, 0x1p-1000L, 6.9314718055994530941723212145817656807550e+02L, 1),
- TEST_f_f1 (lgamma, -0x1p-1000L, 6.9314718055994530941723212145817656807550e+02L, -1),
- TEST_f_f1 (lgamma, 0x1p-1022L, 7.0839641853226410622441122813025645257316e+02L, 1),
- TEST_f_f1 (lgamma, -0x1p-1022L, 7.0839641853226410622441122813025645257316e+02L, -1),
- TEST_f_f1 (lgamma, 0x1p-1074L, 7.4444007192138126231410729844608163411309e+02L, 1),
- TEST_f_f1 (lgamma, -0x1p-1074L, 7.4444007192138126231410729844608163411309e+02L, -1),
-#endif
-#if defined TEST_LDOUBLE && LDBL_MIN_EXP <= -16381
- TEST_f_f1 (lgamma, 0x1p-5000L, 3.4657359027997265470861606072908828403775e+03L, 1),
- TEST_f_f1 (lgamma, -0x1p-5000L, 3.4657359027997265470861606072908828403775e+03L, -1),
- TEST_f_f1 (lgamma, 0x1p-10000L, 6.9314718055994530941723212145817656807550e+03L, 1),
- TEST_f_f1 (lgamma, -0x1p-10000L, 6.9314718055994530941723212145817656807550e+03L, -1),
- TEST_f_f1 (lgamma, 0x1p-16382L, 1.1355137111933024058873096613727848538213e+04L, 1),
- TEST_f_f1 (lgamma, -0x1p-16382L, 1.1355137111933024058873096613727848538213e+04L, -1),
- TEST_f_f1 (lgamma, 0x1p-16445L, 1.1398805384308300613366382237379713662002e+04L, 1),
- TEST_f_f1 (lgamma, -0x1p-16445L, 1.1398805384308300613366382237379713662002e+04L, -1),
-# if LDBL_MANT_DIG >= 113
- TEST_f_f1 (lgamma, 0x1p-16494L, 1.1432769596155737933527826611331164313837e+04L, 1),
- TEST_f_f1 (lgamma, -0x1p-16494L, 1.1432769596155737933527826611331164313837e+04L, -1),
-# endif
-#endif
+
+ AUTO_TESTS_f_f1 (lgamma, tonearest),
};
static void
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index cf55e13..e599937 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -6129,12 +6129,46 @@ ldouble: 1
Test "gamma (-0x1p-5)":
double: 1
idouble: 1
+Test "gamma (-0x2p-16)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "gamma (-0x4p-12)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "gamma (-0x4p-32)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "gamma (-0x8p-4)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "gamma (-0x8p-8)":
+double: 1
+idouble: 1
Test "gamma (0.7)":
float: 1
ifloat: 1
+Test "gamma (0x1.3333333333334p+0)":
+ildouble: 1
+ldouble: 1
Test "gamma (0x1p-40)":
ildouble: 1
ldouble: 1
+Test "gamma (0xb.333333333333334p-4)":
+ildouble: 1
+ldouble: 1
+Test "gamma (0xb.3333333333338p-4)":
+ildouble: 1
+ldouble: 1
Test "gamma (1.2)":
double: 1
float: 2
@@ -6488,12 +6522,46 @@ ldouble: 1
Test "lgamma (-0x1p-5)":
double: 1
idouble: 1
+Test "lgamma (-0x2p-16)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (-0x4p-12)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (-0x4p-32)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (-0x8p-4)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (-0x8p-8)":
+double: 1
+idouble: 1
Test "lgamma (0.7)":
float: 1
ifloat: 1
+Test "lgamma (0x1.3333333333334p+0)":
+ildouble: 1
+ldouble: 1
Test "lgamma (0x1p-40)":
ildouble: 1
ldouble: 1
+Test "lgamma (0xb.333333333333334p-4)":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0xb.3333333333338p-4)":
+ildouble: 1
+ldouble: 1
Test "lgamma (1.2)":
double: 1
float: 2
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index 7331577..7c2fabd 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -7050,11 +7050,33 @@ ldouble: 1
Test "gamma (-0x1p-5)":
double: 1
idouble: 1
+Test "gamma (-0x2p-16)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "gamma (-0x4p-12)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "gamma (-0x4p-32)":
+ildouble: 1
+ldouble: 1
+Test "gamma (-0x8p-4)":
+ildouble: 1
+ldouble: 1
+Test "gamma (-0x8p-8)":
+double: 1
+idouble: 1
Test "gamma (0.7)":
double: 1
float: 1
idouble: 1
ifloat: 1
+Test "gamma (0x1.3333333333334p+0)":
+ildouble: 1
+ldouble: 1
Test "gamma (0x1p-10)":
float: 1
ifloat: 1
@@ -7064,6 +7086,24 @@ idouble: 1
Test "gamma (0x1p-40)":
ildouble: 1
ldouble: 1
+Test "gamma (0x4p-12)":
+float: 1
+ifloat: 1
+Test "gamma (0x4p-32)":
+double: 1
+idouble: 1
+Test "gamma (0xb.333333333333334p-4)":
+ildouble: 1
+ldouble: 1
+Test "gamma (0xb.3333333333338p-4)":
+ildouble: 1
+ldouble: 1
+Test "gamma (0xb.333333333333p-4)":
+double: 1
+idouble: 1
+Test "gamma (0xb.33333p-4)":
+double: 1
+idouble: 1
Test "gamma (1.2)":
double: 1
float: 2
@@ -7428,11 +7468,33 @@ ldouble: 1
Test "lgamma (-0x1p-5)":
double: 1
idouble: 1
+Test "lgamma (-0x2p-16)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (-0x4p-12)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (-0x4p-32)":
+ildouble: 1
+ldouble: 1
+Test "lgamma (-0x8p-4)":
+ildouble: 1
+ldouble: 1
+Test "lgamma (-0x8p-8)":
+double: 1
+idouble: 1
Test "lgamma (0.7)":
double: 1
float: 1
idouble: 1
ifloat: 1
+Test "lgamma (0x1.3333333333334p+0)":
+ildouble: 1
+ldouble: 1
Test "lgamma (0x1p-10)":
float: 1
ifloat: 1
@@ -7442,6 +7504,24 @@ idouble: 1
Test "lgamma (0x1p-40)":
ildouble: 1
ldouble: 1
+Test "lgamma (0x4p-12)":
+float: 1
+ifloat: 1
+Test "lgamma (0x4p-32)":
+double: 1
+idouble: 1
+Test "lgamma (0xb.333333333333334p-4)":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0xb.3333333333338p-4)":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0xb.333333333333p-4)":
+double: 1
+idouble: 1
+Test "lgamma (0xb.33333p-4)":
+double: 1
+idouble: 1
Test "lgamma (1.2)":
double: 1
float: 2
--
Joseph S. Myers
joseph@codesourcery.com