diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-01-26 11:45:21 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-01-26 11:45:21 +0000 |
commit | 16328be66b543759640111eb4a03174bda9c489e (patch) | |
tree | 6ed9a674dd78ed331f0c0735a09ba9271fffc58b | |
parent | 031deac645662aea8a72a5ed0c0bf148e609e681 (diff) | |
download | mpfr-16328be66b543759640111eb4a03174bda9c489e.tar.gz |
+ Internal functions of zeta are now declared as static.
+ Add new tests which fail.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2645 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | tests/tzeta.c | 80 | ||||
-rw-r--r-- | zeta.c | 15 |
2 files changed, 82 insertions, 13 deletions
diff --git a/tests/tzeta.c b/tests/tzeta.c index 790e5447b..3bc375c96 100644 --- a/tests/tzeta.c +++ b/tests/tzeta.c @@ -58,6 +58,81 @@ test1 (void) mpfr_clear (y); } +static const char *const val[] = { + "-2000", "0.0", + "-2.0", "0.0", + "-1.0", "-0.000101010101010101010101010101010101010101010101010101010101010", + "-0.9", "-0.000110011110011111010001010001100010111101001010100110001110110", + "-0.8", "-0.000111110011101010001011100011010010000001010011110100010001110", + "-0.7", "-0.00100101011011111100110011110011111010111111000110110100010110", + "-0.6", "-0.00101100101100100100110111111000110010111010110010111000001100", + "-0.5", "-0.00110101001110000000100000011001100100010000111100010001111100", + "-0.4", "-0.00111111010001100011110001010010111110010001010101111101110001", + "-0.3", "-0.0100101100110111010101010100111011000001001010111010110101010", + "-0.2", "-0.0101100110000011101110101011011110101111000010000010110101111", + "-0.1", "-0.0110101011001111011101001111011000010001111010110011011111011", + "-0.0", "-0.100000000000000000000000000000000000000000000000000000000000", + "0.1", "-0.100110100110000010101010101110100000101100100011011001000101", + "0.2", "-0.10111011111000100011110111100010010001111010010010010100010110", + "0.3", "-0.11100111100100010011001000001011001100110010110101101110110110", + "0.4", "-1.0010001010000010000110111000100101001000001011101010110101011", + "0.5", "-1.0111010111011001110010110000011111100111001111111110111000110", + "0.6", "-1.1111001111100001100111101110010001001000001101100110110000100", + "0.7", "-10.110001110100010001110111000101010011110011000110010100101000", + "0.8", "-100.01110000000000101000010010000011000000111101100101100011010", + "0.9", "-1001.0110111000011011111100111100111011100010001111111010000100", + "0.99","-0.11000110110110001101011010110001011010011000110001011100101110E7", + "0.997", "-0.10100110011000001100111110011111100011110000111011101110001010E9", + "0.9995", "-0.11111001111011011000011110111111010111101001000110001111110010E11", + "0.99998", "-0.11000011010011110110110000111011101100001000101101011001110100E16", + "1.00001", "0.11000011010100000100100111100010001110100000110101110011111011E17", + "1.0002", "0.10011100010001001001111000101010111000011011011111110010110100E13", + "1.003","0.10100110111101001001010000000110101101110100001010100000110000E9", + "1.04", "11001.100101001000001011000111010110011010000001000010111101101", + "1.1", "1010.1001010110011110011010100010001100101001001111111101100001", + "1.2", "101.10010111011100011111001001100101101111110000110001101100010", + "1.3", "11.111011101001010000111001001110100100000101000101101011010100", + "1.4", "11.000110110000010100100101011110110001100001110100100100111111", + "1.5", "10.100111001100010010100001011111110111101100010011101011011100", + "1.6", "10.010010010010011111110000010011000110101001110011101010100110", + "1.7", "10.000011011110010111011110001100110010100010011100011111110010", + "1.8", "1.1110000111011001110011001101110101010000011011101100010111001", + "1.9", "1.1011111111101111011000011110001100100111100110111101101000101", + "2.0", "1.1010010100011010011001100010010100110000011111010011001000110", + "42.17", "1.0000000000000000000000000000000000000000001110001110001011001", + "-17.42", "-11.101110101010101000000001001000001111111101000100001100101100", + "-24.17", "-0.10001111010010011111000010001011111010010111101011000010010011E13" +}; + +static void +test2(void) +{ + mpfr_t x, y; + int i, n = numberof(val); + + mpfr_inits2(55, x, y, NULL); + + for(i = 0 ; i < n ; i+=2) + { + mpfr_set_str1 (x, val[i]); + mpfr_zeta(y, x, GMP_RNDZ); + if (mpfr_cmp_str (y, val[i+1] , 2, GMP_RNDZ)) + { + printf("Wrong result for zeta(%s).\nGot : ", val[i]); + mpfr_print_binary(y); putchar('\n'); + printf("Expected: "); + mpfr_set_str (y, val[i+1], 2, GMP_RNDZ); + mpfr_print_binary(y); putchar('\n'); + mpfr_set_prec(y, 65); + mpfr_zeta(y, x, GMP_RNDZ); + printf("+ Prec : "); + mpfr_print_binary(y); putchar('\n'); + exit(1); + } + } + mpfr_clears(x, y, NULL); +} + #define TEST_FUNCTION mpfr_zeta #include "tgeneric.c" @@ -208,12 +283,13 @@ main (int argc, char *argv[]) exit (1); } - test_generic (2, 70, 1); - mpfr_clear (s); mpfr_clear (y); mpfr_clear (z); + test_generic (2, 70, 1); + test2(); + tests_end_mpfr (); return 0; } @@ -25,15 +25,8 @@ MA 02111-1307, USA. */ #include <stdlib.h> #include <stdio.h> -#include "gmp.h" -#include "gmp-impl.h" -#include "mpfr.h" #include "mpfr-impl.h" -void mpfr_zeta_part_b _MPFR_PROTO ((mpfr_t, mpfr_srcptr, int, int, mpfr_t *)); -void mpfr_zeta_c _MPFR_PROTO ((int, mpfr_t *)); -void mpfr_zeta_part_a _MPFR_PROTO ((mpfr_t, mpfr_srcptr, int)); - /* Parameters: s - the input floating-point number @@ -42,7 +35,7 @@ void mpfr_zeta_part_a _MPFR_PROTO ((mpfr_t, mpfr_srcptr, int)); Output: b is the result */ -void +static void mpfr_zeta_part_b (mpfr_t b, mpfr_srcptr s, int n, int p, mpfr_t *tc) { int n2, l, t, precb; @@ -94,7 +87,7 @@ mpfr_zeta_part_b (mpfr_t b, mpfr_srcptr s, int n, int p, mpfr_t *tc) /* Input: p - an integer Output: fills tc[1..p] */ -void +static void mpfr_zeta_c (int p, mpfr_t *tc) { mpfr_t d; @@ -124,7 +117,7 @@ mpfr_zeta_c (int p, mpfr_t *tc) /* Input: s - a floating-point number n - an integer Output: sum - a floating-point number */ -void +static void mpfr_zeta_part_a (mpfr_t sum, mpfr_srcptr s, int n) { int i, preca; @@ -387,7 +380,7 @@ mpfr_zeta (mpfr_t z, mpfr_srcptr s, mp_rnd_t rnd_mode) add = __gmpfr_ceil_log2 (c * c * c * (13.0 + m1)); prec1 = precz + add; /* Note that prec1 is still incremented by 10 at the first entry of loop below */ prec1 = MAX(prec1, precs1); - if (MPFR_SIGN (s) != -1 && MPFR_GET_EXP (s) >= 0) /* Case s >= 1/2 */ + if (MPFR_IS_POS (s) && MPFR_GET_EXP (s) >= 0) /* Case s >= 1/2 */ inex = mpfr_zeta_pos (z, s, rnd_mode); else { |