Skip to content

Commit

Permalink
replace uses of fmpz_poly_div -> fmpz_poly_divexact
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrik-johansson committed Feb 3, 2024
1 parent e0dbd8b commit 4bee365
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 48 deletions.
4 changes: 2 additions & 2 deletions src/fmpq_poly/xgcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/fmpz_mpoly_factor/bpoly_factor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/fmpz_mpoly_factor/lcc_kaltofen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/fmpz_poly/cos_minpoly.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/fmpz_poly/lcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/fmpz_poly/remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -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--;
}

Expand Down
8 changes: 4 additions & 4 deletions src/fmpz_poly_factor/factor_squarefree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/fmpz_poly_mat/fflu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/fmpz_poly_mat/rref.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/fmpz_poly_mat/solve_fflu_precomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand All @@ -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));
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/fmpz_poly_q/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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);
Expand Down Expand Up @@ -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 */
Expand All @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/fmpz_poly_q/canonicalise.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/fmpz_poly_q/derivative.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions src/fmpz_poly_q/div.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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
Expand All @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions src/fmpz_poly_q/mul.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/fmpz_poly_q/sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 4bee365

Please sign in to comment.