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

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

version 1.1.1.1, 2000/01/10 15:35:28 version 1.1.1.2, 2000/09/09 14:13:01
Line 1 
Line 1 
 /* Test mpz_add, mpz_cmp, mpz_cmp_ui, mpz_divmod, mpz_mul.  /* Test mpz_add, mpz_cmp, mpz_cmp_ui, mpz_divmod, mpz_mul.
   
 Copyright (C) 1991, 1993, 1994, 1996 Free Software Foundation, Inc.  Copyright (C) 1991, 1993, 1994, 1996, 1997, 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 30  mp_size_t _mpn_mul_classic ();
Line 30  mp_size_t _mpn_mul_classic ();
 void mpz_refmul ();  void mpz_refmul ();
   
 #ifndef SIZE  #ifndef SIZE
 #define SIZE 128  #define SIZE 2 * TOOM3_MUL_THRESHOLD
 #endif  #endif
   
 main (argc, argv)  main (argc, argv)
Line 42  main (argc, argv)
Line 42  main (argc, argv)
   mpz_t quotient, remainder;    mpz_t quotient, remainder;
   mp_size_t multiplier_size, multiplicand_size;    mp_size_t multiplier_size, multiplicand_size;
   int i;    int i;
   int reps = 10000;    int reps = 2000;
   
   if (argc == 2)    if (argc == 2)
      reps = atoi (argv[1]);       reps = atoi (argv[1]);
Line 56  main (argc, argv)
Line 56  main (argc, argv)
   
   for (i = 0; i < reps; i++)    for (i = 0; i < reps; i++)
     {      {
       multiplier_size = urandom () % SIZE - SIZE/2;        multiplier_size = urandom () % 2 * SIZE - SIZE;
       multiplicand_size = urandom () % SIZE - SIZE/2;        multiplicand_size = urandom () % 2 * SIZE - SIZE;
   
       mpz_random2 (multiplier, multiplier_size);        mpz_random2 (multiplier, multiplier_size);
       mpz_random2 (multiplicand, multiplicand_size);        mpz_random2 (multiplicand, multiplicand_size);
Line 68  main (argc, argv)
Line 68  main (argc, argv)
         mpz_divmod (quotient, remainder, product, multiplicand);          mpz_divmod (quotient, remainder, product, multiplicand);
   
       if (mpz_cmp (product, ref_product))        if (mpz_cmp (product, ref_product))
         dump_abort (multiplier, multiplicand);          dump_abort ("incorrect plain product",
                       multiplier, multiplicand, product, ref_product);
   
       if (mpz_cmp_ui (multiplicand, 0) != 0)        if (mpz_cmp_ui (multiplicand, 0) != 0)
       if (mpz_cmp_ui (remainder, 0) || mpz_cmp (quotient, multiplier))        if (mpz_cmp_ui (remainder, 0) || mpz_cmp (quotient, multiplier))
         dump_abort (multiplier, multiplicand);          {
             debug_mp (quotient, -16);
             debug_mp (remainder, -16);
             dump_abort ("incorrect quotient or remainder",
                         multiplier, multiplicand, product, ref_product);
           }
   
         /* Test squaring.  */
         mpz_mul (product, multiplier, multiplier);
         mpz_refmul (ref_product, multiplier, multiplier);
   
         if (mpz_cmp (product, ref_product))
           dump_abort ("incorrect square product",
                       multiplier, multiplier, product, ref_product);
     }      }
   
   exit (0);    exit (0);
Line 244  _mpn_mul_classic (prodp, up, usize, vp, vsize)
Line 258  _mpn_mul_classic (prodp, up, usize, vp, vsize)
   return usize + vsize - (cy_dig == 0);    return usize + vsize - (cy_dig == 0);
 }  }
   
 dump_abort (multiplier, multiplicand)  dump_abort (s, multiplier, multiplicand, product, ref_product)
      mpz_t multiplier, multiplicand;       char *s;
        mpz_t multiplier, multiplicand, product, ref_product;
 {  {
   fprintf (stderr, "ERROR\n");    fprintf (stderr, "ERROR: %s\n", s);
   fprintf (stderr, "multiplier = "); debug_mp (multiplier, -16);    fprintf (stderr, "multiplier = "); debug_mp (multiplier, -16);
   fprintf (stderr, "multiplicand  = "); debug_mp (multiplicand, -16);    fprintf (stderr, "multiplicand  = "); debug_mp (multiplicand, -16);
     fprintf (stderr, "product  = "); debug_mp (product, -16);
     fprintf (stderr, "ref_product  = "); debug_mp (ref_product, -16);
   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>