Skip to content

Commit

Permalink
Replace some direct ccalls by calls to wrappers (#1828)
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin authored Jul 16, 2024
1 parent dd58b62 commit 088d70c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 88 deletions.
104 changes: 32 additions & 72 deletions src/flint/FlintTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1289,10 +1289,8 @@ mutable struct ZZMPolyRingElem <: MPolyRingElem{ZZRingElem}
z, a[i], b[i], ctx)
end

ccall((:fmpz_mpoly_sort_terms, libflint), Nothing,
(Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), z, ctx)
ccall((:fmpz_mpoly_combine_like_terms, libflint), Nothing,
(Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand All @@ -1309,10 +1307,8 @@ mutable struct ZZMPolyRingElem <: MPolyRingElem{ZZRingElem}
z, a[i], b[i], ctx)
end

ccall((:fmpz_mpoly_sort_terms, libflint), Nothing,
(Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), z, ctx)
ccall((:fmpz_mpoly_combine_like_terms, libflint), Nothing,
(Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand All @@ -1329,10 +1325,8 @@ mutable struct ZZMPolyRingElem <: MPolyRingElem{ZZRingElem}
z, a[i], b[i], ctx)
end

ccall((:fmpz_mpoly_sort_terms, libflint), Nothing,
(Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), z, ctx)
ccall((:fmpz_mpoly_combine_like_terms, libflint), Nothing,
(Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand Down Expand Up @@ -1484,10 +1478,8 @@ mutable struct QQMPolyRingElem <: MPolyRingElem{QQFieldElem}
z, a[i], b[i], ctx)
end

ccall((:fmpq_mpoly_sort_terms, libflint), Nothing,
(Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), z, ctx)
ccall((:fmpq_mpoly_combine_like_terms, libflint), Nothing,
(Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand All @@ -1504,10 +1496,8 @@ mutable struct QQMPolyRingElem <: MPolyRingElem{QQFieldElem}
z, a[i], b[i], ctx)
end

ccall((:fmpq_mpoly_sort_terms, libflint), Nothing,
(Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), z, ctx)
ccall((:fmpq_mpoly_combine_like_terms, libflint), Nothing,
(Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand All @@ -1524,10 +1514,8 @@ mutable struct QQMPolyRingElem <: MPolyRingElem{QQFieldElem}
z, a[i], b[i], ctx)
end

ccall((:fmpq_mpoly_sort_terms, libflint), Nothing,
(Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), z, ctx)
ccall((:fmpq_mpoly_combine_like_terms, libflint), Nothing,
(Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand Down Expand Up @@ -1696,10 +1684,8 @@ mutable struct zzModMPolyRingElem <: MPolyRingElem{zzModRingElem}
z, a[i].data, b[i], ctx)
end

ccall((:nmod_mpoly_sort_terms, libflint), Nothing,
(Ref{zzModMPolyRingElem}, Ref{zzModMPolyRing}), z, ctx)
ccall((:nmod_mpoly_combine_like_terms, libflint), Nothing,
(Ref{zzModMPolyRingElem}, Ref{zzModMPolyRing}), z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand All @@ -1716,10 +1702,8 @@ mutable struct zzModMPolyRingElem <: MPolyRingElem{zzModRingElem}
z, a[i].data, b[i], ctx)
end

ccall((:nmod_mpoly_sort_terms, libflint), Nothing,
(Ref{zzModMPolyRingElem}, Ref{zzModMPolyRing}), z, ctx)
ccall((:nmod_mpoly_combine_like_terms, libflint), Nothing,
(Ref{zzModMPolyRingElem}, Ref{zzModMPolyRing}), z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand All @@ -1736,10 +1720,8 @@ mutable struct zzModMPolyRingElem <: MPolyRingElem{zzModRingElem}
z, a[i].data, b[i], ctx)
end

ccall((:nmod_mpoly_sort_terms, libflint), Nothing,
(Ref{zzModMPolyRingElem}, Ref{zzModMPolyRing}), z, ctx)
ccall((:nmod_mpoly_combine_like_terms, libflint), Nothing,
(Ref{zzModMPolyRingElem}, Ref{zzModMPolyRing}), z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand Down Expand Up @@ -1887,12 +1869,8 @@ mutable struct fpMPolyRingElem <: MPolyRingElem{fpFieldElem}
z, a[i].data, b[i], ctx)
end

ccall((:nmod_mpoly_sort_terms, libflint), Nothing,
(Ref{fpMPolyRingElem}, Ref{fpMPolyRing}),
z, ctx)
ccall((:nmod_mpoly_combine_like_terms, libflint), Nothing,
(Ref{fpMPolyRingElem}, Ref{fpMPolyRing}),
z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand All @@ -1910,12 +1888,8 @@ mutable struct fpMPolyRingElem <: MPolyRingElem{fpFieldElem}
z, a[i].data, b[i], ctx)
end

ccall((:nmod_mpoly_sort_terms, libflint), Nothing,
(Ref{fpMPolyRingElem}, Ref{fpMPolyRing}),
z, ctx)
ccall((:nmod_mpoly_combine_like_terms, libflint), Nothing,
(Ref{fpMPolyRingElem}, Ref{fpMPolyRing}),
z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand All @@ -1933,12 +1907,8 @@ mutable struct fpMPolyRingElem <: MPolyRingElem{fpFieldElem}
z, a[i].data, b[i], ctx)
end

ccall((:nmod_mpoly_sort_terms, libflint), Nothing,
(Ref{fpMPolyRingElem}, Ref{fpMPolyRing}),
z, ctx)
ccall((:nmod_mpoly_combine_like_terms, libflint), Nothing,
(Ref{fpMPolyRingElem}, Ref{fpMPolyRing}),
z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand Down Expand Up @@ -2104,12 +2074,8 @@ mutable struct FpMPolyRingElem <: MPolyRingElem{FpFieldElem}
end
end

ccall((:fmpz_mod_mpoly_sort_terms, libflint), Nothing,
(Ref{FpMPolyRingElem}, Ref{FpMPolyRing}),
z, ctx)
ccall((:fmpz_mod_mpoly_combine_like_terms, libflint), Nothing,
(Ref{FpMPolyRingElem}, Ref{FpMPolyRing}),
z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand Down Expand Up @@ -2819,10 +2785,8 @@ mutable struct fqPolyRepMPolyRingElem <: MPolyRingElem{fqPolyRepFieldElem}
z, a[i], b[i], ctx)
end

ccall((:fq_nmod_mpoly_sort_terms, libflint), Nothing,
(Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), z, ctx)
ccall((:fq_nmod_mpoly_combine_like_terms, libflint), Nothing,
(Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand All @@ -2839,10 +2803,8 @@ mutable struct fqPolyRepMPolyRingElem <: MPolyRingElem{fqPolyRepFieldElem}
z, a[i], b[i], ctx)
end

ccall((:fq_nmod_mpoly_sort_terms, libflint), Nothing,
(Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), z, ctx)
ccall((:fq_nmod_mpoly_combine_like_terms, libflint), Nothing,
(Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand All @@ -2859,10 +2821,8 @@ mutable struct fqPolyRepMPolyRingElem <: MPolyRingElem{fqPolyRepFieldElem}
z, a[i], b[i], ctx)
end

ccall((:fq_nmod_mpoly_sort_terms, libflint), Nothing,
(Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), z, ctx)
ccall((:nmod_mpoly_combine_like_terms, libflint), Nothing,
(Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), z, ctx)
sort_terms!(z)
combine_like_terms!(z)
return z
end

Expand Down
6 changes: 2 additions & 4 deletions src/flint/fmpq_mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1171,10 +1171,8 @@ function finish(M::MPolyBuildCtx{QQMPolyRingElem})
res = M.poly
R = parent(res)
M.poly = zero(R)
ccall((:fmpq_mpoly_sort_terms, libflint), Nothing,
(Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), res, R)
ccall((:fmpq_mpoly_combine_like_terms, libflint), Nothing,
(Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), res, R)
sort_terms!(res)
combine_like_terms!(res)
return res
end

Expand Down
6 changes: 2 additions & 4 deletions src/flint/fmpz_mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1052,10 +1052,8 @@ function finish(M::MPolyBuildCtx{ZZMPolyRingElem})
res = M.poly
R = parent(res)
M.poly = zero(R)
ccall((:fmpz_mpoly_sort_terms, libflint), Nothing,
(Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), res, R)
ccall((:fmpz_mpoly_combine_like_terms, libflint), Nothing,
(Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), res, R)
sort_terms!(res)
combine_like_terms!(res)
return res
end

Expand Down
6 changes: 2 additions & 4 deletions src/flint/fq_nmod_mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1022,10 +1022,8 @@ function finish(M::MPolyBuildCtx{fqPolyRepMPolyRingElem})
res = M.poly
R = parent(res)
M.poly = zero(R)
ccall((:fq_nmod_mpoly_sort_terms, libflint), Nothing,
(Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), res, R)
ccall((:fq_nmod_mpoly_combine_like_terms, libflint), Nothing,
(Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), res, R)
sort_terms!(res)
combine_like_terms!(res)
return res
end

Expand Down
6 changes: 2 additions & 4 deletions src/flint/nmod_mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1074,10 +1074,8 @@ for (etype, rtype, ftype, ctype, utype) in (
res = M.poly
R = parent(res)
M.poly = zero(R)
ccall((:nmod_mpoly_sort_terms, libflint), Nothing,
(Ref{$etype}, Ref{$rtype}), res, R)
ccall((:nmod_mpoly_combine_like_terms, libflint), Nothing,
(Ref{$etype}, Ref{$rtype}), res, R)
sort_terms!(res)
combine_like_terms!(res)
return res
end

Expand Down

0 comments on commit 088d70c

Please sign in to comment.