Two questions about mpz_addmul() and mpz_submul()

Torbjorn Granlund tege at swox.com
Mon Sep 20 16:53:30 CEST 2004


Roberto Bagnara <bagnara at cs.unipr.it> writes:

  I have just come across these functions and I have
  two questions:
  
  1) Can I assume that mpz_addmul and mpz_submul
      are not less efficient than what a user could write
      using other GMP mpz_* functions?  I am especially
      concerned about the cost of allocation and deallocation
      of space to hold the result of the multiplication.

It is probably possible to find some corner cases where they are
a tad bit slower, but since mpz_addmul is implemented on top of
mpn, there shouldn't be extra overhead compared to separate
calls.

The main reason for mpz_addmul is to reach the optimized
mpn_addmul_1 and mpn_submul_1.

  2) Is there some fundamental reason why these functions
      are not available for rationals?

We keep mpq small, but sinze mpz functions can be applied to mpq
numerators and denominators, mpq's lack of a complete set of
functions should not be a big problem.

--
Torbjörn


More information about the gmp-discuss mailing list