From 4a311ffd142e0340cc889f8e0682dd6ef6843c98 Mon Sep 17 00:00:00 2001 From: thevenyp Date: Wed, 4 Dec 2013 16:08:21 +0000 Subject: [tests/] Switch all tests to new test framework. git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/branches/benchs_tests@1387 211d60ee-9f03-0410-a15a-8952a2c7a4e4 --- tests/Makefile.am | 30 +- tests/check_data.c | 2 +- tests/clear_parameters.c | 4 +- tests/close_datafile.c | 4 +- tests/copy_parameter.c | 2 +- tests/double_rounding.c | 2 +- tests/init_parameters.c | 3 +- tests/mpc-tests.h | 310 +++++++++++++------- tests/open_datafile.c | 5 +- tests/print_parameter.c | 25 +- tests/read_data.c | 696 +-------------------------------------------- tests/read_description.c | 3 +- tests/read_line.c | 2 +- tests/rounding.c | 2 +- tests/setprec_parameters.c | 2 +- tests/tabs.c | 15 +- tests/tabs_tmpl.c | 41 --- tests/tacos.c | 17 +- tests/tacos_tmpl.c | 43 --- tests/tacosh.c | 17 +- tests/tacosh_tmpl.c | 64 ----- tests/tadd.c | 23 +- tests/tadd_fr.c | 17 +- tests/tadd_fr_tmpl.c | 79 ----- tests/tadd_si.c | 68 +++-- tests/tadd_si_tmpl.c | 74 ----- tests/tadd_tmpl.c | 80 ------ tests/tadd_ui.c | 14 +- tests/tadd_ui_tmpl.c | 74 ----- tests/targ.c | 15 +- tests/targ_tmpl.c | 41 --- tests/tasin.c | 17 +- tests/tasin_tmpl.c | 43 --- tests/tasinh.c | 17 +- tests/tasinh_tmpl.c | 64 ----- tests/tatan.c | 16 +- tests/tatan_tmpl.c | 74 ----- tests/tatanh.c | 17 +- tests/tatanh_tmpl.c | 64 ----- tests/tconj.c | 17 +- tests/tconj_tmpl.c | 43 --- tests/tcos.c | 19 +- tests/tcos_tmpl.c | 72 ----- tests/tcosh.c | 19 +- tests/tcosh_tmpl.c | 141 --------- tests/tdiv.c | 20 +- tests/tdiv_2si.c | 13 +- tests/tdiv_2si_tmpl.c | 40 --- tests/tdiv_2ui.c | 13 +- tests/tdiv_2ui_tmpl.c | 41 --- tests/tdiv_fr.c | 19 +- tests/tdiv_fr_tmpl.c | 43 --- tests/tdiv_tmpl.c | 46 --- tests/tdiv_ui.c | 15 +- tests/tdiv_ui_tmpl.c | 40 --- tests/templates.h | 225 --------------- tests/texp.c | 17 +- tests/texp_tmpl.c | 43 --- tests/tfma.c | 26 +- tests/tfma_tmpl.c | 121 -------- tests/tfr_div.c | 17 +- tests/tfr_div_tmpl.c | 43 --- tests/tfr_sub.c | 18 +- tests/tfr_sub_tmpl.c | 43 --- tests/tgeneric.c | 35 ++- tests/timag.c | 11 +- tests/timag_tmpl.c | 38 --- tests/tio_str.c | 4 +- tests/tlog.c | 18 +- tests/tlog10.c | 18 +- tests/tlog10_tmpl.c | 44 --- tests/tlog_tmpl.c | 43 --- tests/tmul.c | 80 ++++-- tests/tmul_2si.c | 13 +- tests/tmul_2si_tmpl.c | 40 --- tests/tmul_2ui.c | 13 +- tests/tmul_2ui_tmpl.c | 40 --- tests/tmul_fr.c | 17 +- tests/tmul_fr_tmpl.c | 43 --- tests/tmul_i.c | 15 +- tests/tmul_i_tmpl.c | 103 ------- tests/tmul_si.c | 12 +- tests/tmul_si_tmpl.c | 40 --- tests/tmul_tmpl.c | 228 --------------- tests/tmul_ui.c | 13 +- tests/tmul_ui_tmpl.c | 40 --- tests/tneg.c | 16 +- tests/tneg_tmpl.c | 43 --- tests/tnorm.c | 16 +- tests/tnorm_tmpl.c | 117 -------- tests/tpl_gmp.c | 2 +- tests/tpl_mpc.c | 2 +- tests/tpl_mpfr.c | 2 +- tests/tpl_native.c | 4 +- tests/tpow.c | 18 +- tests/tpow_d.c | 25 +- tests/tpow_d_tmpl.c | 76 ----- tests/tpow_fr.c | 19 +- tests/tpow_fr_tmpl.c | 72 ----- tests/tpow_si.c | 13 +- tests/tpow_si_tmpl.c | 98 ------- tests/tpow_tmpl.c | 79 ----- tests/tpow_ui.c | 14 +- tests/tpow_ui_tmpl.c | 125 -------- tests/tpow_z.c | 75 ++--- tests/tpow_z_tmpl.c | 40 --- tests/tproj.c | 17 +- tests/tproj_tmpl.c | 43 --- tests/treal.c | 11 +- tests/treal_tmpl.c | 38 --- tests/tsin.c | 17 +- tests/tsin_cos.c | 263 ++++++++++++++++- tests/tsin_cos_tmpl.c | 290 ------------------- tests/tsin_tmpl.c | 43 --- tests/tsinh.c | 17 +- tests/tsinh_tmpl.c | 44 --- tests/tsqr.c | 16 +- tests/tsqr_tmpl.c | 199 ------------- tests/tsqrt.c | 17 +- tests/tsqrt_tmpl.c | 43 --- tests/tstrtoc.c | 4 +- tests/tsub.c | 19 +- tests/tsub_fr.c | 17 +- tests/tsub_fr_tmpl.c | 43 --- tests/tsub_tmpl.c | 45 --- tests/tsub_ui.c | 13 +- tests/tsub_ui_tmpl.c | 40 --- tests/ttan.c | 18 +- tests/ttan_tmpl.c | 224 --------------- tests/ttanh.c | 17 +- tests/ttanh_tmpl.c | 43 --- tests/tui_div.c | 17 +- tests/tui_div_tmpl.c | 107 ------- tests/tui_ui_sub.c | 13 +- tests/tui_ui_sub_tmpl.c | 40 --- 135 files changed, 1259 insertions(+), 5463 deletions(-) delete mode 100644 tests/tabs_tmpl.c delete mode 100644 tests/tacos_tmpl.c delete mode 100644 tests/tacosh_tmpl.c delete mode 100644 tests/tadd_fr_tmpl.c delete mode 100644 tests/tadd_si_tmpl.c delete mode 100644 tests/tadd_tmpl.c delete mode 100644 tests/tadd_ui_tmpl.c delete mode 100644 tests/targ_tmpl.c delete mode 100644 tests/tasin_tmpl.c delete mode 100644 tests/tasinh_tmpl.c delete mode 100644 tests/tatan_tmpl.c delete mode 100644 tests/tatanh_tmpl.c delete mode 100644 tests/tconj_tmpl.c delete mode 100644 tests/tcos_tmpl.c delete mode 100644 tests/tcosh_tmpl.c delete mode 100644 tests/tdiv_2si_tmpl.c delete mode 100644 tests/tdiv_2ui_tmpl.c delete mode 100644 tests/tdiv_fr_tmpl.c delete mode 100644 tests/tdiv_tmpl.c delete mode 100644 tests/tdiv_ui_tmpl.c delete mode 100644 tests/templates.h delete mode 100644 tests/texp_tmpl.c delete mode 100644 tests/tfma_tmpl.c delete mode 100644 tests/tfr_div_tmpl.c delete mode 100644 tests/tfr_sub_tmpl.c delete mode 100644 tests/timag_tmpl.c delete mode 100644 tests/tlog10_tmpl.c delete mode 100644 tests/tlog_tmpl.c delete mode 100644 tests/tmul_2si_tmpl.c delete mode 100644 tests/tmul_2ui_tmpl.c delete mode 100644 tests/tmul_fr_tmpl.c delete mode 100644 tests/tmul_i_tmpl.c delete mode 100644 tests/tmul_si_tmpl.c delete mode 100644 tests/tmul_tmpl.c delete mode 100644 tests/tmul_ui_tmpl.c delete mode 100644 tests/tneg_tmpl.c delete mode 100644 tests/tnorm_tmpl.c delete mode 100644 tests/tpow_d_tmpl.c delete mode 100644 tests/tpow_fr_tmpl.c delete mode 100644 tests/tpow_si_tmpl.c delete mode 100644 tests/tpow_tmpl.c delete mode 100644 tests/tpow_ui_tmpl.c delete mode 100644 tests/tpow_z_tmpl.c delete mode 100644 tests/tproj_tmpl.c delete mode 100644 tests/treal_tmpl.c delete mode 100644 tests/tsin_cos_tmpl.c delete mode 100644 tests/tsin_tmpl.c delete mode 100644 tests/tsinh_tmpl.c delete mode 100644 tests/tsqr_tmpl.c delete mode 100644 tests/tsqrt_tmpl.c delete mode 100644 tests/tsub_fr_tmpl.c delete mode 100644 tests/tsub_tmpl.c delete mode 100644 tests/tsub_ui_tmpl.c delete mode 100644 tests/ttan_tmpl.c delete mode 100644 tests/ttanh_tmpl.c delete mode 100644 tests/tui_div_tmpl.c delete mode 100644 tests/tui_ui_sub_tmpl.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 88eef49..0cf93fd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,32 +28,20 @@ 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 = tabs_tmpl tacos_tmpl tacosh_tmpl tadd_fr_tmpl tadd_tmpl \ - tadd_si_tmpl tadd_ui_tmpl targ_tmpl tasin_tmpl tasinh_tmpl tatan_tmpl \ - tatanh_tmpl tconj_tmpl tcos_tmpl tcosh_tmpl tdiv_tmpl tdiv_2si_tmpl \ - tdiv_2ui_tmpl tdiv_fr_tmpl tdiv_ui_tmpl texp_tmpl tfma_tmpl \ - tfr_div_tmpl tfr_sub_tmpl timag_tmpl tlog10_tmpl tlog_tmpl \ - tlog10_tmpl tmul_tmpl tmul_2si_tmpl tmul_2ui_tmpl tmul_fr_tmpl \ - tmul_i_tmpl tmul_si_tmpl tmul_ui_tmpl tneg_tmpl tnorm_tmpl tpow_tmpl \ - tpow_d_tmpl tpow_fr_tmpl tpow_si_tmpl tpow_ui_tmpl tpow_z_tmpl \ - tproj_tmpl treal_tmpl tsin_tmpl tsinh_tmpl tsin_cos_tmpl tsqr_tmpl \ - tsqrt_tmpl tsub_fr_tmpl tsub_tmpl tsub_ui_tmpl ttan_tmpl ttanh_tmpl \ - tui_div_tmpl tui_ui_sub_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 \ tmul tmul_2si tmul_2ui tmul_fr tmul_i tmul_si tmul_ui tneg tnorm tpow \ - tpow_ld tpow_d tpow_fr tpow_si tpow_ui tpow_z tprec tproj treal \ + tpow_d tpow_fr tpow_ld tpow_si tpow_ui tpow_z tprec tproj treal \ treimref tset tsin tsin_cos tsinh tsqr tsqrt tstrtoc tsub tsub_fr \ - tsub_ui tswap ttan ttanh tui_div tui_ui_sub tget_version $(TEMPLATED) + tsub_ui tswap ttan ttanh tui_div tui_ui_sub tget_version check_LTLIBRARIES=libmpc-tests.la -libmpc_tests_la_SOURCES=mpc-tests.h random.c tgeneric.c read_data.c \ - comparisons.c templates.h check_data.c clear_parameters.c \ - close_datafile.c copy_parameter.c double_rounding.c init_parameters.c \ - open_datafile.c print_parameter.c read_description.c read_line.c \ - rounding.c setprec_parameters.c tpl_gmp.c tpl_mpc.c tpl_mpfr.c \ - tpl_native.c +libmpc_tests_la_SOURCES = mpc-tests.h check_data.c clear_parameters.c \ + close_datafile.c comparisons.c copy_parameter.c double_rounding.c \ + init_parameters.c open_datafile.c print_parameter.c random.c \ + read_data.c read_description.c read_line.c rounding.c \ + setprec_parameters.c tpl_gmp.c tpl_mpc.c tpl_mpfr.c tpl_native.c DESCRIPTIONS = abs.dsc acos.dsc acosh.dsc add.dsc add_fr.dsc add_si.dsc \ add_ui.dsc arg.dsc asin.dsc asinh.dsc atan.dsc atanh.dsc conj.dsc \ @@ -61,8 +49,8 @@ DESCRIPTIONS = abs.dsc acos.dsc acosh.dsc add.dsc add_fr.dsc add_si.dsc \ div_ui.dsc exp.dsc fma.dsc fr_div.dsc fr_sub.dsc imag.dsc log.dsc \ log10.dsc mul.dsc mul_2si.dsc mul_2ui.dsc mul_fr.dsc mul_i.dsc \ mul_si.dsc mul_ui.dsc neg.dsc norm.dsc pow.dsc pow_d.dsc pow_fr.dsc \ - pow_si.dsc pow_ui.dsc pow_z.dsc proj.dsc real.dsc sin.dsc sinh.dsc \ - sin_cos.dsc sqr.dsc sqrt.dsc sub.dsc sub_fr.dsc sub_ui.dsc tan.dsc \ + pow_si.dsc pow_ui.dsc pow_z.dsc proj.dsc real.dsc sin.dsc sin_cos.dsc \ + sinh.dsc sqr.dsc sqrt.dsc sub.dsc sub_fr.dsc sub_ui.dsc tan.dsc \ tanh.dsc ui_div.dsc ui_ui_sub.dsc DATA_SETS = abs.dat acos.dat acosh.dat add.dat add_fr.dat arg.dat \ asin.dat asinh.dat atan.dat atanh.dat conj.dat cos.dat cosh.dat \ diff --git a/tests/check_data.c b/tests/check_data.c index 33ffcb1..6d6bc69 100644 --- a/tests/check_data.c +++ b/tests/check_data.c @@ -18,7 +18,7 @@ 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_INEX_CMP(c, r, i) \ (((r) == TERNARY_NOT_CHECKED || (r) == MPC_INEX_RE(c)) \ diff --git a/tests/clear_parameters.c b/tests/clear_parameters.c index a7088d5..d5c74f8 100644 --- a/tests/clear_parameters.c +++ b/tests/clear_parameters.c @@ -1,6 +1,6 @@ /* clear_parameters -- Deallocate memory for function parameters. -Copyright (C) 2012 INRIA +Copyright (C) 2012, 2013 INRIA This file is part of GNU MPC. @@ -18,7 +18,7 @@ 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" static void clear_param (mpc_operand_t* p, mpc_param_t t) diff --git a/tests/close_datafile.c b/tests/close_datafile.c index 7959d39..b7ddcc6 100644 --- a/tests/close_datafile.c +++ b/tests/close_datafile.c @@ -1,6 +1,6 @@ /* close_datafile.c -- Deallocate buffers and close datafile. -Copyright (C) 2012 INRIA +Copyright (C) 2012, 2013 INRIA This file is part of GNU MPC. @@ -18,7 +18,7 @@ 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 +#include "mpc-tests.h" void close_datafile (mpc_datafile_context_t *dc) diff --git a/tests/copy_parameter.c b/tests/copy_parameter.c index fd66305..4c1ff37 100644 --- a/tests/copy_parameter.c +++ b/tests/copy_parameter.c @@ -19,7 +19,7 @@ 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" int copy_parameter (mpc_fun_param_t *params, int index_dest, int index_src) diff --git a/tests/double_rounding.c b/tests/double_rounding.c index 3ea2188..6181d1a 100644 --- a/tests/double_rounding.c +++ b/tests/double_rounding.c @@ -18,7 +18,7 @@ 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" /* return 1 if double rounding occurs; return 0 otherwise */ diff --git a/tests/init_parameters.c b/tests/init_parameters.c index bbdb15b..ea94a34 100644 --- a/tests/init_parameters.c +++ b/tests/init_parameters.c @@ -19,8 +19,7 @@ along with this program. If not, see http://www.gnu.org/licenses/ . */ #include - -#include "templates.h" +#include "mpc-tests.h" static void init_param (mpc_operand_t* p, mpc_param_t t) diff --git a/tests/mpc-tests.h b/tests/mpc-tests.h index 3be91ff..caed58c 100644 --- a/tests/mpc-tests.h +++ b/tests/mpc-tests.h @@ -1,6 +1,6 @@ /* mpc-tests.h -- Tests helper functions. -Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA +Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -103,7 +103,7 @@ do { \ extern gmp_randstate_t rands; extern void test_start (void); -extern void test_end (void); +extern void test_end (void); extern void test_default_random (mpc_ptr, mp_exp_t, mp_exp_t, unsigned int, unsigned int); @@ -115,8 +115,6 @@ void test_random_mpfr (mpfr_ptr x, mpfr_exp_t emin, mpfr_exp_t emax, void test_random_mpc (mpc_ptr z, mpfr_exp_t emin, mpfr_exp_t emax, unsigned int negative_probability); - - /** COMPARISON FUNCTIONS **/ /* some sign are unspecified in ISO C99, thus we record in struct known_signs_t whether the sign has to be checked */ @@ -135,111 +133,219 @@ typedef struct Unlike mpfr_cmp, same_mpfr_value(got, ref, x) return 1 when got and ref are both NaNs. */ extern int same_mpfr_value (mpfr_ptr got, mpfr_ptr ref, int known_sign); -extern int same_mpc_value (mpc_ptr got, mpc_ptr ref, known_signs_t known_signs); - - -/** GENERIC TESTS **/ - -typedef int (*CC_func_ptr) (mpc_t, mpc_srcptr, mpc_rnd_t); -typedef int (*C_CC_func_ptr) (mpc_t, mpc_srcptr, mpc_srcptr, mpc_rnd_t); -typedef int (*CCCC_func_ptr) (mpc_t, mpc_srcptr, mpc_srcptr, mpc_srcptr, - mpc_rnd_t); -typedef int (*CCU_func_ptr) (mpc_t, mpc_srcptr, unsigned long, mpc_rnd_t); -typedef int (*CCS_func_ptr) (mpc_t, mpc_srcptr, long, mpc_rnd_t); -typedef int (*CCI_func_ptr) (mpc_t, mpc_srcptr, int, mpc_rnd_t); -typedef int (*CCF_func_ptr) (mpc_t, mpc_srcptr, mpfr_srcptr, mpc_rnd_t); -typedef int (*CFC_func_ptr) (mpc_t, mpfr_srcptr, mpc_srcptr, mpc_rnd_t); -typedef int (*CUC_func_ptr) (mpc_t, unsigned long, mpc_srcptr, mpc_rnd_t); -typedef int (*CUUC_func_ptr) (mpc_t, unsigned long, unsigned long, mpc_srcptr, - mpc_rnd_t); -typedef int (*FC_func_ptr) (mpfr_t, mpc_srcptr, mpfr_rnd_t); -typedef int (*CC_C_func_ptr) (mpc_t, mpc_t, mpc_srcptr, mpc_rnd_t, mpc_rnd_t); - -typedef union { - FC_func_ptr FC; /* output: mpfr_t, input: mpc_t */ - CC_func_ptr CC; /* output: mpc_t, input: mpc_t */ - C_CC_func_ptr C_CC; /* output: mpc_t, inputs: (mpc_t, mpc_t) */ - CCCC_func_ptr CCCC; /* output: mpc_t, inputs: (mpc_t, mpc_t, mpc_t) */ - CCU_func_ptr CCU; /* output: mpc_t, inputs: (mpc_t, unsigned long) */ - CCS_func_ptr CCS; /* output: mpc_t, inputs: (mpc_t, long) */ - CCI_func_ptr CCI; /* output: mpc_t, inputs: (mpc_t, int) */ - CCF_func_ptr CCF; /* output: mpc_t, inputs: (mpc_t, mpfr_t) */ - CFC_func_ptr CFC; /* output: mpc_t, inputs: (mpfr_t, mpc_t) */ - CUC_func_ptr CUC; /* output: mpc_t, inputs: (unsigned long, mpc_t) */ - CUUC_func_ptr CUUC; /* output: mpc_t, inputs: (ulong, ulong, mpc_t) */ - CC_C_func_ptr CC_C; /* outputs: (mpc_t, mpc_t), input: mpc_t */ -} func_ptr; - -/* the rounding mode is implicit */ -typedef enum { - FC, /* output: mpfr_t, input: mpc_t */ - CC, /* output: mpc_t, input: mpc_t */ - C_CC, /* output: mpc_t, inputs: (mpc_t, mpc_t) */ - CCCC, /* output: mpc_t, inputs: (mpc_t, mpc_t, mpc_t) */ - CCU, /* output: mpc_t, inputs: (mpc_t, unsigned long) */ - CCS, /* output: mpc_t, inputs: (mpc_t, long) */ - CCI, /* output: mpc_t, inputs: (mpc_t, int) */ - CCF, /* output: mpc_t, inputs: (mpc_t, mpfr_t) */ - CFC, /* output: mpc_t, inputs: (mpfr_t, mpc_t) */ - CUC, /* output: mpc_t, inputs: (unsigned long, mpc_t) */ - CUUC, /* output: mpc_t, inputs: (ulong, ulong, mpc_t) */ - CC_C /* outputs: (mpc_t, mpc_t), input: mpc_t */ -} func_type; - -/* properties */ -#define FUNC_PROP_NONE 0 -#define FUNC_PROP_SYMETRIC 1 - -typedef struct -{ - func_ptr pointer; - func_type type; - const char * name; - int properties; -} mpc_function; - -#define DECL_FUNC(_ftype, _fvar, _func) \ - mpc_function _fvar; \ - _fvar.pointer._ftype = _func; \ - _fvar.type = _ftype; \ - _fvar.name = QUOTE (_func); \ - _fvar.properties = FUNC_PROP_NONE; - - -/* tgeneric(mpc_function, prec_min, prec_max, step, exp_max) checks rounding - with random numbers: - - with precision ranging from prec_min to prec_max with an increment of - step, - - with exponent between -exp_max and exp_max. - - It also checks parameter reuse (it is assumed here that either two mpc_t - variables are equal or they are different, in the sense that the real part of - one of them cannot be the imaginary part of the other). */ -void tgeneric (mpc_function, mpfr_prec_t, mpfr_prec_t, mpfr_prec_t, mp_exp_t); - +extern int same_mpc_value (mpc_ptr got, mpc_ptr ref, + known_signs_t known_signs); /** READ FILE WITH TEST DATA SET **/ -/* data_check (function, "data_file_name") checks function results against - precomputed data in a file.*/ -extern void data_check (mpc_function, const char *); - -extern FILE * open_data_file (const char *file_name); -extern void close_data_file (FILE *fp); +extern FILE * open_data_file (const char *file_name); +extern void close_data_file (FILE *fp); /* helper file reading functions */ extern void skip_whitespace_comments (FILE *fp); -extern void read_ternary (FILE *fp, int* ternary); -extern void read_mpfr_rounding_mode (FILE *fp, mpfr_rnd_t* rnd); -extern void read_mpc_rounding_mode (FILE *fp, mpc_rnd_t* rnd); -extern mpfr_prec_t read_mpfr_prec (FILE *fp); -extern void read_int (FILE *fp, int *n, const char *name); -extern size_t read_string (FILE *fp, char **buffer_ptr, size_t buffer_length, const char *name); -extern void read_mpfr (FILE *fp, mpfr_ptr x, int *known_sign); -extern void read_mpc (FILE *fp, mpc_ptr z, known_signs_t *ks); +extern void read_ternary (FILE *fp, int* ternary); +extern void read_mpfr_rounding_mode (FILE *fp, mpfr_rnd_t* rnd); +extern void read_mpc_rounding_mode (FILE *fp, mpc_rnd_t* rnd); +extern mpfr_prec_t read_mpfr_prec (FILE *fp); +extern void read_int (FILE *fp, int *n, const char *name); +extern size_t read_string (FILE *fp, char **buffer_ptr, + size_t buffer_length, const char *name); +extern void read_mpfr (FILE *fp, mpfr_ptr x, int *known_sign); +extern void read_mpc (FILE *fp, mpc_ptr z, known_signs_t *ks); + +/* + function descriptions +*/ + +/* type for return, output and input parameters */ +typedef enum { + NATIVE_INT, /* int */ + NATIVE_UL, /* unsigned long */ + NATIVE_L, /* signed long */ + NATIVE_D, /* double */ + NATIVE_LD, /* long double */ + NATIVE_DC, /* double _Complex */ + NATIVE_LDC, /* long double _Complex */ + NATIVE_IM, /* intmax_t */ + NATIVE_UIM, /* uintmax_t */ + NATIVE_STRING, /* char* */ + GMP_Z, /* mpz_t */ + GMP_Q, /* mpq_t */ + GMP_F, /* mpf_t */ + MPFR_INEX, /* mpfr_inex */ + MPFR, /* mpfr_t */ + MPFR_RND, /* mpfr_rnd_t */ + MPC_INEX, /* mpc_inex */ + MPC, /* mpc_t */ + MPC_RND /* mpc_rnd_t */ +} mpc_param_t; + +/* additional information for checking mpfr_t result */ +typedef struct { + mpfr_t mpfr; /* skip space for the variable */ + int known_sign; +} mpfr_data_t; #define TERNARY_NOT_CHECKED 255 - /* special value to indicate that the ternary value is not checked */ +/* special value to indicate that the ternary value is not checked */ #define TERNARY_ERROR 254 - /* special value to indicate that an error occurred in an mpc function */ +/* special value to indicate that an error occurred in an mpc function */ + +/* mpc nonary value as a pair of ternary value for data from a file */ +typedef struct { + int real; + int imag; +} mpc_inex_data_t; + +/* additional information for checking mpc_t result */ +typedef struct { + mpc_t mpc; /* skip space */ + int known_sign_real; + int known_sign_imag; +} mpc_data_t; + +/* string buffer information */ +typedef struct { + char* string; /* skip space */ + int length; +} string_info_t; + +/* abstract parameter type + + Let consider an abstract parameter p, which is declared as follows: + mpc_operand_t p; + we use the fact that a mpfr_t (respectively mpc_t) value can be accessed as + 'p.mpfr' (resp. 'p.mpc') as well as 'p.mpfr_info.mpfr' + (resp. 'p.mpc_info.mpc'), the latter form permitting access to the + 'known_sign' field(s). + Similarly, if the abstract parameter represent a string variable, we can + access its value with 'p.string' or 'p.string_info.string' and its size + with 'p.string_info.length'. + + The user uses the simple form when adding a test, the second form is used by the + test suite itself when reading reference data and checking result against them. +*/ +typedef union { + int i; + unsigned long ui; + signed long si; + double d; + long double ld; +#ifdef _MPC_H_HAVE_INTMAX_T + intmax_t im; + uintmax_t uim; +#endif +#ifdef _Complex_I + double _Complex dc; + long double _Complex ldc; +#endif + char * string; + string_info_t string_info; + mpz_t mpz; + mpq_t mpq; + mpf_t mpf; + mpfr_t mpfr; + mpfr_data_t mpfr_data; + mpfr_rnd_t mpfr_rnd; + int mpfr_inex; + mpc_t mpc; + mpc_data_t mpc_data; + mpc_rnd_t mpc_rnd; + int mpc_inex; + mpc_inex_data_t mpc_inex_data; +} mpc_operand_t; + +#define PARAMETER_ARRAY_SIZE 10 + +/* function name plus parameters */ +typedef struct { + char *name; /* name of the function */ + int nbout; /* number of output parameters */ + int nbin; /* number of input parameters */ + mpc_operand_t P[PARAMETER_ARRAY_SIZE]; /* value of parameters */ + mpc_param_t T[PARAMETER_ARRAY_SIZE]; /* type of parameters */ +} mpc_fun_param_t; + + +void read_description (mpc_fun_param_t* param, const char *file); +const char* read_description_findname (mpc_param_t e); + +/* file functions */ +typedef struct { + char *pathname; + FILE *fd; + unsigned long line_number; + unsigned long test_line_number; + int nextchar; +} mpc_datafile_context_t; + +void open_datafile (mpc_datafile_context_t* datafile_context, + const char * data_filename); +void close_datafile (mpc_datafile_context_t *dc); + +/* data file functions */ +void read_line (mpc_datafile_context_t* datafile_context, + mpc_fun_param_t* params); +void check_data (mpc_datafile_context_t* datafile_context, + mpc_fun_param_t* params, + int index_reused_operand); + +/* parameters templated functions */ +int data_check_template (const char* descr_file, const char * data_file); + +void init_parameters (mpc_fun_param_t *params); +void clear_parameters (mpc_fun_param_t *params); +void print_parameter (mpc_fun_param_t *params, int index); +int copy_parameter (mpc_fun_param_t *params, + int index_dest, int index_src); + +void tpl_read_int (mpc_datafile_context_t* datafile_context, + int *nread, const char *name); +void tpl_read_ui (mpc_datafile_context_t* datafile_context, + unsigned long int *ui); +void tpl_read_si (mpc_datafile_context_t* datafile_context, + long int *si); +void tpl_read_mpz (mpc_datafile_context_t* datafile_context, + mpz_t z); +void tpl_skip_whitespace_comments (mpc_datafile_context_t* datafile_context); +void tpl_read_ternary (mpc_datafile_context_t* datafile_context, + int* ternary); +void tpl_read_mpfr (mpc_datafile_context_t* datafile_context, + mpfr_ptr x, int* known_sign); +void tpl_read_mpfr_rnd (mpc_datafile_context_t* datafile_context, + mpfr_rnd_t* rnd); +void tpl_read_mpfr_inex (mpc_datafile_context_t* datafile_context, + int *ternary); +void tpl_read_mpc_inex (mpc_datafile_context_t* datafile_context, + mpc_inex_data_t* ternarypair); +void tpl_read_mpc (mpc_datafile_context_t* datafile_context, + mpc_data_t* z); +void tpl_read_mpc_rnd (mpc_datafile_context_t* datafile_context, + mpc_rnd_t* rnd); + +int tpl_same_mpz_value (mpz_ptr n1, mpz_ptr n2); +int tpl_same_mpfr_value (mpfr_ptr x1, mpfr_ptr x2, int known_sign); +int tpl_check_mpfr_data (mpfr_t got, mpfr_data_t expected); +int tpl_check_mpc_data (mpc_ptr got, mpc_data_t expected); + +void tpl_copy_int (int *dest, const int * const src); +void tpl_copy_ui (unsigned long int *dest, + const unsigned long int * const src); +void tpl_copy_si (long int *dest, const long int * const src); +void tpl_copy_d (double *dest, const double * const src); +void tpl_copy_mpz (mpz_ptr dest, mpz_srcptr src); +void tpl_copy_mpfr (mpfr_ptr dest, mpfr_srcptr src); +void tpl_copy_mpc (mpc_ptr dest, mpc_srcptr src); + +int double_rounding (mpc_fun_param_t *params); + +/* iterating over rounding modes */ +void first_rnd_mode (mpc_fun_param_t *params); +int is_valid_rnd_mode (mpc_fun_param_t *params); +void next_rnd_mode (mpc_fun_param_t *params); + +/* parameter precision */ +void set_output_precision (mpc_fun_param_t *params, mpfr_prec_t prec); +void set_input_precision (mpc_fun_param_t *params, mpfr_prec_t prec); +void set_reference_precision (mpc_fun_param_t *params, mpfr_prec_t prec); #endif /* __MPC_TESTS_H */ diff --git a/tests/open_datafile.c b/tests/open_datafile.c index ffcf1c1..71ca91a 100644 --- a/tests/open_datafile.c +++ b/tests/open_datafile.c @@ -4,7 +4,7 @@ #define the prototype of the function under test in the CALL symbol, see tadd_tmpl.c for an example. -Copyright (C) 2012 INRIA +Copyright (C) 2012, 2013 INRIA This file is part of GNU MPC. @@ -23,8 +23,7 @@ along with this program. If not, see http://www.gnu.org/licenses/ . */ #include - -#include "templates.h" +#include "mpc-tests.h" void open_datafile (mpc_datafile_context_t* datafile_context, diff --git a/tests/print_parameter.c b/tests/print_parameter.c index 500daf4..7d59309 100644 --- a/tests/print_parameter.c +++ b/tests/print_parameter.c @@ -18,31 +18,12 @@ 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 - -#include "templates.h" +#include "mpc-tests.h" static const char *mpfr_rnd_mode [] = { "MPFR_RNDN", "MPFR_RNDZ", "MPFR_RNDU", "MPFR_RNDD" }; -const char *rnd_mode[] = - { "MPC_RNDNN", "MPC_RNDZN", "MPC_RNDUN", "MPC_RNDDN", - "undefined", "undefined", "undefined", "undefined", "undefined", - "undefined", "undefined", "undefined", "undefined", "undefined", - "undefined", "undefined", - "MPC_RNDNZ", "MPC_RNDZZ", "MPC_RNDUZ", "MPC_RNDDZ", - "undefined", "undefined", "undefined", "undefined", "undefined", - "undefined", "undefined", "undefined", "undefined", "undefined", - "undefined", "undefined", - "MPC_RNDNU", "MPC_RNDZU", "MPC_RNDUU", "MPC_RNDDU", - "undefined", "undefined", "undefined", "undefined", "undefined", - "undefined", "undefined", "undefined", "undefined", "undefined", - "undefined", "undefined", - "MPC_RNDND", "MPC_RNDZD", "MPC_RNDUD", "MPC_RNDDD", - "undefined", "undefined", "undefined", "undefined", "undefined", - "undefined", "undefined", "undefined", "undefined", "undefined", - "undefined", "undefined", - }; +extern const char *mpc_rnd_mode[]; #define MPFR_INEX_STR(inex) \ (inex) == TERNARY_NOT_CHECKED ? "?" \ @@ -116,7 +97,7 @@ print_parameter (mpc_fun_param_t* params, int index) case MPC_RND: printf ("(rounding mode): %s\n", - rnd_mode[params->P[index].mpc_rnd]); + mpc_rnd_mode[params->P[index].mpc_rnd]); break; default: diff --git a/tests/read_data.c b/tests/read_data.c index 9447408..039c5a5 100644 --- a/tests/read_data.c +++ b/tests/read_data.c @@ -40,10 +40,7 @@ int nextchar; : (inex) == +1 ? "+1" \ : (inex) == -1 ? "-1" : "0" -static const char *mpfr_rnd_mode [] = - { "MPFR_RNDN", "MPFR_RNDZ", "MPFR_RNDU", "MPFR_RNDD" }; - -const char *rnd_mode[] = +const char *mpc_rnd_mode[] = { "MPC_RNDNN", "MPC_RNDZN", "MPC_RNDUN", "MPC_RNDDN", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", "undefined", @@ -138,7 +135,6 @@ skip_whitespace_comments (FILE *fp) } } - size_t read_string (FILE *fp, char **buffer_ptr, size_t buffer_length, const char *name) { @@ -298,54 +294,6 @@ read_int (FILE *fp, int *nread, const char *name) skip_whitespace_comments (fp); } -static void -read_uint (FILE *fp, unsigned long int *ui) -{ - int n = 0; - - if (nextchar == EOF) - { - printf ("Error: Unexpected EOF when reading uint " - "in file '%s' line %lu\n", - pathname, line_number); - exit (1); - } - ungetc (nextchar, fp); - n = fscanf (fp, "%lu", ui); - if (ferror (fp) || n == 0 || n == EOF) - { - printf ("Error: Cannot read uint in file '%s' line %lu\n", - pathname, line_number); - exit (1); - } - nextchar = getc (fp); - skip_whitespace_comments (fp); -} - -static void -read_sint (FILE *fp, long int *si) -{ - int n = 0; - - if (nextchar == EOF) - { - printf ("Error: Unexpected EOF when reading sint " - "in file '%s' line %lu\n", - pathname, line_number); - exit (1); - } - ungetc (nextchar, fp); - n = fscanf (fp, "%li", si); - if (ferror (fp) || n == 0 || n == EOF) - { - printf ("Error: Cannot read sint in file '%s' line %lu\n", - pathname, line_number); - exit (1); - } - nextchar = getc (fp); - skip_whitespace_comments (fp); -} - mpfr_prec_t read_mpfr_prec (FILE *fp) { @@ -415,645 +363,3 @@ read_mpc (FILE *fp, mpc_ptr z, known_signs_t *ks) read_mpfr (fp, mpc_realref (z), ks == NULL ? NULL : &ks->re); read_mpfr (fp, mpc_imagref (z), ks == NULL ? NULL : &ks->im); } - -static void -check_compatible (int inex, mpfr_t expected, mpfr_rnd_t rnd, const char *s) -{ - if ((rnd == MPFR_RNDU && inex == -1) || - (rnd == MPFR_RNDD && inex == +1) || - (rnd == MPFR_RNDZ && !mpfr_signbit (expected) && inex == +1) || - (rnd == MPFR_RNDZ && mpfr_signbit (expected) && inex == -1)) - { - if (s != NULL) - printf ("Incompatible ternary value '%c' (%s part) in file '%s' line %lu\n", - (inex == 1) ? '+' : '-', s, pathname, test_line_number); - else - printf ("Incompatible ternary value '%c' in file '%s' line %lu\n", - (inex == 1) ? '+' : '-', pathname, test_line_number); - } -} - -/* read lines of data */ -static void -read_cc (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected, - known_signs_t *signs, mpc_ptr op, 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, op, NULL); - read_mpc_rounding_mode (fp, rnd); - check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real"); - check_compatible (*inex_im, mpc_imagref(expected), MPC_RND_IM(*rnd), "imag"); -} - -static void -read_fc (FILE *fp, int *inex, mpfr_ptr expected, int *sign, mpc_ptr op, - mpfr_rnd_t *rnd) -{ - test_line_number = line_number; - read_ternary (fp, inex); - read_mpfr (fp, expected, sign); - read_mpc (fp, op, NULL); - read_mpfr_rounding_mode (fp, rnd); - check_compatible (*inex, expected, *rnd, NULL); -} - -static void -read_ccc (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected, - known_signs_t *signs, mpc_ptr op1, mpc_ptr op2, 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_rounding_mode (fp, rnd); - check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real"); - check_compatible (*inex_im, mpc_imagref(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_realref(expected), MPC_RND_RE(*rnd), "real"); - check_compatible (*inex_im, mpc_imagref(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) -{ - test_line_number = line_number; - read_ternary (fp, inex_re); - read_ternary (fp, inex_im); - read_mpc (fp, expected, signs); - read_mpfr (fp, op1, NULL); - read_mpc (fp, op2, NULL); - read_mpc_rounding_mode (fp, rnd); - check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real"); - check_compatible (*inex_im, mpc_imagref(expected), MPC_RND_IM(*rnd), "imag"); -} - -static void -read_ccf (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected, - known_signs_t *signs, mpc_ptr op1, mpfr_ptr op2, 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_mpfr (fp, op2, NULL); - read_mpc_rounding_mode (fp, rnd); - check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real"); - check_compatible (*inex_im, mpc_imagref(expected), MPC_RND_IM(*rnd), "imag"); -} - -static void -read_ccu (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected, - known_signs_t *signs, mpc_ptr op1, unsigned long int *op2, 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_uint (fp, op2); - read_mpc_rounding_mode (fp, rnd); - check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real"); - check_compatible (*inex_im, mpc_imagref(expected), MPC_RND_IM(*rnd), "imag"); -} - -static void -read_ccs (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected, - known_signs_t *signs, mpc_ptr op1, long int *op2, 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_sint (fp, op2); - read_mpc_rounding_mode (fp, rnd); - check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real"); - check_compatible (*inex_im, mpc_imagref(expected), MPC_RND_IM(*rnd), "imag"); -} - -/* set MPFR flags to random values */ -static void -set_mpfr_flags (int counter) -{ - if (counter & 1) - mpfr_set_underflow (); - else - mpfr_clear_underflow (); - if (counter & 2) - mpfr_set_overflow (); - else - mpfr_clear_overflow (); - /* the divide-by-0 flag was added in MPFR 3.1.0 */ -#ifdef mpfr_set_divby0 - if (counter & 4) - mpfr_set_divby0 (); - else - mpfr_clear_divby0 (); -#endif - if (counter & 8) - mpfr_set_nanflag (); - else - mpfr_clear_nanflag (); - if (counter & 16) - mpfr_set_inexflag (); - else - mpfr_clear_inexflag (); - if (counter & 32) - mpfr_set_erangeflag (); - else - mpfr_clear_erangeflag (); -} - -/* Check MPFR flags: we allow that some flags are set internally by MPC, - for example if MPC does internal computations (using MPFR) which yield - an overflow, even if the final MPC result fits in the exponent range. - However we don't allow MPC to *clear* the MPFR flags */ -static void -check_mpfr_flags (int counter) -{ - int old, neu; - - old = (counter & 1) != 0; - neu = mpfr_underflow_p () != 0; - if (old && (neu == 0)) - { - printf ("Error, underflow flag has been modified from %d to %d\n", - old, neu); - exit (1); - } - old = (counter & 2) != 0; - neu = mpfr_overflow_p () != 0; - if (old && (neu == 0)) - { - printf ("Error, overflow flag has been modified from %d to %d\n", - old, neu); - exit (1); - } -#ifdef mpfr_divby0_p - old = (counter & 4) != 0; - neu = mpfr_divby0_p () != 0; - if (old && (neu == 0)) - { - printf ("Error, divby0 flag has been modified from %d to %d\n", - old, neu); - exit (1); - } -#endif - old = (counter & 8) != 0; - neu = mpfr_nanflag_p () != 0; - if (old && (neu == 0)) - { - printf ("Error, nanflag flag has been modified from %d to %d\n", - old, neu); - exit (1); - } - old = (counter & 16) != 0; - neu = mpfr_inexflag_p () != 0; - if (old && (neu == 0)) - { - printf ("Error, inexflag flag has been modified from %d to %d\n", - old, neu); - exit (1); - } - old = (counter & 32) != 0; - neu = mpfr_erangeflag_p () != 0; - if (old && (neu == 0)) - { - printf ("Error, erangeflag flag has been modified from %d to %d\n", - old, neu); - exit (1); - } -} - -/* data_check (function, data_file_name) checks function results against - precomputed data in a file.*/ -void -data_check (mpc_function function, const char *file_name) -{ - FILE *fp; - - int inex_re; - mpfr_t x1, x2; - mpfr_rnd_t mpfr_rnd = MPFR_RNDN; - int sign_real; - - int inex_im; - mpc_t z1, z2, z3, z4, z5; - mpc_rnd_t rnd = MPC_RNDNN; - - unsigned long int ui; - long int si; - - known_signs_t signs; - int inex = 0; - - static int rand_counter = 0; - - fp = open_data_file (file_name); - - /* 1. init needed variables */ - mpc_init2 (z1, 2); - switch (function.type) - { - case FC: - mpfr_init (x1); - mpfr_init (x2); - break; - case CC: case CCU: case CCS: - mpc_init2 (z2, 2); - mpc_init2 (z3, 2); - break; - case C_CC: - mpc_init2 (z2, 2); - 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); - mpc_init2 (z3, 2); - break; - default: - ; - } - - /* 2. read data file */ - line_number = 1; - nextchar = getc (fp); - skip_whitespace_comments (fp); - while (nextchar != EOF) { - set_mpfr_flags (rand_counter); - - /* for each kind of function prototype: */ - /* 3.1 read a line of data: expected result, parameters, rounding mode */ - /* 3.2 compute function at the same precision as the expected result */ - /* 3.3 compare this result with the expected one */ - switch (function.type) - { - case FC: /* example mpc_norm */ - read_fc (fp, &inex_re, x1, &sign_real, z1, &mpfr_rnd); - mpfr_set_prec (x2, mpfr_get_prec (x1)); - inex = function.pointer.FC (x2, z1, mpfr_rnd); - if ((inex_re != TERNARY_NOT_CHECKED && inex_re != inex) - || !same_mpfr_value (x1, x2, sign_real)) - { - mpfr_t got, expected; - mpc_t op; - op[0] = z1[0]; - got[0] = x2[0]; - expected[0] = x1[0]; - printf ("%s(op) failed (%s:%lu)\nwith rounding mode %s\n", - function.name, file_name, test_line_number, - mpfr_rnd_mode[mpfr_rnd]); - if (inex_re != TERNARY_NOT_CHECKED && inex_re != inex) - printf("ternary value: got %s, expected %s\n", - MPFR_INEX_STR (inex), MPFR_INEX_STR (inex_re)); - MPC_OUT (op); - printf (" "); - MPFR_OUT (got); - MPFR_OUT (expected); - - exit (1); - } - break; - - case CC: /* example mpc_log */ - read_cc (fp, &inex_re, &inex_im, z1, &signs, z2, &rnd); - mpfr_set_prec (mpc_realref (z3), MPC_PREC_RE (z1)); - mpfr_set_prec (mpc_imagref (z3), MPC_PREC_IM (z1)); - inex = function.pointer.CC (z3, z2, rnd); - if (!MPC_INEX_CMP (inex_re, inex_im, inex) - || !same_mpc_value (z3, z1, signs)) - { - mpc_t op, got, expected; /* display sensible variable names */ - op[0] = z2[0]; - expected[0]= z1[0]; - got[0] = z3[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 (op); - printf (" "); - MPC_OUT (got); - MPC_OUT (expected); - - exit (1); - } - break; - - case C_CC: /* example mpc_mul */ - read_ccc (fp, &inex_re, &inex_im, z1, &signs, z2, z3, &rnd); - mpfr_set_prec (mpc_realref(z4), MPC_PREC_RE (z1)); - mpfr_set_prec (mpc_imagref(z4), MPC_PREC_IM (z1)); - inex = function.pointer.C_CC (z4, z2, z3, rnd); - if (!MPC_INEX_CMP (inex_re, inex_im, inex) - || !same_mpc_value (z4, z1, signs)) - { - /* display sensible variable names */ - mpc_t op1, op2, got, expected; - op1[0] = z2[0]; - op2[0] = z3[0]; - expected[0]= z1[0]; - got[0] = z4[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); - printf (" "); - MPC_OUT (got); - MPC_OUT (expected); - - exit (1); - } - if (function.properties & FUNC_PROP_SYMETRIC) - { - inex = function.pointer.C_CC (z4, z3, z2, rnd); - if (!MPC_INEX_CMP (inex_re, inex_im, inex) - || !same_mpc_value (z4, z1, signs)) - { - /* display sensible variable names */ - mpc_t op1, op2, got, expected; - op1[0] = z3[0]; - op2[0] = z2[0]; - expected[0]= z1[0]; - got[0] = z4[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); - printf (" "); - MPC_OUT (got); - MPC_OUT (expected); - - exit (1); - } - } - 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_realref(z5), MPC_PREC_RE (z1)); - mpfr_set_prec (mpc_imagref(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_realref(z3), MPC_PREC_RE (z1)); - mpfr_set_prec (mpc_imagref(z3), MPC_PREC_IM (z1)); - inex = function.pointer.CFC (z3, x1, z2, rnd); - if (!MPC_INEX_CMP (inex_re, inex_im, inex) - || !same_mpc_value (z3, z1, signs)) - { - /* display sensible variable names */ - mpc_t op2, got, expected; - mpfr_t op1; - op1[0] = x1[0]; - op2[0] = z2[0]; - expected[0]= z1[0]; - got[0] = z3[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)); - MPFR_OUT (op1); - MPC_OUT (op2); - printf (" "); - MPC_OUT (got); - MPC_OUT (expected); - - exit (1); - } - break; - - case CCF: /* example mpc_mul_fr */ - read_ccf (fp, &inex_re, &inex_im, z1, &signs, z2, x1, &rnd); - mpfr_set_prec (mpc_realref(z3), MPC_PREC_RE (z1)); - mpfr_set_prec (mpc_imagref(z3), MPC_PREC_IM (z1)); - inex = function.pointer.CCF (z3, z2, x1, rnd); - if (!MPC_INEX_CMP (inex_re, inex_im, inex) - || !same_mpc_value (z3, z1, signs)) - { - /* display sensible variable names */ - mpc_t op1, got, expected; - mpfr_t op2; - op1[0] = z2[0]; - op2[0] = x1[0]; - expected[0]= z1[0]; - got[0] = z3[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); - MPFR_OUT (op2); - printf (" "); - MPC_OUT (got); - MPC_OUT (expected); - - exit (1); - } - break; - - case CCU: /* example mpc_pow_ui */ - read_ccu (fp, &inex_re, &inex_im, z1, &signs, z2, &ui, &rnd); - mpfr_set_prec (mpc_realref(z3), MPC_PREC_RE (z1)); - mpfr_set_prec (mpc_imagref(z3), MPC_PREC_IM (z1)); - inex = function.pointer.CCU (z3, z2, ui, rnd); - if (!MPC_INEX_CMP (inex_re, inex_im, inex) - || !same_mpc_value (z3, z1, signs)) - { - /* display sensible variable names */ - mpc_t op1, got, expected; - op1[0] = z2[0]; - expected[0]= z1[0]; - got[0] = z3[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); - printf ("op2 %lu\n ", ui); - MPC_OUT (got); - MPC_OUT (expected); - - exit (1); - } - break; - - case CCS: /* example mpc_pow_si */ - read_ccs (fp, &inex_re, &inex_im, z1, &signs, z2, &si, &rnd); - mpfr_set_prec (mpc_realref(z3), MPC_PREC_RE (z1)); - mpfr_set_prec (mpc_imagref(z3), MPC_PREC_IM (z1)); - inex = function.pointer.CCS (z3, z2, si, rnd); - if (!MPC_INEX_CMP (inex_re, inex_im, inex) - || !same_mpc_value (z3, z1, signs)) - { - /* display sensible variable names */ - mpc_t op1, got, expected; - op1[0] = z2[0]; - expected[0]= z1[0]; - got[0] = z3[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); - printf ("op2 %li\n ", si); - MPC_OUT (got); - MPC_OUT (expected); - - exit (1); - } - break; - - default: - printf ("Unhandled function prototype %i in 'data_check'\n", function.type); - exit (1); - } - - /* check MPFR flags were not modified */ - check_mpfr_flags (rand_counter); - rand_counter ++; - } - - /* 3. Clear used variables */ - mpc_clear (z1); - switch (function.type) - { - case FC: - mpfr_clear (x1); - mpfr_clear (x2); - break; - case CC: case CCU: case CCS: - mpc_clear (z2); - mpc_clear (z3); - break; - case C_CC: - mpc_clear (z2); - 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); - mpc_clear (z3); - break; - default: - ; - } - - close_data_file (fp); -} diff --git a/tests/read_description.c b/tests/read_description.c index f85a053..899a600 100644 --- a/tests/read_description.c +++ b/tests/read_description.c @@ -1,6 +1,6 @@ /* read_description.c -- read parameters from description file -Copyright (C) 2012 INRIA +Copyright (C) 2012, 2013 INRIA This file is part of GNU MPC. @@ -20,7 +20,6 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include #include "mpc-tests.h" -#include "templates.h" static size_t read_keyworddesc (mpc_datafile_context_t* datafile_context, char **buffer_ptr, size_t buffer_length); diff --git a/tests/read_line.c b/tests/read_line.c index ad52658..3fb29c5 100644 --- a/tests/read_line.c +++ b/tests/read_line.c @@ -18,7 +18,7 @@ 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" static void read_param (mpc_datafile_context_t* datafile_context, diff --git a/tests/rounding.c b/tests/rounding.c index 72b240a..603e627 100644 --- a/tests/rounding.c +++ b/tests/rounding.c @@ -18,7 +18,7 @@ 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" /* helper functions for iterating over mpfr rounding modes */ diff --git a/tests/setprec_parameters.c b/tests/setprec_parameters.c index c251cfd..2080867 100644 --- a/tests/setprec_parameters.c +++ b/tests/setprec_parameters.c @@ -18,7 +18,7 @@ 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" void set_output_precision (mpc_fun_param_t *params, mpfr_prec_t prec) diff --git a/tests/tabs.c b/tests/tabs.c index 4651089..afd33ee 100644 --- a/tests/tabs.c +++ b/tests/tabs.c @@ -1,6 +1,6 @@ /* tabs -- test file for mpc_abs. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,20 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpfr_inex = mpc_abs (P[1].mpfr, P[2].mpc, P[3].mpfr_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (FC, f, mpc_abs); - test_start (); - tgeneric (f, 2, 1024, 1, 0); - data_check (f, "abs.dat"); + data_check_template ("abs.dsc", "abs.dat"); + + tgeneric_template ("abs.dsc", 2, 1024, 1, 1024); test_end (); diff --git a/tests/tabs_tmpl.c b/tests/tabs_tmpl.c deleted file mode 100644 index c70e997..0000000 --- a/tests/tabs_tmpl.c +++ /dev/null @@ -1,41 +0,0 @@ -/* tabs_tmpl.c -- templated test file for mpc_abs. - -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" - -#define MPC_FUNCTION_CALL \ - P[0].mpfr_inex = mpc_abs (P[1].mpfr, P[2].mpc, P[3].mpfr_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("abs.dsc", "abs.dat"); - - tgeneric_template ("abs.dsc", 2, 1024, 1, 1024); - - test_end (); - - return 0; -} diff --git a/tests/tacos.c b/tests/tacos.c index 38653a4..6ad1cc6 100644 --- a/tests/tacos.c +++ b/tests/tacos.c @@ -1,6 +1,6 @@ /* tacos -- test file for mpc_acos. -Copyright (C) 2009 INRIA +Copyright (C) 2009, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_acos (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_acos (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_acos); - test_start (); - data_check (f, "acos.dat"); - tgeneric (f, 2, 512, 7, 7); + data_check_template ("acos.dsc", "acos.dat"); + + tgeneric_template ("acos.dsc", 2, 512, 7, 7); test_end (); diff --git a/tests/tacos_tmpl.c b/tests/tacos_tmpl.c deleted file mode 100644 index 3db6d2c..0000000 --- a/tests/tacos_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* tacos_tmpl -- templated test file for mpc_acos. - -Copyright (C) 2009, 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_acos (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_acos (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("acos.dsc", "acos.dat"); - - tgeneric_template ("acos.dsc", 2, 512, 7, 7); - - test_end (); - - return 0; -} diff --git a/tests/tacosh.c b/tests/tacosh.c index f8fbdc6..1ea1077 100644 --- a/tests/tacosh.c +++ b/tests/tacosh.c @@ -1,6 +1,6 @@ /* tacosh.c -- test file for mpc_acosh. -Copyright (C) 2009 INRIA +Copyright (C) 2009, 2013 INRIA This file is part of GNU MPC. @@ -39,17 +39,24 @@ bug20091120 (void) mpc_clear (y); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_acosh (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_acosh (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_acosh); - test_start (); bug20091120 (); - data_check (f, "acosh.dat"); - tgeneric (f, 2, 512, 7, 7); + data_check_template ("acosh.dsc", "acosh.dat"); + + tgeneric_template ("acosh.dsc", 2, 512, 7, 7); test_end (); diff --git a/tests/tacosh_tmpl.c b/tests/tacosh_tmpl.c deleted file mode 100644 index 82be18f..0000000 --- a/tests/tacosh_tmpl.c +++ /dev/null @@ -1,64 +0,0 @@ -/* tacosh.c -- templated test file for mpc_acosh. - -Copyright (C) 2009, 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" - -static void -bug20091120 (void) -{ - mpc_t x, y; - - mpc_init2 (x, 53); - mpc_init3 (y, 17, 42); - mpc_set_ui_ui (x, 1, 1, MPC_RNDNN); - mpc_acosh (y, x, MPC_RNDNN); - if (mpfr_get_prec (mpc_realref(y)) != 17 || - mpfr_get_prec (mpc_imagref(y)) != 42) - { - printf ("Error, mpc_acosh changed the precisions!!!\n"); - exit (1); - } - mpc_clear (x); - mpc_clear (y); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_acosh (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_acosh (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - bug20091120 (); - - data_check_template ("acosh.dsc", "acosh.dat"); - - tgeneric_template ("acosh.dsc", 2, 512, 7, 7); - - test_end (); - - return 0; -} diff --git a/tests/tadd.c b/tests/tadd.c index 11a305b..9654026 100644 --- a/tests/tadd.c +++ b/tests/tadd.c @@ -1,6 +1,6 @@ /* tadd -- test file for mpc_add. -Copyright (C) 2008, 2010, 2011, 2012 INRIA +Copyright (C) 2008, 2010, 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -52,17 +52,28 @@ check_ternary_value (void) mpc_clear (z); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_add (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_SYMMETRIC \ + P[0].mpc_inex = mpc_add (P[1].mpc, P[3].mpc, P[2].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_add (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP2 \ + P[0].mpc_inex = mpc_add (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (C_CC, f, mpc_add); - f.properties = FUNC_PROP_SYMETRIC; - test_start (); check_ternary_value(); - data_check (f, "add.dat"); - tgeneric (f, 2, 1024, 7, -1); + + data_check_template ("add.dsc", "add.dat"); + + tgeneric_template ("add.dsc", 2, 1024, 7, 128); test_end (); diff --git a/tests/tadd_fr.c b/tests/tadd_fr.c index 0f1a5cf..225a32d 100644 --- a/tests/tadd_fr.c +++ b/tests/tadd_fr.c @@ -1,6 +1,6 @@ /* tadd_fr -- test file for mpc_add_fr. -Copyright (C) 2008, 2010, 2012 INRIA +Copyright (C) 2008, 2010, 2012, 2013 INRIA This file is part of GNU MPC. @@ -56,17 +56,26 @@ check_ternary_value (mpfr_prec_t prec_max, mpfr_prec_t step) mpfr_clear (f); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_add_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_add_fr (P[1].mpc, P[1].mpc, P[3].mpfr, P[4].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCF, f, mpc_add_fr); test_start (); check_ternary_value (1024, 1); - data_check (f, "add_fr.dat"); - tgeneric (f, 2, 1024, 7, 10); + data_check_template ("add_fr.dsc", "add_fr.dat"); + + tgeneric_template ("add_fr.dsc", 2, 1024, 7, 128); test_end (); + return 0; } diff --git a/tests/tadd_fr_tmpl.c b/tests/tadd_fr_tmpl.c deleted file mode 100644 index 51661a8..0000000 --- a/tests/tadd_fr_tmpl.c +++ /dev/null @@ -1,79 +0,0 @@ -/* tadd_fr_tmpl.c -- templated test file for mpc_add_fr. - -Copyright (C) 2008, 2010, 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" - -static void -check_ternary_value (mpfr_prec_t prec_max, mpfr_prec_t step) -{ - mpfr_prec_t prec; - mpc_t z; - mpfr_t f; - - mpc_init2 (z, 2); - mpfr_init (f); - - for (prec = 2; prec < prec_max; prec += step) - { - mpc_set_prec (z, prec); - mpfr_set_prec (f, prec); - - mpc_set_ui (z, 1, MPC_RNDNN); - mpfr_set_ui (f, 1, GMP_RNDN); - if (mpc_add_fr (z, z, f, MPC_RNDNZ)) - { - printf ("Error in mpc_add_fr: 1+1 should be exact\n"); - exit (1); - } - - mpc_set_ui (z, 1, MPC_RNDNN); - mpc_mul_2ui (z, z, (unsigned long int) prec, MPC_RNDNN); - if (mpc_add_fr (z, z, f, MPC_RNDNN) == 0) - { - fprintf (stderr, "Error in mpc_add_fr: 2^prec+1 cannot be exact\n"); - exit (1); - } - } - mpc_clear (z); - mpfr_clear (f); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_add_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_add_fr (P[1].mpc, P[1].mpc, P[3].mpfr, P[4].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - check_ternary_value (1024, 1); - - data_check_template ("add_fr.dsc", "add_fr.dat"); - - tgeneric_template ("add_fr.dsc", 2, 1024, 7, 128); - - test_end (); - return 0; -} diff --git a/tests/tadd_si.c b/tests/tadd_si.c index 969f552..7bc1449 100644 --- a/tests/tadd_si.c +++ b/tests/tadd_si.c @@ -1,6 +1,6 @@ /* tadd_si -- test file for mpc_add_si. -Copyright (C) 2011, 2012 INRIA +Copyright (C) 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -24,45 +24,51 @@ along with this program. If not, see http://www.gnu.org/licenses/ . static void check_ternary_value (void) { - mpfr_prec_t prec; - mpc_t z; - const long int s = -1; - - mpc_init2 (z, 2); - - for (prec=2; prec <= 1024; prec++) { - mpc_set_prec (z, prec); - mpc_set_ui (z, 3ul, MPC_RNDNN); - if (mpc_add_si (z, z, s, MPC_RNDDU)) { - printf ("Error in mpc_add_si: 3+(-1) should be exact\n"); - exit (1); - } - else if (mpc_cmp_si (z, 2l) != 0) { - printf ("Error in mpc_add_si: 3+(-1) should be 2\n"); - exit (1); - } - - mpc_mul_2ui (z, z, (unsigned long int) prec, MPC_RNDNN); - if (mpc_add_si (z, z, s, MPC_RNDNN) == 0) { - printf ("Error in mpc_add_si: 2^(prec+1)-1 cannot be exact\n"); - exit (1); - } + mpfr_prec_t prec; + mpc_t z; + const long int s = -1; + + mpc_init2 (z, 2); + + for (prec=2; prec <= 1024; prec++) { + mpc_set_prec (z, prec); + mpc_set_ui (z, 3ul, MPC_RNDNN); + if (mpc_add_si (z, z, s, MPC_RNDDU)) { + printf ("Error in mpc_add_si: 3+(-1) should be exact\n"); + exit (1); } + else if (mpc_cmp_si (z, 2l) != 0) { + printf ("Error in mpc_add_si: 3+(-1) should be 2\n"); + exit (1); + } + + mpc_mul_2ui (z, z, (unsigned long int) prec, MPC_RNDNN); + if (mpc_add_si (z, z, s, MPC_RNDNN) == 0) { + printf ("Error in mpc_add_si: 2^(prec+1)-1 cannot be exact\n"); + exit (1); + } + } - mpc_clear (z); + mpc_clear (z); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_add_si (P[1].mpc, P[2].mpc, P[3].si, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_add_si (P[1].mpc, P[1].mpc, P[3].si, P[4].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCS, f, mpc_add_si); + test_start (); - test_start (); + check_ternary_value (); - check_ternary_value (); - tgeneric (f, 2, 1024, 11, -2); + tgeneric_template ("add_si.dsc", 2, 1024, 1, 1024); - test_end (); + test_end (); - return 0; + return 0; } diff --git a/tests/tadd_si_tmpl.c b/tests/tadd_si_tmpl.c deleted file mode 100644 index 7e82626..0000000 --- a/tests/tadd_si_tmpl.c +++ /dev/null @@ -1,74 +0,0 @@ -/* tadd_si_tmpl.c -- templated test file for mpc_add_si. - -Copyright (C) 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 -#include "templates.h" - -static void -check_ternary_value (void) -{ - mpfr_prec_t prec; - mpc_t z; - const long int s = -1; - - mpc_init2 (z, 2); - - for (prec=2; prec <= 1024; prec++) { - mpc_set_prec (z, prec); - mpc_set_ui (z, 3ul, MPC_RNDNN); - if (mpc_add_si (z, z, s, MPC_RNDDU)) { - printf ("Error in mpc_add_si: 3+(-1) should be exact\n"); - exit (1); - } - else if (mpc_cmp_si (z, 2l) != 0) { - printf ("Error in mpc_add_si: 3+(-1) should be 2\n"); - exit (1); - } - - mpc_mul_2ui (z, z, (unsigned long int) prec, MPC_RNDNN); - if (mpc_add_si (z, z, s, MPC_RNDNN) == 0) { - printf ("Error in mpc_add_si: 2^(prec+1)-1 cannot be exact\n"); - exit (1); - } - } - - mpc_clear (z); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_add_si (P[1].mpc, P[2].mpc, P[3].si, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_add_si (P[1].mpc, P[1].mpc, P[3].si, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - check_ternary_value (); - - tgeneric_template ("add_si.dsc", 2, 1024, 1, 1024); - - test_end (); - - return 0; -} diff --git a/tests/tadd_tmpl.c b/tests/tadd_tmpl.c deleted file mode 100644 index 044cb33..0000000 --- a/tests/tadd_tmpl.c +++ /dev/null @@ -1,80 +0,0 @@ -/* tadd_tmpl.c -- templated test file for mpc_add. - -Copyright (C) 2008, 2010, 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" - -static void -check_ternary_value (void) -{ - mpc_t x, y, z; - mpfr_prec_t prec; - - mpc_init2 (x, 2); - mpc_init2 (y, 2); - mpc_init2 (z, 2); - - for (prec = 2; prec <= 1000; prec++) - { - mpc_set_prec (x, prec); - mpc_set_prec (y, prec); - - mpc_set_ui (x, 1, MPC_RNDNN); - mpc_mul_2ui (x, x, (unsigned long int) prec, MPC_RNDNN); - mpc_set_ui (y, 1, MPC_RNDNN); - - if (mpc_add (z, x, y, MPC_RNDNN) == 0) - { - fprintf (stderr, "Error in mpc_add: 2^(-prec)+1 cannot be exact\n"); - exit (1); - } - } - - mpc_clear (x); - mpc_clear (y); - mpc_clear (z); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_add (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_SYMMETRIC \ - P[0].mpc_inex = mpc_add (P[1].mpc, P[3].mpc, P[2].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_add (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP2 \ - P[0].mpc_inex = mpc_add (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - check_ternary_value(); - - data_check_template ("add.dsc", "add.dat"); - - tgeneric_template ("add.dsc", 2, 1024, 7, 128); - - test_end (); - - return 0; -} diff --git a/tests/tadd_ui.c b/tests/tadd_ui.c index 4f8efea..a62979d 100644 --- a/tests/tadd_ui.c +++ b/tests/tadd_ui.c @@ -1,6 +1,6 @@ /* tadd_ui -- test file for mpc_add_ui. -Copyright (C) 2008, 2010, 2012 INRIA +Copyright (C) 2008, 2010, 2012, 2013 INRIA This file is part of GNU MPC. @@ -52,15 +52,21 @@ check_ternary_value (void) mpc_clear (z); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_add_ui (P[1].mpc, P[2].mpc, P[3].ui, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_add_ui (P[1].mpc, P[1].mpc, P[3].ui, P[4].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCU, f, mpc_add_ui); - test_start (); check_ternary_value (); - tgeneric (f, 2, 1024, 7, -1); + + tgeneric_template ("add_ui.dsc", 2, 1024, 1, 1024); test_end (); diff --git a/tests/tadd_ui_tmpl.c b/tests/tadd_ui_tmpl.c deleted file mode 100644 index b1bf5cb..0000000 --- a/tests/tadd_ui_tmpl.c +++ /dev/null @@ -1,74 +0,0 @@ -/* tadd_ui_tmpl.c -- templated test file for mpc_add_ui. - -Copyright (C) 2008, 2010, 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 -#include "templates.h" - -static void -check_ternary_value (void) -{ - mpfr_prec_t prec; - mpc_t z; - - mpc_init2 (z, 2); - - for (prec=2; prec <= 1024; prec++) - { - mpc_set_prec (z, prec); - - mpc_set_ui (z, 1, MPC_RNDNN); - if (mpc_add_ui (z, z, 1, MPC_RNDNZ)) - { - printf ("Error in mpc_add_ui: 1+1 should be exact\n"); - exit (1); - } - - mpc_set_ui (z, 1, MPC_RNDNN); - mpc_mul_2ui (z, z, (unsigned long int) prec, MPC_RNDNN); - if (mpc_add_ui (z, z, 1, MPC_RNDNN) == 0) - { - printf ("Error in mpc_add_ui: 2^prec+1 cannot be exact\n"); - exit (1); - } - } - - mpc_clear (z); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_add_ui (P[1].mpc, P[2].mpc, P[3].ui, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_add_ui (P[1].mpc, P[1].mpc, P[3].ui, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - check_ternary_value (); - - tgeneric_template ("add_ui.dsc", 2, 1024, 1, 1024); - - test_end (); - - return 0; -} diff --git a/tests/targ.c b/tests/targ.c index b84c292..84b027f 100644 --- a/tests/targ.c +++ b/tests/targ.c @@ -1,6 +1,6 @@ /* targ -- test file for mpc_arg. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,20 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpfr_inex = mpc_arg (P[1].mpfr, P[2].mpc, P[3].mpfr_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (FC, f, mpc_arg); - test_start (); - tgeneric (f, 2, 1024, 1, 4096); - data_check (f, "arg.dat"); + data_check_template ("arg.dsc", "arg.dat"); + + tgeneric_template ("arg.dsc", 2, 1024, 1, 4096); test_end (); diff --git a/tests/targ_tmpl.c b/tests/targ_tmpl.c deleted file mode 100644 index 690bea1..0000000 --- a/tests/targ_tmpl.c +++ /dev/null @@ -1,41 +0,0 @@ -/* targ_tmpl -- templated test file for mpc_arg. - -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" - -#define MPC_FUNCTION_CALL \ - P[0].mpfr_inex = mpc_arg (P[1].mpfr, P[2].mpc, P[3].mpfr_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("arg.dsc", "arg.dat"); - - tgeneric_template ("arg.dsc", 2, 1024, 1, 4096); - - test_end (); - - return 0; -} diff --git a/tests/tasin.c b/tests/tasin.c index 3470408..612cd47 100644 --- a/tests/tasin.c +++ b/tests/tasin.c @@ -1,6 +1,6 @@ /* tasin -- test file for mpc_asin. -Copyright (C) 2009 INRIA +Copyright (C) 2009, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_asin (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_asin (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_asin); - test_start (); - data_check (f, "asin.dat"); - tgeneric (f, 2, 512, 7, 7); + data_check_template ("asin.dsc", "asin.dat"); + + tgeneric_template ("asin.dsc", 2, 512, 7, 7); test_end (); diff --git a/tests/tasin_tmpl.c b/tests/tasin_tmpl.c deleted file mode 100644 index 13f4e2e..0000000 --- a/tests/tasin_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* tasin_tmpl -- templated test file for mpc_asin. - -Copyright (C) 2009, 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_asin (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_asin (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("asin.dsc", "asin.dat"); - - tgeneric_template ("asin.dsc", 2, 512, 7, 7); - - test_end (); - - return 0; -} diff --git a/tests/tasinh.c b/tests/tasinh.c index c266829..207aa54 100644 --- a/tests/tasinh.c +++ b/tests/tasinh.c @@ -1,6 +1,6 @@ /* tasinh -- test file for mpc_asinh. -Copyright (C) 2009 INRIA +Copyright (C) 2009, 2013 INRIA This file is part of GNU MPC. @@ -39,17 +39,24 @@ bug20091120 (void) mpc_clear (y); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_asinh (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_asinh (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_asinh); - test_start (); bug20091120 (); - data_check (f, "asinh.dat"); - tgeneric (f, 2, 512, 7, 7); + data_check_template ("asinh.dsc", "asinh.dat"); + + tgeneric_template ("asinh.dsc", 2, 512, 7, 7); test_end (); diff --git a/tests/tasinh_tmpl.c b/tests/tasinh_tmpl.c deleted file mode 100644 index c046d51..0000000 --- a/tests/tasinh_tmpl.c +++ /dev/null @@ -1,64 +0,0 @@ -/* tasinh_tmpl -- templated test file for mpc_asinh. - -Copyright (C) 2009, 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" - -static void -bug20091120 (void) -{ - mpc_t x, y; - - mpc_init2 (x, 53); - mpc_init3 (y, 17, 42); - mpc_set_ui_ui (x, 1, 1, MPC_RNDNN); - mpc_asinh (y, x, MPC_RNDNN); - if (mpfr_get_prec (mpc_realref(y)) != 17 || - mpfr_get_prec (mpc_imagref(y)) != 42) - { - printf ("Error, mpc_asinh changed the precisions!!!\n"); - exit (1); - } - mpc_clear (x); - mpc_clear (y); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_asinh (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_asinh (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - bug20091120 (); - - data_check_template ("asinh.dsc", "asinh.dat"); - - tgeneric_template ("asinh.dsc", 2, 512, 7, 7); - - test_end (); - - return 0; -} diff --git a/tests/tatan.c b/tests/tatan.c index ca93ec4..fcb7e4d 100644 --- a/tests/tatan.c +++ b/tests/tatan.c @@ -1,6 +1,6 @@ /* tatan -- test file for mpc_atan. -Copyright (C) 2009, 2012 INRIA +Copyright (C) 2009, 2012, 2013 INRIA This file is part of GNU MPC. @@ -50,16 +50,22 @@ test_underflow (void) } #endif +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_atan (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_atan (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" int main (void) { - DECL_FUNC (CC, f, mpc_atan); - test_start (); - data_check (f, "atan.dat"); - tgeneric (f, 2, 512, 5, 128); + data_check_template ("atan.dsc", "atan.dat"); + + tgeneric_template ("atan.dsc", 2, 512, 5, 128); test_end (); diff --git a/tests/tatan_tmpl.c b/tests/tatan_tmpl.c deleted file mode 100644 index e6d6688..0000000 --- a/tests/tatan_tmpl.c +++ /dev/null @@ -1,74 +0,0 @@ -/* tatan_tmpl -- templated test file for mpc_atan. - -Copyright (C) 2009, 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" - -#if 0 -/* tests intermediate underflow; WONTFIX */ -static int -test_underflow (void) -{ - mpc_t z; - mpfr_exp_t emin = mpfr_get_emin (); - - mpfr_set_emin (-10); - mpc_init2 (z, 21); - mpfr_set_si (mpc_realref(z), -1, MPFR_RNDZ); - mpfr_set_ui_2exp (mpc_imagref(z), 1, 20, MPFR_RNDZ); - mpfr_add_ui (mpc_imagref(z), mpc_imagref(z), 1, MPFR_RNDZ); - mpfr_div_2exp (mpc_imagref(z), mpc_imagref(z), 20, MPFR_RNDZ); - mpc_atan (z, z, MPC_RNDNN); - if (mpfr_cmp_si_2exp (mpc_realref(z), -1066635, 20) != 0 || - mpfr_cmp_si_2exp (mpc_imagref(z), 1687619, 22)) - { - printf ("Error in test_coverage\n"); - printf ("expected (-1066635/2^20 1687619/2^22)\n"); - printf ("got "); - mpc_out_str (stdout, 10, 20, z, MPC_RNDNN); - printf ("\n"); - exit (1); - } - mpc_clear (z); - mpfr_set_emin (emin); -} -#endif - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_atan (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_atan (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("atan.dsc", "atan.dat"); - - tgeneric_template ("atan.dsc", 2, 512, 5, 128); - - test_end (); - - return 0; -} - diff --git a/tests/tatanh.c b/tests/tatanh.c index ddba68c..188b772 100644 --- a/tests/tatanh.c +++ b/tests/tatanh.c @@ -1,6 +1,6 @@ /* tatanh -- test file for mpc_atanh. -Copyright (C) 2009 INRIA +Copyright (C) 2009, 2013 INRIA This file is part of GNU MPC. @@ -39,17 +39,24 @@ bug20091120 (void) mpc_clear (y); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_atanh (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_atanh (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_atanh); - test_start (); bug20091120 (); - data_check (f, "atanh.dat"); - tgeneric (f, 2, 512, 5, 128); + data_check_template ("atanh.dsc", "atanh.dat"); + + tgeneric_template ("atanh.dsc", 2, 512, 5, 128); test_end (); diff --git a/tests/tatanh_tmpl.c b/tests/tatanh_tmpl.c deleted file mode 100644 index 6c4fcc9..0000000 --- a/tests/tatanh_tmpl.c +++ /dev/null @@ -1,64 +0,0 @@ -/* tatanh_tmpl -- templated test file for mpc_atanh. - -Copyright (C) 2009, 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" - -static void -bug20091120 (void) -{ - mpc_t x, y; - - mpc_init2 (x, 53); - mpc_init3 (y, 17, 42); - mpc_set_ui_ui (x, 1, 1, MPC_RNDNN); - mpc_atanh (y, x, MPC_RNDNN); - if (mpfr_get_prec (mpc_realref(y)) != 17 || - mpfr_get_prec (mpc_imagref(y)) != 42) - { - printf ("Error, mpc_atanh changed the precisions!!!\n"); - exit (1); - } - mpc_clear (x); - mpc_clear (y); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_atanh (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_atanh (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - bug20091120 (); - - data_check_template ("atanh.dsc", "atanh.dat"); - - tgeneric_template ("atanh.dsc", 2, 512, 5, 128); - - test_end (); - - return 0; -} diff --git a/tests/tconj.c b/tests/tconj.c index 949a80b..c179135 100644 --- a/tests/tconj.c +++ b/tests/tconj.c @@ -1,6 +1,6 @@ /* tconj -- test file for mpc_conj. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_conj (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_conj (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_conj); - test_start (); - data_check (f, "conj.dat"); - tgeneric (f, 2, 1024, 1, 0); + data_check_template ("conj.dsc", "conj.dat"); + + tgeneric_template ("conj.dsc", 2, 1024, 1, 0); test_end (); diff --git a/tests/tconj_tmpl.c b/tests/tconj_tmpl.c deleted file mode 100644 index d875ad9..0000000 --- a/tests/tconj_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* tconj_tmpl -- templated test file for mpc_conj. - -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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_conj (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_conj (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("conj.dsc", "conj.dat"); - - tgeneric_template ("conj.dsc", 2, 1024, 1, 0); - - test_end (); - - return 0; -} diff --git a/tests/tcos.c b/tests/tcos.c index dafc01d..bfd7a76 100644 --- a/tests/tcos.c +++ b/tests/tcos.c @@ -1,6 +1,6 @@ /* tcos -- test file for mpc_cos. -Copyright (C) 2008, 2009, 2011, 2012 INRIA +Copyright (C) 2008, 2009, 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -47,17 +47,24 @@ bug20090105 (void) mpc_clear (op); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_cos (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_cos (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_cos); - test_start (); - data_check (f, "cos.dat"); - tgeneric (f, 2, 512, 7, 7); + data_check_template ("cos.dsc", "cos.dat"); + + tgeneric_template ("cos.dsc", 2, 512, 7, 7); - bug20090105 (); + bug20090105 (); /* TODO: move data in cos.dat */ test_end (); diff --git a/tests/tcos_tmpl.c b/tests/tcos_tmpl.c deleted file mode 100644 index 66fb76f..0000000 --- a/tests/tcos_tmpl.c +++ /dev/null @@ -1,72 +0,0 @@ -/* tcos_tmpl -- templated test file for mpc_cos. - -Copyright (C) 2008, 2009, 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" - -static void -bug20090105 (void) -{ - /* this bug appeared on 32-bits machines */ - mpc_t op, expected, got; - mpc_init2 (op, 324); - mpc_init2 (expected, 324); - mpc_init2 (got, 324); - - mpfr_set_str (mpc_realref(op), "-3.f1813b1487372434fea4414a520f65a343a16d0ec1ffb" - "b2b880154db8d63377ce788fc4215c450300@1", 16, MPFR_RNDN); - mpfr_set_str (mpc_imagref(op), "-2.b7a0c80bcacf1ccbbac614bf53a58b672b1b503161bee" - "59a82e46a23570b652f7ba5f01ef766d1c50", 16,MPFR_RNDN); - mpfr_set_str (mpc_realref(expected), "7.57c5b08a2b11b660d906a354289b0724b9c4b237" - "95abe33424e8d9858e534bd5d776ddd18e34b0240", 16, MPFR_RNDN); - mpfr_set_str (mpc_imagref(expected), "-1.f41a389646d068e0263561cb3c5d1df763945ad" - "ed9339f2a98387a3c4f97dbfd8a08b7d0af2f11b46", 16,MPFR_RNDN); - - mpc_cos (got, op, MPC_RNDNN); - if (mpc_cmp (got, expected) != 0) - TEST_FAILED ("mpc_cos", op, got, expected, MPC_RNDNN); - - mpc_clear (got); - mpc_clear(expected); - mpc_clear (op); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_cos (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_cos (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("cos.dsc", "cos.dat"); - - tgeneric_template ("cos.dsc", 2, 512, 7, 7); - - bug20090105 (); /* TODO: move data in cos.dat */ - - test_end (); - - return 0; -} diff --git a/tests/tcosh.c b/tests/tcosh.c index 0d6a9da..8c04653 100644 --- a/tests/tcosh.c +++ b/tests/tcosh.c @@ -1,6 +1,6 @@ -/* test file for mpc_cosh. +/* tcosh -- test file for mpc_cosh. -Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA +Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -115,16 +115,23 @@ pure_imaginary_argument (void) mpc_clear (u); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_cosh (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_cosh (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" int main (void) { - DECL_FUNC(CC, f,mpc_cosh); - test_start (); - data_check (f, "cosh.dat"); - tgeneric (f, 2, 512, 7, 7); + data_check_template ("cosh.dsc", "cosh.dat"); + + tgeneric_template ("cosh.dsc", 2, 512, 7, 7); + /* FIXME: remove the following tests? (Now tested by tgeneric) */ pure_real_argument (); pure_imaginary_argument (); diff --git a/tests/tcosh_tmpl.c b/tests/tcosh_tmpl.c deleted file mode 100644 index 344f25b..0000000 --- a/tests/tcosh_tmpl.c +++ /dev/null @@ -1,141 +0,0 @@ -/* tcosh_tmpl -- test file for mpc_cosh. - -Copyright (C) 2008, 2009, 2010, 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 -#include "templates.h" - -static void -pure_real_argument (void) -{ - /* cosh(x -i*0) = cosh(x) +i*0 if x<0 */ - /* cosh(x -i*0) = cosh(x) -i*0 if x>0 */ - /* cosh(x +i*0) = cosh(x) -i*0 if x<0 */ - /* cosh(x -i*0) = cosh(x) +i*0 if x>0 */ - mpc_t u; - mpc_t z; - mpc_t cosh_z; - - mpc_init2 (z, 2); - mpc_init2 (u, 100); - mpc_init2 (cosh_z, 100); - - /* cosh(1 +i*0) = cosh(1) +i*0 */ - mpc_set_ui_ui (z, 1, 0, MPC_RNDNN); - mpfr_cosh (mpc_realref (u), mpc_realref (z), MPFR_RNDN); - mpfr_set_ui (mpc_imagref (u), 0, MPFR_RNDN); - mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); - - /* cosh(1 -i*0) = cosh(1) -i*0 */ - mpc_conj (z, z, MPC_RNDNN); - mpc_conj (u, u, MPC_RNDNN); - mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); - - /* cosh(-1 +i*0) = cosh(1) -i*0 */ - mpc_neg (z, z, MPC_RNDNN); - mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); - - /* cosh(-1 -i*0) = cosh(1) +i*0 */ - mpc_conj (z, z, MPC_RNDNN); - mpc_conj (u, u, MPC_RNDNN); - mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); - - mpc_clear (cosh_z); - mpc_clear (z); - mpc_clear (u); -} - -static void -pure_imaginary_argument (void) -{ - /* cosh(+0 +i*y) = cos y +i*0*sin y */ - /* cosh(-0 +i*y) = cos y -i*0*sin y */ - mpc_t u; - mpc_t z; - mpc_t cosh_z; - - mpc_init2 (z, 2); - mpc_init2 (u, 100); - mpc_init2 (cosh_z, 100); - - /* cosh(+0 +i) = cos(1) + i*0 */ - mpc_set_ui_ui (z, 0, 1, MPC_RNDNN); - mpfr_cos (mpc_realref (u), mpc_imagref (z), MPFR_RNDN); - mpfr_set_ui (mpc_imagref (u), 0, MPFR_RNDN); - mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); - - /* cosh(+0 -i) = cos(1) - i*0 */ - mpc_conj (z, z, MPC_RNDNN); - mpc_conj (u, u, MPC_RNDNN); - mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); - - /* cosh(-0 +i) = cos(1) - i*0 */ - mpc_neg (z, z, MPC_RNDNN); - mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || !mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); - - /* cosh(-0 -i) = cos(1) + i*0 */ - mpc_conj (z, z, MPC_RNDNN); - mpc_conj (u, u, MPC_RNDNN); - mpc_cosh (cosh_z, z, MPC_RNDNN); - if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z))) - TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); - - mpc_clear (cosh_z); - mpc_clear (z); - mpc_clear (u); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_cosh (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_cosh (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" -int -main (void) -{ - test_start (); - - data_check_template ("cosh.dsc", "cosh.dat"); - - tgeneric_template ("cosh.dsc", 2, 512, 7, 7); - - /* FIXME: remove the following tests? (Now tested by tgeneric) */ - pure_real_argument (); - pure_imaginary_argument (); - - test_end (); - - return 0; -} diff --git a/tests/tdiv.c b/tests/tdiv.c index 3b8340f..51ffb39 100644 --- a/tests/tdiv.c +++ b/tests/tdiv.c @@ -1,6 +1,6 @@ /* tdiv -- test file for mpc_div. -Copyright (C) 2002, 2008, 2009, 2011 INRIA +Copyright (C) 2002, 2008, 2009, 2011, 2013 INRIA This file is part of GNU MPC. @@ -21,16 +21,26 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_div (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_div (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP2 \ + P[0].mpc_inex = mpc_div (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (C_CC, f, mpc_div); - test_start (); - data_check (f, "div.dat"); - tgeneric (f, 2, 1024, 7, 4096); + data_check_template ("div.dsc", "div.dat"); + + tgeneric_template ("div.dsc", 2, 1024, 7, 4096); test_end (); + return 0; } diff --git a/tests/tdiv_2si.c b/tests/tdiv_2si.c index 5046201..2b34aec 100644 --- a/tests/tdiv_2si.c +++ b/tests/tdiv_2si.c @@ -1,6 +1,6 @@ /* tdiv_2si -- test file for mpc_div_2si. -Copyright (C) 2012 INRIA +Copyright (C) 2012, 2013 INRIA This file is part of GNU MPC. @@ -20,14 +20,19 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_div_2si (P[1].mpc, P[2].mpc, P[3].si, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_div_2si (P[1].mpc, P[1].mpc, P[3].si, P[4].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCS, f, mpc_div_2si); - test_start (); - tgeneric (f, 2, 1024, 7, -1); + tgeneric_template ("div_2si.dsc", 2, 1024, 7, 1024); test_end (); diff --git a/tests/tdiv_2si_tmpl.c b/tests/tdiv_2si_tmpl.c deleted file mode 100644 index b2f4a86..0000000 --- a/tests/tdiv_2si_tmpl.c +++ /dev/null @@ -1,40 +0,0 @@ -/* tdiv_2si_tmpl.c -- templated test file for mpc_div_2si. - -Copyright (C) 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_div_2si (P[1].mpc, P[2].mpc, P[3].si, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_div_2si (P[1].mpc, P[1].mpc, P[3].si, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - tgeneric_template ("div_2si.dsc", 2, 1024, 7, 1024); - - test_end (); - - return 0; -} diff --git a/tests/tdiv_2ui.c b/tests/tdiv_2ui.c index 6cc8f14..8c6a7f4 100644 --- a/tests/tdiv_2ui.c +++ b/tests/tdiv_2ui.c @@ -1,6 +1,6 @@ /* tdiv_2ui -- test file for mpc_div_2ui. -Copyright (C) 2008, 2012 INRIA +Copyright (C) 2008, 2012, 2013 INRIA This file is part of GNU MPC. @@ -20,14 +20,19 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_div_2ui (P[1].mpc, P[2].mpc, P[3].ui, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_div_2ui (P[1].mpc, P[1].mpc, P[3].ui, P[4].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCU, f, mpc_div_2ui); - test_start (); - tgeneric (f, 2, 1024, 7, -1); + tgeneric_template ("div_2ui.dsc", 2, 1024, 7, 1024); test_end (); diff --git a/tests/tdiv_2ui_tmpl.c b/tests/tdiv_2ui_tmpl.c deleted file mode 100644 index 7d90cf6..0000000 --- a/tests/tdiv_2ui_tmpl.c +++ /dev/null @@ -1,41 +0,0 @@ -/* tdiv_2ui_tmpl.c -- templated test file for mpc_div_2ui. - -Copyright (C) 2008, 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_div_2ui (P[1].mpc, P[2].mpc, P[3].ui, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_div_2ui (P[1].mpc, P[1].mpc, P[3].ui, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - tgeneric_template ("div_2ui.dsc", 2, 1024, 7, 1024); - - test_end (); - - return 0; -} diff --git a/tests/tdiv_fr.c b/tests/tdiv_fr.c index 21e677e..a56f701 100644 --- a/tests/tdiv_fr.c +++ b/tests/tdiv_fr.c @@ -1,6 +1,6 @@ -/* test file for mpc_div_fr. +/* tdiv_fr.c -- test file for mpc_div_fr. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_div_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_div_fr (P[1].mpc, P[1].mpc, P[3].mpfr, P[4].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCF, f, mpc_div_fr); - test_start (); - data_check (f, "div_fr.dat"); - tgeneric (f, 2, 1024, 7, -1); + data_check_template ("div_fr.dsc", "div_fr.dat"); + + tgeneric_template ("div_fr.dsc", 2, 1024, 7, 1024); test_end (); diff --git a/tests/tdiv_fr_tmpl.c b/tests/tdiv_fr_tmpl.c deleted file mode 100644 index 4f96fb3..0000000 --- a/tests/tdiv_fr_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* tdiv_fr_tmpl -- templated test file for mpc_div_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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_div_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_div_fr (P[1].mpc, P[1].mpc, P[3].mpfr, P[4].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("div_fr.dsc", "div_fr.dat"); - - tgeneric_template ("div_fr.dsc", 2, 1024, 7, 1024); - - test_end (); - - return 0; -} diff --git a/tests/tdiv_tmpl.c b/tests/tdiv_tmpl.c deleted file mode 100644 index e70f5e2..0000000 --- a/tests/tdiv_tmpl.c +++ /dev/null @@ -1,46 +0,0 @@ -/* tdiv_tmpl -- templated test file for mpc_div. - -Copyright (C) 2002, 2008, 2009, 2011, 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 -#include "templates.h" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_div (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_div (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP2 \ - P[0].mpc_inex = mpc_div (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("div.dsc", "div.dat"); - - tgeneric_template ("div.dsc", 2, 1024, 7, 4096); - - test_end (); - - return 0; -} diff --git a/tests/tdiv_ui.c b/tests/tdiv_ui.c index 5e62d57..1455730 100644 --- a/tests/tdiv_ui.c +++ b/tests/tdiv_ui.c @@ -1,6 +1,6 @@ -/* test file for mpc_div_ui. +/* tdiv_ui.c -- test file for mpc_div_ui. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,14 +20,19 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_div_ui (P[1].mpc, P[2].mpc, P[3].ui, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_div_ui (P[1].mpc, P[1].mpc, P[3].ui, P[4].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCU, f, mpc_div_ui); - test_start (); - tgeneric (f, 2, 1024, 7, -1); + tgeneric_template ("div_ui.dsc", 2, 1024, 7, -1); test_end (); diff --git a/tests/tdiv_ui_tmpl.c b/tests/tdiv_ui_tmpl.c deleted file mode 100644 index c528f55..0000000 --- a/tests/tdiv_ui_tmpl.c +++ /dev/null @@ -1,40 +0,0 @@ -/* tdiv_ui_tmpl.c -- templated test file for mpc_div_ui. - -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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_div_ui (P[1].mpc, P[2].mpc, P[3].ui, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_div_ui (P[1].mpc, P[1].mpc, P[3].ui, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - tgeneric_template ("div_ui.dsc", 2, 1024, 7, -1); - - test_end (); - - return 0; -} diff --git a/tests/templates.h b/tests/templates.h deleted file mode 100644 index 404ca0f..0000000 --- a/tests/templates.h +++ /dev/null @@ -1,225 +0,0 @@ -/* templates.h -- Templated parameters functions. - -Copyright (C) 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/ . -*/ - -#ifndef __TEMPLATES_H -#define __TEMPLATES_H - -#include -#include -#include "config.h" -#include "mpc-tests.h" - -/* - function descriptions -*/ - -/* type for return, output and input parameters */ -typedef enum { - NATIVE_INT, /* int */ - NATIVE_UL, /* unsigned long */ - NATIVE_L, /* signed long */ - NATIVE_D, /* double */ - NATIVE_LD, /* long double */ - NATIVE_DC, /* double _Complex */ - NATIVE_LDC, /* long double _Complex */ - NATIVE_IM, /* intmax_t */ - NATIVE_UIM, /* uintmax_t */ - NATIVE_STRING, /* char* */ - GMP_Z, /* mpz_t */ - GMP_Q, /* mpq_t */ - GMP_F, /* mpf_t */ - MPFR_INEX, /* mpfr_inex */ - MPFR, /* mpfr_t */ - MPFR_RND, /* mpfr_rnd_t */ - MPC_INEX, /* mpc_inex */ - MPC, /* mpc_t */ - MPC_RND /* mpc_rnd_t */ -} mpc_param_t; - -/* additional information for checking mpfr_t result */ -typedef struct { - mpfr_t mpfr; /* skip space for the variable */ - int known_sign; -} mpfr_data_t; - -#define TERNARY_NOT_CHECKED 255 -/* special value to indicate that the ternary value is not checked */ -#define TERNARY_ERROR 254 -/* special value to indicate that an error occurred in an mpc function */ - -/* mpc nonary value as a pair of ternary value for data from a file */ -typedef struct { - int real; - int imag; -} mpc_inex_data_t; - -/* additional information for checking mpc_t result */ -typedef struct { - mpc_t mpc; /* skip space */ - int known_sign_real; - int known_sign_imag; -} mpc_data_t; - -/* string buffer information */ -typedef struct { - char* string; /* skip space */ - int length; -} string_info_t; - -/* abstract parameter type - - Let consider an abstract parameter p, which is declared as follows: - mpc_operand_t p; - we use the fact that a mpfr_t (respectively mpc_t) value can be accessed as - 'p.mpfr' (resp. 'p.mpc') as well as 'p.mpfr_info.mpfr' - (resp. 'p.mpc_info.mpc'), the latter form permitting access to the - 'known_sign' field(s). - Similarly, if the abstract parameter represent a string variable, we can - access its value with 'p.string' or 'p.string_info.string' and its size - with 'p.string_info.length'. - - The user uses the simple form when adding a test, the second form is used by the - test suite itself when reading reference data and checking result against them. -*/ -typedef union { - int i; - unsigned long ui; - signed long si; - double d; - long double ld; -#ifdef _MPC_H_HAVE_INTMAX_T - intmax_t im; - uintmax_t uim; -#endif -#ifdef _Complex_I - double _Complex dc; - long double _Complex ldc; -#endif - char * string; - string_info_t string_info; - mpz_t mpz; - mpq_t mpq; - mpf_t mpf; - mpfr_t mpfr; - mpfr_data_t mpfr_data; - mpfr_rnd_t mpfr_rnd; - int mpfr_inex; - mpc_t mpc; - mpc_data_t mpc_data; - mpc_rnd_t mpc_rnd; - int mpc_inex; - mpc_inex_data_t mpc_inex_data; -} mpc_operand_t; - -#define PARAMETER_ARRAY_SIZE 10 - -/* function name plus parameters */ -typedef struct { - char *name; /* name of the function */ - int nbout; /* number of output parameters */ - int nbin; /* number of input parameters */ - mpc_operand_t P[PARAMETER_ARRAY_SIZE]; /* value of parameters */ - mpc_param_t T[PARAMETER_ARRAY_SIZE]; /* type of parameters */ -} mpc_fun_param_t; - - -void read_description (mpc_fun_param_t* param, const char *file); -const char* read_description_findname (mpc_param_t e); - -/* file functions */ -typedef struct { - char *pathname; - FILE *fd; - unsigned long line_number; - unsigned long test_line_number; - int nextchar; -} mpc_datafile_context_t; - -void open_datafile (mpc_datafile_context_t* datafile_context, - const char * data_filename); -void close_datafile (mpc_datafile_context_t *dc); - -/* data file functions */ -void read_line (mpc_datafile_context_t* datafile_context, - mpc_fun_param_t* params); -void check_data (mpc_datafile_context_t* datafile_context, - mpc_fun_param_t* params, - int index_reused_operand); - -/* parameters templated functions */ -int data_check_template (const char* descr_file, const char * data_file); - -void init_parameters (mpc_fun_param_t *params); -void clear_parameters (mpc_fun_param_t *params); -void print_parameter (mpc_fun_param_t *params, int index); -int copy_parameter (mpc_fun_param_t *params, - int index_dest, int index_src); - -void tpl_read_int (mpc_datafile_context_t* datafile_context, - int *nread, const char *name); -void tpl_read_ui (mpc_datafile_context_t* datafile_context, - unsigned long int *ui); -void tpl_read_si (mpc_datafile_context_t* datafile_context, - long int *si); -void tpl_read_mpz (mpc_datafile_context_t* datafile_context, - mpz_t z); -void tpl_skip_whitespace_comments (mpc_datafile_context_t* datafile_context); -void tpl_read_ternary (mpc_datafile_context_t* datafile_context, - int* ternary); -void tpl_read_mpfr (mpc_datafile_context_t* datafile_context, - mpfr_ptr x, int* known_sign); -void tpl_read_mpfr_rnd (mpc_datafile_context_t* datafile_context, - mpfr_rnd_t* rnd); -void tpl_read_mpfr_inex (mpc_datafile_context_t* datafile_context, - int *ternary); -void tpl_read_mpc_inex (mpc_datafile_context_t* datafile_context, - mpc_inex_data_t* ternarypair); -void tpl_read_mpc (mpc_datafile_context_t* datafile_context, - mpc_data_t* z); -void tpl_read_mpc_rnd (mpc_datafile_context_t* datafile_context, - mpc_rnd_t* rnd); - -int tpl_same_mpz_value (mpz_ptr n1, mpz_ptr n2); -int tpl_same_mpfr_value (mpfr_ptr x1, mpfr_ptr x2, int known_sign); -int tpl_check_mpfr_data (mpfr_t got, mpfr_data_t expected); -int tpl_check_mpc_data (mpc_ptr got, mpc_data_t expected); - -void tpl_copy_int (int *dest, const int * const src); -void tpl_copy_ui (unsigned long int *dest, - const unsigned long int * const src); -void tpl_copy_si (long int *dest, const long int * const src); -void tpl_copy_d (double *dest, const double * const src); -void tpl_copy_mpz (mpz_ptr dest, mpz_srcptr src); -void tpl_copy_mpfr (mpfr_ptr dest, mpfr_srcptr src); -void tpl_copy_mpc (mpc_ptr dest, mpc_srcptr src); - -int double_rounding (mpc_fun_param_t *params); - -/* iterating over rounding modes */ -void first_rnd_mode (mpc_fun_param_t *params); -int is_valid_rnd_mode (mpc_fun_param_t *params); -void next_rnd_mode (mpc_fun_param_t *params); - -/* parameter precision */ -void set_output_precision (mpc_fun_param_t *params, mpfr_prec_t prec); -void set_input_precision (mpc_fun_param_t *params, mpfr_prec_t prec); -void set_reference_precision (mpc_fun_param_t *params, mpfr_prec_t prec); - -#endif /*__TEMPLATES_H*/ diff --git a/tests/texp.c b/tests/texp.c index 0486cce..4415d3f 100644 --- a/tests/texp.c +++ b/tests/texp.c @@ -1,6 +1,6 @@ /* texp -- test file for mpc_exp. -Copyright (C) 2002, 2008 INRIA +Copyright (C) 2002, 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_exp (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_exp (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_exp); - test_start (); - data_check (f, "exp.dat"); - tgeneric (f, 2, 512, 7, 256); + data_check_template ("exp.dsc", "exp.dat"); + + tgeneric_template ("exp.dsc", 2, 512, 7, 256); test_end (); diff --git a/tests/texp_tmpl.c b/tests/texp_tmpl.c deleted file mode 100644 index c7c37e6..0000000 --- a/tests/texp_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* texp_tmpl -- templated test file for mpc_exp. - -Copyright (C) 2002, 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_exp (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_exp (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("exp.dsc", "exp.dat"); - - tgeneric_template ("exp.dsc", 2, 512, 7, 256); - - test_end (); - - return 0; -} diff --git a/tests/tfma.c b/tests/tfma.c index 81bc167..62a7b0c 100644 --- a/tests/tfma.c +++ b/tests/tfma.c @@ -1,6 +1,6 @@ /* tfma -- test file for mpc_fma. -Copyright (C) 2011, 2012 INRIA +Copyright (C) 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -88,18 +88,32 @@ check_random (void) mpc_clear (c); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = \ + mpc_fma (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc, P[5].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = \ + mpc_fma (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc, P[5].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP2 \ + P[0].mpc_inex = \ + mpc_fma (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc, P[5].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP3 \ + P[0].mpc_inex = \ + mpc_fma (P[1].mpc, P[2].mpc, P[3].mpc, P[1].mpc, P[5].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" int main (void) { - DECL_FUNC (CCCC, f, mpc_fma); - test_start (); - check_random (); + check_random (); /* Remove it? */ + + data_check_template ("fma.dsc", "fma.dat"); - data_check (f, "fma.dat"); - tgeneric (f, 2, 1024, 1, 256); + tgeneric_template ("fma.dsc", 2, 1024, 1, 256); test_end (); diff --git a/tests/tfma_tmpl.c b/tests/tfma_tmpl.c deleted file mode 100644 index cfc1ea3..0000000 --- a/tests/tfma_tmpl.c +++ /dev/null @@ -1,121 +0,0 @@ -/* tfma -- test file for mpc_fma. - -Copyright (C) 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" - -static void -cmpfma (mpc_srcptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rnd) - /* computes a*b+c with the naive and fast functions using the rounding - mode rnd and compares the results and return values. - In our current test suite, all input precisions are the same, and we - use this precision also for the result. - */ -{ - mpc_t z, t; - int inex_z, inex_t; - - mpc_init2 (z, MPC_MAX_PREC (a)); - mpc_init2 (t, MPC_MAX_PREC (a)); - - inex_z = mpc_fma_naive (z, a, b, c, rnd); - inex_t = mpc_fma (t, a, b, c, rnd); - - if (mpc_cmp (z, t) != 0 || inex_z != inex_t) { - fprintf (stderr, "fma_naive and fma differ for rnd=(%s,%s)\n", - mpfr_print_rnd_mode(MPC_RND_RE(rnd)), - mpfr_print_rnd_mode(MPC_RND_IM(rnd))); - MPC_OUT (a); - MPC_OUT (b); - MPC_OUT (c); - MPC_OUT (z); - MPC_OUT (t); - if (inex_z != inex_t) { - fprintf (stderr, "inex_re (z): %s\n", MPC_INEX_STR (inex_z)); - fprintf (stderr, "inex_re (t): %s\n", MPC_INEX_STR (inex_t)); - } - exit (1); - } - - mpc_clear (z); - mpc_clear (t); -} - - -static void -check_random (void) -{ - mpfr_prec_t prec; - int rnd_re, rnd_im; - mpc_t a, b, c; - - mpc_init2 (a, 1000); - mpc_init2 (b, 1000); - mpc_init2 (c, 1000); - - for (prec = 2; prec < 1000; prec = (mpfr_prec_t) (prec * 1.1 + 1)) { - mpc_set_prec (a, prec); - mpc_set_prec (b, prec); - mpc_set_prec (c, prec); - - test_default_random (a, -1024, 1024, 128, 0); - test_default_random (b, -1024, 1024, 128, 0); - test_default_random (c, -1024, 1024, 128, 0); - - for (rnd_re = 0; rnd_re < 4; rnd_re ++) - for (rnd_im = 0; rnd_im < 4; rnd_im ++) - cmpfma (a, b, c, MPC_RND (rnd_re, rnd_im)); - } - - mpc_clear (a); - mpc_clear (b); - mpc_clear (c); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = \ - mpc_fma (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc, P[5].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = \ - mpc_fma (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc, P[5].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP2 \ - P[0].mpc_inex = \ - mpc_fma (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc, P[5].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP3 \ - P[0].mpc_inex = \ - mpc_fma (P[1].mpc, P[2].mpc, P[3].mpc, P[1].mpc, P[5].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - check_random (); /* Remove it? */ - - data_check_template ("fma.dsc", "fma.dat"); - - tgeneric_template ("fma.dsc", 2, 1024, 1, 256); - - test_end (); - - return 0; -} diff --git a/tests/tfr_div.c b/tests/tfr_div.c index bea8a21..e257384 100644 --- a/tests/tfr_div.c +++ b/tests/tfr_div.c @@ -1,6 +1,6 @@ /* tfr_div -- test file for mpc_fr_div. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,24 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_fr_div (P[1].mpc, P[2].mpfr, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP2 \ + P[0].mpc_inex = mpc_fr_div (P[1].mpc, P[2].mpfr, P[1].mpc, P[4].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CFC, f, mpc_fr_div); test_start(); - data_check (f, "fr_div.dat"); - tgeneric (f, 2, 1024, 7, 65535); + data_check_template ("fr_div.dsc", "fr_div.dat"); + + tgeneric_template ("fr_div.dsc", 2, 1024, 7, 65535); test_end (); + return 0; } diff --git a/tests/tfr_div_tmpl.c b/tests/tfr_div_tmpl.c deleted file mode 100644 index 39e53a5..0000000 --- a/tests/tfr_div_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* tfr_div_tmpl -- templated test file for mpc_fr_div. - -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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_fr_div (P[1].mpc, P[2].mpfr, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP2 \ - P[0].mpc_inex = mpc_fr_div (P[1].mpc, P[2].mpfr, P[1].mpc, P[4].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start(); - - data_check_template ("fr_div.dsc", "fr_div.dat"); - - tgeneric_template ("fr_div.dsc", 2, 1024, 7, 65535); - - test_end (); - - return 0; -} diff --git a/tests/tfr_sub.c b/tests/tfr_sub.c index e366bc6..5665cc2 100644 --- a/tests/tfr_sub.c +++ b/tests/tfr_sub.c @@ -1,6 +1,6 @@ /* tfr_div -- test file for mpc_fr_sub. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,16 +20,24 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_fr_sub (P[1].mpc, P[2].mpfr, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP2 \ + P[0].mpc_inex = mpc_fr_sub (P[1].mpc, P[2].mpfr, P[1].mpc, P[4].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC(CFC, f, mpc_fr_sub); - test_start(); - data_check (f, "fr_sub.dat"); - tgeneric (f, 2, 4096, 7, 0); + data_check_template ("fr_sub.dsc", "fr_sub.dat"); + + tgeneric_template ("fr_sub.dsc", 2, 4096, 7, 1024); test_end (); + return 0; } diff --git a/tests/tfr_sub_tmpl.c b/tests/tfr_sub_tmpl.c deleted file mode 100644 index 7b295b4..0000000 --- a/tests/tfr_sub_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* tfr_div_tmpl -- template test file for mpc_fr_sub. - -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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_fr_sub (P[1].mpc, P[2].mpfr, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP2 \ - P[0].mpc_inex = mpc_fr_sub (P[1].mpc, P[2].mpfr, P[1].mpc, P[4].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start(); - - data_check_template ("fr_sub.dsc", "fr_sub.dat"); - - tgeneric_template ("fr_sub.dsc", 2, 4096, 7, 1024); - - test_end (); - - return 0; -} diff --git a/tests/tgeneric.c b/tests/tgeneric.c index cf56997..002ea91 100644 --- a/tests/tgeneric.c +++ b/tests/tgeneric.c @@ -851,16 +851,15 @@ reuse_cuuc (mpc_function* function, unsigned long ul1, unsigned long ul2, } } - /* helper functions for iterating over mpfr rounding modes */ static mpfr_rnd_t -first_rnd_mode (void) +first_rounding_mode (void) { return MPFR_RNDN; } static mpfr_rnd_t -next_rnd_mode (mpfr_rnd_t curr) +next_rounding_mode (mpfr_rnd_t curr) /* assumes that all rounding modes are non-negative, and returns -1 when curr is the last rounding mode */ { @@ -882,7 +881,7 @@ next_rnd_mode (mpfr_rnd_t curr) } static int -is_valid_rnd_mode (mpfr_rnd_t curr) +is_valid_rounding_mode (mpfr_rnd_t curr) /* returns 1 if curr is a valid rounding mode, and 0otherwise */ { if ( curr == MPFR_RNDN || curr == MPFR_RNDZ @@ -1282,17 +1281,17 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, } } - for (rnd_re = first_rnd_mode (); is_valid_rnd_mode (rnd_re); rnd_re = next_rnd_mode (rnd_re)) + for (rnd_re = first_rounding_mode (); is_valid_rounding_mode (rnd_re); rnd_re = next_rounding_mode (rnd_re)) switch (function.type) { case C_CC: - for (rnd_im = first_rnd_mode (); is_valid_rnd_mode (rnd_im); rnd_im = next_rnd_mode (rnd_im)) + for (rnd_im = first_rounding_mode (); is_valid_rounding_mode (rnd_im); rnd_im = next_rounding_mode (rnd_im)) tgeneric_c_cc (&function, z1, z2, z3, zzzz, z4, MPC_RND (rnd_re, rnd_im)); reuse_c_cc (&function, z1, z2, z3, z4); break; case CCCC: - for (rnd_im = first_rnd_mode (); is_valid_rnd_mode (rnd_im); rnd_im = next_rnd_mode (rnd_im)) + for (rnd_im = first_rounding_mode (); is_valid_rounding_mode (rnd_im); rnd_im = next_rounding_mode (rnd_im)) tgeneric_cccc (&function, z1, z2, z3, z4, zzzz, z5, MPC_RND (rnd_re, rnd_im)); reuse_cccc (&function, z1, z2, z3, z4, z5); @@ -1302,57 +1301,57 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, reuse_fc (&function, z1, z2, x1); break; case CC: - for (rnd_im = first_rnd_mode (); is_valid_rnd_mode (rnd_im); rnd_im = next_rnd_mode (rnd_im)) + for (rnd_im = first_rounding_mode (); is_valid_rounding_mode (rnd_im); rnd_im = next_rounding_mode (rnd_im)) tgeneric_cc (&function, z1, z2, zzzz, z3, MPC_RND (rnd_re, rnd_im)); reuse_cc (&function, z1, z2, z3); break; case CC_C: - for (rnd_im = first_rnd_mode (); is_valid_rnd_mode (rnd_im); rnd_im = next_rnd_mode (rnd_im)) - for (rnd2_re = first_rnd_mode (); is_valid_rnd_mode (rnd2_re); rnd2_re = next_rnd_mode (rnd2_re)) - for (rnd2_im = first_rnd_mode (); is_valid_rnd_mode (rnd2_im); rnd2_im = next_rnd_mode (rnd2_im)) + for (rnd_im = first_rounding_mode (); is_valid_rounding_mode (rnd_im); rnd_im = next_rounding_mode (rnd_im)) + for (rnd2_re = first_rounding_mode (); is_valid_rounding_mode (rnd2_re); rnd2_re = next_rounding_mode (rnd2_re)) + for (rnd2_im = first_rounding_mode (); is_valid_rounding_mode (rnd2_im); rnd2_im = next_rounding_mode (rnd2_im)) tgeneric_cc_c (&function, z1, z2, z3, zzzz, zzzz2, z4, z5, MPC_RND (rnd_re, rnd_im), MPC_RND (rnd2_re, rnd2_im)); reuse_cc_c (&function, z1, z2, z3, z4, z5); break; case CFC: - for (rnd_im = first_rnd_mode (); is_valid_rnd_mode (rnd_im); rnd_im = next_rnd_mode (rnd_im)) + for (rnd_im = first_rounding_mode (); is_valid_rounding_mode (rnd_im); rnd_im = next_rounding_mode (rnd_im)) tgeneric_cfc (&function, x1, z1, z2, zzzz, z3, MPC_RND (rnd_re, rnd_im)); reuse_cfc (&function, z1, x1, z2, z3); break; case CCF: - for (rnd_im = first_rnd_mode (); is_valid_rnd_mode (rnd_im); rnd_im = next_rnd_mode (rnd_im)) + for (rnd_im = first_rounding_mode (); is_valid_rounding_mode (rnd_im); rnd_im = next_rounding_mode (rnd_im)) tgeneric_ccf (&function, z1, x1, z2, zzzz, z3, MPC_RND (rnd_re, rnd_im)); reuse_ccf (&function, z1, x1, z2, z3); break; case CCU: - for (rnd_im = first_rnd_mode (); is_valid_rnd_mode (rnd_im); rnd_im = next_rnd_mode (rnd_im)) + for (rnd_im = first_rounding_mode (); is_valid_rounding_mode (rnd_im); rnd_im = next_rounding_mode (rnd_im)) tgeneric_ccu (&function, z1, ul1, z2, zzzz, z3, MPC_RND (rnd_re, rnd_im)); reuse_ccu (&function, z1, ul1, z2, z3); break; case CUC: - for (rnd_im = first_rnd_mode (); is_valid_rnd_mode (rnd_im); rnd_im = next_rnd_mode (rnd_im)) + for (rnd_im = first_rounding_mode (); is_valid_rounding_mode (rnd_im); rnd_im = next_rounding_mode (rnd_im)) tgeneric_cuc (&function, ul1, z1, z2, zzzz, z3, MPC_RND (rnd_re, rnd_im)); reuse_cuc (&function, ul1, z1, z2, z3); break; case CCS: - for (rnd_im = first_rnd_mode (); is_valid_rnd_mode (rnd_im); rnd_im = next_rnd_mode (rnd_im)) + for (rnd_im = first_rounding_mode (); is_valid_rounding_mode (rnd_im); rnd_im = next_rounding_mode (rnd_im)) tgeneric_ccs (&function, z1, lo, z2, zzzz, z3, MPC_RND (rnd_re, rnd_im)); reuse_ccs (&function, z1, lo, z2, z3); break; case CCI: - for (rnd_im = first_rnd_mode (); is_valid_rnd_mode (rnd_im); rnd_im = next_rnd_mode (rnd_im)) + for (rnd_im = first_rounding_mode (); is_valid_rounding_mode (rnd_im); rnd_im = next_rounding_mode (rnd_im)) tgeneric_cci (&function, z1, i, z2, zzzz, z3, MPC_RND (rnd_re, rnd_im)); reuse_cci (&function, z1, i, z2, z3); break; case CUUC: - for (rnd_im = first_rnd_mode (); is_valid_rnd_mode (rnd_im); rnd_im = next_rnd_mode (rnd_im)) + for (rnd_im = first_rounding_mode (); is_valid_rounding_mode (rnd_im); rnd_im = next_rounding_mode (rnd_im)) tgeneric_cuuc (&function, ul1, ul2, z1, z2, zzzz, z3, MPC_RND (rnd_re, rnd_im)); reuse_cuuc (&function, ul1, ul2, z1, z2, z3); diff --git a/tests/timag.c b/tests/timag.c index 47cf52c..3d427ba 100644 --- a/tests/timag.c +++ b/tests/timag.c @@ -1,6 +1,6 @@ /* timag -- test file for mpc_imag. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,14 +20,17 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpfr_inex = mpc_imag (P[1].mpfr, P[2].mpc, P[3].mpfr_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (FC, f, mpc_imag); - test_start (); - tgeneric (f, 2, 1024, 1, 4096); + tgeneric_template ("imag.dsc", 2, 1024, 1, 4096); test_end (); diff --git a/tests/timag_tmpl.c b/tests/timag_tmpl.c deleted file mode 100644 index af0cb59..0000000 --- a/tests/timag_tmpl.c +++ /dev/null @@ -1,38 +0,0 @@ -/* timag_tmpl.c -- templated test file for mpc_imag. - -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" - -#define MPC_FUNCTION_CALL \ - P[0].mpfr_inex = mpc_imag (P[1].mpfr, P[2].mpc, P[3].mpfr_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - tgeneric_template ("imag.dsc", 2, 1024, 1, 4096); - - test_end (); - - return 0; -} diff --git a/tests/tio_str.c b/tests/tio_str.c index b148b7b..b7daf9d 100644 --- a/tests/tio_str.c +++ b/tests/tio_str.c @@ -33,7 +33,7 @@ along with this program. If not, see http://www.gnu.org/licenses/ . extern unsigned long line_number; /* character appearing next in the file, may be EOF */ extern int nextchar; -extern const char *rnd_mode[]; +extern const char *mpc_rnd_mode[]; static void check_file (const char* file_name) @@ -87,7 +87,7 @@ check_file (const char* file_name) || size != expected_size) { printf ("mpc_inp_str failed (line %lu) with rounding mode %s\n", - line_number, rnd_mode[rnd]); + line_number, mpc_rnd_mode[rnd]); if (inex != expected_inex) printf(" got inexact value: %d\nexpected inexact value: %d\n", inex, expected_inex); diff --git a/tests/tlog.c b/tests/tlog.c index 83f528d..1bb3cbe 100644 --- a/tests/tlog.c +++ b/tests/tlog.c @@ -1,6 +1,6 @@ /* tlog -- test file for mpc_log. -Copyright (C) 2008, 2009 INRIA +Copyright (C) 2008, 2009, 2013 INRIA This file is part of GNU MPC. @@ -18,18 +18,24 @@ 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 #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_log (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_log (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_log); - test_start (); - data_check (f, "log.dat"); - tgeneric (f, 2, 512, 7, 128); + data_check_template ("log.dsc", "log.dat"); + + tgeneric_template ("log.dsc", 2, 512, 7, 128); test_end (); diff --git a/tests/tlog10.c b/tests/tlog10.c index 5591b06..73c8580 100644 --- a/tests/tlog10.c +++ b/tests/tlog10.c @@ -1,6 +1,6 @@ /* tlog10 -- test file for mpc_log10. -Copyright (C) 2012 INRIA +Copyright (C) 2012, 2013 INRIA This file is part of GNU MPC. @@ -18,18 +18,24 @@ 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 #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_log10 (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_log10 (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_log10); - test_start (); - data_check (f, "log10.dat"); - tgeneric (f, 2, 512, 7, 128); + data_check_template ("log10.dsc", "log10.dat"); + + tgeneric_template ("log10.dsc", 2, 512, 7, 128); test_end (); diff --git a/tests/tlog10_tmpl.c b/tests/tlog10_tmpl.c deleted file mode 100644 index 1d57350..0000000 --- a/tests/tlog10_tmpl.c +++ /dev/null @@ -1,44 +0,0 @@ -/* tlog10_tmpl -- templated test file for mpc_log10. - -Copyright (C) 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_log10 (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_log10 (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("log10.dsc", "log10.dat"); - - tgeneric_template ("log10.dsc", 2, 512, 7, 128); - - test_end (); - - return 0; -} diff --git a/tests/tlog_tmpl.c b/tests/tlog_tmpl.c deleted file mode 100644 index 5de84e5..0000000 --- a/tests/tlog_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* tlog_tmpl -- templated test file for mpc_log. - -Copyright (C) 2008, 2009, 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_log (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_log (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("log.dsc", "log.dat"); - - tgeneric_template ("log.dsc", 2, 512, 7, 128); - - test_end (); - - return 0; -} diff --git a/tests/tmul.c b/tests/tmul.c index 225cf0e..4064cb5 100644 --- a/tests/tmul.c +++ b/tests/tmul.c @@ -1,6 +1,6 @@ /* tmul -- test file for mpc_mul. -Copyright (C) 2002, 2005, 2008, 2009, 2010, 2011, 2012 INRIA +Copyright (C) 2002, 2005, 2008, 2009, 2010, 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -33,32 +33,48 @@ cmpmul (mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) /* all have the same precision, and we use this precision also for the */ /* result. */ { - mpc_t z, t; - int inex_z, inex_t; + mpc_t z, t; + int inexact_z, inexact_t; - mpc_init2 (z, MPC_MAX_PREC (x)); - mpc_init2 (t, MPC_MAX_PREC (x)); + mpc_init2 (z, MPC_MAX_PREC (x)); + mpc_init2 (t, MPC_MAX_PREC (x)); - inex_z = mpc_mul_naive (z, x, y, rnd); - inex_t = mpc_mul_karatsuba (t, x, y, rnd); + inexact_z = mpc_mul_naive (z, x, y, rnd); + inexact_t = mpc_mul_karatsuba (t, x, y, rnd); - if (mpc_cmp (z, t) != 0 || inex_z != inex_t) { - fprintf (stderr, "mul_naive and mul_karatsuba differ for rnd=(%s,%s)\n", + if (mpc_cmp (z, t)) + { + fprintf (stderr, "mul and mul2 differ for rnd=(%s,%s)\nx=", + mpfr_print_rnd_mode(MPC_RND_RE(rnd)), + mpfr_print_rnd_mode(MPC_RND_IM(rnd))); + mpc_out_str (stderr, 2, 0, x, MPC_RNDNN); + fprintf (stderr, "\ny="); + mpc_out_str (stderr, 2, 0, y, MPC_RNDNN); + fprintf (stderr, "\nmpc_mul_naive gives "); + mpc_out_str (stderr, 2, 0, z, MPC_RNDNN); + fprintf (stderr, "\nmpc_mul_karatsuba gives "); + mpc_out_str (stderr, 2, 0, t, MPC_RNDNN); + fprintf (stderr, "\n"); + exit (1); + } + if (inexact_z != inexact_t) + { + fprintf (stderr, "The return values of mul and mul2 differ for rnd=(%s,%s) \nx=", mpfr_print_rnd_mode(MPC_RND_RE(rnd)), mpfr_print_rnd_mode(MPC_RND_IM(rnd))); - MPC_OUT (x); - MPC_OUT (y); - MPC_OUT (z); - MPC_OUT (t); - if (inex_z != inex_t) { - fprintf (stderr, "inex_re (z): %s\n", MPC_INEX_STR (inex_z)); - fprintf (stderr, "inex_re (t): %s\n", MPC_INEX_STR (inex_t)); - } + mpc_out_str (stderr, 2, 0, x, MPC_RNDNN); + fprintf (stderr, "\nand y="); + mpc_out_str (stderr, 2, 0, y, MPC_RNDNN); + fprintf (stderr, "\nand x*y="); + mpc_out_str (stderr, 2, 0, z, MPC_RNDNN); + fprintf (stderr, "\nmpc_mul_naive gives %i", inexact_z); + fprintf (stderr, "\nmpc_mul_karatsuba gives %i", inexact_t); + fprintf (stderr, "\n"); exit (1); - } + } - mpc_clear (z); - mpc_clear (t); + mpc_clear (z); + mpc_clear (t); } @@ -84,7 +100,7 @@ static void check_regular (void) { mpc_t x, y; - int rnd_re, rnd_im; + mpc_rnd_t rnd_re, rnd_im; mpfr_prec_t prec; testmul (247, -65, -223, 416, 8, 24); @@ -123,7 +139,7 @@ check_regular (void) for (rnd_re = 0; rnd_re < 4; rnd_re ++) for (rnd_im = 0; rnd_im < 4; rnd_im ++) - cmpmul (x, y, MPC_RND (rnd_re, rnd_im)); + cmpmul (x, y, MPC_RND(rnd_re, rnd_im)); } mpc_clear (x); @@ -178,13 +194,21 @@ timemul (void) } #endif +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_mul (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_SYMMETRIC \ + P[0].mpc_inex = mpc_mul (P[1].mpc, P[3].mpc, P[2].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_mul (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP2 \ + P[0].mpc_inex = mpc_mul (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" int main (void) { - DECL_FUNC (C_CC, f, mpc_mul); - f.properties = FUNC_PROP_SYMETRIC; - test_start (); #ifdef TIMING @@ -193,9 +217,11 @@ main (void) check_regular (); - data_check (f, "mul.dat"); - tgeneric (f, 2, 4096, 41, 100); + data_check_template ("mul.dsc", "mul.dat"); + + tgeneric_template ("mul.dsc", 2, 4096, 41, 1024); test_end (); + return 0; } diff --git a/tests/tmul_2si.c b/tests/tmul_2si.c index bf86f18..7829cdb 100644 --- a/tests/tmul_2si.c +++ b/tests/tmul_2si.c @@ -1,6 +1,6 @@ /* tmul_2si -- test file for mpc_mul_2si. -Copyright (C) 2012 INRIA +Copyright (C) 2012, 2013 INRIA This file is part of GNU MPC. @@ -20,14 +20,19 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_mul_2si (P[1].mpc, P[2].mpc, P[3].si, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_mul_2si (P[1].mpc, P[1].mpc, P[3].si, P[4].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCS, f, mpc_mul_2si); - test_start (); - tgeneric (f, 2, 1024, 7, -1); + tgeneric_template ("mul_2si.dsc", 2, 1024, 7, 1024); test_end (); diff --git a/tests/tmul_2si_tmpl.c b/tests/tmul_2si_tmpl.c deleted file mode 100644 index 0ec6c18..0000000 --- a/tests/tmul_2si_tmpl.c +++ /dev/null @@ -1,40 +0,0 @@ -/* tmul_2si_tmpl.c -- templated test file for mpc_mul_2si. - -Copyright (C) 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_mul_2si (P[1].mpc, P[2].mpc, P[3].si, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_mul_2si (P[1].mpc, P[1].mpc, P[3].si, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - tgeneric_template ("mul_2si.dsc", 2, 1024, 7, 1024); - - test_end (); - - return 0; -} diff --git a/tests/tmul_2ui.c b/tests/tmul_2ui.c index 97073db..6d5ea70 100644 --- a/tests/tmul_2ui.c +++ b/tests/tmul_2ui.c @@ -1,6 +1,6 @@ /* tmul_2ui -- test file for mpc_mul_2ui. -Copyright (C) 2008, 2012 INRIA +Copyright (C) 2008, 2012, 2013 INRIA This file is part of GNU MPC. @@ -20,14 +20,19 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_mul_2ui (P[1].mpc, P[2].mpc, P[3].ui, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_mul_2ui (P[1].mpc, P[1].mpc, P[3].ui, P[4].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCU, f, mpc_mul_2ui); - test_start (); - tgeneric (f, 2, 1024, 7, -1); + tgeneric_template ("mul_2ui.dsc", 2, 1024, 7, 1024); test_end (); diff --git a/tests/tmul_2ui_tmpl.c b/tests/tmul_2ui_tmpl.c deleted file mode 100644 index 8b736b5..0000000 --- a/tests/tmul_2ui_tmpl.c +++ /dev/null @@ -1,40 +0,0 @@ -/* tmul_2ui_tmpl.c -- templated test file for mpc_mul_2ui. - -Copyright (C) 2008, 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_mul_2ui (P[1].mpc, P[2].mpc, P[3].ui, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_mul_2ui (P[1].mpc, P[1].mpc, P[3].ui, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - tgeneric_template ("mul_2ui.dsc", 2, 1024, 7, 1024); - - test_end (); - - return 0; -} diff --git a/tests/tmul_fr.c b/tests/tmul_fr.c index 796ab28..32d6f86 100644 --- a/tests/tmul_fr.c +++ b/tests/tmul_fr.c @@ -1,6 +1,6 @@ /* tmul_fr -- test file for mpc_mul_fr. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_mul_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_mul_fr (P[1].mpc, P[1].mpc, P[3].mpfr, P[4].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCF, f, mpc_mul_fr); - test_start (); - data_check (f, "mul_fr.dat"); - tgeneric (f, 2, 1024, 7, -1); + data_check_template ("mul_fr.dsc", "mul_fr.dat"); + + tgeneric_template ("mul_fr.dsc", 2, 1024, 7, -1); test_end (); diff --git a/tests/tmul_fr_tmpl.c b/tests/tmul_fr_tmpl.c deleted file mode 100644 index 9c4b32d..0000000 --- a/tests/tmul_fr_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* tmul_fr_tmpl -- templated test file for mpc_mul_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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_mul_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_mul_fr (P[1].mpc, P[1].mpc, P[3].mpfr, P[4].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("mul_fr.dsc", "mul_fr.dat"); - - tgeneric_template ("mul_fr.dsc", 2, 1024, 7, -1); - - test_end (); - - return 0; -} diff --git a/tests/tmul_i.c b/tests/tmul_i.c index 863ed5f..87ae2ce 100644 --- a/tests/tmul_i.c +++ b/tests/tmul_i.c @@ -1,6 +1,6 @@ /* tmul_i -- test file for mpc_mul_i. -Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA +Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -80,15 +80,22 @@ check_different_precisions(void) mpc_clear (got); } + +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_mul_i (P[1].mpc, P[2].mpc, P[3].i, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_mul_i (P[1].mpc, P[1].mpc, P[3].i, P[4].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCI, f, mpc_mul_i); - test_start (); check_different_precisions (); - tgeneric (f, 2, 1024, 7, -1); + + tgeneric_template ("mul_i.dsc", 2, 1024, 7, 1024); test_end (); diff --git a/tests/tmul_i_tmpl.c b/tests/tmul_i_tmpl.c deleted file mode 100644 index bf920af..0000000 --- a/tests/tmul_i_tmpl.c +++ /dev/null @@ -1,103 +0,0 @@ -/* tmul_i_tmpl.c -- templated test file for mpc_mul_i. - -Copyright (C) 2008, 2009, 2010, 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" - -static void -check_different_precisions(void) -{ - /* check reuse when real and imaginary part have different precisions. */ - mpc_t z, expected, got; - int res; - - mpc_init2(z, 128); - mpc_init2(expected, 128); - mpc_init2(got, 128); - - /* change precision of one part */ - mpfr_set_prec (mpc_imagref (z), 32); - mpfr_set_prec (mpc_imagref (expected), 32); - mpfr_set_prec (mpc_imagref (got), 32); - - mpfr_set_str (mpc_realref (z), "0x100000000fp-32", 16, MPFR_RNDN); - mpfr_set_str (mpc_imagref (z), "-1", 2, MPFR_RNDN); - mpfr_set_str (mpc_realref (expected), "+1", 2, MPFR_RNDN); - mpfr_set_str (mpc_imagref (expected), "0x100000000fp-32", 16, MPFR_RNDN); - - mpc_set (got, z, MPC_RNDNN); - res = mpc_mul_i (got, got, +1, MPC_RNDNN); - if (MPC_INEX_RE(res) != 0 || MPC_INEX_IM(res) >=0) - { - printf("Wrong inexact flag for mpc_mul_i(z, z, n)\n" - " got (re=%2d, im=%2d)\nexpected (re= 0, im=-1)\n", - MPC_INEX_RE(res), MPC_INEX_IM(res)); - exit(1); - } - if (mpc_cmp(got, expected) != 0) - { - printf ("Error for mpc_mul_i(z, z, n) for\n"); - MPC_OUT (z); - printf ("n=+1\n"); - MPC_OUT (expected); - MPC_OUT (got); - - exit (1); - } - - mpc_neg (expected, expected, MPC_RNDNN); - mpc_set (got, z, MPC_RNDNN); - mpc_mul_i (got, got, -1, MPC_RNDNN); - if (mpc_cmp(got, expected) != 0) - { - printf ("Error for mpc_mul_i(z, z, n) for\n"); - MPC_OUT (z); - printf ("n=-1\n"); - MPC_OUT (expected); - MPC_OUT (got); - - exit (1); - } - - mpc_clear (z); - mpc_clear (expected); - mpc_clear (got); -} - - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_mul_i (P[1].mpc, P[2].mpc, P[3].i, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_mul_i (P[1].mpc, P[1].mpc, P[3].i, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - check_different_precisions (); - - tgeneric_template ("mul_i.dsc", 2, 1024, 7, 1024); - - test_end (); - - return 0; -} diff --git a/tests/tmul_si.c b/tests/tmul_si.c index 1d0e0d7..9aba11a 100644 --- a/tests/tmul_si.c +++ b/tests/tmul_si.c @@ -1,6 +1,6 @@ /* tmul_si -- test file for mpc_mul_si. -Copyright (C) 2002, 2005, 2008 INRIA +Copyright (C) 2002, 2005, 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,13 +20,19 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_mul_si (P[1].mpc, P[2].mpc, P[3].si, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_mul_si (P[1].mpc, P[1].mpc, P[3].si, P[4].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCS, f, mpc_mul_si); test_start (); - tgeneric (f, 2, 1024, 7, -1); + tgeneric_template ("mul_si.dsc", 2, 1024, 7, 1024); test_end (); diff --git a/tests/tmul_si_tmpl.c b/tests/tmul_si_tmpl.c deleted file mode 100644 index 6a63be1..0000000 --- a/tests/tmul_si_tmpl.c +++ /dev/null @@ -1,40 +0,0 @@ -/* tmul_si_tmpl.c -- templated test file for mpc_mul_si. - -Copyright (C) 2002, 2005, 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_mul_si (P[1].mpc, P[2].mpc, P[3].si, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_mul_si (P[1].mpc, P[1].mpc, P[3].si, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - tgeneric_template ("mul_si.dsc", 2, 1024, 7, 1024); - - test_end (); - - return 0; -} diff --git a/tests/tmul_tmpl.c b/tests/tmul_tmpl.c deleted file mode 100644 index 9c01361..0000000 --- a/tests/tmul_tmpl.c +++ /dev/null @@ -1,228 +0,0 @@ -/* tmul -- test file for mpc_mul. - -Copyright (C) 2002, 2005, 2008, 2009, 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 -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 -#ifdef TIMING -#include -#endif - -#include "templates.h" - -static void -cmpmul (mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) - /* computes the product of x and y with the naive and Karatsuba methods */ - /* using the rounding mode rnd and compares the results and return */ - /* values. */ - /* In our current test suite, the real and imaginary parts of x and y */ - /* all have the same precision, and we use this precision also for the */ - /* result. */ -{ - mpc_t z, t; - int inexact_z, inexact_t; - - mpc_init2 (z, MPC_MAX_PREC (x)); - mpc_init2 (t, MPC_MAX_PREC (x)); - - inexact_z = mpc_mul_naive (z, x, y, rnd); - inexact_t = mpc_mul_karatsuba (t, x, y, rnd); - - if (mpc_cmp (z, t)) - { - fprintf (stderr, "mul and mul2 differ for rnd=(%s,%s)\nx=", - mpfr_print_rnd_mode(MPC_RND_RE(rnd)), - mpfr_print_rnd_mode(MPC_RND_IM(rnd))); - mpc_out_str (stderr, 2, 0, x, MPC_RNDNN); - fprintf (stderr, "\ny="); - mpc_out_str (stderr, 2, 0, y, MPC_RNDNN); - fprintf (stderr, "\nmpc_mul_naive gives "); - mpc_out_str (stderr, 2, 0, z, MPC_RNDNN); - fprintf (stderr, "\nmpc_mul_karatsuba gives "); - mpc_out_str (stderr, 2, 0, t, MPC_RNDNN); - fprintf (stderr, "\n"); - exit (1); - } - if (inexact_z != inexact_t) - { - fprintf (stderr, "The return values of mul and mul2 differ for rnd=(%s,%s) \nx=", - mpfr_print_rnd_mode(MPC_RND_RE(rnd)), - mpfr_print_rnd_mode(MPC_RND_IM(rnd))); - mpc_out_str (stderr, 2, 0, x, MPC_RNDNN); - fprintf (stderr, "\nand y="); - mpc_out_str (stderr, 2, 0, y, MPC_RNDNN); - fprintf (stderr, "\nand x*y="); - mpc_out_str (stderr, 2, 0, z, MPC_RNDNN); - fprintf (stderr, "\nmpc_mul_naive gives %i", inexact_z); - fprintf (stderr, "\nmpc_mul_karatsuba gives %i", inexact_t); - fprintf (stderr, "\n"); - exit (1); - } - - mpc_clear (z); - mpc_clear (t); -} - - -static void -testmul (long a, long b, long c, long d, mpfr_prec_t prec, mpc_rnd_t rnd) -{ - mpc_t x, y; - - mpc_init2 (x, prec); - mpc_init2 (y, prec); - - mpc_set_si_si (x, a, b, rnd); - mpc_set_si_si (y, c, d, rnd); - - cmpmul (x, y, rnd); - - mpc_clear (x); - mpc_clear (y); -} - - -static void -check_regular (void) -{ - mpc_t x, y; - mpc_rnd_t rnd_re, rnd_im; - mpfr_prec_t prec; - - testmul (247, -65, -223, 416, 8, 24); - testmul (5, -896, 5, -32, 3, 2); - testmul (-3, -512, -1, -1, 2, 16); - testmul (266013312, 121990769, 110585572, 116491059, 27, 0); - testmul (170, 9, 450, 251, 8, 0); - testmul (768, 85, 169, 440, 8, 16); - testmul (145, 1816, 848, 169, 8, 24); - - mpc_init2 (x, 1000); - mpc_init2 (y, 1000); - - /* Bug 20081114: mpc_mul_karatsuba returned wrong inexact value for - imaginary part */ - mpc_set_prec (x, 7); - mpc_set_prec (y, 7); - mpfr_set_str (mpc_realref (x), "0xB4p+733", 16, GMP_RNDN); - mpfr_set_str (mpc_imagref (x), "0x90p+244", 16, GMP_RNDN); - mpfr_set_str (mpc_realref (y), "0xECp-146", 16, GMP_RNDN); - mpfr_set_str (mpc_imagref (y), "0xACp-471", 16, GMP_RNDN); - cmpmul (x, y, MPC_RNDNN); - mpfr_set_str (mpc_realref (x), "0xB4p+733", 16, GMP_RNDN); - mpfr_set_str (mpc_imagref (x), "0x90p+244", 16, GMP_RNDN); - mpfr_set_str (mpc_realref (y), "0xACp-471", 16, GMP_RNDN); - mpfr_set_str (mpc_imagref (y), "-0xECp-146", 16, GMP_RNDN); - cmpmul (x, y, MPC_RNDNN); - - for (prec = 2; prec < 1000; prec = (mpfr_prec_t) (prec * 1.1 + 1)) - { - mpc_set_prec (x, prec); - mpc_set_prec (y, prec); - - test_default_random (x, -1024, 1024, 128, 0); - test_default_random (y, -1024, 1024, 128, 0); - - for (rnd_re = 0; rnd_re < 4; rnd_re ++) - for (rnd_im = 0; rnd_im < 4; rnd_im ++) - cmpmul (x, y, MPC_RND(rnd_re, rnd_im)); - } - - mpc_clear (x); - mpc_clear (y); -} - - -#ifdef TIMING -static void -timemul (void) -{ - /* measures the time needed with different precisions for naive and */ - /* Karatsuba multiplication */ - - mpc_t x, y, z; - unsigned long int i, j; - const unsigned long int tests = 10000; - struct tms time_old, time_new; - double passed1, passed2; - - mpc_init (x); - mpc_init (y); - mpc_init_set_ui_ui (z, 1, 0, MPC_RNDNN); - - for (i = 1; i < 50; i++) - { - mpc_set_prec (x, i * BITS_PER_MP_LIMB); - mpc_set_prec (y, i * BITS_PER_MP_LIMB); - mpc_set_prec (z, i * BITS_PER_MP_LIMB); - test_default_random (x, -1, 1, 128, 25); - test_default_random (y, -1, 1, 128, 25); - - times (&time_old); - for (j = 0; j < tests; j++) - mpc_mul_naive (z, x, y, MPC_RNDNN); - times (&time_new); - passed1 = ((double) (time_new.tms_utime - time_old.tms_utime)) / 100; - - times (&time_old); - for (j = 0; j < tests; j++) - mpc_mul_karatsuba (z, x, y, MPC_RNDNN); - times (&time_new); - passed2 = ((double) (time_new.tms_utime - time_old.tms_utime)) / 100; - - printf ("Time for %3li limbs naive/Karatsuba: %5.2f %5.2f\n", i, - passed1, passed2); - } - - mpc_clear (x); - mpc_clear (y); - mpc_clear (z); -} -#endif - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_mul (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_SYMMETRIC \ - P[0].mpc_inex = mpc_mul (P[1].mpc, P[3].mpc, P[2].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_mul (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP2 \ - P[0].mpc_inex = mpc_mul (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - -#ifdef TIMING - timemul (); -#endif - - check_regular (); - - data_check_template ("mul.dsc", "mul.dat"); - - tgeneric_template ("mul.dsc", 2, 4096, 41, 1024); - - test_end (); - - return 0; -} diff --git a/tests/tmul_ui.c b/tests/tmul_ui.c index e7f62f2..f9a9d87 100644 --- a/tests/tmul_ui.c +++ b/tests/tmul_ui.c @@ -1,6 +1,6 @@ /* tmul_ui -- test file for mpc_mul_ui. -Copyright (C) 2002, 2005, 2008 INRIA +Copyright (C) 2002, 2005, 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,14 +20,19 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_mul_ui (P[1].mpc, P[2].mpc, P[3].si, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_mul_ui (P[1].mpc, P[1].mpc, P[3].si, P[4].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCU, f, mpc_mul_ui); - test_start (); - tgeneric (f, 2, 1024, 7, -1); + tgeneric_template ("mul_ui.dsc", 2, 1024, 7, 1024); test_end (); diff --git a/tests/tmul_ui_tmpl.c b/tests/tmul_ui_tmpl.c deleted file mode 100644 index e13227a..0000000 --- a/tests/tmul_ui_tmpl.c +++ /dev/null @@ -1,40 +0,0 @@ -/* tmul_ui_tmpl.c -- templated test file for mpc_mul_ui. - -Copyright (C) 2002, 2005, 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_mul_ui (P[1].mpc, P[2].mpc, P[3].si, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_mul_ui (P[1].mpc, P[1].mpc, P[3].si, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - tgeneric_template ("mul_ui.dsc", 2, 1024, 7, 1024); - - test_end (); - - return 0; -} diff --git a/tests/tneg.c b/tests/tneg.c index be1c90a..53ed67f 100644 --- a/tests/tneg.c +++ b/tests/tneg.c @@ -1,6 +1,6 @@ /* tneg -- test file for mpc_neg. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,14 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #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" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_neg); test_start (); - data_check (f, "neg.dat"); - tgeneric (f, 2, 1024, 1, 0); + data_check_template ("neg.dsc", "neg.dat"); + + tgeneric_template ("neg.dsc", 2, 1024, 1, 0); test_end (); diff --git a/tests/tneg_tmpl.c b/tests/tneg_tmpl.c deleted file mode 100644 index fbcc3ad..0000000 --- a/tests/tneg_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* 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" - -#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" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("neg.dsc", "neg.dat"); - - tgeneric_template ("neg.dsc", 2, 1024, 1, 0); - - test_end (); - - return 0; -} diff --git a/tests/tnorm.c b/tests/tnorm.c index 1dba939..30651ac 100644 --- a/tests/tnorm.c +++ b/tests/tnorm.c @@ -1,6 +1,6 @@ /* tnorm -- test file for mpc_norm. -Copyright (C) 2008, 2011, 2012 INRIA +Copyright (C) 2008, 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -93,15 +93,21 @@ test_underflow (void) mpfr_set_emin (emin); } +#define MPC_FUNCTION_CALL \ + P[0].mpfr_inex = mpc_norm (P[1].mpfr, P[2].mpc, P[3].mpfr_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (FC, f, mpc_norm); - test_start (); - data_check (f, "norm.dat"); - tgeneric (f, 2, 1024, 1, 4096); + data_check_template ("norm.dsc", "norm.dat"); + + tgeneric_template ("norm.dsc", 2, 1024, 1, 4096); + test_underflow (); test_end (); diff --git a/tests/tnorm_tmpl.c b/tests/tnorm_tmpl.c deleted file mode 100644 index 78ca948..0000000 --- a/tests/tnorm_tmpl.c +++ /dev/null @@ -1,117 +0,0 @@ -/* 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" - -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); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpfr_inex = mpc_norm (P[1].mpfr, P[2].mpc, P[3].mpfr_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("norm.dsc", "norm.dat"); - - tgeneric_template ("norm.dsc", 2, 1024, 1, 4096); - - test_underflow (); - - test_end (); - - return 0; -} diff --git a/tests/tpl_gmp.c b/tests/tpl_gmp.c index a30de95..9899584 100644 --- a/tests/tpl_gmp.c +++ b/tests/tpl_gmp.c @@ -18,7 +18,7 @@ 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" void tpl_read_mpz (mpc_datafile_context_t* datafile_context, mpz_t mpz) diff --git a/tests/tpl_mpc.c b/tests/tpl_mpc.c index a68c7fd..395d737 100644 --- a/tests/tpl_mpc.c +++ b/tests/tpl_mpc.c @@ -18,7 +18,7 @@ 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" void tpl_read_mpc_rnd (mpc_datafile_context_t* datafile_context, mpc_rnd_t* rnd) diff --git a/tests/tpl_mpfr.c b/tests/tpl_mpfr.c index d53717f..f1a8ee7 100644 --- a/tests/tpl_mpfr.c +++ b/tests/tpl_mpfr.c @@ -18,7 +18,7 @@ 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" mpfr_prec_t tpl_read_mpfr_prec (mpc_datafile_context_t* datafile_context) diff --git a/tests/tpl_native.c b/tests/tpl_native.c index fde5ecc..4b8f48c 100644 --- a/tests/tpl_native.c +++ b/tests/tpl_native.c @@ -1,6 +1,6 @@ /* tpl_mpfr.c -- Helper functions for data with native types. -Copyright (C) 2012 INRIA +Copyright (C) 2012, 2013 INRIA This file is part of GNU MPC. @@ -18,7 +18,7 @@ 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" /* int */ diff --git a/tests/tpow.c b/tests/tpow.c index 31ac1ca..123673e 100644 --- a/tests/tpow.c +++ b/tests/tpow.c @@ -1,6 +1,6 @@ /* tpow -- test file for mpc_pow. -Copyright (C) 2009, 2011, 2012 INRIA +Copyright (C) 2009, 2011, 2013 INRIA This file is part of GNU MPC. @@ -52,18 +52,26 @@ reuse_bug (void) } } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_pow (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_pow (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP2 \ + P[0].mpc_inex = mpc_pow (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" int main (void) { - DECL_FUNC (C_CC, f, mpc_pow); - test_start (); reuse_bug (); - data_check (f, "pow.dat"); - tgeneric (f, 2, 1024, 7, 10); + data_check_template ("pow.dsc", "pow.dat"); + + tgeneric_template ("pow.dsc", 2, 1024, 7, 10); test_end (); diff --git a/tests/tpow_d.c b/tests/tpow_d.c index 22de27e..eeb7791 100644 --- a/tests/tpow_d.c +++ b/tests/tpow_d.c @@ -1,6 +1,6 @@ /* tpow_d -- test file for mpc_pow_d. -Copyright (C) 2009 INRIA +Copyright (C) 2009, 2013 INRIA This file is part of GNU MPC. @@ -20,13 +20,11 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" -int -main (void) +static void +test_integer_values (void) { mpc_t z; - test_start (); - mpc_init2 (z, 11); mpc_set_ui_ui (z, 2, 3, MPC_RNDNN); @@ -54,6 +52,23 @@ main (void) } mpc_clear (z); +} + +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_pow_d (P[1].mpc, P[2].mpc, P[3].d, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_pow_d (P[1].mpc, P[1].mpc, P[3].d, P[4].mpc_rnd) + +#include "tgeneric.tpl" + +int +main (void) +{ + test_start (); + + tgeneric_template ("pow_d.dsc", 2, 1024, 15, 20); + + test_integer_values (); /* FIXME: should be in a data file */ test_end (); diff --git a/tests/tpow_d_tmpl.c b/tests/tpow_d_tmpl.c deleted file mode 100644 index 6122876..0000000 --- a/tests/tpow_d_tmpl.c +++ /dev/null @@ -1,76 +0,0 @@ -/* tpow_d_tmpl.c -- templated test file for mpc_pow_d. - -Copyright (C) 2009, 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" - -static void -test_integer_values (void) -{ - mpc_t z; - - mpc_init2 (z, 11); - - mpc_set_ui_ui (z, 2, 3, MPC_RNDNN); - mpc_pow_d (z, z, 3.0, MPC_RNDNN); - if (mpc_cmp_si_si (z, -46, 9) != 0) - { - printf ("Error for mpc_pow_d (1)\n"); - exit (1); - } - - mpc_set_si_si (z, -3, 4, MPC_RNDNN); - mpc_pow_d (z, z, 0.5, MPC_RNDNN); - if (mpc_cmp_si_si (z, 1, 2) != 0) - { - printf ("Error for mpc_pow_d (2)\n"); - exit (1); - } - - mpc_set_ui_ui (z, 2, 3, MPC_RNDNN); - mpc_pow_d (z, z, 6.0, MPC_RNDNN); - if (mpc_cmp_si_si (z, 2035, -828) != 0) - { - printf ("Error for mpc_pow_d (3)\n"); - exit (1); - } - - mpc_clear (z); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_pow_d (P[1].mpc, P[2].mpc, P[3].d, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_pow_d (P[1].mpc, P[1].mpc, P[3].d, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - tgeneric_template ("pow_d.dsc", 2, 1024, 15, 20); - - test_integer_values (); /* FIXME: should be in a data file */ - - test_end (); - - return 0; -} diff --git a/tests/tpow_fr.c b/tests/tpow_fr.c index 99274af..a19c95f 100644 --- a/tests/tpow_fr.c +++ b/tests/tpow_fr.c @@ -1,6 +1,6 @@ /* tpow_fr -- test file for mpc_pow_fr. -Copyright (C) 2009, 2011, 2012 INRIA +Copyright (C) 2009, 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -47,15 +47,24 @@ test_reuse (void) 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" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCF, f, mpc_pow_fr); test_start (); - test_reuse (); - data_check (f, "pow_fr.dat"); - tgeneric (f, 2, 1024, 7, 10); + test_reuse (); /* FIXME: remove it, already checked by tgeneric */ + + data_check_template ("pow_fr.dsc", "pow_fr.dat"); + + tgeneric_template ("pow_fr.dsc", 2, 1024, 7, 10); test_end (); diff --git a/tests/tpow_fr_tmpl.c b/tests/tpow_fr_tmpl.c deleted file mode 100644 index 32c8352..0000000 --- a/tests/tpow_fr_tmpl.c +++ /dev/null @@ -1,72 +0,0 @@ -/* 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 "templates.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_2ui (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" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - test_reuse (); /* FIXME: remove it, already checked by tgeneric */ - - data_check_template ("pow_fr.dsc", "pow_fr.dat"); - - tgeneric_template ("pow_fr.dsc", 2, 1024, 7, 10); - - test_end (); - - return 0; -} diff --git a/tests/tpow_si.c b/tests/tpow_si.c index a3cbfb7..75f01ef 100644 --- a/tests/tpow_si.c +++ b/tests/tpow_si.c @@ -1,6 +1,6 @@ /* tpow_si -- test file for mpc_pow_si. -Copyright (C) 2009, 2010, 2011 INRIA +Copyright (C) 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -74,12 +74,19 @@ compare_mpc_pow (mpfr_prec_t pmax, int iter, unsigned long nbits) mpc_clear (y); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_pow_si (P[1].mpc, P[2].mpc, P[3].si, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_pow_si (P[1].mpc, P[1].mpc, P[3].si, P[4].mpc_rnd) + +#include "data_check.tpl" + int main (void) { - DECL_FUNC (CCS, f, mpc_pow_si); test_start (); - data_check (f, "pow_si.dat"); + + data_check_template ("pow_si.dsc", "pow_si.dat"); compare_mpc_pow (100, 5, 19); diff --git a/tests/tpow_si_tmpl.c b/tests/tpow_si_tmpl.c deleted file mode 100644 index 142294d..0000000 --- a/tests/tpow_si_tmpl.c +++ /dev/null @@ -1,98 +0,0 @@ -/* tpow_si_tmpl.c -- test file for mpc_pow_si. - -Copyright (C) 2009, 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 -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 /* for CHAR_BIT */ - -#include "templates.h" -#include "mpc-tests.h" - -static void -compare_mpc_pow (mpfr_prec_t pmax, int iter, unsigned long nbits) - /* copied from tpow_ui.c and replaced unsigned by signed */ -{ - mpfr_prec_t p; - mpc_t x, y, z, t; - long n; - int i, inex_pow, inex_pow_si; - mpc_rnd_t rnd; - - mpc_init3 (y, sizeof (unsigned long) * CHAR_BIT, MPFR_PREC_MIN); - for (p = MPFR_PREC_MIN; p <= pmax; p++) - for (i = 0; i < iter; i++) - { - mpc_init2 (x, p); - mpc_init2 (z, p); - mpc_init2 (t, p); - mpc_urandom (x, rands); - n = (signed long) gmp_urandomb_ui (rands, nbits); - mpc_set_si (y, n, MPC_RNDNN); - for (rnd = 0; rnd < 16; rnd ++) - { - inex_pow = mpc_pow (z, x, y, rnd); - inex_pow_si = mpc_pow_si (t, x, n, rnd); - if (mpc_cmp (z, t) != 0) - { - printf ("mpc_pow and mpc_pow_si differ for x="); - mpc_out_str (stdout, 10, 0, x, MPC_RNDNN); - printf (" n=%li\n", n); - printf ("mpc_pow gives "); - mpc_out_str (stdout, 10, 0, z, MPC_RNDNN); - printf ("\nmpc_pow_si gives "); - mpc_out_str (stdout, 10, 0, t, MPC_RNDNN); - printf ("\n"); - exit (1); - } - if (inex_pow != inex_pow_si) - { - printf ("mpc_pow and mpc_pow_si give different flags for x="); - mpc_out_str (stdout, 10, 0, x, MPC_RNDNN); - printf (" n=%li\n", n); - printf ("mpc_pow gives %d\n", inex_pow); - printf ("mpc_pow_si gives %d\n", inex_pow_si); - exit (1); - } - } - mpc_clear (x); - mpc_clear (z); - mpc_clear (t); - } - mpc_clear (y); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_pow_si (P[1].mpc, P[2].mpc, P[3].si, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_pow_si (P[1].mpc, P[1].mpc, P[3].si, P[4].mpc_rnd) - -#include "data_check.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("pow_si.dsc", "pow_si.dat"); - - compare_mpc_pow (100, 5, 19); - - test_end (); - - return 0; -} diff --git a/tests/tpow_tmpl.c b/tests/tpow_tmpl.c deleted file mode 100644 index 7a66c0c..0000000 --- a/tests/tpow_tmpl.c +++ /dev/null @@ -1,79 +0,0 @@ -/* tpow_tmpl.c -- test file for mpc_pow. - -Copyright (C) 2009, 2011, 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" - -static void -reuse_bug (void) -{ - /* bug found by the automatic builds on - http://hydra.nixos.org/build/1469029/log/raw */ - mpc_t x, y, z; - mp_prec_t prec = 2; - - for (prec = 2; prec <= 20; prec ++) - { - mpc_init2 (x, prec); - mpc_init2 (y, prec); - mpc_init2 (z, prec); - - mpfr_set_ui (mpc_realref (x), 0ul, GMP_RNDN); - mpfr_set_ui_2exp (mpc_imagref (x), 3ul, -2, GMP_RNDN); - mpc_set_ui (y, 8ul, MPC_RNDNN); - - mpc_pow (z, x, y, MPC_RNDNN); - mpc_pow (y, x, y, MPC_RNDNN); - if (mpfr_signbit (mpc_imagref (y)) != mpfr_signbit (mpc_imagref (z))) - { - printf ("Error: regression, reuse_bug reproduced\n"); - exit (1); - } - - mpc_clear (x); - mpc_clear (y); - mpc_clear (z); - } -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_pow (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_pow (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP2 \ - P[0].mpc_inex = mpc_pow (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - reuse_bug (); - - data_check_template ("pow.dsc", "pow.dat"); - - tgeneric_template ("pow.dsc", 2, 1024, 7, 10); - - test_end (); - - return 0; -} diff --git a/tests/tpow_ui.c b/tests/tpow_ui.c index 1c7cc6b..9956d0d 100644 --- a/tests/tpow_ui.c +++ b/tests/tpow_ui.c @@ -1,6 +1,6 @@ /* tpow_ui -- test file for mpc_pow_ui. -Copyright (C) 2009, 2010, 2012 INRIA +Copyright (C) 2009, 2010, 2012, 2013 INRIA This file is part of GNU MPC. @@ -73,13 +73,18 @@ compare_mpc_pow (mpfr_prec_t pmax, int iter, unsigned long nbits) mpc_clear (y); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_pow_ui (P[1].mpc, P[2].mpc, P[3].ui, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_pow_ui (P[1].mpc, P[1].mpc, P[3].ui, P[4].mpc_rnd) + +#include "data_check.tpl" + int main (int argc, char *argv[]) { mpc_t z; - DECL_FUNC (CCU, f, mpc_pow_ui); - if (argc != 1) { mpfr_prec_t p; @@ -108,7 +113,8 @@ main (int argc, char *argv[]) } test_start (); - data_check (f, "pow_ui.dat"); + + data_check_template ("pow_ui.dsc", "pow_ui.dat"); compare_mpc_pow (100, 5, 19); diff --git a/tests/tpow_ui_tmpl.c b/tests/tpow_ui_tmpl.c deleted file mode 100644 index 0966ccc..0000000 --- a/tests/tpow_ui_tmpl.c +++ /dev/null @@ -1,125 +0,0 @@ -/* tpow_ui_tmpl.c -- test file for mpc_pow_ui. - -Copyright (C) 2009, 2010, 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 /* for CHAR_BIT */ -#include "templates.h" -#include "mpc-tests.h" - -static void -compare_mpc_pow (mpfr_prec_t pmax, int iter, unsigned long nbits) -{ - mpfr_prec_t p; - mpc_t x, y, z, t; - unsigned long n; - int i, inex_pow, inex_pow_ui; - mpc_rnd_t rnd; - - mpc_init3 (y, sizeof (unsigned long) * CHAR_BIT, MPFR_PREC_MIN); - for (p = MPFR_PREC_MIN; p <= pmax; p++) - for (i = 0; i < iter; i++) - { - mpc_init2 (x, p); - mpc_init2 (z, p); - mpc_init2 (t, p); - mpc_urandom (x, rands); - n = gmp_urandomb_ui (rands, nbits); /* 0 <= n < 2^nbits */ - mpc_set_ui (y, n, MPC_RNDNN); - for (rnd = 0; rnd < 16; rnd ++) - { - inex_pow = mpc_pow (z, x, y, rnd); - inex_pow_ui = mpc_pow_ui (t, x, n, rnd); - if (mpc_cmp (z, t) != 0) - { - printf ("mpc_pow and mpc_pow_ui differ for x="); - mpc_out_str (stdout, 10, 0, x, MPC_RNDNN); - printf (" n=%lu\n", n); - printf ("mpc_pow gives "); - mpc_out_str (stdout, 10, 0, z, MPC_RNDNN); - printf ("\nmpc_pow_ui gives "); - mpc_out_str (stdout, 10, 0, t, MPC_RNDNN); - printf ("\n"); - exit (1); - } - if (inex_pow != inex_pow_ui) - { - printf ("mpc_pow and mpc_pow_ui give different flags for x="); - mpc_out_str (stdout, 10, 0, x, MPC_RNDNN); - printf (" n=%lu\n", n); - printf ("mpc_pow gives %d\n", inex_pow); - printf ("mpc_pow_ui gives %d\n", inex_pow_ui); - exit (1); - } - } - mpc_clear (x); - mpc_clear (z); - mpc_clear (t); - } - mpc_clear (y); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_pow_ui (P[1].mpc, P[2].mpc, P[3].ui, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_pow_ui (P[1].mpc, P[1].mpc, P[3].ui, P[4].mpc_rnd) - -#include "data_check.tpl" - -int -main (int argc, char *argv[]) -{ - mpc_t z; - - if (argc != 1) - { - mpfr_prec_t p; - long int n, k; - mpc_t res; - if (argc != 3 && argc != 4) - { - printf ("Usage: tpow_ui precision exponent [k]\n"); - exit (1); - } - p = atoi (argv[1]); - n = atoi (argv[2]); - MPC_ASSERT (n >= 0); - k = (argc > 3) ? atoi (argv[3]) : 1; - MPC_ASSERT (k >= 0); - mpc_init2 (z, p); - mpc_init2 (res, p); - mpfr_const_pi (mpc_realref (z), GMP_RNDN); - mpfr_div_2exp (mpc_realref (z), mpc_realref (z), 2, GMP_RNDN); - mpfr_const_log2 (mpc_imagref (z), GMP_RNDN); - while (k--) - mpc_pow_ui (res, z, (unsigned long int) n, MPC_RNDNN); - mpc_clear (z); - mpc_clear (res); - return 0; - } - - test_start (); - - data_check_template ("pow_ui.dsc", "pow_ui.dat"); - - compare_mpc_pow (100, 5, 19); - - test_end (); - - return 0; -} diff --git a/tests/tpow_z.c b/tests/tpow_z.c index 2a897e6..f940bca 100644 --- a/tests/tpow_z.c +++ b/tests/tpow_z.c @@ -1,6 +1,6 @@ /* tpow_z -- test file for mpc_pow_z. -Copyright (C) 2009, 2011 INRIA +Copyright (C) 2009, 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -21,42 +21,45 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include /* for CHAR_BIT */ #include "mpc-tests.h" +static void +test_large () +{ + mpc_t z; + mpz_t t; + + mpc_init2 (z, 5); + mpz_init_set_ui (t, 1ul); + + mpz_set_ui (t, 1ul); + mpz_mul_2exp (t, t, sizeof (long) * CHAR_BIT); + mpc_set_ui_ui (z, 0ul, 1ul, MPC_RNDNN); + mpc_pow_z (z, z, t, MPC_RNDNN); + if (mpc_cmp_si_si (z, 1l, 0l) != 0) { + printf ("Error for mpc_pow_z (4*large)\n"); + exit (1); + } + + mpc_clear (z); + mpz_clear (t); +} + +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_pow_z (P[1].mpc, P[2].mpc, P[3].mpz, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_pow_z (P[1].mpc, P[1].mpc, P[3].mpz, P[4].mpc_rnd) + +#include "data_check.tpl" + int main (void) { - mpc_t z; - mpz_t t; - - test_start (); - - mpc_init2 (z, 5); - mpz_init_set_ui (t, 1ul); - mpc_set_ui_ui (z, 17ul, 42ul, MPC_RNDNN); - mpc_pow_z (z, z, t, MPC_RNDNN); - if (mpc_cmp_si_si (z, 17l, 42l) != 0) { - printf ("Error for mpc_pow_z (1)\n"); - exit (1); - } - mpz_set_si (t, -1l); - mpc_set_ui_ui (z, 1ul, 1ul, MPC_RNDNN); - mpc_pow_z (z, z, t, MPC_RNDNN); - mpc_mul_ui (z, z, 2ul, MPC_RNDNN); - if (mpc_cmp_si_si (z, 1l, -1l) != 0) { - printf ("Error for mpc_pow_z (-1)\n"); - exit (1); - } - mpz_set_ui (t, 1ul); - mpz_mul_2exp (t, t, sizeof (long) * CHAR_BIT); - mpc_set_ui_ui (z, 0ul, 1ul, MPC_RNDNN); - mpc_pow_z (z, z, t, MPC_RNDNN); - if (mpc_cmp_si_si (z, 1l, 0l) != 0) { - printf ("Error for mpc_pow_z (4*large)\n"); - exit (1); - } - mpc_clear (z); - mpz_clear (t); - - test_end (); - - return 0; + test_start (); + + data_check_template ("pow_z.dsc", "pow_z.dat"); + + test_large (); + + test_end (); + + return 0; } diff --git a/tests/tpow_z_tmpl.c b/tests/tpow_z_tmpl.c deleted file mode 100644 index 993861e..0000000 --- a/tests/tpow_z_tmpl.c +++ /dev/null @@ -1,40 +0,0 @@ -/* tpow_z_tmpl.c -- templated test file for mpc_pow_z. - -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 "templates.h" -#include "mpc-tests.h" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_pow_z (P[1].mpc, P[2].mpc, P[3].mpz, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_pow_z (P[1].mpc, P[1].mpc, P[3].mpz, P[4].mpc_rnd) - -#include "data_check.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("pow_z.dsc", "pow_z.dat"); - - test_end (); - return 0; -} diff --git a/tests/tproj.c b/tests/tproj.c index 222b697..c63e5b0 100644 --- a/tests/tproj.c +++ b/tests/tproj.c @@ -1,6 +1,6 @@ /* tproj -- test file for mpc_proj. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #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" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_proj); - test_start (); - tgeneric (f, 2, 1024, 1, 4096); - data_check (f, "proj.dat"); + data_check_template ("proj.dsc", "proj.dat"); + + tgeneric_template ("proj.dsc", 2, 1024, 1, 4096); test_end (); diff --git a/tests/tproj_tmpl.c b/tests/tproj_tmpl.c deleted file mode 100644 index fd90650..0000000 --- a/tests/tproj_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* 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" - -#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" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("proj.dsc", "proj.dat"); - - tgeneric_template ("proj.dsc", 2, 1024, 1, 4096); - - test_end (); - - return 0; -} diff --git a/tests/treal.c b/tests/treal.c index c3ab95f..9b13e78 100644 --- a/tests/treal.c +++ b/tests/treal.c @@ -1,6 +1,6 @@ /* treal -- test file for mpc_real. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,14 +20,17 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpfr_inex = mpc_imag (P[1].mpfr, P[2].mpc, P[3].mpfr_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (FC, f, mpc_real); - test_start (); - tgeneric (f, 2, 1024, 1, 4096); + tgeneric_template ("real.dsc", 2, 1024, 1, 4096); test_end (); diff --git a/tests/treal_tmpl.c b/tests/treal_tmpl.c deleted file mode 100644 index b2c4c02..0000000 --- a/tests/treal_tmpl.c +++ /dev/null @@ -1,38 +0,0 @@ -/* treal_tmpl.c -- teemplated test file for mpc_real. - -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" - -#define MPC_FUNCTION_CALL \ - P[0].mpfr_inex = mpc_imag (P[1].mpfr, P[2].mpc, P[3].mpfr_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - tgeneric_template ("real.dsc", 2, 1024, 1, 4096); - - test_end (); - - return 0; -} diff --git a/tests/tsin.c b/tests/tsin.c index 3b09c78..e69baf1 100644 --- a/tests/tsin.c +++ b/tests/tsin.c @@ -1,6 +1,6 @@ /* tsin -- test file for mpc_sin. -Copyright (C) 2007, 2008, 2010 INRIA +Copyright (C) 2007, 2008, 2010, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_sin (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_sin (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_sin); - test_start (); - data_check (f, "sin.dat"); - tgeneric (f, 2, 512, 7, 7); + data_check_template ("sin.dsc", "sin.dat"); + + tgeneric_template ("sin.dsc", 2, 512, 7, 7); test_end (); diff --git a/tests/tsin_cos.c b/tests/tsin_cos.c index a1e7424..73791e6 100644 --- a/tests/tsin_cos.c +++ b/tests/tsin_cos.c @@ -1,6 +1,6 @@ /* tsin_cos -- test file for mpc_sin_cos. -Copyright (C) 2011 INRIA +Copyright (C) 2011, 2013 INRIA This file is part of GNU MPC. @@ -20,14 +20,269 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +static void random_params (mpc_fun_param_t *params, + mpfr_exp_t exp_min, mpfr_exp_t exp_max, + int special); +static void check_against_quadruple_precision (mpc_fun_param_t *params, + mpc_fun_param_t *params_sin, + mpc_fun_param_t *params_cos, + mpfr_prec_t prec, + mpfr_exp_t exp_min, + mpfr_exp_t exp_max, + int special); + +/* tgeneric(desc, prec_min, prec_max, step, exp_max) checks rounding with + random numbers: + - with precision ranging from prec_min to prec_max with an increment of + step, + - with exponent between -exp_max and exp_max. + - for pure real, pure imaginary and infinite random parameters. + + It also checks parameter reuse. +*/ +static void +tgeneric_custom (mpfr_prec_t prec_min, mpfr_prec_t prec_max, mpfr_prec_t step, + mpfr_exp_t exp_max) +{ + int special = 0; + const int last_special = 8; + mpfr_prec_t prec; + mpfr_exp_t exp_min; + mpc_fun_param_t params; + mpc_fun_param_t params_sin; + mpc_fun_param_t params_cos; + + read_description (¶ms, "sin_cos.dsc"); + init_parameters (¶ms); + read_description (¶ms_sin, "sin.dsc"); + init_parameters (¶ms_sin); + read_description (¶ms_cos, "cos.dsc"); + init_parameters (¶ms_cos); + + /* ask for enough memory */ + set_output_precision (¶ms, 4 * prec_max); + set_input_precision (¶ms, prec_max); + set_reference_precision (¶ms, prec_max); + set_output_precision (¶ms_sin, 4 * prec_max); + set_input_precision (¶ms_sin, prec_max); + set_reference_precision (¶ms_sin, prec_max); + set_output_precision (¶ms_cos, 4 * prec_max); + set_input_precision (¶ms_cos, prec_max); + set_reference_precision (¶ms_cos, prec_max); + + /* sanity checks */ + exp_min = mpfr_get_emin (); + if (exp_max <= 0 || exp_max > mpfr_get_emax ()) + exp_max = mpfr_get_emax(); + if (-exp_max > exp_min) + exp_min = - exp_max; + if (step < 1) + step = 1; + + /* check consistency with quadruple precision for random parameters */ + for (prec = prec_min; prec <= prec_max; prec += step) + check_against_quadruple_precision (¶ms, ¶ms_sin, ¶ms_cos, + prec, exp_min, exp_max, -1); + + /* check consistency with quadruple precision for special values: + pure real, pure imaginary, or infinite arguments */ + for (special = 0; special < last_special ; special++) + check_against_quadruple_precision (¶ms, ¶ms_sin, ¶ms_cos, + prec_max, exp_min, exp_max, + special); + + clear_parameters (¶ms); + clear_parameters (¶ms_sin); + clear_parameters (¶ms_cos); +} + +static void +filter_params (mpc_fun_param_t *params_sin_cos, + mpc_fun_param_t *params, + int index) +{ + /* inex */ + params->P[0].mpc_inex = (index == 0) ? + MPC_INEX1 (params_sin_cos->P[0].mpc_inex) + : MPC_INEX2 (params_sin_cos->P[0].mpc_inex); + + /* output */ + mpc_set (params->P[1].mpc, params_sin_cos->P[1 + index].mpc, MPC_RNDNN); + + /* input */ + mpc_set (params->P[2].mpc, params_sin_cos->P[3].mpc, MPC_RNDNN); + + /* rnd mode is already set */ +} + +static void +gather_params (mpc_fun_param_t *params_sin_cos, + mpc_fun_param_t *params_sin, + mpc_fun_param_t *params_cos) +{ + /* do not check inex value */ + params_sin_cos->P[6].mpc_inex_data.real = TERNARY_NOT_CHECKED; + params_sin_cos->P[6].mpc_inex_data.imag = TERNARY_NOT_CHECKED; + + mpc_set (params_sin_cos->P[7].mpc_data.mpc, + params_sin->P[5].mpc_data.mpc, + MPC_RNDNN); + params_sin_cos->P[7].mpc_data.known_sign_real = -1; + params_sin_cos->P[7].mpc_data.known_sign_imag = -1; + + mpc_set (params_sin_cos->P[8].mpc_data.mpc, + params_cos->P[5].mpc_data.mpc, + MPC_RNDNN); + params_sin_cos->P[8].mpc_data.known_sign_real = -1; + params_sin_cos->P[8].mpc_data.known_sign_imag = -1; +} + +static void +gather_rounding_modes (mpc_fun_param_t *params_sin_cos, + mpc_fun_param_t *params_sin, + mpc_fun_param_t *params_cos) +{ + params_sin_cos->P[4].mpc_rnd = params_sin->P[3].mpc_rnd; + params_sin_cos->P[5].mpc_rnd = params_cos->P[3].mpc_rnd; +} + +static void +check_against_quadruple_precision (mpc_fun_param_t *params, + mpc_fun_param_t *params_sin, + mpc_fun_param_t *params_cos, + mpfr_prec_t prec, + mpfr_exp_t exp_min, mpfr_exp_t exp_max, + int special) +{ + mpc_operand_t *P = params->P; /* developer-friendly alias, used in macros */ + + set_input_precision (params, prec); + set_reference_precision (params, prec); + set_output_precision (params, 4 * prec); + + set_input_precision (params_sin, prec); + set_reference_precision (params_sin, prec); + set_output_precision (params_sin, 4 * prec); + + set_input_precision (params_cos, prec); + set_reference_precision (params_cos, prec); + set_output_precision (params_cos, 4 * prec); + + + for (first_rnd_mode (params_sin); + is_valid_rnd_mode (params_sin); + next_rnd_mode (params_sin)) + { + for (first_rnd_mode (params_cos); + is_valid_rnd_mode (params_cos); + next_rnd_mode (params_cos)) + { + gather_rounding_modes (params, params_sin, params_cos); + do + { + random_params (params, exp_min, exp_max, special); + P[0].mpc_inex = mpc_sin_cos (P[1].mpc, P[2].mpc, P[3].mpc, + P[4].mpc_rnd, P[5].mpc_rnd); + filter_params (params, params_sin, 0); + filter_params (params, params_cos, 1); + } while (double_rounding (params_sin) + || double_rounding (params_cos)); + gather_params (params, params_sin, params_cos); + + set_output_precision (params, prec); + P[0].mpc_inex = mpc_sin_cos (P[1].mpc, P[2].mpc, P[3].mpc, + P[4].mpc_rnd, P[5].mpc_rnd); + check_data (NULL, params, 0); + + set_output_precision (params, 4 * prec); + } + } +} + + +/* special cases */ + +enum { + SPECIAL_MINF, + SPECIAL_MZERO, + SPECIAL_PZERO, + SPECIAL_PINF, + SPECIAL_COUNT, +} special_case; + +static void +special_mpfr (mpfr_ptr x, int special) +{ + switch (special) + { + case SPECIAL_MINF: + mpfr_set_inf (x, -1); + break; + case SPECIAL_MZERO: + mpfr_set_zero (x, -1); + break; + case SPECIAL_PZERO: + mpfr_set_zero (x, +1); + break; + case SPECIAL_PINF: + mpfr_set_inf (x, +1); + break; + } +} + +static void +special_random_mpc (mpc_ptr z, mpfr_exp_t exp_min, mpfr_exp_t exp_max, + int special) +{ + mpfr_ptr special_part; + mpfr_ptr random_part; + int mpfr_special; + + if (special < SPECIAL_COUNT) + { + mpfr_special = special; + special_part = mpc_realref (z); + random_part = mpc_imagref (z); + } + else + { + mpfr_special = special - SPECIAL_COUNT; + special_part = mpc_imagref (z); + random_part = mpc_realref (z); + } + + special_mpfr (special_part, mpfr_special); + test_random_mpfr (random_part, exp_min, exp_max, 128); +} + +static void +random_params (mpc_fun_param_t *params, + mpfr_exp_t exp_min, mpfr_exp_t exp_max, + int special) +{ + int i; + int base_index = 0; + const int start = params->nbout; + const int end = start + params->nbin - 2; + + for (i = start; i < end; i++) + { + if (base_index <= special + && special - base_index < 2 * SPECIAL_COUNT) + special_random_mpc (params->P[i].mpc, exp_min, exp_max, + special - base_index); + else + test_random_mpc (params->P[i].mpc, exp_min, exp_max, 128); + base_index += 2 * SPECIAL_COUNT; + } +} + int main (void) { - DECL_FUNC (CC_C, f, mpc_sin_cos); - test_start (); - tgeneric (f, 2, 512, 13, 7); + tgeneric_custom (2, 512, 13, 7); test_end (); diff --git a/tests/tsin_cos_tmpl.c b/tests/tsin_cos_tmpl.c deleted file mode 100644 index d28c6e2..0000000 --- a/tests/tsin_cos_tmpl.c +++ /dev/null @@ -1,290 +0,0 @@ -/* tsin_cos_tmpl.c -- templated test file for mpc_sin_cos. - -Copyright (C) 2011, 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" - -static void random_params (mpc_fun_param_t *params, - mpfr_exp_t exp_min, mpfr_exp_t exp_max, - int special); -static void check_against_quadruple_precision (mpc_fun_param_t *params, - mpc_fun_param_t *params_sin, - mpc_fun_param_t *params_cos, - mpfr_prec_t prec, - mpfr_exp_t exp_min, - mpfr_exp_t exp_max, - int special); - -/* tgeneric(desc, prec_min, prec_max, step, exp_max) checks rounding with - random numbers: - - with precision ranging from prec_min to prec_max with an increment of - step, - - with exponent between -exp_max and exp_max. - - for pure real, pure imaginary and infinite random parameters. - - It also checks parameter reuse. -*/ -static void -tgeneric_custom (mpfr_prec_t prec_min, mpfr_prec_t prec_max, mpfr_prec_t step, - mpfr_exp_t exp_max) -{ - int special = 0; - const int last_special = 8; - mpfr_prec_t prec; - mpfr_exp_t exp_min; - mpc_fun_param_t params; - mpc_fun_param_t params_sin; - mpc_fun_param_t params_cos; - - read_description (¶ms, "sin_cos.dsc"); - init_parameters (¶ms); - read_description (¶ms_sin, "sin.dsc"); - init_parameters (¶ms_sin); - read_description (¶ms_cos, "cos.dsc"); - init_parameters (¶ms_cos); - - /* ask for enough memory */ - set_output_precision (¶ms, 4 * prec_max); - set_input_precision (¶ms, prec_max); - set_reference_precision (¶ms, prec_max); - set_output_precision (¶ms_sin, 4 * prec_max); - set_input_precision (¶ms_sin, prec_max); - set_reference_precision (¶ms_sin, prec_max); - set_output_precision (¶ms_cos, 4 * prec_max); - set_input_precision (¶ms_cos, prec_max); - set_reference_precision (¶ms_cos, prec_max); - - /* sanity checks */ - exp_min = mpfr_get_emin (); - if (exp_max <= 0 || exp_max > mpfr_get_emax ()) - exp_max = mpfr_get_emax(); - if (-exp_max > exp_min) - exp_min = - exp_max; - if (step < 1) - step = 1; - - /* check consistency with quadruple precision for random parameters */ - for (prec = prec_min; prec <= prec_max; prec += step) - check_against_quadruple_precision (¶ms, ¶ms_sin, ¶ms_cos, - prec, exp_min, exp_max, -1); - - /* check consistency with quadruple precision for special values: - pure real, pure imaginary, or infinite arguments */ - for (special = 0; special < last_special ; special++) - check_against_quadruple_precision (¶ms, ¶ms_sin, ¶ms_cos, - prec_max, exp_min, exp_max, - special); - - clear_parameters (¶ms); - clear_parameters (¶ms_sin); - clear_parameters (¶ms_cos); -} - -static void -filter_params (mpc_fun_param_t *params_sin_cos, - mpc_fun_param_t *params, - int index) -{ - /* inex */ - params->P[0].mpc_inex = (index == 0) ? - MPC_INEX1 (params_sin_cos->P[0].mpc_inex) - : MPC_INEX2 (params_sin_cos->P[0].mpc_inex); - - /* output */ - mpc_set (params->P[1].mpc, params_sin_cos->P[1 + index].mpc, MPC_RNDNN); - - /* input */ - mpc_set (params->P[2].mpc, params_sin_cos->P[3].mpc, MPC_RNDNN); - - /* rnd mode is already set */ -} - -static void -gather_params (mpc_fun_param_t *params_sin_cos, - mpc_fun_param_t *params_sin, - mpc_fun_param_t *params_cos) -{ - /* do not check inex value */ - params_sin_cos->P[6].mpc_inex_data.real = TERNARY_NOT_CHECKED; - params_sin_cos->P[6].mpc_inex_data.imag = TERNARY_NOT_CHECKED; - - mpc_set (params_sin_cos->P[7].mpc_data.mpc, - params_sin->P[5].mpc_data.mpc, - MPC_RNDNN); - params_sin_cos->P[7].mpc_data.known_sign_real = -1; - params_sin_cos->P[7].mpc_data.known_sign_imag = -1; - - mpc_set (params_sin_cos->P[8].mpc_data.mpc, - params_cos->P[5].mpc_data.mpc, - MPC_RNDNN); - params_sin_cos->P[8].mpc_data.known_sign_real = -1; - params_sin_cos->P[8].mpc_data.known_sign_imag = -1; -} - -static void -gather_rounding_modes (mpc_fun_param_t *params_sin_cos, - mpc_fun_param_t *params_sin, - mpc_fun_param_t *params_cos) -{ - params_sin_cos->P[4].mpc_rnd = params_sin->P[3].mpc_rnd; - params_sin_cos->P[5].mpc_rnd = params_cos->P[3].mpc_rnd; -} - -static void -check_against_quadruple_precision (mpc_fun_param_t *params, - mpc_fun_param_t *params_sin, - mpc_fun_param_t *params_cos, - mpfr_prec_t prec, - mpfr_exp_t exp_min, mpfr_exp_t exp_max, - int special) -{ - mpc_operand_t *P = params->P; /* developer-friendly alias, used in macros */ - - set_input_precision (params, prec); - set_reference_precision (params, prec); - set_output_precision (params, 4 * prec); - - set_input_precision (params_sin, prec); - set_reference_precision (params_sin, prec); - set_output_precision (params_sin, 4 * prec); - - set_input_precision (params_cos, prec); - set_reference_precision (params_cos, prec); - set_output_precision (params_cos, 4 * prec); - - - for (first_rnd_mode (params_sin); - is_valid_rnd_mode (params_sin); - next_rnd_mode (params_sin)) - { - for (first_rnd_mode (params_cos); - is_valid_rnd_mode (params_cos); - next_rnd_mode (params_cos)) - { - gather_rounding_modes (params, params_sin, params_cos); - do - { - random_params (params, exp_min, exp_max, special); - P[0].mpc_inex = mpc_sin_cos (P[1].mpc, P[2].mpc, P[3].mpc, - P[4].mpc_rnd, P[5].mpc_rnd); - filter_params (params, params_sin, 0); - filter_params (params, params_cos, 1); - } while (double_rounding (params_sin) - || double_rounding (params_cos)); - gather_params (params, params_sin, params_cos); - - set_output_precision (params, prec); - P[0].mpc_inex = mpc_sin_cos (P[1].mpc, P[2].mpc, P[3].mpc, - P[4].mpc_rnd, P[5].mpc_rnd); - check_data (NULL, params, 0); - - set_output_precision (params, 4 * prec); - } - } -} - - -/* special cases */ - -enum { - SPECIAL_MINF, - SPECIAL_MZERO, - SPECIAL_PZERO, - SPECIAL_PINF, - SPECIAL_COUNT, -} special_case; - -static void -special_mpfr (mpfr_ptr x, int special) -{ - switch (special) - { - case SPECIAL_MINF: - mpfr_set_inf (x, -1); - break; - case SPECIAL_MZERO: - mpfr_set_zero (x, -1); - break; - case SPECIAL_PZERO: - mpfr_set_zero (x, +1); - break; - case SPECIAL_PINF: - mpfr_set_inf (x, +1); - break; - } -} - -static void -special_random_mpc (mpc_ptr z, mpfr_exp_t exp_min, mpfr_exp_t exp_max, - int special) -{ - mpfr_ptr special_part; - mpfr_ptr random_part; - int mpfr_special; - - if (special < SPECIAL_COUNT) - { - mpfr_special = special; - special_part = mpc_realref (z); - random_part = mpc_imagref (z); - } - else - { - mpfr_special = special - SPECIAL_COUNT; - special_part = mpc_imagref (z); - random_part = mpc_realref (z); - } - - special_mpfr (special_part, mpfr_special); - test_random_mpfr (random_part, exp_min, exp_max, 128); -} - -static void -random_params (mpc_fun_param_t *params, - mpfr_exp_t exp_min, mpfr_exp_t exp_max, - int special) -{ - int i; - int base_index = 0; - const int start = params->nbout; - const int end = start + params->nbin - 2; - - for (i = start; i < end; i++) - { - if (base_index <= special - && special - base_index < 2 * SPECIAL_COUNT) - special_random_mpc (params->P[i].mpc, exp_min, exp_max, - special - base_index); - else - test_random_mpc (params->P[i].mpc, exp_min, exp_max, 128); - base_index += 2 * SPECIAL_COUNT; - } -} - -int -main (void) -{ - test_start (); - - tgeneric_custom (2, 512, 13, 7); - - test_end (); - - return 0; -} diff --git a/tests/tsin_tmpl.c b/tests/tsin_tmpl.c deleted file mode 100644 index 7f66e54..0000000 --- a/tests/tsin_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* tsin_tmpl -- templated test file for mpc_sin. - -Copyright (C) 2007, 2008, 2010, 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_sin (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_sin (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("sin.dsc", "sin.dat"); - - tgeneric_template ("sin.dsc", 2, 512, 7, 7); - - test_end (); - - return 0; -} diff --git a/tests/tsinh.c b/tests/tsinh.c index c12f036..48e362a 100644 --- a/tests/tsinh.c +++ b/tests/tsinh.c @@ -1,6 +1,6 @@ /* tsinh -- test file for mpc_sinh. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_sinh (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_sinh (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_sinh); - test_start (); - data_check (f, "sinh.dat"); - tgeneric (f, 2, 512, 7, 7); + data_check_template ("sinh.dsc", "sinh.dat"); + + tgeneric_template ("sinh.dsc", 2, 512, 7, 7); test_end (); diff --git a/tests/tsinh_tmpl.c b/tests/tsinh_tmpl.c deleted file mode 100644 index 909229b..0000000 --- a/tests/tsinh_tmpl.c +++ /dev/null @@ -1,44 +0,0 @@ -/* tsinh_tmpl -- templated test file for mpc_sinh. - -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_sinh (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_sinh (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("sinh.dsc", "sinh.dat"); - - tgeneric_template ("sinh.dsc", 2, 512, 7, 7); - - test_end (); - - return 0; -} diff --git a/tests/tsqr.c b/tests/tsqr.c index 2ec2099..fa4350a 100644 --- a/tests/tsqr.c +++ b/tests/tsqr.c @@ -1,6 +1,6 @@ /* tsqr -- test file for mpc_sqr. -Copyright (C) 2002, 2005, 2008, 2010, 2011, 2012 INRIA +Copyright (C) 2002, 2005, 2008, 2010, 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -164,10 +164,17 @@ reuse_bug (void) mpc_clear (z1); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_sqr (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_sqr (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_sqr); test_start (); testsqr (247, -65, 8, 24); @@ -180,8 +187,9 @@ main (void) testsqr (0, 1816, 8, 24); testsqr (145, 0, 8, 24); - data_check (f, "sqr.dat"); - tgeneric (f, 2, 1024, 1, 0); + data_check_template ("sqr.dsc", "sqr.dat"); + + tgeneric_template ("sqr.dsc", 2, 1024, 1, 1024); reuse_bug (); diff --git a/tests/tsqr_tmpl.c b/tests/tsqr_tmpl.c deleted file mode 100644 index b39e89f..0000000 --- a/tests/tsqr_tmpl.c +++ /dev/null @@ -1,199 +0,0 @@ -/* tsqr_tmpl.c -- test file for mpc_sqr. - -Copyright (C) 2002, 2005, 2008, 2010, 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 -#include "templates.h" - -static void -cmpsqr (mpc_srcptr x, mpc_rnd_t rnd) - /* computes the square of x with the specific function or by simple */ - /* multiplication using the rounding mode rnd and compares the results */ - /* and return values. */ - /* In our current test suite, the real and imaginary parts of x have */ - /* the same precision, and we use this precision also for the result. */ - /* Furthermore, we check whether computing the square in the same */ - /* place yields the same result. */ - /* We also compute the result with four times the precision and check */ - /* whether the rounding is correct. Error reports in this part of the */ - /* algorithm might still be wrong, though, since there are two */ - /* consecutive roundings. */ -{ - mpc_t z, t, u; - int inexact_z, inexact_t; - - mpc_init2 (z, MPC_MAX_PREC (x)); - mpc_init2 (t, MPC_MAX_PREC (x)); - mpc_init2 (u, 4 * MPC_MAX_PREC (x)); - - inexact_z = mpc_sqr (z, x, rnd); - inexact_t = mpc_mul (t, x, x, rnd); - - if (mpc_cmp (z, t)) - { - fprintf (stderr, "sqr and mul differ for rnd=(%s,%s) \nx=", - mpfr_print_rnd_mode(MPC_RND_RE(rnd)), - mpfr_print_rnd_mode(MPC_RND_IM(rnd))); - mpc_out_str (stderr, 2, 0, x, MPC_RNDNN); - fprintf (stderr, "\nmpc_sqr gives "); - mpc_out_str (stderr, 2, 0, z, MPC_RNDNN); - fprintf (stderr, "\nmpc_mul gives "); - mpc_out_str (stderr, 2, 0, t, MPC_RNDNN); - fprintf (stderr, "\n"); - exit (1); - } - if (inexact_z != inexact_t) - { - fprintf (stderr, "The return values of sqr and mul differ for rnd=(%s,%s) \nx= ", - mpfr_print_rnd_mode(MPC_RND_RE(rnd)), - mpfr_print_rnd_mode(MPC_RND_IM(rnd))); - mpc_out_str (stderr, 2, 0, x, MPC_RNDNN); - fprintf (stderr, "\nx^2="); - mpc_out_str (stderr, 2, 0, z, MPC_RNDNN); - fprintf (stderr, "\nmpc_sqr gives %i", inexact_z); - fprintf (stderr, "\nmpc_mul gives %i", inexact_t); - fprintf (stderr, "\n"); - exit (1); - } - - mpc_set (t, x, MPC_RNDNN); - inexact_t = mpc_sqr (t, t, rnd); - if (mpc_cmp (z, t)) - { - fprintf (stderr, "sqr and sqr in place differ for rnd=(%s,%s) \nx=", - mpfr_print_rnd_mode(MPC_RND_RE(rnd)), - mpfr_print_rnd_mode(MPC_RND_IM(rnd))); - mpc_out_str (stderr, 2, 0, x, MPC_RNDNN); - fprintf (stderr, "\nmpc_sqr gives "); - mpc_out_str (stderr, 2, 0, z, MPC_RNDNN); - fprintf (stderr, "\nmpc_sqr in place gives "); - mpc_out_str (stderr, 2, 0, t, MPC_RNDNN); - fprintf (stderr, "\n"); - exit (1); - } - if (inexact_z != inexact_t) - { - fprintf (stderr, "The return values of sqr and sqr in place differ for rnd=(%s,%s) \nx= ", - mpfr_print_rnd_mode(MPC_RND_RE(rnd)), - mpfr_print_rnd_mode(MPC_RND_IM(rnd))); - mpc_out_str (stderr, 2, 0, x, MPC_RNDNN); - fprintf (stderr, "\nx^2="); - mpc_out_str (stderr, 2, 0, z, MPC_RNDNN); - fprintf (stderr, "\nmpc_sqr gives %i", inexact_z); - fprintf (stderr, "\nmpc_sqr in place gives %i", inexact_t); - fprintf (stderr, "\n"); - exit (1); - } - - mpc_sqr (u, x, rnd); - mpc_set (t, u, rnd); - if (mpc_cmp (z, t)) - { - fprintf (stderr, "rounding in sqr might be incorrect for rnd=(%s,%s) \nx=", - mpfr_print_rnd_mode(MPC_RND_RE(rnd)), - mpfr_print_rnd_mode(MPC_RND_IM(rnd))); - mpc_out_str (stderr, 2, 0, x, MPC_RNDNN); - fprintf (stderr, "\nmpc_sqr gives "); - mpc_out_str (stderr, 2, 0, z, MPC_RNDNN); - fprintf (stderr, "\nmpc_sqr quadruple precision gives "); - mpc_out_str (stderr, 2, 0, u, MPC_RNDNN); - fprintf (stderr, "\nand is rounded to "); - mpc_out_str (stderr, 2, 0, t, MPC_RNDNN); - fprintf (stderr, "\n"); - exit (1); - } - - mpc_clear (z); - mpc_clear (t); - mpc_clear (u); -} - - -static void -testsqr (long a, long b, mpfr_prec_t prec, mpc_rnd_t rnd) -{ - mpc_t x; - - mpc_init2 (x, prec); - - mpc_set_si_si (x, a, b, rnd); - - cmpsqr (x, rnd); - - mpc_clear (x); -} - - -static void -reuse_bug (void) -{ - mpc_t z1; - - /* reuse bug found by Paul Zimmermann 20081021 */ - mpc_init2 (z1, 2); - /* RE (z1^2) overflows, IM(z^2) = -0 */ - mpfr_set_str (mpc_realref (z1), "0.11", 2, MPFR_RNDN); - mpfr_mul_2si (mpc_realref (z1), mpc_realref (z1), mpfr_get_emax (), MPFR_RNDN); - mpfr_set_ui (mpc_imagref (z1), 0, MPFR_RNDN); - mpc_conj (z1, z1, MPC_RNDNN); - mpc_sqr (z1, z1, MPC_RNDNN); - if (!mpfr_inf_p (mpc_realref (z1)) || mpfr_signbit (mpc_realref (z1)) - ||!mpfr_zero_p (mpc_imagref (z1)) || !mpfr_signbit (mpc_imagref (z1))) - { - printf ("Error: Regression, bug 20081021 reproduced\n"); - MPC_OUT (z1); - exit (1); - } - - mpc_clear (z1); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_sqr (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_sqr (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - testsqr (247, -65, 8, 24); - testsqr (5, -896, 3, 2); - testsqr (-3, -512, 2, 16); - testsqr (266013312, 121990769, 27, 0); - testsqr (170, 9, 8, 0); - testsqr (768, 85, 8, 16); - testsqr (145, 1816, 8, 24); - testsqr (0, 1816, 8, 24); - testsqr (145, 0, 8, 24); - - data_check_template ("sqr.dsc", "sqr.dat"); - - tgeneric_template ("sqr.dsc", 2, 1024, 1, 1024); - - reuse_bug (); - - test_end (); - - return 0; -} diff --git a/tests/tsqrt.c b/tests/tsqrt.c index 2da6842..17d05c3 100644 --- a/tests/tsqrt.c +++ b/tests/tsqrt.c @@ -1,6 +1,6 @@ /* tsqrt -- test file for mpc_sqrt. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_sqrt (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_sqrt (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_sqrt); - test_start (); - data_check (f, "sqrt.dat"); - tgeneric (f, 2, 1024, 7, 256); + data_check_template ("sqrt.dsc", "sqrt.dat"); + + tgeneric_template ("sqrt.dsc", 2, 1024, 7, 256); test_end (); diff --git a/tests/tsqrt_tmpl.c b/tests/tsqrt_tmpl.c deleted file mode 100644 index 7674d54..0000000 --- a/tests/tsqrt_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* tsqrt_tmpl.c -- templated test file for mpc_sqrt. - -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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_sqrt (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_sqrt (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("sqrt.dsc", "sqrt.dat"); - - tgeneric_template ("sqrt.dsc", 2, 1024, 7, 256); - - test_end (); - - return 0; -} diff --git a/tests/tstrtoc.c b/tests/tstrtoc.c index 77e34ee..fd1711c 100644 --- a/tests/tstrtoc.c +++ b/tests/tstrtoc.c @@ -28,7 +28,7 @@ extern int nextchar; extern char *pathname; /* names of rounding modes */ -extern const char *rnd_mode[]; +extern const char *mpc_rnd_mode[]; static void check_file (const char* file_name) @@ -103,7 +103,7 @@ check_file (const char* file_name) { printf ("mpc_strtoc(str) failed (line %lu)\nwith base=%d and " "rounding mode %s\n", test_line_number, base, - rnd_mode[rnd]); + mpc_rnd_mode[rnd]); if (inex != MPC_INEX (inex_re, inex_im)) printf ("ternary value: got %s, expected (%s, %s)\n", MPC_INEX_STR (inex), diff --git a/tests/tsub.c b/tests/tsub.c index 658c81e..f9e6e74 100644 --- a/tests/tsub.c +++ b/tests/tsub.c @@ -1,6 +1,6 @@ /* tsub -- test file for mpc_sub. -Copyright (C) 2008, 2011 INRIA +Copyright (C) 2008, 2011, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,24 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_sub (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_sub (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP2 \ + P[0].mpc_inex = mpc_sub (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (C_CC, f, mpc_sub); - test_start (); - data_check (f, "sub.dat"); - tgeneric (f, 2, 1024, 7, -1); + data_check_template ("sub.dsc", "sub.dat"); + + tgeneric_template ("sub.dsc", 2, 1024, 7, 128); test_end (); diff --git a/tests/tsub_fr.c b/tests/tsub_fr.c index 495fdee..6158c65 100644 --- a/tests/tsub_fr.c +++ b/tests/tsub_fr.c @@ -1,6 +1,6 @@ /* tsub_fr -- test file for mpc_sub_fr. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #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" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCF, f, mpc_sub_fr); - test_start (); - data_check (f, "sub_fr.dat"); - tgeneric (f, 2, 1024, 7, -1); + data_check_template ("sub_fr.dsc", "sub_fr.dat"); + + tgeneric_template ("sub_fr.dsc", 2, 1024, 7, 128); test_end (); diff --git a/tests/tsub_fr_tmpl.c b/tests/tsub_fr_tmpl.c deleted file mode 100644 index 0f7c287..0000000 --- a/tests/tsub_fr_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* 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" - -#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" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("sub_fr.dsc", "sub_fr.dat"); - - tgeneric_template ("sub_fr.dsc", 2, 1024, 7, 128); - - test_end (); - - return 0; -} diff --git a/tests/tsub_tmpl.c b/tests/tsub_tmpl.c deleted file mode 100644 index 77fff84..0000000 --- a/tests/tsub_tmpl.c +++ /dev/null @@ -1,45 +0,0 @@ -/* tsub_tmpl.c -- templated test file for mpc_sub. - -Copyright (C) 2008, 2011, 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_sub (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_sub (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP2 \ - P[0].mpc_inex = mpc_sub (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("sub.dsc", "sub.dat"); - - tgeneric_template ("sub.dsc", 2, 1024, 7, 128); - - test_end (); - - return 0; -} diff --git a/tests/tsub_ui.c b/tests/tsub_ui.c index 567ead5..153b5db 100644 --- a/tests/tsub_ui.c +++ b/tests/tsub_ui.c @@ -1,6 +1,6 @@ /* tsub_ui -- test file for mpc_sub_ui. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,14 +20,19 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_sub_ui (P[1].mpc, P[2].mpc, P[3].ui, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_sub_ui (P[1].mpc, P[1].mpc, P[3].ui, P[4].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CCU, f, mpc_sub_ui); - test_start (); - tgeneric (f, 2, 1024, 7, -1); + tgeneric_template ("sub_ui.dsc", 2, 1024, 7, 1024); test_end (); diff --git a/tests/tsub_ui_tmpl.c b/tests/tsub_ui_tmpl.c deleted file mode 100644 index 4fc8e5e..0000000 --- a/tests/tsub_ui_tmpl.c +++ /dev/null @@ -1,40 +0,0 @@ -/* tsub_ui_tmpl.c -- templated test file for mpc_sub_ui. - -Copyright (C) 2008 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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_sub_ui (P[1].mpc, P[2].mpc, P[3].ui, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_sub_ui (P[1].mpc, P[1].mpc, P[3].ui, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - tgeneric_template ("sub_ui.dsc", 2, 1024, 7, 1024); - - test_end (); - - return 0; -} diff --git a/tests/ttan.c b/tests/ttan.c index c7c672c..db2d3f9 100644 --- a/tests/ttan.c +++ b/tests/ttan.c @@ -1,6 +1,6 @@ /* ttan -- test file for mpc_tan. -Copyright (C) 2008, 2011, 2012 INRIA +Copyright (C) 2008, 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -197,16 +197,24 @@ pure_imaginary_argument (void) mpfr_clear (y); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_tan (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_tan (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_tan); - test_start (); - data_check (f, "tan.dat"); - tgeneric (f, 2, 512, 7, 4); + data_check_template ("tan.dsc", "tan.dat"); + + tgeneric_template ("tan.dsc", 2, 512, 7, 4); + /* FIXME: remove them? */ pure_real_argument (); pure_imaginary_argument (); diff --git a/tests/ttan_tmpl.c b/tests/ttan_tmpl.c deleted file mode 100644 index d74a74a..0000000 --- a/tests/ttan_tmpl.c +++ /dev/null @@ -1,224 +0,0 @@ -/* ttan_tmpl -- templated test file for mpc_tan. - -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 -#include "templates.h" - -static void -pure_real_argument (void) -{ - /* tan(x -i*0) = tan(x) -i*0 */ - /* tan(x +i*0) = tan(x) +i*0 */ - mpfr_t x; - mpfr_t tan_x; - mpc_t z; - mpc_t tan_z; - - mpfr_init2 (x, 79); - mpfr_init2 (tan_x, 113); - mpc_init2 (z, 79); - mpc_init2 (tan_z, 113); - - /* tan(1 +i*0) = tan(1) +i*0 */ - mpc_set_ui_ui (z, 1, 0, MPC_RNDNN); - mpfr_set_ui (x, 1, MPFR_RNDN); - mpfr_tan (tan_x, x, MPFR_RNDN); - mpc_tan (tan_z, z, MPC_RNDNN); - if (mpfr_cmp (mpc_realref (tan_z), tan_x) != 0 - || !mpfr_zero_p (mpc_imagref (tan_z)) || mpfr_signbit (mpc_imagref (tan_z))) - { - printf ("mpc_tan(1 + i * 0) failed\n"); - exit (1); - } - - /* tan(1 -i*0) = tan(1) -i*0 */ - mpc_conj (z, z, MPC_RNDNN); - mpc_tan (tan_z, z, MPC_RNDNN); - if (mpfr_cmp (mpc_realref (tan_z), tan_x) != 0 - || !mpfr_zero_p (mpc_imagref (tan_z)) || !mpfr_signbit (mpc_imagref (tan_z))) - { - printf ("mpc_tan(1 - i * 0) failed\n"); - exit (1); - } - - /* tan(Pi/2 +i*0) = +Inf +i*0 */ - mpfr_const_pi (x, MPFR_RNDN); - mpfr_div_2ui (x, x, 1, MPFR_RNDN); - mpfr_set (mpc_realref (z), x, MPFR_RNDN); - mpfr_set_ui (mpc_imagref (z), 0, MPFR_RNDN); - mpfr_tan (tan_x, x, MPFR_RNDN); - mpc_tan (tan_z, z, MPC_RNDNN); - if (mpfr_cmp (mpc_realref (tan_z), tan_x) != 0 - || !mpfr_zero_p (mpc_imagref (tan_z)) || mpfr_signbit (mpc_imagref (tan_z))) - { - printf ("mpc_tan(Pi/2 + i * 0) failed\n"); - exit (1); - } - - /* tan(Pi/2 -i*0) = +Inf -i*0 */ - mpc_conj (z, z, MPC_RNDNN); - mpc_tan (tan_z, z, MPC_RNDNN); - if (mpfr_cmp (mpc_realref (tan_z), tan_x) != 0 - || !mpfr_zero_p (mpc_imagref (tan_z)) || !mpfr_signbit (mpc_imagref (tan_z))) - { - printf ("mpc_tan(Pi/2 - i * 0) failed\n"); - exit (1); - } - - /* tan(-Pi/2 +i*0) = -Inf +i*0 */ - mpfr_neg (x, x, MPFR_RNDN); - mpc_neg (z, z, MPC_RNDNN); - mpfr_tan (tan_x, x, MPFR_RNDN); - mpc_tan (tan_z, z, MPC_RNDNN); - if (mpfr_cmp (mpc_realref (tan_z), tan_x) != 0 - || !mpfr_zero_p (mpc_imagref (tan_z)) || mpfr_signbit (mpc_imagref (tan_z))) - { - printf ("mpc_tan(-Pi/2 + i * 0) failed\n"); - exit (1); - } - - /* tan(-Pi/2 -i*0) = -Inf -i*0 */ - mpc_conj (z, z, MPC_RNDNN); - mpc_tan (tan_z, z, MPC_RNDNN); - if (mpfr_cmp (mpc_realref (tan_z), tan_x) != 0 - || !mpfr_zero_p (mpc_imagref (tan_z)) || !mpfr_signbit (mpc_imagref (tan_z))) - { - printf ("mpc_tan(-Pi/2 - i * 0) failed\n"); - exit (1); - } - - mpc_clear (tan_z); - mpc_clear (z); - mpfr_clear (tan_x); - mpfr_clear (x); -} - -static void -pure_imaginary_argument (void) -{ - /* tan(-0 +i*y) = -0 +i*tanh(y) */ - /* tan(+0 +i*y) = +0 +i*tanh(y) */ - mpfr_t y; - mpfr_t tanh_y; - mpc_t z; - mpc_t tan_z; - mpfr_prec_t prec = (mpfr_prec_t) 111; - - mpfr_init2 (y, 2); - mpfr_init2 (tanh_y, prec); - mpc_init2 (z, 2); - mpc_init2 (tan_z, prec); - - /* tan(0 +i) = +0 +i*tanh(1) */ - mpc_set_ui_ui (z, 0, 1, MPC_RNDNN); - mpfr_set_ui (y, 1, MPFR_RNDN); - mpfr_tanh (tanh_y, y, MPFR_RNDN); - mpc_tan (tan_z, z, MPC_RNDNN); - if (mpfr_cmp (mpc_imagref (tan_z), tanh_y) != 0 - || !mpfr_zero_p (mpc_realref (tan_z)) || mpfr_signbit (mpc_realref (tan_z))) - { - mpc_t c99; - - mpc_init2 (c99, prec); - mpfr_set_ui (mpc_realref (c99), 0, MPFR_RNDN); - mpfr_set (mpc_imagref (c99), tanh_y, MPFR_RNDN); - - TEST_FAILED ("mpc_tan", z, tan_z, c99, MPC_RNDNN); - } - - /* tan(0 -i) = +0 +i*tanh(-1) */ - mpc_conj (z, z, MPC_RNDNN); - mpfr_neg (tanh_y, tanh_y, MPFR_RNDN); - mpc_tan (tan_z, z, MPC_RNDNN); - if (mpfr_cmp (mpc_imagref (tan_z), tanh_y) != 0 - || !mpfr_zero_p (mpc_realref (tan_z)) || mpfr_signbit (mpc_realref (tan_z))) - { - mpc_t c99; - - mpc_init2 (c99, prec); - mpfr_set_ui (mpc_realref (c99), 0, MPFR_RNDN); - mpfr_set (mpc_imagref (c99), tanh_y, MPFR_RNDN); - - TEST_FAILED ("mpc_tan", z, tan_z, c99, MPC_RNDNN); - } - - /* tan(-0 +i) = -0 +i*tanh(1) */ - mpc_neg (z, z, MPC_RNDNN); - mpfr_neg (tanh_y, tanh_y, MPFR_RNDN); - mpc_tan (tan_z, z, MPC_RNDNN); - if (mpfr_cmp (mpc_imagref (tan_z), tanh_y) != 0 - || !mpfr_zero_p (mpc_realref (tan_z)) || !mpfr_signbit (mpc_realref (tan_z))) - { - mpc_t c99; - - mpc_init2 (c99, prec); - mpfr_set_ui (mpc_realref (c99), 0, MPFR_RNDN); - mpfr_set (mpc_imagref (c99), tanh_y, MPFR_RNDN); - - TEST_FAILED ("mpc_tan", z, tan_z, c99, MPC_RNDNN); - } - - /* tan(-0 -i) = -0 +i*tanh(-1) */ - mpc_conj (z, z, MPC_RNDNN); - mpfr_neg (tanh_y, tanh_y, MPFR_RNDN); - mpc_tan (tan_z, z, MPC_RNDNN); - if (mpfr_cmp (mpc_imagref (tan_z), tanh_y) != 0 - || !mpfr_zero_p (mpc_realref (tan_z)) || !mpfr_signbit (mpc_realref (tan_z))) - { - mpc_t c99; - - mpc_init2 (c99, prec); - mpfr_set_ui (mpc_realref (c99), 0, MPFR_RNDN); - mpfr_set (mpc_imagref (c99), tanh_y, MPFR_RNDN); - - TEST_FAILED ("mpc_tan", z, tan_z, c99, MPC_RNDNN); - } - - mpc_clear (tan_z); - mpc_clear (z); - mpfr_clear (tanh_y); - mpfr_clear (y); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_tan (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_tan (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("tan.dsc", "tan.dat"); - - tgeneric_template ("tan.dsc", 2, 512, 7, 4); - - /* FIXME: remove them? */ - pure_real_argument (); - pure_imaginary_argument (); - - test_end (); - - return 0; -} diff --git a/tests/ttanh.c b/tests/ttanh.c index 26d9fbe..2312b9e 100644 --- a/tests/ttanh.c +++ b/tests/ttanh.c @@ -1,6 +1,6 @@ /* ttanh -- test file for mpc_tanh. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,15 +20,22 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_tanh (P[1].mpc, P[2].mpc, P[3].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP1 \ + P[0].mpc_inex = mpc_tanh (P[1].mpc, P[1].mpc, P[3].mpc_rnd) + +#include "data_check.tpl" +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CC, f, mpc_tanh); - test_start (); - data_check (f, "tanh.dat"); - tgeneric (f, 2, 512, 7, 4); + data_check_template ("tanh.dsc", "tanh.dat"); + + tgeneric_template ("tanh.dsc", 2, 512, 7, 4); test_end (); diff --git a/tests/ttanh_tmpl.c b/tests/ttanh_tmpl.c deleted file mode 100644 index ca4f457..0000000 --- a/tests/ttanh_tmpl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ttanh_tmpl -- templated test file for mpc_tanh. - -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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_tanh (P[1].mpc, P[2].mpc, P[3].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP1 \ - P[0].mpc_inex = mpc_tanh (P[1].mpc, P[1].mpc, P[3].mpc_rnd) - -#include "data_check.tpl" -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - data_check_template ("tanh.dsc", "tanh.dat"); - - tgeneric_template ("tanh.dsc", 2, 512, 7, 4); - - test_end (); - - return 0; -} diff --git a/tests/tui_div.c b/tests/tui_div.c index 40c740a..f63711a 100644 --- a/tests/tui_div.c +++ b/tests/tui_div.c @@ -1,6 +1,6 @@ /* tui_div -- test file for mpc_ui_div. -Copyright (C) 2008, 2011, 2012 INRIA +Copyright (C) 2008, 2011, 2012, 2013 INRIA This file is part of GNU MPC. @@ -21,7 +21,7 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" static void -special (void) +test_special (void) { mpc_t a, b; @@ -85,16 +85,21 @@ special (void) mpc_clear (b); } +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_ui_div (P[1].mpc, P[2].ui, P[3].mpc, P[4].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP2 \ + P[0].mpc_inex = mpc_ui_div (P[1].mpc, P[2].ui, P[1].mpc, P[4].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CUC, f, mpc_ui_div); - test_start (); - special (); + test_special (); - tgeneric (f, 2, 1024, 7, 4096); + tgeneric_template ("ui_div.dsc", 2, 1024, 7, 4096); test_end (); diff --git a/tests/tui_div_tmpl.c b/tests/tui_div_tmpl.c deleted file mode 100644 index 58dd50e..0000000 --- a/tests/tui_div_tmpl.c +++ /dev/null @@ -1,107 +0,0 @@ -/* tui_div_tmpl -- templatesd test file for mpc_ui_div. - -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" - -static void -test_special (void) -{ - mpc_t a, b; - - mpc_init2 (a, 10); - mpc_init2 (b, 10); - - mpc_set_ui_ui (a, 2, 4, MPC_RNDNN); - mpc_ui_div (b, 10, a, MPC_RNDNN); - if (mpc_cmp_si_si (b, 1, -2) != 0) - { - printf ("10/(2,4) failed\n"); - printf ("expected (1,-2)\n"); - printf ("got "); - mpc_out_str (stdout, 10, 0, b, MPC_RNDNN); - printf ("\n"); - exit (1); - } - - /* 0/(-1-0*I) should give (-0, +0) */ - mpfr_set_str (mpc_realref(a), "-1", 10, MPFR_RNDN); - mpfr_set_str (mpc_imagref(a), "-0", 10, MPFR_RNDN); - mpc_ui_div (b, 0, a, MPC_RNDNN); - if ((mpc_cmp_si_si (b, 0, 0) != 0) || (MPFR_SIGN (mpc_realref(b)) > 0) - || (MPFR_SIGN (mpc_imagref(b)) < 0)) - { - printf ("0/(-1,-0) failed\n"); - printf ("expected (-0,+0)\n"); - printf ("got "); - mpc_out_str (stdout, 10, 0, b, MPC_RNDNN); - printf ("\n"); - exit (1); - } - - mpc_set_ui_ui (a, 1, 0, MPC_RNDNN); - mpc_ui_div (b, 1, a, MPC_RNDNN); - if (mpc_cmp_si_si (b, 1, 0) != 0) - { - printf ("1/(1,0) failed\n"); - printf ("expected (1,0)\n"); - printf ("got "); - mpc_out_str (stdout, 10, 0, b, MPC_RNDNN); - printf ("\n"); - exit (1); - } - - /* problem reported by Timo Hartmann with mpc-0.7, 21 Oct 2009 */ - mpc_set_ui_ui (a, 4, 0, MPC_RNDNN); - mpc_ui_div (b, 1, a, MPC_RNDNN); - if (mpfr_cmp_ui_2exp (mpc_realref(b), 1, -2) != 0 || - mpfr_cmp_ui (mpc_imagref(b), 0) != 0 || mpfr_signbit (mpc_imagref(b)) != 0) - { - printf ("1/(4,0) failed\n"); - printf ("expected (1/4,0)\n"); - printf ("got "); - mpc_out_str (stdout, 10, 0, b, MPC_RNDNN); - printf ("\n"); - exit (1); - } - - mpc_clear (a); - mpc_clear (b); -} - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_ui_div (P[1].mpc, P[2].ui, P[3].mpc, P[4].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP2 \ - P[0].mpc_inex = mpc_ui_div (P[1].mpc, P[2].ui, P[1].mpc, P[4].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - test_special (); - - tgeneric_template ("ui_div.dsc", 2, 1024, 7, 4096); - - test_end (); - - return 0; -} diff --git a/tests/tui_ui_sub.c b/tests/tui_ui_sub.c index 67c9071..d2a91eb 100644 --- a/tests/tui_ui_sub.c +++ b/tests/tui_ui_sub.c @@ -1,6 +1,6 @@ /* tui_ui_sub -- test file for mpc_ui_ui_sub. -Copyright (C) 2008 INRIA +Copyright (C) 2008, 2013 INRIA This file is part of GNU MPC. @@ -20,14 +20,19 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +#define MPC_FUNCTION_CALL \ + P[0].mpc_inex = mpc_ui_ui_sub (P[1].mpc, P[2].ui, P[3].ui, P[4].mpc, P[5].mpc_rnd) +#define MPC_FUNCTION_CALL_REUSE_OP3 \ + P[0].mpc_inex = mpc_ui_ui_sub (P[1].mpc, P[2].ui, P[3].ui, P[4].mpc, P[5].mpc_rnd) + +#include "tgeneric.tpl" + int main (void) { - DECL_FUNC (CUUC, f, mpc_ui_ui_sub); - test_start (); - tgeneric (f, 2, 1024, 7, -1); + tgeneric_template ("ui_ui_sub.dsc", 2, 1024, 7, 1024); test_end (); diff --git a/tests/tui_ui_sub_tmpl.c b/tests/tui_ui_sub_tmpl.c deleted file mode 100644 index 5b7c608..0000000 --- a/tests/tui_ui_sub_tmpl.c +++ /dev/null @@ -1,40 +0,0 @@ -/* tui_ui_sub_tmpl -- templated test file for mpc_ui_ui_sub. - -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" - -#define MPC_FUNCTION_CALL \ - P[0].mpc_inex = mpc_ui_ui_sub (P[1].mpc, P[2].ui, P[3].ui, P[4].mpc, P[5].mpc_rnd) -#define MPC_FUNCTION_CALL_REUSE_OP3 \ - P[0].mpc_inex = mpc_ui_ui_sub (P[1].mpc, P[2].ui, P[3].ui, P[4].mpc, P[5].mpc_rnd) - -#include "tgeneric.tpl" - -int -main (void) -{ - test_start (); - - tgeneric_template ("ui_ui_sub.dsc", 2, 1024, 7, 1024); - - test_end (); - - return 0; -} -- cgit v1.2.1