mpn_perfpow: do we need a special GCD for mp_bitcnt_t?
bodrato at mail.dm.unipi.it
bodrato at mail.dm.unipi.it
Mon Sep 1 20:00:11 UTC 2014
Ciao,
Il Lun, 1 Settembre 2014 2:40 pm, Torbjörn Granlund ha scritto:
> nisse at lysator.liu.se (Niels Möller) writes:
> > examined number, the exponent is returned as mp_bitcnt_t, the returned
> > value is then casted to mp_limb_t, because we need the GCD of the
> > exponents and mpn_gcd_1 wants limbs.
>
> And when can there be a problem? If the mp_limb_t type is smaller than
> mp_bitcnt_t?
> I am not aware of any configurations where mp_limb_t is the smaller of
> the two. But I feel bothered by type mixing such as this.
Mixing types is not good for abstraction, i.e. portability and
maintainability.
> Vaguely related: We could have an mpn_gcd_11 function, accepting two
> limb-size arguments.
>
> Which would then be in assembly. This would obsolete the many mpn_gcd_1
> implementations, I think.
Agreed.
There are at least two functions where mpn_gcd_11 is needed and currently
mpn_gcd_1 (&x, 1, y) is used:
$ grep -rl "mpn_gcd_1 (&" mp?
mpn/generic/perfpow.c
mpz/mfac_uiui.c
... in both cases, to be honest, the GCD is needed on arguments that are
not limbs...
Regards,
m
--
http://bodrato.it/
More information about the gmp-devel
mailing list