[BACK]Return to t-dm2exp.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpf / tests

Diff for /OpenXM_contrib/gmp/mpf/tests/Attic/t-dm2exp.c between version 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2000/01/10 15:35:22 version 1.1.1.2, 2000/09/09 14:13:16
Line 1 
Line 1 
 /* Test mpf_div, mpf_div_2exp, mpf_mul_2exp.  /* Test mpf_div, mpf_div_2exp, mpf_mul_2exp.
   
 Copyright (C) 1996 Free Software Foundation, Inc.  Copyright (C) 1996, 2000 Free Software Foundation, Inc.
   
 This file is part of the GNU MP Library.  This file is part of the GNU MP Library.
   
 The GNU MP Library is free software; you can redistribute it and/or modify  The GNU MP 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  it under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your  the Free Software Foundation; either version 2.1 of the License, or (at your
 option) any later version.  option) any later version.
   
 The GNU MP Library is distributed in the hope that it will be useful, but  The GNU MP Library is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY  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.  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 GNU MP Library; see the file COPYING.LIB.  If not, write to  along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 MA 02111-1307, USA. */  MA 02111-1307, USA. */
Line 34  main (argc, argv)
Line 34  main (argc, argv)
 {  {
   int reps = 500000;    int reps = 500000;
   int i;    int i;
   mpf_t u, v, w1, w2;    mpf_t u, v, w1, w2, w3;
   mp_size_t bprec = 100;    mp_size_t bprec = 100;
   mpf_t rerr, limit_rerr;    mpf_t rerr, limit_rerr;
     mp_size_t un;
     mp_exp_t ue;
   
   if (argc > 1)    if (argc > 1)
     {      {
Line 54  main (argc, argv)
Line 56  main (argc, argv)
   mpf_init (v);    mpf_init (v);
   mpf_init (w1);    mpf_init (w1);
   mpf_init (w2);    mpf_init (w2);
     mpf_init (w3);
   
   for (i = 0; i < reps; i++)    for (i = 0; i < reps; i++)
     {      {
       mp_size_t res_prec;        unsigned long int res_prec;
       unsigned long int pow2;        unsigned long int pow2;
   
       res_prec = urandom () % (bprec + 100);        res_prec = urandom () % (bprec + 100);
       mpf_set_prec (w1, res_prec);        mpf_set_prec (w1, res_prec);
       mpf_set_prec (w2, res_prec);        mpf_set_prec (w2, res_prec);
         mpf_set_prec (w3, res_prec);
   
       mpf_set_ui (limit_rerr, 1);        mpf_set_ui (limit_rerr, 1);
       mpf_div_2exp (limit_rerr, limit_rerr, res_prec);        mpf_div_2exp (limit_rerr, limit_rerr, res_prec);
Line 71  main (argc, argv)
Line 75  main (argc, argv)
       mpf_set_ui (v, 1);        mpf_set_ui (v, 1);
       mpf_mul_2exp (v, v, pow2);        mpf_mul_2exp (v, v, pow2);
   
         un = urandom () % (2 * SIZE) - SIZE;
         ue = urandom () % SIZE;
         mpf_random2 (u, un, ue);
   
       mpf_div_2exp (w1, u, pow2);        mpf_div_2exp (w1, u, pow2);
       mpf_div (w2, u, v);        mpf_div (w2, u, v);
       mpf_reldiff (rerr, w1, w2);        mpf_reldiff (rerr, w1, w2);
Line 81  main (argc, argv)
Line 89  main (argc, argv)
           printf ("   v = "); mpf_dump (v);            printf ("   v = "); mpf_dump (v);
           printf ("  w1 = "); mpf_dump (w1);            printf ("  w1 = "); mpf_dump (w1);
           printf ("  w2 = "); mpf_dump (w2);            printf ("  w2 = "); mpf_dump (w2);
             abort ();
           }
         mpf_mul_2exp (w3, w1, pow2);
         mpf_reldiff (rerr, u, w3);
         if (mpf_cmp (rerr, limit_rerr) > 0)
           {
             printf ("ERROR in mpf_mul_2exp after %d tests\n", i);
             printf ("   u = "); mpf_dump (u);
             printf ("   v = "); mpf_dump (v);
             printf ("  w1 = "); mpf_dump (w1);
             printf ("  w3 = "); mpf_dump (w3);
           abort ();            abort ();
         }          }
     }      }

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2

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