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

Annotation of OpenXM_contrib/gmp/tests/mpn/t-mp_bases.c, Revision 1.1.1.1

1.1       ohara       1: /* Check mp_bases values.
                      2:
                      3: Copyright 2002 Free Software Foundation, Inc.
                      4:
                      5: This file is part of the GNU MP Library.
                      6:
                      7: The GNU MP Library is free software; you can redistribute it and/or modify
                      8: it under the terms of the GNU Lesser General Public License as published by
                      9: the Free Software Foundation; either version 2.1 of the License, or (at your
                     10: option) any later version.
                     11:
                     12: The GNU MP 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 Lesser General Public
                     15: License for more details.
                     16:
                     17: You should have received a copy of the GNU Lesser General Public License
                     18: along with the GNU MP 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 <stdlib.h>
                     24: #include "gmp.h"
                     25: #include "gmp-impl.h"
                     26: #include "longlong.h"
                     27: #include "tests.h"
                     28:
                     29:
                     30: int
                     31: main (int argc, char *argv[])
                     32: {
                     33:   mp_limb_t  bb, h, l, bb_inv;
                     34:   int        i, j;
                     35:
                     36:   for (i = 2; i < numberof (mp_bases); i++)
                     37:     {
                     38:       if (POW2_P (i))
                     39:         {
                     40:           count_trailing_zeros (j, i);
                     41:           if (mp_bases[i].big_base != (mp_limb_t) j)
                     42:             {
                     43:               printf ("mp_bases[%d].big_base (trailing zeros) wrong\n", i);
                     44:               abort ();
                     45:             }
                     46:         }
                     47:       else
                     48:         {
                     49:           bb = 1;
                     50:           for (j = 0; j < mp_bases[i].chars_per_limb; j++)
                     51:             {
                     52:               umul_ppmm (h, bb, bb, i);
                     53:               if (h != 0 || (bb & GMP_NAIL_MASK) != 0)
                     54:                 {
                     55:                   printf ("mp_bases[%d].chars_per_limb overflow\n", i);
                     56:                   abort ();
                     57:                 }
                     58:             }
                     59:           umul_ppmm (h, l, bb, i);
                     60:           if (h == 0 && (l & GMP_NAIL_MASK) == 0)
                     61:             {
                     62:               printf ("mp_bases[%d].chars_per_limb too small\n", i);
                     63:               abort ();
                     64:             }
                     65:
                     66:           if (mp_bases[i].big_base != bb)
                     67:             {
                     68:               printf ("mp_bases[%d].big_base wrong\n", i);
                     69:               abort ();
                     70:             }
                     71:
                     72:           invert_limb (bb_inv, bb << refmpn_count_leading_zeros (bb));
                     73:           if (mp_bases[i].big_base_inverted != bb_inv)
                     74:             {
                     75:               printf ("mp_bases[%d].big_base_inverted wrong\n", i);
                     76:               abort ();
                     77:             }
                     78:         }
                     79:     }
                     80:
                     81:   if (MP_BASES_CHARS_PER_LIMB_10 != mp_bases[10].chars_per_limb)
                     82:     {
                     83:       printf ("MP_BASES_CHARS_PER_LIMB_10 not the same as mp_bases[10].chars_per_limb\n");
                     84:       abort ();
                     85:     }
                     86:
                     87:   if (MP_BASES_BIG_BASE_10 != mp_bases[10].big_base)
                     88:     {
                     89:       printf ("MP_BASES_BIG_BASE_10 not the same as mp_bases[10].big_base\n");
                     90:       abort ();
                     91:     }
                     92:
                     93:   if (MP_BASES_BIG_BASE_INVERTED_10 != mp_bases[10].big_base_inverted)
                     94:     {
                     95:       printf ("MP_BASES_BIG_BASE_INVERTED_10 not the same as mp_bases[10].big_base_inverted\n");
                     96:       abort ();
                     97:     }
                     98:
                     99:   if (MP_BASES_NORMALIZATION_STEPS_10
                    100:       != refmpn_count_leading_zeros (MP_BASES_BIG_BASE_10))
                    101:     {
                    102:       printf ("MP_BASES_NORMALIZATION_STEPS_10 wrong\n");
                    103:       abort ();
                    104:     }
                    105:
                    106:   exit (0);
                    107: }

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