diff options
-rw-r--r-- | tests/Makefile.am | 13 | ||||
-rw-r--r-- | tests/neg.dsc | 28 | ||||
-rw-r--r-- | tests/norm.dsc | 29 | ||||
-rw-r--r-- | tests/proj.dsc | 28 | ||||
-rw-r--r-- | tests/sub_fr.dsc | 30 | ||||
-rw-r--r-- | tests/tneg_tmpl.c | 43 | ||||
-rw-r--r-- | tests/tnorm_tmpl.c | 117 | ||||
-rw-r--r-- | tests/tproj_tmpl.c | 45 | ||||
-rw-r--r-- | tests/tsub_fr_tmpl.c | 45 |
9 files changed, 372 insertions, 6 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 2055e58..bee7180 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -31,9 +31,10 @@ LOADLIBES=$(DEFS) -I$(top_srcdir)/src -I$(top_builddir) $(CPPFLAGS) \ TEMPLATED = tabs_tmpl tacos_tmpl tacosh_tmpl tadd_tmpl tadd_fr_tmpl \ targ_tmpl tasin_tmpl tasinh_tmpl tatan_tmpl tatanh_tmpl tconj_tmpl \ tcos_tmpl tcosh_tmpl tdiv_tmpl tdiv_tmpl texp_tmpl tfma_tmpl \ - tfr_div_tmpl tfr_sub_tmpl tlog_tmpl tlog10_tmpl tmul_tmpl \ - tmul_fr_tmpl tpow_tmpl tpow_fr_tmpl tpow_si_tmpl tpow_ui_tmpl \ - tpow_z_tmpl tsin_tmpl tsinh_tmpl tsub_tmpl ttan_tmpl ttanh_tmpl + tfr_div_tmpl tfr_sub_tmpl tlog_tmpl tlog10_tmpl tneg_tmpl tnorm_tmpl \ + tmul_tmpl tmul_fr_tmpl tpow_tmpl tpow_fr_tmpl tpow_si_tmpl \ + tpow_ui_tmpl tpow_z_tmpl tproj_tmpl tsin_tmpl tsinh_tmpl tsub_tmpl \ + tsub_fr_tmpl ttan_tmpl ttanh_tmpl check_PROGRAMS = tabs tacos tacosh tadd tadd_fr tadd_si tadd_ui targ \ tasin tasinh tatan tatanh tconj tcos tcosh tdiv tdiv_2si tdiv_2ui \ tdiv_fr tdiv_ui texp tfma tfr_div tfr_sub timag tio_str tlog tlog10 \ @@ -52,9 +53,9 @@ libmpc_tests_la_SOURCES=mpc-tests.h random.c tgeneric.c read_data.c \ TEMPLATES = data_check.tpl abs.dsc acos.dsc acosh.dsc asin.dsc \ asinh.dsc atan.dsc atanh.dsc add.dsc add_fr.dsc add_si.dsc add_ui.dsc \ arg.dsc conj.dsc cos.dsc cosh.dsc div.dsc div_fr.dsc exp.dsc fma.dsc \ - fr_div.dsc fr_sub.dsc log.dsc log10.dsc mul.dsc mul_fr.dsc pow.dsc \ - pow_fr.dsc pow_si.dsc pow_ui.dsc pow_z.dsc sin.dsc sinh.dsc sub.dsc \ - tan.dsc tanh.dsc + fr_div.dsc fr_sub.dsc log.dsc log10.dsc mul.dsc mul_fr.dsc neg.dsc \ + norm.dsc pow.dsc pow_fr.dsc pow_si.dsc pow_ui.dsc pow_z.dsc proj.dsc \ + sin.dsc sinh.dsc sub.dsc sub_fr.dsc tan.dsc tanh.dsc DATA_SETS = abs.dat acos.dat acosh.dat asin.dat asinh.dat atan.dat \ atanh.dat add.dat add_fr.dat arg.dat conj.dat cos.dat cosh.dat \ div.dat div_fr.dat exp.dat fma.dat fr_div.dat fr_sub.dat \ diff --git a/tests/neg.dsc b/tests/neg.dsc new file mode 100644 index 0000000..f7cdae1 --- /dev/null +++ b/tests/neg.dsc @@ -0,0 +1,28 @@ +# Description file for mpc_neg +# +# Copyright (C) 2013 INRIA +# +# This file is part of GNU MPC. +# +# GNU MPC is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at your +#o ption) any later version. +# +# GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for +# more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see http://www.gnu.org/licenses/ . +# +NAME: + mpc_neg +RETURN: + mpc_inex +OUTPUT: + mpc_ptr +INPUT: + mpc_srcptr + mpc_rnd_t diff --git a/tests/norm.dsc b/tests/norm.dsc new file mode 100644 index 0000000..373a8d3 --- /dev/null +++ b/tests/norm.dsc @@ -0,0 +1,29 @@ +# Description file for mpc_norm +# +# Copyright (C) 2013 INRIA +# +# This file is part of GNU MPC. +# +# GNU MPC is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at your +#o ption) any later version. +# +# GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for +# more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see http://www.gnu.org/licenses/ . +# +# Description file of the function +NAME: + mpc_norm +RETURN: + mpfr_inex +OUTPUT: + mpfr_ptr +INPUT: + mpc_srcptr + mpfr_rnd_t diff --git a/tests/proj.dsc b/tests/proj.dsc new file mode 100644 index 0000000..d9b45f3 --- /dev/null +++ b/tests/proj.dsc @@ -0,0 +1,28 @@ +# Description file for mpc_proj +# +# Copyright (C) 2013 INRIA +# +# This file is part of GNU MPC. +# +# GNU MPC is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at your +#o ption) any later version. +# +# GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for +# more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see http://www.gnu.org/licenses/ . +# +NAME: + mpc_proj +RETURN: + mpc_inex +OUTPUT: + mpc_ptr +INPUT: + mpc_srcptr + mpc_rnd_t diff --git a/tests/sub_fr.dsc b/tests/sub_fr.dsc new file mode 100644 index 0000000..2e95113 --- /dev/null +++ b/tests/sub_fr.dsc @@ -0,0 +1,30 @@ +# Description file for mpc_sub_fr +# +# Copyright (C) 2008, 2010, 2011, 2012, INRIA +# +# This file is part of GNU MPC. +# +# GNU MPC is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at your +#o ption) any later version. +# +# GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for +# more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see http://www.gnu.org/licenses/ . +# +# Description file of the function +NAME: + mpc_sub_fr +RETURN: + mpc_inex +OUTPUT: + mpc_ptr +INPUT: + mpc_srcptr + mpfr_srcptr + mpc_rnd_t diff --git a/tests/tneg_tmpl.c b/tests/tneg_tmpl.c new file mode 100644 index 0000000..833d678 --- /dev/null +++ b/tests/tneg_tmpl.c @@ -0,0 +1,43 @@ +/* tneg_tmpl -- templated test file for mpc_neg. + +Copyright (C) 2008, 2013 INRIA + +This file is part of GNU MPC. + +GNU MPC is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for +more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see http://www.gnu.org/licenses/ . +*/ + +#include "templates.h" +#include "mpc-tests.h" + +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_neg (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_neg (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" + +int +main (void) +{ + DECL_FUNC (CC, f, mpc_neg); + test_start (); + + data_check_template ("neg.dsc", "neg.dat"); + tgeneric (f, 2, 1024, 1, 0); + + test_end (); + + return 0; +} diff --git a/tests/tnorm_tmpl.c b/tests/tnorm_tmpl.c new file mode 100644 index 0000000..950f87e --- /dev/null +++ b/tests/tnorm_tmpl.c @@ -0,0 +1,117 @@ +/* tnorm_tmpl -- templated test file for mpc_norm. + +Copyright (C) 2008, 2011, 2012, 2013 INRIA + +This file is part of GNU MPC. + +GNU MPC is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for +more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see http://www.gnu.org/licenses/ . +*/ + + +#include "templates.h" +#include "mpc-tests.h" + +#define MPC_FUNCTION_CALL \ + P[0].mpfr_inex = mpc_norm (P[1].mpfr, P[2].mpc, P[3].mpfr_rnd) + +#include "data_check.tpl" + +static void +test_underflow (void) +{ + mpfr_exp_t emin = mpfr_get_emin (); + mpc_t z; + mpfr_t f; + int inex; + + mpfr_set_emin (-1); /* smallest positive number is 0.5*2^emin = 0.25 */ + mpc_init2 (z, 10); + mpfr_set_ui_2exp (mpc_realref (z), 1023, -11, MPFR_RNDN); /* exact */ + mpfr_set_ui_2exp (mpc_imagref (z), 1023, -11, MPFR_RNDN); /* exact */ + mpfr_init2 (f, 10); + + inex = mpc_norm (f, z, MPFR_RNDZ); /* should give 511/1024 */ + if (inex >= 0) + { + printf ("Error in underflow case (1)\n"); + printf ("expected inex < 0, got %d\n", inex); + exit (1); + } + if (mpfr_cmp_ui_2exp (f, 511, -10) != 0) + { + printf ("Error in underflow case (1)\n"); + printf ("got "); + mpfr_dump (f); + printf ("expected "); + mpfr_set_ui_2exp (f, 511, -10, MPFR_RNDZ); + mpfr_dump (f); + exit (1); + } + + inex = mpc_norm (f, z, MPFR_RNDN); /* should give 511/1024 */ + if (inex >= 0) + { + printf ("Error in underflow case (2)\n"); + printf ("expected inex < 0, got %d\n", inex); + exit (1); + } + if (mpfr_cmp_ui_2exp (f, 511, -10) != 0) + { + printf ("Error in underflow case (2)\n"); + printf ("got "); + mpfr_dump (f); + printf ("expected "); + mpfr_set_ui_2exp (f, 511, -10, MPFR_RNDZ); + mpfr_dump (f); + exit (1); + } + + inex = mpc_norm (f, z, MPFR_RNDU); /* should give 1023/2048 */ + if (inex <= 0) + { + printf ("Error in underflow case (3)\n"); + printf ("expected inex > 0, got %d\n", inex); + exit (1); + } + if (mpfr_cmp_ui_2exp (f, 1023, -11) != 0) + { + printf ("Error in underflow case (3)\n"); + printf ("got "); + mpfr_dump (f); + printf ("expected "); + mpfr_set_ui_2exp (f, 1023, -11, MPFR_RNDZ); + mpfr_dump (f); + exit (1); + } + + mpc_clear (z); + mpfr_clear (f); + mpfr_set_emin (emin); +} + +int +main (void) +{ + DECL_FUNC (FC, f, mpc_norm); + + test_start (); + + data_check_template ("norm.dsc", "norm.dat"); + tgeneric (f, 2, 1024, 1, 4096); + test_underflow (); + + test_end (); + + return 0; +} diff --git a/tests/tproj_tmpl.c b/tests/tproj_tmpl.c new file mode 100644 index 0000000..e7825ab --- /dev/null +++ b/tests/tproj_tmpl.c @@ -0,0 +1,45 @@ +/* tproj_tmpl -- templated test file for mpc_proj. + +Copyright (C) 2008, 2013 INRIA + +This file is part of GNU MPC. + +GNU MPC is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for +more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see http://www.gnu.org/licenses/ . +*/ + +#include "templates.h" +#include "mpc-tests.h" + +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_proj (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_proj (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" + +int +main (void) +{ + DECL_FUNC (CC, f, mpc_proj); + + test_start (); + + data_check_template ("proj.dsc", "proj.dat"); + + tgeneric (f, 2, 1024, 1, 4096); + + test_end (); + + return 0; +} diff --git a/tests/tsub_fr_tmpl.c b/tests/tsub_fr_tmpl.c new file mode 100644 index 0000000..f6dbcf0 --- /dev/null +++ b/tests/tsub_fr_tmpl.c @@ -0,0 +1,45 @@ +/* tsub_fr_tmpl -- templated test file for mpc_sub_fr. + +Copyright (C) 2008, 2013 INRIA + +This file is part of GNU MPC. + +GNU MPC is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for +more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see http://www.gnu.org/licenses/ . +*/ + +#include "templates.h" +#include "mpc-tests.h" + +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_sub_fr (P[1].mpc, P[2].mpc, P[3].mpfr, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_sub_fr (P[1].mpc, P[1].mpc, P[3].mpfr, P[4].mpc_rnd) + +#include "data_check.tpl" + +int +main (void) +{ + DECL_FUNC (CCF, f, mpc_sub_fr); + + test_start (); + + data_check_template ("sub_fr.dsc", "sub_fr.dat"); + + tgeneric (f, 2, 1024, 7, -1); + + test_end (); + + return 0; +} |