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/div.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/div.c')
-rw-r--r-- | mpq/div.c | 36 |
1 files changed, 18 insertions, 18 deletions
@@ -34,10 +34,10 @@ mpq_div (mpq_ptr quot, mpq_srcptr op1, mpq_srcptr op2) mp_size_t alloc; TMP_DECL; - op1_num_size = ABS (op1->_mp_num._mp_size); - op1_den_size = op1->_mp_den._mp_size; - op2_num_size = ABS (op2->_mp_num._mp_size); - op2_den_size = op2->_mp_den._mp_size; + op1_num_size = ABSIZ(NUM(op1)); + op1_den_size = SIZ(DEN(op1)); + op2_num_size = ABSIZ(NUM(op2)); + op2_den_size = SIZ(DEN(op2)); if (op2_num_size == 0) DIVIDE_BY_ZERO; @@ -46,9 +46,9 @@ mpq_div (mpq_ptr quot, mpq_srcptr op1, mpq_srcptr op2) { /* We special case this to simplify allocation logic; gcd(0,x) = x is a singular case for the allocations. */ - quot->_mp_num._mp_size = 0; - quot->_mp_den._mp_d[0] = 1; - quot->_mp_den._mp_size = 1; + SIZ(NUM(quot)) = 0; + PTR(DEN(quot))[0] = 1; + SIZ(DEN(quot)) = 1; return; } @@ -74,28 +74,28 @@ mpq_div (mpq_ptr quot, mpq_srcptr op1, mpq_srcptr op2) numerator of QUOT when we are finished with the numerators of OP1 and OP2. */ - mpz_gcd (gcd1, &(op1->_mp_num), &(op2->_mp_num)); - mpz_gcd (gcd2, &(op2->_mp_den), &(op1->_mp_den)); + mpz_gcd (gcd1, NUM(op1), NUM(op2)); + mpz_gcd (gcd2, DEN(op2), DEN(op1)); - mpz_divexact_gcd (tmp1, &(op1->_mp_num), gcd1); - mpz_divexact_gcd (tmp2, &(op2->_mp_den), gcd2); + mpz_divexact_gcd (tmp1, NUM(op1), gcd1); + mpz_divexact_gcd (tmp2, DEN(op2), gcd2); mpz_mul (numtmp, tmp1, tmp2); - mpz_divexact_gcd (tmp1, &(op2->_mp_num), gcd1); - mpz_divexact_gcd (tmp2, &(op1->_mp_den), gcd2); + mpz_divexact_gcd (tmp1, NUM(op2), gcd1); + mpz_divexact_gcd (tmp2, DEN(op1), gcd2); - mpz_mul (&(quot->_mp_den), tmp1, tmp2); + mpz_mul (DEN(quot), tmp1, tmp2); /* We needed to go via NUMTMP to take care of QUOT being the same as OP2. Now move NUMTMP to QUOT->_mp_num. */ - mpz_set (&(quot->_mp_num), numtmp); + mpz_set (NUM(quot), numtmp); /* Keep the denominator positive. */ - if (quot->_mp_den._mp_size < 0) + if (SIZ(DEN(quot)) < 0) { - quot->_mp_den._mp_size = -quot->_mp_den._mp_size; - quot->_mp_num._mp_size = -quot->_mp_num._mp_size; + SIZ(DEN(quot)) = -SIZ(DEN(quot)); + SIZ(NUM(quot)) = -SIZ(NUM(quot)); } TMP_FREE; |