mpn_tdiv_qr vs mpn_divrem

Paul Zimmermann Paul.Zimmermann at loria.fr
Mon Aug 31 11:53:24 CEST 2009


       Hi,

1) the documentation of mpn_tdiv_qr says "No overlap is permitted between
arguments". However line 325 of mpn/generic/hgcd.c (in GMP 4.3.0) writes
the remainder in place of the dividend:

  mpn_tdiv_qr (tp, ap, 0, ap, an, bp, bn);

I believe either the documentation should be fixed, telling which overlap is
allowed, or hgcd.c should be fixed to avoid overlap.

2) We are still using mpn_divrem instead of mpn_tdiv_qr in MPFR. The reason
is that mpn_tdiv_qr requires one extra limb for the quotient, whereas in some
cases with mpn_divrem we can directly store the result in the destination
variable. Thus we avoid an unnecessary copy. The documentation of mpn_divrem
says "Please call `mpn_tdiv_qr' instead for best performance". In which cases
is mpn_tdiv_qr faster than mpn_divrem?

Paul Zimmermann



More information about the gmp-devel mailing list