From 4bee36561d5d884b252dbf00f267839f57b23835 Mon Sep 17 00:00:00 2001 From: Fredrik Johansson Date: Sat, 3 Feb 2024 16:06:18 +0100 Subject: [PATCH] replace uses of fmpz_poly_div -> fmpz_poly_divexact --- src/fmpq_poly/xgcd.c | 4 ++-- src/fmpz_mpoly_factor/bpoly_factor.c | 2 +- src/fmpz_mpoly_factor/lcc_kaltofen.c | 4 ++-- src/fmpz_poly/cos_minpoly.c | 2 +- src/fmpz_poly/lcm.c | 2 +- src/fmpz_poly/remove.c | 2 +- src/fmpz_poly_factor/factor_squarefree.c | 8 ++++---- src/fmpz_poly_mat/fflu.c | 2 +- src/fmpz_poly_mat/rref.c | 2 +- src/fmpz_poly_mat/solve_fflu_precomp.c | 4 ++-- src/fmpz_poly_q/add.c | 16 ++++++++-------- src/fmpz_poly_q/canonicalise.c | 4 ++-- src/fmpz_poly_q/derivative.c | 4 ++-- src/fmpz_poly_q/div.c | 16 ++++++++-------- src/fmpz_poly_q/mul.c | 16 ++++++++-------- src/fmpz_poly_q/sub.c | 8 ++++---- 16 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/fmpq_poly/xgcd.c b/src/fmpq_poly/xgcd.c index 73e3c6bfe4..6f73512abf 100644 --- a/src/fmpq_poly/xgcd.c +++ b/src/fmpq_poly/xgcd.c @@ -76,8 +76,8 @@ void _fmpq_poly_xgcd(fmpz *G, fmpz_t denG, lenD = lenB - lenG + 1; C = _fmpz_vec_init(lenC + lenD); D = C + lenC; - _fmpz_poly_div(C, primA, lenA, G, lenG, 0); - _fmpz_poly_div(D, primB, lenB, G, lenG, 0); + _fmpz_poly_divexact(C, primA, lenA, G, lenG); + _fmpz_poly_divexact(D, primB, lenB, G, lenG); } else { diff --git a/src/fmpz_mpoly_factor/bpoly_factor.c b/src/fmpz_mpoly_factor/bpoly_factor.c index a874b9e786..942b9c5b68 100644 --- a/src/fmpz_mpoly_factor/bpoly_factor.c +++ b/src/fmpz_mpoly_factor/bpoly_factor.c @@ -139,7 +139,7 @@ void fmpz_bpoly_make_primitive(fmpz_poly_t g, fmpz_bpoly_t A) for (i = 0; i < A->length; i++) { - fmpz_poly_div(q, A->coeffs + i, g); + fmpz_poly_divexact(q, A->coeffs + i, g); fmpz_poly_swap(A->coeffs + i, q); } diff --git a/src/fmpz_mpoly_factor/lcc_kaltofen.c b/src/fmpz_mpoly_factor/lcc_kaltofen.c index f2f7af670b..f4202e493a 100644 --- a/src/fmpz_mpoly_factor/lcc_kaltofen.c +++ b/src/fmpz_mpoly_factor/lcc_kaltofen.c @@ -151,8 +151,8 @@ static void _make_bases_coprime( fmpz_poly_gcd(g, A->p + i, B->p + j); if (fmpz_poly_degree(g) > 0) { - fmpz_poly_div(A->p + i, A->p + i, g); - fmpz_poly_div(B->p + j, B->p + j, g); + fmpz_poly_divexact(A->p + i, A->p + i, g); + fmpz_poly_divexact(B->p + j, B->p + j, g); fmpz_poly_factor_fit_length(A, A->num + 1); fmpz_poly_set(A->p + A->num, g); A->exp[A->num] = A->exp[i]; diff --git a/src/fmpz_poly/cos_minpoly.c b/src/fmpz_poly/cos_minpoly.c index 68bbe2f6b9..754bfe5a36 100644 --- a/src/fmpz_poly/cos_minpoly.c +++ b/src/fmpz_poly/cos_minpoly.c @@ -246,7 +246,7 @@ _fmpz_poly_cos_minpoly(fmpz * f, ulong n) } } - _fmpz_poly_div(f, P, Plen, Q, Qlen, 0); + _fmpz_poly_divexact(f, P, Plen, Q, Qlen); _fmpz_vec_clear(P, Pdeg + 1); _fmpz_vec_clear(Q, Pdeg + 1); diff --git a/src/fmpz_poly/lcm.c b/src/fmpz_poly/lcm.c index 589110e5da..295f1676ea 100644 --- a/src/fmpz_poly/lcm.c +++ b/src/fmpz_poly/lcm.c @@ -39,7 +39,7 @@ void _fmpz_poly_lcm(fmpz * res, const fmpz * poly1, slong len1, slong lenV = len1 + len2 - lenW; V = _fmpz_vec_init(lenV); - _fmpz_poly_div(V, res, len1 + len2 - 1, W, lenW, 0); + _fmpz_poly_divexact(V, res, len1 + len2 - 1, W, lenW); if (fmpz_sgn(V + (lenV - 1)) > 0) _fmpz_vec_set(res, V, lenV); else diff --git a/src/fmpz_poly/remove.c b/src/fmpz_poly/remove.c index 139bb8172e..afc5a96653 100644 --- a/src/fmpz_poly/remove.c +++ b/src/fmpz_poly/remove.c @@ -73,7 +73,7 @@ fmpz_poly_remove(fmpz_poly_t res, const fmpz_poly_t poly1, while (i > 0 && !fmpz_poly_divides(q, poly1, p)) { - fmpz_poly_div(p, p, poly2); + fmpz_poly_divexact(p, p, poly2); i--; } diff --git a/src/fmpz_poly_factor/factor_squarefree.c b/src/fmpz_poly_factor/factor_squarefree.c index a9719f20fc..c80fcf0245 100644 --- a/src/fmpz_poly_factor/factor_squarefree.c +++ b/src/fmpz_poly_factor/factor_squarefree.c @@ -47,8 +47,8 @@ void fmpz_poly_factor_squarefree(fmpz_poly_factor_t fac, const fmpz_poly_t F) fmpz_poly_init(w); fmpz_poly_init(s); - fmpz_poly_div(v, f, d); - fmpz_poly_div(w, t1, d); + fmpz_poly_divexact(v, f, d); + fmpz_poly_divexact(w, t1, d); for (i = 1; ; i++) { @@ -63,8 +63,8 @@ void fmpz_poly_factor_squarefree(fmpz_poly_factor_t fac, const fmpz_poly_t F) } fmpz_poly_gcd(d, v, s); - fmpz_poly_div(v, v, d); - fmpz_poly_div(w, s, d); + fmpz_poly_divexact(v, v, d); + fmpz_poly_divexact(w, s, d); if (d->length > 1) fmpz_poly_factor_insert(fac, d, i); diff --git a/src/fmpz_poly_mat/fflu.c b/src/fmpz_poly_mat/fflu.c index 0ca3daeee3..161bc89d03 100644 --- a/src/fmpz_poly_mat/fflu.c +++ b/src/fmpz_poly_mat/fflu.c @@ -84,7 +84,7 @@ fmpz_poly_mat_fflu(fmpz_poly_mat_t B, fmpz_poly_t den, slong * perm, fmpz_poly_mul(t, E(j, pivot_col), E(pivot_row, k)); fmpz_poly_sub(E(j, k), E(j, k), t); if (pivot_row > 0) - fmpz_poly_div(E(j, k), E(j, k), den); + fmpz_poly_divexact(E(j, k), E(j, k), den); } } diff --git a/src/fmpz_poly_mat/rref.c b/src/fmpz_poly_mat/rref.c index eee62c8b2d..a9ee28fce7 100644 --- a/src/fmpz_poly_mat/rref.c +++ b/src/fmpz_poly_mat/rref.c @@ -70,7 +70,7 @@ fmpz_poly_mat_rref(fmpz_poly_mat_t R, fmpz_poly_t den, const fmpz_poly_mat_t A) fmpz_poly_sub(tmp, tmp, tmp2); } - fmpz_poly_div(fmpz_poly_mat_entry(R, i, nonpivots[k]), + fmpz_poly_divexact(fmpz_poly_mat_entry(R, i, nonpivots[k]), tmp, fmpz_poly_mat_entry(R, i, pivots[i])); } } diff --git a/src/fmpz_poly_mat/solve_fflu_precomp.c b/src/fmpz_poly_mat/solve_fflu_precomp.c index fdf2e563c9..4a834e7def 100644 --- a/src/fmpz_poly_mat/solve_fflu_precomp.c +++ b/src/fmpz_poly_mat/solve_fflu_precomp.c @@ -66,7 +66,7 @@ fmpz_poly_mat_solve_fflu_precomp(fmpz_poly_mat_t X, fmpz_poly_mul(T, LU(j, i), XX(i, k)); fmpz_poly_sub(XX(j, k), XX(j, k), T); if (i > 0) - fmpz_poly_div(XX(j, k), XX(j, k), LU(i-1, i-1)); + fmpz_poly_divexact(XX(j, k), XX(j, k), LU(i-1, i-1)); } } @@ -79,7 +79,7 @@ fmpz_poly_mat_solve_fflu_precomp(fmpz_poly_mat_t X, fmpz_poly_mul(T, XX(j, k), LU(i, j)); fmpz_poly_sub(XX(i, k), XX(i, k), T); } - fmpz_poly_div(XX(i, k), XX(i, k), LU(i, i)); + fmpz_poly_divexact(XX(i, k), XX(i, k), LU(i, i)); } } diff --git a/src/fmpz_poly_q/add.c b/src/fmpz_poly_q/add.c index 911d59c7ed..60a6d0249e 100644 --- a/src/fmpz_poly_q/add.c +++ b/src/fmpz_poly_q/add.c @@ -82,8 +82,8 @@ void fmpz_poly_q_add_in_place(fmpz_poly_q_t rop, const fmpz_poly_q_t op) fmpz_poly_init(r2); fmpz_poly_init(s2); - fmpz_poly_div(r2, rop->den, d); - fmpz_poly_div(s2, op->den, d); + fmpz_poly_divexact(r2, rop->den, d); + fmpz_poly_divexact(s2, op->den, d); fmpz_poly_mul(rop->num, rop->num, s2); fmpz_poly_mul(s2, op->num, r2); /* Using s2 as temp */ @@ -102,8 +102,8 @@ void fmpz_poly_q_add_in_place(fmpz_poly_q_t rop, const fmpz_poly_q_t op) if (!fmpz_poly_is_one(r2)) { - fmpz_poly_div(rop->num, rop->num, r2); - fmpz_poly_div(rop->den, rop->den, r2); + fmpz_poly_divexact(rop->num, rop->num, r2); + fmpz_poly_divexact(rop->den, rop->den, r2); } } fmpz_poly_clear(r2); @@ -209,8 +209,8 @@ fmpz_poly_q_add(fmpz_poly_q_t rop, fmpz_poly_init(r2); fmpz_poly_init(s2); - fmpz_poly_div(r2, op1->den, d); /* +ve leading coeff */ - fmpz_poly_div(s2, op2->den, d); /* +ve leading coeff */ + fmpz_poly_divexact(r2, op1->den, d); /* +ve leading coeff */ + fmpz_poly_divexact(s2, op2->den, d); /* +ve leading coeff */ fmpz_poly_mul(rop->num, op1->num, s2); fmpz_poly_mul(rop->den, op2->num, r2); /* Using rop->den as temp */ @@ -229,8 +229,8 @@ fmpz_poly_q_add(fmpz_poly_q_t rop, if (!fmpz_poly_is_one(r2)) { - fmpz_poly_div(rop->num, rop->num, r2); - fmpz_poly_div(rop->den, rop->den, r2); + fmpz_poly_divexact(rop->num, rop->num, r2); + fmpz_poly_divexact(rop->den, rop->den, r2); } } diff --git a/src/fmpz_poly_q/canonicalise.c b/src/fmpz_poly_q/canonicalise.c index 49cbf6ca25..ff1d5d8c4d 100644 --- a/src/fmpz_poly_q/canonicalise.c +++ b/src/fmpz_poly_q/canonicalise.c @@ -28,8 +28,8 @@ void fmpz_poly_q_canonicalise(fmpz_poly_q_t rop) fmpz_poly_gcd(gcd, rop->num, rop->den); if (!fmpz_poly_is_unit(gcd)) { - fmpz_poly_div(rop->num, rop->num, gcd); - fmpz_poly_div(rop->den, rop->den, gcd); + fmpz_poly_divexact(rop->num, rop->num, gcd); + fmpz_poly_divexact(rop->den, rop->den, gcd); } fmpz_poly_clear(gcd); diff --git a/src/fmpz_poly_q/derivative.c b/src/fmpz_poly_q/derivative.c index b951a9393c..4f3386736c 100644 --- a/src/fmpz_poly_q/derivative.c +++ b/src/fmpz_poly_q/derivative.c @@ -36,7 +36,7 @@ void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op) fmpz_poly_derivative(rhs, op->den); fmpz_poly_gcd(d, rhs, op->den); if (!fmpz_poly_is_one(d)) - fmpz_poly_div(rhs, rhs, d); + fmpz_poly_divexact(rhs, rhs, d); fmpz_poly_mul(rhs, op->num, rhs); fmpz_poly_derivative(rop->num, op->num); @@ -48,7 +48,7 @@ void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op) else { fmpz_poly_init(lhs); - fmpz_poly_div(lhs, op->den, d); + fmpz_poly_divexact(lhs, op->den, d); fmpz_poly_mul(rop->num, rop->num, lhs); fmpz_poly_mul(rop->den, op->den, lhs); fmpz_poly_clear(lhs); diff --git a/src/fmpz_poly_q/div.c b/src/fmpz_poly_q/div.c index cfac02fdfd..83bd00fde1 100644 --- a/src/fmpz_poly_q/div.c +++ b/src/fmpz_poly_q/div.c @@ -78,9 +78,9 @@ void fmpz_poly_q_div(fmpz_poly_q_t rop, } else { - fmpz_poly_div(rop->num, op2->den, rop->den); + fmpz_poly_divexact(rop->num, op2->den, rop->den); fmpz_poly_mul(rop->num, op1->num, rop->num); - fmpz_poly_div(rop->den, op1->den, rop->den); + fmpz_poly_divexact(rop->den, op1->den, rop->den); fmpz_poly_mul(rop->den, rop->den, op2->num); } } @@ -90,9 +90,9 @@ void fmpz_poly_q_div(fmpz_poly_q_t rop, if (fmpz_poly_is_one(rop->den)) { - fmpz_poly_div(rop->den, op2->num, rop->num); + fmpz_poly_divexact(rop->den, op2->num, rop->num); fmpz_poly_mul(rop->den, op1->den, rop->den); - fmpz_poly_div(rop->num, op1->num, rop->num); + fmpz_poly_divexact(rop->num, op1->num, rop->num); fmpz_poly_mul(rop->num, rop->num, op2->den); } else @@ -101,11 +101,11 @@ void fmpz_poly_q_div(fmpz_poly_q_t rop, fmpz_poly_init(t); fmpz_poly_init(u); - fmpz_poly_div(t, op1->num, rop->num); - fmpz_poly_div(u, op2->num, rop->num); - fmpz_poly_div(rop->num, op2->den, rop->den); + fmpz_poly_divexact(t, op1->num, rop->num); + fmpz_poly_divexact(u, op2->num, rop->num); + fmpz_poly_divexact(rop->num, op2->den, rop->den); fmpz_poly_mul(rop->num, t, rop->num); - fmpz_poly_div(rop->den, op1->den, rop->den); + fmpz_poly_divexact(rop->den, op1->den, rop->den); fmpz_poly_mul(rop->den, rop->den, u); fmpz_poly_clear(t); fmpz_poly_clear(u); diff --git a/src/fmpz_poly_q/mul.c b/src/fmpz_poly_q/mul.c index 2bd2d29295..b971d3dab9 100644 --- a/src/fmpz_poly_q/mul.c +++ b/src/fmpz_poly_q/mul.c @@ -82,9 +82,9 @@ void fmpz_poly_q_mul(fmpz_poly_q_t rop, } else { - fmpz_poly_div(rop->num, op2->num, rop->den); + fmpz_poly_divexact(rop->num, op2->num, rop->den); fmpz_poly_mul(rop->num, op1->num, rop->num); - fmpz_poly_div(rop->den, op1->den, rop->den); + fmpz_poly_divexact(rop->den, op1->den, rop->den); fmpz_poly_mul(rop->den, rop->den, op2->den); } } @@ -94,9 +94,9 @@ void fmpz_poly_q_mul(fmpz_poly_q_t rop, if (fmpz_poly_is_one(rop->den)) { - fmpz_poly_div(rop->den, op2->den, rop->num); + fmpz_poly_divexact(rop->den, op2->den, rop->num); fmpz_poly_mul(rop->den, op1->den, rop->den); - fmpz_poly_div(rop->num, op1->num, rop->num); + fmpz_poly_divexact(rop->num, op1->num, rop->num); fmpz_poly_mul(rop->num, rop->num, op2->num); } else @@ -105,11 +105,11 @@ void fmpz_poly_q_mul(fmpz_poly_q_t rop, fmpz_poly_init(t); fmpz_poly_init(u); - fmpz_poly_div(t, op1->num, rop->num); - fmpz_poly_div(u, op2->den, rop->num); - fmpz_poly_div(rop->num, op2->num, rop->den); + fmpz_poly_divexact(t, op1->num, rop->num); + fmpz_poly_divexact(u, op2->den, rop->num); + fmpz_poly_divexact(rop->num, op2->num, rop->den); fmpz_poly_mul(rop->num, t, rop->num); - fmpz_poly_div(rop->den, op1->den, rop->den); + fmpz_poly_divexact(rop->den, op1->den, rop->den); fmpz_poly_mul(rop->den, rop->den, u); fmpz_poly_clear(t); fmpz_poly_clear(u); diff --git a/src/fmpz_poly_q/sub.c b/src/fmpz_poly_q/sub.c index 4ffa6548c6..373f10be1f 100644 --- a/src/fmpz_poly_q/sub.c +++ b/src/fmpz_poly_q/sub.c @@ -128,8 +128,8 @@ fmpz_poly_q_sub(fmpz_poly_q_t rop, fmpz_poly_init(r2); fmpz_poly_init(s2); - fmpz_poly_div(r2, op1->den, d); /* +ve leading coeff */ - fmpz_poly_div(s2, op2->den, d); /* +ve leading coeff */ + fmpz_poly_divexact(r2, op1->den, d); /* +ve leading coeff */ + fmpz_poly_divexact(s2, op2->den, d); /* +ve leading coeff */ fmpz_poly_mul(rop->num, op1->num, s2); fmpz_poly_mul(rop->den, op2->num, r2); /* Using rop->den as temp */ @@ -148,8 +148,8 @@ fmpz_poly_q_sub(fmpz_poly_q_t rop, if (!fmpz_poly_is_one(r2)) { - fmpz_poly_div(rop->num, rop->num, r2); - fmpz_poly_div(rop->den, rop->den, r2); + fmpz_poly_divexact(rop->num, rop->num, r2); + fmpz_poly_divexact(rop->den, rop->den, r2); } }