1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-09-01 05:02:03 +03:00

Move tests of cpow from libm-test.inc to auto-libm-test-in.

This patch moves tests of cpow to auto-libm-test-in, adding the
required support to gen-auto-libm-tests.

Tested x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of cpow.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (cpow_test_data): Use AUTO_TESTS_cc_c.
	* * math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpc_cc_c.
	(func_calc_desc): Add mpc_cc_c union field.
	(test_functions): Add cpow.
	(special_fill_2pi): New function.
	(special_real_inputs): Add 2pi.
	(calc_generic_results): Handle mpc_cc_c.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
This commit is contained in:
Joseph Myers
2013-12-20 12:35:10 +00:00
parent 7fda568229
commit b7867a3bfb
7 changed files with 1372 additions and 22 deletions

View File

@@ -1,5 +1,18 @@
2013-12-20 Joseph Myers <joseph@codesourcery.com> 2013-12-20 Joseph Myers <joseph@codesourcery.com>
* math/auto-libm-test-in: Add tests of cpow.
* math/auto-libm-test-out: Regenerated.
* math/libm-test.inc (cpow_test_data): Use AUTO_TESTS_cc_c.
* * math/gen-auto-libm-tests.c (func_calc_method): Add value
mpc_cc_c.
(func_calc_desc): Add mpc_cc_c union field.
(test_functions): Add cpow.
(special_fill_2pi): New function.
(special_real_inputs): Add 2pi.
(calc_generic_results): Handle mpc_cc_c.
* sysdeps/i386/fpu/libm-test-ulps: Update.
* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
* math/auto-libm-test-in: Add tests of ccos, ccosh, cexp, clog, * math/auto-libm-test-in: Add tests of ccos, ccosh, cexp, clog,
csqrt, ctan and ctanh. csqrt, ctan and ctanh.
* math/auto-libm-test-out: Regenerated. * math/auto-libm-test-out: Regenerated.

View File

@@ -412,6 +412,17 @@ cosh 22
cosh 23 cosh 23
cosh 24 cosh 24
cpow 1 0 0 0
cpow 2 0 10 0
# Bug 14473: cpow results inaccurate.
cpow e 0 0 2pi xfail
cpow 2 3 4 0
cpow 0.75 1.25 0.75 1.25
cpow 0.75 1.25 1.0 1.0
cpow 0.75 1.25 1.0 0.0
cpow 0.75 1.25 0.0 1.0
csqrt 0 0 csqrt 0 0
csqrt 0 -0 csqrt 0 -0
csqrt -0 0 csqrt -0 0

File diff suppressed because it is too large Load Diff

View File

