diff options
author | tege <tege@gmplib.org> | 2002-05-07 00:49:46 +0200 |
---|---|---|
committer | tege <tege@gmplib.org> | 2002-05-07 00:49:46 +0200 |
commit | 9fe216c07fdb2677d31d8bc8843093a4718d09a7 (patch) | |
tree | f45ab12d71c8cfd307c230b772e6c1f6ad794d06 | |
parent | 22ce05a529afd753733d86944983fb79dd0e76dd (diff) | |
download | gmp-9fe216c07fdb2677d31d8bc8843093a4718d09a7.tar.gz |
Handle exp <= 1. Reverse rp/tp parity scheme for bn == 1 arm.
-rw-r--r-- | mpn/generic/pow_1.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/mpn/generic/pow_1.c b/mpn/generic/pow_1.c index b9a6af950..d2660db3e 100644 --- a/mpn/generic/pow_1.c +++ b/mpn/generic/pow_1.c @@ -36,6 +36,20 @@ mpn_pow_1 (mp_ptr rp, mp_srcptr bp, mp_size_t bn, mp_limb_t exp, mp_ptr tp) mp_size_t rn; int par; + if (exp <= 1) + { + if (exp == 0) + { + rp[0] = 1; + return 1; + } + else + { + MPN_COPY (rp, bp, bn); + return bn; + } + } + /* Count number of bits in exp, and compute where to put initial square in order to magically get results in the entry rp. Use simple code, optimized for small exp. For large exp, the bignum operations will take @@ -53,7 +67,7 @@ mpn_pow_1 (mp_ptr rp, mp_srcptr bp, mp_size_t bn, mp_limb_t exp, mp_ptr tp) { mp_limb_t bl = bp[0]; - if ((cnt & 1) == 0) + if ((cnt & 1) != 0) MP_PTR_SWAP (rp, tp); mpn_sqr_n (rp, bp, bn); |