diff options
author | zimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2011-01-14 13:41:20 +0000 |
---|---|---|
committer | zimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2011-01-14 13:41:20 +0000 |
commit | ae3c1baa7a01a99a98a6115466cbced522127c83 (patch) | |
tree | c7df5833180b20711b2fc27ea6869e6aa732afda /tests/read_data.c | |
parent | 7b728db30ac9e194f257bbd3bb188b9fad9251a0 (diff) | |
download | mpc-ae3c1baa7a01a99a98a6115466cbced522127c83.tar.gz |
added mpc_fma (request from Mickael Gastineau)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@869 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/read_data.c')
-rw-r--r-- | tests/read_data.c | 97 |
1 files changed, 96 insertions, 1 deletions
diff --git a/tests/read_data.c b/tests/read_data.c index 77e74f9..2ae8b6a 100644 --- a/tests/read_data.c +++ b/tests/read_data.c @@ -452,6 +452,25 @@ read_ccc (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected, check_compatible (*inex_im, MPC_IM(expected), MPC_RND_IM(*rnd), "imag"); } +/* read lines of data for function with three mpc_t inputs and one mpc_t + output like mpc_fma */ +static void +read_cccc (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected, + known_signs_t *signs, mpc_ptr op1, mpc_ptr op2, mpc_ptr op3, + mpc_rnd_t *rnd) +{ + test_line_number = line_number; + read_ternary (fp, inex_re); + read_ternary (fp, inex_im); + read_mpc (fp, expected, signs); + read_mpc (fp, op1, NULL); + read_mpc (fp, op2, NULL); + read_mpc (fp, op3, NULL); + read_mpc_rounding_mode (fp, rnd); + check_compatible (*inex_re, MPC_RE(expected), MPC_RND_RE(*rnd), "real"); + check_compatible (*inex_im, MPC_IM(expected), MPC_RND_IM(*rnd), "imag"); +} + static void read_cfc (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected, known_signs_t *signs, mpfr_ptr op1, mpc_ptr op2, mpc_rnd_t *rnd) @@ -510,7 +529,7 @@ data_check (mpc_function function, const char *file_name) int sign_real; int inex_im; - mpc_t z1, z2, z3, z4; + mpc_t z1, z2, z3, z4, z5; mpc_rnd_t rnd = MPC_RNDNN; unsigned long int ui; @@ -537,6 +556,12 @@ data_check (mpc_function function, const char *file_name) mpc_init2 (z3, 2); mpc_init2 (z4, 2); break; + case CCCC: + mpc_init2 (z2, 2); + mpc_init2 (z3, 2); + mpc_init2 (z4, 2); + mpc_init2 (z5, 2); + break; case CFC: case CCF: mpfr_init (x1); mpc_init2 (z2, 2); @@ -669,6 +694,70 @@ data_check (mpc_function function, const char *file_name) } break; + case CCCC: /* example mpc_fma */ + read_cccc (fp, &inex_re, &inex_im, z1, &signs, z2, z3, z4, &rnd); + /* z1 is the expected value, z2, z3, z4 are the inputs, and z5 is + the computed value */ + mpfr_set_prec (MPC_RE(z5), MPC_PREC_RE (z1)); + mpfr_set_prec (MPC_IM(z5), MPC_PREC_IM (z1)); + inex = function.pointer.CCCC (z5, z2, z3, z4, rnd); + if (!MPC_INEX_CMP (inex_re, inex_im, inex) + || !same_mpc_value (z5, z1, signs)) + { + /* display sensible variable names */ + mpc_t op1, op2, op3, got, expected; + op1[0] = z2[0]; + op2[0] = z3[0]; + op3[0] = z4[0]; + expected[0]= z1[0]; + got[0] = z5[0]; + printf ("%s(op) failed (line %lu)\nwith rounding mode %s\n", + function.name, test_line_number, rnd_mode[rnd]); + if (!MPC_INEX_CMP (inex_re, inex_im, inex)) + printf("ternary value: got %s, expected (%s, %s)\n", + MPC_INEX_STR (inex), + MPFR_INEX_STR (inex_re), MPFR_INEX_STR (inex_im)); + MPC_OUT (op1); + MPC_OUT (op2); + MPC_OUT (op3); + printf (" "); + MPC_OUT (got); + MPC_OUT (expected); + + exit (1); + } + if (function.properties & FUNC_PROP_SYMETRIC) + { + inex = function.pointer.CCCC (z5, z3, z2, z4, rnd); + if (!MPC_INEX_CMP (inex_re, inex_im, inex) + || !same_mpc_value (z5, z1, signs)) + { + /* display sensible variable names */ + mpc_t op1, op2, op3, got, expected; + op1[0] = z3[0]; + op2[0] = z2[0]; + op3[0] = z4[0]; + expected[0]= z1[0]; + got[0] = z5[0]; + printf ("%s(op) failed (line %lu/symetric test)\n" + "with rounding mode %s\n", + function.name, test_line_number, rnd_mode[rnd]); + if (!MPC_INEX_CMP (inex_re, inex_im, inex)) + printf("ternary value: got %s, expected (%s, %s)\n", + MPC_INEX_STR (inex), + MPFR_INEX_STR (inex_re), MPFR_INEX_STR (inex_im)); + MPC_OUT (op1); + MPC_OUT (op2); + MPC_OUT (op3); + printf (" "); + MPC_OUT (got); + MPC_OUT (expected); + + exit (1); + } + } + break; + case CFC: /* example mpc_fr_div */ read_cfc (fp, &inex_re, &inex_im, z1, &signs, x1, z2, &rnd); mpfr_set_prec (MPC_RE(z3), MPC_PREC_RE (z1)); @@ -781,6 +870,12 @@ data_check (mpc_function function, const char *file_name) mpc_clear (z3); mpc_clear (z4); break; + case CCCC: + mpc_clear (z2); + mpc_clear (z3); + mpc_clear (z4); + mpc_clear (z5); + break; case CFC: case CCF: mpfr_clear (x1); mpc_clear (z2); |