diff options
author | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2012-10-29 15:57:15 +0000 |
---|---|---|
committer | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2012-10-29 15:57:15 +0000 |
commit | d8f61435133dd28d3ed4eab1d4826823c062605d (patch) | |
tree | 104a5fa0dfb63be954efdd75be87d06cbcb55769 | |
parent | cd289b9c420ea0758348b81e20e94974c731f904 (diff) | |
download | mpc-d8f61435133dd28d3ed4eab1d4826823c062605d.tar.gz |
Add templated tests for pow_fr.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/branches/benchs_tests@1294 211d60ee-9f03-0410-a15a-8952a2c7a4e4
-rw-r--r-- | tests/Makefile.am | 9 | ||||
-rw-r--r-- | tests/pow_fr.dsc | 30 | ||||
-rw-r--r-- | tests/tpow_fr_tmpl.c | 72 |
3 files changed, 106 insertions, 5 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index ebddba7..6c6d759 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ ## tests/Makefile.am -- Process this file with automake to produce Makefile.in ## -## Copyright (C) 2008, 2009, 2010, 2011 INRIA +## Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA ## ## This file is part of GNU MPC. ## @@ -28,8 +28,8 @@ AM_LDFLAGS = -no-install LOADLIBES=$(DEFS) -I$(top_srcdir)/src -I$(top_builddir) $(CPPFLAGS) \ $(CFLAGS) -L$(top_builddir)/tests/.libs -lmpc-tests -lmpc -lm $(LIBS) -TEMPLATED = tadd_tmpl tadd_fr_tmpl tmul_tmpl tpow_tmpl tpow_si_tmpl \ - tpow_ui_tmpl +TEMPLATED = tadd_tmpl tadd_fr_tmpl tmul_tmpl tpow_tmpl tpow_fr_tmpl \ + tpow_si_tmpl tpow_ui_tmpl check_PROGRAMS = tabs tacos tacosh tadd tadd_fr tadd_si tadd_ui targ \ tasin tasinh tatan tatanh tconj tcos tcosh tdiv tdiv_2exp tdiv_fr \ tdiv_ui texp tfma tfr_div tfr_sub timag tio_str tlog tlog10 tmul \ @@ -46,7 +46,7 @@ libmpc_tests_la_SOURCES=mpc-tests.h random.c tgeneric.c read_data.c \ tpl_mpfr.c tpl_native.c TEMPLATES = data_check.tpl add.dsc add_fr.dsc add_si.dsc add_ui.dsc mul.dsc \ - pow.dsc pow_si.dsc pow_ui.dsc + pow.dsc pow_fr.dsc pow_si.dsc pow_ui.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 inp_str.dat \ @@ -58,4 +58,3 @@ EXTRA_DIST = $(DATA_SETS) $(TEMPLATES) TESTS_ENVIRONMENT = $(VALGRIND) TESTS = $(check_PROGRAMS) CLEANFILES = mpc_test - diff --git a/tests/pow_fr.dsc b/tests/pow_fr.dsc new file mode 100644 index 0000000..a21f756 --- /dev/null +++ b/tests/pow_fr.dsc @@ -0,0 +1,30 @@ +# Description file for mpc_pow_fr +# +# Copyright (C) 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_pow_fr +RETURN: + mpc_inex +OUTPUT: + mpc_ptr +INPUT: + mpc_srcptr + mpfr_srcptr + mpc_rnd_t diff --git a/tests/tpow_fr_tmpl.c b/tests/tpow_fr_tmpl.c new file mode 100644 index 0000000..a8d5c95 --- /dev/null +++ b/tests/tpow_fr_tmpl.c @@ -0,0 +1,72 @@ +/* tpow_fr_tmpl.c -- test file for mpc_pow_fr. + +Copyright (C) 2009, 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 +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 "mpc-tests.h" + +static void +test_reuse (void) +{ + mpc_t z; + mpfr_t y; + int inex; + + mpfr_init2 (y, 2); + mpc_init2 (z, 2); + mpc_set_si_si (z, 0, -1, MPC_RNDNN); + mpfr_neg (mpc_realref (z), mpc_realref (z), GMP_RNDN); + mpc_div_2exp (z, z, 4, MPC_RNDNN); + mpfr_set_ui (y, 512, GMP_RNDN); + inex = mpc_pow_fr (z, z, y, MPC_RNDNN); + if (MPC_INEX_RE(inex) != 0 || MPC_INEX_IM(inex) != 0 || + mpfr_cmp_ui_2exp (mpc_realref(z), 1, -2048) != 0 || + mpfr_cmp_ui (mpc_imagref(z), 0) != 0 || mpfr_signbit (mpc_imagref(z)) == 0) + { + printf ("Error in test_reuse, wrong ternary value or output\n"); + printf ("inex=(%d %d)\n", MPC_INEX_RE(inex), MPC_INEX_IM(inex)); + printf ("z="); mpc_out_str (stdout, 2, 0, z, MPC_RNDNN); printf ("\n"); + exit (1); + } + mpfr_clear (y); + mpc_clear (z); +} + +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_pow_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_pow_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_pow_fr); + test_start (); + + test_reuse (); + + data_check_template ("pow_fr.dsc", "pow_fr.dat"); + + tgeneric (f, 2, 1024, 7, 10); + + test_end (); + + return 0; +} |