remove extra division in mpq/aors.c
Marc Glisse
marc.glisse at inria.fr
Sun Feb 20 17:19:31 CET 2011
On Sun, 20 Feb 2011, Torbjorn Granlund wrote:
> Marc Glisse <marc.glisse at inria.fr> writes:
>
> the file doc/tasks.html mentions an extra division in
> mpq/aors.c. Would something like the attached do?
>
> I find it very, very difficult to understand unidiffs. Please use
> context diffs for GMP patches.
Ok, I'll try to remember that. See attached.
> I suppose we should at some point perform bdiv-type
> precomputations on the 'gcd' value.
That's precisely the item written next to this one in the tasks file ;-)
But it is more complicated, so I won't do it myself.
> For making hg generate context diffs (hg cdiff), put this in your
> ~/.hgrc:
>
> [extensions]
> hgext.extdiff=
>
> [extdiff]
> cmd.cdiff = diff
> opts.cdiff = -Nrc2
Can this be done on a project basis? Other projects specifically ask for
unified diffs...
--
Marc Glisse
-------------- next part --------------
*** /data/repos/gmp/mpq/aors.c 2011-02-19 18:32:22.753357195 +0100
--- mpq/aors.c 2011-02-20 17:07:25.106236000 +0100
***************
*** 53,67 ****
mpz_t t;
mpz_divexact_gcd (tmp1, &(op2->_mp_den), gcd);
mpz_mul (tmp1, &(op1->_mp_num), tmp1);
! mpz_divexact_gcd (tmp2, &(op1->_mp_den), gcd);
! mpz_mul (tmp2, &(op2->_mp_num), tmp2);
! MPZ_TMP_INIT (t, MAX (ABS (tmp1->_mp_size), ABS (tmp2->_mp_size)) + 1);
! (*fun) (t, tmp1, tmp2);
! mpz_divexact_gcd (tmp2, &(op1->_mp_den), gcd);
mpz_gcd (gcd, t, gcd);
if (MPZ_EQUAL_1_P (gcd))
--- 53,68 ----
mpz_t t;
mpz_divexact_gcd (tmp1, &(op2->_mp_den), gcd);
+ mpz_divexact_gcd (tmp2, &(op1->_mp_den), gcd);
+
mpz_mul (tmp1, &(op1->_mp_num), tmp1);
! MPZ_TMP_INIT (t, 1 + MAX (ABS (tmp1->_mp_size),
! op2_num_size + ABS (tmp2->_mp_size)));
! mpz_mul (t, &(op2->_mp_num), tmp2);
! (*fun) (t, tmp1, t);
mpz_gcd (gcd, t, gcd);
if (MPZ_EQUAL_1_P (gcd))
-------------- next part --------------
*** /data/repos/gmp/mpq/aors.c 2011-02-19 18:32:22.753357195 +0100
--- mpq/aors.c 2011-02-20 17:11:07.248427000 +0100
***************
*** 52,67 ****
{
mpz_t t;
! mpz_divexact_gcd (tmp1, &(op2->_mp_den), gcd);
! mpz_mul (tmp1, &(op1->_mp_num), tmp1);
mpz_divexact_gcd (tmp2, &(op1->_mp_den), gcd);
- mpz_mul (tmp2, &(op2->_mp_num), tmp2);
! MPZ_TMP_INIT (t, MAX (ABS (tmp1->_mp_size), ABS (tmp2->_mp_size)) + 1);
! (*fun) (t, tmp1, tmp2);
! mpz_divexact_gcd (tmp2, &(op1->_mp_den), gcd);
mpz_gcd (gcd, t, gcd);
if (MPZ_EQUAL_1_P (gcd))
--- 52,67 ----
{
mpz_t t;
! MPZ_TMP_INIT (t, MAX (op1_num_size + op2_den_size,
! op2_num_size + op1_den_size) + 2 - gcd->_mp_size);
+ mpz_divexact_gcd (t, &(op2->_mp_den), gcd);
mpz_divexact_gcd (tmp2, &(op1->_mp_den), gcd);
! mpz_mul (tmp1, &(op1->_mp_num), t);
! mpz_mul (t, &(op2->_mp_num), tmp2);
! (*fun) (t, tmp1, t);
mpz_gcd (gcd, t, gcd);
if (MPZ_EQUAL_1_P (gcd))
More information about the gmp-discuss
mailing list