17
17
You should have received a copy of the GNU Lesser General Public License
18
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. */
19
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
MA 02110-1301, USA. */
23
23
#include <stdlib.h>
31
31
main (int argc, char *argv[])
33
mp_limb_t bb, h, l, bb_inv;
36
for (i = 2; i < numberof (mp_bases); i++)
40
count_trailing_zeros (j, i);
41
if (mp_bases[i].big_base != (mp_limb_t) j)
43
printf ("mp_bases[%d].big_base (trailing zeros) wrong\n", i);
50
for (j = 0; j < mp_bases[i].chars_per_limb; j++)
52
umul_ppmm (h, bb, bb, i);
53
if (h != 0 || (bb & GMP_NAIL_MASK) != 0)
55
printf ("mp_bases[%d].chars_per_limb overflow\n", i);
59
umul_ppmm (h, l, bb, i);
60
if (h == 0 && (l & GMP_NAIL_MASK) == 0)
62
printf ("mp_bases[%d].chars_per_limb too small\n", i);
66
if (mp_bases[i].big_base != bb)
68
printf ("mp_bases[%d].big_base wrong\n", i);
72
invert_limb (bb_inv, bb << refmpn_count_leading_zeros (bb));
73
if (mp_bases[i].big_base_inverted != bb_inv)
75
printf ("mp_bases[%d].big_base_inverted wrong\n", i);
81
if (MP_BASES_CHARS_PER_LIMB_10 != mp_bases[10].chars_per_limb)
83
printf ("MP_BASES_CHARS_PER_LIMB_10 not the same as mp_bases[10].chars_per_limb\n");
87
if (MP_BASES_BIG_BASE_10 != mp_bases[10].big_base)
89
printf ("MP_BASES_BIG_BASE_10 not the same as mp_bases[10].big_base\n");
93
if (MP_BASES_BIG_BASE_INVERTED_10 != mp_bases[10].big_base_inverted)
95
printf ("MP_BASES_BIG_BASE_INVERTED_10 not the same as mp_bases[10].big_base_inverted\n");
33
mp_limb_t want_bb, want_bb_inv;
34
int base, want_chars_per_limb;
36
want_chars_per_limb = refmpn_chars_per_limb (10);
37
if (MP_BASES_CHARS_PER_LIMB_10 != want_chars_per_limb)
39
printf ("MP_BASES_CHARS_PER_LIMB_10 wrong\n");
43
want_bb = refmpn_big_base (10);
44
if (MP_BASES_BIG_BASE_10 != want_bb)
46
printf ("MP_BASES_BIG_BASE_10 wrong\n");
50
want_bb_inv = refmpn_invert_limb
51
(want_bb << refmpn_count_leading_zeros (want_bb));
52
if (MP_BASES_BIG_BASE_INVERTED_10 != want_bb_inv)
54
printf ("MP_BASES_BIG_BASE_INVERTED_10 wrong\n");
65
for (base = 2; base < numberof (mp_bases); base++)
67
want_chars_per_limb = refmpn_chars_per_limb (base);
68
if (mp_bases[base].chars_per_limb != want_chars_per_limb)
70
printf ("mp_bases[%d].chars_per_limb wrong\n", base);
71
printf (" got %d\n", mp_bases[base].chars_per_limb);
72
printf (" want %d\n", want_chars_per_limb);
78
want_bb = refmpn_count_trailing_zeros ((mp_limb_t) base);
79
if (mp_bases[base].big_base != want_bb)
81
printf ("mp_bases[%d].big_base (log2 of base) wrong\n", base);
87
want_bb = refmpn_big_base (base);
88
if (mp_bases[base].big_base != want_bb)
90
printf ("mp_bases[%d].big_base wrong\n", base);
94
#if USE_PREINV_DIVREM_1
95
want_bb_inv = refmpn_invert_limb
96
(want_bb << refmpn_count_leading_zeros (want_bb));
97
if (mp_bases[base].big_base_inverted != want_bb_inv)
99
printf ("mp_bases[%d].big_base_inverted wrong\n", base);