Division call in mpn_gcd

Torbjorn Granlund tg at gmplib.org
Sat Feb 25 14:00:54 CET 2012


nisse at lysator.liu.se (Niels Möller) writes:

  > Perhaps this is the reason for keeping redc separate?
  
  IIRC, bdiv functions return a borrow, meaning that the remainder
  corresponding to the computed quotient is negative, while red returns a
  carry which means that the computed remainder is a bit too large.
  
That redc behaviour is just one week old...

  And then the questions was if a remainder-only function should follow
  the redc convention, since that's the most important use, or the bdiv_qr
  convention, for consistency.
  
And we shouldn't sacrifice speed for consistency, at the lowest mpn
level.

  > Really?  Doesn't that quotient affect the cofactors?
  
  It affects one of the cofactors: the one which we're not going to
  return.
  
I see.  I suppose that means the caller that really wants the cofactor
should performs this initial (Hensel) division, for efficiency.

-- 
Torbjörn


More information about the gmp-devel mailing list