[BACK]Return to tzeta.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpfr / tests

Annotation of OpenXM_contrib/gmp/mpfr/tests/tzeta.c, Revision 1.1.1.1

1.1       maekawa     1: /* Test file for mpfr_zeta.
                      2:
                      3: Copyright (C) 1999 PolKA project, Inria Lorraine and Loria
                      4:
                      5: This file is part of the MPFR Library.
                      6:
                      7: The MPFR Library is free software; you can redistribute it and/or modify
                      8: it under the terms of the GNU Library General Public License as published by
                      9: the Free Software Foundation; either version 2 of the License, or (at your
                     10: option) any later version.
                     11:
                     12: The MPFR Library is distributed in the hope that it will be useful, but
                     13: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
                     14: or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
                     15: License for more details.
                     16:
                     17: You should have received a copy of the GNU Library General Public License
                     18: along with the MPFR Library; see the file COPYING.LIB.  If not, write to
                     19: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
                     20: MA 02111-1307, USA. */
                     21:
                     22: #include <stdio.h>
                     23: #include <math.h>
                     24: #include "gmp.h"
                     25: #include "gmp-impl.h"
                     26: #include "longlong.h"
                     27: #include "mpfr.h"
                     28:
                     29: /* #define DEBUG */
                     30:
                     31: int main()
                     32: {mpfr_t p,result,res_p; int succes; size_t t;
                     33: mpfr_init2(result, 53);
                     34: mpfr_init2(res_p, 53);
                     35: mpfr_init2(p, 53); mpfr_set_d(p, 2.0, GMP_RNDN);
                     36:
                     37: mpfr_zeta(result,p,GMP_RNDN);
                     38: /*printf("%d\n",succes);*/
                     39: #ifdef DEBUG
                     40: printf("Valeur de zeta(2) avec prec=53 et arrondi au plus pres:\n");
                     41: mpfr_print_raw(result);printf("\n");
                     42: t=mpfr_out_str(stdout,10,0,result,GMP_RNDN);printf("\n");
                     43: #endif
                     44:  if (mpfr_get_d(result) != 1.64493406684822640607e+00) {
                     45:    fprintf(stderr, "mpfr_zeta fails for s=2 and rnd_mode=GMP_RNDN\n");
                     46:    exit(1);
                     47:  }
                     48:
                     49: /*Test de comparaison avec pi^2/6*/
                     50: mpfr_set_prec(p, 67);
                     51: mpfr_pi(p,GMP_RNDN);
                     52: mpfr_mul(p,p,p,GMP_RNDN);
                     53: mpfr_set_ui(res_p,6,GMP_RNDN);
                     54: mpfr_div(p,p,res_p,GMP_RNDN);
                     55: /*mpfr_print_raw(p);printf("\n");
                     56: t=mpfr_out_str(stdout,10,0,p,GMP_RNDN);printf("\n");*/
                     57: succes=mpfr_can_round(p,63,GMP_RNDN,GMP_RNDN,53);
                     58: mpfr_set(res_p,p,GMP_RNDN);
                     59: /*printf("%d\n",succes);*/
                     60: #ifdef DEBUG
                     61: printf("Valeur de pi^2/6 avec prec=53 et arrondi au plus pres:\n");
                     62: mpfr_print_raw(res_p);printf("\n");
                     63: t=mpfr_out_str(stdout,10,0,res_p,GMP_RNDN);printf("\n");
                     64: #endif
                     65:
                     66: mpfr_clear(p);
                     67: mpfr_clear(result);
                     68: mpfr_clear(res_p);
                     69: exit (0);
                     70: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>