diff options
Diffstat (limited to 'mpfr/tests/texp.c')
-rw-r--r-- | mpfr/tests/texp.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/mpfr/tests/texp.c b/mpfr/tests/texp.c index a441c2ea7..c613ab836 100644 --- a/mpfr/tests/texp.c +++ b/mpfr/tests/texp.c @@ -1,25 +1,26 @@ /* Test file for mpfr_exp. -Copyright (C) 1999 Free Software Foundation. +Copyright (C) 1999, 2001 Free Software Foundation, Inc. This file is part of the MPFR Library. The MPFR Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Library General Public License as published by -the Free Software Foundation; either version 2 of the License, or (at your +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The MPFR Library 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 Library General Public +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 Library General Public License +You should have received a copy of the GNU Lesser General Public License along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <math.h> +#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "gmp.h" @@ -31,6 +32,8 @@ int check_large _PROTO((double, int, mp_rnd_t)); int check_worst_case _PROTO((double, double)); int check_worst_cases _PROTO((void)); void compare_exp2_exp3 _PROTO((int)); +extern int mpfr_exp_2 _PROTO((mpfr_ptr, mpfr_srcptr, mp_rnd_t)); +extern int mpfr_exp3 _PROTO((mpfr_ptr, mpfr_srcptr, mp_rnd_t)); int maxu=0; @@ -154,10 +157,10 @@ int check_worst_cases () mpfr_set_prec (x, 601); mpfr_set_str_raw (x, "0.1000100010110110101110100101000100001110000100000100010100001110110111000010010110000111010010001011110010011101111111011101010001100110111100100001101101000111111011010010011001001100110111110010010010101010100011110110010010101111000111110011111110101101100111101100001000110000000111010100001111000000011101000011111101010011010010110101101010100010000000001001000111111111011011010011010100101101111101000101100011101111000110111010010100011001100000010001111011110110111101011011000100011000010100110101001101001111110110001111101000110010011101100100101000001010011011010010110100001101110100100E0"); mpfr_init2 (y, 601); - mpfr_exp2 (y, x, GMP_RNDD); + mpfr_exp_2 (y, x, GMP_RNDD); mpfr_exp3 (x, x, GMP_RNDD); if (mpfr_cmp (x, y)) { - fprintf (stderr, "mpfr_exp2 and mpfr_exp3 for prec=601\n"); + fprintf (stderr, "mpfr_exp_2 and mpfr_exp3 for prec=601\n"); exit (1); } @@ -175,13 +178,13 @@ void compare_exp2_exp3 (int n) mpfr_set_prec(x, prec); mpfr_set_prec(y, prec); mpfr_set_prec(z, prec); mpfr_random(x); rnd = rand() % 4; - mpfr_exp2 (y, x, rnd); + mpfr_exp_2 (y, x, rnd); mpfr_exp3 (z, x, rnd); if (mpfr_cmp(y,z)) { - printf("mpfr_exp2 and mpfr_exp3 disagree for rnd=%s and\nx=", + printf("mpfr_exp_2 and mpfr_exp3 disagree for rnd=%s and\nx=", mpfr_print_rnd_mode(rnd)); mpfr_print_raw(x); putchar('\n'); - printf("mpfr_exp2 gives "); mpfr_print_raw(y); putchar('\n'); + printf("mpfr_exp_2 gives "); mpfr_print_raw(y); putchar('\n'); printf("mpfr_exp3 gives "); mpfr_print_raw(z); putchar('\n'); exit(1); } @@ -189,17 +192,26 @@ void compare_exp2_exp3 (int n) mpfr_clear(x); mpfr_clear(y); mpfr_clear(z); } +#define TEST_FUNCTION mpfr_exp +#include "tgeneric.c" + int -main(int argc, char **argv) +main (int argc, char *argv[]) { #ifdef TEST int i, N, s=0, e, maxe=0; double d, lo, hi; #endif + test_generic (1, 100, 100); + + if (argc == 4) + { + check_large (atof(argv[1]), atoi(argv[2]), atoi(argv[3])); + exit(1); + } + srand(getpid()); - compare_exp2_exp3(1000); - if (argc==4) { check_large(atof(argv[1]), atoi(argv[2]), atoi(argv[3])); - exit(1); } + compare_exp2_exp3(500); check_worst_cases(); check3(0.0, GMP_RNDU, 1.0); check3(-8.88024741073346941839e-17, GMP_RNDU, 1.0); @@ -256,5 +268,6 @@ main(int argc, char **argv) } if (N) printf("mean error=%1.2e max error=%d\n", (double)s/(double)N,maxe); #endif + return 0; } |