@@ -409,6 +409,9 @@ typedef enum
/* MPC function with a single complex argument and one complex /* MPC function with a single complex argument and one complex
result. */ result. */
mpc_c_c, mpc_c_c,
/* MPC function with two complex arguments and one complex
result. */
mpc_cc_c,
} func_calc_method; } func_calc_method;
/* Description of how to calculate a function. */ /* Description of how to calculate a function. */
@@ -426,6 +429,7 @@ typedef struct
int (*mpfr_f_11) (mpfr_t, mpfr_t, const mpfr_t, mpfr_rnd_t); int (*mpfr_f_11) (mpfr_t, mpfr_t, const mpfr_t, mpfr_rnd_t);
int (*mpc_c_f) (mpfr_t, const mpc_t, mpfr_rnd_t); int (*mpc_c_f) (mpfr_t, const mpc_t, mpfr_rnd_t);
int (*mpc_c_c) (mpc_t, const mpc_t, mpc_rnd_t); int (*mpc_c_c) (mpc_t, const mpc_t, mpc_rnd_t);
int (*mpc_cc_c) (mpc_t, const mpc_t, const mpc_t, mpc_rnd_t);
} func; } func;
} func_calc_desc; } func_calc_desc;
@@ -512,6 +516,8 @@ static test_function test_functions[] =
FUNC_mpc_c_c ("clog10", mpc_log10, false), FUNC_mpc_c_c ("clog10", mpc_log10, false),
FUNC_mpfr_f_f ("cos", mpfr_cos, false), FUNC_mpfr_f_f ("cos", mpfr_cos, false),
FUNC_mpfr_f_f ("cosh", mpfr_cosh, false), FUNC_mpfr_f_f ("cosh", mpfr_cosh, false),
FUNC ("cpow", ARGS4 (type_fp, type_fp, type_fp, type_fp),
RET2 (type_fp, type_fp), false, true, CALC (mpc_cc_c, mpc_pow)),
FUNC_mpc_c_c ("csin", mpc_sin, false), FUNC_mpc_c_c ("csin", mpc_sin, false),
FUNC_mpc_c_c ("csinh", mpc_sinh, false), FUNC_mpc_c_c ("csinh", mpc_sinh, false),
FUNC_mpc_c_c ("csqrt", mpc_sqrt, false), FUNC_mpc_c_c ("csqrt", mpc_sqrt, false),
@@ -876,6 +882,18 @@ special_fill_2pi_3 (mpfr_t res0, mpfr_t res1, fp_format format)
return 2; return 2;
} }
static size_t
special_fill_2pi (mpfr_t res0, mpfr_t res1, fp_format format)
{
mpfr_init2 (res0, fp_formats[format].mant_dig);
mpfr_const_pi (res0, MPFR_RNDU);
assert_exact (mpfr_mul_ui (res0, res0, 2, MPFR_RNDN));
mpfr_init2 (res1, fp_formats[format].mant_dig);
mpfr_const_pi (res1, MPFR_RNDD);
assert_exact (mpfr_mul_ui (res1, res1, 2, MPFR_RNDN));
return 2;
}
static size_t static size_t
special_fill_e (mpfr_t res0, mpfr_t res1, fp_format format) special_fill_e (mpfr_t res0, mpfr_t res1, fp_format format)
{ {
@@ -943,6 +961,7 @@ static const special_real_input special_real_inputs[] =
{ "-pi/6", special_fill_minus_pi_6 }, { "-pi/6", special_fill_minus_pi_6 },
{ "pi/3", special_fill_pi_3 }, { "pi/3", special_fill_pi_3 },
{ "2pi/3", special_fill_2pi_3 }, { "2pi/3", special_fill_2pi_3 },
{ "2pi", special_fill_2pi },
{ "e", special_fill_e }, { "e", special_fill_e },
{ "1/e", special_fill_1_e }, { "1/e", special_fill_1_e },
{ "e-1", special_fill_e_minus_1 }, { "e-1", special_fill_e_minus_1 },
@@ -1364,6 +1383,9 @@ calc_generic_results (generic_value *outputs, generic_value *inputs,
const func_calc_desc *calc) const func_calc_desc *calc)
{ {
bool inexact; bool inexact;
int mpc_ternary;
mpc_t ci1, ci2, co;
switch (calc->method) switch (calc->method)
{ {
case mpfr_f_f: case mpfr_f_f:
@@ -1428,13 +1450,12 @@ calc_generic_results (generic_value *outputs, generic_value *inputs,
assert (inputs[1].type == gtype_fp); assert (inputs[1].type == gtype_fp);
outputs[0].type = gtype_fp; outputs[0].type = gtype_fp;
mpfr_init (outputs[0].value.f); mpfr_init (outputs[0].value.f);
mpc_t ci; mpc_init2 (ci1, internal_precision);
mpc_init2 (ci, internal_precision); assert_exact (mpc_set_fr_fr (ci1, inputs[0].value.f, inputs[1].value.f,
assert_exact (mpc_set_fr_fr (ci, inputs[0].value.f, inputs[1].value.f,
MPC_RNDNN)); MPC_RNDNN));
inexact = calc->func.mpc_c_f (outputs[0].value.f, ci, MPFR_RNDZ); inexact = calc->func.mpc_c_f (outputs[0].value.f, ci1, MPFR_RNDZ);
adjust_real (outputs[0].value.f, inexact); adjust_real (outputs[0].value.f, inexact);
mpc_clear (ci); mpc_clear (ci1);
break; break;
case mpc_c_c: case mpc_c_c:
@@ -1444,19 +1465,46 @@ calc_generic_results (generic_value *outputs, generic_value *inputs,
mpfr_init (outputs[0].value.f); mpfr_init (outputs[0].value.f);
outputs[1].type = gtype_fp; outputs[1].type = gtype_fp;
mpfr_init (outputs[1].value.f); mpfr_init (outputs[1].value.f);
mpc_t co; mpc_init2 (ci1, internal_precision);
mpc_init2 (ci, internal_precision);
mpc_init2 (co, internal_precision); mpc_init2 (co, internal_precision);
assert_exact (mpc_set_fr_fr (ci, inputs[0].value.f, inputs[1].value.f, assert_exact (mpc_set_fr_fr (ci1, inputs[0].value.f, inputs[1].value.f,
MPC_RNDNN)); MPC_RNDNN));
int mpc_ternary = calc->func.mpc_c_c (co, ci, MPC_RNDZZ); mpc_ternary = calc->func.mpc_c_c (co, ci1, MPC_RNDZZ);
assert_exact (mpfr_set (outputs[0].value.f, mpc_realref (co), assert_exact (mpfr_set (outputs[0].value.f, mpc_realref (co),
MPFR_RNDN)); MPFR_RNDN));
assert_exact (mpfr_set (outputs[1].value.f, mpc_imagref (co), assert_exact (mpfr_set (outputs[1].value.f, mpc_imagref (co),
MPFR_RNDN)); MPFR_RNDN));
adjust_real (outputs[0].value.f, MPC_INEX_RE (mpc_ternary)); adjust_real (outputs[0].value.f, MPC_INEX_RE (mpc_ternary));
adjust_real (outputs[1].value.f, MPC_INEX_IM (mpc_ternary)); adjust_real (outputs[1].value.f, MPC_INEX_IM (mpc_ternary));
mpc_clear (ci); mpc_clear (ci1);
mpc_clear (co);
break;
case mpc_cc_c:
assert (inputs[0].type == gtype_fp);
assert (inputs[1].type == gtype_fp);
assert (inputs[2].type == gtype_fp);
assert (inputs[3].type == gtype_fp);
outputs[0].type = gtype_fp;
mpfr_init (outputs[0].value.f);
outputs[1].type = gtype_fp;
mpfr_init (outputs[1].value.f);
mpc_init2 (ci1, internal_precision);
mpc_init2 (ci2, internal_precision);
mpc_init2 (co, internal_precision);
assert_exact (mpc_set_fr_fr (ci1, inputs[0].value.f, inputs[1].value.f,
MPC_RNDNN));
assert_exact (mpc_set_fr_fr (ci2, inputs[2].value.f, inputs[3].value.f,
MPC_RNDNN));
mpc_ternary = calc->func.mpc_cc_c (co, ci1, ci2, MPC_RNDZZ);
assert_exact (mpfr_set (outputs[0].value.f, mpc_realref (co),
MPFR_RNDN));
assert_exact (mpfr_set (outputs[1].value.f, mpc_imagref (co),
MPFR_RNDN));
adjust_real (outputs[0].value.f, MPC_INEX_RE (mpc_ternary));
adjust_real (outputs[1].value.f, MPC_INEX_IM (mpc_ternary));
mpc_clear (ci1);
mpc_clear (ci2);
mpc_clear (co); mpc_clear (co);
break; break;

View File

@@ -6564,20 +6564,9 @@ cosh_test_upward (void)
static const struct test_cc_c_data cpow_test_data[] = static const struct test_cc_c_data cpow_test_data[] =
{ {
TEST_cc_c (cpow, 1, 0, 0, 0, 1.0, 0.0),
TEST_cc_c (cpow, 2, 0, 10, 0, 1024.0, 0.0),
#if 0
/* Disabled until we fix bug 14473. */
TEST_cc_c (cpow, M_El, 0, 0, 2 * M_PIl, 1.0, 0.0),
#endif
TEST_cc_c (cpow, 2, 3, 4, 0, -119.0, -120.0),
TEST_cc_c (cpow, qnan_value, qnan_value, qnan_value, qnan_value, qnan_value, qnan_value), TEST_cc_c (cpow, qnan_value, qnan_value, qnan_value, qnan_value, qnan_value, qnan_value),
TEST_cc_c (cpow, 0.75L, 1.25L, 0.75L, 1.25L, 0.117506293914473555420279832210420483L, 0.346552747708338676483025352060418001L), AUTO_TESTS_cc_c (cpow, tonearest),
TEST_cc_c (cpow, 0.75L, 1.25L, 1.0L, 1.0L, 0.0846958290317209430433805274189191353L, 0.513285749182902449043287190519090481L),
TEST_cc_c (cpow, 0.75L, 1.25L, 1.0L, 0.0L, 0.75L, 1.25L),
TEST_cc_c (cpow, 0.75L, 1.25L, 0.0L, 1.0L, 0.331825439177608832276067945276730566L, 0.131338600281188544930936345230903032L),
}; };
static void static void

View File

@@ -6886,6 +6886,55 @@ ldouble: 3
Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i)": Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i)":
double: 1 double: 1
idouble: 1 idouble: 1
Test "Real part of: cpow (0x2p+0 + +0 i, 0xap+0 + +0 i)":
ildouble: 1
ldouble: 1
Test "Real part of: cpow (0x2p+0 + 0x3p+0 i, 0x4p+0 + +0 i)":
double: 1
float: 5
idouble: 1
ifloat: 5
ildouble: 1
ldouble: 1
Test "Imaginary part of: cpow (0x2p+0 + 0x3p+0 i, 0x4p+0 + +0 i)":
float: 1
ifloat: 1
ildouble: 4
ldouble: 4
Test "Real part of: cpow (0xcp-4 + 0x1.4p+0 i, +0 + 0x1p+0 i)":
float: 1
ifloat: 1
ildouble: 1
ldouble: 1
Test "Real part of: cpow (0xcp-4 + 0x1.4p+0 i, 0x1p+0 + +0 i)":
double: 1
float: 1
idouble: 1
ifloat: 1
ildouble: 1
ldouble: 1
Test "Real part of: cpow (0xcp-4 + 0x1.4p+0 i, 0x1p+0 + 0x1p+0 i)":
double: 2
float: 4
idouble: 2
ifloat: 4
ildouble: 3
ldouble: 3
Test "Imaginary part of: cpow (0xcp-4 + 0x1.4p+0 i, 0x1p+0 + 0x1p+0 i)":
double: 1
idouble: 1
Test "Real part of: cpow (0xcp-4 + 0x1.4p+0 i, 0xcp-4 + 0x1.4p+0 i)":
double: 1
float: 3
idouble: 1
ifloat: 3
ildouble: 1
ldouble: 1
Test "Imaginary part of: cpow (0xcp-4 + 0x1.4p+0 i, 0xcp-4 + 0x1.4p+0 i)":
float: 1
ifloat: 1
ildouble: 2
ldouble: 2
Test "Real part of: cpow (2 + 0 i, 10 + 0 i)": Test "Real part of: cpow (2 + 0 i, 10 + 0 i)":
ildouble: 1 ildouble: 1
ldouble: 1 ldouble: 1

View File

@@ -7759,6 +7759,46 @@ idouble: 2
ifloat: 3 ifloat: 3
ildouble: 3 ildouble: 3
ldouble: 3 ldouble: 3
Test "Real part of: cpow (0x2p+0 + +0 i, 0xap+0 + +0 i)":
ildouble: 1
ldouble: 1
Test "Real part of: cpow (0x2p+0 + 0x3p+0 i, 0x4p+0 + +0 i)":
double: 1
float: 5
idouble: 1
ifloat: 5
ildouble: 1
ldouble: 1
Test "Imaginary part of: cpow (0x2p+0 + 0x3p+0 i, 0x4p+0 + +0 i)":
float: 2
ifloat: 2
ildouble: 4
ldouble: 4
Test "Real part of: cpow (0xcp-4 + 0x1.4p+0 i, +0 + 0x1p+0 i)":
float: 1
ifloat: 1
ildouble: 1
ldouble: 1
Test "Real part of: cpow (0xcp-4 + 0x1.4p+0 i, 0x1p+0 + +0 i)":
ildouble: 1
ldouble: 1
Test "Real part of: cpow (0xcp-4 + 0x1.4p+0 i, 0x1p+0 + 0x1p+0 i)":
double: 2
float: 3
idouble: 2
ifloat: 3
ildouble: 3
ldouble: 3
Test "Real part of: cpow (0xcp-4 + 0x1.4p+0 i, 0xcp-4 + 0x1.4p+0 i)":
double: 1
float: 4
idouble: 1
ifloat: 4
ildouble: 1
ldouble: 1
Test "Imaginary part of: cpow (0xcp-4 + 0x1.4p+0 i, 0xcp-4 + 0x1.4p+0 i)":
ildouble: 2
ldouble: 2
Test "Real part of: cpow (2 + 0 i, 10 + 0 i)": Test "Real part of: cpow (2 + 0 i, 10 + 0 i)":
ildouble: 1 ildouble: 1
ldouble: 1 ldouble: 1