diff options
author | tege <tege@gmplib.org> | 2002-04-14 03:29:35 +0200 |
---|---|---|
committer | tege <tege@gmplib.org> | 2002-04-14 03:29:35 +0200 |
commit | fb3dd1b6ed701065bf082fee7f8cff05e62327ee (patch) | |
tree | 4cf03cdcaa57e98cbfe1ef79b4ff184f8a4040c1 /mpz/mul_i.h | |
parent | a72a5f7dd3b43c9781d2f88418131827e9808397 (diff) | |
download | gmp-fb3dd1b6ed701065bf082fee7f8cff05e62327ee.tar.gz |
Nailify.
Diffstat (limited to 'mpz/mul_i.h')
-rw-r--r-- | mpz/mul_i.h | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/mpz/mul_i.h b/mpz/mul_i.h index bd40a4ae7..d8199b976 100644 --- a/mpz/mul_i.h +++ b/mpz/mul_i.h @@ -1,7 +1,8 @@ /* mpz_mul_ui/si (product, multiplier, small_multiplicand) -- Set PRODUCT to MULTIPLICATOR times SMALL_MULTIPLICAND. -Copyright 1991, 1993, 1994, 1996, 2000, 2001 Free Software Foundation, Inc. +Copyright 1991, 1993, 1994, 1996, 2000, 2001, 2002 Free Software Foundation, +Inc. This file is part of the GNU MP Library. @@ -45,32 +46,43 @@ void FUNCTION (mpz_ptr prod, mpz_srcptr mult, MULTIPLICAND_UNSIGNED long int small_mult) { - mp_size_t size = mult->_mp_size; + mp_size_t size = SIZ(mult); mp_size_t sign_product = size; + mp_limb_t sml; mp_limb_t cy; - mp_size_t prod_size; - mp_ptr prod_ptr; + mp_ptr pp; if (size == 0 || small_mult == 0) { - prod->_mp_size = 0; + SIZ(prod) = 0; return; } + size = ABS (size); - prod_size = size + 1; - if (prod->_mp_alloc < prod_size) - _mpz_realloc (prod, prod_size); + if (small_mult > GMP_NUMB_MAX) + MPZ_REALLOC (prod, size + 2); + else + MPZ_REALLOC (prod, size + 1); + + pp = PTR(prod); - prod_ptr = prod->_mp_d; + sml = MULTIPLICAND_ABS (small_mult); - cy = mpn_mul_1 (prod_ptr, mult->_mp_d, size, - (mp_limb_t) MULTIPLICAND_ABS (small_mult)); - if (cy != 0) + cy = mpn_mul_1 (pp, PTR(mult), size, sml & GMP_NUMB_MASK); + if (small_mult > GMP_NUMB_MAX) + { + pp[size] = cy; + cy = mpn_addmul_1 (pp + 1, PTR(mult), size, sml >> GMP_NUMB_BITS); + pp[size + 1] = cy; + size += 2; + MPN_NORMALIZE_NOT_ZERO (pp, size); + } + else { - prod_ptr[size] = cy; - size++; + pp[size] = cy; + size += cy != 0; } - prod->_mp_size = ((sign_product < 0) ^ (small_mult < 0)) ? -size : size; + SIZ(prod) = ((sign_product < 0) ^ (small_mult < 0)) ? -size : size; } |