This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Move tests of cabs and carg from libm-test.inc to auto-libm-test-in


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

Tested x86_64 and x86; no ulps updates needed.

(auto-libm-test-out diffs omitted below.)

2013-12-19  Joseph Myers  <joseph@codesourcery.com>

	* math/auto-libm-test-in: Add tests of cabs and carg.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (cabs_test_data): Use AUTO_TESTS_c_f.
	(carg_test_data): Likewise.
	* math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpc_c_f.
	(func_calc_desc): Add mpc_c_f union field.
	(test_functions): Add cabs and carg.
	(calc_generic_results): Handle mpc_c_f.

diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index 49f6604..383fd01 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -105,6 +105,46 @@ atanh 0
 atanh -0
 atanh 0.75
 
+# cabs (x,y) == cabs (y,x).
+cabs 0.75 12.390625
+# cabs (x,y) == cabs (-x,y).
+cabs -12.390625 0.75
+# cabs (x,y) == cabs (-y,x).
+cabs -0.75 12.390625
+# cabs (x,y) == cabs (-x,-y).
+cabs -12.390625 -0.75
+# cabs (x,y) == cabs (-y,-x).
+cabs -0.75 -12.390625
+# cabs (x,0) == fabs (x).
+cabs -0.75 0
+cabs 0.75 0
+cabs -1.0 0
+cabs 1.0 0
+cabs -5.7e7 0
+cabs 5.7e7 0
+cabs 0.75 1.25
+
+# carg (x + i 0) == 0 for x > 0.
+carg 2.0 0
+# carg (x - i 0) == -0 for x > 0.
+carg 2.0 -0
+carg 0 0
+carg 0 -0
+# carg (x + i 0) == +pi for x < 0.
+carg -2.0 0
+# carg (x - i 0) == -pi for x < 0.
+carg -2.0 -0
+carg -0 0
+carg -0 -0
+# carg (+0 + i y) == pi/2 for y > 0.
+carg 0 2.0
+# carg (-0 + i y) == pi/2 for y > 0.
+carg -0 2.0
+# carg (+0 + i y) == -pi/2 for y < 0.
+carg 0 -2.0
+# carg (-0 + i y) == -pi/2 for y < 0.
+carg -0 -2.0
+
 cbrt 0.0
 cbrt -0
 cbrt -0.001
diff --git a/math/gen-auto-libm-tests.c b/math/gen-auto-libm-tests.c
index 9c8394e..0201b8a 100644
--- a/math/gen-auto-libm-tests.c
+++ b/math/gen-auto-libm-tests.c
@@ -403,6 +403,9 @@ typedef enum
     /* MPFR function with a single argument and two floating-point
        results.  */
     mpfr_f_11,
+    /* MPC function with a single complex argument and one real
+       result.  */
+    mpc_c_f,
   } func_calc_method;
 
 /* Description of how to calculate a function.  */
@@ -418,6 +421,7 @@ typedef struct
     int (*mpfr_f_f1) (mpfr_t, int *, const mpfr_t, mpfr_rnd_t);
     int (*mpfr_if_f) (mpfr_t, long, 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);
   } func;
 } func_calc_desc;
 
@@ -471,6 +475,9 @@ typedef struct
 #define FUNC_mpfr_if_f(NAME, MPFR_FUNC, EXACT)				\
   FUNC (NAME, ARGS2 (type_int, type_fp), RET1 (type_fp), EXACT, false,	\
 	CALC (mpfr_if_f, MPFR_FUNC))
+#define FUNC_mpc_c_f(NAME, MPFR_FUNC, EXACT)				\
+  FUNC (NAME, ARGS2 (type_fp, type_fp), RET1 (type_fp), EXACT, true,	\
+	CALC (mpc_c_f, MPFR_FUNC))
 
 /* List of functions handled by this program.  */
 static test_function test_functions[] =
@@ -482,6 +489,8 @@ static test_function test_functions[] =
     FUNC_mpfr_f_f ("atan", mpfr_atan, false),
     FUNC_mpfr_ff_f ("atan2", mpfr_atan2, false),
     FUNC_mpfr_f_f ("atanh", mpfr_atanh, false),
+    FUNC_mpc_c_f ("cabs", mpc_abs, false),
+    FUNC_mpc_c_f ("carg", mpc_arg, false),
     FUNC_mpfr_f_f ("cbrt", mpfr_cbrt, false),
     FUNC_mpfr_f_f ("cos", mpfr_cos, false),
     FUNC_mpfr_f_f ("cosh", mpfr_cosh, false),
