diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2012-02-24 11:14:11 +0100 |
---|---|---|
committer | Marc Glisse <marc.glisse@inria.fr> | 2012-02-24 11:14:11 +0100 |
commit | 15cafc39ad37fb3f06cd0e769f855b199288fdf4 (patch) | |
tree | e81213fb0aa75cb6d8e069d3fd6caaf0be7c985d /mpq/aors.c | |
parent | 38a9408ef532be12fb53f765541d32f014302f99 (diff) | |
download | gmp-15cafc39ad37fb3f06cd0e769f855b199288fdf4.tar.gz |
Use macros like NUM, ALLOC, SIZ, etc in mpq/*.
Test some mpq functions that were not used in the testsuite.
Implement q=z (in gmpxx) with mpq_set_z.
Diffstat (limited to 'mpq/aors.c')
-rw-r--r-- | mpq/aors.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/mpq/aors.c b/mpq/aors.c index 384df162f..9676ffea8 100644 --- a/mpq/aors.c +++ b/mpq/aors.c @@ -31,10 +31,10 @@ mpq_aors (mpq_ptr rop, mpq_srcptr op1, mpq_srcptr op2, { mpz_t gcd; mpz_t tmp1, tmp2; - mp_size_t op1_num_size = ABS (op1->_mp_num._mp_size); - mp_size_t op1_den_size = op1->_mp_den._mp_size; - mp_size_t op2_num_size = ABS (op2->_mp_num._mp_size); - mp_size_t op2_den_size = op2->_mp_den._mp_size; + mp_size_t op1_num_size = ABSIZ(NUM(op1)); + mp_size_t op1_den_size = SIZ(DEN(op1)); + mp_size_t op2_num_size = ABSIZ(NUM(op2)); + mp_size_t op2_den_size = SIZ(DEN(op2)); TMP_DECL; TMP_MARK; @@ -47,43 +47,43 @@ mpq_aors (mpq_ptr rop, mpq_srcptr op1, mpq_srcptr op2, dare to overwrite the numerator of ROP when we are finished with the numerators of OP1 and OP2. */ - mpz_gcd (gcd, &(op1->_mp_den), &(op2->_mp_den)); + mpz_gcd (gcd, DEN(op1), DEN(op2)); if (! MPZ_EQUAL_1_P (gcd)) { mpz_t t; MPZ_TMP_INIT (t, MAX (op1_num_size + op2_den_size, - op2_num_size + op1_den_size) + 2 - gcd->_mp_size); + op2_num_size + op1_den_size) + 2 - SIZ(gcd)); - mpz_divexact_gcd (t, &(op2->_mp_den), gcd); - mpz_divexact_gcd (tmp2, &(op1->_mp_den), gcd); + mpz_divexact_gcd (t, DEN(op2), gcd); + mpz_divexact_gcd (tmp2, DEN(op1), gcd); - mpz_mul (tmp1, &(op1->_mp_num), t); - mpz_mul (t, &(op2->_mp_num), tmp2); + mpz_mul (tmp1, NUM(op1), t); + mpz_mul (t, NUM(op2), tmp2); (*fun) (t, tmp1, t); mpz_gcd (gcd, t, gcd); if (MPZ_EQUAL_1_P (gcd)) { - mpz_set (&(rop->_mp_num), t); - mpz_mul (&(rop->_mp_den), &(op2->_mp_den), tmp2); + mpz_set (NUM(rop), t); + mpz_mul (DEN(rop), DEN(op2), tmp2); } else { - mpz_divexact_gcd (&(rop->_mp_num), t, gcd); - mpz_divexact_gcd (tmp1, &(op2->_mp_den), gcd); - mpz_mul (&(rop->_mp_den), tmp1, tmp2); + mpz_divexact_gcd (NUM(rop), t, gcd); + mpz_divexact_gcd (tmp1, DEN(op2), gcd); + mpz_mul (DEN(rop), tmp1, tmp2); } } else { /* The common divisor is 1. This is the case (for random input) with probability 6/(pi**2), which is about 60.8%. */ - mpz_mul (tmp1, &(op1->_mp_num), &(op2->_mp_den)); - mpz_mul (tmp2, &(op2->_mp_num), &(op1->_mp_den)); - (*fun) (&(rop->_mp_num), tmp1, tmp2); - mpz_mul (&(rop->_mp_den), &(op1->_mp_den), &(op2->_mp_den)); + mpz_mul (tmp1, NUM(op1), DEN(op2)); + mpz_mul (tmp2, NUM(op2), DEN(op1)); + (*fun) (NUM(rop), tmp1, tmp2); + mpz_mul (DEN(rop), DEN(op1), DEN(op2)); } TMP_FREE; } |