diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-01-14 17:18:34 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-01-14 17:18:34 +0000 |
commit | f9106da753829c3adca5c0cf8c38c4608cc34218 (patch) | |
tree | 2cbb6e0fc012305dc760d50ec8cb93f5b8e746ce /const_euler.c | |
parent | 0a40b14f2ae6f51268df552f999845f23de4a321 (diff) | |
download | mpfr-f9106da753829c3adca5c0cf8c38c4608cc34218.tar.gz |
Changed some error messages into assertions.
Removed some useless #include's.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2622 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'const_euler.c')
-rw-r--r-- | const_euler.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/const_euler.c b/const_euler.c index ee1fdb8c6..c62ec78ec 100644 --- a/const_euler.c +++ b/const_euler.c @@ -1,6 +1,6 @@ /* mpfr_const_euler -- Euler's constant -Copyright 2001, 2002 Free Software Foundation. +Copyright 2001, 2002, 2004 Free Software Foundation. This file is part of the MPFR Library. @@ -19,7 +19,6 @@ 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 <stdio.h> #include <stdlib.h> #include "gmp.h" #include "gmp-impl.h" @@ -115,7 +114,7 @@ mpfr_const_euler_S (mpfr_t x, unsigned long n) mpz_clear (t); } -/* computes R(n) = exp(-n)/n * sum(k!/(-n)^k, k=0..n-2) +/* computes R(n) = exp(-n)/n * sum(k!/(-n)^k, k=0..n-2) with error at most 4*ulp(x). Assumes n>=2. Since x <= exp(-n)/n <= 1/8, then 4*ulp(x) <= ulp(1). */ @@ -137,7 +136,7 @@ mpfr_const_euler_R (mpfr_t x, unsigned long n) for (k = 1; k <= n; k++) { - mpz_mul_ui (a, a, k); + mpz_mul_ui (a, a, k); mpz_div_ui (a, a, n); /* the error e(k) on a is e(k) <= 1 + k/n*e(k-1) with e(0)=0, i.e. e(k) <= k */ @@ -148,11 +147,7 @@ mpfr_const_euler_R (mpfr_t x, unsigned long n) } /* the error on s is at most 1+2+...+n = n*(n+1)/2 */ mpz_div_ui (s, s, n); /* err <= 1 + (n+1)/2 */ - if (MPFR_PREC(x) < mpz_sizeinbase(s, 2)) - { - fprintf (stderr, "prec(x) is too small in mpfr_const_euler_R\n"); - exit (1); - } + MPFR_ASSERTN (MPFR_PREC(x) >= mpz_sizeinbase(s, 2)); mpfr_set_z (x, s, GMP_RNDD); /* exact */ mpfr_div_2ui (x, x, m, GMP_RNDD); /* now x = 1/n * sum(k!/(-n)^k, k=0..n-2) <= 1/n */ |