@@ -1379,6 +1388,20 @@ calc_generic_results (generic_value *outputs, generic_value *inputs,
       adjust_real (outputs[1].value.f, (comb_ternary & 0xc) != 0);
       break;
 
+    case mpc_c_f:
+      assert (inputs[0].type == gtype_fp);
+      assert (inputs[1].type == gtype_fp);
+      outputs[0].type = gtype_fp;
+      mpfr_init (outputs[0].value.f);
+      mpc_t ci;
+      mpc_init2 (ci, internal_precision);
+      assert_exact (mpc_set_fr_fr (ci, inputs[0].value.f, inputs[1].value.f,
+				   MPC_RNDNN));
+      inexact = calc->func.mpc_c_f (outputs[0].value.f, ci, MPFR_RNDZ);
+      adjust_real (outputs[0].value.f, inexact);
+      mpc_clear (ci);
+      break;
+
     default:
       abort ();
     }
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 7ee4b82..c23696a 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -1917,25 +1917,7 @@ static const struct test_c_f_data cabs_test_data[] =
 
     TEST_c_f (cabs, qnan_value, qnan_value, qnan_value),
 
-    /* cabs (x,y) == cabs (y,x).  */
-    TEST_c_f (cabs, 0.75L, 12.390625L, 12.4133028598606664302388810868156657L),
-    /* cabs (x,y) == cabs (-x,y).  */
-    TEST_c_f (cabs, -12.390625L, 0.75L, 12.4133028598606664302388810868156657L),
-    /* cabs (x,y) == cabs (-y,x).  */
-    TEST_c_f (cabs, -0.75L, 12.390625L, 12.4133028598606664302388810868156657L),
-    /* cabs (x,y) == cabs (-x,-y).  */
-    TEST_c_f (cabs, -12.390625L, -0.75L, 12.4133028598606664302388810868156657L),
-    /* cabs (x,y) == cabs (-y,-x).  */
-    TEST_c_f (cabs, -0.75L, -12.390625L, 12.4133028598606664302388810868156657L),
-    /* cabs (x,0) == fabs (x).  */
-    TEST_c_f (cabs, -0.75L, 0, 0.75L),
-    TEST_c_f (cabs, 0.75L, 0, 0.75L),
-    TEST_c_f (cabs, -1.0L, 0, 1.0L),
-    TEST_c_f (cabs, 1.0L, 0, 1.0L),
-    TEST_c_f (cabs, -5.7e7L, 0, 5.7e7L),
-    TEST_c_f (cabs, 5.7e7L, 0, 5.7e7L),
-
-    TEST_c_f (cabs, 0.75L, 1.25L, 1.45773797371132511771853821938639577L),
+    AUTO_TESTS_c_f (cabs, tonearest),
   };
 
 static void
@@ -3326,35 +3308,6 @@ static const struct test_c_f_data carg_test_data[] =
   {
     /* carg (x + iy) is specified as atan2 (y, x) */
 
-    /* carg (x + i 0) == 0 for x > 0.  */
-    TEST_c_f (carg, 2.0, 0, 0),
-    /* carg (x - i 0) == -0 for x > 0.  */
-    TEST_c_f (carg, 2.0, minus_zero, minus_zero),
-
-    TEST_c_f (carg, 0, 0, 0),
-    TEST_c_f (carg, 0, minus_zero, minus_zero),
-
-    /* carg (x + i 0) == +pi for x < 0.  */
-    TEST_c_f (carg, -2.0, 0, M_PIl),
-
-    /* carg (x - i 0) == -pi for x < 0.  */
-    TEST_c_f (carg, -2.0, minus_zero, -M_PIl),
-
-    TEST_c_f (carg, minus_zero, 0, M_PIl),
-    TEST_c_f (carg, minus_zero, minus_zero, -M_PIl),
-
-    /* carg (+0 + i y) == pi/2 for y > 0.  */
-    TEST_c_f (carg, 0, 2.0, M_PI_2l),
-
-    /* carg (-0 + i y) == pi/2 for y > 0.  */
-    TEST_c_f (carg, minus_zero, 2.0, M_PI_2l),
-
-    /* carg (+0 + i y) == -pi/2 for y < 0.  */
-    TEST_c_f (carg, 0, -2.0, -M_PI_2l),
-
-    /* carg (-0 + i y) == -pi/2 for y < 0.  */
-    TEST_c_f (carg, minus_zero, -2.0, -M_PI_2l),
-
     /* carg (inf + i y) == +0 for finite y > 0.  */
     TEST_c_f (carg, plus_infty, 2.0, 0),
 
@@ -3382,6 +3335,8 @@ static const struct test_c_f_data carg_test_data[] =
     TEST_c_f (carg, minus_infty, minus_infty, -M_PI_34l),
 
     TEST_c_f (carg, qnan_value, qnan_value, qnan_value),
+
+    AUTO_TESTS_c_f (carg, tonearest),
   };
 
 static void

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]