From 66a46b9c937fae5765d1307730001bdda2c39a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Tue, 29 Oct 2024 17:11:13 +0100 Subject: [PATCH] Update ccall syntax to `@ccall` using a script --- benchmarks/gcdx.jl | 3 +- src/HeckeMoreStuff.jl | 93 +- src/Nemo.jl | 10 +- src/antic/AnticTypes.jl | 17 +- src/antic/nf_elem.jl | 252 ++-- src/arb/ArbTypes.jl | 165 +-- src/arb/Complex.jl | 321 ++--- src/arb/ComplexMat.jl | 141 +-- src/arb/ComplexPoly.jl | 142 +-- src/arb/Real.jl | 405 +++---- src/arb/RealMat.jl | 107 +- src/arb/RealPoly.jl | 134 +-- src/arb/acb.jl | 315 ++--- src/arb/acb_calc.jl | 31 +- src/arb/acb_mat.jl | 141 +-- src/arb/acb_poly.jl | 138 +-- src/arb/arb.jl | 415 +++---- src/arb/arb_mat.jl | 113 +- src/arb/arb_poly.jl | 130 +- src/calcium/CalciumTypes.jl | 18 +- src/calcium/ca.jl | 340 ++---- src/calcium/qqbar.jl | 284 ++--- src/flint/FlintTypes.jl | 1333 +++++++-------------- src/flint/fmpq.jl | 119 +- src/flint/fmpq_abs_series.jl | 166 +-- src/flint/fmpq_mat.jl | 135 +-- src/flint/fmpq_mpoly.jl | 315 ++--- src/flint/fmpq_poly.jl | 171 +-- src/flint/fmpq_rel_series.jl | 286 ++--- src/flint/fmpz.jl | 350 ++---- src/flint/fmpz_abs_series.jl | 119 +- src/flint/fmpz_factor.jl | 16 +- src/flint/fmpz_laurent_series.jl | 36 +- src/flint/fmpz_mat.jl | 243 ++-- src/flint/fmpz_mod.jl | 26 +- src/flint/fmpz_mod_abs_series.jl | 152 +-- src/flint/fmpz_mod_mat.jl | 153 +-- src/flint/fmpz_mod_mpoly.jl | 319 ++--- src/flint/fmpz_mod_poly.jl | 247 +--- src/flint/fmpz_mod_rel_series.jl | 226 +--- src/flint/fmpz_mpoly.jl | 304 ++--- src/flint/fmpz_poly.jl | 159 +-- src/flint/fmpz_rel_series.jl | 179 +-- src/flint/fq.jl | 114 +- src/flint/fq_default.jl | 126 +- src/flint/fq_default_abs_series.jl | 128 +- src/flint/fq_default_embed.jl | 12 +- src/flint/fq_default_extended.jl | 30 +- src/flint/fq_default_mat.jl | 166 +-- src/flint/fq_default_poly.jl | 228 +--- src/flint/fq_default_rel_series.jl | 189 +-- src/flint/fq_embed.jl | 22 +- src/flint/fq_mat.jl | 134 +-- src/flint/fq_nmod.jl | 155 +-- src/flint/fq_nmod_embed.jl | 14 +- src/flint/fq_nmod_mat.jl | 136 +-- src/flint/fq_nmod_mpoly.jl | 308 ++--- src/flint/fq_nmod_poly.jl | 219 +--- src/flint/fq_poly.jl | 214 +--- src/flint/gfp_elem.jl | 32 +- src/flint/gfp_fmpz_elem.jl | 45 +- src/flint/gfp_fmpz_mat.jl | 57 +- src/flint/gfp_fmpz_poly.jl | 125 +- src/flint/gfp_mat.jl | 48 +- src/flint/gfp_poly.jl | 97 +- src/flint/nmod.jl | 18 +- src/flint/nmod_abs_series.jl | 103 +- src/flint/nmod_mat.jl | 138 +-- src/flint/nmod_mpoly.jl | 325 ++--- src/flint/nmod_poly.jl | 203 ++-- src/flint/nmod_rel_series.jl | 200 +--- src/flint/padic.jl | 100 +- src/flint/qadic.jl | 133 +- src/gaussiannumbers/QQi.jl | 4 +- src/gaussiannumbers/ZZi.jl | 7 +- src/gaussiannumbers/continued_fraction.jl | 28 +- src/julia/Integer.jl | 2 +- 77 files changed, 3842 insertions(+), 8787 deletions(-) diff --git a/benchmarks/gcdx.jl b/benchmarks/gcdx.jl index 7b360f667..820678f5b 100644 --- a/benchmarks/gcdx.jl +++ b/benchmarks/gcdx.jl @@ -7,8 +7,7 @@ function gcdx_fmpz(a::ZZRingElem, b::ZZRingElem) d = ZZ() x = ZZ() y = ZZ() - ccall((:fmpz_xgcd_canonical_bezout, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), d, x, y, a, b) + @ccall libflint.fmpz_xgcd_canonical_bezout(d::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem}, a::Ref{ZZRingElem}, b::Ref{ZZRingElem})::Nothing return d, x, y end diff --git a/src/HeckeMoreStuff.jl b/src/HeckeMoreStuff.jl index b28d9bddc..6f0f8a09b 100644 --- a/src/HeckeMoreStuff.jl +++ b/src/HeckeMoreStuff.jl @@ -79,8 +79,7 @@ function _acb_mat(A::ArbMatrix) end function mul!(z::AcbFieldElem, x::AcbFieldElem, y::ArbFieldElem) - ccall((:acb_mul_arb, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{ArbFieldElem}, Int), - z, x, y, parent(z).prec) + @ccall libflint.acb_mul_arb(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, y::Ref{ArbFieldElem}, parent(z).prec::Int)::Nothing return z end @@ -103,16 +102,13 @@ function roots(f::ZZModPolyRingElem, fac::Fac{ZZRingElem}) res = fmpz_mod_poly_factor(base_ring(f)) _fac = fmpz_factor() for (p, e) in fac - ccall((:_fmpz_factor_append, libflint), Nothing, (Ref{fmpz_factor}, Ref{ZZRingElem}, UInt), _fac, p, UInt(e)) + @ccall libflint._fmpz_factor_append(_fac::Ref{fmpz_factor}, p::Ref{ZZRingElem}, UInt(e)::UInt)::Nothing end - ccall((:fmpz_mod_poly_roots_factored, libflint), Nothing, (Ref{fmpz_mod_poly_factor}, Ref{ZZModPolyRingElem}, Cint, Ref{fmpz_factor}, Ref{fmpz_mod_ctx_struct}), res, f, 1, _fac, base_ring(f).ninv) + @ccall libflint.fmpz_mod_poly_roots_factored(res::Ref{fmpz_mod_poly_factor}, f::Ref{ZZModPolyRingElem}, 1::Cint, _fac::Ref{fmpz_factor}, base_ring(f).ninv::Ref{fmpz_mod_ctx_struct})::Nothing _res = Tuple{ZZModRingElem,Int}[] for i in 1:res.num g = parent(f)() - ccall((:fmpz_mod_poly_factor_get_fmpz_mod_poly, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{fmpz_mod_poly_factor}, Int, - Ref{fmpz_mod_ctx_struct}), - g, res, i - 1, base_ring(f).ninv) + @ccall libflint.fmpz_mod_poly_factor_get_fmpz_mod_poly(g::Ref{ZZModPolyRingElem}, res::Ref{fmpz_mod_poly_factor}, (i - 1)::Int, base_ring(f).ninv::Ref{fmpz_mod_ctx_struct})::Nothing e = unsafe_load(res.exp, i) push!(_res, (-coeff(g, 0), e)) end @@ -202,12 +198,12 @@ function AbstractAlgebra.map_coefficients(F::fpField, f::QQMPolyRingElem; parent end function tdivpow2!(B::ZZMatrix, t::Int) - ccall((:fmpz_mat_scalar_tdiv_q_2exp, libflint), Nothing, (Ref{ZZMatrix}, Ref{ZZMatrix}, Cint), B, B, t) + @ccall libflint.fmpz_mat_scalar_tdiv_q_2exp(B::Ref{ZZMatrix}, B::Ref{ZZMatrix}, t::Cint)::Nothing end function tdivpow2(B::ZZMatrix, t::Int) C = similar(B) - ccall((:fmpz_mat_scalar_tdiv_q_2exp, libflint), Nothing, (Ref{ZZMatrix}, Ref{ZZMatrix}, Cint), C, B, t) + @ccall libflint.fmpz_mat_scalar_tdiv_q_2exp(C::Ref{ZZMatrix}, B::Ref{ZZMatrix}, t::Cint)::Nothing return C end @@ -257,7 +253,7 @@ function dot(a::Vector{<:NumFieldElem}, b::Vector{ZZRingElem}) end function bits(x::ArbFieldElem) - return ccall((:arb_bits, libflint), Int, (Ref{ArbFieldElem},), x) + return @ccall libflint.arb_bits(x::Ref{ArbFieldElem})::Int end function Base.setprecision(x::BigFloat, p::Int) @@ -303,9 +299,7 @@ end #Assuming that the denominator of a is one, reduces all the coefficients modulo p # non-symmetric (positive) residue system function mod!(a::AbsSimpleNumFieldElem, b::ZZRingElem) - ccall((:nf_elem_mod_fmpz, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - a, a, b, parent(a)) + @ccall libflint.nf_elem_mod_fmpz(a::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{ZZRingElem}, parent(a)::Ref{AbsSimpleNumField})::Nothing return a end @@ -319,23 +313,17 @@ This function returns $b$. function numerator(a::AbsSimpleNumFieldElem) _one = one(ZZ) z = deepcopy(a) - ccall((:nf_elem_set_den, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - z, _one, a.parent) + @ccall libflint.nf_elem_set_den(z::Ref{AbsSimpleNumFieldElem}, _one::Ref{ZZRingElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return z end function divexact!(z::AbsSimpleNumFieldElem, x::AbsSimpleNumFieldElem, y::ZZRingElem) - ccall((:nf_elem_scalar_div_fmpz, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - z, x, y, parent(x)) + @ccall libflint.nf_elem_scalar_div_fmpz(z::Ref{AbsSimpleNumFieldElem}, x::Ref{AbsSimpleNumFieldElem}, y::Ref{ZZRingElem}, parent(x)::Ref{AbsSimpleNumField})::Nothing return z end function sub!(a::AbsSimpleNumFieldElem, b::AbsSimpleNumFieldElem, c::AbsSimpleNumFieldElem) - ccall((:nf_elem_sub, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - a, b, c, a.parent) + @ccall libflint.nf_elem_sub(a::Ref{AbsSimpleNumFieldElem}, b::Ref{AbsSimpleNumFieldElem}, c::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return a end @@ -351,9 +339,7 @@ function evaluate(f::fpPolyRingElem, v::Vector{fpFieldElem}) F = base_ring(f) v1 = UInt[x.data for x in v] res = UInt[UInt(1) for x in v] - ccall((:nmod_poly_evaluate_nmod_vec, libflint), Nothing, - (Ptr{UInt}, Ref{fpPolyRingElem}, Ptr{UInt}, UInt), - res, f, v1, UInt(length(v))) + @ccall libflint.nmod_poly_evaluate_nmod_vec(res::Ptr{UInt}, f::Ref{fpPolyRingElem}, v1::Ptr{UInt}, UInt(length(v))::UInt)::Nothing return fpFieldElem[fpFieldElem(x, F) for x in res] end @@ -434,7 +420,7 @@ end function invmod(f::ZZModPolyRingElem, M::ZZModPolyRingElem) if !is_unit(f) r = parent(f)() - i = ccall((:fmpz_mod_poly_invmod, libflint), Int, (Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), r, f, M, f.parent.base_ring.ninv) + i = @ccall libflint.fmpz_mod_poly_invmod(r::Ref{ZZModPolyRingElem}, f::Ref{ZZModPolyRingElem}, M::Ref{ZZModPolyRingElem}, f.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Int if iszero(i) error("not yet implemented") else @@ -461,31 +447,31 @@ function invmod(f::ZZModPolyRingElem, M::ZZModPolyRingElem) end function round!(z::ArbFieldElem, x::ArbFieldElem, p::Int) - ccall((:arb_set_round, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, p) + @ccall libflint.arb_set_round(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, p::Int)::Nothing z.parent = ArbField(p, cached=false) return z end function round!(z::AcbFieldElem, x::AcbFieldElem, p::Int) - ccall((:acb_set_round, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, p) + @ccall libflint.acb_set_round(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, p::Int)::Nothing z.parent = AcbField(p, cached=false) return z end function round(x::ArbFieldElem, p::Int) z = ArbField(p, cached=false)() - ccall((:arb_set_round, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, p) + @ccall libflint.arb_set_round(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, p::Int)::Nothing return z end function round(x::AcbFieldElem, p::Int) z = AcbField(p, cached=false)() - ccall((:acb_set_round, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, p) + @ccall libflint.acb_set_round(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, p::Int)::Nothing return z end function bits(x::AcbFieldElem) - return ccall((:acb_bits, libflint), Int, (Ref{AcbFieldElem},), x) + return @ccall libflint.acb_bits(x::Ref{AcbFieldElem})::Int end function order(x::EuclideanRingResidueRingElem{ZZRingElem}, fp::Dict{ZZRingElem,Int64}) @@ -610,17 +596,17 @@ function rand(R::Union{EuclideanRingResidueRing{zzModPolyRingElem},EuclideanRing end function rem!(f::zzModPolyRingElem, g::zzModPolyRingElem, h::zzModPolyRingElem) - ccall((:nmod_poly_rem, libflint), Nothing, (Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}), f, g, h) + @ccall libflint.nmod_poly_rem(f::Ref{zzModPolyRingElem}, g::Ref{zzModPolyRingElem}, h::Ref{zzModPolyRingElem})::Nothing return f end function gcd!(f::zzModPolyRingElem, g::zzModPolyRingElem, h::zzModPolyRingElem) - ccall((:nmod_poly_gcd, libflint), Nothing, (Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}), f, g, h) + @ccall libflint.nmod_poly_gcd(f::Ref{zzModPolyRingElem}, g::Ref{zzModPolyRingElem}, h::Ref{zzModPolyRingElem})::Nothing return f end function gcd!(f::fpPolyRingElem, g::fpPolyRingElem, h::fpPolyRingElem) - ccall((:nmod_poly_gcd, libflint), Nothing, (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), f, g, h) + @ccall libflint.nmod_poly_gcd(f::Ref{fpPolyRingElem}, g::Ref{fpPolyRingElem}, h::Ref{fpPolyRingElem})::Nothing return f end @@ -722,9 +708,7 @@ function evaluate(f::QQPolyRingElem, a::AbsSimpleNumFieldElem) end function rem!(z::fpPolyRingElem, a::fpPolyRingElem, b::fpPolyRingElem) - ccall((:nmod_poly_rem, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ptr{Nothing}), - z, a, b, pointer_from_objref(base_ring(z)) + sizeof(ZZRingElem)) + @ccall libflint.nmod_poly_rem(z::Ref{fpPolyRingElem}, a::Ref{fpPolyRingElem}, b::Ref{fpPolyRingElem}, (pointer_from_objref(base_ring(z)) + sizeof(ZZRingElem))::Ptr{Nothing})::Nothing return z end @@ -750,8 +734,7 @@ function image(M::Map{D,C}, a) where {D,C} end function setcoeff!(x::fqPolyRepFieldElem, n::Int, u::UInt) - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Int, UInt), x, n, u) + @ccall libflint.nmod_poly_set_coeff_ui(x::Ref{fqPolyRepFieldElem}, n::Int, u::UInt)::Nothing end function basis(k::fpField) @@ -990,9 +973,7 @@ is_cyclo_type(::NumField) = false function nf_elem_to_fmpz_mod_poly!(r::ZZModPolyRingElem, a::AbsSimpleNumFieldElem, useden::Bool=true) - ccall((:nf_elem_get_fmpz_mod_poly_den, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}, Cint, Ref{fmpz_mod_ctx_struct}), - r, a, a.parent, Cint(useden), r.parent.base_ring.ninv) + @ccall libflint.nf_elem_get_fmpz_mod_poly_den(r::Ref{ZZModPolyRingElem}, a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField}, Cint(useden)::Cint, r.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return nothing end @@ -1003,9 +984,7 @@ function (R::ZZModPolyRing)(a::AbsSimpleNumFieldElem) end function nf_elem_to_gfp_poly!(r::fpPolyRingElem, a::AbsSimpleNumFieldElem, useden::Bool=true) - ccall((:nf_elem_get_nmod_poly_den, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}, Cint), - r, a, a.parent, Cint(useden)) + @ccall libflint.nf_elem_get_nmod_poly_den(r::Ref{fpPolyRingElem}, a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField}, Cint(useden)::Cint)::Nothing return nothing end @@ -1016,9 +995,7 @@ function (R::fpPolyRing)(a::AbsSimpleNumFieldElem) end function nf_elem_to_nmod_poly!(r::zzModPolyRingElem, a::AbsSimpleNumFieldElem, useden::Bool=true) - ccall((:nf_elem_get_nmod_poly_den, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}, Cint), - r, a, a.parent, Cint(useden)) + @ccall libflint.nf_elem_get_nmod_poly_den(r::Ref{zzModPolyRingElem}, a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField}, Cint(useden)::Cint)::Nothing return nothing end @@ -1029,9 +1006,7 @@ function (R::zzModPolyRing)(a::AbsSimpleNumFieldElem) end function nf_elem_to_gfp_fmpz_poly!(r::FpPolyRingElem, a::AbsSimpleNumFieldElem, useden::Bool=true) - ccall((:nf_elem_get_fmpz_mod_poly_den, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}, Cint, Ref{fmpz_mod_ctx_struct}), - r, a, a.parent, Cint(useden), r.parent.base_ring.ninv) + @ccall libflint.nf_elem_get_fmpz_mod_poly_den(r::Ref{FpPolyRingElem}, a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField}, Cint(useden)::Cint, r.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return nothing end @@ -1099,29 +1074,29 @@ end function (R::FqPolyRepField)(x::ZZModPolyRingElem) z = R() - ccall((:fq_set_fmpz_mod_poly, libflint), Nothing, (Ref{FqPolyRepFieldElem}, Ref{ZZModPolyRingElem}, Ref{FqPolyRepField}), z, x, R) - #ccall((:fq_reduce, libflint), Nothing, (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, R) + @ccall libflint.fq_set_fmpz_mod_poly(z::Ref{FqPolyRepFieldElem}, x::Ref{ZZModPolyRingElem}, R::Ref{FqPolyRepField})::Nothing + #@ccall libflint.fq_reduce(z::Ref{FqPolyRepFieldElem}, R::Ref{FqPolyRepField})::Nothing return z end function (R::FqPolyRepField)(x::FpPolyRingElem) z = R() - ccall((:fq_set_fmpz_mod_poly, libflint), Nothing, (Ref{FqPolyRepFieldElem}, Ref{FpPolyRingElem}, Ref{FqPolyRepField}), z, x, R) - ccall((:fq_reduce, libflint), Nothing, (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, R) + @ccall libflint.fq_set_fmpz_mod_poly(z::Ref{FqPolyRepFieldElem}, x::Ref{FpPolyRingElem}, R::Ref{FqPolyRepField})::Nothing + @ccall libflint.fq_reduce(z::Ref{FqPolyRepFieldElem}, R::Ref{FqPolyRepField})::Nothing return z end @inline function rem!(a::ZZRingElem, b::ZZRingElem, c::ZZRingElem) - ccall((:fmpz_mod, libflint), Nothing, (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), a, b, c) + @ccall libflint.fmpz_mod(a::Ref{ZZRingElem}, b::Ref{ZZRingElem}, c::Ref{ZZRingElem})::Nothing return a end function rem!(a::ZZModPolyRingElem, b::ZZModPolyRingElem, c::ZZModPolyRingElem) - ccall((:fmpz_mod_poly_rem, libflint), Nothing, (Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), a, b, c, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_rem(a::Ref{ZZModPolyRingElem}, b::Ref{ZZModPolyRingElem}, c::Ref{ZZModPolyRingElem}, a.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return a end function rem!(a::FpPolyRingElem, b::FpPolyRingElem, c::FpPolyRingElem) - ccall((:fmpz_mod_poly_rem, libflint), Nothing, (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), a, b, c, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_rem(a::Ref{FpPolyRingElem}, b::Ref{FpPolyRingElem}, c::Ref{FpPolyRingElem}, a.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return a end diff --git a/src/Nemo.jl b/src/Nemo.jl index a38c1bc1f..084f6fea5 100644 --- a/src/Nemo.jl +++ b/src/Nemo.jl @@ -369,7 +369,7 @@ function flint_set_num_threads(a::Int) if !__isthreaded[] error("To use threaded flint, julia has to be started with NEMO_THREADED=1") else - ccall((:flint_set_num_threads, libflint), Nothing, (Int,), a) + @ccall libflint.flint_set_num_threads(a::Int)::Nothing end end @@ -537,21 +537,21 @@ Random.seed!(a::rand_ctx, s::Nothing=nothing) = Random.seed!(a, rand(UInt128)) if NEW_FLINT flint_randseed!(a::rand_ctx, seed1::UInt, seed2::UInt) = - ccall((:flint_rand_set_seed, libflint), Cvoid, (Ref{rand_ctx}, UInt, UInt), a, seed1, seed2) + @ccall libflint.flint_rand_set_seed(a::Ref{rand_ctx}, seed1::UInt, seed2::UInt)::Cvoid function flint_gmp_randseed!(a::rand_ctx, seed::BigInt) if a.gmp_state == C_NULL # gmp_state needs to be initialised - ccall((:_flint_rand_init_gmp_state, libflint), Cvoid, (Ref{rand_ctx},), a) + @ccall libflint._flint_rand_init_gmp_state(a::Ref{rand_ctx})::Cvoid end ccall((:__gmp_randseed, :libgmp), Cvoid, (Ptr{Cvoid}, Ref{BigInt}), a.gmp_state, seed) end else flint_randseed!(a::rand_ctx, seed1::UInt, seed2::UInt) = - ccall((:flint_randseed, libflint), Cvoid, (Ref{rand_ctx}, UInt, UInt), a, seed1, seed2) + @ccall libflint.flint_randseed(a::Ref{rand_ctx}, seed1::UInt, seed2::UInt)::Cvoid function flint_gmp_randseed!(a::rand_ctx, seed::BigInt) - ccall((:_flint_rand_init_gmp, libflint), Cvoid, (Ref{rand_ctx},), a) + @ccall libflint._flint_rand_init_gmp(a::Ref{rand_ctx})::Cvoid ccall((:__gmp_randseed, :libgmp), Cvoid, (Ref{rand_ctx}, Ref{BigInt}), a, # gmp_state is the first field of flint_rand_s seed) diff --git a/src/antic/AnticTypes.jl b/src/antic/AnticTypes.jl index c47e03bc8..73e4011be 100644 --- a/src/antic/AnticTypes.jl +++ b/src/antic/AnticTypes.jl @@ -43,8 +43,7 @@ for some more specialized fields. return get_cached!(AnticNumberFieldID, (parent(pol), pol, s), cached) do nf = new() nf.pol = pol - ccall((:nf_init, libflint), Nothing, - (Ref{AbsSimpleNumField}, Ref{QQPolyRingElem}), nf, pol) + @ccall libflint.nf_init(nf::Ref{AbsSimpleNumField}, pol::Ref{QQPolyRingElem})::Nothing finalizer(_AnticNumberField_clear_fn, nf) nf.S = s return nf @@ -56,7 +55,7 @@ const AnticNumberFieldID = CacheDictType{Tuple{QQPolyRing, QQPolyRingElem, Symbo function _AnticNumberField_clear_fn(a::AbsSimpleNumField) - ccall((:nf_clear, libflint), Nothing, (Ref{AbsSimpleNumField},), a) + @ccall libflint.nf_clear(a::Ref{AbsSimpleNumField})::Nothing end """ @@ -81,8 +80,7 @@ mutable struct AbsSimpleNumFieldElem <: SimpleNumFieldElem{QQFieldElem} function AbsSimpleNumFieldElem(p::AbsSimpleNumField) r = new() - ccall((:nf_elem_init, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), r, p) + @ccall libflint.nf_elem_init(r::Ref{AbsSimpleNumFieldElem}, p::Ref{AbsSimpleNumField})::Nothing r.parent = p finalizer(_nf_elem_clear_fn, r) return r @@ -90,10 +88,8 @@ mutable struct AbsSimpleNumFieldElem <: SimpleNumFieldElem{QQFieldElem} function AbsSimpleNumFieldElem(p::AbsSimpleNumField, a::AbsSimpleNumFieldElem) r = new() - ccall((:nf_elem_init, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), r, p) - ccall((:nf_elem_set, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), r, a, p) + @ccall libflint.nf_elem_init(r::Ref{AbsSimpleNumFieldElem}, p::Ref{AbsSimpleNumField})::Nothing + @ccall libflint.nf_elem_set(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, p::Ref{AbsSimpleNumField})::Nothing r.parent = p finalizer(_nf_elem_clear_fn, r) return r @@ -101,8 +97,7 @@ mutable struct AbsSimpleNumFieldElem <: SimpleNumFieldElem{QQFieldElem} end function _nf_elem_clear_fn(a::AbsSimpleNumFieldElem) - ccall((:nf_elem_clear, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), a, a.parent) + @ccall libflint.nf_elem_clear(a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing end diff --git a/src/antic/nf_elem.jl b/src/antic/nf_elem.jl index 4de53eea7..0d4173146 100644 --- a/src/antic/nf_elem.jl +++ b/src/antic/nf_elem.jl @@ -86,15 +86,13 @@ constant coefficient. function coeff(x::AbsSimpleNumFieldElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = QQFieldElem() - ccall((:nf_elem_get_coeff_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), z, x, n, parent(x)) + @ccall libflint.nf_elem_get_coeff_fmpq(z::Ref{QQFieldElem}, x::Ref{AbsSimpleNumFieldElem}, n::Int, parent(x)::Ref{AbsSimpleNumField})::Nothing return z end function num_coeff!(z::ZZRingElem, x::AbsSimpleNumFieldElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) - ccall((:nf_elem_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), z, x, n, parent(x)) + @ccall libflint.nf_elem_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{AbsSimpleNumFieldElem}, n::Int, parent(x)::Ref{AbsSimpleNumField})::Nothing return z end @@ -106,8 +104,7 @@ defining polynomial. """ function gen(a::AbsSimpleNumField) r = AbsSimpleNumFieldElem(a) - ccall((:nf_elem_gen, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), r, a) + @ccall libflint.nf_elem_gen(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumField})::Nothing return r end @@ -122,18 +119,15 @@ Return `true` if the given number field element is the generator of the number field, otherwise return `false`. """ function is_gen(a::AbsSimpleNumFieldElem) - return ccall((:nf_elem_is_gen, libflint), Bool, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), a, a.parent) + return @ccall libflint.nf_elem_is_gen(a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Bool end function isone(a::AbsSimpleNumFieldElem) - return ccall((:nf_elem_is_one, libflint), Bool, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), a, a.parent) + return @ccall libflint.nf_elem_is_one(a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Bool end function iszero(a::AbsSimpleNumFieldElem) - return ccall((:nf_elem_is_zero, libflint), Bool, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), a, a.parent) + return @ccall libflint.nf_elem_is_zero(a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Bool end @doc raw""" @@ -151,8 +145,7 @@ Return `true` if the given number field element is an integer, i.e., in ZZ, othe return `false`. """ function isinteger(a::AbsSimpleNumFieldElem) - b = ccall((:nf_elem_is_integer, libflint), Cint, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), a, a.parent) + b = @ccall libflint.nf_elem_is_integer(a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Cint return Bool(b) end @@ -163,8 +156,7 @@ Return `true` if the given number field element is a rational number, i.e., in Q otherwise `false`. """ function is_rational(a::AbsSimpleNumFieldElem) - b = ccall((:nf_elem_is_rational, libflint), Cint, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), a, a.parent) + b = @ccall libflint.nf_elem_is_rational(a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Cint return Bool(b) end @@ -176,9 +168,7 @@ field element. """ function denominator(a::AbsSimpleNumFieldElem) z = ZZRingElem() - ccall((:nf_elem_get_den, libflint), Nothing, - (Ref{ZZRingElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - z, a, a.parent) + @ccall libflint.nf_elem_get_den(z::Ref{ZZRingElem}, a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return z end @@ -186,16 +176,12 @@ function elem_from_mat_row(a::AbsSimpleNumField, b::ZZMatrix, i::Int, d::ZZRingE _checkbounds(nrows(b), i) || throw(BoundsError()) ncols(b) == degree(a) || error("Wrong number of columns") z = a() - ccall((:nf_elem_set_fmpz_mat_row, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{ZZMatrix}, Int, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - z, b, i - 1, d, a) + @ccall libflint.nf_elem_set_fmpz_mat_row(z::Ref{AbsSimpleNumFieldElem}, b::Ref{ZZMatrix}, (i - 1)::Int, d::Ref{ZZRingElem}, a::Ref{AbsSimpleNumField})::Nothing return z end function elem_to_mat_row!(a::ZZMatrix, i::Int, d::ZZRingElem, b::AbsSimpleNumFieldElem) - ccall((:nf_elem_get_fmpz_mat_row, libflint), Nothing, - (Ref{ZZMatrix}, Int, Ref{ZZRingElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - a, i - 1, d, b, b.parent) + @ccall libflint.nf_elem_get_fmpz_mat_row(a::Ref{ZZMatrix}, (i - 1)::Int, d::Ref{ZZRingElem}, b::Ref{AbsSimpleNumFieldElem}, b.parent::Ref{AbsSimpleNumField})::Nothing nothing end @@ -276,9 +262,7 @@ function +(a::AbsSimpleNumFieldElem, b::AbsSimpleNumFieldElem) parent(a) == parent(b) || return force_op(+, a, b)::AbsSimpleNumFieldElem check_parent(a, b) r = a.parent() - ccall((:nf_elem_add, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_add(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end @@ -286,9 +270,7 @@ function -(a::AbsSimpleNumFieldElem, b::AbsSimpleNumFieldElem) parent(a) == parent(b) || return force_op(-, a, b)::AbsSimpleNumFieldElem check_parent(a, b) r = a.parent() - ccall((:nf_elem_sub, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_sub(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end @@ -296,9 +278,7 @@ function *(a::AbsSimpleNumFieldElem, b::AbsSimpleNumFieldElem) parent(a) == parent(b) || return force_op(*, a, b)::AbsSimpleNumFieldElem check_parent(a, b) r = a.parent() - ccall((:nf_elem_mul, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_mul(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end @@ -310,73 +290,55 @@ end function +(a::AbsSimpleNumFieldElem, b::Int) r = a.parent() - ccall((:nf_elem_add_si, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_add_si(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Int, a.parent::Ref{AbsSimpleNumField})::Nothing return r end function +(a::AbsSimpleNumFieldElem, b::ZZRingElem) r = a.parent() - ccall((:nf_elem_add_fmpz, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_add_fmpz(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{ZZRingElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end function +(a::AbsSimpleNumFieldElem, b::QQFieldElem) r = a.parent() - ccall((:nf_elem_add_fmpq, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{QQFieldElem}, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_add_fmpq(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{QQFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end function -(a::AbsSimpleNumFieldElem, b::Int) r = a.parent() - ccall((:nf_elem_sub_si, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_sub_si(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Int, a.parent::Ref{AbsSimpleNumField})::Nothing return r end function -(a::AbsSimpleNumFieldElem, b::ZZRingElem) r = a.parent() - ccall((:nf_elem_sub_fmpz, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_sub_fmpz(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{ZZRingElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end function -(a::AbsSimpleNumFieldElem, b::QQFieldElem) r = a.parent() - ccall((:nf_elem_sub_fmpq, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{QQFieldElem}, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_sub_fmpq(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{QQFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end function -(a::Int, b::AbsSimpleNumFieldElem) r = b.parent() - ccall((:nf_elem_si_sub, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - r, a, b, b.parent) + @ccall libflint.nf_elem_si_sub(r::Ref{AbsSimpleNumFieldElem}, a::Int, b::Ref{AbsSimpleNumFieldElem}, b.parent::Ref{AbsSimpleNumField})::Nothing return r end function -(a::ZZRingElem, b::AbsSimpleNumFieldElem) r = b.parent() - ccall((:nf_elem_fmpz_sub, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - r, a, b, b.parent) + @ccall libflint.nf_elem_fmpz_sub(r::Ref{AbsSimpleNumFieldElem}, a::Ref{ZZRingElem}, b::Ref{AbsSimpleNumFieldElem}, b.parent::Ref{AbsSimpleNumField})::Nothing return r end function -(a::QQFieldElem, b::AbsSimpleNumFieldElem) r = b.parent() - ccall((:nf_elem_fmpq_sub, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{QQFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - r, a, b, b.parent) + @ccall libflint.nf_elem_fmpq_sub(r::Ref{AbsSimpleNumFieldElem}, a::Ref{QQFieldElem}, b::Ref{AbsSimpleNumFieldElem}, b.parent::Ref{AbsSimpleNumField})::Nothing return r end @@ -400,25 +362,19 @@ end function *(a::AbsSimpleNumFieldElem, b::Int) r = a.parent() - ccall((:nf_elem_scalar_mul_si, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_scalar_mul_si(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Int, a.parent::Ref{AbsSimpleNumField})::Nothing return r end function *(a::AbsSimpleNumFieldElem, b::ZZRingElem) r = a.parent() - ccall((:nf_elem_scalar_mul_fmpz, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_scalar_mul_fmpz(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{ZZRingElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end function *(a::AbsSimpleNumFieldElem, b::QQFieldElem) r = a.parent() - ccall((:nf_elem_scalar_mul_fmpq, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{QQFieldElem}, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_scalar_mul_fmpq(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{QQFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end @@ -462,9 +418,7 @@ end function ^(a::AbsSimpleNumFieldElem, n::Int) r = a.parent() - ccall((:nf_elem_pow, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), - r, a, abs(n), a.parent) + @ccall libflint.nf_elem_pow(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, abs(n)::Int, a.parent::Ref{AbsSimpleNumField})::Nothing if n < 0 r = inv(r) end @@ -480,8 +434,7 @@ end function ==(a::AbsSimpleNumFieldElem, b::AbsSimpleNumFieldElem) parent(a) == parent(b) || return force_op(==, a, b)::Bool check_parent(a, b) - return ccall((:nf_elem_equal, libflint), Bool, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), a, b, a.parent) + return @ccall libflint.nf_elem_equal(a::Ref{AbsSimpleNumFieldElem}, b::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Bool end ############################################################################### @@ -491,30 +444,22 @@ end ############################################################################### function ==(a::AbsSimpleNumFieldElem, b::ZZRingElem) - b = ccall((:nf_elem_equal_fmpz, libflint), Cint, - (Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - a, b, a.parent) + b = @ccall libflint.nf_elem_equal_fmpz(a::Ref{AbsSimpleNumFieldElem}, b::Ref{ZZRingElem}, a.parent::Ref{AbsSimpleNumField})::Cint return Bool(b) end function ==(a::AbsSimpleNumFieldElem, b::QQFieldElem) - b = ccall((:nf_elem_equal_fmpq, libflint), Cint, - (Ref{AbsSimpleNumFieldElem}, Ref{QQFieldElem}, Ref{AbsSimpleNumField}), - a, b, a.parent) + b = @ccall libflint.nf_elem_equal_fmpq(a::Ref{AbsSimpleNumFieldElem}, b::Ref{QQFieldElem}, a.parent::Ref{AbsSimpleNumField})::Cint return Bool(b) end function ==(a::AbsSimpleNumFieldElem, b::Int) - b = ccall((:nf_elem_equal_si, libflint), Cint, - (Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), - a, b, a.parent) + b = @ccall libflint.nf_elem_equal_si(a::Ref{AbsSimpleNumFieldElem}, b::Int, a.parent::Ref{AbsSimpleNumField})::Cint return Bool(b) end function ==(a::AbsSimpleNumFieldElem, b::UInt) - b = ccall((:nf_elem_equal_ui, libflint), Cint, - (Ref{AbsSimpleNumFieldElem}, UInt, Ref{AbsSimpleNumField}), - a, b, a.parent) + b = @ccall libflint.nf_elem_equal_ui(a::Ref{AbsSimpleNumFieldElem}, b::UInt, a.parent::Ref{AbsSimpleNumField})::Cint return Bool(b) end @@ -548,9 +493,7 @@ Return $a^{-1}$. Requires $a \neq 0$. function inv(a::AbsSimpleNumFieldElem) iszero(a) && throw(DivideError()) r = a.parent() - ccall((:nf_elem_inv, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - r, a, a.parent) + @ccall libflint.nf_elem_inv(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end @@ -565,9 +508,7 @@ function divexact(a::AbsSimpleNumFieldElem, b::AbsSimpleNumFieldElem; check::Boo parent(a) == parent(b) || return force_op(divexact, a, b)::AbsSimpleNumFieldElem check_parent(a, b) r = a.parent() - ccall((:nf_elem_div, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_div(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end @@ -580,18 +521,14 @@ end function divexact(a::AbsSimpleNumFieldElem, b::Int; check::Bool=true) b == 0 && throw(DivideError()) r = a.parent() - ccall((:nf_elem_scalar_div_si, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_scalar_div_si(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Int, a.parent::Ref{AbsSimpleNumField})::Nothing return r end function divexact(a::AbsSimpleNumFieldElem, b::ZZRingElem; check::Bool=true) iszero(b) && throw(DivideError()) r = a.parent() - ccall((:nf_elem_scalar_div_fmpz, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_scalar_div_fmpz(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{ZZRingElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end @@ -600,9 +537,7 @@ divexact(a::AbsSimpleNumFieldElem, b::Integer; check::Bool=true) = divexact(a, f function divexact(a::AbsSimpleNumFieldElem, b::QQFieldElem; check::Bool=true) iszero(b) && throw(DivideError()) r = a.parent() - ccall((:nf_elem_scalar_div_fmpq, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{QQFieldElem}, Ref{AbsSimpleNumField}), - r, a, b, a.parent) + @ccall libflint.nf_elem_scalar_div_fmpq(r::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{QQFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return r end @@ -663,9 +598,7 @@ Return the absolute norm of $a$. The result will be a rational number. """ function norm(a::AbsSimpleNumFieldElem) z = QQFieldElem() - ccall((:nf_elem_norm, libflint), Nothing, - (Ref{QQFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - z, a, a.parent) + @ccall libflint.nf_elem_norm(z::Ref{QQFieldElem}, a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return z end @@ -676,9 +609,7 @@ Return the absolute trace of $a$. The result will be a rational number. """ function tr(a::AbsSimpleNumFieldElem) z = QQFieldElem() - ccall((:nf_elem_trace, libflint), Nothing, - (Ref{QQFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - z, a, a.parent) + @ccall libflint.nf_elem_trace(z::Ref{QQFieldElem}, a::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return z end @@ -692,8 +623,7 @@ The matrix is of type QQMatrix. function representation_matrix(a::AbsSimpleNumFieldElem) K = parent(a) z = QQMatrix(degree(K), degree(K)) - ccall((:nf_elem_rep_mat, libflint), Nothing, - (Ref{QQMatrix}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), z, a, K) + @ccall libflint.nf_elem_rep_mat(z::Ref{QQMatrix}, a::Ref{AbsSimpleNumFieldElem}, K::Ref{AbsSimpleNumField})::Nothing return z end @@ -709,9 +639,7 @@ function representation_matrix_q(a::AbsSimpleNumFieldElem) K = parent(a) z = ZZMatrix(degree(K), degree(K)) d = ZZRingElem() - ccall((:nf_elem_rep_mat_fmpz_mat_den, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZRingElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - z, d, a, K) + @ccall libflint.nf_elem_rep_mat_fmpz_mat_den(z::Ref{ZZMatrix}, d::Ref{ZZRingElem}, a::Ref{AbsSimpleNumFieldElem}, K::Ref{AbsSimpleNumField})::Nothing return z, d end @@ -722,27 +650,22 @@ end ############################################################################### function zero!(a::AbsSimpleNumFieldElem) - ccall((:nf_elem_zero, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), a, parent(a)) + @ccall libflint.nf_elem_zero(a::Ref{AbsSimpleNumFieldElem}, parent(a)::Ref{AbsSimpleNumField})::Nothing return a end function one!(a::AbsSimpleNumFieldElem) - ccall((:nf_elem_one, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), a, parent(a)) + @ccall libflint.nf_elem_one(a::Ref{AbsSimpleNumFieldElem}, parent(a)::Ref{AbsSimpleNumField})::Nothing return a end function neg!(z::AbsSimpleNumFieldElem, a::AbsSimpleNumFieldElem) - ccall((:nf_elem_neg, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), z, a, parent(a)) + @ccall libflint.nf_elem_neg(z::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, parent(a)::Ref{AbsSimpleNumField})::Nothing return z end function mul!(z::AbsSimpleNumFieldElem, x::AbsSimpleNumFieldElem, y::AbsSimpleNumFieldElem) - ccall((:nf_elem_mul, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - z, x, y, parent(x)) + @ccall libflint.nf_elem_mul(z::Ref{AbsSimpleNumFieldElem}, x::Ref{AbsSimpleNumFieldElem}, y::Ref{AbsSimpleNumFieldElem}, parent(x)::Ref{AbsSimpleNumField})::Nothing return z end @@ -756,16 +679,12 @@ for performance reasons as it saves allocating a new object for the result and eliminates associated garbage collection. """ function mul_red!(z::AbsSimpleNumFieldElem, x::AbsSimpleNumFieldElem, y::AbsSimpleNumFieldElem, red::Bool) - ccall((:nf_elem_mul_red, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}, Cint), - z, x, y, parent(x), red) + @ccall libflint.nf_elem_mul_red(z::Ref{AbsSimpleNumFieldElem}, x::Ref{AbsSimpleNumFieldElem}, y::Ref{AbsSimpleNumFieldElem}, parent(x)::Ref{AbsSimpleNumField}, red::Cint)::Nothing return z end function add!(a::AbsSimpleNumFieldElem, b::AbsSimpleNumFieldElem, c::AbsSimpleNumFieldElem) - ccall((:nf_elem_add, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - a, b, c, a.parent) + @ccall libflint.nf_elem_add(a::Ref{AbsSimpleNumFieldElem}, b::Ref{AbsSimpleNumFieldElem}, c::Ref{AbsSimpleNumFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return a end @@ -778,8 +697,7 @@ where reduction has not been performed. All standard Nemo number field functions automatically reduce their outputs. """ function reduce!(x::AbsSimpleNumFieldElem) - ccall((:nf_elem_reduce, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), x, parent(x)) + @ccall libflint.nf_elem_reduce(x::Ref{AbsSimpleNumFieldElem}, parent(x)::Ref{AbsSimpleNumField})::Nothing return x end @@ -790,92 +708,68 @@ end ############################################################################### function add!(c::AbsSimpleNumFieldElem, a::AbsSimpleNumFieldElem, b::QQFieldElem) - ccall((:nf_elem_add_fmpq, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{QQFieldElem}, Ref{AbsSimpleNumField}), - c, a, b, a.parent) + @ccall libflint.nf_elem_add_fmpq(c::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{QQFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return c end function add!(c::AbsSimpleNumFieldElem, a::AbsSimpleNumFieldElem, b::ZZRingElem) - ccall((:nf_elem_add_fmpz, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - c, a, b, a.parent) + @ccall libflint.nf_elem_add_fmpz(c::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{ZZRingElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return c end function add!(c::AbsSimpleNumFieldElem, a::AbsSimpleNumFieldElem, b::Int) - ccall((:nf_elem_add_si, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), - c, a, b, a.parent) + @ccall libflint.nf_elem_add_si(c::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Int, a.parent::Ref{AbsSimpleNumField})::Nothing return c end add!(c::AbsSimpleNumFieldElem, a::AbsSimpleNumFieldElem, b::Integer) = add!(c, a, flintify(b)) function sub!(c::AbsSimpleNumFieldElem, a::AbsSimpleNumFieldElem, b::QQFieldElem) - ccall((:nf_elem_sub_fmpq, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{QQFieldElem}, Ref{AbsSimpleNumField}), - c, a, b, a.parent) + @ccall libflint.nf_elem_sub_fmpq(c::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{QQFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return c end function sub!(c::AbsSimpleNumFieldElem, a::AbsSimpleNumFieldElem, b::ZZRingElem) - ccall((:nf_elem_sub_fmpz, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - c, a, b, a.parent) + @ccall libflint.nf_elem_sub_fmpz(c::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{ZZRingElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return c end function sub!(c::AbsSimpleNumFieldElem, a::AbsSimpleNumFieldElem, b::Int) - ccall((:nf_elem_sub_si, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), - c, a, b, a.parent) + @ccall libflint.nf_elem_sub_si(c::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Int, a.parent::Ref{AbsSimpleNumField})::Nothing return c end sub!(c::AbsSimpleNumFieldElem, a::AbsSimpleNumFieldElem, b::Integer) = sub!(c, a, flintify(b)) function sub!(c::AbsSimpleNumFieldElem, a::QQFieldElem, b::AbsSimpleNumFieldElem) - ccall((:nf_elem_fmpq_sub, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{QQFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - c, a, b, parent(b)) + @ccall libflint.nf_elem_fmpq_sub(c::Ref{AbsSimpleNumFieldElem}, a::Ref{QQFieldElem}, b::Ref{AbsSimpleNumFieldElem}, parent(b)::Ref{AbsSimpleNumField})::Nothing return c end function sub!(c::AbsSimpleNumFieldElem, a::ZZRingElem, b::AbsSimpleNumFieldElem) - ccall((:nf_elem_fmpz_sub, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - c, a, b, parent(b)) + @ccall libflint.nf_elem_fmpz_sub(c::Ref{AbsSimpleNumFieldElem}, a::Ref{ZZRingElem}, b::Ref{AbsSimpleNumFieldElem}, parent(b)::Ref{AbsSimpleNumField})::Nothing return c end function sub!(c::AbsSimpleNumFieldElem, a::Int, b::AbsSimpleNumFieldElem) - ccall((:nf_elem_si_sub, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), - c, a, b, b.parent) + @ccall libflint.nf_elem_si_sub(c::Ref{AbsSimpleNumFieldElem}, a::Int, b::Ref{AbsSimpleNumFieldElem}, b.parent::Ref{AbsSimpleNumField})::Nothing return c end sub!(c::AbsSimpleNumFieldElem, a::Integer, b::AbsSimpleNumFieldElem) = sub!(c, flintify(a), b) function mul!(c::AbsSimpleNumFieldElem, a::AbsSimpleNumFieldElem, b::QQFieldElem) - ccall((:nf_elem_scalar_mul_fmpq, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{QQFieldElem}, Ref{AbsSimpleNumField}), - c, a, b, a.parent) + @ccall libflint.nf_elem_scalar_mul_fmpq(c::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{QQFieldElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return c end function mul!(c::AbsSimpleNumFieldElem, a::AbsSimpleNumFieldElem, b::ZZRingElem) - ccall((:nf_elem_scalar_mul_fmpz, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - c, a, b, a.parent) + @ccall libflint.nf_elem_scalar_mul_fmpz(c::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{ZZRingElem}, a.parent::Ref{AbsSimpleNumField})::Nothing return c end function mul!(c::AbsSimpleNumFieldElem, a::AbsSimpleNumFieldElem, b::Int) - ccall((:nf_elem_scalar_mul_si, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), - c, a, b, a.parent) + @ccall libflint.nf_elem_scalar_mul_si(c::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Int, a.parent::Ref{AbsSimpleNumField})::Nothing return c end @@ -1069,8 +963,7 @@ Return an empty (0) element. """ function (a::AbsSimpleNumField)() z = AbsSimpleNumFieldElem(a) - ccall((:nf_elem_set_si, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), z, 0, a) + @ccall libflint.nf_elem_set_si(z::Ref{AbsSimpleNumFieldElem}, 0::Int, a::Ref{AbsSimpleNumField})::Nothing return z end @@ -1081,8 +974,7 @@ Return $c$ as an element in $a$. """ function (a::AbsSimpleNumField)(c::Int) z = AbsSimpleNumFieldElem(a) - ccall((:nf_elem_set_si, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Int, Ref{AbsSimpleNumField}), z, c, a) + @ccall libflint.nf_elem_set_si(z::Ref{AbsSimpleNumFieldElem}, c::Int, a::Ref{AbsSimpleNumField})::Nothing return z end @@ -1090,15 +982,13 @@ end function (a::AbsSimpleNumField)(c::ZZRingElem) z = AbsSimpleNumFieldElem(a) - ccall((:nf_elem_set_fmpz, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), z, c, a) + @ccall libflint.nf_elem_set_fmpz(z::Ref{AbsSimpleNumFieldElem}, c::Ref{ZZRingElem}, a::Ref{AbsSimpleNumField})::Nothing return z end function (a::AbsSimpleNumField)(c::QQFieldElem) z = AbsSimpleNumFieldElem(a) - ccall((:nf_elem_set_fmpq, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{QQFieldElem}, Ref{AbsSimpleNumField}), z, c, a) + @ccall libflint.nf_elem_set_fmpq(z::Ref{AbsSimpleNumFieldElem}, c::Ref{QQFieldElem}, a::Ref{AbsSimpleNumField})::Nothing return z end @@ -1115,16 +1005,14 @@ function (a::AbsSimpleNumField)(pol::QQPolyRingElem) if length(pol) >= length(a.pol) pol = mod(pol, a.pol) end - ccall((:nf_elem_set_fmpq_poly, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{QQPolyRingElem}, Ref{AbsSimpleNumField}), z, pol, a) + @ccall libflint.nf_elem_set_fmpq_poly(z::Ref{AbsSimpleNumFieldElem}, pol::Ref{QQPolyRingElem}, a::Ref{AbsSimpleNumField})::Nothing return z end function (a::QQPolyRing)(b::AbsSimpleNumFieldElem) parent(parent(b).pol) != a && error("Cannot coerce from number field to polynomial ring") r = a() - ccall((:nf_elem_get_fmpq_poly, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), r, b, parent(b)) + @ccall libflint.nf_elem_get_fmpq_poly(r::Ref{QQPolyRingElem}, b::Ref{AbsSimpleNumFieldElem}, parent(b)::Ref{AbsSimpleNumField})::Nothing return r end @@ -1348,9 +1236,7 @@ end function Base.:(^)(a::AbsSimpleNumFieldElem, e::UInt) b = parent(a)() - ccall((:nf_elem_pow, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, UInt, Ref{AbsSimpleNumField}), - b, a, e, parent(a)) + @ccall libflint.nf_elem_pow(b::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, e::UInt, parent(a)::Ref{AbsSimpleNumField})::Nothing return b end @@ -1376,9 +1262,7 @@ base_field(::AbsSimpleNumField) = QQ ############################################################################### function mod_sym!(a::AbsSimpleNumFieldElem, b::ZZRingElem) - ccall((:nf_elem_smod_fmpz, libflint), Nothing, - (Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}), - a, a, b, parent(a)) + @ccall libflint.nf_elem_smod_fmpz(a::Ref{AbsSimpleNumFieldElem}, a::Ref{AbsSimpleNumFieldElem}, b::Ref{ZZRingElem}, parent(a)::Ref{AbsSimpleNumField})::Nothing return a end diff --git a/src/arb/ArbTypes.jl b/src/arb/ArbTypes.jl index 47b23490d..c19d38f51 100644 --- a/src/arb/ArbTypes.jl +++ b/src/arb/ArbTypes.jl @@ -35,14 +35,14 @@ mutable struct arf_struct function arf_struct() z = new() - ccall((:arf_init, libflint), Nothing, (Ref{arf_struct}, ), z) + @ccall libflint.arf_init(z::Ref{arf_struct})::Nothing finalizer(_arf_clear_fn, z) return z end end function _arf_clear_fn(x::arf_struct) - ccall((:arf_clear, libflint), Nothing, (Ref{arf_struct}, ), x) + @ccall libflint.arf_clear(x::Ref{arf_struct})::Nothing end mutable struct mag_struct @@ -104,7 +104,7 @@ mutable struct RealFieldElem <: FieldElem function RealFieldElem() z = new() - ccall((:arb_init, libflint), Nothing, (Ref{RealFieldElem}, ), z) + @ccall libflint.arb_init(z::Ref{RealFieldElem})::Nothing finalizer(_arb_clear_fn, z) return z end @@ -124,14 +124,14 @@ mutable struct RealFieldElem <: FieldElem function RealFieldElem(mid::RealFieldElem, rad::RealFieldElem) z = RealFieldElem() _arb_set(z, mid) - ccall((:arb_add_error, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}), z, rad) + @ccall libflint.arb_add_error(z::Ref{RealFieldElem}, rad::Ref{RealFieldElem})::Nothing return z end end function _arb_clear_fn(x::RealFieldElem) - ccall((:arb_clear, libflint), Nothing, (Ref{RealFieldElem}, ), x) + @ccall libflint.arb_clear(x::Ref{RealFieldElem})::Nothing end # fixed precision @@ -162,7 +162,7 @@ mutable struct ArbFieldElem <: FieldElem function ArbFieldElem() z = new() - ccall((:arb_init, libflint), Nothing, (Ref{ArbFieldElem}, ), z) + @ccall libflint.arb_init(z::Ref{ArbFieldElem})::Nothing finalizer(_arb_clear_fn, z) return z end @@ -182,19 +182,19 @@ mutable struct ArbFieldElem <: FieldElem function ArbFieldElem(mid::ArbFieldElem, rad::ArbFieldElem) z = ArbFieldElem() _arb_set(z, mid) - ccall((:arb_add_error, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), z, rad) + @ccall libflint.arb_add_error(z::Ref{ArbFieldElem}, rad::Ref{ArbFieldElem})::Nothing return z end #function ArbFieldElem(x::arf) # z = ArbFieldElem() - # ccall((:arb_set_arf, libflint), Nothing, (Ref{ArbFieldElem}, Ptr{arf}), z, x) + # @ccall libflint.arb_set_arf(z::Ref{ArbFieldElem}, x::Ptr{arf})::Nothing # return z #end end function _arb_clear_fn(x::ArbFieldElem) - ccall((:arb_clear, libflint), Nothing, (Ref{ArbFieldElem}, ), x) + @ccall libflint.arb_clear(x::Ref{ArbFieldElem})::Nothing end @@ -223,7 +223,7 @@ mutable struct ComplexFieldElem <: FieldElem function ComplexFieldElem() z = new() - ccall((:acb_init, libflint), Nothing, (Ref{ComplexFieldElem}, ), z) + @ccall libflint.acb_init(z::Ref{ComplexFieldElem})::Nothing finalizer(_acb_clear_fn, z) return z end @@ -248,7 +248,7 @@ mutable struct ComplexFieldElem <: FieldElem end function _acb_clear_fn(x::ComplexFieldElem) - ccall((:acb_clear, libflint), Nothing, (Ref{ComplexFieldElem}, ), x) + @ccall libflint.acb_clear(x::Ref{ComplexFieldElem})::Nothing end ################################################################################ @@ -374,7 +374,7 @@ mutable struct AcbFieldElem <: FieldElem function AcbFieldElem() z = new() - ccall((:acb_init, libflint), Nothing, (Ref{AcbFieldElem}, ), z) + @ccall libflint.acb_init(z::Ref{AcbFieldElem})::Nothing finalizer(_acb_clear_fn, z) return z end @@ -405,7 +405,7 @@ mutable struct AcbFieldElem <: FieldElem end function _acb_clear_fn(x::AcbFieldElem) - ccall((:acb_clear, libflint), Nothing, (Ref{AcbFieldElem}, ), x) + @ccall libflint.acb_clear(x::Ref{AcbFieldElem})::Nothing end ################################################################################ @@ -428,8 +428,7 @@ mutable struct acb_calc_integrate_opts function acb_calc_integrate_opts() opts = new() - ccall((:acb_calc_integrate_opt_init, libflint), - Nothing, (Ref{acb_calc_integrate_opts}, ), opts) + @ccall libflint.acb_calc_integrate_opt_init(opts::Ref{acb_calc_integrate_opts})::Nothing return opts end end @@ -460,7 +459,7 @@ mutable struct RealPolyRingElem <: PolyRingElem{RealFieldElem} function RealPolyRingElem() z = new() - ccall((:arb_poly_init, libflint), Nothing, (Ref{RealPolyRingElem}, ), z) + @ccall libflint.arb_poly_init(z::Ref{RealPolyRingElem})::Nothing finalizer(_RealPoly_clear_fn, z) return z end @@ -481,34 +480,31 @@ mutable struct RealPolyRingElem <: PolyRingElem{RealFieldElem} function RealPolyRingElem(x::RealPolyRingElem) z = RealPolyRingElem() - ccall((:arb_poly_set, libflint), Nothing, (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}), z, x) + @ccall libflint.arb_poly_set(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem})::Nothing return z end function RealPolyRingElem(x::RealPolyRingElem, p::Int) z = RealPolyRingElem() - ccall((:arb_poly_set_round, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, p) + @ccall libflint.arb_poly_set_round(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, p::Int)::Nothing return z end function RealPolyRingElem(x::ZZPolyRingElem, p::Int) z = RealPolyRingElem() - ccall((:arb_poly_set_fmpz_poly, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{ZZPolyRingElem}, Int), z, x, p) + @ccall libflint.arb_poly_set_fmpz_poly(z::Ref{RealPolyRingElem}, x::Ref{ZZPolyRingElem}, p::Int)::Nothing return z end function RealPolyRingElem(x::QQPolyRingElem, p::Int) z = RealPolyRingElem() - ccall((:arb_poly_set_fmpq_poly, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{QQPolyRingElem}, Int), z, x, p) + @ccall libflint.arb_poly_set_fmpq_poly(z::Ref{RealPolyRingElem}, x::Ref{QQPolyRingElem}, p::Int)::Nothing return z end end function _RealPoly_clear_fn(x::RealPolyRingElem) - ccall((:arb_poly_clear, libflint), Nothing, (Ref{RealPolyRingElem}, ), x) + @ccall libflint.arb_poly_clear(x::Ref{RealPolyRingElem})::Nothing end parent(x::RealPolyRingElem) = x.parent @@ -540,7 +536,7 @@ mutable struct ArbPolyRingElem <: PolyRingElem{ArbFieldElem} function ArbPolyRingElem() z = new() - ccall((:arb_poly_init, libflint), Nothing, (Ref{ArbPolyRingElem}, ), z) + @ccall libflint.arb_poly_init(z::Ref{ArbPolyRingElem})::Nothing finalizer(_arb_poly_clear_fn, z) return z end @@ -561,34 +557,31 @@ mutable struct ArbPolyRingElem <: PolyRingElem{ArbFieldElem} function ArbPolyRingElem(x::ArbPolyRingElem) z = ArbPolyRingElem() - ccall((:arb_poly_set, libflint), Nothing, (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}), z, x) + @ccall libflint.arb_poly_set(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem})::Nothing return z end function ArbPolyRingElem(x::ArbPolyRingElem, p::Int) z = ArbPolyRingElem() - ccall((:arb_poly_set_round, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Int), z, x, p) + @ccall libflint.arb_poly_set_round(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, p::Int)::Nothing return z end function ArbPolyRingElem(x::ZZPolyRingElem, p::Int) z = ArbPolyRingElem() - ccall((:arb_poly_set_fmpz_poly, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ZZPolyRingElem}, Int), z, x, p) + @ccall libflint.arb_poly_set_fmpz_poly(z::Ref{ArbPolyRingElem}, x::Ref{ZZPolyRingElem}, p::Int)::Nothing return z end function ArbPolyRingElem(x::QQPolyRingElem, p::Int) z = ArbPolyRingElem() - ccall((:arb_poly_set_fmpq_poly, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{QQPolyRingElem}, Int), z, x, p) + @ccall libflint.arb_poly_set_fmpq_poly(z::Ref{ArbPolyRingElem}, x::Ref{QQPolyRingElem}, p::Int)::Nothing return z end end function _arb_poly_clear_fn(x::ArbPolyRingElem) - ccall((:arb_poly_clear, libflint), Nothing, (Ref{ArbPolyRingElem}, ), x) + @ccall libflint.arb_poly_clear(x::Ref{ArbPolyRingElem})::Nothing end parent(x::ArbPolyRingElem) = x.parent @@ -625,7 +618,7 @@ mutable struct ComplexPolyRingElem <: PolyRingElem{ComplexFieldElem} function ComplexPolyRingElem() z = new() - ccall((:acb_poly_init, libflint), Nothing, (Ref{ComplexPolyRingElem}, ), z) + @ccall libflint.acb_poly_init(z::Ref{ComplexPolyRingElem})::Nothing finalizer(_acb_poly_clear_fn, z) return z end @@ -646,43 +639,38 @@ mutable struct ComplexPolyRingElem <: PolyRingElem{ComplexFieldElem} function ComplexPolyRingElem(x::ComplexPolyRingElem) z = ComplexPolyRingElem() - ccall((:acb_poly_set, libflint), Nothing, (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}), z, x) + @ccall libflint.acb_poly_set(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem})::Nothing return z end function ComplexPolyRingElem(x::RealPolyRingElem, p::Int) z = ComplexPolyRingElem() - ccall((:acb_poly_set_arb_poly, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ArbPolyRingElem}, Int), z, x, p) - ccall((:acb_poly_set_round, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, z, p) + @ccall libflint.acb_poly_set_arb_poly(z::Ref{ComplexPolyRingElem}, x::Ref{ArbPolyRingElem}, p::Int)::Nothing + @ccall libflint.acb_poly_set_round(z::Ref{ComplexPolyRingElem}, z::Ref{ComplexPolyRingElem}, p::Int)::Nothing return z end function ComplexPolyRingElem(x::ComplexPolyRingElem, p::Int) z = ComplexPolyRingElem() - ccall((:acb_poly_set_round, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, p) + @ccall libflint.acb_poly_set_round(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, p::Int)::Nothing return z end function ComplexPolyRingElem(x::ZZPolyRingElem, p::Int) z = ComplexPolyRingElem() - ccall((:acb_poly_set_fmpz_poly, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ZZPolyRingElem}, Int), z, x, p) + @ccall libflint.acb_poly_set_fmpz_poly(z::Ref{ComplexPolyRingElem}, x::Ref{ZZPolyRingElem}, p::Int)::Nothing return z end function ComplexPolyRingElem(x::QQPolyRingElem, p::Int) z = ComplexPolyRingElem() - ccall((:acb_poly_set_fmpq_poly, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{QQPolyRingElem}, Int), z, x, p) + @ccall libflint.acb_poly_set_fmpq_poly(z::Ref{ComplexPolyRingElem}, x::Ref{QQPolyRingElem}, p::Int)::Nothing return z end end function _acb_poly_clear_fn(x::ComplexPolyRingElem) - ccall((:acb_poly_clear, libflint), Nothing, (Ref{ComplexPolyRingElem}, ), x) + @ccall libflint.acb_poly_clear(x::Ref{ComplexPolyRingElem})::Nothing end parent(x::ComplexPolyRingElem) = x.parent @@ -714,7 +702,7 @@ mutable struct AcbPolyRingElem <: PolyRingElem{AcbFieldElem} function AcbPolyRingElem() z = new() - ccall((:acb_poly_init, libflint), Nothing, (Ref{AcbPolyRingElem}, ), z) + @ccall libflint.acb_poly_init(z::Ref{AcbPolyRingElem})::Nothing finalizer(_acb_poly_clear_fn, z) return z end @@ -735,43 +723,38 @@ mutable struct AcbPolyRingElem <: PolyRingElem{AcbFieldElem} function AcbPolyRingElem(x::AcbPolyRingElem) z = AcbPolyRingElem() - ccall((:acb_poly_set, libflint), Nothing, (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}), z, x) + @ccall libflint.acb_poly_set(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem})::Nothing return z end function AcbPolyRingElem(x::ArbPolyRingElem, p::Int) z = AcbPolyRingElem() - ccall((:acb_poly_set_arb_poly, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{ArbPolyRingElem}, Int), z, x, p) - ccall((:acb_poly_set_round, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Int), z, z, p) + @ccall libflint.acb_poly_set_arb_poly(z::Ref{AcbPolyRingElem}, x::Ref{ArbPolyRingElem}, p::Int)::Nothing + @ccall libflint.acb_poly_set_round(z::Ref{AcbPolyRingElem}, z::Ref{AcbPolyRingElem}, p::Int)::Nothing return z end function AcbPolyRingElem(x::AcbPolyRingElem, p::Int) z = AcbPolyRingElem() - ccall((:acb_poly_set_round, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Int), z, x, p) + @ccall libflint.acb_poly_set_round(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, p::Int)::Nothing return z end function AcbPolyRingElem(x::ZZPolyRingElem, p::Int) z = AcbPolyRingElem() - ccall((:acb_poly_set_fmpz_poly, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{ZZPolyRingElem}, Int), z, x, p) + @ccall libflint.acb_poly_set_fmpz_poly(z::Ref{AcbPolyRingElem}, x::Ref{ZZPolyRingElem}, p::Int)::Nothing return z end function AcbPolyRingElem(x::QQPolyRingElem, p::Int) z = AcbPolyRingElem() - ccall((:acb_poly_set_fmpq_poly, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{QQPolyRingElem}, Int), z, x, p) + @ccall libflint.acb_poly_set_fmpq_poly(z::Ref{AcbPolyRingElem}, x::Ref{QQPolyRingElem}, p::Int)::Nothing return z end end function _acb_poly_clear_fn(x::AcbPolyRingElem) - ccall((:acb_poly_clear, libflint), Nothing, (Ref{AcbPolyRingElem}, ), x) + @ccall libflint.acb_poly_clear(x::Ref{AcbPolyRingElem})::Nothing end parent(x::AcbPolyRingElem) = x.parent @@ -801,22 +784,20 @@ mutable struct RealMatrix <: MatElem{RealFieldElem} function RealMatrix(r::Int, c::Int) z = new() - ccall((:arb_mat_init, libflint), Nothing, (Ref{RealMatrix}, Int, Int), z, r, c) + @ccall libflint.arb_mat_init(z::Ref{RealMatrix}, r::Int, c::Int)::Nothing finalizer(_arb_mat_clear_fn, z) return z end function RealMatrix(a::ZZMatrix) z = RealMatrix(a.r, a.c) - ccall((:arb_mat_set_fmpz_mat, libflint), Nothing, - (Ref{RealMatrix}, Ref{ZZMatrix}), z, a) + @ccall libflint.arb_mat_set_fmpz_mat(z::Ref{RealMatrix}, a::Ref{ZZMatrix})::Nothing return z end function RealMatrix(a::ZZMatrix, prec::Int) z = RealMatrix(a.r, a.c) - ccall((:arb_mat_set_round_fmpz_mat, libflint), Nothing, - (Ref{RealMatrix}, Ref{ZZMatrix}, Int), z, a, prec) + @ccall libflint.arb_mat_set_round_fmpz_mat(z::Ref{RealMatrix}, a::Ref{ZZMatrix}, prec::Int)::Nothing return z end @@ -866,14 +847,13 @@ mutable struct RealMatrix <: MatElem{RealFieldElem} function RealMatrix(a::QQMatrix, prec::Int) z = RealMatrix(a.r, a.c) - ccall((:arb_mat_set_fmpq_mat, libflint), Nothing, - (Ref{RealMatrix}, Ref{QQMatrix}, Int), z, a, prec) + @ccall libflint.arb_mat_set_fmpq_mat(z::Ref{RealMatrix}, a::Ref{QQMatrix}, prec::Int)::Nothing return z end end function _arb_mat_clear_fn(x::RealMatrix) - ccall((:arb_mat_clear, libflint), Nothing, (Ref{RealMatrix}, ), x) + @ccall libflint.arb_mat_clear(x::Ref{RealMatrix})::Nothing end # fixed precision @@ -889,22 +869,20 @@ mutable struct ArbMatrix <: MatElem{ArbFieldElem} function ArbMatrix(r::Int, c::Int) z = new() - ccall((:arb_mat_init, libflint), Nothing, (Ref{ArbMatrix}, Int, Int), z, r, c) + @ccall libflint.arb_mat_init(z::Ref{ArbMatrix}, r::Int, c::Int)::Nothing finalizer(_arb_mat_clear_fn, z) return z end function ArbMatrix(a::ZZMatrix) z = ArbMatrix(a.r, a.c) - ccall((:arb_mat_set_fmpz_mat, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ZZMatrix}), z, a) + @ccall libflint.arb_mat_set_fmpz_mat(z::Ref{ArbMatrix}, a::Ref{ZZMatrix})::Nothing return z end function ArbMatrix(a::ZZMatrix, prec::Int) z = ArbMatrix(a.r, a.c) - ccall((:arb_mat_set_round_fmpz_mat, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ZZMatrix}, Int), z, a, prec) + @ccall libflint.arb_mat_set_round_fmpz_mat(z::Ref{ArbMatrix}, a::Ref{ZZMatrix}, prec::Int)::Nothing return z end @@ -954,14 +932,13 @@ mutable struct ArbMatrix <: MatElem{ArbFieldElem} function ArbMatrix(a::QQMatrix, prec::Int) z = ArbMatrix(a.r, a.c) - ccall((:arb_mat_set_fmpq_mat, libflint), Nothing, - (Ref{ArbMatrix}, Ref{QQMatrix}, Int), z, a, prec) + @ccall libflint.arb_mat_set_fmpq_mat(z::Ref{ArbMatrix}, a::Ref{QQMatrix}, prec::Int)::Nothing return z end end function _arb_mat_clear_fn(x::ArbMatrix) - ccall((:arb_mat_clear, libflint), Nothing, (Ref{ArbMatrix}, ), x) + @ccall libflint.arb_mat_clear(x::Ref{ArbMatrix})::Nothing end ################################################################################ @@ -981,36 +958,32 @@ mutable struct ComplexMatrix <: MatElem{ComplexFieldElem} function ComplexMatrix(r::Int, c::Int) z = new() - ccall((:acb_mat_init, libflint), Nothing, (Ref{ComplexMatrix}, Int, Int), z, r, c) + @ccall libflint.acb_mat_init(z::Ref{ComplexMatrix}, r::Int, c::Int)::Nothing finalizer(_acb_mat_clear_fn, z) return z end function ComplexMatrix(a::ZZMatrix) z = ComplexMatrix(a.r, a.c) - ccall((:acb_mat_set_fmpz_mat, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ZZMatrix}), z, a) + @ccall libflint.acb_mat_set_fmpz_mat(z::Ref{ComplexMatrix}, a::Ref{ZZMatrix})::Nothing return z end function ComplexMatrix(a::ZZMatrix, prec::Int) z = ComplexMatrix(a.r, a.c) - ccall((:acb_mat_set_round_fmpz_mat, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ZZMatrix}, Int), z, a, prec) + @ccall libflint.acb_mat_set_round_fmpz_mat(z::Ref{ComplexMatrix}, a::Ref{ZZMatrix}, prec::Int)::Nothing return z end function ComplexMatrix(a::RealMatrix) z = ComplexMatrix(a.r, a.c) - ccall((:acb_mat_set_arb_mat, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ArbMatrix}), z, a) + @ccall libflint.acb_mat_set_arb_mat(z::Ref{ComplexMatrix}, a::Ref{ArbMatrix})::Nothing return z end function ComplexMatrix(a::ArbMatrix, prec::Int) z = ComplexMatrix(a.r, a.c) - ccall((:acb_mat_set_round_arb_mat, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ArbMatrix}, Int), z, a, prec) + @ccall libflint.acb_mat_set_round_arb_mat(z::Ref{ComplexMatrix}, a::Ref{ArbMatrix}, prec::Int)::Nothing return z end @@ -1148,14 +1121,13 @@ mutable struct ComplexMatrix <: MatElem{ComplexFieldElem} function ComplexMatrix(a::QQMatrix, prec::Int) z = ComplexMatrix(a.r, a.c) - ccall((:acb_mat_set_fmpq_mat, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{QQMatrix}, Int), z, a, prec) + @ccall libflint.acb_mat_set_fmpq_mat(z::Ref{ComplexMatrix}, a::Ref{QQMatrix}, prec::Int)::Nothing return z end end function _acb_mat_clear_fn(x::ComplexMatrix) - ccall((:acb_mat_clear, libflint), Nothing, (Ref{ComplexMatrix}, ), x) + @ccall libflint.acb_mat_clear(x::Ref{ComplexMatrix})::Nothing end # fixed precision @@ -1171,36 +1143,32 @@ mutable struct AcbMatrix <: MatElem{AcbFieldElem} function AcbMatrix(r::Int, c::Int) z = new() - ccall((:acb_mat_init, libflint), Nothing, (Ref{AcbMatrix}, Int, Int), z, r, c) + @ccall libflint.acb_mat_init(z::Ref{AcbMatrix}, r::Int, c::Int)::Nothing finalizer(_acb_mat_clear_fn, z) return z end function AcbMatrix(a::ZZMatrix) z = AcbMatrix(a.r, a.c) - ccall((:acb_mat_set_fmpz_mat, libflint), Nothing, - (Ref{AcbMatrix}, Ref{ZZMatrix}), z, a) + @ccall libflint.acb_mat_set_fmpz_mat(z::Ref{AcbMatrix}, a::Ref{ZZMatrix})::Nothing return z end function AcbMatrix(a::ZZMatrix, prec::Int) z = AcbMatrix(a.r, a.c) - ccall((:acb_mat_set_round_fmpz_mat, libflint), Nothing, - (Ref{AcbMatrix}, Ref{ZZMatrix}, Int), z, a, prec) + @ccall libflint.acb_mat_set_round_fmpz_mat(z::Ref{AcbMatrix}, a::Ref{ZZMatrix}, prec::Int)::Nothing return z end function AcbMatrix(a::ArbMatrix) z = AcbMatrix(a.r, a.c) - ccall((:acb_mat_set_arb_mat, libflint), Nothing, - (Ref{AcbMatrix}, Ref{ArbMatrix}), z, a) + @ccall libflint.acb_mat_set_arb_mat(z::Ref{AcbMatrix}, a::Ref{ArbMatrix})::Nothing return z end function AcbMatrix(a::ArbMatrix, prec::Int) z = AcbMatrix(a.r, a.c) - ccall((:acb_mat_set_round_arb_mat, libflint), Nothing, - (Ref{AcbMatrix}, Ref{ArbMatrix}, Int), z, a, prec) + @ccall libflint.acb_mat_set_round_arb_mat(z::Ref{AcbMatrix}, a::Ref{ArbMatrix}, prec::Int)::Nothing return z end @@ -1338,14 +1306,13 @@ mutable struct AcbMatrix <: MatElem{AcbFieldElem} function AcbMatrix(a::QQMatrix, prec::Int) z = AcbMatrix(a.r, a.c) - ccall((:acb_mat_set_fmpq_mat, libflint), Nothing, - (Ref{AcbMatrix}, Ref{QQMatrix}, Int), z, a, prec) + @ccall libflint.acb_mat_set_fmpq_mat(z::Ref{AcbMatrix}, a::Ref{QQMatrix}, prec::Int)::Nothing return z end end function _acb_mat_clear_fn(x::AcbMatrix) - ccall((:acb_mat_clear, libflint), Nothing, (Ref{AcbMatrix}, ), x) + @ccall libflint.acb_mat_clear(x::Ref{AcbMatrix})::Nothing end diff --git a/src/arb/Complex.jl b/src/arb/Complex.jl index d7de364b7..cf3bd5d71 100644 --- a/src/arb/Complex.jl +++ b/src/arb/Complex.jl @@ -50,7 +50,7 @@ Return the relative accuracy of $x$ measured in bits, capped between """ function accuracy_bits(x::ComplexFieldElem) # bug in acb.h: rel_accuracy_bits is not in the library - return -ccall((:acb_rel_error_bits, libflint), Int, (Ref{ComplexFieldElem},), x) + return -@ccall libflint.acb_rel_error_bits(x::Ref{ComplexFieldElem})::Int end function deepcopy_internal(a::ComplexFieldElem, dict::IdDict) @@ -80,8 +80,8 @@ function convert(::Type{ComplexF64}, x::ComplexFieldElem) t = _mid_ptr(re) u = _mid_ptr(im) # 4 == round to nearest - v = ccall((:arf_get_d, libflint), Float64, (Ptr{arf_struct}, Int), t, 4) - w = ccall((:arf_get_d, libflint), Float64, (Ptr{arf_struct}, Int), u, 4) + v = @ccall libflint.arf_get_d(t::Ptr{arf_struct}, 4::Int)::Float64 + w = @ccall libflint.arf_get_d(u::Ptr{arf_struct}, 4::Int)::Float64 end return complex(v, w) end @@ -94,13 +94,13 @@ end function real(x::ComplexFieldElem) z = RealFieldElem() - ccall((:acb_get_real, libflint), Nothing, (Ref{RealFieldElem}, Ref{ComplexFieldElem}), z, x) + @ccall libflint.acb_get_real(z::Ref{RealFieldElem}, x::Ref{ComplexFieldElem})::Nothing return z end function imag(x::ComplexFieldElem) z = RealFieldElem() - ccall((:acb_get_imag, libflint), Nothing, (Ref{RealFieldElem}, Ref{ComplexFieldElem}), z, x) + @ccall libflint.acb_get_imag(z::Ref{RealFieldElem}, x::Ref{ComplexFieldElem})::Nothing return z end @@ -227,25 +227,25 @@ end function -(x::UInt, y::ComplexFieldElem) z = ComplexFieldElem() - ccall((:acb_sub_ui, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, UInt, Int), z, y, x, precision(Balls)) + @ccall libflint.acb_sub_ui(z::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem}, x::UInt, precision(Balls)::Int)::Nothing return neg!(z) end function -(x::Int, y::ComplexFieldElem) z = ComplexFieldElem() - ccall((:acb_sub_si, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int, Int), z, y, x, precision(Balls)) + @ccall libflint.acb_sub_si(z::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem}, x::Int, precision(Balls)::Int)::Nothing return neg!(z) end function -(x::ZZRingElem, y::ComplexFieldElem) z = ComplexFieldElem() - ccall((:acb_sub_fmpz, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ZZRingElem}, Int), z, y, x, precision(Balls)) + @ccall libflint.acb_sub_fmpz(z::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem}, x::Ref{ZZRingElem}, precision(Balls)::Int)::Nothing return neg!(z) end function -(x::RealFieldElem, y::ComplexFieldElem) z = ComplexFieldElem() - ccall((:acb_sub_arb, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{RealFieldElem}, Int), z, y, x, precision(Balls)) + @ccall libflint.acb_sub_arb(z::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem}, x::Ref{RealFieldElem}, precision(Balls)::Int)::Nothing return neg!(z) end @@ -314,17 +314,17 @@ Return `true` if the boxes $x$ and $y$ are precisely equal, i.e. their real and imaginary parts have the same midpoints and radii. """ function isequal(x::ComplexFieldElem, y::ComplexFieldElem) - r = ccall((:acb_equal, libflint), Cint, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}), x, y) + r = @ccall libflint.acb_equal(x::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem})::Cint return Bool(r) end function ==(x::ComplexFieldElem, y::ComplexFieldElem) - r = ccall((:acb_eq, libflint), Cint, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}), x, y) + r = @ccall libflint.acb_eq(x::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem})::Cint return Bool(r) end function !=(x::ComplexFieldElem, y::ComplexFieldElem) - r = ccall((:acb_ne, libflint), Cint, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}), x, y) + r = @ccall libflint.acb_ne(x::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem})::Cint return Bool(r) end @@ -368,7 +368,7 @@ Returns `true` if any part of the box $x$ overlaps any part of the box $y$, otherwise return `false`. """ function overlaps(x::ComplexFieldElem, y::ComplexFieldElem) - r = ccall((:acb_overlaps, libflint), Cint, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}), x, y) + r = @ccall libflint.acb_overlaps(x::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem})::Cint return Bool(r) end @@ -379,7 +379,7 @@ Returns `true` if the box $x$ contains the box $y$, otherwise return `false`. """ function contains(x::ComplexFieldElem, y::ComplexFieldElem) - r = ccall((:acb_contains, libflint), Cint, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}), x, y) + r = @ccall libflint.acb_contains(x::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem})::Cint return Bool(r) end @@ -390,7 +390,7 @@ Returns `true` if the box $x$ contains the given rational value, otherwise return `false`. """ function contains(x::ComplexFieldElem, y::QQFieldElem) - r = ccall((:acb_contains_fmpq, libflint), Cint, (Ref{ComplexFieldElem}, Ref{QQFieldElem}), x, y) + r = @ccall libflint.acb_contains_fmpq(x::Ref{ComplexFieldElem}, y::Ref{QQFieldElem})::Cint return Bool(r) end @@ -401,13 +401,13 @@ Returns `true` if the box $x$ contains the given integer value, otherwise return `false`. """ function contains(x::ComplexFieldElem, y::ZZRingElem) - r = ccall((:acb_contains_fmpz, libflint), Cint, (Ref{ComplexFieldElem}, Ref{ZZRingElem}), x, y) + r = @ccall libflint.acb_contains_fmpz(x::Ref{ComplexFieldElem}, y::Ref{ZZRingElem})::Cint return Bool(r) end function contains(x::ComplexFieldElem, y::Int) v = ZZRingElem(y) - r = ccall((:acb_contains_fmpz, libflint), Cint, (Ref{ComplexFieldElem}, Ref{ZZRingElem}), x, v) + r = @ccall libflint.acb_contains_fmpz(x::Ref{ComplexFieldElem}, v::Ref{ZZRingElem})::Cint return Bool(r) end @@ -433,7 +433,7 @@ contains(x::ComplexFieldElem, y::Rational{T}) where {T <: Integer} = contains(x, Returns `true` if the box $x$ contains zero, otherwise return `false`. """ function contains_zero(x::ComplexFieldElem) - return Bool(ccall((:acb_contains_zero, libflint), Cint, (Ref{ComplexFieldElem},), x)) + return Bool(@ccall libflint.acb_contains_zero(x::Ref{ComplexFieldElem})::Cint) end ################################################################################ @@ -452,7 +452,7 @@ end Return `true` if $x$ is certainly zero, otherwise return `false`. """ function iszero(x::ComplexFieldElem) - return Bool(ccall((:acb_is_zero, libflint), Cint, (Ref{ComplexFieldElem},), x)) + return Bool(@ccall libflint.acb_is_zero(x::Ref{ComplexFieldElem})::Cint) end @doc raw""" @@ -461,7 +461,7 @@ end Return `true` if $x$ is certainly one, otherwise return `false`. """ function isone(x::ComplexFieldElem) - return Bool(ccall((:acb_is_one, libflint), Cint, (Ref{ComplexFieldElem},), x)) + return Bool(@ccall libflint.acb_is_one(x::Ref{ComplexFieldElem})::Cint) end @doc raw""" @@ -471,7 +471,7 @@ Return `true` if $x$ is finite, i.e. its real and imaginary parts have finite midpoint and radius, otherwise return `false`. """ function isfinite(x::ComplexFieldElem) - return Bool(ccall((:acb_is_finite, libflint), Cint, (Ref{ComplexFieldElem},), x)) + return Bool(@ccall libflint.acb_is_finite(x::Ref{ComplexFieldElem})::Cint) end @doc raw""" @@ -481,7 +481,7 @@ Return `true` if $x$ is exact, i.e. has its real and imaginary parts have zero radius, otherwise return `false`. """ function is_exact(x::ComplexFieldElem) - return Bool(ccall((:acb_is_exact, libflint), Cint, (Ref{ComplexFieldElem},), x)) + return Bool(@ccall libflint.acb_is_exact(x::Ref{ComplexFieldElem})::Cint) end @doc raw""" @@ -490,11 +490,11 @@ end Return `true` if $x$ is an exact integer, otherwise return `false`. """ function isinteger(x::ComplexFieldElem) - return Bool(ccall((:acb_is_int, libflint), Cint, (Ref{ComplexFieldElem},), x)) + return Bool(@ccall libflint.acb_is_int(x::Ref{ComplexFieldElem})::Cint) end function isreal(x::ComplexFieldElem) - return Bool(ccall((:acb_is_real, libflint), Cint, (Ref{ComplexFieldElem},), x)) + return Bool(@ccall libflint.acb_is_real(x::Ref{ComplexFieldElem})::Cint) end is_negative(x::ComplexFieldElem) = isreal(x) && is_negative(real(x)) @@ -507,8 +507,7 @@ is_negative(x::ComplexFieldElem) = isreal(x) && is_negative(real(x)) function abs(x::ComplexFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:acb_abs, libflint), Nothing, - (Ref{RealFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_abs(z::Ref{RealFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -520,7 +519,7 @@ end function inv(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_inv, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_inv(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -532,15 +531,13 @@ end function ldexp(x::ComplexFieldElem, y::Int) z = ComplexFieldElem() - ccall((:acb_mul_2exp_si, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, y) + @ccall libflint.acb_mul_2exp_si(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, y::Int)::Nothing return z end function ldexp(x::ComplexFieldElem, y::ZZRingElem) z = ComplexFieldElem() - ccall((:acb_mul_2exp_fmpz, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.acb_mul_2exp_fmpz(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, y::Ref{ZZRingElem})::Nothing return z end @@ -558,7 +555,7 @@ by rounding off insignificant bits from midpoints. """ function trim(x::ComplexFieldElem) z = ComplexFieldElem() - ccall((:acb_trim, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}), z, x) + @ccall libflint.acb_trim(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem})::Nothing return z end @@ -572,21 +569,19 @@ integer. """ function unique_integer(x::ComplexFieldElem) z = ZZRingElem() - unique = ccall((:acb_get_unique_fmpz, libflint), Int, - (Ref{ZZRingElem}, Ref{ComplexFieldElem}), z, x) + unique = @ccall libflint.acb_get_unique_fmpz(z::Ref{ZZRingElem}, x::Ref{ComplexFieldElem})::Int return (unique != 0, z) end function conj(x::ComplexFieldElem) z = ComplexFieldElem() - ccall((:acb_conj, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}), z, x) + @ccall libflint.acb_conj(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem})::Nothing return z end function angle(x::ComplexFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:acb_arg, libflint), Nothing, - (Ref{RealFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_arg(z::Ref{RealFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -603,7 +598,7 @@ Return $\pi = 3.14159\ldots$ as an element of $r$. """ function const_pi(r::ComplexField, prec::Int = precision(Balls)) z = r() - ccall((:acb_const_pi, libflint), Nothing, (Ref{ComplexFieldElem}, Int), z, prec) + @ccall libflint.acb_const_pi(z::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -617,7 +612,7 @@ end function Base.sqrt(x::ComplexFieldElem, prec::Int = precision(Balls); check::Bool=true) z = ComplexFieldElem() - ccall((:acb_sqrt, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_sqrt(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -628,7 +623,7 @@ Return the reciprocal of the square root of $x$, i.e. $1/\sqrt{x}$. """ function rsqrt(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_rsqrt, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_rsqrt(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -644,32 +639,32 @@ function root(x::ComplexFieldElem, n::Int, prec::Int = precision(Balls)) n = -n x = inv(x) end - ccall((:acb_root_ui, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, UInt, Int), z, x, UInt(n), prec) + @ccall libflint.acb_root_ui(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, UInt(n)::UInt, prec::Int)::Nothing return z end function log(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_log, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_log(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function log1p(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_log1p, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_log1p(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function Base.exp(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_exp, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_exp(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function Base.expm1(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_expm1, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_expm1(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -680,7 +675,7 @@ Return the exponential of $\pi i x$. """ function cispi(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_exp_pi_i, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_exp_pi_i(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -692,85 +687,85 @@ Return $\exp(2\pi i/k)$. function root_of_unity(C::ComplexField, k::Int, prec::Int = precision(Balls)) k <= 0 && throw(ArgumentError("Order must be positive ($k)")) z = C() - ccall((:acb_unit_root, libflint), Nothing, (Ref{ComplexFieldElem}, UInt, Int), z, k, prec) + @ccall libflint.acb_unit_root(z::Ref{ComplexFieldElem}, k::UInt, prec::Int)::Nothing return z end function sin(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_sin, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_sin(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function cos(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_cos, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_cos(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function tan(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_tan, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_tan(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function cot(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_cot, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_cot(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function sinpi(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_sin_pi, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_sin_pi(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function cospi(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_cos_pi, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_cos_pi(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function tanpi(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_tan_pi, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_tan_pi(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function cotpi(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_cot_pi, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_cot_pi(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function sinh(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_sinh, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_sinh(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function cosh(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_cosh, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_cosh(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function tanh(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_tanh, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_tanh(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function coth(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_coth, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_coth(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function atan(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_atan, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_atan(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -781,7 +776,7 @@ Return $\log\sin(\pi x)$, constructed without branch cuts off the real line. """ function log_sinpi(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_log_sin_pi, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_log_sin_pi(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -792,7 +787,7 @@ Return the Gamma function evaluated at $x$. """ function gamma(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_gamma, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_gamma(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -803,7 +798,7 @@ Return the reciprocal of the Gamma function evaluated at $x$. """ function rgamma(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_rgamma, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_rgamma(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -814,7 +809,7 @@ Return the logarithm of the Gamma function evaluated at $x$. """ function lgamma(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_lgamma, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_lgamma(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -826,7 +821,7 @@ i.e. $\psi(x)$. """ function digamma(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_digamma, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_digamma(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -837,7 +832,7 @@ Return the Riemann zeta function evaluated at $x$. """ function zeta(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_zeta, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_zeta(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -848,7 +843,7 @@ Return the Barnes $G$-function, evaluated at $x$. """ function barnes_g(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_barnes_g, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_barnes_g(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -859,7 +854,7 @@ Return the logarithm of the Barnes $G$-function, evaluated at $x$. """ function log_barnes_g(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_log_barnes_g, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_log_barnes_g(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -870,7 +865,7 @@ Return the arithmetic-geometric mean of $1$ and $x$. """ function agm(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_agm1, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_agm1(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -881,7 +876,7 @@ Return the error function evaluated at $x$. """ function erf(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_erf, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_hypgeom_erf(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -892,7 +887,7 @@ Return the imaginary error function evaluated at $x$. """ function erfi(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_erfi, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_hypgeom_erfi(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -903,7 +898,7 @@ Return the complementary error function evaluated at $x$. """ function erfc(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_erfc, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_hypgeom_erfc(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -914,7 +909,7 @@ Return the exponential integral evaluated at $x$. """ function exp_integral_ei(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_ei, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_hypgeom_ei(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -925,7 +920,7 @@ Return the sine integral evaluated at $x$. """ function sin_integral(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_si, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_hypgeom_si(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -936,7 +931,7 @@ Return the exponential cosine integral evaluated at $x$. """ function cos_integral(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_ci, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_hypgeom_ci(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -947,7 +942,7 @@ Return the hyperbolic sine integral evaluated at $x$. """ function sinh_integral(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_shi, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_hypgeom_shi(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -958,7 +953,7 @@ Return the hyperbolic cosine integral evaluated at $x$. """ function cosh_integral(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_chi, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_hypgeom_chi(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -969,7 +964,7 @@ Return the Dedekind eta function $\eta(\tau)$ at $\tau = x$. """ function dedekind_eta(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_modular_eta, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_modular_eta(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1017,7 +1012,7 @@ Return the $j$-invariant $j(\tau)$ at $\tau = x$. """ function j_invariant(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_modular_j, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_modular_j(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1028,7 +1023,7 @@ Return the modular lambda function $\lambda(\tau)$ at $\tau = x$. """ function modular_lambda(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_modular_lambda, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_modular_lambda(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1039,7 +1034,7 @@ Return the modular delta function $\Delta(\tau)$ at $\tau = x$. """ function modular_delta(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_modular_delta, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_modular_delta(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1059,8 +1054,7 @@ function eisenstein_g(k::Int, x::ComplexFieldElem, prec::Int = precision(Balls)) len = div(k, 2) - 1 vec = acb_vec(len) - ccall((:acb_modular_eisenstein, libflint), Nothing, - (Ptr{acb_struct}, Ref{ComplexFieldElem}, Int, Int), vec, x, len, prec) + @ccall libflint.acb_modular_eisenstein(vec::Ptr{acb_struct}, x::Ref{ComplexFieldElem}, len::Int, prec::Int)::Nothing z = array(CC, vec, len) acb_vec_clear(vec, len) return z[end] @@ -1075,9 +1069,7 @@ which is only defined for $D < 0$ and $D \equiv 0, 1 \pmod 4$. function hilbert_class_polynomial(D::Int, R::ZZPolyRing) D < 0 && mod(D, 4) < 2 || throw(ArgumentError("$D is not a negative discriminant")) z = R() - ccall((:acb_modular_hilbert_class_poly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Int), - z, D) + @ccall libflint.acb_modular_hilbert_class_poly(z::Ref{ZZPolyRingElem}, D::Int)::Nothing return z end @@ -1088,7 +1080,7 @@ Return the complete elliptic integral $K(x)$. """ function elliptic_k(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_modular_elliptic_k, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_modular_elliptic_k(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1099,23 +1091,21 @@ Return the complete elliptic integral $E(x)$. """ function elliptic_e(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_modular_elliptic_e, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, x, prec) + @ccall libflint.acb_modular_elliptic_e(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function sincos(x::ComplexFieldElem, prec::Int = precision(Balls)) s = ComplexFieldElem() c = ComplexFieldElem() - ccall((:acb_sin_cos, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), s, c, x, prec) + @ccall libflint.acb_sin_cos(s::Ref{ComplexFieldElem}, c::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return (s, c) end function sincospi(x::ComplexFieldElem, prec::Int = precision(Balls)) s = ComplexFieldElem() c = ComplexFieldElem() - ccall((:acb_sin_cos_pi, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), s, c, x, prec) + @ccall libflint.acb_sin_cos_pi(s::Ref{ComplexFieldElem}, c::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return (s, c) end @@ -1127,8 +1117,7 @@ Return a tuple $s, c$ consisting of the hyperbolic sine and cosine of $x$. function sinhcosh(x::ComplexFieldElem, prec::Int = precision(Balls)) s = ComplexFieldElem() c = ComplexFieldElem() - ccall((:acb_sinh_cosh, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), s, c, x, prec) + @ccall libflint.acb_sinh_cosh(s::Ref{ComplexFieldElem}, c::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return (s, c) end @@ -1139,8 +1128,7 @@ Return the Hurwitz zeta function $\zeta(s,a)$. """ function zeta(s::ComplexFieldElem, a::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:acb_hurwitz_zeta, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, s, a, prec) + @ccall libflint.acb_hurwitz_zeta(z::Ref{ComplexFieldElem}, s::Ref{ComplexFieldElem}, a::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1151,15 +1139,13 @@ Return the generalised polygamma function $\psi(s,z)$. """ function polygamma(s::ComplexFieldElem, a::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:acb_polygamma, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, s, a, prec) + @ccall libflint.acb_polygamma(z::Ref{ComplexFieldElem}, s::Ref{ComplexFieldElem}, a::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function rising_factorial(x::ComplexFieldElem, n::UInt, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_rising_ui, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, UInt, Int), z, x, n, prec) + @ccall libflint.acb_rising_ui(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, n::UInt, prec::Int)::Nothing return z end @@ -1176,8 +1162,7 @@ end function rising_factorial2(x::ComplexFieldElem, n::UInt, prec::Int = precision(Balls)) z = ComplexFieldElem() w = ComplexFieldElem() - ccall((:acb_rising2_ui, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, UInt, Int), z, w, x, n, prec) + @ccall libflint.acb_rising2_ui(z::Ref{ComplexFieldElem}, w::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, n::UInt, prec::Int)::Nothing return (z, w) end @@ -1194,15 +1179,13 @@ end function polylog(s::ComplexFieldElem, a::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:acb_polylog, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, s, a, prec) + @ccall libflint.acb_polylog(z::Ref{ComplexFieldElem}, s::Ref{ComplexFieldElem}, a::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function polylog(s::Int, a::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(a)() - ccall((:acb_polylog_si, libflint), Nothing, - (Ref{ComplexFieldElem}, Int, Ref{ComplexFieldElem}, Int), z, s, a, prec) + @ccall libflint.acb_polylog_si(z::Ref{ComplexFieldElem}, s::Int, a::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1219,8 +1202,7 @@ Return the logarithmic integral, evaluated at $x$. """ function log_integral(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_li, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int, Int), z, x, 0, prec) + @ccall libflint.acb_hypgeom_li(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, 0::Int, prec::Int)::Nothing return z end @@ -1231,8 +1213,7 @@ Return the offset logarithmic integral, evaluated at $x$. """ function log_integral_offset(x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_li, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int, Int), z, x, 1, prec) + @ccall libflint.acb_hypgeom_li(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, 1::Int, prec::Int)::Nothing return z end @@ -1243,8 +1224,7 @@ Return the generalised exponential integral $E_s(x)$. """ function exp_integral_e(s::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:acb_hypgeom_expint, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, s, x, prec) + @ccall libflint.acb_hypgeom_expint(z::Ref{ComplexFieldElem}, s::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1255,8 +1235,7 @@ Return the upper incomplete gamma function $\Gamma(s,x)$. """ function gamma(s::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:acb_hypgeom_gamma_upper, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int, Int), z, s, x, 0, prec) + @ccall libflint.acb_hypgeom_gamma_upper(z::Ref{ComplexFieldElem}, s::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, 0::Int, prec::Int)::Nothing return z end @@ -1268,8 +1247,7 @@ $\Gamma(s,x) / \Gamma(s)$. """ function gamma_regularized(s::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:acb_hypgeom_gamma_upper, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int, Int), z, s, x, 1, prec) + @ccall libflint.acb_hypgeom_gamma_upper(z::Ref{ComplexFieldElem}, s::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, 1::Int, prec::Int)::Nothing return z end @@ -1280,8 +1258,7 @@ Return the lower incomplete gamma function $\gamma(s,x) / \Gamma(s)$. """ function gamma_lower(s::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:acb_hypgeom_gamma_lower, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int, Int), z, s, x, 0, prec) + @ccall libflint.acb_hypgeom_gamma_lower(z::Ref{ComplexFieldElem}, s::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, 0::Int, prec::Int)::Nothing return z end @@ -1293,8 +1270,7 @@ $\gamma(s,x) / \Gamma(s)$. """ function gamma_lower_regularized(s::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:acb_hypgeom_gamma_lower, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int, Int), z, s, x, 1, prec) + @ccall libflint.acb_hypgeom_gamma_lower(z::Ref{ComplexFieldElem}, s::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, 1::Int, prec::Int)::Nothing return z end @@ -1305,8 +1281,7 @@ Return the Bessel function $J_{\nu}(x)$. """ function bessel_j(nu::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_bessel_j, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, nu, x, prec) + @ccall libflint.acb_hypgeom_bessel_j(z::Ref{ComplexFieldElem}, nu::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1317,8 +1292,7 @@ Return the Bessel function $Y_{\nu}(x)$. """ function bessel_y(nu::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_bessel_y, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, nu, x, prec) + @ccall libflint.acb_hypgeom_bessel_y(z::Ref{ComplexFieldElem}, nu::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1329,8 +1303,7 @@ Return the Bessel function $I_{\nu}(x)$. """ function bessel_i(nu::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_bessel_i, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, nu, x, prec) + @ccall libflint.acb_hypgeom_bessel_i(z::Ref{ComplexFieldElem}, nu::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1341,8 +1314,7 @@ Return the Bessel function $K_{\nu}(x)$. """ function bessel_k(nu::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_bessel_k, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, nu, x, prec) + @ccall libflint.acb_hypgeom_bessel_k(z::Ref{ComplexFieldElem}, nu::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1353,9 +1325,7 @@ Return the Airy function $\operatorname{Ai}(x)$. """ function airy_ai(x::ComplexFieldElem, prec::Int = precision(Balls)) ai = ComplexFieldElem() - ccall((:acb_hypgeom_airy, libflint), Nothing, - (Ref{ComplexFieldElem}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ref{ComplexFieldElem}, Int), - ai, C_NULL, C_NULL, C_NULL, x, prec) + @ccall libflint.acb_hypgeom_airy(ai::Ref{ComplexFieldElem}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return ai end @@ -1366,9 +1336,7 @@ Return the Airy function $\operatorname{Bi}(x)$. """ function airy_bi(x::ComplexFieldElem, prec::Int = precision(Balls)) bi = ComplexFieldElem() - ccall((:acb_hypgeom_airy, libflint), Nothing, - (Ptr{Cvoid}, Ptr{Cvoid}, Ref{ComplexFieldElem}, Ptr{Cvoid}, Ref{ComplexFieldElem}, Int), - C_NULL, C_NULL, bi, C_NULL, x, prec) + @ccall libflint.acb_hypgeom_airy(C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, bi::Ref{ComplexFieldElem}, C_NULL::Ptr{Cvoid}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return bi end @@ -1379,9 +1347,7 @@ Return the derivative of the Airy function $\operatorname{Ai}^\prime(x)$. """ function airy_ai_prime(x::ComplexFieldElem, prec::Int = precision(Balls)) ai_prime = ComplexFieldElem() - ccall((:acb_hypgeom_airy, libflint), Nothing, - (Ptr{Cvoid}, Ref{ComplexFieldElem}, Ptr{Cvoid}, Ptr{Cvoid}, Ref{ComplexFieldElem}, Int), - C_NULL, ai_prime, C_NULL, C_NULL, x, prec) + @ccall libflint.acb_hypgeom_airy(C_NULL::Ptr{Cvoid}, ai_prime::Ref{ComplexFieldElem}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return ai_prime end @@ -1392,9 +1358,7 @@ Return the derivative of the Airy function $\operatorname{Bi}^\prime(x)$. """ function airy_bi_prime(x::ComplexFieldElem, prec::Int = precision(Balls)) bi_prime = ComplexFieldElem() - ccall((:acb_hypgeom_airy, libflint), Nothing, - (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), - C_NULL, C_NULL, C_NULL, bi_prime, x, prec) + @ccall libflint.acb_hypgeom_airy(C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, bi_prime::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return bi_prime end @@ -1405,8 +1369,7 @@ Return the confluent hypergeometric function ${}_1F_1(a,b,x)$. """ function hypergeometric_1f1(a::ComplexFieldElem, b::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_m, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int, Int), z, a, b, x, 0, prec) + @ccall libflint.acb_hypgeom_m(z::Ref{ComplexFieldElem}, a::Ref{ComplexFieldElem}, b::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, 0::Int, prec::Int)::Nothing return z end @@ -1418,8 +1381,7 @@ ${}_1F_1(a,b,x) / \Gamma(b)$. """ function hypergeometric_1f1_regularized(a::ComplexFieldElem, b::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_m, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int, Int), z, a, b, x, 1, prec) + @ccall libflint.acb_hypgeom_m(z::Ref{ComplexFieldElem}, a::Ref{ComplexFieldElem}, b::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, 1::Int, prec::Int)::Nothing return z end @@ -1430,8 +1392,7 @@ Return the confluent hypergeometric function $U(a,b,x)$. """ function hypergeometric_u(a::ComplexFieldElem, b::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() - ccall((:acb_hypgeom_u, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), z, a, b, x, prec) + @ccall libflint.acb_hypgeom_u(z::Ref{ComplexFieldElem}, a::Ref{ComplexFieldElem}, b::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1442,8 +1403,7 @@ Return the Gauss hypergeometric function ${}_2F_1(a,b,c,x)$. """ function hypergeometric_2f1(a::ComplexFieldElem, b::ComplexFieldElem, c::ComplexFieldElem, x::ComplexFieldElem, prec::Int = precision(Balls); flags=0) z = ComplexFieldElem() - ccall((:acb_hypgeom_2f1, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int, Int), z, a, b, c, x, flags, prec) + @ccall libflint.acb_hypgeom_2f1(z::Ref{ComplexFieldElem}, a::Ref{ComplexFieldElem}, b::Ref{ComplexFieldElem}, c::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, flags::Int, prec::Int)::Nothing return z end @@ -1458,9 +1418,7 @@ function jacobi_theta(z::ComplexFieldElem, tau::ComplexFieldElem, prec::Int = pr t2 = ComplexFieldElem() t3 = ComplexFieldElem() t4 = ComplexFieldElem() - ccall((:acb_modular_theta, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), - t1, t2, t3, t4, z, tau, prec) + @ccall libflint.acb_modular_theta(t1::Ref{ComplexFieldElem}, t2::Ref{ComplexFieldElem}, t3::Ref{ComplexFieldElem}, t4::Ref{ComplexFieldElem}, z::Ref{ComplexFieldElem}, tau::Ref{ComplexFieldElem}, prec::Int)::Nothing return (t1, t2, t3, t4) end @@ -1471,8 +1429,7 @@ Return the Weierstrass elliptic function $\wp(z,\tau)$. """ function weierstrass_p(z::ComplexFieldElem, tau::ComplexFieldElem, prec::Int = precision(Balls)) r = parent(z)() - ccall((:acb_elliptic_p, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), r, z, tau, prec) + @ccall libflint.acb_elliptic_p(r::Ref{ComplexFieldElem}, z::Ref{ComplexFieldElem}, tau::Ref{ComplexFieldElem}, prec::Int)::Nothing return r end @@ -1483,8 +1440,7 @@ Return the derivative of the Weierstrass elliptic function $\frac{\partial}{\par """ function weierstrass_p_prime(z::ComplexFieldElem, tau::ComplexFieldElem, prec::Int = precision(Balls)) r = parent(z)() - ccall((:acb_elliptic_p_prime, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), r, z, tau, prec) + @ccall libflint.acb_elliptic_p_prime(r::Ref{ComplexFieldElem}, z::Ref{ComplexFieldElem}, tau::Ref{ComplexFieldElem}, prec::Int)::Nothing return r end @@ -1587,26 +1543,22 @@ function neg!(z::ComplexFieldElemOrPtr, a::ComplexFieldElemOrPtr) end function add!(z::ComplexFieldElem, x::ComplexFieldElem, y::ComplexFieldElem, prec::Int = precision(Balls)) - ccall((:acb_add, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), - z, x, y, prec) + @ccall libflint.acb_add(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function sub!(z::ComplexFieldElem, x::ComplexFieldElem, y::ComplexFieldElem, prec::Int = precision(Balls)) - ccall((:acb_sub, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), - z, x, y, prec) + @ccall libflint.acb_sub(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function mul!(z::ComplexFieldElem, x::ComplexFieldElem, y::ComplexFieldElem, prec::Int = precision(Balls)) - ccall((:acb_mul, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), - z, x, y, prec) + @ccall libflint.acb_mul(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end function div!(z::ComplexFieldElem, x::ComplexFieldElem, y::ComplexFieldElem, prec::Int = precision(Balls)) - ccall((:acb_div, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), - z, x, y, prec) + @ccall libflint.acb_div(z::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -1620,62 +1572,57 @@ _real_ptr(x::ComplexFieldElemOrPtr) = @ccall libflint.acb_real_ptr(x::Ref{Comple _imag_ptr(x::ComplexFieldElemOrPtr) = @ccall libflint.acb_imag_ptr(x::Ref{ComplexFieldElem})::Ptr{RealFieldElem} function _acb_set(x::ComplexFieldElemOrPtr, y::Int) - ccall((:acb_set_si, libflint), Nothing, (Ref{ComplexFieldElem}, Int), x, y) + @ccall libflint.acb_set_si(x::Ref{ComplexFieldElem}, y::Int)::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, y::UInt) - ccall((:acb_set_ui, libflint), Nothing, (Ref{ComplexFieldElem}, UInt), x, y) + @ccall libflint.acb_set_ui(x::Ref{ComplexFieldElem}, y::UInt)::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, y::Float64) - ccall((:acb_set_d, libflint), Nothing, (Ref{ComplexFieldElem}, Float64), x, y) + @ccall libflint.acb_set_d(x::Ref{ComplexFieldElem}, y::Float64)::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, y::Union{Int,UInt,Float64}, p::Int) _acb_set(x, y) - ccall((:acb_set_round, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), x, x, p) + @ccall libflint.acb_set_round(x::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, p::Int)::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, y::ZZRingElem) - ccall((:acb_set_fmpz, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ZZRingElem}), x, y) + @ccall libflint.acb_set_fmpz(x::Ref{ComplexFieldElem}, y::Ref{ZZRingElem})::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, y::ZZRingElem, p::Int) - ccall((:acb_set_round_fmpz, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ZZRingElem}, Int), x, y, p) + @ccall libflint.acb_set_round_fmpz(x::Ref{ComplexFieldElem}, y::Ref{ZZRingElem}, p::Int)::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, y::QQFieldElem, p::Int) - ccall((:acb_set_fmpq, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{QQFieldElem}, Int), x, y, p) + @ccall libflint.acb_set_fmpq(x::Ref{ComplexFieldElem}, y::Ref{QQFieldElem}, p::Int)::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, y::RealFieldElem) - ccall((:acb_set_arb, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{RealFieldElem}), x, y) + @ccall libflint.acb_set_arb(x::Ref{ComplexFieldElem}, y::Ref{RealFieldElem})::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, y::RealFieldElem, p::Int) _acb_set(x, y) - ccall((:acb_set_round, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), x, x, p) + @ccall libflint.acb_set_round(x::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, p::Int)::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, y::ComplexFieldElemOrPtr) - ccall((:acb_set, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}), x, y) + @ccall libflint.acb_set(x::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem})::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, y::Ptr{acb_struct}) - ccall((:acb_set, libflint), Nothing, (Ref{ComplexFieldElem}, Ptr{acb_struct}), x, y) + @ccall libflint.acb_set(x::Ref{ComplexFieldElem}, y::Ptr{acb_struct})::Nothing end function _acb_set(x::Ptr{acb_struct}, y::ComplexFieldElemOrPtr) - ccall((:acb_set, libflint), Nothing, (Ptr{acb_struct}, Ref{ComplexFieldElem}) , x, y) + @ccall libflint.acb_set(x::Ptr{acb_struct}, y::Ref{ComplexFieldElem})::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, y::ComplexFieldElemOrPtr, p::Int) - ccall((:acb_set_round, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), x, y, p) + @ccall libflint.acb_set_round(x::Ref{ComplexFieldElem}, y::Ref{ComplexFieldElem}, p::Int)::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, y::AbstractString, p::Int) @@ -1700,21 +1647,17 @@ function _acb_set(x::ComplexFieldElemOrPtr, y::BigFloat, p::Int) end function _acb_set(x::ComplexFieldElemOrPtr, yz::Tuple{Int,Int}, p::Int) - ccall((:acb_set_si_si, libflint), Nothing, - (Ref{ComplexFieldElem}, Int, Int), x, yz[1], yz[2]) - ccall((:acb_set_round, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), x, x, p) + @ccall libflint.acb_set_si_si(x::Ref{ComplexFieldElem}, yz[1]::Int, yz[2]::Int)::Nothing + @ccall libflint.acb_set_round(x::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, p::Int)::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, yz::Tuple{RealFieldElem,RealFieldElem}) - ccall((:acb_set_arb_arb, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}), x, yz[1], yz[2]) + @ccall libflint.acb_set_arb_arb(x::Ref{ComplexFieldElem}, yz[1]::Ref{RealFieldElem}, yz[2]::Ref{RealFieldElem})::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, yz::Tuple{RealFieldElem,RealFieldElem}, p::Int) _acb_set(x, yz) - ccall((:acb_set_round, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), x, x, p) + @ccall libflint.acb_set_round(x::Ref{ComplexFieldElem}, x::Ref{ComplexFieldElem}, p::Int)::Nothing end function _acb_set(x::ComplexFieldElemOrPtr, yz::Tuple{QQFieldElem,QQFieldElem}, p::Int) diff --git a/src/arb/ComplexMat.jl b/src/arb/ComplexMat.jl index 89f2e1a16..21ee29d26 100644 --- a/src/arb/ComplexMat.jl +++ b/src/arb/ComplexMat.jl @@ -89,7 +89,7 @@ number_of_columns(a::ComplexMatrix) = a.c function deepcopy_internal(x::ComplexMatrix, dict::IdDict) z = similar(x) - ccall((:acb_mat_set, libflint), Nothing, (Ref{ComplexMatrix}, Ref{ComplexMatrix}), z, x) + @ccall libflint.acb_mat_set(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix})::Nothing return z end @@ -109,8 +109,7 @@ end function transpose(x::ComplexMatrix) z = similar(x, ncols(x), nrows(x)) - ccall((:acb_mat_transpose, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}), z, x) + @ccall libflint.acb_mat_transpose(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix})::Nothing return z end @@ -123,27 +122,21 @@ end function +(x::ComplexMatrix, y::ComplexMatrix) check_parent(x, y) z = similar(x) - ccall((:acb_mat_add, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_mat_add(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Ref{ComplexMatrix}, precision(Balls)::Int)::Nothing return z end function -(x::ComplexMatrix, y::ComplexMatrix) check_parent(x, y) z = similar(x) - ccall((:acb_mat_sub, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_mat_sub(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Ref{ComplexMatrix}, precision(Balls)::Int)::Nothing return z end function *(x::ComplexMatrix, y::ComplexMatrix) ncols(x) != nrows(y) && error("Matrices have wrong dimensions") z = similar(x, nrows(x), ncols(y)) - ccall((:acb_mat_mul, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_mat_mul(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Ref{ComplexMatrix}, precision(Balls)::Int)::Nothing return z end @@ -156,17 +149,13 @@ end function ^(x::ComplexMatrix, y::UInt) nrows(x) != ncols(x) && error("Matrix must be square") z = similar(x) - ccall((:acb_mat_pow_ui, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, UInt, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_mat_pow_ui(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::UInt, precision(Balls)::Int)::Nothing return z end function *(x::ComplexMatrix, y::Int) z = similar(x) - ccall((:acb_mat_scalar_mul_si, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_mat_scalar_mul_si(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Int, precision(Balls)::Int)::Nothing return z end @@ -174,9 +163,7 @@ end function *(x::ComplexMatrix, y::ZZRingElem) z = similar(x) - ccall((:acb_mat_scalar_mul_fmpz, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ZZRingElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_mat_scalar_mul_fmpz(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Ref{ZZRingElem}, precision(Balls)::Int)::Nothing return z end @@ -184,9 +171,7 @@ end function *(x::ComplexMatrix, y::RealFieldElem) z = similar(x) - ccall((:acb_mat_scalar_mul_arb, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{RealFieldElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_mat_scalar_mul_arb(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Ref{RealFieldElem}, precision(Balls)::Int)::Nothing return z end @@ -194,9 +179,7 @@ end function *(x::ComplexMatrix, y::ComplexFieldElem) z = similar(x) - ccall((:acb_mat_scalar_mul_acb, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexFieldElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_mat_scalar_mul_acb(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Ref{ComplexFieldElem}, precision(Balls)::Int)::Nothing return z end @@ -286,8 +269,7 @@ end function ldexp(x::ComplexMatrix, y::Int) z = similar(x) - ccall((:acb_mat_scalar_mul_2exp_si, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), z, x, y) + @ccall libflint.acb_mat_scalar_mul_2exp_si(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Int)::Nothing return z end @@ -304,20 +286,19 @@ Return `true` if the matrices of balls $x$ and $y$ are precisely equal, i.e. if all matrix entries have the same midpoints and radii. """ function isequal(x::ComplexMatrix, y::ComplexMatrix) - r = ccall((:acb_mat_equal, libflint), Cint, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}), x, y) + r = @ccall libflint.acb_mat_equal(x::Ref{ComplexMatrix}, y::Ref{ComplexMatrix})::Cint return Bool(r) end function ==(x::ComplexMatrix, y::ComplexMatrix) fl = check_parent(x, y, false) !fl && return false - r = ccall((:acb_mat_eq, libflint), Cint, (Ref{ComplexMatrix}, Ref{ComplexMatrix}), x, y) + r = @ccall libflint.acb_mat_eq(x::Ref{ComplexMatrix}, y::Ref{ComplexMatrix})::Cint return Bool(r) end function !=(x::ComplexMatrix, y::ComplexMatrix) - r = ccall((:acb_mat_ne, libflint), Cint, (Ref{ComplexMatrix}, Ref{ComplexMatrix}), x, y) + r = @ccall libflint.acb_mat_ne(x::Ref{ComplexMatrix}, y::Ref{ComplexMatrix})::Cint return Bool(r) end @@ -328,8 +309,7 @@ Returns `true` if all entries of $x$ overlap with the corresponding entry of $y$, otherwise return `false`. """ function overlaps(x::ComplexMatrix, y::ComplexMatrix) - r = ccall((:acb_mat_overlaps, libflint), Cint, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}), x, y) + r = @ccall libflint.acb_mat_overlaps(x::Ref{ComplexMatrix}, y::Ref{ComplexMatrix})::Cint return Bool(r) end @@ -340,8 +320,7 @@ Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ function contains(x::ComplexMatrix, y::ComplexMatrix) - r = ccall((:acb_mat_contains, libflint), Cint, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}), x, y) + r = @ccall libflint.acb_mat_contains(x::Ref{ComplexMatrix}, y::Ref{ComplexMatrix})::Cint return Bool(r) end @@ -358,8 +337,7 @@ Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ function contains(x::ComplexMatrix, y::ZZMatrix) - r = ccall((:acb_mat_contains_fmpz_mat, libflint), Cint, - (Ref{ComplexMatrix}, Ref{ZZMatrix}), x, y) + r = @ccall libflint.acb_mat_contains_fmpz_mat(x::Ref{ComplexMatrix}, y::Ref{ZZMatrix})::Cint return Bool(r) end @@ -370,8 +348,7 @@ Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ function contains(x::ComplexMatrix, y::QQMatrix) - r = ccall((:acb_mat_contains_fmpq_mat, libflint), Cint, - (Ref{ComplexMatrix}, Ref{QQMatrix}), x, y) + r = @ccall libflint.acb_mat_contains_fmpq_mat(x::Ref{ComplexMatrix}, y::Ref{QQMatrix})::Cint return Bool(r) end @@ -390,7 +367,7 @@ end ################################################################################ isreal(x::ComplexMatrix) = -Bool(ccall((:acb_mat_is_real, libflint), Cint, (Ref{ComplexMatrix}, ), x)) +Bool(@ccall libflint.acb_mat_is_real(x::Ref{ComplexMatrix})::Cint) ############################################################################### # @@ -414,8 +391,7 @@ end function is_invertible_with_inverse(x::ComplexMatrix) ncols(x) != nrows(x) && return false, x z = similar(x) - r = ccall((:acb_mat_inv, libflint), Cint, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), z, x, precision(Balls)) + r = @ccall libflint.acb_mat_inv(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, precision(Balls)::Int)::Cint return Bool(r), z end @@ -439,33 +415,25 @@ end function divexact(x::ComplexMatrix, y::Int; check::Bool=true) y == 0 && throw(DivideError()) z = similar(x) - ccall((:acb_mat_scalar_div_si, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_mat_scalar_div_si(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Int, precision(Balls)::Int)::Nothing return z end function divexact(x::ComplexMatrix, y::ZZRingElem; check::Bool=true) z = similar(x) - ccall((:acb_mat_scalar_div_fmpz, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ZZRingElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_mat_scalar_div_fmpz(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Ref{ZZRingElem}, precision(Balls)::Int)::Nothing return z end function divexact(x::ComplexMatrix, y::RealFieldElem; check::Bool=true) z = similar(x) - ccall((:acb_mat_scalar_div_arb, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{RealFieldElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_mat_scalar_div_arb(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Ref{RealFieldElem}, precision(Balls)::Int)::Nothing return z end function divexact(x::ComplexMatrix, y::ComplexFieldElem; check::Bool=true) z = similar(x) - ccall((:acb_mat_scalar_div_acb, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexFieldElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_mat_scalar_div_acb(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Ref{ComplexFieldElem}, precision(Balls)::Int)::Nothing return z end @@ -486,8 +454,7 @@ divexact(x::ComplexMatrix, y::Rational{T}; check::Bool=true) where T <: Union{In function charpoly(x::AcbPolyRing, y::ComplexMatrix, prec::Int = precision(Balls)) base_ring(x) != base_ring(y) && error("Base rings must coincide") z = x() - ccall((:acb_mat_charpoly, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{ComplexMatrix}, Int), z, y, prec) + @ccall libflint.acb_mat_charpoly(z::Ref{AcbPolyRingElem}, y::Ref{ComplexMatrix}, prec::Int)::Nothing return z end @@ -500,8 +467,7 @@ end function det(x::ComplexMatrix, prec::Int = precision(Balls)) ncols(x) != nrows(x) && error("Matrix must be square") z = base_ring(x)() - ccall((:acb_mat_det, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexMatrix}, Int), z, x, prec) + @ccall libflint.acb_mat_det(z::Ref{ComplexFieldElem}, x::Ref{ComplexMatrix}, prec::Int)::Nothing return z end @@ -514,8 +480,7 @@ end function Base.exp(x::ComplexMatrix) ncols(x) != nrows(x) && error("Matrix must be square") z = similar(x) - ccall((:acb_mat_exp, libflint), Nothing, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), z, x, precision(Balls)) + @ccall libflint.acb_mat_exp(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, precision(Balls)::Int)::Nothing return z end @@ -527,9 +492,7 @@ end function lu!(P::Perm, z::ComplexMatrix, x::ComplexMatrix) P.d .-= 1 - r = ccall((:acb_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), - P.d, z, x, precision(Balls)) + r = @ccall libflint.acb_mat_lu(P.d::Ptr{Int}, z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, precision(Balls)::Int)::Cint r == 0 && error("Could not find $(nrows(x)) invertible pivot elements") P.d .+= 1 inv!(P) @@ -541,18 +504,14 @@ function lu!(P::Perm, x::ComplexMatrix) end function _solve!(z::ComplexMatrix, x::ComplexMatrix, y::ComplexMatrix) - r = ccall((:acb_mat_solve, libflint), Cint, - (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), - z, x, y, precision(Balls)) + r = @ccall libflint.acb_mat_solve(z::Ref{ComplexMatrix}, x::Ref{ComplexMatrix}, y::Ref{ComplexMatrix}, precision(Balls)::Int)::Cint r == 0 && error("Matrix cannot be inverted numerically") nothing end function _solve_lu_precomp!(z::ComplexMatrix, P::Perm, LU::ComplexMatrix, y::ComplexMatrix) Q = inv(P) - ccall((:acb_mat_solve_lu_precomp, libflint), Nothing, - (Ref{ComplexMatrix}, Ptr{Int}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), - z, Q.d .- 1, LU, y, precision(Balls)) + @ccall libflint.acb_mat_solve_lu_precomp(z::Ref{ComplexMatrix}, (Q.d .- 1)::Ptr{Int}, LU::Ref{ComplexMatrix}, y::Ref{ComplexMatrix}, precision(Balls)::Int)::Nothing nothing end @@ -666,9 +625,7 @@ function swap_rows(x::ComplexMatrix, i::Int, j::Int) end function swap_rows!(x::ComplexMatrix, i::Int, j::Int) - ccall((:acb_mat_swap_rows, libflint), Nothing, - (Ref{ComplexMatrix}, Ptr{Nothing}, Int, Int), - x, C_NULL, i - 1, j - 1) + @ccall libflint.acb_mat_swap_rows(x::Ref{ComplexMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int)::Nothing end ################################################################################ @@ -687,13 +644,10 @@ function bound_inf_norm(x::ComplexMatrix) z = RealFieldElem() GC.@preserve x z begin t = _rad_ptr(z) - ccall((:acb_mat_bound_inf_norm, libflint), Nothing, - (Ptr{mag_struct}, Ref{ComplexMatrix}), t, x) + @ccall libflint.acb_mat_bound_inf_norm(t::Ptr{mag_struct}, x::Ref{ComplexMatrix})::Nothing s = _mid_ptr(z) - ccall((:arf_set_mag, libflint), Nothing, - (Ptr{arf_struct}, Ptr{mag_struct}), s, t) - ccall((:mag_zero, libflint), Nothing, - (Ptr{mag_struct},), t) + @ccall libflint.arf_set_mag(s::Ptr{arf_struct}, t::Ptr{mag_struct})::Nothing + @ccall libflint.mag_zero(t::Ptr{mag_struct})::Nothing end return z end @@ -899,8 +853,7 @@ end ################################################################################ @inline mat_entry_ptr(A::ComplexMatrix, i::Int, j::Int) = -ccall((:acb_mat_entry_ptr, libflint), - Ptr{ComplexFieldElem}, (Ref{ComplexMatrix}, Int, Int), A, i-1, j-1) +@ccall libflint.acb_mat_entry_ptr(A::Ref{ComplexMatrix}, (i-1)::Int, (j-1)::Int)::Ptr{ComplexFieldElem} @@ -936,10 +889,7 @@ promote_rule(::Type{ComplexMatrix}, ::Type{ArbMatrix}) = ComplexMatrix function __approx_eig_qr!(v::Ptr{acb_struct}, R::ComplexMatrix, A::ComplexMatrix) n = nrows(A) - ccall((:acb_mat_approx_eig_qr, libflint), Cint, - (Ptr{acb_struct}, Ptr{Nothing}, Ref{ComplexMatrix}, - Ref{ComplexMatrix}, Ptr{Nothing}, Int, Int), - v, C_NULL, R, A, C_NULL, 0, precision(Balls)) + @ccall libflint.acb_mat_approx_eig_qr(v::Ptr{acb_struct}, C_NULL::Ptr{Nothing}, R::Ref{ComplexMatrix}, A::Ref{ComplexMatrix}, C_NULL::Ptr{Nothing}, 0::Int, precision(Balls)::Int)::Cint return nothing end @@ -959,9 +909,7 @@ function _eig_multiple(A::ComplexMatrix, check::Bool = true) v_approx = acb_vec(n) R = zero_matrix(base_ring(A), n, n) __approx_eig_qr!(v, R, A) - b = ccall((:acb_mat_eig_multiple, libflint), Cint, - (Ptr{acb_struct}, Ref{ComplexMatrix}, Ptr{acb_struct}, Ref{ComplexMatrix}, Int), - v_approx, A, v, R, precision(Balls)) + b = @ccall libflint.acb_mat_eig_multiple(v_approx::Ptr{acb_struct}, A::Ref{ComplexMatrix}, v::Ptr{acb_struct}, R::Ref{ComplexMatrix}, precision(Balls)::Int)::Cint check && b == 0 && error("Could not isolate eigenvalues of matrix $A") z = array(base_ring(A), v, n) acb_vec_clear(v, n) @@ -993,20 +941,11 @@ function _eig_simple(A::ComplexMatrix; check::Bool = true, algorithm::Symbol = : R = zero_matrix(base_ring(A), n, n) __approx_eig_qr!(v, Rapprox, A) if algorithm == :vdhoeven_mourrain - b = ccall((:acb_mat_eig_simple_vdhoeven_mourrain, libflint), Cint, - (Ptr{acb_struct}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, - Ref{ComplexMatrix}, Ptr{acb_struct}, Ref{ComplexMatrix}, Int), - v_approx, L, R, A, v, Rapprox, precision(Balls)) + b = @ccall libflint.acb_mat_eig_simple_vdhoeven_mourrain(v_approx::Ptr{acb_struct}, L::Ref{ComplexMatrix}, R::Ref{ComplexMatrix}, A::Ref{ComplexMatrix}, v::Ptr{acb_struct}, Rapprox::Ref{ComplexMatrix}, precision(Balls)::Int)::Cint elseif algorithm == :rump - b = ccall((:acb_mat_eig_simple_rump, libflint), Cint, - (Ptr{acb_struct}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, - Ref{ComplexMatrix}, Ptr{acb_struct}, Ref{ComplexMatrix}, Int), - v_approx, L, R, A, v, Rapprox, precision(Balls)) + b = @ccall libflint.acb_mat_eig_simple_rump(v_approx::Ptr{acb_struct}, L::Ref{ComplexMatrix}, R::Ref{ComplexMatrix}, A::Ref{ComplexMatrix}, v::Ptr{acb_struct}, Rapprox::Ref{ComplexMatrix}, precision(Balls)::Int)::Cint elseif algorithm == :default - b = ccall((:acb_mat_eig_simple, libflint), Cint, - (Ptr{acb_struct}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, - Ref{ComplexMatrix}, Ptr{acb_struct}, Ref{ComplexMatrix}, Int), - v_approx, L, R, A, v, Rapprox, precision(Balls)) + b = @ccall libflint.acb_mat_eig_simple(v_approx::Ptr{acb_struct}, L::Ref{ComplexMatrix}, R::Ref{ComplexMatrix}, A::Ref{ComplexMatrix}, v::Ptr{acb_struct}, Rapprox::Ref{ComplexMatrix}, precision(Balls)::Int)::Cint else error("Algorithm $algorithm not supported") end diff --git a/src/arb/ComplexPoly.jl b/src/arb/ComplexPoly.jl index b37cbebc5..357581348 100644 --- a/src/arb/ComplexPoly.jl +++ b/src/arb/ComplexPoly.jl @@ -16,12 +16,10 @@ elem_type(::Type{ComplexPolyRing}) = ComplexPolyRingElem dense_poly_type(::Type{ComplexFieldElem}) = ComplexPolyRingElem -length(x::ComplexPolyRingElem) = ccall((:acb_poly_length, libflint), Int, - (Ref{ComplexPolyRingElem},), x) +length(x::ComplexPolyRingElem) = @ccall libflint.acb_poly_length(x::Ref{ComplexPolyRingElem})::Int function set_length!(x::ComplexPolyRingElem, n::Int) - ccall((:_acb_poly_set_length, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Int), x, n) + @ccall libflint._acb_poly_set_length(x::Ref{ComplexPolyRingElem}, n::Int)::Nothing return x end @@ -30,8 +28,7 @@ degree(x::ComplexPolyRingElem) = length(x) - 1 function coeff(a::ComplexPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) t = ComplexFieldElem() - ccall((:acb_poly_get_coeff_acb, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexPolyRingElem}, Int), t, a, n) + @ccall libflint.acb_poly_get_coeff_acb(t::Ref{ComplexFieldElem}, a::Ref{ComplexPolyRingElem}, n::Int)::Nothing return t end @@ -108,8 +105,7 @@ end ############################################################################### function isequal(x::ComplexPolyRingElem, y::ComplexPolyRingElem) - return ccall((:acb_poly_equal, libflint), Bool, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}), x, y) + return @ccall libflint.acb_poly_equal(x::Ref{ComplexPolyRingElem}, y::Ref{ComplexPolyRingElem})::Bool end @doc raw""" @@ -119,8 +115,7 @@ Return `true` if the coefficient boxes of $x$ overlap the coefficient boxes of $y$, otherwise return `false`. """ function overlaps(x::ComplexPolyRingElem, y::ComplexPolyRingElem) - return ccall((:acb_poly_overlaps, libflint), Bool, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}), x, y) + return @ccall libflint.acb_poly_overlaps(x::Ref{ComplexPolyRingElem}, y::Ref{ComplexPolyRingElem})::Bool end @doc raw""" @@ -130,8 +125,7 @@ Return `true` if the coefficient boxes of $x$ contain the corresponding coefficient boxes of $y$, otherwise return `false`. """ function contains(x::ComplexPolyRingElem, y::ComplexPolyRingElem) - return ccall((:acb_poly_contains, libflint), Bool, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}), x, y) + return @ccall libflint.acb_poly_contains(x::Ref{ComplexPolyRingElem}, y::Ref{ComplexPolyRingElem})::Bool end @doc raw""" @@ -141,8 +135,7 @@ Return `true` if the coefficient boxes of $x$ contain the corresponding exact coefficients of $y$, otherwise return `false`. """ function contains(x::ComplexPolyRingElem, y::ZZPolyRingElem) - return ccall((:acb_poly_contains_fmpz_poly, libflint), Bool, - (Ref{ComplexPolyRingElem}, Ref{ZZPolyRingElem}), x, y) + return @ccall libflint.acb_poly_contains_fmpz_poly(x::Ref{ComplexPolyRingElem}, y::Ref{ZZPolyRingElem})::Bool end @doc raw""" @@ -152,8 +145,7 @@ Return `true` if the coefficient boxes of $x$ contain the corresponding exact coefficients of $y$, otherwise return `false`. """ function contains(x::ComplexPolyRingElem, y::QQPolyRingElem) - return ccall((:acb_poly_contains_fmpq_poly, libflint), Bool, - (Ref{ComplexPolyRingElem}, Ref{QQPolyRingElem}), x, y) + return @ccall libflint.acb_poly_contains_fmpq_poly(x::Ref{ComplexPolyRingElem}, y::Ref{QQPolyRingElem})::Bool end function ==(x::ComplexPolyRingElem, y::ComplexPolyRingElem) @@ -186,13 +178,12 @@ in case it is, otherwise sets $t$ to `false`. """ function unique_integer(x::ComplexPolyRingElem) z = ZZPolyRing(ZZ, var(parent(x)))() - unique = ccall((:acb_poly_get_unique_fmpz_poly, libflint), Int, - (Ref{ZZPolyRingElem}, Ref{ComplexPolyRingElem}), z, x) + unique = @ccall libflint.acb_poly_get_unique_fmpz_poly(z::Ref{ZZPolyRingElem}, x::Ref{ComplexPolyRingElem})::Int return (unique != 0, z) end function isreal(x::ComplexPolyRingElem) - return ccall((:acb_poly_is_real, libflint), Cint, (Ref{ComplexPolyRingElem}, ), x) != 0 + return @ccall libflint.acb_poly_is_real(x::Ref{ComplexPolyRingElem})::Cint != 0 end ############################################################################### @@ -204,16 +195,14 @@ end function shift_left(x::ComplexPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:acb_poly_shift_left, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, len) + @ccall libflint.acb_poly_shift_left(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, len::Int)::Nothing return z end function shift_right(x::ComplexPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:acb_poly_shift_right, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, len) + @ccall libflint.acb_poly_shift_right(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, len::Int)::Nothing return z end @@ -249,9 +238,7 @@ end function ^(x::ComplexPolyRingElem, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() - ccall((:acb_poly_pow_ui, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, UInt, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_poly_pow_ui(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, y::UInt, precision(Balls)::Int)::Nothing return z end @@ -335,17 +322,14 @@ function truncate(a::ComplexPolyRingElem, n::Int) end # todo: implement set_trunc in ArbFieldElem z = deepcopy(a) - ccall((:acb_poly_truncate, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Int), z, n) + @ccall libflint.acb_poly_truncate(z::Ref{ComplexPolyRingElem}, n::Int)::Nothing return z end function mullow(x::ComplexPolyRingElem, y::ComplexPolyRingElem, n::Int, prec::Int = precision(Balls)) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() - ccall((:acb_poly_mullow, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int, Int), - z, x, y, n, prec) + @ccall libflint.acb_poly_mullow(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, y::Ref{ComplexPolyRingElem}, n::Int, prec::Int)::Nothing return z end @@ -371,9 +355,7 @@ end function evaluate(x::ComplexPolyRingElem, y::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(y)() - ccall((:acb_poly_evaluate, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexPolyRingElem}, Ref{ComplexFieldElem}, Int), - z, x, y, prec) + @ccall libflint.acb_poly_evaluate(z::Ref{ComplexFieldElem}, x::Ref{ComplexPolyRingElem}, y::Ref{ComplexFieldElem}, prec::Int)::Nothing return z end @@ -392,9 +374,7 @@ its derivative evaluated at $y$. function evaluate2(x::ComplexPolyRingElem, y::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() w = ComplexFieldElem() - ccall((:acb_poly_evaluate2, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexPolyRingElem}, Ref{ComplexFieldElem}, Int), - z, w, x, y, prec) + @ccall libflint.acb_poly_evaluate2(z::Ref{ComplexFieldElem}, w::Ref{ComplexFieldElem}, x::Ref{ComplexPolyRingElem}, y::Ref{ComplexFieldElem}, prec::Int)::Nothing return z, w end @@ -414,9 +394,7 @@ function compose(x::ComplexPolyRingElem, y::ComplexPolyRingElem, prec::Int = pre end @assert inner == :second z = parent(x)() - ccall((:acb_poly_compose, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), - z, x, y, prec) + @ccall libflint.acb_poly_compose(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, y::Ref{ComplexPolyRingElem}, prec::Int)::Nothing return z end @@ -428,15 +406,13 @@ end function derivative(x::ComplexPolyRingElem, prec::Int = precision(Balls)) z = parent(x)() - ccall((:acb_poly_derivative, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, prec) + @ccall libflint.acb_poly_derivative(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, prec::Int)::Nothing return z end function integral(x::ComplexPolyRingElem, prec::Int = precision(Balls)) z = parent(x)() - ccall((:acb_poly_integral, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, prec) + @ccall libflint.acb_poly_integral(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, prec::Int)::Nothing return z end @@ -447,11 +423,11 @@ end ############################################################################### function acb_vec(n::Int) - return ccall((:_acb_vec_init, libflint), Ptr{acb_struct}, (Int,), n) + return @ccall libflint._acb_vec_init(n::Int)::Ptr{acb_struct} end function acb_vec(b::Vector{ComplexFieldElem}) - v = ccall((:_acb_vec_init, libflint), Ptr{acb_struct}, (Int,), length(b)) + v = @ccall libflint._acb_vec_init(length(b)::Int)::Ptr{acb_struct} for i in 1:length(b) _acb_set(v + (i-1)*sizeof(acb_struct), b[i]) end @@ -468,7 +444,7 @@ function array(R::ComplexField, v::Ptr{acb_struct}, n::Int) end function acb_vec_clear(v::Ptr{acb_struct}, n::Int) - ccall((:_acb_vec_clear, libflint), Nothing, (Ptr{acb_struct}, Int), v, n) + @ccall libflint._acb_vec_clear(v::Ptr{acb_struct}, n::Int)::Nothing end @doc raw""" @@ -479,8 +455,7 @@ Construct a polynomial in the given polynomial ring from a list of its roots. function from_roots(R::ComplexPolyRing, b::Vector{ComplexFieldElem}, prec::Int = precision(Balls)) z = R() tmp = acb_vec(b) - ccall((:acb_poly_product_roots, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ptr{acb_struct}, Int, Int), z, tmp, length(b), prec) + @ccall libflint.acb_poly_product_roots(z::Ref{ComplexPolyRingElem}, tmp::Ptr{acb_struct}, length(b)::Int, prec::Int)::Nothing acb_vec_clear(tmp, length(b)) return z end @@ -491,9 +466,7 @@ end function evaluate_fast(x::ComplexPolyRingElem, b::Vector{ComplexFieldElem}, prec::Int = precision(Balls)) tmp = acb_vec(b) - ccall((:acb_poly_evaluate_vec_fast, libflint), Nothing, - (Ptr{acb_struct}, Ref{ComplexPolyRingElem}, Ptr{acb_struct}, Int, Int), - tmp, x, tmp, length(b), prec) + @ccall libflint.acb_poly_evaluate_vec_fast(tmp::Ptr{acb_struct}, x::Ref{ComplexPolyRingElem}, tmp::Ptr{acb_struct}, length(b)::Int, prec::Int)::Nothing res = array(base_ring(parent(x)), tmp, length(b)) acb_vec_clear(tmp, length(b)) return res @@ -504,9 +477,7 @@ function interpolate_newton(R::ComplexPolyRing, xs::Vector{ComplexFieldElem}, ys z = R() xsv = acb_vec(xs) ysv = acb_vec(ys) - ccall((:acb_poly_interpolate_newton, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ptr{acb_struct}, Ptr{acb_struct}, Int, Int), - z, xsv, ysv, length(xs), prec) + @ccall libflint.acb_poly_interpolate_newton(z::Ref{ComplexPolyRingElem}, xsv::Ptr{acb_struct}, ysv::Ptr{acb_struct}, length(xs)::Int, prec::Int)::Nothing acb_vec_clear(xsv, length(xs)) acb_vec_clear(ysv, length(ys)) return z @@ -517,9 +488,7 @@ function interpolate_barycentric(R::ComplexPolyRing, xs::Vector{ComplexFieldElem z = R() xsv = acb_vec(xs) ysv = acb_vec(ys) - ccall((:acb_poly_interpolate_barycentric, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ptr{acb_struct}, Ptr{acb_struct}, Int, Int), - z, xsv, ysv, length(xs), prec) + @ccall libflint.acb_poly_interpolate_barycentric(z::Ref{ComplexPolyRingElem}, xsv::Ptr{acb_struct}, ysv::Ptr{acb_struct}, length(xs)::Int, prec::Int)::Nothing acb_vec_clear(xsv, length(xs)) acb_vec_clear(ysv, length(ys)) return z @@ -530,9 +499,7 @@ function interpolate_fast(R::ComplexPolyRing, xs::Vector{ComplexFieldElem}, ys:: z = R() xsv = acb_vec(xs) ysv = acb_vec(ys) - ccall((:acb_poly_interpolate_fast, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ptr{acb_struct}, Ptr{acb_struct}, Int, Int), - z, xsv, ysv, length(xs), prec) + @ccall libflint.acb_poly_interpolate_fast(z::Ref{ComplexPolyRingElem}, xsv::Ptr{acb_struct}, ysv::Ptr{acb_struct}, length(xs)::Int, prec::Int)::Nothing acb_vec_clear(xsv, length(xs)) acb_vec_clear(ysv, length(ys)) return z @@ -586,9 +553,7 @@ function roots(x::ComplexPolyRingElem; target=0, isolate_real=false, initial_pre while true in_roots = (wp == initial_prec) ? C_NULL : roots step_max_iter = (max_iter >= 1) ? max_iter : min(max(deg, 32), wp) - isolated = ccall((:acb_poly_find_roots, libflint), Int, - (Ptr{acb_struct}, Ref{ComplexPolyRingElem}, Ptr{acb_struct}, Int, Int), - roots, x, in_roots, step_max_iter, wp) + isolated = @ccall libflint.acb_poly_find_roots(roots::Ptr{acb_struct}, x::Ref{ComplexPolyRingElem}, in_roots::Ptr{acb_struct}, step_max_iter::Int, wp::Int)::Int wp = wp * 2 @@ -608,8 +573,7 @@ function roots(x::ComplexPolyRingElem; target=0, isolate_real=false, initial_pre end if isreal(x) - real_ok = ccall((:acb_poly_validate_real_roots, libflint), - Bool, (Ptr{acb_struct}, Ref{ComplexPolyRingElem}, Int), roots, x, wp) + real_ok = @ccall libflint.acb_poly_validate_real_roots(roots::Ptr{acb_struct}, x::Ref{ComplexPolyRingElem}, wp::Int)::Bool if isolate_real && !real_ok ok = false @@ -618,8 +582,8 @@ function roots(x::ComplexPolyRingElem; target=0, isolate_real=false, initial_pre if real_ok for i = 0 : deg - 1 im = _imag_ptr(roots + i * sizeof(acb_struct)) - if ccall((:arb_contains_zero, libflint), Bool, (Ptr{arb_struct}, ), im) - ccall((:arb_zero, libflint), Nothing, (Ptr{arb_struct}, ), im) + if @ccall libflint.arb_contains_zero(im::Ptr{arb_struct})::Bool + @ccall libflint.arb_zero(im::Ptr{arb_struct})::Nothing end end end @@ -636,8 +600,7 @@ function roots(x::ComplexPolyRingElem; target=0, isolate_real=false, initial_pre end if isolated == deg - ccall((:_acb_vec_sort_pretty, libflint), Nothing, - (Ptr{acb_struct}, Int), roots, deg) + @ccall libflint._acb_vec_sort_pretty(roots::Ptr{acb_struct}, deg::Int)::Nothing res = array(base_ring(parent(x)), roots, deg) end @@ -666,13 +629,11 @@ function roots_upper_bound(x::ComplexPolyRingElem) p = precision(Balls) GC.@preserve x z begin t = _rad_ptr(z) - ccall((:acb_poly_root_bound_fujiwara, libflint), Nothing, - (Ptr{mag_struct}, Ref{ComplexPolyRingElem}), t, x) + @ccall libflint.acb_poly_root_bound_fujiwara(t::Ptr{mag_struct}, x::Ref{ComplexPolyRingElem})::Nothing s = _mid_ptr(z) - ccall((:arf_set_mag, libflint), Nothing, (Ptr{arf_struct}, Ptr{mag_struct}), s, t) - ccall((:arf_set_round, libflint), Nothing, - (Ptr{arf_struct}, Ptr{arf_struct}, Int, Cint), s, s, p, ARB_RND_CEIL) - ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct},), t) + @ccall libflint.arf_set_mag(s::Ptr{arf_struct}, t::Ptr{mag_struct})::Nothing + @ccall libflint.arf_set_round(s::Ptr{arf_struct}, s::Ptr{arf_struct}, p::Int, ARB_RND_CEIL::Cint)::Nothing + @ccall libflint.mag_zero(t::Ptr{mag_struct})::Nothing end return z end @@ -699,20 +660,17 @@ function neg!(z::ComplexPolyRingElemOrPtr, a::ComplexPolyRingElemOrPtr) end function fit!(z::ComplexPolyRingElem, n::Int) - ccall((:acb_poly_fit_length, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Int), z, n) + @ccall libflint.acb_poly_fit_length(z::Ref{ComplexPolyRingElem}, n::Int)::Nothing return nothing end function setcoeff!(z::ComplexPolyRingElem, n::Int, x::ComplexFieldElem) - ccall((:acb_poly_set_coeff_acb, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Int, Ref{ComplexFieldElem}), z, n, x) + @ccall libflint.acb_poly_set_coeff_acb(z::Ref{ComplexPolyRingElem}, n::Int, x::Ref{ComplexFieldElem})::Nothing return z end function setcoeff!(z::ComplexPolyRingElem, n::Int, x::Int) - ccall((:acb_poly_set_coeff_si, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Int, Int), z, n, x) + @ccall libflint.acb_poly_set_coeff_si(z::Ref{ComplexPolyRingElem}, n::Int, x::Int)::Nothing return z end @@ -725,16 +683,12 @@ setcoeff!(z::ComplexPolyRingElem, n::Int, x::Integer) = setcoeff!(z, n, flintify # function add!(z::ComplexPolyRingElem, x::ComplexPolyRingElem, y::ComplexPolyRingElem) - ccall((:acb_poly_add, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_poly_add(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, y::Ref{ComplexPolyRingElem}, precision(Balls)::Int)::Nothing return z end function add!(z::ComplexPolyRingElem, x::ComplexPolyRingElem, y::Int) - ccall((:acb_poly_add_si, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_poly_add_si(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, y::Int, precision(Balls)::Int)::Nothing return z end @@ -749,9 +703,7 @@ add!(z::ComplexPolyRingElem, x::Union{ComplexFieldElem,IntegerUnion}, y::Complex # function sub!(z::ComplexPolyRingElem, x::ComplexPolyRingElem, y::ComplexPolyRingElem) - ccall((:acb_poly_sub, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_poly_sub(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, y::Ref{ComplexPolyRingElem}, precision(Balls)::Int)::Nothing return z end @@ -762,16 +714,12 @@ sub!(z::ComplexPolyRingElem, x::Union{ComplexFieldElem,IntegerUnion}, y::Complex # function mul!(z::ComplexPolyRingElem, x::ComplexPolyRingElem, y::ComplexPolyRingElem) - ccall((:acb_poly_mul, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_poly_mul(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, y::Ref{ComplexPolyRingElem}, precision(Balls)::Int)::Nothing return z end function mul!(z::ComplexPolyRingElem, x::ComplexPolyRingElem, y::ComplexFieldElem) - ccall((:acb_poly_scalar_mul, libflint), Nothing, - (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexFieldElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.acb_poly_scalar_mul(z::Ref{ComplexPolyRingElem}, x::Ref{ComplexPolyRingElem}, y::Ref{ComplexFieldElem}, precision(Balls)::Int)::Nothing return z end diff --git a/src/arb/Real.jl b/src/arb/Real.jl index f9f0c3409..d41a7550e 100644 --- a/src/arb/Real.jl +++ b/src/arb/Real.jl @@ -40,7 +40,7 @@ Return the relative accuracy of $x$ measured in bits, capped between `typemax(Int)` and `-typemax(Int)`. """ function accuracy_bits(x::RealFieldElem) - return ccall((:arb_rel_accuracy_bits, libflint), Int, (Ref{RealFieldElem},), x) + return @ccall libflint.arb_rel_accuracy_bits(x::Ref{RealFieldElem})::Int end function deepcopy_internal(a::RealFieldElem, dict::IdDict) @@ -94,9 +94,7 @@ function _arb_get_arf(x::RealFieldElem, ::RoundingMode{:Nearest}) t = arf_struct() GC.@preserve x begin t1 = _mid_ptr(x) - ccall((:arf_set, libflint), Nothing, - (Ref{arf_struct}, Ptr{arf_struct}), - t, t1) + @ccall libflint.arf_set(t::Ref{arf_struct}, t1::Ptr{arf_struct})::Nothing end return t end @@ -152,13 +150,9 @@ end function native_string(x::RealFieldElem) d = ceil(precision(Balls) * 0.30102999566398119521) - cstr = ccall((:arb_get_str, libflint), Ptr{UInt8}, - (Ref{RealFieldElem}, Int, UInt), - x, Int(d), UInt(0)) + cstr = @ccall libflint.arb_get_str(x::Ref{RealFieldElem}, Int(d)::Int, UInt(0)::UInt)::Ptr{UInt8} res = unsafe_string(cstr) - ccall((:flint_free, libflint), Nothing, - (Ptr{UInt8},), - cstr) + @ccall libflint.flint_free(cstr::Ptr{UInt8})::Nothing return res end @@ -197,12 +191,12 @@ Returns `true` if any part of the ball $x$ overlaps any part of the ball $y$, otherwise return `false`. """ function overlaps(x::RealFieldElem, y::RealFieldElem) - r = ccall((:arb_overlaps, libflint), Cint, (Ref{RealFieldElem}, Ref{RealFieldElem}), x, y) + r = @ccall libflint.arb_overlaps(x::Ref{RealFieldElem}, y::Ref{RealFieldElem})::Cint return Bool(r) end #function contains(x::RealFieldElem, y::arf) -# r = ccall((:arb_contains_arf, libflint), Cint, (Ref{RealFieldElem}, Ref{arf}), x, y) +# r = @ccall libflint.arb_contains_arf(x::Ref{RealFieldElem}, y::Ref{arf})::Cint # return Bool(r) #end @@ -213,7 +207,7 @@ Returns `true` if the ball $x$ contains the given rational value, otherwise return `false`. """ function contains(x::RealFieldElem, y::QQFieldElem) - r = ccall((:arb_contains_fmpq, libflint), Cint, (Ref{RealFieldElem}, Ref{QQFieldElem}), x, y) + r = @ccall libflint.arb_contains_fmpq(x::Ref{RealFieldElem}, y::Ref{QQFieldElem})::Cint return Bool(r) end @@ -224,12 +218,12 @@ Returns `true` if the ball $x$ contains the given integer value, otherwise return `false`. """ function contains(x::RealFieldElem, y::ZZRingElem) - r = ccall((:arb_contains_fmpz, libflint), Cint, (Ref{RealFieldElem}, Ref{ZZRingElem}), x, y) + r = @ccall libflint.arb_contains_fmpz(x::Ref{RealFieldElem}, y::Ref{ZZRingElem})::Cint return Bool(r) end function contains(x::RealFieldElem, y::Int) - r = ccall((:arb_contains_si, libflint), Cint, (Ref{RealFieldElem}, Int), x, y) + r = @ccall libflint.arb_contains_si(x::Ref{RealFieldElem}, y::Int)::Cint return Bool(r) end @@ -256,8 +250,7 @@ Returns `true` if the ball $x$ contains the given floating point value, otherwise return `false`. """ function contains(x::RealFieldElem, y::BigFloat) - r = ccall((:arb_contains_mpfr, libflint), Cint, - (Ref{RealFieldElem}, Ref{BigFloat}), x, y) + r = @ccall libflint.arb_contains_mpfr(x::Ref{RealFieldElem}, y::Ref{BigFloat})::Cint return Bool(r) end @@ -268,7 +261,7 @@ Returns `true` if the ball $x$ contains the ball $y$, otherwise return `false`. """ function contains(x::RealFieldElem, y::RealFieldElem) - r = ccall((:arb_contains, libflint), Cint, (Ref{RealFieldElem}, Ref{RealFieldElem}), x, y) + r = @ccall libflint.arb_contains(x::Ref{RealFieldElem}, y::Ref{RealFieldElem})::Cint return Bool(r) end @@ -278,7 +271,7 @@ end Returns `true` if the ball $x$ contains zero, otherwise return `false`. """ function contains_zero(x::RealFieldElem) - r = ccall((:arb_contains_zero, libflint), Cint, (Ref{RealFieldElem}, ), x) + r = @ccall libflint.arb_contains_zero(x::Ref{RealFieldElem})::Cint return Bool(r) end @@ -289,7 +282,7 @@ Returns `true` if the ball $x$ contains any negative value, otherwise return `false`. """ function contains_negative(x::RealFieldElem) - r = ccall((:arb_contains_negative, libflint), Cint, (Ref{RealFieldElem}, ), x) + r = @ccall libflint.arb_contains_negative(x::Ref{RealFieldElem})::Cint return Bool(r) end @@ -300,7 +293,7 @@ Returns `true` if the ball $x$ contains any positive value, otherwise return `false`. """ function contains_positive(x::RealFieldElem) - r = ccall((:arb_contains_positive, libflint), Cint, (Ref{RealFieldElem}, ), x) + r = @ccall libflint.arb_contains_positive(x::Ref{RealFieldElem})::Cint return Bool(r) end @@ -311,7 +304,7 @@ Returns `true` if the ball $x$ contains any non-negative value, otherwise return `false`. """ function contains_nonnegative(x::RealFieldElem) - r = ccall((:arb_contains_nonnegative, libflint), Cint, (Ref{RealFieldElem}, ), x) + r = @ccall libflint.arb_contains_nonnegative(x::Ref{RealFieldElem})::Cint return Bool(r) end @@ -322,7 +315,7 @@ Returns `true` if the ball $x$ contains any nonpositive value, otherwise return `false`. """ function contains_nonpositive(x::RealFieldElem) - r = ccall((:arb_contains_nonpositive, libflint), Cint, (Ref{RealFieldElem}, ), x) + r = @ccall libflint.arb_contains_nonpositive(x::Ref{RealFieldElem})::Cint return Bool(r) end @@ -339,24 +332,24 @@ Return `true` if the balls $x$ and $y$ are precisely equal, i.e. have the same midpoints and radii. """ function isequal(x::RealFieldElem, y::RealFieldElem) - r = ccall((:arb_equal, libflint), Cint, (Ref{RealFieldElem}, Ref{RealFieldElem}), x, y) + r = @ccall libflint.arb_equal(x::Ref{RealFieldElem}, y::Ref{RealFieldElem})::Cint return Bool(r) end function ==(x::RealFieldElem, y::RealFieldElem) - return Bool(ccall((:arb_eq, libflint), Cint, (Ref{RealFieldElem}, Ref{RealFieldElem}), x, y)) + return Bool(@ccall libflint.arb_eq(x::Ref{RealFieldElem}, y::Ref{RealFieldElem})::Cint) end function !=(x::RealFieldElem, y::RealFieldElem) - return Bool(ccall((:arb_ne, libflint), Cint, (Ref{RealFieldElem}, Ref{RealFieldElem}), x, y)) + return Bool(@ccall libflint.arb_ne(x::Ref{RealFieldElem}, y::Ref{RealFieldElem})::Cint) end function isless(x::RealFieldElem, y::RealFieldElem) - return Bool(ccall((:arb_lt, libflint), Cint, (Ref{RealFieldElem}, Ref{RealFieldElem}), x, y)) + return Bool(@ccall libflint.arb_lt(x::Ref{RealFieldElem}, y::Ref{RealFieldElem})::Cint) end function <=(x::RealFieldElem, y::RealFieldElem) - return Bool(ccall((:arb_le, libflint), Cint, (Ref{RealFieldElem}, Ref{RealFieldElem}), x, y)) + return Bool(@ccall libflint.arb_le(x::Ref{RealFieldElem}, y::Ref{RealFieldElem})::Cint) end ==(x::RealFieldElem, y::Int) = x == RealFieldElem(y) @@ -446,7 +439,7 @@ end Return `true` if $x$ is certainly zero, otherwise return `false`. """ function iszero(x::RealFieldElem) - return Bool(ccall((:arb_is_zero, libflint), Cint, (Ref{RealFieldElem},), x)) + return Bool(@ccall libflint.arb_is_zero(x::Ref{RealFieldElem})::Cint) end @doc raw""" @@ -456,7 +449,7 @@ Return `true` if $x$ is certainly not equal to zero, otherwise return `false`. """ function is_nonzero(x::RealFieldElem) - return Bool(ccall((:arb_is_nonzero, libflint), Cint, (Ref{RealFieldElem},), x)) + return Bool(@ccall libflint.arb_is_nonzero(x::Ref{RealFieldElem})::Cint) end @doc raw""" @@ -465,7 +458,7 @@ end Return `true` if $x$ is certainly one, otherwise return `false`. """ function isone(x::RealFieldElem) - return Bool(ccall((:arb_is_one, libflint), Cint, (Ref{RealFieldElem},), x)) + return Bool(@ccall libflint.arb_is_one(x::Ref{RealFieldElem})::Cint) end @doc raw""" @@ -475,7 +468,7 @@ Return `true` if $x$ is finite, i.e. having finite midpoint and radius, otherwise return `false`. """ function isfinite(x::RealFieldElem) - return Bool(ccall((:arb_is_finite, libflint), Cint, (Ref{RealFieldElem},), x)) + return Bool(@ccall libflint.arb_is_finite(x::Ref{RealFieldElem})::Cint) end @doc raw""" @@ -485,7 +478,7 @@ Return `true` if $x$ is exact, i.e. has zero radius, otherwise return `false`. """ function is_exact(x::RealFieldElem) - return Bool(ccall((:arb_is_exact, libflint), Cint, (Ref{RealFieldElem},), x)) + return Bool(@ccall libflint.arb_is_exact(x::Ref{RealFieldElem})::Cint) end @doc raw""" @@ -494,7 +487,7 @@ end Return `true` if $x$ is an exact integer, otherwise return `false`. """ function isinteger(x::RealFieldElem) - return Bool(ccall((:arb_is_int, libflint), Cint, (Ref{RealFieldElem},), x)) + return Bool(@ccall libflint.arb_is_int(x::Ref{RealFieldElem})::Cint) end @doc raw""" @@ -503,7 +496,7 @@ end Return `true` if $x$ is certainly positive, otherwise return `false`. """ function is_positive(x::RealFieldElem) - return Bool(ccall((:arb_is_positive, libflint), Cint, (Ref{RealFieldElem},), x)) + return Bool(@ccall libflint.arb_is_positive(x::Ref{RealFieldElem})::Cint) end @doc raw""" @@ -512,7 +505,7 @@ end Return `true` if $x$ is certainly non-negative, otherwise return `false`. """ function is_nonnegative(x::RealFieldElem) - return Bool(ccall((:arb_is_nonnegative, libflint), Cint, (Ref{RealFieldElem},), x)) + return Bool(@ccall libflint.arb_is_nonnegative(x::Ref{RealFieldElem})::Cint) end @doc raw""" @@ -521,7 +514,7 @@ end Return `true` if $x$ is certainly negative, otherwise return `false`. """ function is_negative(x::RealFieldElem) - return Bool(ccall((:arb_is_negative, libflint), Cint, (Ref{RealFieldElem},), x)) + return Bool(@ccall libflint.arb_is_negative(x::Ref{RealFieldElem})::Cint) end @doc raw""" @@ -530,7 +523,7 @@ end Return `true` if $x$ is certainly nonpositive, otherwise return `false`. """ function is_nonpositive(x::RealFieldElem) - return Bool(ccall((:arb_is_nonpositive, libflint), Cint, (Ref{RealFieldElem},), x)) + return Bool(@ccall libflint.arb_is_nonpositive(x::Ref{RealFieldElem})::Cint) end ################################################################################ @@ -557,7 +550,7 @@ Return the radius of the ball $x$ as an Arb ball. """ function radius(x::RealFieldElem) z = RealFieldElem() - ccall((:arb_get_rad_arb, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}), z, x) + @ccall libflint.arb_get_rad_arb(z::Ref{RealFieldElem}, x::Ref{RealFieldElem})::Nothing return z end @@ -568,7 +561,7 @@ Return the midpoint of the ball $x$ as an Arb ball. """ function midpoint(x::RealFieldElem) z = RealFieldElem() - ccall((:arb_get_mid_arb, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}), z, x) + @ccall libflint.arb_get_mid_arb(z::Ref{RealFieldElem}, x::Ref{RealFieldElem})::Nothing return z end @@ -578,7 +571,7 @@ end Adds the absolute values of the midpoint and radius of $y$ to the radius of $x$. """ function add_error!(x::RealFieldElem, y::RealFieldElem) - ccall((:arb_add_error, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}), x, y) + @ccall libflint.arb_add_error(x::Ref{RealFieldElem}, y::Ref{RealFieldElem})::Nothing end ################################################################################ @@ -660,8 +653,7 @@ end function -(x::RealFieldElem, y::UInt, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_sub_ui, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, UInt, Int), z, x, y, prec) + @ccall libflint.arb_sub_ui(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::UInt, prec::Int)::Nothing return z end @@ -669,8 +661,7 @@ end function -(x::RealFieldElem, y::Int, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_sub_si, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Int, Int), z, x, y, prec) + @ccall libflint.arb_sub_si(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Int, prec::Int)::Nothing return z end @@ -678,9 +669,7 @@ end function -(x::RealFieldElem, y::ZZRingElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_sub_fmpz, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{ZZRingElem}, Int), - z, x, y, prec) + @ccall libflint.arb_sub_fmpz(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Ref{ZZRingElem}, prec::Int)::Nothing return z end @@ -711,61 +700,51 @@ end function //(x::RealFieldElem, y::UInt, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_div_ui, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, UInt, Int), z, x, y, prec) + @ccall libflint.arb_div_ui(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::UInt, prec::Int)::Nothing return z end function //(x::RealFieldElem, y::Int, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_div_si, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Int, Int), z, x, y, prec) + @ccall libflint.arb_div_si(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Int, prec::Int)::Nothing return z end function //(x::RealFieldElem, y::ZZRingElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_div_fmpz, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{ZZRingElem}, Int), - z, x, y, prec) + @ccall libflint.arb_div_fmpz(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Ref{ZZRingElem}, prec::Int)::Nothing return z end function //(x::UInt, y::RealFieldElem, prec::Int = precision(Balls)) z = parent(y)() - ccall((:arb_ui_div, libflint), Nothing, - (Ref{RealFieldElem}, UInt, Ref{RealFieldElem}, Int), z, x, y, prec) + @ccall libflint.arb_ui_div(z::Ref{RealFieldElem}, x::UInt, y::Ref{RealFieldElem}, prec::Int)::Nothing return z end function //(x::Int, y::RealFieldElem, prec::Int = precision(Balls)) z = parent(y)() t = RealFieldElem(x) - ccall((:arb_div, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, t, y, prec) + @ccall libflint.arb_div(z::Ref{RealFieldElem}, t::Ref{RealFieldElem}, y::Ref{RealFieldElem}, prec::Int)::Nothing return z end function //(x::ZZRingElem, y::RealFieldElem, prec::Int = precision(Balls)) z = parent(y)() t = RealFieldElem(x) - ccall((:arb_div, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, t, y, prec) + @ccall libflint.arb_div(z::Ref{RealFieldElem}, t::Ref{RealFieldElem}, y::Ref{RealFieldElem}, prec::Int)::Nothing return z end function ^(x::RealFieldElem, y::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_pow, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, y, prec) + @ccall libflint.arb_pow(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Ref{RealFieldElem}, prec::Int)::Nothing return z end function ^(x::RealFieldElem, y::ZZRingElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_pow_fmpz, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{ZZRingElem}, Int), - z, x, y, prec) + @ccall libflint.arb_pow_fmpz(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Ref{ZZRingElem}, prec::Int)::Nothing return z end @@ -773,16 +752,13 @@ end function ^(x::RealFieldElem, y::UInt, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_pow_ui, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, UInt, Int), z, x, y, prec) + @ccall libflint.arb_pow_ui(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::UInt, prec::Int)::Nothing return z end function ^(x::RealFieldElem, y::QQFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_pow_fmpq, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{QQFieldElem}, Int), - z, x, y, prec) + @ccall libflint.arb_pow_fmpq(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Ref{QQFieldElem}, prec::Int)::Nothing return z end @@ -869,7 +845,7 @@ divexact(x::RealFieldElem, y::Rational{T}; check::Bool=true) where {T <: Integer function abs(x::RealFieldElem) z = RealFieldElem() - ccall((:arb_abs, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}), z, x) + @ccall libflint.arb_abs(z::Ref{RealFieldElem}, x::Ref{RealFieldElem})::Nothing return z end @@ -881,8 +857,7 @@ end function inv(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_inv, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_inv(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return parent(x)(z) end @@ -894,15 +869,13 @@ end function ldexp(x::RealFieldElem, y::Int) z = RealFieldElem() - ccall((:arb_mul_2exp_si, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, y) + @ccall libflint.arb_mul_2exp_si(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Int)::Nothing return z end function ldexp(x::RealFieldElem, y::ZZRingElem) z = RealFieldElem() - ccall((:arb_mul_2exp_fmpz, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.arb_mul_2exp_fmpz(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Ref{ZZRingElem})::Nothing return z end @@ -920,7 +893,7 @@ by rounding off insignificant bits from the midpoint. """ function trim(x::RealFieldElem) z = RealFieldElem() - ccall((:arb_trim, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}), z, x) + @ccall libflint.arb_trim(z::Ref{RealFieldElem}, x::Ref{RealFieldElem})::Nothing return z end @@ -934,8 +907,7 @@ integer. """ function unique_integer(x::RealFieldElem) z = ZZRingElem() - unique = ccall((:arb_get_unique_fmpz, libflint), Int, - (Ref{ZZRingElem}, Ref{RealFieldElem}), z, x) + unique = @ccall libflint.arb_get_unique_fmpz(z::Ref{ZZRingElem}, x::Ref{RealFieldElem})::Int return (unique != 0, z) end @@ -951,8 +923,7 @@ $y$. """ function setunion(x::RealFieldElem, y::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_union, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, y, prec) + @ccall libflint.arb_union(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -964,8 +935,7 @@ $x$ and $y$. """ function setintersection(x::RealFieldElem, y::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_intersection, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, y, prec) + @ccall libflint.arb_intersection(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -982,7 +952,7 @@ Return $\pi = 3.14159\ldots$ as an element of $r$. """ function const_pi(r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_const_pi, libflint), Nothing, (Ref{RealFieldElem}, Int), z, prec) + @ccall libflint.arb_const_pi(z::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -993,7 +963,7 @@ Return $e = 2.71828\ldots$ as an element of $r$. """ function const_e(r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_const_e, libflint), Nothing, (Ref{RealFieldElem}, Int), z, prec) + @ccall libflint.arb_const_e(z::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1004,7 +974,7 @@ Return $\log(2) = 0.69314\ldots$ as an element of $r$. """ function const_log2(r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_const_log2, libflint), Nothing, (Ref{RealFieldElem}, Int), z, prec) + @ccall libflint.arb_const_log2(z::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1015,7 +985,7 @@ Return $\log(10) = 2.302585\ldots$ as an element of $r$. """ function const_log10(r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_const_log10, libflint), Nothing, (Ref{RealFieldElem}, Int), z, prec) + @ccall libflint.arb_const_log10(z::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1026,7 +996,7 @@ Return Euler's constant $\gamma = 0.577215\ldots$ as an element of $r$. """ function const_euler(r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_const_euler, libflint), Nothing, (Ref{RealFieldElem}, Int), z, prec) + @ccall libflint.arb_const_euler(z::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1037,7 +1007,7 @@ Return Catalan's constant $C = 0.915965\ldots$ as an element of $r$. """ function const_catalan(r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_const_catalan, libflint), Nothing, (Ref{RealFieldElem}, Int), z, prec) + @ccall libflint.arb_const_catalan(z::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1048,7 +1018,7 @@ Return Khinchin's constant $K = 2.685452\ldots$ as an element of $r$. """ function const_khinchin(r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_const_khinchin, libflint), Nothing, (Ref{RealFieldElem}, Int), z, prec) + @ccall libflint.arb_const_khinchin(z::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1059,7 +1029,7 @@ Return Glaisher's constant $A = 1.282427\ldots$ as an element of $r$. """ function const_glaisher(r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_const_glaisher, libflint), Nothing, (Ref{RealFieldElem}, Int), z, prec) + @ccall libflint.arb_const_glaisher(z::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1073,7 +1043,7 @@ end function floor(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_floor, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_floor(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1083,7 +1053,7 @@ floor(::Type{T}, x::RealFieldElem) where {T <: Integer} = T(floor(x)) function ceil(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_ceil, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_ceil(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1093,7 +1063,7 @@ ceil(::Type{T}, x::RealFieldElem) where {T <: Integer} = T(ceil(x)) function Base.sqrt(x::RealFieldElem, prec::Int = precision(Balls); check::Bool=true) z = RealFieldElem() - ccall((:arb_sqrt, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_sqrt(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1104,7 +1074,7 @@ Return the reciprocal of the square root of $x$, i.e. $1/\sqrt{x}$. """ function rsqrt(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_rsqrt, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_rsqrt(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1115,7 +1085,7 @@ Return $\sqrt{1+x}-1$, evaluated accurately for small $x$. """ function sqrt1pm1(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_sqrt1pm1, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_sqrt1pm1(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1127,139 +1097,139 @@ number. Thus any negative number in the input interval is discarded. """ function sqrtpos(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_sqrtpos, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_sqrtpos(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function log(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_log, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_log(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function log1p(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_log1p, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_log1p(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function Base.exp(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_exp, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_exp(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function expm1(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_expm1, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_expm1(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function sin(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_sin, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_sin(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function cos(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_cos, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_cos(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function sinpi(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_sin_pi, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_sin_pi(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function cospi(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_cos_pi, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_cos_pi(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function tan(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_tan, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_tan(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function cot(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_cot, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_cot(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function tanpi(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_tan_pi, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_tan_pi(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function cotpi(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_cot_pi, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_cot_pi(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function sinh(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_sinh, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_sinh(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function cosh(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_cosh, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_cosh(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function tanh(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_tanh, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_tanh(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function coth(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_coth, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_coth(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function atan(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_atan, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_atan(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function asin(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_asin, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_asin(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function acos(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_acos, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_acos(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function atanh(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_atanh, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_atanh(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function asinh(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_asinh, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_asinh(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function acosh(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_acosh, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_acosh(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1270,7 +1240,7 @@ Return the Gamma function evaluated at $x$. """ function gamma(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_gamma, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_gamma(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1281,7 +1251,7 @@ Return the logarithm of the Gamma function evaluated at $x$. """ function lgamma(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_lgamma, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_lgamma(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1292,7 +1262,7 @@ Return the reciprocal of the Gamma function evaluated at $x$. """ function rgamma(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_rgamma, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_rgamma(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1304,7 +1274,7 @@ i.e. $\psi(x)$. """ function digamma(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_digamma, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_digamma(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1315,8 +1285,7 @@ Return the upper incomplete gamma function $\Gamma(s,x)$. """ function gamma(s::RealFieldElem, x::RealFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:arb_hypgeom_gamma_upper, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int, Int), z, s, x, 0, prec) + @ccall libflint.arb_hypgeom_gamma_upper(z::Ref{RealFieldElem}, s::Ref{RealFieldElem}, x::Ref{RealFieldElem}, 0::Int, prec::Int)::Nothing return z end @@ -1328,8 +1297,7 @@ $\Gamma(s,x) / \Gamma(s)$. """ function gamma_regularized(s::RealFieldElem, x::RealFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:arb_hypgeom_gamma_upper, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int, Int), z, s, x, 1, prec) + @ccall libflint.arb_hypgeom_gamma_upper(z::Ref{RealFieldElem}, s::Ref{RealFieldElem}, x::Ref{RealFieldElem}, 1::Int, prec::Int)::Nothing return z end @@ -1340,8 +1308,7 @@ Return the lower incomplete gamma function $\gamma(s,x) / \Gamma(s)$. """ function gamma_lower(s::RealFieldElem, x::RealFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:arb_hypgeom_gamma_lower, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int, Int), z, s, x, 0, prec) + @ccall libflint.arb_hypgeom_gamma_lower(z::Ref{RealFieldElem}, s::Ref{RealFieldElem}, x::Ref{RealFieldElem}, 0::Int, prec::Int)::Nothing return z end @@ -1353,8 +1320,7 @@ $\gamma(s,x) / \Gamma(s)$. """ function gamma_lower_regularized(s::RealFieldElem, x::RealFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:arb_hypgeom_gamma_lower, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int, Int), z, s, x, 1, prec) + @ccall libflint.arb_hypgeom_gamma_lower(z::Ref{RealFieldElem}, s::Ref{RealFieldElem}, x::Ref{RealFieldElem}, 1::Int, prec::Int)::Nothing return z end @@ -1366,60 +1332,53 @@ Return the Riemann zeta function evaluated at $x$. """ function zeta(x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_zeta, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, prec) + @ccall libflint.arb_zeta(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function sincos(x::RealFieldElem, prec::Int = precision(Balls)) s = RealFieldElem() c = RealFieldElem() - ccall((:arb_sin_cos, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), s, c, x, prec) + @ccall libflint.arb_sin_cos(s::Ref{RealFieldElem}, c::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return (s, c) end function sincospi(x::RealFieldElem, prec::Int = precision(Balls)) s = RealFieldElem() c = RealFieldElem() - ccall((:arb_sin_cos_pi, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), s, c, x, prec) + @ccall libflint.arb_sin_cos_pi(s::Ref{RealFieldElem}, c::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return (s, c) end function sinpi(x::QQFieldElem, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_sin_pi_fmpq, libflint), Nothing, - (Ref{RealFieldElem}, Ref{QQFieldElem}, Int), z, x, prec) + @ccall libflint.arb_sin_pi_fmpq(z::Ref{RealFieldElem}, x::Ref{QQFieldElem}, prec::Int)::Nothing return z end function cospi(x::QQFieldElem, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_cos_pi_fmpq, libflint), Nothing, - (Ref{RealFieldElem}, Ref{QQFieldElem}, Int), z, x, prec) + @ccall libflint.arb_cos_pi_fmpq(z::Ref{RealFieldElem}, x::Ref{QQFieldElem}, prec::Int)::Nothing return z end function sincospi(x::QQFieldElem, r::RealField, prec::Int = precision(Balls)) s = r() c = r() - ccall((:arb_sin_cos_pi_fmpq, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{QQFieldElem}, Int), s, c, x, prec) + @ccall libflint.arb_sin_cos_pi_fmpq(s::Ref{RealFieldElem}, c::Ref{RealFieldElem}, x::Ref{QQFieldElem}, prec::Int)::Nothing return (s, c) end function sinhcosh(x::RealFieldElem, prec::Int = precision(Balls)) s = RealFieldElem() c = RealFieldElem() - ccall((:arb_sinh_cosh, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), s, c, x, prec) + @ccall libflint.arb_sinh_cosh(s::Ref{RealFieldElem}, c::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return (s, c) end function atan(y::RealFieldElem, x::RealFieldElem, prec::Int = precision(Balls)) z = parent(y)() - ccall((:arb_atan2, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, y, x, prec) + @ccall libflint.arb_atan2(z::Ref{RealFieldElem}, y::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1439,8 +1398,7 @@ Return the arithmetic-geometric mean of $x$ and $y$ """ function agm(x::RealFieldElem, y::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_agm, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, y, prec) + @ccall libflint.arb_agm(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1451,22 +1409,19 @@ Return the Hurwitz zeta function $\zeta(s,a)$. """ function zeta(s::RealFieldElem, a::RealFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:arb_hurwitz_zeta, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, s, a, prec) + @ccall libflint.arb_hurwitz_zeta(z::Ref{RealFieldElem}, s::Ref{RealFieldElem}, a::Ref{RealFieldElem}, prec::Int)::Nothing return z end function hypot(x::RealFieldElem, y::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_hypot, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, x, y, prec) + @ccall libflint.arb_hypot(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, y::Ref{RealFieldElem}, prec::Int)::Nothing return z end function root(x::RealFieldElem, n::UInt, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_root, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, UInt, Int), z, x, n, prec) + @ccall libflint.arb_root(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, n::UInt, prec::Int)::Nothing return z end @@ -1489,7 +1444,7 @@ factorial(x::RealFieldElem, prec::Int = precision(Balls)) = gamma(x+1) function factorial(n::UInt, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_fac_ui, libflint), Nothing, (Ref{RealFieldElem}, UInt, Int), z, n, prec) + @ccall libflint.arb_fac_ui(z::Ref{RealFieldElem}, n::UInt, prec::Int)::Nothing return z end @@ -1507,8 +1462,7 @@ Return the binomial coefficient ${x \choose n}$. """ function binomial(x::RealFieldElem, n::UInt, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_bin_ui, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, UInt, Int), z, x, n, prec) + @ccall libflint.arb_bin_ui(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, n::UInt, prec::Int)::Nothing return z end @@ -1519,8 +1473,7 @@ Return the binomial coefficient ${n \choose k}$ in the given Arb field. """ function binomial(n::UInt, k::UInt, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_bin_uiui, libflint), Nothing, - (Ref{RealFieldElem}, UInt, UInt, Int), z, n, k, prec) + @ccall libflint.arb_bin_uiui(z::Ref{RealFieldElem}, n::UInt, k::UInt, prec::Int)::Nothing return z end @@ -1531,15 +1484,13 @@ Return the $n$-th Fibonacci number in the given Arb field. """ function fibonacci(n::ZZRingElem, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_fib_fmpz, libflint), Nothing, - (Ref{RealFieldElem}, Ref{ZZRingElem}, Int), z, n, prec) + @ccall libflint.arb_fib_fmpz(z::Ref{RealFieldElem}, n::Ref{ZZRingElem}, prec::Int)::Nothing return z end function fibonacci(n::UInt, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_fib_ui, libflint), Nothing, - (Ref{RealFieldElem}, UInt, Int), z, n, prec) + @ccall libflint.arb_fib_ui(z::Ref{RealFieldElem}, n::UInt, prec::Int)::Nothing return z end @@ -1557,8 +1508,7 @@ Return the Gamma function evaluated at $x$ in the given Arb field. """ function gamma(x::ZZRingElem, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_gamma_fmpz, libflint), Nothing, - (Ref{RealFieldElem}, Ref{ZZRingElem}, Int), z, x, prec) + @ccall libflint.arb_gamma_fmpz(z::Ref{RealFieldElem}, x::Ref{ZZRingElem}, prec::Int)::Nothing return z end @@ -1569,16 +1519,14 @@ Return the Gamma function evaluated at $x$ in the given Arb field. """ function gamma(x::QQFieldElem, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_gamma_fmpq, libflint), Nothing, - (Ref{RealFieldElem}, Ref{QQFieldElem}, Int), z, x, prec) + @ccall libflint.arb_gamma_fmpq(z::Ref{RealFieldElem}, x::Ref{QQFieldElem}, prec::Int)::Nothing return z end function zeta(n::UInt, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_zeta_ui, libflint), Nothing, - (Ref{RealFieldElem}, UInt, Int), z, n, prec) + @ccall libflint.arb_zeta_ui(z::Ref{RealFieldElem}, n::UInt, prec::Int)::Nothing return z end @@ -1592,8 +1540,7 @@ zeta(n::Int, r::RealField, prec::Int = precision(Balls)) = n >= 0 ? zeta(UInt(n) function bernoulli(n::UInt, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_bernoulli_ui, libflint), Nothing, - (Ref{RealFieldElem}, UInt, Int), z, n, prec) + @ccall libflint.arb_bernoulli_ui(z::Ref{RealFieldElem}, n::UInt, prec::Int)::Nothing return z end @@ -1606,8 +1553,7 @@ bernoulli(n::Int, r::RealField, prec::Int = precision(Balls)) = n >= 0 ? bernoul function rising_factorial(x::RealFieldElem, n::UInt, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_rising_ui, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, UInt, Int), z, x, n, prec) + @ccall libflint.arb_rising_ui(z::Ref{RealFieldElem}, x::Ref{RealFieldElem}, n::UInt, prec::Int)::Nothing return z end @@ -1620,8 +1566,7 @@ rising_factorial(x::RealFieldElem, n::Int, prec::Int = precision(Balls)) = n < 0 function rising_factorial(x::QQFieldElem, n::UInt, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_rising_fmpq_ui, libflint), Nothing, - (Ref{RealFieldElem}, Ref{QQFieldElem}, UInt, Int), z, x, n, prec) + @ccall libflint.arb_rising_fmpq_ui(z::Ref{RealFieldElem}, x::Ref{QQFieldElem}, n::UInt, prec::Int)::Nothing return z end @@ -1636,8 +1581,7 @@ rising_factorial(x::QQFieldElem, n::Int, r::RealField, prec::Int = precision(Bal function rising_factorial2(x::RealFieldElem, n::UInt, prec::Int = precision(Balls)) z = RealFieldElem() w = RealFieldElem() - ccall((:arb_rising2_ui, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, UInt, Int), z, w, x, n, prec) + @ccall libflint.arb_rising2_ui(z::Ref{RealFieldElem}, w::Ref{RealFieldElem}, x::Ref{RealFieldElem}, n::UInt, prec::Int)::Nothing return (z, w) end @@ -1651,15 +1595,13 @@ rising_factorial2(x::RealFieldElem, n::Int, prec::Int = precision(Balls)) = n < function polylog(s::RealFieldElem, a::RealFieldElem, prec::Int = precision(Balls)) z = parent(s)() - ccall((:arb_polylog, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), z, s, a, prec) + @ccall libflint.arb_polylog(z::Ref{RealFieldElem}, s::Ref{RealFieldElem}, a::Ref{RealFieldElem}, prec::Int)::Nothing return z end function polylog(s::Int, a::RealFieldElem, prec::Int = precision(Balls)) z = parent(a)() - ccall((:arb_polylog_si, libflint), Nothing, - (Ref{RealFieldElem}, Int, Ref{RealFieldElem}, Int), z, s, a, prec) + @ccall libflint.arb_polylog_si(z::Ref{RealFieldElem}, s::Int, a::Ref{RealFieldElem}, prec::Int)::Nothing return z end @@ -1671,31 +1613,27 @@ Return the polylogarithm Li$_s(a)$. function chebyshev_t(n::UInt, x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_chebyshev_t_ui, libflint), Nothing, - (Ref{RealFieldElem}, UInt, Ref{RealFieldElem}, Int), z, n, x, prec) + @ccall libflint.arb_chebyshev_t_ui(z::Ref{RealFieldElem}, n::UInt, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function chebyshev_u(n::UInt, x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() - ccall((:arb_chebyshev_u_ui, libflint), Nothing, - (Ref{RealFieldElem}, UInt, Ref{RealFieldElem}, Int), z, n, x, prec) + @ccall libflint.arb_chebyshev_u_ui(z::Ref{RealFieldElem}, n::UInt, x::Ref{RealFieldElem}, prec::Int)::Nothing return z end function chebyshev_t2(n::UInt, x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() w = RealFieldElem() - ccall((:arb_chebyshev_t2_ui, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, UInt, Ref{RealFieldElem}, Int), z, w, n, x, prec) + @ccall libflint.arb_chebyshev_t2_ui(z::Ref{RealFieldElem}, w::Ref{RealFieldElem}, n::UInt, x::Ref{RealFieldElem}, prec::Int)::Nothing return z, w end function chebyshev_u2(n::UInt, x::RealFieldElem, prec::Int = precision(Balls)) z = RealFieldElem() w = RealFieldElem() - ccall((:arb_chebyshev_u2_ui, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, UInt, Ref{RealFieldElem}, Int), z, w, n, x, prec) + @ccall libflint.arb_chebyshev_u2_ui(z::Ref{RealFieldElem}, w::Ref{RealFieldElem}, n::UInt, x::Ref{RealFieldElem}, prec::Int)::Nothing return z, w end @@ -1734,8 +1672,7 @@ Return the Bell number $B_n$ as an element of $r$. """ function bell(n::ZZRingElem, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_bell_fmpz, libflint), Nothing, - (Ref{RealFieldElem}, Ref{ZZRingElem}, Int), z, n, prec) + @ccall libflint.arb_bell_fmpz(z::Ref{RealFieldElem}, n::Ref{ZZRingElem}, prec::Int)::Nothing return z end @@ -1753,8 +1690,7 @@ Return the number of partitions $p(n)$ as an element of $r$. """ function numpart(n::ZZRingElem, r::RealField, prec::Int = precision(Balls)) z = r() - ccall((:arb_partitions_fmpz, libflint), Nothing, - (Ref{RealFieldElem}, Ref{ZZRingElem}, Int), z, n, prec) + @ccall libflint.arb_partitions_fmpz(z::Ref{RealFieldElem}, n::Ref{ZZRingElem}, prec::Int)::Nothing return z end @@ -1778,9 +1714,7 @@ Return the Airy function $\operatorname{Ai}(x)$. """ function airy_ai(x::RealFieldElem, prec::Int = precision(Balls)) ai = RealFieldElem() - ccall((:arb_hypgeom_airy, libflint), Nothing, - (Ref{RealFieldElem}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ref{RealFieldElem}, Int), - ai, C_NULL, C_NULL, C_NULL, x, prec) + @ccall libflint.arb_hypgeom_airy(ai::Ref{RealFieldElem}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, x::Ref{RealFieldElem}, prec::Int)::Nothing return ai end @@ -1791,9 +1725,7 @@ Return the Airy function $\operatorname{Bi}(x)$. """ function airy_bi(x::RealFieldElem, prec::Int = precision(Balls)) bi = RealFieldElem() - ccall((:arb_hypgeom_airy, libflint), Nothing, - (Ptr{Cvoid}, Ptr{Cvoid}, Ref{RealFieldElem}, Ptr{Cvoid}, Ref{RealFieldElem}, Int), - C_NULL, C_NULL, bi, C_NULL, x, prec) + @ccall libflint.arb_hypgeom_airy(C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, bi::Ref{RealFieldElem}, C_NULL::Ptr{Cvoid}, x::Ref{RealFieldElem}, prec::Int)::Nothing return bi end @@ -1804,9 +1736,7 @@ Return the derivative of the Airy function $\operatorname{Ai}^\prime(x)$. """ function airy_ai_prime(x::RealFieldElem, prec::Int = precision(Balls)) ai_prime = RealFieldElem() - ccall((:arb_hypgeom_airy, libflint), Nothing, - (Ptr{Cvoid}, Ref{RealFieldElem}, Ptr{Cvoid}, Ptr{Cvoid}, Ref{RealFieldElem}, Int), - C_NULL, ai_prime, C_NULL, C_NULL, x, prec) + @ccall libflint.arb_hypgeom_airy(C_NULL::Ptr{Cvoid}, ai_prime::Ref{RealFieldElem}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, x::Ref{RealFieldElem}, prec::Int)::Nothing return ai_prime end @@ -1817,9 +1747,7 @@ Return the derivative of the Airy function $\operatorname{Bi}^\prime(x)$. """ function airy_bi_prime(x::RealFieldElem, prec::Int = precision(Balls)) bi_prime = RealFieldElem() - ccall((:arb_hypgeom_airy, libflint), Nothing, - (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ref{RealFieldElem}, Ref{RealFieldElem}, Int), - C_NULL, C_NULL, C_NULL, bi_prime, x, prec) + @ccall libflint.arb_hypgeom_airy(C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, bi_prime::Ref{RealFieldElem}, x::Ref{RealFieldElem}, prec::Int)::Nothing return bi_prime end @@ -1908,8 +1836,7 @@ function simplest_rational_inside(x::RealFieldElem) b = ZZRingElem() e = ZZRingElem() - ccall((:arb_get_interval_fmpz_2exp, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{RealFieldElem}), a, b, e, x) + @ccall libflint.arb_get_interval_fmpz_2exp(a::Ref{ZZRingElem}, b::Ref{ZZRingElem}, e::Ref{ZZRingElem}, x::Ref{RealFieldElem})::Nothing !fits(Int, e) && error("Result does not fit into an QQFieldElem") _e = Int(e) if e >= 0 @@ -1959,77 +1886,69 @@ end ################################################################################ function _arb_set(x::RealFieldElemOrPtr, y::Int) - ccall((:arb_set_si, libflint), Nothing, (Ref{RealFieldElem}, Int), x, y) + @ccall libflint.arb_set_si(x::Ref{RealFieldElem}, y::Int)::Nothing end function _arb_set(x::RealFieldElemOrPtr, y::UInt) - ccall((:arb_set_ui, libflint), Nothing, (Ref{RealFieldElem}, UInt), x, y) + @ccall libflint.arb_set_ui(x::Ref{RealFieldElem}, y::UInt)::Nothing end function _arb_set(x::RealFieldElemOrPtr, y::Float64) - ccall((:arb_set_d, libflint), Nothing, (Ref{RealFieldElem}, Float64), x, y) + @ccall libflint.arb_set_d(x::Ref{RealFieldElem}, y::Float64)::Nothing end function _arb_set(x::RealFieldElemOrPtr, y::Union{Int,UInt,Float64}, p::Int) _arb_set(x, y) - ccall((:arb_set_round, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), x, x, p) + @ccall libflint.arb_set_round(x::Ref{RealFieldElem}, x::Ref{RealFieldElem}, p::Int)::Nothing end function _arb_set(x::RealFieldElemOrPtr, y::ZZRingElem) - ccall((:arb_set_fmpz, libflint), Nothing, (Ref{RealFieldElem}, Ref{ZZRingElem}), x, y) + @ccall libflint.arb_set_fmpz(x::Ref{RealFieldElem}, y::Ref{ZZRingElem})::Nothing end function _arb_set(x::RealFieldElemOrPtr, y::ZZRingElem, p::Int) - ccall((:arb_set_round_fmpz, libflint), Nothing, - (Ref{RealFieldElem}, Ref{ZZRingElem}, Int), x, y, p) + @ccall libflint.arb_set_round_fmpz(x::Ref{RealFieldElem}, y::Ref{ZZRingElem}, p::Int)::Nothing end function _arb_set(x::RealFieldElemOrPtr, y::QQFieldElem, p::Int) - ccall((:arb_set_fmpq, libflint), Nothing, - (Ref{RealFieldElem}, Ref{QQFieldElem}, Int), x, y, p) + @ccall libflint.arb_set_fmpq(x::Ref{RealFieldElem}, y::Ref{QQFieldElem}, p::Int)::Nothing end function _arb_set(x::RealFieldElemOrPtr, y::RealFieldElemOrPtr) - ccall((:arb_set, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}), x, y) + @ccall libflint.arb_set(x::Ref{RealFieldElem}, y::Ref{RealFieldElem})::Nothing end function _arb_set(x::RealFieldElemOrPtr, y::Ptr{arb_struct}) - ccall((:arb_set, libflint), Nothing, (Ref{RealFieldElem}, Ptr{arb_struct}), x, y) + @ccall libflint.arb_set(x::Ref{RealFieldElem}, y::Ptr{arb_struct})::Nothing end function _arb_set(x::Ptr{arb_struct}, y::RealFieldElemOrPtr) - ccall((:arb_set, libflint), Nothing, (Ptr{arb_struct}, Ref{RealFieldElem}) , x, y) + @ccall libflint.arb_set(x::Ptr{arb_struct}, y::Ref{RealFieldElem})::Nothing end function _arb_set(x::RealFieldElemOrPtr, y::RealFieldElemOrPtr, p::Int) - ccall((:arb_set_round, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), x, y, p) + @ccall libflint.arb_set_round(x::Ref{RealFieldElem}, y::Ref{RealFieldElem}, p::Int)::Nothing end function _arb_set(x::RealFieldElemOrPtr, y::AbstractString, p::Int) s = string(y) - err = ccall((:arb_set_str, libflint), Int32, - (Ref{RealFieldElem}, Ptr{UInt8}, Int), x, s, p) + err = @ccall libflint.arb_set_str(x::Ref{RealFieldElem}, s::Ptr{UInt8}, p::Int)::Int32 err == 0 || error("Invalid real string: $(repr(s))") end function _arb_set(x::RealFieldElemOrPtr, y::BigFloat) m = _mid_ptr(x) r = _rad_ptr(x) - ccall((:arf_set_mpfr, libflint), Nothing, - (Ptr{arf_struct}, Ref{BigFloat}), m, y) - ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct}, ), r) + @ccall libflint.arf_set_mpfr(m::Ptr{arf_struct}, y::Ref{BigFloat})::Nothing + @ccall libflint.mag_zero(r::Ptr{mag_struct})::Nothing end function _arb_set(x::RealFieldElemOrPtr, y::BigFloat, p::Int) m = _mid_ptr(x) r = _rad_ptr(x) - ccall((:arf_set_mpfr, libflint), Nothing, - (Ptr{arf_struct}, Ref{BigFloat}), m, y) - ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct}, ), r) - ccall((:arb_set_round, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), x, x, p) + @ccall libflint.arf_set_mpfr(m::Ptr{arf_struct}, y::Ref{BigFloat})::Nothing + @ccall libflint.mag_zero(r::Ptr{mag_struct})::Nothing + @ccall libflint.arb_set_round(x::Ref{RealFieldElem}, x::Ref{RealFieldElem}, p::Int)::Nothing end function _arb_set(x::RealFieldElemOrPtr, y::Integer) @@ -2109,23 +2028,17 @@ function rand(r::RealField, prec::Int = precision(Balls); randtype::Symbol=:uran x = r() if randtype == :urandom - ccall((:arb_urandom, libflint), Nothing, - (Ref{RealFieldElem}, Ref{rand_ctx}, Int), x, state, prec) + @ccall libflint.arb_urandom(x::Ref{RealFieldElem}, state::Ref{rand_ctx}, prec::Int)::Nothing elseif randtype == :randtest - ccall((:arb_randtest, libflint), Nothing, - (Ref{RealFieldElem}, Ref{rand_ctx}, Int, Int), x, state, prec, 30) + @ccall libflint.arb_randtest(x::Ref{RealFieldElem}, state::Ref{rand_ctx}, prec::Int, 30::Int)::Nothing elseif randtype == :randtest_exact - ccall((:arb_randtest_exact, libflint), Nothing, - (Ref{RealFieldElem}, Ref{rand_ctx}, Int, Int), x, state, prec, 30) + @ccall libflint.arb_randtest_exact(x::Ref{RealFieldElem}, state::Ref{rand_ctx}, prec::Int, 30::Int)::Nothing elseif randtype == :randtest_precise - ccall((:arb_randtest_precise, libflint), Nothing, - (Ref{RealFieldElem}, Ref{rand_ctx}, Int, Int), x, state, prec, 30) + @ccall libflint.arb_randtest_precise(x::Ref{RealFieldElem}, state::Ref{rand_ctx}, prec::Int, 30::Int)::Nothing elseif randtype == :randtest_wide - ccall((:arb_randtest_wide, libflint), Nothing, - (Ref{RealFieldElem}, Ref{rand_ctx}, Int, Int), x, state, prec, 30) + @ccall libflint.arb_randtest_wide(x::Ref{RealFieldElem}, state::Ref{rand_ctx}, prec::Int, 30::Int)::Nothing elseif randtype == :randtest_special - ccall((:arb_randtest_special, libflint), Nothing, - (Ref{RealFieldElem}, Ref{rand_ctx}, Int, Int), x, state, prec, 30) + @ccall libflint.arb_randtest_special(x::Ref{RealFieldElem}, state::Ref{rand_ctx}, prec::Int, 30::Int)::Nothing else error("Arb random generation `" * String(randtype) * "` is not defined") end diff --git a/src/arb/RealMat.jl b/src/arb/RealMat.jl index f48e3f6db..5a8ffdcd4 100644 --- a/src/arb/RealMat.jl +++ b/src/arb/RealMat.jl @@ -77,7 +77,7 @@ number_of_columns(a::RealMatrix) = a.c function deepcopy_internal(x::RealMatrix, dict::IdDict) z = RealMatrix(nrows(x), ncols(x)) - ccall((:arb_mat_set, libflint), Nothing, (Ref{RealMatrix}, Ref{RealMatrix}), z, x) + @ccall libflint.arb_mat_set(z::Ref{RealMatrix}, x::Ref{RealMatrix})::Nothing return z end @@ -97,8 +97,7 @@ end function transpose(x::RealMatrix) z = similar(x, ncols(x), nrows(x)) - ccall((:arb_mat_transpose, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}), z, x) + @ccall libflint.arb_mat_transpose(z::Ref{RealMatrix}, x::Ref{RealMatrix})::Nothing return z end @@ -111,27 +110,21 @@ end function +(x::RealMatrix, y::RealMatrix) check_parent(x, y) z = similar(x) - ccall((:arb_mat_add, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealMatrix}, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_mat_add(z::Ref{RealMatrix}, x::Ref{RealMatrix}, y::Ref{RealMatrix}, precision(Balls)::Int)::Nothing return z end function -(x::RealMatrix, y::RealMatrix) check_parent(x, y) z = similar(x) - ccall((:arb_mat_sub, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealMatrix}, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_mat_sub(z::Ref{RealMatrix}, x::Ref{RealMatrix}, y::Ref{RealMatrix}, precision(Balls)::Int)::Nothing return z end function *(x::RealMatrix, y::RealMatrix) ncols(x) != nrows(y) && error("Matrices have wrong dimensions") z = similar(x, nrows(x), ncols(y)) - ccall((:arb_mat_mul, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealMatrix}, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_mat_mul(z::Ref{RealMatrix}, x::Ref{RealMatrix}, y::Ref{RealMatrix}, precision(Balls)::Int)::Nothing return z end @@ -144,17 +137,13 @@ end function ^(x::RealMatrix, y::UInt) nrows(x) != ncols(x) && error("Matrix must be square") z = similar(x) - ccall((:arb_mat_pow_ui, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}, UInt, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_mat_pow_ui(z::Ref{RealMatrix}, x::Ref{RealMatrix}, y::UInt, precision(Balls)::Int)::Nothing return z end function *(x::RealMatrix, y::Int) z = similar(x) - ccall((:arb_mat_scalar_mul_si, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}, Int, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_mat_scalar_mul_si(z::Ref{RealMatrix}, x::Ref{RealMatrix}, y::Int, precision(Balls)::Int)::Nothing return z end @@ -166,9 +155,7 @@ end function *(x::RealMatrix, y::ZZRingElem) z = similar(x) - ccall((:arb_mat_scalar_mul_fmpz, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}, Ref{ZZRingElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_mat_scalar_mul_fmpz(z::Ref{RealMatrix}, x::Ref{RealMatrix}, y::Ref{ZZRingElem}, precision(Balls)::Int)::Nothing return z end @@ -176,9 +163,7 @@ end function *(x::RealMatrix, y::ArbFieldElem) z = similar(x) - ccall((:arb_mat_scalar_mul_arb, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealFieldElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_mat_scalar_mul_arb(z::Ref{RealMatrix}, x::Ref{RealMatrix}, y::Ref{RealFieldElem}, precision(Balls)::Int)::Nothing return z end @@ -248,8 +233,7 @@ end function ldexp(x::RealMatrix, y::Int) z = similar(x) - ccall((:arb_mat_scalar_mul_2exp_si, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}, Int), z, x, y) + @ccall libflint.arb_mat_scalar_mul_2exp_si(z::Ref{RealMatrix}, x::Ref{RealMatrix}, y::Int)::Nothing return z end @@ -266,20 +250,19 @@ Return `true` if the matrices of balls $x$ and $y$ are precisely equal, i.e. if all matrix entries have the same midpoints and radii. """ function isequal(x::RealMatrix, y::RealMatrix) - r = ccall((:arb_mat_equal, libflint), Cint, - (Ref{RealMatrix}, Ref{RealMatrix}), x, y) + r = @ccall libflint.arb_mat_equal(x::Ref{RealMatrix}, y::Ref{RealMatrix})::Cint return Bool(r) end function ==(x::RealMatrix, y::RealMatrix) fl = check_parent(x, y, false) !fl && return false - r = ccall((:arb_mat_eq, libflint), Cint, (Ref{RealMatrix}, Ref{RealMatrix}), x, y) + r = @ccall libflint.arb_mat_eq(x::Ref{RealMatrix}, y::Ref{RealMatrix})::Cint return Bool(r) end function !=(x::RealMatrix, y::RealMatrix) - r = ccall((:arb_mat_ne, libflint), Cint, (Ref{RealMatrix}, Ref{RealMatrix}), x, y) + r = @ccall libflint.arb_mat_ne(x::Ref{RealMatrix}, y::Ref{RealMatrix})::Cint return Bool(r) end @@ -290,8 +273,7 @@ Returns `true` if all entries of $x$ overlap with the corresponding entry of $y$, otherwise return `false`. """ function overlaps(x::RealMatrix, y::RealMatrix) - r = ccall((:arb_mat_overlaps, libflint), Cint, - (Ref{RealMatrix}, Ref{RealMatrix}), x, y) + r = @ccall libflint.arb_mat_overlaps(x::Ref{RealMatrix}, y::Ref{RealMatrix})::Cint return Bool(r) end @@ -302,8 +284,7 @@ Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ function contains(x::RealMatrix, y::RealMatrix) - r = ccall((:arb_mat_contains, libflint), Cint, - (Ref{RealMatrix}, Ref{RealMatrix}), x, y) + r = @ccall libflint.arb_mat_contains(x::Ref{RealMatrix}, y::Ref{RealMatrix})::Cint return Bool(r) end @@ -320,8 +301,7 @@ Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ function contains(x::RealMatrix, y::ZZMatrix) - r = ccall((:arb_mat_contains_fmpz_mat, libflint), Cint, - (Ref{RealMatrix}, Ref{ZZMatrix}), x, y) + r = @ccall libflint.arb_mat_contains_fmpz_mat(x::Ref{RealMatrix}, y::Ref{ZZMatrix})::Cint return Bool(r) end @@ -333,8 +313,7 @@ Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ function contains(x::RealMatrix, y::QQMatrix) - r = ccall((:arb_mat_contains_fmpq_mat, libflint), Cint, - (Ref{RealMatrix}, Ref{QQMatrix}), x, y) + r = @ccall libflint.arb_mat_contains_fmpq_mat(x::Ref{RealMatrix}, y::Ref{QQMatrix})::Cint return Bool(r) end @@ -372,8 +351,7 @@ end function is_invertible_with_inverse(x::RealMatrix) ncols(x) != nrows(x) && return false, x z = similar(x) - r = ccall((:arb_mat_inv, libflint), Cint, - (Ref{RealMatrix}, Ref{RealMatrix}, Int), z, x, precision(Balls)) + r = @ccall libflint.arb_mat_inv(z::Ref{RealMatrix}, x::Ref{RealMatrix}, precision(Balls)::Int)::Cint return Bool(r), z end @@ -397,25 +375,19 @@ end function divexact(x::RealMatrix, y::Int; check::Bool=true) y == 0 && throw(DivideError()) z = similar(x) - ccall((:arb_mat_scalar_div_si, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}, Int, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_mat_scalar_div_si(z::Ref{RealMatrix}, x::Ref{RealMatrix}, y::Int, precision(Balls)::Int)::Nothing return z end function divexact(x::RealMatrix, y::ZZRingElem; check::Bool=true) z = similar(x) - ccall((:arb_mat_scalar_div_fmpz, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}, Ref{ZZRingElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_mat_scalar_div_fmpz(z::Ref{RealMatrix}, x::Ref{RealMatrix}, y::Ref{ZZRingElem}, precision(Balls)::Int)::Nothing return z end function divexact(x::RealMatrix, y::ArbFieldElem; check::Bool=true) z = similar(x) - ccall((:arb_mat_scalar_div_arb, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealFieldElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_mat_scalar_div_arb(z::Ref{RealMatrix}, x::Ref{RealMatrix}, y::Ref{RealFieldElem}, precision(Balls)::Int)::Nothing return z end @@ -428,8 +400,7 @@ end function charpoly(x::RealPolyRing, y::RealMatrix, prec::Int = precision(Balls)) base_ring(y) != base_ring(x) && error("Base rings must coincide") z = x() - ccall((:arb_mat_charpoly, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealMatrix}, Int), z, y, prec) + @ccall libflint.arb_mat_charpoly(z::Ref{RealPolyRingElem}, y::Ref{RealMatrix}, prec::Int)::Nothing return z end @@ -442,8 +413,7 @@ end function det(x::RealMatrix, prec::Int = precision(Balls)) ncols(x) != nrows(x) && error("Matrix must be square") z = base_ring(x)() - ccall((:arb_mat_det, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealMatrix}, Int), z, x, prec) + @ccall libflint.arb_mat_det(z::Ref{RealFieldElem}, x::Ref{RealMatrix}, prec::Int)::Nothing return z end @@ -456,8 +426,7 @@ end function Base.exp(x::RealMatrix) ncols(x) != nrows(x) && error("Matrix must be square") z = similar(x) - ccall((:arb_mat_exp, libflint), Nothing, - (Ref{RealMatrix}, Ref{RealMatrix}, Int), z, x, precision(Balls)) + @ccall libflint.arb_mat_exp(z::Ref{RealMatrix}, x::Ref{RealMatrix}, precision(Balls)::Int)::Nothing return z end @@ -470,9 +439,7 @@ end function lu!(P::Perm, z::RealMatrix, x::RealMatrix) parent(P).n != nrows(x) && error("Permutation does not match matrix") P.d .-= 1 - r = ccall((:arb_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{RealMatrix}, Ref{RealMatrix}, Int), - P.d, z, x, precision(Balls)) + r = @ccall libflint.arb_mat_lu(P.d::Ptr{Int}, z::Ref{RealMatrix}, x::Ref{RealMatrix}, precision(Balls)::Int)::Cint r == 0 && error("Could not find $(nrows(x)) invertible pivot elements") P.d .+= 1 inv!(P) @@ -484,18 +451,14 @@ function lu!(P::Perm, x::RealMatrix) end function _solve!(z::RealMatrix, x::RealMatrix, y::RealMatrix) - r = ccall((:arb_mat_solve, libflint), Cint, - (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealMatrix}, Int), - z, x, y, precision(Balls)) + r = @ccall libflint.arb_mat_solve(z::Ref{RealMatrix}, x::Ref{RealMatrix}, y::Ref{RealMatrix}, precision(Balls)::Int)::Cint r == 0 && error("Matrix cannot be inverted numerically") nothing end function _solve_lu_precomp!(z::RealMatrix, P::Perm, LU::RealMatrix, y::RealMatrix) Q = inv(P) - ccall((:arb_mat_solve_lu_precomp, libflint), Nothing, - (Ref{RealMatrix}, Ptr{Int}, Ref{RealMatrix}, Ref{RealMatrix}, Int), - z, Q.d .- 1, LU, y, precision(Balls)) + @ccall libflint.arb_mat_solve_lu_precomp(z::Ref{RealMatrix}, (Q.d .- 1)::Ptr{Int}, LU::Ref{RealMatrix}, y::Ref{RealMatrix}, precision(Balls)::Int)::Nothing nothing end @@ -608,9 +571,7 @@ function swap_rows(x::RealMatrix, i::Int, j::Int) end function swap_rows!(x::RealMatrix, i::Int, j::Int) - ccall((:arb_mat_swap_rows, libflint), Nothing, - (Ref{RealMatrix}, Ptr{Nothing}, Int, Int), - x, C_NULL, i - 1, j - 1) + @ccall libflint.arb_mat_swap_rows(x::Ref{RealMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int)::Nothing end ################################################################################ @@ -629,13 +590,10 @@ function bound_inf_norm(x::RealMatrix) z = RealFieldElem() GC.@preserve x z begin t = _rad_ptr(z) - ccall((:arb_mat_bound_inf_norm, libflint), Nothing, - (Ptr{mag_struct}, Ref{RealMatrix}), t, x) + @ccall libflint.arb_mat_bound_inf_norm(t::Ptr{mag_struct}, x::Ref{RealMatrix})::Nothing s = _mid_ptr(z) - ccall((:arf_set_mag, libflint), Nothing, - (Ptr{arf_struct}, Ptr{mag_struct}), s, t) - ccall((:mag_zero, libflint), Nothing, - (Ptr{mag_struct},), t) + @ccall libflint.arf_set_mag(s::Ptr{arf_struct}, t::Ptr{mag_struct})::Nothing + @ccall libflint.mag_zero(t::Ptr{mag_struct})::Nothing end return base_ring(x)(z) end @@ -804,8 +762,7 @@ end ################################################################################ @inline mat_entry_ptr(A::RealMatrix, i::Int, j::Int) = -ccall((:arb_mat_entry_ptr, libflint), - Ptr{RealFieldElem}, (Ref{RealMatrix}, Int, Int), A, i-1, j-1) +@ccall libflint.arb_mat_entry_ptr(A::Ref{RealMatrix}, (i-1)::Int, (j-1)::Int)::Ptr{RealFieldElem} ############################################################################### # diff --git a/src/arb/RealPoly.jl b/src/arb/RealPoly.jl index a2d5826b5..4473fb3b9 100644 --- a/src/arb/RealPoly.jl +++ b/src/arb/RealPoly.jl @@ -16,12 +16,10 @@ elem_type(::Type{RealPolyRing}) = RealPolyRingElem dense_poly_type(::Type{RealFieldElem}) = RealPolyRingElem -length(x::RealPolyRingElem) = ccall((:arb_poly_length, libflint), Int, - (Ref{RealPolyRingElem},), x) +length(x::RealPolyRingElem) = @ccall libflint.arb_poly_length(x::Ref{RealPolyRingElem})::Int function set_length!(x::RealPolyRingElem, n::Int) - ccall((:_arb_poly_set_length, libflint), Nothing, - (Ref{RealPolyRingElem}, Int), x, n) + @ccall libflint._arb_poly_set_length(x::Ref{RealPolyRingElem}, n::Int)::Nothing return x end @@ -30,8 +28,7 @@ degree(x::RealPolyRingElem) = length(x) - 1 function coeff(a::RealPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) t = base_ring(parent(a))() - ccall((:arb_poly_get_coeff_arb, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealPolyRingElem}, Int), t, a, n) + @ccall libflint.arb_poly_get_coeff_arb(t::Ref{RealFieldElem}, a::Ref{RealPolyRingElem}, n::Int)::Nothing return t end @@ -98,8 +95,7 @@ end ############################################################################### function isequal(x::RealPolyRingElem, y::RealPolyRingElem) - return ccall((:arb_poly_equal, libflint), Bool, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}), x, y) + return @ccall libflint.arb_poly_equal(x::Ref{RealPolyRingElem}, y::Ref{RealPolyRingElem})::Bool end @doc raw""" @@ -109,8 +105,7 @@ Return `true` if the coefficient balls of $x$ overlap the coefficient balls of $y$, otherwise return `false`. """ function overlaps(x::RealPolyRingElem, y::RealPolyRingElem) - return ccall((:arb_poly_overlaps, libflint), Bool, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}), x, y) + return @ccall libflint.arb_poly_overlaps(x::Ref{RealPolyRingElem}, y::Ref{RealPolyRingElem})::Bool end @doc raw""" @@ -120,8 +115,7 @@ Return `true` if the coefficient balls of $x$ contain the corresponding coefficient balls of $y$, otherwise return `false`. """ function contains(x::RealPolyRingElem, y::RealPolyRingElem) - return ccall((:arb_poly_contains, libflint), Bool, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}), x, y) + return @ccall libflint.arb_poly_contains(x::Ref{RealPolyRingElem}, y::Ref{RealPolyRingElem})::Bool end @doc raw""" @@ -131,8 +125,7 @@ Return `true` if the coefficient balls of $x$ contain the corresponding exact coefficients of $y$, otherwise return `false`. """ function contains(x::RealPolyRingElem, y::ZZPolyRingElem) - return ccall((:arb_poly_contains_fmpz_poly, libflint), Bool, - (Ref{RealPolyRingElem}, Ref{ZZPolyRingElem}), x, y) + return @ccall libflint.arb_poly_contains_fmpz_poly(x::Ref{RealPolyRingElem}, y::Ref{ZZPolyRingElem})::Bool end @doc raw""" @@ -142,8 +135,7 @@ Return `true` if the coefficient balls of $x$ contain the corresponding exact coefficients of $y$, otherwise return `false`. """ function contains(x::RealPolyRingElem, y::QQPolyRingElem) - return ccall((:arb_poly_contains_fmpq_poly, libflint), Bool, - (Ref{RealPolyRingElem}, Ref{QQPolyRingElem}), x, y) + return @ccall libflint.arb_poly_contains_fmpq_poly(x::Ref{RealPolyRingElem}, y::Ref{QQPolyRingElem})::Bool end function ==(x::RealPolyRingElem, y::RealPolyRingElem) @@ -176,8 +168,7 @@ In the former case, $z$ is set to the integer polynomial. """ function unique_integer(x::RealPolyRingElem) z = ZZPolyRing(ZZ, var(parent(x)))() - unique = ccall((:arb_poly_get_unique_fmpz_poly, libflint), Int, - (Ref{ZZPolyRingElem}, Ref{RealPolyRingElem}), z, x) + unique = @ccall libflint.arb_poly_get_unique_fmpz_poly(z::Ref{ZZPolyRingElem}, x::Ref{RealPolyRingElem})::Int return (unique != 0, z) end @@ -190,16 +181,14 @@ end function shift_left(x::RealPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:arb_poly_shift_left, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, len) + @ccall libflint.arb_poly_shift_left(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, len::Int)::Nothing return z end function shift_right(x::RealPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:arb_poly_shift_right, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, len) + @ccall libflint.arb_poly_shift_right(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, len::Int)::Nothing return z end @@ -236,9 +225,7 @@ end function ^(x::RealPolyRingElem, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() - ccall((:arb_poly_pow_ui, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, UInt, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_poly_pow_ui(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, y::UInt, precision(Balls)::Int)::Nothing return z end @@ -322,17 +309,14 @@ function truncate(a::RealPolyRingElem, n::Int) end # todo: implement set_trunc in ArbFieldElem z = deepcopy(a) - ccall((:arb_poly_truncate, libflint), Nothing, - (Ref{RealPolyRingElem}, Int), z, n) + @ccall libflint.arb_poly_truncate(z::Ref{RealPolyRingElem}, n::Int)::Nothing return z end function mullow(x::RealPolyRingElem, y::RealPolyRingElem, n::Int, prec::Int = precision(Balls)) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() - ccall((:arb_poly_mullow, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int, Int), - z, x, y, n, prec) + @ccall libflint.arb_poly_mullow(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, y::Ref{RealPolyRingElem}, n::Int, prec::Int)::Nothing return z end @@ -358,17 +342,13 @@ end function evaluate(x::RealPolyRingElem, y::RealFieldElem, prec::Int = precision(Balls)) z = parent(y)() - ccall((:arb_poly_evaluate, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealPolyRingElem}, Ref{RealFieldElem}, Int), - z, x, y, prec) + @ccall libflint.arb_poly_evaluate(z::Ref{RealFieldElem}, x::Ref{RealPolyRingElem}, y::Ref{RealFieldElem}, prec::Int)::Nothing return z end function evaluate(x::RealPolyRingElem, y::AcbFieldElem, prec::Int = precision(Balls)) z = parent(y)() - ccall((:arb_poly_evaluate_acb, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{RealPolyRingElem}, Ref{AcbFieldElem}, Int), - z, x, y, prec) + @ccall libflint.arb_poly_evaluate_acb(z::Ref{AcbFieldElem}, x::Ref{RealPolyRingElem}, y::Ref{AcbFieldElem}, prec::Int)::Nothing return z end @@ -387,18 +367,14 @@ its derivative evaluated at $y$. function evaluate2(x::RealPolyRingElem, y::RealFieldElem, prec::Int = precision(Balls)) z = parent(y)() w = parent(y)() - ccall((:arb_poly_evaluate2, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealPolyRingElem}, Ref{RealFieldElem}, Int), - z, w, x, y, prec) + @ccall libflint.arb_poly_evaluate2(z::Ref{RealFieldElem}, w::Ref{RealFieldElem}, x::Ref{RealPolyRingElem}, y::Ref{RealFieldElem}, prec::Int)::Nothing return z, w end function evaluate2(x::RealPolyRingElem, y::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(y)() w = parent(y)() - ccall((:arb_poly_evaluate2_acb, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{RealPolyRingElem}, Ref{AcbFieldElem}, Int), - z, w, x, y, prec) + @ccall libflint.arb_poly_evaluate2_acb(z::Ref{AcbFieldElem}, w::Ref{AcbFieldElem}, x::Ref{RealPolyRingElem}, y::Ref{AcbFieldElem}, prec::Int)::Nothing return z, w end @@ -419,9 +395,7 @@ function compose(x::RealPolyRingElem, y::RealPolyRingElem, prec::Int = precision @assert inner == :second z = parent(x)() - ccall((:arb_poly_compose, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), - z, x, y, prec) + @ccall libflint.arb_poly_compose(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, y::Ref{RealPolyRingElem}, prec::Int)::Nothing return z end @@ -433,15 +407,13 @@ end function derivative(x::RealPolyRingElem, prec::Int = precision(Balls)) z = parent(x)() - ccall((:arb_poly_derivative, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, prec) + @ccall libflint.arb_poly_derivative(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, prec::Int)::Nothing return z end function integral(x::RealPolyRingElem, prec::Int = precision(Balls)) z = parent(x)() - ccall((:arb_poly_integral, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, prec) + @ccall libflint.arb_poly_integral(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, prec::Int)::Nothing return z end @@ -452,11 +424,11 @@ end ############################################################################### function arb_vec(n::Int) - return ccall((:_arb_vec_init, libflint), Ptr{arb_struct}, (Int,), n) + return @ccall libflint._arb_vec_init(n::Int)::Ptr{arb_struct} end function arb_vec(b::Vector{RealFieldElem}) - v = ccall((:_arb_vec_init, libflint), Ptr{arb_struct}, (Int,), length(b)) + v = @ccall libflint._arb_vec_init(length(b)::Int)::Ptr{arb_struct} for i in 1:length(b) _arb_set(v + (i-1)*sizeof(arb_struct), b[i]) end @@ -473,7 +445,7 @@ function array(R::RealField, v::Ptr{arb_struct}, n::Int) end function arb_vec_clear(v::Ptr{arb_struct}, n::Int) - ccall((:_arb_vec_clear, libflint), Nothing, (Ptr{arb_struct}, Int), v, n) + @ccall libflint._arb_vec_clear(v::Ptr{arb_struct}, n::Int)::Nothing end @doc raw""" @@ -484,8 +456,7 @@ Construct a polynomial in the given polynomial ring from a list of its roots. function from_roots(R::RealPolyRing, b::Vector{RealFieldElem}, prec::Int = precision(Balls)) z = R() tmp = arb_vec(b) - ccall((:arb_poly_product_roots, libflint), Nothing, - (Ref{RealPolyRingElem}, Ptr{arb_struct}, Int, Int), z, tmp, length(b), prec) + @ccall libflint.arb_poly_product_roots(z::Ref{RealPolyRingElem}, tmp::Ptr{arb_struct}, length(b)::Int, prec::Int)::Nothing arb_vec_clear(tmp, length(b)) return z end @@ -496,9 +467,7 @@ end function evaluate_fast(x::RealPolyRingElem, b::Vector{RealFieldElem}, prec::Int = precision(Balls)) tmp = arb_vec(b) - ccall((:arb_poly_evaluate_vec_fast, libflint), Nothing, - (Ptr{arb_struct}, Ref{RealPolyRingElem}, Ptr{arb_struct}, Int, Int), - tmp, x, tmp, length(b), prec) + @ccall libflint.arb_poly_evaluate_vec_fast(tmp::Ptr{arb_struct}, x::Ref{RealPolyRingElem}, tmp::Ptr{arb_struct}, length(b)::Int, prec::Int)::Nothing res = array(base_ring(parent(x)), tmp, length(b)) arb_vec_clear(tmp, length(b)) return res @@ -509,9 +478,7 @@ function interpolate_newton(R::RealPolyRing, xs::Vector{RealFieldElem}, ys::Vect z = R() xsv = arb_vec(xs) ysv = arb_vec(ys) - ccall((:arb_poly_interpolate_newton, libflint), Nothing, - (Ref{RealPolyRingElem}, Ptr{arb_struct}, Ptr{arb_struct}, Int, Int), - z, xsv, ysv, length(xs), prec) + @ccall libflint.arb_poly_interpolate_newton(z::Ref{RealPolyRingElem}, xsv::Ptr{arb_struct}, ysv::Ptr{arb_struct}, length(xs)::Int, prec::Int)::Nothing arb_vec_clear(xsv, length(xs)) arb_vec_clear(ysv, length(ys)) return z @@ -522,9 +489,7 @@ function interpolate_barycentric(R::RealPolyRing, xs::Vector{RealFieldElem}, ys: z = R() xsv = arb_vec(xs) ysv = arb_vec(ys) - ccall((:arb_poly_interpolate_barycentric, libflint), Nothing, - (Ref{RealPolyRingElem}, Ptr{arb_struct}, Ptr{arb_struct}, Int, Int), - z, xsv, ysv, length(xs), prec) + @ccall libflint.arb_poly_interpolate_barycentric(z::Ref{RealPolyRingElem}, xsv::Ptr{arb_struct}, ysv::Ptr{arb_struct}, length(xs)::Int, prec::Int)::Nothing arb_vec_clear(xsv, length(xs)) arb_vec_clear(ysv, length(ys)) return z @@ -535,9 +500,7 @@ function interpolate_fast(R::RealPolyRing, xs::Vector{RealFieldElem}, ys::Vector z = R() xsv = arb_vec(xs) ysv = arb_vec(ys) - ccall((:arb_poly_interpolate_fast, libflint), Nothing, - (Ref{RealPolyRingElem}, Ptr{arb_struct}, Ptr{arb_struct}, Int, Int), - z, xsv, ysv, length(xs), prec) + @ccall libflint.arb_poly_interpolate_fast(z::Ref{RealPolyRingElem}, xsv::Ptr{arb_struct}, ysv::Ptr{arb_struct}, length(xs)::Int, prec::Int)::Nothing arb_vec_clear(xsv, length(xs)) arb_vec_clear(ysv, length(ys)) return z @@ -569,13 +532,11 @@ function roots_upper_bound(x::RealPolyRingElem) p = precision(Balls) GC.@preserve x z begin t = _rad_ptr(z) - ccall((:arb_poly_root_bound_fujiwara, libflint), Nothing, - (Ptr{mag_struct}, Ref{RealPolyRingElem}), t, x) + @ccall libflint.arb_poly_root_bound_fujiwara(t::Ptr{mag_struct}, x::Ref{RealPolyRingElem})::Nothing s = _mid_ptr(z) - ccall((:arf_set_mag, libflint), Nothing, (Ptr{arf_struct}, Ptr{mag_struct}), s, t) - ccall((:arf_set_round, libflint), Nothing, - (Ptr{arf_struct}, Ptr{arf_struct}, Int, Cint), s, s, p, ARB_RND_CEIL) - ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct},), t) + @ccall libflint.arf_set_mag(s::Ptr{arf_struct}, t::Ptr{mag_struct})::Nothing + @ccall libflint.arf_set_round(s::Ptr{arf_struct}, s::Ptr{arf_struct}, p::Int, ARB_RND_CEIL::Cint)::Nothing + @ccall libflint.mag_zero(t::Ptr{mag_struct})::Nothing end return z end @@ -602,20 +563,17 @@ function neg!(z::RealPolyRingElemOrPtr, a::RealPolyRingElemOrPtr) end function fit!(z::RealPolyRingElem, n::Int) - ccall((:arb_poly_fit_length, libflint), Nothing, - (Ref{RealPolyRingElem}, Int), z, n) + @ccall libflint.arb_poly_fit_length(z::Ref{RealPolyRingElem}, n::Int)::Nothing return nothing end function setcoeff!(z::RealPolyRingElem, n::Int, x::RealFieldElem) - ccall((:arb_poly_set_coeff_arb, libflint), Nothing, - (Ref{RealPolyRingElem}, Int, Ref{RealFieldElem}), z, n, x) + @ccall libflint.arb_poly_set_coeff_arb(z::Ref{RealPolyRingElem}, n::Int, x::Ref{RealFieldElem})::Nothing return z end function setcoeff!(z::RealPolyRingElem, n::Int, x::Int) - ccall((:arb_poly_set_coeff_si, libflint), Nothing, - (Ref{RealPolyRingElem}, Int, Int), z, n, x) + @ccall libflint.arb_poly_set_coeff_si(z::Ref{RealPolyRingElem}, n::Int, x::Int)::Nothing return z end @@ -628,16 +586,12 @@ setcoeff!(z::RealPolyRingElem, n::Int, x::Integer) = setcoeff!(z, n, flintify(x) # function add!(z::RealPolyRingElem, x::RealPolyRingElem, y::RealPolyRingElem) - ccall((:arb_poly_add, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_poly_add(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, y::Ref{RealPolyRingElem}, precision(Balls)::Int)::Nothing return z end function add!(z::RealPolyRingElem, x::RealPolyRingElem, y::Int) - ccall((:arb_poly_add_si, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_poly_add_si(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, y::Int, precision(Balls)::Int)::Nothing return z end @@ -652,9 +606,7 @@ add!(z::RealPolyRingElem, x::Union{RealFieldElem,IntegerUnion}, y::RealPolyRingE # function sub!(z::RealPolyRingElem, x::RealPolyRingElem, y::RealPolyRingElem) - ccall((:arb_poly_sub, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_poly_sub(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, y::Ref{RealPolyRingElem}, precision(Balls)::Int)::Nothing return z end @@ -665,16 +617,12 @@ sub!(z::RealPolyRingElem, x::Union{RealFieldElem,IntegerUnion}, y::RealPolyRingE # function mul!(z::RealPolyRingElem, x::RealPolyRingElem, y::RealPolyRingElem) - ccall((:arb_poly_mul, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_poly_mul(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, y::Ref{RealPolyRingElem}, precision(Balls)::Int)::Nothing return z end function mul!(z::RealPolyRingElem, x::RealPolyRingElem, y::RealFieldElem) - ccall((:arb_poly_scalar_mul, libflint), Nothing, - (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealFieldElem}, Int), - z, x, y, precision(Balls)) + @ccall libflint.arb_poly_scalar_mul(z::Ref{RealPolyRingElem}, x::Ref{RealPolyRingElem}, y::Ref{RealFieldElem}, precision(Balls)::Int)::Nothing return z end diff --git a/src/arb/acb.jl b/src/arb/acb.jl index 382724472..ed2f5a763 100644 --- a/src/arb/acb.jl +++ b/src/arb/acb.jl @@ -60,7 +60,7 @@ Return the relative accuracy of $x$ measured in bits, capped between """ function accuracy_bits(x::AcbFieldElem) # bug in acb.h: rel_accuracy_bits is not in the library - return -ccall((:acb_rel_error_bits, libflint), Int, (Ref{AcbFieldElem},), x) + return -@ccall libflint.acb_rel_error_bits(x::Ref{AcbFieldElem})::Int end function deepcopy_internal(a::AcbFieldElem, dict::IdDict) @@ -90,8 +90,8 @@ function convert(::Type{ComplexF64}, x::AcbFieldElem) t = _mid_ptr(re) u = _mid_ptr(im) # 4 == round to nearest - v = ccall((:arf_get_d, libflint), Float64, (Ptr{arf_struct}, Int), t, 4) - w = ccall((:arf_get_d, libflint), Float64, (Ptr{arf_struct}, Int), u, 4) + v = @ccall libflint.arf_get_d(t::Ptr{arf_struct}, 4::Int)::Float64 + w = @ccall libflint.arf_get_d(u::Ptr{arf_struct}, 4::Int)::Float64 end return complex(v, w) end @@ -104,14 +104,14 @@ end function real(x::AcbFieldElem) z = ArbFieldElem() - ccall((:acb_get_real, libflint), Nothing, (Ref{ArbFieldElem}, Ref{AcbFieldElem}), z, x) + @ccall libflint.acb_get_real(z::Ref{ArbFieldElem}, x::Ref{AcbFieldElem})::Nothing z.parent = ArbField(parent(x).prec) return z end function imag(x::AcbFieldElem) z = ArbFieldElem() - ccall((:acb_get_imag, libflint), Nothing, (Ref{ArbFieldElem}, Ref{AcbFieldElem}), z, x) + @ccall libflint.acb_get_imag(z::Ref{ArbFieldElem}, x::Ref{AcbFieldElem})::Nothing z.parent = ArbField(parent(x).prec) return z end @@ -238,25 +238,25 @@ end function -(x::UInt, y::AcbFieldElem) z = parent(y)() - ccall((:acb_sub_ui, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, UInt, Int), z, y, x, parent(y).prec) + @ccall libflint.acb_sub_ui(z::Ref{AcbFieldElem}, y::Ref{AcbFieldElem}, x::UInt, parent(y).prec::Int)::Nothing return neg!(z) end function -(x::Int, y::AcbFieldElem) z = parent(y)() - ccall((:acb_sub_si, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int, Int), z, y, x, parent(y).prec) + @ccall libflint.acb_sub_si(z::Ref{AcbFieldElem}, y::Ref{AcbFieldElem}, x::Int, parent(y).prec::Int)::Nothing return neg!(z) end function -(x::ZZRingElem, y::AcbFieldElem) z = parent(y)() - ccall((:acb_sub_fmpz, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{ZZRingElem}, Int), z, y, x, parent(y).prec) + @ccall libflint.acb_sub_fmpz(z::Ref{AcbFieldElem}, y::Ref{AcbFieldElem}, x::Ref{ZZRingElem}, parent(y).prec::Int)::Nothing return neg!(z) end function -(x::ArbFieldElem, y::AcbFieldElem) z = parent(y)() - ccall((:acb_sub_arb, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{ArbFieldElem}, Int), z, y, x, parent(y).prec) + @ccall libflint.acb_sub_arb(z::Ref{AcbFieldElem}, y::Ref{AcbFieldElem}, x::Ref{ArbFieldElem}, parent(y).prec::Int)::Nothing return neg!(z) end @@ -325,17 +325,17 @@ Return `true` if the boxes $x$ and $y$ are precisely equal, i.e. their real and imaginary parts have the same midpoints and radii. """ function isequal(x::AcbFieldElem, y::AcbFieldElem) - r = ccall((:acb_equal, libflint), Cint, (Ref{AcbFieldElem}, Ref{AcbFieldElem}), x, y) + r = @ccall libflint.acb_equal(x::Ref{AcbFieldElem}, y::Ref{AcbFieldElem})::Cint return Bool(r) end function ==(x::AcbFieldElem, y::AcbFieldElem) - r = ccall((:acb_eq, libflint), Cint, (Ref{AcbFieldElem}, Ref{AcbFieldElem}), x, y) + r = @ccall libflint.acb_eq(x::Ref{AcbFieldElem}, y::Ref{AcbFieldElem})::Cint return Bool(r) end function !=(x::AcbFieldElem, y::AcbFieldElem) - r = ccall((:acb_ne, libflint), Cint, (Ref{AcbFieldElem}, Ref{AcbFieldElem}), x, y) + r = @ccall libflint.acb_ne(x::Ref{AcbFieldElem}, y::Ref{AcbFieldElem})::Cint return Bool(r) end @@ -379,7 +379,7 @@ Returns `true` if any part of the box $x$ overlaps any part of the box $y$, otherwise return `false`. """ function overlaps(x::AcbFieldElem, y::AcbFieldElem) - r = ccall((:acb_overlaps, libflint), Cint, (Ref{AcbFieldElem}, Ref{AcbFieldElem}), x, y) + r = @ccall libflint.acb_overlaps(x::Ref{AcbFieldElem}, y::Ref{AcbFieldElem})::Cint return Bool(r) end @@ -390,7 +390,7 @@ Returns `true` if the box $x$ contains the box $y$, otherwise return `false`. """ function contains(x::AcbFieldElem, y::AcbFieldElem) - r = ccall((:acb_contains, libflint), Cint, (Ref{AcbFieldElem}, Ref{AcbFieldElem}), x, y) + r = @ccall libflint.acb_contains(x::Ref{AcbFieldElem}, y::Ref{AcbFieldElem})::Cint return Bool(r) end @@ -401,7 +401,7 @@ Returns `true` if the box $x$ contains the given rational value, otherwise return `false`. """ function contains(x::AcbFieldElem, y::QQFieldElem) - r = ccall((:acb_contains_fmpq, libflint), Cint, (Ref{AcbFieldElem}, Ref{QQFieldElem}), x, y) + r = @ccall libflint.acb_contains_fmpq(x::Ref{AcbFieldElem}, y::Ref{QQFieldElem})::Cint return Bool(r) end @@ -412,13 +412,13 @@ Returns `true` if the box $x$ contains the given integer value, otherwise return `false`. """ function contains(x::AcbFieldElem, y::ZZRingElem) - r = ccall((:acb_contains_fmpz, libflint), Cint, (Ref{AcbFieldElem}, Ref{ZZRingElem}), x, y) + r = @ccall libflint.acb_contains_fmpz(x::Ref{AcbFieldElem}, y::Ref{ZZRingElem})::Cint return Bool(r) end function contains(x::AcbFieldElem, y::Int) v = ZZRingElem(y) - r = ccall((:acb_contains_fmpz, libflint), Cint, (Ref{AcbFieldElem}, Ref{ZZRingElem}), x, v) + r = @ccall libflint.acb_contains_fmpz(x::Ref{AcbFieldElem}, v::Ref{ZZRingElem})::Cint return Bool(r) end @@ -444,7 +444,7 @@ contains(x::AcbFieldElem, y::Rational{T}) where {T <: Integer} = contains(x, ZZR Returns `true` if the box $x$ contains zero, otherwise return `false`. """ function contains_zero(x::AcbFieldElem) - return Bool(ccall((:acb_contains_zero, libflint), Cint, (Ref{AcbFieldElem},), x)) + return Bool(@ccall libflint.acb_contains_zero(x::Ref{AcbFieldElem})::Cint) end ################################################################################ @@ -463,7 +463,7 @@ end Return `true` if $x$ is certainly zero, otherwise return `false`. """ function iszero(x::AcbFieldElem) - return Bool(ccall((:acb_is_zero, libflint), Cint, (Ref{AcbFieldElem},), x)) + return Bool(@ccall libflint.acb_is_zero(x::Ref{AcbFieldElem})::Cint) end @doc raw""" @@ -472,7 +472,7 @@ end Return `true` if $x$ is certainly one, otherwise return `false`. """ function isone(x::AcbFieldElem) - return Bool(ccall((:acb_is_one, libflint), Cint, (Ref{AcbFieldElem},), x)) + return Bool(@ccall libflint.acb_is_one(x::Ref{AcbFieldElem})::Cint) end @doc raw""" @@ -482,7 +482,7 @@ Return `true` if $x$ is finite, i.e. its real and imaginary parts have finite midpoint and radius, otherwise return `false`. """ function isfinite(x::AcbFieldElem) - return Bool(ccall((:acb_is_finite, libflint), Cint, (Ref{AcbFieldElem},), x)) + return Bool(@ccall libflint.acb_is_finite(x::Ref{AcbFieldElem})::Cint) end @doc raw""" @@ -492,7 +492,7 @@ Return `true` if $x$ is exact, i.e. has its real and imaginary parts have zero radius, otherwise return `false`. """ function is_exact(x::AcbFieldElem) - return Bool(ccall((:acb_is_exact, libflint), Cint, (Ref{AcbFieldElem},), x)) + return Bool(@ccall libflint.acb_is_exact(x::Ref{AcbFieldElem})::Cint) end @doc raw""" @@ -501,11 +501,11 @@ end Return `true` if $x$ is an exact integer, otherwise return `false`. """ function isinteger(x::AcbFieldElem) - return Bool(ccall((:acb_is_int, libflint), Cint, (Ref{AcbFieldElem},), x)) + return Bool(@ccall libflint.acb_is_int(x::Ref{AcbFieldElem})::Cint) end function isreal(x::AcbFieldElem) - return Bool(ccall((:acb_is_real, libflint), Cint, (Ref{AcbFieldElem},), x)) + return Bool(@ccall libflint.acb_is_real(x::Ref{AcbFieldElem})::Cint) end is_negative(x::AcbFieldElem) = isreal(x) && is_negative(real(x)) @@ -518,8 +518,7 @@ is_negative(x::AcbFieldElem) = isreal(x) && is_negative(real(x)) function abs(x::AcbFieldElem) z = ArbFieldElem() - ccall((:acb_abs, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_abs(z::Ref{ArbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing z.parent = ArbField(parent(x).prec) return z end @@ -532,7 +531,7 @@ end function inv(x::AcbFieldElem) z = parent(x)() - ccall((:acb_inv, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_inv(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -558,15 +557,13 @@ end function ldexp(x::AcbFieldElem, y::Int) z = parent(x)() - ccall((:acb_mul_2exp_si, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, y) + @ccall libflint.acb_mul_2exp_si(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, y::Int)::Nothing return z end function ldexp(x::AcbFieldElem, y::ZZRingElem) z = parent(x)() - ccall((:acb_mul_2exp_fmpz, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.acb_mul_2exp_fmpz(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, y::Ref{ZZRingElem})::Nothing return z end @@ -584,7 +581,7 @@ by rounding off insignificant bits from midpoints. """ function trim(x::AcbFieldElem) z = parent(x)() - ccall((:acb_trim, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}), z, x) + @ccall libflint.acb_trim(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem})::Nothing return z end @@ -598,21 +595,19 @@ integer. """ function unique_integer(x::AcbFieldElem) z = ZZRingElem() - unique = ccall((:acb_get_unique_fmpz, libflint), Int, - (Ref{ZZRingElem}, Ref{AcbFieldElem}), z, x) + unique = @ccall libflint.acb_get_unique_fmpz(z::Ref{ZZRingElem}, x::Ref{AcbFieldElem})::Int return (unique != 0, z) end function conj(x::AcbFieldElem) z = parent(x)() - ccall((:acb_conj, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}), z, x) + @ccall libflint.acb_conj(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem})::Nothing return z end function angle(x::AcbFieldElem) z = ArbFieldElem() - ccall((:acb_arg, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_arg(z::Ref{ArbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing z.parent = ArbField(parent(x).prec) return z end @@ -630,7 +625,7 @@ Return $\pi = 3.14159\ldots$ as an element of $r$. """ function const_pi(r::AcbField) z = r() - ccall((:acb_const_pi, libflint), Nothing, (Ref{AcbFieldElem}, Int), z, precision(r)) + @ccall libflint.acb_const_pi(z::Ref{AcbFieldElem}, precision(r)::Int)::Nothing return z end @@ -644,7 +639,7 @@ end function Base.sqrt(x::AcbFieldElem; check::Bool=true) z = parent(x)() - ccall((:acb_sqrt, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_sqrt(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -655,31 +650,31 @@ Return the reciprocal of the square root of $x$, i.e. $1/\sqrt{x}$. """ function rsqrt(x::AcbFieldElem) z = parent(x)() - ccall((:acb_rsqrt, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_rsqrt(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function log(x::AcbFieldElem) z = parent(x)() - ccall((:acb_log, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_log(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function log1p(x::AcbFieldElem) z = parent(x)() - ccall((:acb_log1p, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_log1p(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function Base.exp(x::AcbFieldElem) z = parent(x)() - ccall((:acb_exp, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_exp(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function Base.expm1(x::AcbFieldElem) z = parent(x)() - ccall((:acb_expm1, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_expm1(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -690,7 +685,7 @@ Return the exponential of $\pi i x$. """ function cispi(x::AcbFieldElem) z = parent(x)() - ccall((:acb_exp_pi_i, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_exp_pi_i(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -702,85 +697,85 @@ Return $\exp(2\pi i/k)$. function root_of_unity(C::AcbField, k::Int) k <= 0 && throw(ArgumentError("Order must be positive ($k)")) z = C() - ccall((:acb_unit_root, libflint), Nothing, (Ref{AcbFieldElem}, UInt, Int), z, k, C.prec) + @ccall libflint.acb_unit_root(z::Ref{AcbFieldElem}, k::UInt, C.prec::Int)::Nothing return z end function sin(x::AcbFieldElem) z = parent(x)() - ccall((:acb_sin, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_sin(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function cos(x::AcbFieldElem) z = parent(x)() - ccall((:acb_cos, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_cos(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function tan(x::AcbFieldElem) z = parent(x)() - ccall((:acb_tan, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_tan(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function cot(x::AcbFieldElem) z = parent(x)() - ccall((:acb_cot, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_cot(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function sinpi(x::AcbFieldElem) z = parent(x)() - ccall((:acb_sin_pi, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_sin_pi(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function cospi(x::AcbFieldElem) z = parent(x)() - ccall((:acb_cos_pi, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_cos_pi(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function tanpi(x::AcbFieldElem) z = parent(x)() - ccall((:acb_tan_pi, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_tan_pi(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function cotpi(x::AcbFieldElem) z = parent(x)() - ccall((:acb_cot_pi, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_cot_pi(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function sinh(x::AcbFieldElem) z = parent(x)() - ccall((:acb_sinh, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_sinh(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function cosh(x::AcbFieldElem) z = parent(x)() - ccall((:acb_cosh, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_cosh(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function tanh(x::AcbFieldElem) z = parent(x)() - ccall((:acb_tanh, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_tanh(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function coth(x::AcbFieldElem) z = parent(x)() - ccall((:acb_coth, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_coth(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function atan(x::AcbFieldElem) z = parent(x)() - ccall((:acb_atan, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_atan(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -791,7 +786,7 @@ Return $\log\sin(\pi x)$, constructed without branch cuts off the real line. """ function log_sinpi(x::AcbFieldElem) z = parent(x)() - ccall((:acb_log_sin_pi, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_log_sin_pi(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -802,7 +797,7 @@ Return the Gamma function evaluated at $x$. """ function gamma(x::AcbFieldElem) z = parent(x)() - ccall((:acb_gamma, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_gamma(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -813,7 +808,7 @@ Return the reciprocal of the Gamma function evaluated at $x$. """ function rgamma(x::AcbFieldElem) z = parent(x)() - ccall((:acb_rgamma, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_rgamma(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -824,7 +819,7 @@ Return the logarithm of the Gamma function evaluated at $x$. """ function lgamma(x::AcbFieldElem) z = parent(x)() - ccall((:acb_lgamma, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_lgamma(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -836,7 +831,7 @@ i.e. $\psi(x)$. """ function digamma(x::AcbFieldElem) z = parent(x)() - ccall((:acb_digamma, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_digamma(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -847,7 +842,7 @@ Return the Riemann zeta function evaluated at $x$. """ function zeta(x::AcbFieldElem) z = parent(x)() - ccall((:acb_zeta, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_zeta(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -858,7 +853,7 @@ Return the Barnes $G$-function, evaluated at $x$. """ function barnes_g(x::AcbFieldElem) z = parent(x)() - ccall((:acb_barnes_g, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_barnes_g(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -869,7 +864,7 @@ Return the logarithm of the Barnes $G$-function, evaluated at $x$. """ function log_barnes_g(x::AcbFieldElem) z = parent(x)() - ccall((:acb_log_barnes_g, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_log_barnes_g(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -880,7 +875,7 @@ Return the arithmetic-geometric mean of $1$ and $x$. """ function agm(x::AcbFieldElem) z = parent(x)() - ccall((:acb_agm1, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_agm1(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -891,7 +886,7 @@ Return the error function evaluated at $x$. """ function erf(x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_erf, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_hypgeom_erf(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -902,7 +897,7 @@ Return the imaginary error function evaluated at $x$. """ function erfi(x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_erfi, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_hypgeom_erfi(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -913,7 +908,7 @@ Return the complementary error function evaluated at $x$. """ function erfc(x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_erfc, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_hypgeom_erfc(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -924,7 +919,7 @@ Return the exponential integral evaluated at $x$. """ function exp_integral_ei(x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_ei, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_hypgeom_ei(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -935,7 +930,7 @@ Return the sine integral evaluated at $x$. """ function sin_integral(x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_si, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_hypgeom_si(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -946,7 +941,7 @@ Return the exponential cosine integral evaluated at $x$. """ function cos_integral(x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_ci, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_hypgeom_ci(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -957,7 +952,7 @@ Return the hyperbolic sine integral evaluated at $x$. """ function sinh_integral(x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_shi, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_hypgeom_shi(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -968,7 +963,7 @@ Return the hyperbolic cosine integral evaluated at $x$. """ function cosh_integral(x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_chi, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_hypgeom_chi(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -979,7 +974,7 @@ Return the Dedekind eta function $\eta(\tau)$ at $\tau = x$. """ function dedekind_eta(x::AcbFieldElem) z = parent(x)() - ccall((:acb_modular_eta, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_modular_eta(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1027,7 +1022,7 @@ Return the $j$-invariant $j(\tau)$ at $\tau = x$. """ function j_invariant(x::AcbFieldElem) z = parent(x)() - ccall((:acb_modular_j, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_modular_j(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1038,7 +1033,7 @@ Return the modular lambda function $\lambda(\tau)$ at $\tau = x$. """ function modular_lambda(x::AcbFieldElem) z = parent(x)() - ccall((:acb_modular_lambda, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_modular_lambda(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1049,7 +1044,7 @@ Return the modular delta function $\Delta(\tau)$ at $\tau = x$. """ function modular_delta(x::AcbFieldElem) z = parent(x)() - ccall((:acb_modular_delta, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_modular_delta(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1069,8 +1064,7 @@ function eisenstein_g(k::Int, x::AcbFieldElem) len = div(k, 2) - 1 vec = acb_vec(len) - ccall((:acb_modular_eisenstein, libflint), Nothing, - (Ptr{acb_struct}, Ref{AcbFieldElem}, Int, Int), vec, x, len, CC.prec) + @ccall libflint.acb_modular_eisenstein(vec::Ptr{acb_struct}, x::Ref{AcbFieldElem}, len::Int, CC.prec::Int)::Nothing z = array(CC, vec, len) acb_vec_clear(vec, len) return z[end] @@ -1083,7 +1077,7 @@ Return the complete elliptic integral $K(x)$. """ function elliptic_k(x::AcbFieldElem) z = parent(x)() - ccall((:acb_modular_elliptic_k, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_modular_elliptic_k(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1094,23 +1088,21 @@ Return the complete elliptic integral $E(x)$. """ function elliptic_e(x::AcbFieldElem) z = parent(x)() - ccall((:acb_modular_elliptic_e, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.acb_modular_elliptic_e(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end function sincos(x::AcbFieldElem) s = parent(x)() c = parent(x)() - ccall((:acb_sin_cos, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), s, c, x, parent(x).prec) + @ccall libflint.acb_sin_cos(s::Ref{AcbFieldElem}, c::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return (s, c) end function sincospi(x::AcbFieldElem) s = parent(x)() c = parent(x)() - ccall((:acb_sin_cos_pi, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), s, c, x, parent(x).prec) + @ccall libflint.acb_sin_cos_pi(s::Ref{AcbFieldElem}, c::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return (s, c) end @@ -1122,8 +1114,7 @@ Return a tuple $s, c$ consisting of the hyperbolic sine and cosine of $x$. function sinhcosh(x::AcbFieldElem) s = parent(x)() c = parent(x)() - ccall((:acb_sinh_cosh, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), s, c, x, parent(x).prec) + @ccall libflint.acb_sinh_cosh(s::Ref{AcbFieldElem}, c::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return (s, c) end @@ -1134,8 +1125,7 @@ Return the Hurwitz zeta function $\zeta(s,a)$. """ function zeta(s::AcbFieldElem, a::AcbFieldElem) z = parent(s)() - ccall((:acb_hurwitz_zeta, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, s, a, parent(s).prec) + @ccall libflint.acb_hurwitz_zeta(z::Ref{AcbFieldElem}, s::Ref{AcbFieldElem}, a::Ref{AcbFieldElem}, parent(s).prec::Int)::Nothing return z end @@ -1146,15 +1136,13 @@ Return the generalised polygamma function $\psi(s,z)$. """ function polygamma(s::AcbFieldElem, a::AcbFieldElem) z = parent(s)() - ccall((:acb_polygamma, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, s, a, parent(s).prec) + @ccall libflint.acb_polygamma(z::Ref{AcbFieldElem}, s::Ref{AcbFieldElem}, a::Ref{AcbFieldElem}, parent(s).prec::Int)::Nothing return z end function rising_factorial(x::AcbFieldElem, n::UInt) z = parent(x)() - ccall((:acb_rising_ui, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, UInt, Int), z, x, n, parent(x).prec) + @ccall libflint.acb_rising_ui(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, n::UInt, parent(x).prec::Int)::Nothing return z end @@ -1171,8 +1159,7 @@ end function rising_factorial2(x::AcbFieldElem, n::UInt) z = parent(x)() w = parent(x)() - ccall((:acb_rising2_ui, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, UInt, Int), z, w, x, n, parent(x).prec) + @ccall libflint.acb_rising2_ui(z::Ref{AcbFieldElem}, w::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, n::UInt, parent(x).prec::Int)::Nothing return (z, w) end @@ -1189,15 +1176,13 @@ end function polylog(s::AcbFieldElem, a::AcbFieldElem) z = parent(s)() - ccall((:acb_polylog, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, s, a, parent(s).prec) + @ccall libflint.acb_polylog(z::Ref{AcbFieldElem}, s::Ref{AcbFieldElem}, a::Ref{AcbFieldElem}, parent(s).prec::Int)::Nothing return z end function polylog(s::Int, a::AcbFieldElem) z = parent(a)() - ccall((:acb_polylog_si, libflint), Nothing, - (Ref{AcbFieldElem}, Int, Ref{AcbFieldElem}, Int), z, s, a, parent(a).prec) + @ccall libflint.acb_polylog_si(z::Ref{AcbFieldElem}, s::Int, a::Ref{AcbFieldElem}, parent(a).prec::Int)::Nothing return z end @@ -1214,8 +1199,7 @@ Return the logarithmic integral, evaluated at $x$. """ function log_integral(x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_li, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int, Int), z, x, 0, parent(x).prec) + @ccall libflint.acb_hypgeom_li(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, 0::Int, parent(x).prec::Int)::Nothing return z end @@ -1226,8 +1210,7 @@ Return the offset logarithmic integral, evaluated at $x$. """ function log_integral_offset(x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_li, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int, Int), z, x, 1, parent(x).prec) + @ccall libflint.acb_hypgeom_li(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, 1::Int, parent(x).prec::Int)::Nothing return z end @@ -1238,8 +1221,7 @@ Return the generalised exponential integral $E_s(x)$. """ function exp_integral_e(s::AcbFieldElem, x::AcbFieldElem) z = parent(s)() - ccall((:acb_hypgeom_expint, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, s, x, parent(s).prec) + @ccall libflint.acb_hypgeom_expint(z::Ref{AcbFieldElem}, s::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(s).prec::Int)::Nothing return z end @@ -1250,8 +1232,7 @@ Return the upper incomplete gamma function $\Gamma(s,x)$. """ function gamma(s::AcbFieldElem, x::AcbFieldElem) z = parent(s)() - ccall((:acb_hypgeom_gamma_upper, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int, Int), z, s, x, 0, parent(s).prec) + @ccall libflint.acb_hypgeom_gamma_upper(z::Ref{AcbFieldElem}, s::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, 0::Int, parent(s).prec::Int)::Nothing return z end @@ -1263,8 +1244,7 @@ $\Gamma(s,x) / \Gamma(s)$. """ function gamma_regularized(s::AcbFieldElem, x::AcbFieldElem) z = parent(s)() - ccall((:acb_hypgeom_gamma_upper, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int, Int), z, s, x, 1, parent(s).prec) + @ccall libflint.acb_hypgeom_gamma_upper(z::Ref{AcbFieldElem}, s::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, 1::Int, parent(s).prec::Int)::Nothing return z end @@ -1275,8 +1255,7 @@ Return the lower incomplete gamma function $\gamma(s,x) / \Gamma(s)$. """ function gamma_lower(s::AcbFieldElem, x::AcbFieldElem) z = parent(s)() - ccall((:acb_hypgeom_gamma_lower, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int, Int), z, s, x, 0, parent(s).prec) + @ccall libflint.acb_hypgeom_gamma_lower(z::Ref{AcbFieldElem}, s::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, 0::Int, parent(s).prec::Int)::Nothing return z end @@ -1288,8 +1267,7 @@ $\gamma(s,x) / \Gamma(s)$. """ function gamma_lower_regularized(s::AcbFieldElem, x::AcbFieldElem) z = parent(s)() - ccall((:acb_hypgeom_gamma_lower, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int, Int), z, s, x, 1, parent(s).prec) + @ccall libflint.acb_hypgeom_gamma_lower(z::Ref{AcbFieldElem}, s::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, 1::Int, parent(s).prec::Int)::Nothing return z end @@ -1300,8 +1278,7 @@ Return the Bessel function $J_{\nu}(x)$. """ function bessel_j(nu::AcbFieldElem, x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_bessel_j, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, nu, x, parent(x).prec) + @ccall libflint.acb_hypgeom_bessel_j(z::Ref{AcbFieldElem}, nu::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1312,8 +1289,7 @@ Return the Bessel function $Y_{\nu}(x)$. """ function bessel_y(nu::AcbFieldElem, x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_bessel_y, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, nu, x, parent(x).prec) + @ccall libflint.acb_hypgeom_bessel_y(z::Ref{AcbFieldElem}, nu::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1324,8 +1300,7 @@ Return the Bessel function $I_{\nu}(x)$. """ function bessel_i(nu::AcbFieldElem, x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_bessel_i, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, nu, x, parent(x).prec) + @ccall libflint.acb_hypgeom_bessel_i(z::Ref{AcbFieldElem}, nu::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1336,8 +1311,7 @@ Return the Bessel function $K_{\nu}(x)$. """ function bessel_k(nu::AcbFieldElem, x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_bessel_k, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, nu, x, parent(x).prec) + @ccall libflint.acb_hypgeom_bessel_k(z::Ref{AcbFieldElem}, nu::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1348,9 +1322,7 @@ Return the Airy function $\operatorname{Ai}(x)$. """ function airy_ai(x::AcbFieldElem) ai = parent(x)() - ccall((:acb_hypgeom_airy, libflint), Nothing, - (Ref{AcbFieldElem}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ref{AcbFieldElem}, Int), - ai, C_NULL, C_NULL, C_NULL, x, parent(x).prec) + @ccall libflint.acb_hypgeom_airy(ai::Ref{AcbFieldElem}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return ai end @@ -1361,9 +1333,7 @@ Return the Airy function $\operatorname{Bi}(x)$. """ function airy_bi(x::AcbFieldElem) bi = parent(x)() - ccall((:acb_hypgeom_airy, libflint), Nothing, - (Ptr{Cvoid}, Ptr{Cvoid}, Ref{AcbFieldElem}, Ptr{Cvoid}, Ref{AcbFieldElem}, Int), - C_NULL, C_NULL, bi, C_NULL, x, parent(x).prec) + @ccall libflint.acb_hypgeom_airy(C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, bi::Ref{AcbFieldElem}, C_NULL::Ptr{Cvoid}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return bi end @@ -1374,9 +1344,7 @@ Return the derivative of the Airy function $\operatorname{Ai}^\prime(x)$. """ function airy_ai_prime(x::AcbFieldElem) ai_prime = parent(x)() - ccall((:acb_hypgeom_airy, libflint), Nothing, - (Ptr{Cvoid}, Ref{AcbFieldElem}, Ptr{Cvoid}, Ptr{Cvoid}, Ref{AcbFieldElem}, Int), - C_NULL, ai_prime, C_NULL, C_NULL, x, parent(x).prec) + @ccall libflint.acb_hypgeom_airy(C_NULL::Ptr{Cvoid}, ai_prime::Ref{AcbFieldElem}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return ai_prime end @@ -1387,9 +1355,7 @@ Return the derivative of the Airy function $\operatorname{Bi}^\prime(x)$. """ function airy_bi_prime(x::AcbFieldElem) bi_prime = parent(x)() - ccall((:acb_hypgeom_airy, libflint), Nothing, - (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), - C_NULL, C_NULL, C_NULL, bi_prime, x, parent(x).prec) + @ccall libflint.acb_hypgeom_airy(C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, bi_prime::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return bi_prime end @@ -1400,8 +1366,7 @@ Return the confluent hypergeometric function ${}_1F_1(a,b,x)$. """ function hypergeometric_1f1(a::AcbFieldElem, b::AcbFieldElem, x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_m, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int, Int), z, a, b, x, 0, parent(x).prec) + @ccall libflint.acb_hypgeom_m(z::Ref{AcbFieldElem}, a::Ref{AcbFieldElem}, b::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, 0::Int, parent(x).prec::Int)::Nothing return z end @@ -1413,8 +1378,7 @@ ${}_1F_1(a,b,x) / \Gamma(b)$. """ function hypergeometric_1f1_regularized(a::AcbFieldElem, b::AcbFieldElem, x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_m, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int, Int), z, a, b, x, 1, parent(x).prec) + @ccall libflint.acb_hypgeom_m(z::Ref{AcbFieldElem}, a::Ref{AcbFieldElem}, b::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, 1::Int, parent(x).prec::Int)::Nothing return z end @@ -1425,8 +1389,7 @@ Return the confluent hypergeometric function $U(a,b,x)$. """ function hypergeometric_u(a::AcbFieldElem, b::AcbFieldElem, x::AcbFieldElem) z = parent(x)() - ccall((:acb_hypgeom_u, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, a, b, x, parent(x).prec) + @ccall libflint.acb_hypgeom_u(z::Ref{AcbFieldElem}, a::Ref{AcbFieldElem}, b::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1437,8 +1400,7 @@ Return the Gauss hypergeometric function ${}_2F_1(a,b,c,x)$. """ function hypergeometric_2f1(a::AcbFieldElem, b::AcbFieldElem, c::AcbFieldElem, x::AcbFieldElem; flags=0) z = parent(x)() - ccall((:acb_hypgeom_2f1, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int, Int), z, a, b, c, x, flags, parent(x).prec) + @ccall libflint.acb_hypgeom_2f1(z::Ref{AcbFieldElem}, a::Ref{AcbFieldElem}, b::Ref{AcbFieldElem}, c::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, flags::Int, parent(x).prec::Int)::Nothing return z end @@ -1453,9 +1415,7 @@ function jacobi_theta(z::AcbFieldElem, tau::AcbFieldElem) t2 = parent(z)() t3 = parent(z)() t4 = parent(z)() - ccall((:acb_modular_theta, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), - t1, t2, t3, t4, z, tau, parent(z).prec) + @ccall libflint.acb_modular_theta(t1::Ref{AcbFieldElem}, t2::Ref{AcbFieldElem}, t3::Ref{AcbFieldElem}, t4::Ref{AcbFieldElem}, z::Ref{AcbFieldElem}, tau::Ref{AcbFieldElem}, parent(z).prec::Int)::Nothing return (t1, t2, t3, t4) end @@ -1466,8 +1426,7 @@ Return the Weierstrass elliptic function $\wp(z,\tau)$. """ function weierstrass_p(z::AcbFieldElem, tau::AcbFieldElem) r = parent(z)() - ccall((:acb_elliptic_p, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), r, z, tau, parent(z).prec) + @ccall libflint.acb_elliptic_p(r::Ref{AcbFieldElem}, z::Ref{AcbFieldElem}, tau::Ref{AcbFieldElem}, parent(z).prec::Int)::Nothing return r end @@ -1478,8 +1437,7 @@ Return the derivative of the Weierstrass elliptic function $\frac{\partial}{\par """ function weierstrass_p_prime(z::AcbFieldElem, tau::AcbFieldElem) r = parent(z)() - ccall((:acb_elliptic_p_prime, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), r, z, tau, parent(z).prec) + @ccall libflint.acb_elliptic_p_prime(r::Ref{AcbFieldElem}, z::Ref{AcbFieldElem}, tau::Ref{AcbFieldElem}, parent(z).prec::Int)::Nothing return r end @@ -1582,26 +1540,22 @@ function neg!(z::AcbFieldElemOrPtr, a::AcbFieldElemOrPtr) end function add!(z::AcbFieldElem, x::AcbFieldElem, y::AcbFieldElem) - ccall((:acb_add, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), - z, x, y, parent(z).prec) + @ccall libflint.acb_add(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, y::Ref{AcbFieldElem}, parent(z).prec::Int)::Nothing return z end function sub!(z::AcbFieldElem, x::AcbFieldElem, y::AcbFieldElem) - ccall((:acb_sub, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), - z, x, y, parent(z).prec) + @ccall libflint.acb_sub(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, y::Ref{AcbFieldElem}, parent(z).prec::Int)::Nothing return z end function mul!(z::AcbFieldElem, x::AcbFieldElem, y::AcbFieldElem) - ccall((:acb_mul, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), - z, x, y, parent(z).prec) + @ccall libflint.acb_mul(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, y::Ref{AcbFieldElem}, parent(z).prec::Int)::Nothing return z end function div!(z::AcbFieldElem, x::AcbFieldElem, y::AcbFieldElem) - ccall((:acb_div, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), - z, x, y, parent(z).prec) + @ccall libflint.acb_div(z::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, y::Ref{AcbFieldElem}, parent(z).prec::Int)::Nothing return z end @@ -1615,62 +1569,57 @@ _real_ptr(x::AcbFieldElemOrPtr) = @ccall libflint.acb_real_ptr(x::Ref{AcbFieldEl _imag_ptr(x::AcbFieldElemOrPtr) = @ccall libflint.acb_imag_ptr(x::Ref{AcbFieldElem})::Ptr{ArbFieldElem} function _acb_set(x::AcbFieldElemOrPtr, y::Int) - ccall((:acb_set_si, libflint), Nothing, (Ref{AcbFieldElem}, Int), x, y) + @ccall libflint.acb_set_si(x::Ref{AcbFieldElem}, y::Int)::Nothing end function _acb_set(x::AcbFieldElemOrPtr, y::UInt) - ccall((:acb_set_ui, libflint), Nothing, (Ref{AcbFieldElem}, UInt), x, y) + @ccall libflint.acb_set_ui(x::Ref{AcbFieldElem}, y::UInt)::Nothing end function _acb_set(x::AcbFieldElemOrPtr, y::Float64) - ccall((:acb_set_d, libflint), Nothing, (Ref{AcbFieldElem}, Float64), x, y) + @ccall libflint.acb_set_d(x::Ref{AcbFieldElem}, y::Float64)::Nothing end function _acb_set(x::AcbFieldElemOrPtr, y::Union{Int,UInt,Float64}, p::Int) _acb_set(x, y) - ccall((:acb_set_round, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), x, x, p) + @ccall libflint.acb_set_round(x::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, p::Int)::Nothing end function _acb_set(x::AcbFieldElemOrPtr, y::ZZRingElem) - ccall((:acb_set_fmpz, libflint), Nothing, (Ref{AcbFieldElem}, Ref{ZZRingElem}), x, y) + @ccall libflint.acb_set_fmpz(x::Ref{AcbFieldElem}, y::Ref{ZZRingElem})::Nothing end function _acb_set(x::AcbFieldElemOrPtr, y::ZZRingElem, p::Int) - ccall((:acb_set_round_fmpz, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{ZZRingElem}, Int), x, y, p) + @ccall libflint.acb_set_round_fmpz(x::Ref{AcbFieldElem}, y::Ref{ZZRingElem}, p::Int)::Nothing end function _acb_set(x::AcbFieldElemOrPtr, y::QQFieldElem, p::Int) - ccall((:acb_set_fmpq, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{QQFieldElem}, Int), x, y, p) + @ccall libflint.acb_set_fmpq(x::Ref{AcbFieldElem}, y::Ref{QQFieldElem}, p::Int)::Nothing end function _acb_set(x::AcbFieldElemOrPtr, y::ArbFieldElem) - ccall((:acb_set_arb, libflint), Nothing, (Ref{AcbFieldElem}, Ref{ArbFieldElem}), x, y) + @ccall libflint.acb_set_arb(x::Ref{AcbFieldElem}, y::Ref{ArbFieldElem})::Nothing end function _acb_set(x::AcbFieldElemOrPtr, y::ArbFieldElem, p::Int) _acb_set(x, y) - ccall((:acb_set_round, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), x, x, p) + @ccall libflint.acb_set_round(x::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, p::Int)::Nothing end function _acb_set(x::AcbFieldElemOrPtr, y::AcbFieldElemOrPtr) - ccall((:acb_set, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}), x, y) + @ccall libflint.acb_set(x::Ref{AcbFieldElem}, y::Ref{AcbFieldElem})::Nothing end function _acb_set(x::AcbFieldElemOrPtr, y::Ptr{acb_struct}) - ccall((:acb_set, libflint), Nothing, (Ref{AcbFieldElem}, Ptr{acb_struct}), x, y) + @ccall libflint.acb_set(x::Ref{AcbFieldElem}, y::Ptr{acb_struct})::Nothing end function _acb_set(x::Ptr{acb_struct}, y::AcbFieldElemOrPtr) - ccall((:acb_set, libflint), Nothing, (Ptr{acb_struct}, Ref{AcbFieldElem}) , x, y) + @ccall libflint.acb_set(x::Ptr{acb_struct}, y::Ref{AcbFieldElem})::Nothing end function _acb_set(x::AcbFieldElemOrPtr, y::AcbFieldElemOrPtr, p::Int) - ccall((:acb_set_round, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), x, y, p) + @ccall libflint.acb_set_round(x::Ref{AcbFieldElem}, y::Ref{AcbFieldElem}, p::Int)::Nothing end function _acb_set(x::AcbFieldElemOrPtr, y::AbstractString, p::Int) @@ -1695,21 +1644,17 @@ function _acb_set(x::AcbFieldElemOrPtr, y::BigFloat, p::Int) end function _acb_set(x::AcbFieldElemOrPtr, yz::Tuple{Int,Int}, p::Int) - ccall((:acb_set_si_si, libflint), Nothing, - (Ref{AcbFieldElem}, Int, Int), x, yz[1], yz[2]) - ccall((:acb_set_round, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), x, x, p) + @ccall libflint.acb_set_si_si(x::Ref{AcbFieldElem}, yz[1]::Int, yz[2]::Int)::Nothing + @ccall libflint.acb_set_round(x::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, p::Int)::Nothing end function _acb_set(x::AcbFieldElemOrPtr, yz::Tuple{ArbFieldElem,ArbFieldElem}) - ccall((:acb_set_arb_arb, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, yz[1], yz[2]) + @ccall libflint.acb_set_arb_arb(x::Ref{AcbFieldElem}, yz[1]::Ref{ArbFieldElem}, yz[2]::Ref{ArbFieldElem})::Nothing end function _acb_set(x::AcbFieldElemOrPtr, yz::Tuple{ArbFieldElem,ArbFieldElem}, p::Int) _acb_set(x, yz) - ccall((:acb_set_round, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), x, x, p) + @ccall libflint.acb_set_round(x::Ref{AcbFieldElem}, x::Ref{AcbFieldElem}, p::Int)::Nothing end function _acb_set(x::AcbFieldElemOrPtr, yz::Tuple{QQFieldElem,QQFieldElem}, p::Int) diff --git a/src/arb/acb_calc.jl b/src/arb/acb_calc.jl index f43001ce4..9bf9bd69d 100644 --- a/src/arb/acb_calc.jl +++ b/src/arb/acb_calc.jl @@ -37,10 +37,10 @@ function integrate(C::ComplexField, F, a, b; end ctol = mag_struct(0, 0) - ccall((:mag_init, libflint), Nothing, (Ref{mag_struct},), ctol) + @ccall libflint.mag_init(ctol::Ref{mag_struct})::Nothing if abs_tol === -1.0 - ccall((:mag_set_ui_2exp_si, libflint), Nothing, (Ref{mag_struct}, UInt, Int), ctol, 1, -precision(Balls)) + @ccall libflint.mag_set_ui_2exp_si(ctol::Ref{mag_struct}, 1::UInt, (-precision(Balls))::Int)::Nothing else t = BigFloat(abs_tol, RoundDown) expo = Ref{Clong}() @@ -48,26 +48,23 @@ function integrate(C::ComplexField, F, a, b; (Ref{Clong}, Ref{BigFloat}, Cint), expo, t, Base.convert(Base.MPFR.MPFRRoundingMode, RoundDown)) - ccall((:mag_set_d, libflint), Nothing, (Ref{mag_struct}, Float64), ctol, d) - ccall((:mag_mul_2exp_si, libflint), Nothing, - (Ref{mag_struct}, Ref{mag_struct}, Int), ctol, ctol, Int(expo[])) + @ccall libflint.mag_set_d(ctol::Ref{mag_struct}, d::Float64)::Nothing + @ccall libflint.mag_mul_2exp_si(ctol::Ref{mag_struct}, ctol::Ref{mag_struct}, Int(expo[])::Int)::Nothing end res = C() - status = ccall((:acb_calc_integrate, libflint), UInt, - (Ref{ComplexFieldElem}, #res - Ptr{Nothing}, #func - Any, #params - Ref{ComplexFieldElem}, #a - Ref{ComplexFieldElem}, #b - Int, #rel_goal - Ref{mag_struct}, #abs_tol - Ref{acb_calc_integrate_opts}, #opts - Int), - res, acb_calc_func_wrap_c(), F, lower, upper, cgoal, ctol, opts, precision(Balls)) + status = @ccall libflint.acb_calc_integrate(res::Ref{ComplexFieldElem}, acb_calc_func_wrap_c()::#res + Ptr{Nothing}, F::#func + Any, lower::#params + Ref{ComplexFieldElem}, upper::#a + Ref{ComplexFieldElem}, cgoal::#b + Int, ctol::#rel_goal + Ref{mag_struct}, opts::#abs_tol + Ref{acb_calc_integrate_opts}, precision(Balls)::#opts + Int)::UInt - ccall((:mag_clear, libflint), Nothing, (Ref{mag_struct},), ctol) + @ccall libflint.mag_clear(ctol::Ref{mag_struct})::Nothing if status == ARB_CALC_SUCCESS nothing diff --git a/src/arb/acb_mat.jl b/src/arb/acb_mat.jl index aa544c74e..f1c6394d4 100644 --- a/src/arb/acb_mat.jl +++ b/src/arb/acb_mat.jl @@ -92,7 +92,7 @@ number_of_columns(a::AcbMatrix) = a.c function deepcopy_internal(x::AcbMatrix, dict::IdDict) z = similar(x) - ccall((:acb_mat_set, libflint), Nothing, (Ref{AcbMatrix}, Ref{AcbMatrix}), z, x) + @ccall libflint.acb_mat_set(z::Ref{AcbMatrix}, x::Ref{AcbMatrix})::Nothing return z end @@ -112,8 +112,7 @@ end function transpose(x::AcbMatrix) z = similar(x, ncols(x), nrows(x)) - ccall((:acb_mat_transpose, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}), z, x) + @ccall libflint.acb_mat_transpose(z::Ref{AcbMatrix}, x::Ref{AcbMatrix})::Nothing return z end @@ -126,27 +125,21 @@ end function +(x::AcbMatrix, y::AcbMatrix) check_parent(x, y) z = similar(x) - ccall((:acb_mat_add, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Ref{AcbMatrix}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.acb_mat_add(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Ref{AcbMatrix}, precision(base_ring(x))::Int)::Nothing return z end function -(x::AcbMatrix, y::AcbMatrix) check_parent(x, y) z = similar(x) - ccall((:acb_mat_sub, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Ref{AcbMatrix}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.acb_mat_sub(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Ref{AcbMatrix}, precision(base_ring(x))::Int)::Nothing return z end function *(x::AcbMatrix, y::AcbMatrix) ncols(x) != nrows(y) && error("Matrices have wrong dimensions") z = similar(x, nrows(x), ncols(y)) - ccall((:acb_mat_mul, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Ref{AcbMatrix}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.acb_mat_mul(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Ref{AcbMatrix}, precision(base_ring(x))::Int)::Nothing return z end @@ -159,17 +152,13 @@ end function ^(x::AcbMatrix, y::UInt) nrows(x) != ncols(x) && error("Matrix must be square") z = similar(x) - ccall((:acb_mat_pow_ui, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, UInt, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.acb_mat_pow_ui(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::UInt, precision(base_ring(x))::Int)::Nothing return z end function *(x::AcbMatrix, y::Int) z = similar(x) - ccall((:acb_mat_scalar_mul_si, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Int, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.acb_mat_scalar_mul_si(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Int, precision(base_ring(x))::Int)::Nothing return z end @@ -177,9 +166,7 @@ end function *(x::AcbMatrix, y::ZZRingElem) z = similar(x) - ccall((:acb_mat_scalar_mul_fmpz, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Ref{ZZRingElem}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.acb_mat_scalar_mul_fmpz(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Ref{ZZRingElem}, precision(base_ring(x))::Int)::Nothing return z end @@ -187,9 +174,7 @@ end function *(x::AcbMatrix, y::ArbFieldElem) z = similar(x) - ccall((:acb_mat_scalar_mul_arb, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Ref{ArbFieldElem}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.acb_mat_scalar_mul_arb(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Ref{ArbFieldElem}, precision(base_ring(x))::Int)::Nothing return z end @@ -197,9 +182,7 @@ end function *(x::AcbMatrix, y::AcbFieldElem) z = similar(x) - ccall((:acb_mat_scalar_mul_acb, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Ref{AcbFieldElem}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.acb_mat_scalar_mul_acb(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Ref{AcbFieldElem}, precision(base_ring(x))::Int)::Nothing return z end @@ -289,8 +272,7 @@ end function ldexp(x::AcbMatrix, y::Int) z = similar(x) - ccall((:acb_mat_scalar_mul_2exp_si, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Int), z, x, y) + @ccall libflint.acb_mat_scalar_mul_2exp_si(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Int)::Nothing return z end @@ -307,20 +289,19 @@ Return `true` if the matrices of balls $x$ and $y$ are precisely equal, i.e. if all matrix entries have the same midpoints and radii. """ function isequal(x::AcbMatrix, y::AcbMatrix) - r = ccall((:acb_mat_equal, libflint), Cint, - (Ref{AcbMatrix}, Ref{AcbMatrix}), x, y) + r = @ccall libflint.acb_mat_equal(x::Ref{AcbMatrix}, y::Ref{AcbMatrix})::Cint return Bool(r) end function ==(x::AcbMatrix, y::AcbMatrix) fl = check_parent(x, y, false) !fl && return false - r = ccall((:acb_mat_eq, libflint), Cint, (Ref{AcbMatrix}, Ref{AcbMatrix}), x, y) + r = @ccall libflint.acb_mat_eq(x::Ref{AcbMatrix}, y::Ref{AcbMatrix})::Cint return Bool(r) end function !=(x::AcbMatrix, y::AcbMatrix) - r = ccall((:acb_mat_ne, libflint), Cint, (Ref{AcbMatrix}, Ref{AcbMatrix}), x, y) + r = @ccall libflint.acb_mat_ne(x::Ref{AcbMatrix}, y::Ref{AcbMatrix})::Cint return Bool(r) end @@ -331,8 +312,7 @@ Returns `true` if all entries of $x$ overlap with the corresponding entry of $y$, otherwise return `false`. """ function overlaps(x::AcbMatrix, y::AcbMatrix) - r = ccall((:acb_mat_overlaps, libflint), Cint, - (Ref{AcbMatrix}, Ref{AcbMatrix}), x, y) + r = @ccall libflint.acb_mat_overlaps(x::Ref{AcbMatrix}, y::Ref{AcbMatrix})::Cint return Bool(r) end @@ -343,8 +323,7 @@ Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ function contains(x::AcbMatrix, y::AcbMatrix) - r = ccall((:acb_mat_contains, libflint), Cint, - (Ref{AcbMatrix}, Ref{AcbMatrix}), x, y) + r = @ccall libflint.acb_mat_contains(x::Ref{AcbMatrix}, y::Ref{AcbMatrix})::Cint return Bool(r) end @@ -361,8 +340,7 @@ Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ function contains(x::AcbMatrix, y::ZZMatrix) - r = ccall((:acb_mat_contains_fmpz_mat, libflint), Cint, - (Ref{AcbMatrix}, Ref{ZZMatrix}), x, y) + r = @ccall libflint.acb_mat_contains_fmpz_mat(x::Ref{AcbMatrix}, y::Ref{ZZMatrix})::Cint return Bool(r) end @@ -373,8 +351,7 @@ Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ function contains(x::AcbMatrix, y::QQMatrix) - r = ccall((:acb_mat_contains_fmpq_mat, libflint), Cint, - (Ref{AcbMatrix}, Ref{QQMatrix}), x, y) + r = @ccall libflint.acb_mat_contains_fmpq_mat(x::Ref{AcbMatrix}, y::Ref{QQMatrix})::Cint return Bool(r) end @@ -393,7 +370,7 @@ end ################################################################################ isreal(x::AcbMatrix) = -Bool(ccall((:acb_mat_is_real, libflint), Cint, (Ref{AcbMatrix}, ), x)) +Bool(@ccall libflint.acb_mat_is_real(x::Ref{AcbMatrix})::Cint) ############################################################################### # @@ -417,8 +394,7 @@ end function is_invertible_with_inverse(x::AcbMatrix) ncols(x) != nrows(x) && return false, x z = similar(x) - r = ccall((:acb_mat_inv, libflint), Cint, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Int), z, x, precision(base_ring(x))) + r = @ccall libflint.acb_mat_inv(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, precision(base_ring(x))::Int)::Cint return Bool(r), z end @@ -442,33 +418,25 @@ end function divexact(x::AcbMatrix, y::Int; check::Bool=true) y == 0 && throw(DivideError()) z = similar(x) - ccall((:acb_mat_scalar_div_si, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Int, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.acb_mat_scalar_div_si(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Int, precision(base_ring(x))::Int)::Nothing return z end function divexact(x::AcbMatrix, y::ZZRingElem; check::Bool=true) z = similar(x) - ccall((:acb_mat_scalar_div_fmpz, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Ref{ZZRingElem}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.acb_mat_scalar_div_fmpz(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Ref{ZZRingElem}, precision(base_ring(x))::Int)::Nothing return z end function divexact(x::AcbMatrix, y::ArbFieldElem; check::Bool=true) z = similar(x) - ccall((:acb_mat_scalar_div_arb, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Ref{ArbFieldElem}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.acb_mat_scalar_div_arb(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Ref{ArbFieldElem}, precision(base_ring(x))::Int)::Nothing return z end function divexact(x::AcbMatrix, y::AcbFieldElem; check::Bool=true) z = similar(x) - ccall((:acb_mat_scalar_div_acb, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Ref{AcbFieldElem}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.acb_mat_scalar_div_acb(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Ref{AcbFieldElem}, precision(base_ring(x))::Int)::Nothing return z end @@ -489,8 +457,7 @@ divexact(x::AcbMatrix, y::Rational{T}; check::Bool=true) where T <: Union{Int, B function charpoly(x::AcbPolyRing, y::AcbMatrix) base_ring(x) != base_ring(y) && error("Base rings must coincide") z = x() - ccall((:acb_mat_charpoly, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbMatrix}, Int), z, y, precision(base_ring(y))) + @ccall libflint.acb_mat_charpoly(z::Ref{AcbPolyRingElem}, y::Ref{AcbMatrix}, precision(base_ring(y))::Int)::Nothing return z end @@ -503,8 +470,7 @@ end function det(x::AcbMatrix) ncols(x) != nrows(x) && error("Matrix must be square") z = base_ring(x)() - ccall((:acb_mat_det, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbMatrix}, Int), z, x, precision(base_ring(x))) + @ccall libflint.acb_mat_det(z::Ref{AcbFieldElem}, x::Ref{AcbMatrix}, precision(base_ring(x))::Int)::Nothing return z end @@ -517,8 +483,7 @@ end function Base.exp(x::AcbMatrix) ncols(x) != nrows(x) && error("Matrix must be square") z = similar(x) - ccall((:acb_mat_exp, libflint), Nothing, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Int), z, x, precision(base_ring(x))) + @ccall libflint.acb_mat_exp(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, precision(base_ring(x))::Int)::Nothing return z end @@ -530,9 +495,7 @@ end function lu!(P::Perm, z::AcbMatrix, x::AcbMatrix) P.d .-= 1 - r = ccall((:acb_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{AcbMatrix}, Ref{AcbMatrix}, Int), - P.d, z, x, precision(base_ring(x))) + r = @ccall libflint.acb_mat_lu(P.d::Ptr{Int}, z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, precision(base_ring(x))::Int)::Cint r == 0 && error("Could not find $(nrows(x)) invertible pivot elements") P.d .+= 1 inv!(P) @@ -544,18 +507,14 @@ function lu!(P::Perm, x::AcbMatrix) end function _solve!(z::AcbMatrix, x::AcbMatrix, y::AcbMatrix) - r = ccall((:acb_mat_solve, libflint), Cint, - (Ref{AcbMatrix}, Ref{AcbMatrix}, Ref{AcbMatrix}, Int), - z, x, y, precision(base_ring(x))) + r = @ccall libflint.acb_mat_solve(z::Ref{AcbMatrix}, x::Ref{AcbMatrix}, y::Ref{AcbMatrix}, precision(base_ring(x))::Int)::Cint r == 0 && error("Matrix cannot be inverted numerically") nothing end function _solve_lu_precomp!(z::AcbMatrix, P::Perm, LU::AcbMatrix, y::AcbMatrix) Q = inv(P) - ccall((:acb_mat_solve_lu_precomp, libflint), Nothing, - (Ref{AcbMatrix}, Ptr{Int}, Ref{AcbMatrix}, Ref{AcbMatrix}, Int), - z, Q.d .- 1, LU, y, precision(base_ring(LU))) + @ccall libflint.acb_mat_solve_lu_precomp(z::Ref{AcbMatrix}, (Q.d .- 1)::Ptr{Int}, LU::Ref{AcbMatrix}, y::Ref{AcbMatrix}, precision(base_ring(LU))::Int)::Nothing nothing end @@ -668,9 +627,7 @@ function swap_rows(x::AcbMatrix, i::Int, j::Int) end function swap_rows!(x::AcbMatrix, i::Int, j::Int) - ccall((:acb_mat_swap_rows, libflint), Nothing, - (Ref{AcbMatrix}, Ptr{Nothing}, Int, Int), - x, C_NULL, i - 1, j - 1) + @ccall libflint.acb_mat_swap_rows(x::Ref{AcbMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int)::Nothing end ################################################################################ @@ -689,13 +646,10 @@ function bound_inf_norm(x::AcbMatrix) z = ArbFieldElem() GC.@preserve x z begin t = _rad_ptr(z) - ccall((:acb_mat_bound_inf_norm, libflint), Nothing, - (Ptr{mag_struct}, Ref{AcbMatrix}), t, x) + @ccall libflint.acb_mat_bound_inf_norm(t::Ptr{mag_struct}, x::Ref{AcbMatrix})::Nothing s = _mid_ptr(z) - ccall((:arf_set_mag, libflint), Nothing, - (Ptr{arf_struct}, Ptr{mag_struct}), s, t) - ccall((:mag_zero, libflint), Nothing, - (Ptr{mag_struct},), t) + @ccall libflint.arf_set_mag(s::Ptr{arf_struct}, t::Ptr{mag_struct})::Nothing + @ccall libflint.mag_zero(t::Ptr{mag_struct})::Nothing end return ArbField(precision(base_ring(x)))(z) end @@ -913,8 +867,7 @@ end ################################################################################ @inline mat_entry_ptr(A::AcbMatrix, i::Int, j::Int) = -ccall((:acb_mat_entry_ptr, libflint), - Ptr{AcbFieldElem}, (Ref{AcbMatrix}, Int, Int), A, i-1, j-1) +@ccall libflint.acb_mat_entry_ptr(A::Ref{AcbMatrix}, (i-1)::Int, (j-1)::Int)::Ptr{AcbFieldElem} ############################################################################### # @@ -948,10 +901,7 @@ promote_rule(::Type{AcbMatrix}, ::Type{ArbMatrix}) = AcbMatrix function __approx_eig_qr!(v::Ptr{acb_struct}, R::AcbMatrix, A::AcbMatrix) n = nrows(A) - ccall((:acb_mat_approx_eig_qr, libflint), Cint, - (Ptr{acb_struct}, Ptr{Nothing}, Ref{AcbMatrix}, - Ref{AcbMatrix}, Ptr{Nothing}, Int, Int), - v, C_NULL, R, A, C_NULL, 0, precision(parent(A))) + @ccall libflint.acb_mat_approx_eig_qr(v::Ptr{acb_struct}, C_NULL::Ptr{Nothing}, R::Ref{AcbMatrix}, A::Ref{AcbMatrix}, C_NULL::Ptr{Nothing}, 0::Int, precision(parent(A))::Int)::Cint return nothing end @@ -971,9 +921,7 @@ function _eig_multiple(A::AcbMatrix, check::Bool = true) v_approx = acb_vec(n) R = zero_matrix(base_ring(A), n, n) __approx_eig_qr!(v, R, A) - b = ccall((:acb_mat_eig_multiple, libflint), Cint, - (Ptr{acb_struct}, Ref{AcbMatrix}, Ptr{acb_struct}, Ref{AcbMatrix}, Int), - v_approx, A, v, R, precision(base_ring(A))) + b = @ccall libflint.acb_mat_eig_multiple(v_approx::Ptr{acb_struct}, A::Ref{AcbMatrix}, v::Ptr{acb_struct}, R::Ref{AcbMatrix}, precision(base_ring(A))::Int)::Cint check && b == 0 && error("Could not isolate eigenvalues of matrix $A") z = array(base_ring(A), v, n) acb_vec_clear(v, n) @@ -1005,20 +953,11 @@ function _eig_simple(A::AcbMatrix; check::Bool = true, algorithm::Symbol = :defa R = zero_matrix(base_ring(A), n, n) __approx_eig_qr!(v, Rapprox, A) if algorithm == :vdhoeven_mourrain - b = ccall((:acb_mat_eig_simple_vdhoeven_mourrain, libflint), Cint, - (Ptr{acb_struct}, Ref{AcbMatrix}, Ref{AcbMatrix}, - Ref{AcbMatrix}, Ptr{acb_struct}, Ref{AcbMatrix}, Int), - v_approx, L, R, A, v, Rapprox, precision(base_ring(A))) + b = @ccall libflint.acb_mat_eig_simple_vdhoeven_mourrain(v_approx::Ptr{acb_struct}, L::Ref{AcbMatrix}, R::Ref{AcbMatrix}, A::Ref{AcbMatrix}, v::Ptr{acb_struct}, Rapprox::Ref{AcbMatrix}, precision(base_ring(A))::Int)::Cint elseif algorithm == :rump - b = ccall((:acb_mat_eig_simple_rump, libflint), Cint, - (Ptr{acb_struct}, Ref{AcbMatrix}, Ref{AcbMatrix}, - Ref{AcbMatrix}, Ptr{acb_struct}, Ref{AcbMatrix}, Int), - v_approx, L, R, A, v, Rapprox, precision(base_ring(A))) + b = @ccall libflint.acb_mat_eig_simple_rump(v_approx::Ptr{acb_struct}, L::Ref{AcbMatrix}, R::Ref{AcbMatrix}, A::Ref{AcbMatrix}, v::Ptr{acb_struct}, Rapprox::Ref{AcbMatrix}, precision(base_ring(A))::Int)::Cint elseif algorithm == :default - b = ccall((:acb_mat_eig_simple, libflint), Cint, - (Ptr{acb_struct}, Ref{AcbMatrix}, Ref{AcbMatrix}, - Ref{AcbMatrix}, Ptr{acb_struct}, Ref{AcbMatrix}, Int), - v_approx, L, R, A, v, Rapprox, precision(base_ring(A))) + b = @ccall libflint.acb_mat_eig_simple(v_approx::Ptr{acb_struct}, L::Ref{AcbMatrix}, R::Ref{AcbMatrix}, A::Ref{AcbMatrix}, v::Ptr{acb_struct}, Rapprox::Ref{AcbMatrix}, precision(base_ring(A))::Int)::Cint else error("Algorithm $algorithm not supported") end diff --git a/src/arb/acb_poly.jl b/src/arb/acb_poly.jl index cdc6bac12..2fb088b6c 100644 --- a/src/arb/acb_poly.jl +++ b/src/arb/acb_poly.jl @@ -16,12 +16,10 @@ elem_type(::Type{AcbPolyRing}) = AcbPolyRingElem dense_poly_type(::Type{AcbFieldElem}) = AcbPolyRingElem -length(x::AcbPolyRingElem) = ccall((:acb_poly_length, libflint), Int, - (Ref{AcbPolyRingElem},), x) +length(x::AcbPolyRingElem) = @ccall libflint.acb_poly_length(x::Ref{AcbPolyRingElem})::Int function set_length!(x::AcbPolyRingElem, n::Int) - ccall((:_acb_poly_set_length, libflint), Nothing, - (Ref{AcbPolyRingElem}, Int), x, n) + @ccall libflint._acb_poly_set_length(x::Ref{AcbPolyRingElem}, n::Int)::Nothing return x end @@ -30,8 +28,7 @@ degree(x::AcbPolyRingElem) = length(x) - 1 function coeff(a::AcbPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) t = parent(a).base_ring() - ccall((:acb_poly_get_coeff_acb, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbPolyRingElem}, Int), t, a, n) + @ccall libflint.acb_poly_get_coeff_acb(t::Ref{AcbFieldElem}, a::Ref{AcbPolyRingElem}, n::Int)::Nothing return t end @@ -117,8 +114,7 @@ end ############################################################################### function isequal(x::AcbPolyRingElem, y::AcbPolyRingElem) - return ccall((:acb_poly_equal, libflint), Bool, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}), x, y) + return @ccall libflint.acb_poly_equal(x::Ref{AcbPolyRingElem}, y::Ref{AcbPolyRingElem})::Bool end @doc raw""" @@ -128,8 +124,7 @@ Return `true` if the coefficient boxes of $x$ overlap the coefficient boxes of $y$, otherwise return `false`. """ function overlaps(x::AcbPolyRingElem, y::AcbPolyRingElem) - return ccall((:acb_poly_overlaps, libflint), Bool, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}), x, y) + return @ccall libflint.acb_poly_overlaps(x::Ref{AcbPolyRingElem}, y::Ref{AcbPolyRingElem})::Bool end @doc raw""" @@ -139,8 +134,7 @@ Return `true` if the coefficient boxes of $x$ contain the corresponding coefficient boxes of $y$, otherwise return `false`. """ function contains(x::AcbPolyRingElem, y::AcbPolyRingElem) - return ccall((:acb_poly_contains, libflint), Bool, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}), x, y) + return @ccall libflint.acb_poly_contains(x::Ref{AcbPolyRingElem}, y::Ref{AcbPolyRingElem})::Bool end @doc raw""" @@ -150,8 +144,7 @@ Return `true` if the coefficient boxes of $x$ contain the corresponding exact coefficients of $y$, otherwise return `false`. """ function contains(x::AcbPolyRingElem, y::ZZPolyRingElem) - return ccall((:acb_poly_contains_fmpz_poly, libflint), Bool, - (Ref{AcbPolyRingElem}, Ref{ZZPolyRingElem}), x, y) + return @ccall libflint.acb_poly_contains_fmpz_poly(x::Ref{AcbPolyRingElem}, y::Ref{ZZPolyRingElem})::Bool end @doc raw""" @@ -161,8 +154,7 @@ Return `true` if the coefficient boxes of $x$ contain the corresponding exact coefficients of $y$, otherwise return `false`. """ function contains(x::AcbPolyRingElem, y::QQPolyRingElem) - return ccall((:acb_poly_contains_fmpq_poly, libflint), Bool, - (Ref{AcbPolyRingElem}, Ref{QQPolyRingElem}), x, y) + return @ccall libflint.acb_poly_contains_fmpq_poly(x::Ref{AcbPolyRingElem}, y::Ref{QQPolyRingElem})::Bool end function ==(x::AcbPolyRingElem, y::AcbPolyRingElem) @@ -195,13 +187,12 @@ in case it is, otherwise sets $t$ to `false`. """ function unique_integer(x::AcbPolyRingElem) z = ZZPolyRing(ZZ, var(parent(x)))() - unique = ccall((:acb_poly_get_unique_fmpz_poly, libflint), Int, - (Ref{ZZPolyRingElem}, Ref{AcbPolyRingElem}), z, x) + unique = @ccall libflint.acb_poly_get_unique_fmpz_poly(z::Ref{ZZPolyRingElem}, x::Ref{AcbPolyRingElem})::Int return (unique != 0, z) end function isreal(x::AcbPolyRingElem) - return ccall((:acb_poly_is_real, libflint), Cint, (Ref{AcbPolyRingElem}, ), x) != 0 + return @ccall libflint.acb_poly_is_real(x::Ref{AcbPolyRingElem})::Cint != 0 end ############################################################################### @@ -213,16 +204,14 @@ end function shift_left(x::AcbPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:acb_poly_shift_left, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Int), z, x, len) + @ccall libflint.acb_poly_shift_left(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, len::Int)::Nothing return z end function shift_right(x::AcbPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:acb_poly_shift_right, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Int), z, x, len) + @ccall libflint.acb_poly_shift_right(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, len::Int)::Nothing return z end @@ -259,9 +248,7 @@ end function ^(x::AcbPolyRingElem, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() - ccall((:acb_poly_pow_ui, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, UInt, Int), - z, x, y, precision(parent(x))) + @ccall libflint.acb_poly_pow_ui(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, y::UInt, precision(parent(x))::Int)::Nothing return z end @@ -345,17 +332,14 @@ function truncate(a::AcbPolyRingElem, n::Int) end # todo: implement set_trunc in ArbFieldElem z = deepcopy(a) - ccall((:acb_poly_truncate, libflint), Nothing, - (Ref{AcbPolyRingElem}, Int), z, n) + @ccall libflint.acb_poly_truncate(z::Ref{AcbPolyRingElem}, n::Int)::Nothing return z end function mullow(x::AcbPolyRingElem, y::AcbPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() - ccall((:acb_poly_mullow, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Int, Int), - z, x, y, n, precision(parent(x))) + @ccall libflint.acb_poly_mullow(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, y::Ref{AcbPolyRingElem}, n::Int, precision(parent(x))::Int)::Nothing return z end @@ -381,9 +365,7 @@ end function evaluate(x::AcbPolyRingElem, y::AcbFieldElem) z = parent(y)() - ccall((:acb_poly_evaluate, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbPolyRingElem}, Ref{AcbFieldElem}, Int), - z, x, y, precision(parent(y))) + @ccall libflint.acb_poly_evaluate(z::Ref{AcbFieldElem}, x::Ref{AcbPolyRingElem}, y::Ref{AcbFieldElem}, precision(parent(y))::Int)::Nothing return z end @@ -402,9 +384,7 @@ its derivative evaluated at $y$. function evaluate2(x::AcbPolyRingElem, y::AcbFieldElem) z = parent(y)() w = parent(y)() - ccall((:acb_poly_evaluate2, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{AcbPolyRingElem}, Ref{AcbFieldElem}, Int), - z, w, x, y, precision(parent(y))) + @ccall libflint.acb_poly_evaluate2(z::Ref{AcbFieldElem}, w::Ref{AcbFieldElem}, x::Ref{AcbPolyRingElem}, y::Ref{AcbFieldElem}, precision(parent(y))::Int)::Nothing return z, w end @@ -418,9 +398,7 @@ evaluate2(x::AcbPolyRingElem, y::RingElement) = evaluate2(x, base_ring(parent(x) function AbstractAlgebra._compose_right(x::AcbPolyRingElem, y::AcbPolyRingElem) z = parent(x)() - ccall((:acb_poly_compose, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Int), - z, x, y, precision(parent(x))) + @ccall libflint.acb_poly_compose(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, y::Ref{AcbPolyRingElem}, precision(parent(x))::Int)::Nothing return z end @@ -432,15 +410,13 @@ end function derivative(x::AcbPolyRingElem) z = parent(x)() - ccall((:acb_poly_derivative, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Int), z, x, precision(parent(x))) + @ccall libflint.acb_poly_derivative(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, precision(parent(x))::Int)::Nothing return z end function integral(x::AcbPolyRingElem) z = parent(x)() - ccall((:acb_poly_integral, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Int), z, x, precision(parent(x))) + @ccall libflint.acb_poly_integral(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, precision(parent(x))::Int)::Nothing return z end @@ -451,7 +427,7 @@ end ############################################################################### function acb_vec(b::Vector{AcbFieldElem}) - v = ccall((:_acb_vec_init, libflint), Ptr{acb_struct}, (Int,), length(b)) + v = @ccall libflint._acb_vec_init(length(b)::Int)::Ptr{acb_struct} for i in 1:length(b) _acb_set(v + (i-1)*sizeof(acb_struct), b[i]) end @@ -475,8 +451,7 @@ Construct a polynomial in the given polynomial ring from a list of its roots. function from_roots(R::AcbPolyRing, b::Vector{AcbFieldElem}) z = R() tmp = acb_vec(b) - ccall((:acb_poly_product_roots, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ptr{acb_struct}, Int, Int), z, tmp, length(b), precision(R)) + @ccall libflint.acb_poly_product_roots(z::Ref{AcbPolyRingElem}, tmp::Ptr{acb_struct}, length(b)::Int, precision(R)::Int)::Nothing acb_vec_clear(tmp, length(b)) return z end @@ -487,9 +462,7 @@ end function evaluate_fast(x::AcbPolyRingElem, b::Vector{AcbFieldElem}) tmp = acb_vec(b) - ccall((:acb_poly_evaluate_vec_fast, libflint), Nothing, - (Ptr{acb_struct}, Ref{AcbPolyRingElem}, Ptr{acb_struct}, Int, Int), - tmp, x, tmp, length(b), precision(parent(x))) + @ccall libflint.acb_poly_evaluate_vec_fast(tmp::Ptr{acb_struct}, x::Ref{AcbPolyRingElem}, tmp::Ptr{acb_struct}, length(b)::Int, precision(parent(x))::Int)::Nothing res = array(base_ring(parent(x)), tmp, length(b)) acb_vec_clear(tmp, length(b)) return res @@ -500,9 +473,7 @@ function interpolate_newton(R::AcbPolyRing, xs::Vector{AcbFieldElem}, ys::Vector z = R() xsv = acb_vec(xs) ysv = acb_vec(ys) - ccall((:acb_poly_interpolate_newton, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ptr{acb_struct}, Ptr{acb_struct}, Int, Int), - z, xsv, ysv, length(xs), precision(R)) + @ccall libflint.acb_poly_interpolate_newton(z::Ref{AcbPolyRingElem}, xsv::Ptr{acb_struct}, ysv::Ptr{acb_struct}, length(xs)::Int, precision(R)::Int)::Nothing acb_vec_clear(xsv, length(xs)) acb_vec_clear(ysv, length(ys)) return z @@ -513,9 +484,7 @@ function interpolate_barycentric(R::AcbPolyRing, xs::Vector{AcbFieldElem}, ys::V z = R() xsv = acb_vec(xs) ysv = acb_vec(ys) - ccall((:acb_poly_interpolate_barycentric, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ptr{acb_struct}, Ptr{acb_struct}, Int, Int), - z, xsv, ysv, length(xs), precision(R)) + @ccall libflint.acb_poly_interpolate_barycentric(z::Ref{AcbPolyRingElem}, xsv::Ptr{acb_struct}, ysv::Ptr{acb_struct}, length(xs)::Int, precision(R)::Int)::Nothing acb_vec_clear(xsv, length(xs)) acb_vec_clear(ysv, length(ys)) return z @@ -526,9 +495,7 @@ function interpolate_fast(R::AcbPolyRing, xs::Vector{AcbFieldElem}, ys::Vector{A z = R() xsv = acb_vec(xs) ysv = acb_vec(ys) - ccall((:acb_poly_interpolate_fast, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ptr{acb_struct}, Ptr{acb_struct}, Int, Int), - z, xsv, ysv, length(xs), precision(R)) + @ccall libflint.acb_poly_interpolate_fast(z::Ref{AcbPolyRingElem}, xsv::Ptr{acb_struct}, ysv::Ptr{acb_struct}, length(xs)::Int, precision(R)::Int)::Nothing acb_vec_clear(xsv, length(xs)) acb_vec_clear(ysv, length(ys)) return z @@ -582,9 +549,7 @@ function roots(x::AcbPolyRingElem; target=0, isolate_real=false, initial_prec=0, while true in_roots = (wp == initial_prec) ? C_NULL : roots step_max_iter = (max_iter >= 1) ? max_iter : min(max(deg, 32), wp) - isolated = ccall((:acb_poly_find_roots, libflint), Int, - (Ptr{acb_struct}, Ref{AcbPolyRingElem}, Ptr{acb_struct}, Int, Int), - roots, x, in_roots, step_max_iter, wp) + isolated = @ccall libflint.acb_poly_find_roots(roots::Ptr{acb_struct}, x::Ref{AcbPolyRingElem}, in_roots::Ptr{acb_struct}, step_max_iter::Int, wp::Int)::Int wp = wp * 2 @@ -604,8 +569,7 @@ function roots(x::AcbPolyRingElem; target=0, isolate_real=false, initial_prec=0, end if isreal(x) - real_ok = ccall((:acb_poly_validate_real_roots, libflint), - Bool, (Ptr{acb_struct}, Ref{AcbPolyRingElem}, Int), roots, x, wp) + real_ok = @ccall libflint.acb_poly_validate_real_roots(roots::Ptr{acb_struct}, x::Ref{AcbPolyRingElem}, wp::Int)::Bool if isolate_real && !real_ok ok = false @@ -614,8 +578,8 @@ function roots(x::AcbPolyRingElem; target=0, isolate_real=false, initial_prec=0, if real_ok for i = 0 : deg - 1 im = _imag_ptr(roots + i * sizeof(acb_struct)) - if ccall((:arb_contains_zero, libflint), Bool, (Ptr{arb_struct}, ), im) - ccall((:arb_zero, libflint), Nothing, (Ptr{arb_struct}, ), im) + if @ccall libflint.arb_contains_zero(im::Ptr{arb_struct})::Bool + @ccall libflint.arb_zero(im::Ptr{arb_struct})::Nothing end end end @@ -632,8 +596,7 @@ function roots(x::AcbPolyRingElem; target=0, isolate_real=false, initial_prec=0, end if isolated == deg - ccall((:_acb_vec_sort_pretty, libflint), Nothing, - (Ptr{acb_struct}, Int), roots, deg) + @ccall libflint._acb_vec_sort_pretty(roots::Ptr{acb_struct}, deg::Int)::Nothing res = array(base_ring(parent(x)), roots, deg) end @@ -662,13 +625,11 @@ function roots_upper_bound(x::AcbPolyRingElem) p = precision(base_ring(x)) GC.@preserve x z begin t = _rad_ptr(z) - ccall((:acb_poly_root_bound_fujiwara, libflint), Nothing, - (Ptr{mag_struct}, Ref{AcbPolyRingElem}), t, x) + @ccall libflint.acb_poly_root_bound_fujiwara(t::Ptr{mag_struct}, x::Ref{AcbPolyRingElem})::Nothing s = _mid_ptr(z) - ccall((:arf_set_mag, libflint), Nothing, (Ptr{arf_struct}, Ptr{mag_struct}), s, t) - ccall((:arf_set_round, libflint), Nothing, - (Ptr{arf_struct}, Ptr{arf_struct}, Int, Cint), s, s, p, ARB_RND_CEIL) - ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct},), t) + @ccall libflint.arf_set_mag(s::Ptr{arf_struct}, t::Ptr{mag_struct})::Nothing + @ccall libflint.arf_set_round(s::Ptr{arf_struct}, s::Ptr{arf_struct}, p::Int, ARB_RND_CEIL::Cint)::Nothing + @ccall libflint.mag_zero(t::Ptr{mag_struct})::Nothing end return z end @@ -695,20 +656,17 @@ function neg!(z::AcbPolyRingElemOrPtr, a::AcbPolyRingElemOrPtr) end function fit!(z::AcbPolyRingElem, n::Int) - ccall((:acb_poly_fit_length, libflint), Nothing, - (Ref{AcbPolyRingElem}, Int), z, n) + @ccall libflint.acb_poly_fit_length(z::Ref{AcbPolyRingElem}, n::Int)::Nothing return nothing end function setcoeff!(z::AcbPolyRingElem, n::Int, x::AcbFieldElem) - ccall((:acb_poly_set_coeff_acb, libflint), Nothing, - (Ref{AcbPolyRingElem}, Int, Ref{AcbFieldElem}), z, n, x) + @ccall libflint.acb_poly_set_coeff_acb(z::Ref{AcbPolyRingElem}, n::Int, x::Ref{AcbFieldElem})::Nothing return z end function setcoeff!(z::AcbPolyRingElem, n::Int, x::Int) - ccall((:acb_poly_set_coeff_si, libflint), Nothing, - (Ref{AcbPolyRingElem}, Int, Int), z, n, x) + @ccall libflint.acb_poly_set_coeff_si(z::Ref{AcbPolyRingElem}, n::Int, x::Int)::Nothing return z end @@ -721,16 +679,12 @@ setcoeff!(z::AcbPolyRingElem, n::Int, x::Integer) = setcoeff!(z, n, flintify(x)) # function add!(z::AcbPolyRingElem, x::AcbPolyRingElem, y::AcbPolyRingElem) - ccall((:acb_poly_add, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Int), - z, x, y, precision(parent(z))) + @ccall libflint.acb_poly_add(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, y::Ref{AcbPolyRingElem}, precision(parent(z))::Int)::Nothing return z end function add!(z::AcbPolyRingElem, x::AcbPolyRingElem, y::Int) - ccall((:acb_poly_add_si, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Int, Int), - z, x, y, precision(parent(z))) + @ccall libflint.acb_poly_add_si(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, y::Int, precision(parent(z))::Int)::Nothing return z end @@ -745,9 +699,7 @@ add!(z::AcbPolyRingElem, x::Union{AcbFieldElem,IntegerUnion}, y::AcbPolyRingElem # function sub!(z::AcbPolyRingElem, x::AcbPolyRingElem, y::AcbPolyRingElem) - ccall((:acb_poly_sub, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Int), - z, x, y, precision(parent(z))) + @ccall libflint.acb_poly_sub(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, y::Ref{AcbPolyRingElem}, precision(parent(z))::Int)::Nothing return z end @@ -758,16 +710,12 @@ sub!(z::AcbPolyRingElem, x::Union{AcbFieldElem,IntegerUnion}, y::AcbPolyRingElem # function mul!(z::AcbPolyRingElem, x::AcbPolyRingElem, y::AcbPolyRingElem) - ccall((:acb_poly_mul, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Int), - z, x, y, precision(parent(z))) + @ccall libflint.acb_poly_mul(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, y::Ref{AcbPolyRingElem}, precision(parent(z))::Int)::Nothing return z end function mul!(z::AcbPolyRingElem, x::AcbPolyRingElem, y::AcbFieldElem) - ccall((:acb_poly_scalar_mul, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{AcbPolyRingElem}, Ref{AcbFieldElem}, Int), - z, x, y, precision(parent(z))) + @ccall libflint.acb_poly_scalar_mul(z::Ref{AcbPolyRingElem}, x::Ref{AcbPolyRingElem}, y::Ref{AcbFieldElem}, precision(parent(z))::Int)::Nothing return z end diff --git a/src/arb/arb.jl b/src/arb/arb.jl index 6f31026cb..0a5123d46 100644 --- a/src/arb/arb.jl +++ b/src/arb/arb.jl @@ -40,7 +40,7 @@ Return the relative accuracy of $x$ measured in bits, capped between `typemax(Int)` and `-typemax(Int)`. """ function accuracy_bits(x::ArbFieldElem) - return ccall((:arb_rel_accuracy_bits, libflint), Int, (Ref{ArbFieldElem},), x) + return @ccall libflint.arb_rel_accuracy_bits(x::Ref{ArbFieldElem})::Int end function deepcopy_internal(a::ArbFieldElem, dict::IdDict) @@ -95,9 +95,7 @@ function _arb_get_arf(x::ArbFieldElem, ::RoundingMode{:Nearest}) t = arf_struct() GC.@preserve x begin t1 = _mid_ptr(x) - ccall((:arf_set, libflint), Nothing, - (Ref{arf_struct}, Ptr{arf_struct}), - t, t1) + @ccall libflint.arf_set(t::Ref{arf_struct}, t1::Ptr{arf_struct})::Nothing end return t end @@ -120,16 +118,12 @@ for (b, i) in ((RoundingMode{:Down}, 2), (RoundingMode{:Nearest}, 4)) @eval begin function _arf_get_d(t::arf_struct, ::$b) - d = ccall((:arf_get_d, libflint), Float64, - (Ref{arf_struct}, Int), - t, $i) + d = @ccall libflint.arf_get_d(t::Ref{arf_struct}, $i::Int)::Float64 return d end function _arf_get_mpfr(t::arf_struct, ::$b) d = BigFloat() - ccall((:arf_get_mpfr, libflint), Int32, - (Ref{BigFloat}, Ref{arf_struct}, Base.MPFR.MPFRRoundingMode), - d, t, $b()) + @ccall libflint.arf_get_mpfr(d::Ref{BigFloat}, t::Ref{arf_struct}, $b()::Base.MPFR.MPFRRoundingMode)::Int32 return d end end @@ -173,13 +167,9 @@ end function native_string(x::ArbFieldElem) d = ceil(parent(x).prec * 0.30102999566398119521) - cstr = ccall((:arb_get_str, libflint), Ptr{UInt8}, - (Ref{ArbFieldElem}, Int, UInt), - x, Int(d), UInt(0)) + cstr = @ccall libflint.arb_get_str(x::Ref{ArbFieldElem}, Int(d)::Int, UInt(0)::UInt)::Ptr{UInt8} res = unsafe_string(cstr) - ccall((:flint_free, libflint), Nothing, - (Ptr{UInt8},), - cstr) + @ccall libflint.flint_free(cstr::Ptr{UInt8})::Nothing return res end @@ -217,12 +207,12 @@ Returns `true` if any part of the ball $x$ overlaps any part of the ball $y$, otherwise return `false`. """ function overlaps(x::ArbFieldElem, y::ArbFieldElem) - r = ccall((:arb_overlaps, libflint), Cint, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y) + r = @ccall libflint.arb_overlaps(x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem})::Cint return Bool(r) end #function contains(x::ArbFieldElem, y::arf) -# r = ccall((:arb_contains_arf, libflint), Cint, (Ref{ArbFieldElem}, Ref{arf}), x, y) +# r = @ccall libflint.arb_contains_arf(x::Ref{ArbFieldElem}, y::Ref{arf})::Cint # return Bool(r) #end @@ -233,7 +223,7 @@ Returns `true` if the ball $x$ contains the given rational value, otherwise return `false`. """ function contains(x::ArbFieldElem, y::QQFieldElem) - r = ccall((:arb_contains_fmpq, libflint), Cint, (Ref{ArbFieldElem}, Ref{QQFieldElem}), x, y) + r = @ccall libflint.arb_contains_fmpq(x::Ref{ArbFieldElem}, y::Ref{QQFieldElem})::Cint return Bool(r) end @@ -244,12 +234,12 @@ Returns `true` if the ball $x$ contains the given integer value, otherwise return `false`. """ function contains(x::ArbFieldElem, y::ZZRingElem) - r = ccall((:arb_contains_fmpz, libflint), Cint, (Ref{ArbFieldElem}, Ref{ZZRingElem}), x, y) + r = @ccall libflint.arb_contains_fmpz(x::Ref{ArbFieldElem}, y::Ref{ZZRingElem})::Cint return Bool(r) end function contains(x::ArbFieldElem, y::Int) - r = ccall((:arb_contains_si, libflint), Cint, (Ref{ArbFieldElem}, Int), x, y) + r = @ccall libflint.arb_contains_si(x::Ref{ArbFieldElem}, y::Int)::Cint return Bool(r) end @@ -276,8 +266,7 @@ Returns `true` if the ball $x$ contains the given floating point value, otherwise return `false`. """ function contains(x::ArbFieldElem, y::BigFloat) - r = ccall((:arb_contains_mpfr, libflint), Cint, - (Ref{ArbFieldElem}, Ref{BigFloat}), x, y) + r = @ccall libflint.arb_contains_mpfr(x::Ref{ArbFieldElem}, y::Ref{BigFloat})::Cint return Bool(r) end @@ -288,7 +277,7 @@ Returns `true` if the ball $x$ contains the ball $y$, otherwise return `false`. """ function contains(x::ArbFieldElem, y::ArbFieldElem) - r = ccall((:arb_contains, libflint), Cint, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y) + r = @ccall libflint.arb_contains(x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem})::Cint return Bool(r) end @@ -298,7 +287,7 @@ end Returns `true` if the ball $x$ contains zero, otherwise return `false`. """ function contains_zero(x::ArbFieldElem) - r = ccall((:arb_contains_zero, libflint), Cint, (Ref{ArbFieldElem}, ), x) + r = @ccall libflint.arb_contains_zero(x::Ref{ArbFieldElem})::Cint return Bool(r) end @@ -309,7 +298,7 @@ Returns `true` if the ball $x$ contains any negative value, otherwise return `false`. """ function contains_negative(x::ArbFieldElem) - r = ccall((:arb_contains_negative, libflint), Cint, (Ref{ArbFieldElem}, ), x) + r = @ccall libflint.arb_contains_negative(x::Ref{ArbFieldElem})::Cint return Bool(r) end @@ -320,7 +309,7 @@ Returns `true` if the ball $x$ contains any positive value, otherwise return `false`. """ function contains_positive(x::ArbFieldElem) - r = ccall((:arb_contains_positive, libflint), Cint, (Ref{ArbFieldElem}, ), x) + r = @ccall libflint.arb_contains_positive(x::Ref{ArbFieldElem})::Cint return Bool(r) end @@ -331,7 +320,7 @@ Returns `true` if the ball $x$ contains any non-negative value, otherwise return `false`. """ function contains_nonnegative(x::ArbFieldElem) - r = ccall((:arb_contains_nonnegative, libflint), Cint, (Ref{ArbFieldElem}, ), x) + r = @ccall libflint.arb_contains_nonnegative(x::Ref{ArbFieldElem})::Cint return Bool(r) end @@ -342,7 +331,7 @@ Returns `true` if the ball $x$ contains any nonpositive value, otherwise return `false`. """ function contains_nonpositive(x::ArbFieldElem) - r = ccall((:arb_contains_nonpositive, libflint), Cint, (Ref{ArbFieldElem}, ), x) + r = @ccall libflint.arb_contains_nonpositive(x::Ref{ArbFieldElem})::Cint return Bool(r) end @@ -359,24 +348,24 @@ Return `true` if the balls $x$ and $y$ are precisely equal, i.e. have the same midpoints and radii. """ function isequal(x::ArbFieldElem, y::ArbFieldElem) - r = ccall((:arb_equal, libflint), Cint, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y) + r = @ccall libflint.arb_equal(x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem})::Cint return Bool(r) end function ==(x::ArbFieldElem, y::ArbFieldElem) - return Bool(ccall((:arb_eq, libflint), Cint, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y)) + return Bool(@ccall libflint.arb_eq(x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem})::Cint) end function !=(x::ArbFieldElem, y::ArbFieldElem) - return Bool(ccall((:arb_ne, libflint), Cint, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y)) + return Bool(@ccall libflint.arb_ne(x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem})::Cint) end function isless(x::ArbFieldElem, y::ArbFieldElem) - return Bool(ccall((:arb_lt, libflint), Cint, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y)) + return Bool(@ccall libflint.arb_lt(x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem})::Cint) end function <=(x::ArbFieldElem, y::ArbFieldElem) - return Bool(ccall((:arb_le, libflint), Cint, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y)) + return Bool(@ccall libflint.arb_le(x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem})::Cint) end ==(x::ArbFieldElem, y::Int) = x == ArbFieldElem(y) @@ -466,7 +455,7 @@ end Return `true` if $x$ is certainly zero, otherwise return `false`. """ function iszero(x::ArbFieldElem) - return Bool(ccall((:arb_is_zero, libflint), Cint, (Ref{ArbFieldElem},), x)) + return Bool(@ccall libflint.arb_is_zero(x::Ref{ArbFieldElem})::Cint) end @doc raw""" @@ -476,7 +465,7 @@ Return `true` if $x$ is certainly not equal to zero, otherwise return `false`. """ function is_nonzero(x::ArbFieldElem) - return Bool(ccall((:arb_is_nonzero, libflint), Cint, (Ref{ArbFieldElem},), x)) + return Bool(@ccall libflint.arb_is_nonzero(x::Ref{ArbFieldElem})::Cint) end @doc raw""" @@ -485,7 +474,7 @@ end Return `true` if $x$ is certainly one, otherwise return `false`. """ function isone(x::ArbFieldElem) - return Bool(ccall((:arb_is_one, libflint), Cint, (Ref{ArbFieldElem},), x)) + return Bool(@ccall libflint.arb_is_one(x::Ref{ArbFieldElem})::Cint) end @doc raw""" @@ -495,7 +484,7 @@ Return `true` if $x$ is finite, i.e. having finite midpoint and radius, otherwise return `false`. """ function isfinite(x::ArbFieldElem) - return Bool(ccall((:arb_is_finite, libflint), Cint, (Ref{ArbFieldElem},), x)) + return Bool(@ccall libflint.arb_is_finite(x::Ref{ArbFieldElem})::Cint) end @doc raw""" @@ -505,7 +494,7 @@ Return `true` if $x$ is exact, i.e. has zero radius, otherwise return `false`. """ function is_exact(x::ArbFieldElem) - return Bool(ccall((:arb_is_exact, libflint), Cint, (Ref{ArbFieldElem},), x)) + return Bool(@ccall libflint.arb_is_exact(x::Ref{ArbFieldElem})::Cint) end @doc raw""" @@ -514,7 +503,7 @@ end Return `true` if $x$ is an exact integer, otherwise return `false`. """ function isinteger(x::ArbFieldElem) - return Bool(ccall((:arb_is_int, libflint), Cint, (Ref{ArbFieldElem},), x)) + return Bool(@ccall libflint.arb_is_int(x::Ref{ArbFieldElem})::Cint) end @doc raw""" @@ -523,7 +512,7 @@ end Return `true` if $x$ is certainly positive, otherwise return `false`. """ function is_positive(x::ArbFieldElem) - return Bool(ccall((:arb_is_positive, libflint), Cint, (Ref{ArbFieldElem},), x)) + return Bool(@ccall libflint.arb_is_positive(x::Ref{ArbFieldElem})::Cint) end @doc raw""" @@ -532,7 +521,7 @@ end Return `true` if $x$ is certainly non-negative, otherwise return `false`. """ function is_nonnegative(x::ArbFieldElem) - return Bool(ccall((:arb_is_nonnegative, libflint), Cint, (Ref{ArbFieldElem},), x)) + return Bool(@ccall libflint.arb_is_nonnegative(x::Ref{ArbFieldElem})::Cint) end @doc raw""" @@ -541,7 +530,7 @@ end Return `true` if $x$ is certainly negative, otherwise return `false`. """ function is_negative(x::ArbFieldElem) - return Bool(ccall((:arb_is_negative, libflint), Cint, (Ref{ArbFieldElem},), x)) + return Bool(@ccall libflint.arb_is_negative(x::Ref{ArbFieldElem})::Cint) end @doc raw""" @@ -550,7 +539,7 @@ end Return `true` if $x$ is certainly nonpositive, otherwise return `false`. """ function is_nonpositive(x::ArbFieldElem) - return Bool(ccall((:arb_is_nonpositive, libflint), Cint, (Ref{ArbFieldElem},), x)) + return Bool(@ccall libflint.arb_is_nonpositive(x::Ref{ArbFieldElem})::Cint) end ################################################################################ @@ -578,7 +567,7 @@ Return the radius of the ball $x$ as an Arb ball. """ function radius(x::ArbFieldElem) z = parent(x)() - ccall((:arb_get_rad_arb, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), z, x) + @ccall libflint.arb_get_rad_arb(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem})::Nothing return z end @@ -589,7 +578,7 @@ Return the midpoint of the ball $x$ as an Arb ball. """ function midpoint(x::ArbFieldElem) z = parent(x)() - ccall((:arb_get_mid_arb, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), z, x) + @ccall libflint.arb_get_mid_arb(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem})::Nothing return z end @@ -599,7 +588,7 @@ end Adds the absolute values of the midpoint and radius of $y$ to the radius of $x$. """ function add_error!(x::ArbFieldElem, y::ArbFieldElem) - ccall((:arb_add_error, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y) + @ccall libflint.arb_add_error(x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem})::Nothing end ################################################################################ @@ -699,8 +688,7 @@ end function -(x::ArbFieldElem, y::UInt) z = parent(x)() - ccall((:arb_sub_ui, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, UInt, Int), z, x, y, parent(x).prec) + @ccall libflint.arb_sub_ui(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::UInt, parent(x).prec::Int)::Nothing return z end @@ -708,8 +696,7 @@ end function -(x::ArbFieldElem, y::Int) z = parent(x)() - ccall((:arb_sub_si, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int, Int), z, x, y, parent(x).prec) + @ccall libflint.arb_sub_si(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Int, parent(x).prec::Int)::Nothing return z end @@ -717,9 +704,7 @@ end function -(x::ArbFieldElem, y::ZZRingElem) z = parent(x)() - ccall((:arb_sub_fmpz, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ZZRingElem}, Int), - z, x, y, parent(x).prec) + @ccall libflint.arb_sub_fmpz(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Ref{ZZRingElem}, parent(x).prec::Int)::Nothing return z end @@ -750,61 +735,51 @@ end function //(x::ArbFieldElem, y::UInt) z = parent(x)() - ccall((:arb_div_ui, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, UInt, Int), z, x, y, parent(x).prec) + @ccall libflint.arb_div_ui(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::UInt, parent(x).prec::Int)::Nothing return z end function //(x::ArbFieldElem, y::Int) z = parent(x)() - ccall((:arb_div_si, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int, Int), z, x, y, parent(x).prec) + @ccall libflint.arb_div_si(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Int, parent(x).prec::Int)::Nothing return z end function //(x::ArbFieldElem, y::ZZRingElem) z = parent(x)() - ccall((:arb_div_fmpz, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ZZRingElem}, Int), - z, x, y, parent(x).prec) + @ccall libflint.arb_div_fmpz(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Ref{ZZRingElem}, parent(x).prec::Int)::Nothing return z end function //(x::UInt, y::ArbFieldElem) z = parent(y)() - ccall((:arb_ui_div, libflint), Nothing, - (Ref{ArbFieldElem}, UInt, Ref{ArbFieldElem}, Int), z, x, y, parent(y).prec) + @ccall libflint.arb_ui_div(z::Ref{ArbFieldElem}, x::UInt, y::Ref{ArbFieldElem}, parent(y).prec::Int)::Nothing return z end function //(x::Int, y::ArbFieldElem) z = parent(y)() t = ArbFieldElem(x) - ccall((:arb_div, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, t, y, parent(y).prec) + @ccall libflint.arb_div(z::Ref{ArbFieldElem}, t::Ref{ArbFieldElem}, y::Ref{ArbFieldElem}, parent(y).prec::Int)::Nothing return z end function //(x::ZZRingElem, y::ArbFieldElem) z = parent(y)() t = ArbFieldElem(x) - ccall((:arb_div, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, t, y, parent(y).prec) + @ccall libflint.arb_div(z::Ref{ArbFieldElem}, t::Ref{ArbFieldElem}, y::Ref{ArbFieldElem}, parent(y).prec::Int)::Nothing return z end function ^(x::ArbFieldElem, y::ArbFieldElem) z = parent(x)() - ccall((:arb_pow, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, y, parent(x).prec) + @ccall libflint.arb_pow(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function ^(x::ArbFieldElem, y::ZZRingElem) z = parent(x)() - ccall((:arb_pow_fmpz, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ZZRingElem}, Int), - z, x, y, parent(x).prec) + @ccall libflint.arb_pow_fmpz(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Ref{ZZRingElem}, parent(x).prec::Int)::Nothing return z end @@ -812,16 +787,13 @@ end function ^(x::ArbFieldElem, y::UInt) z = parent(x)() - ccall((:arb_pow_ui, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, UInt, Int), z, x, y, parent(x).prec) + @ccall libflint.arb_pow_ui(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::UInt, parent(x).prec::Int)::Nothing return z end function ^(x::ArbFieldElem, y::QQFieldElem) z = parent(x)() - ccall((:arb_pow_fmpq, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{QQFieldElem}, Int), - z, x, y, parent(x).prec) + @ccall libflint.arb_pow_fmpq(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Ref{QQFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -871,7 +843,7 @@ divexact(x::ArbFieldElem, y::ZZRingElem; check::Bool=true) = x // y function abs(x::ArbFieldElem) z = parent(x)() - ccall((:arb_abs, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), z, x) + @ccall libflint.arb_abs(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem})::Nothing return z end @@ -883,8 +855,7 @@ end function inv(x::ArbFieldElem) z = parent(x)() - ccall((:arb_inv, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_inv(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return parent(x)(z) end @@ -896,15 +867,13 @@ end function ldexp(x::ArbFieldElem, y::Int) z = parent(x)() - ccall((:arb_mul_2exp_si, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, y) + @ccall libflint.arb_mul_2exp_si(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Int)::Nothing return z end function ldexp(x::ArbFieldElem, y::ZZRingElem) z = parent(x)() - ccall((:arb_mul_2exp_fmpz, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.arb_mul_2exp_fmpz(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Ref{ZZRingElem})::Nothing return z end @@ -922,7 +891,7 @@ by rounding off insignificant bits from the midpoint. """ function trim(x::ArbFieldElem) z = parent(x)() - ccall((:arb_trim, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), z, x) + @ccall libflint.arb_trim(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem})::Nothing return z end @@ -936,8 +905,7 @@ integer. """ function unique_integer(x::ArbFieldElem) z = ZZRingElem() - unique = ccall((:arb_get_unique_fmpz, libflint), Int, - (Ref{ZZRingElem}, Ref{ArbFieldElem}), z, x) + unique = @ccall libflint.arb_get_unique_fmpz(z::Ref{ZZRingElem}, x::Ref{ArbFieldElem})::Int return (unique != 0, z) end @@ -953,8 +921,7 @@ $y$. """ function setunion(x::ArbFieldElem, y::ArbFieldElem) z = parent(x)() - ccall((:arb_union, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, y, parent(x).prec) + @ccall libflint.arb_union(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -966,8 +933,7 @@ $x$ and $y$. """ function setintersection(x::ArbFieldElem, y::ArbFieldElem) z = parent(x)() - ccall((:arb_intersection, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, y, parent(x).prec) + @ccall libflint.arb_intersection(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -984,7 +950,7 @@ Return $\pi = 3.14159\ldots$ as an element of $r$. """ function const_pi(r::ArbField) z = r() - ccall((:arb_const_pi, libflint), Nothing, (Ref{ArbFieldElem}, Int), z, precision(r)) + @ccall libflint.arb_const_pi(z::Ref{ArbFieldElem}, precision(r)::Int)::Nothing return z end @@ -995,7 +961,7 @@ Return $e = 2.71828\ldots$ as an element of $r$. """ function const_e(r::ArbField) z = r() - ccall((:arb_const_e, libflint), Nothing, (Ref{ArbFieldElem}, Int), z, precision(r)) + @ccall libflint.arb_const_e(z::Ref{ArbFieldElem}, precision(r)::Int)::Nothing return z end @@ -1006,7 +972,7 @@ Return $\log(2) = 0.69314\ldots$ as an element of $r$. """ function const_log2(r::ArbField) z = r() - ccall((:arb_const_log2, libflint), Nothing, (Ref{ArbFieldElem}, Int), z, precision(r)) + @ccall libflint.arb_const_log2(z::Ref{ArbFieldElem}, precision(r)::Int)::Nothing return z end @@ -1017,7 +983,7 @@ Return $\log(10) = 2.302585\ldots$ as an element of $r$. """ function const_log10(r::ArbField) z = r() - ccall((:arb_const_log10, libflint), Nothing, (Ref{ArbFieldElem}, Int), z, precision(r)) + @ccall libflint.arb_const_log10(z::Ref{ArbFieldElem}, precision(r)::Int)::Nothing return z end @@ -1028,7 +994,7 @@ Return Euler's constant $\gamma = 0.577215\ldots$ as an element of $r$. """ function const_euler(r::ArbField) z = r() - ccall((:arb_const_euler, libflint), Nothing, (Ref{ArbFieldElem}, Int), z, precision(r)) + @ccall libflint.arb_const_euler(z::Ref{ArbFieldElem}, precision(r)::Int)::Nothing return z end @@ -1039,7 +1005,7 @@ Return Catalan's constant $C = 0.915965\ldots$ as an element of $r$. """ function const_catalan(r::ArbField) z = r() - ccall((:arb_const_catalan, libflint), Nothing, (Ref{ArbFieldElem}, Int), z, precision(r)) + @ccall libflint.arb_const_catalan(z::Ref{ArbFieldElem}, precision(r)::Int)::Nothing return z end @@ -1050,7 +1016,7 @@ Return Khinchin's constant $K = 2.685452\ldots$ as an element of $r$. """ function const_khinchin(r::ArbField) z = r() - ccall((:arb_const_khinchin, libflint), Nothing, (Ref{ArbFieldElem}, Int), z, precision(r)) + @ccall libflint.arb_const_khinchin(z::Ref{ArbFieldElem}, precision(r)::Int)::Nothing return z end @@ -1061,7 +1027,7 @@ Return Glaisher's constant $A = 1.282427\ldots$ as an element of $r$. """ function const_glaisher(r::ArbField) z = r() - ccall((:arb_const_glaisher, libflint), Nothing, (Ref{ArbFieldElem}, Int), z, precision(r)) + @ccall libflint.arb_const_glaisher(z::Ref{ArbFieldElem}, precision(r)::Int)::Nothing return z end @@ -1075,7 +1041,7 @@ end function floor(x::ArbFieldElem) z = parent(x)() - ccall((:arb_floor, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_floor(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1085,7 +1051,7 @@ floor(::Type{T}, x::ArbFieldElem) where {T <: Integer} = T(floor(x)) function ceil(x::ArbFieldElem) z = parent(x)() - ccall((:arb_ceil, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_ceil(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1095,7 +1061,7 @@ ceil(::Type{T}, x::ArbFieldElem) where {T <: Integer} = T(ceil(x)) function Base.sqrt(x::ArbFieldElem; check::Bool=true) z = parent(x)() - ccall((:arb_sqrt, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_sqrt(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1106,7 +1072,7 @@ Return the reciprocal of the square root of $x$, i.e. $1/\sqrt{x}$. """ function rsqrt(x::ArbFieldElem) z = parent(x)() - ccall((:arb_rsqrt, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_rsqrt(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1117,7 +1083,7 @@ Return $\sqrt{1+x}-1$, evaluated accurately for small $x$. """ function sqrt1pm1(x::ArbFieldElem) z = parent(x)() - ccall((:arb_sqrt1pm1, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_sqrt1pm1(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1129,139 +1095,139 @@ number. Thus any negative number in the input interval is discarded. """ function sqrtpos(x::ArbFieldElem) z = parent(x)() - ccall((:arb_sqrtpos, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_sqrtpos(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function log(x::ArbFieldElem) z = parent(x)() - ccall((:arb_log, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_log(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function log1p(x::ArbFieldElem) z = parent(x)() - ccall((:arb_log1p, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_log1p(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function Base.exp(x::ArbFieldElem) z = parent(x)() - ccall((:arb_exp, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_exp(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function expm1(x::ArbFieldElem) z = parent(x)() - ccall((:arb_expm1, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_expm1(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function sin(x::ArbFieldElem) z = parent(x)() - ccall((:arb_sin, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_sin(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function cos(x::ArbFieldElem) z = parent(x)() - ccall((:arb_cos, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_cos(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function sinpi(x::ArbFieldElem) z = parent(x)() - ccall((:arb_sin_pi, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_sin_pi(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function cospi(x::ArbFieldElem) z = parent(x)() - ccall((:arb_cos_pi, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_cos_pi(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function tan(x::ArbFieldElem) z = parent(x)() - ccall((:arb_tan, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_tan(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function cot(x::ArbFieldElem) z = parent(x)() - ccall((:arb_cot, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_cot(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function tanpi(x::ArbFieldElem) z = parent(x)() - ccall((:arb_tan_pi, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_tan_pi(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function cotpi(x::ArbFieldElem) z = parent(x)() - ccall((:arb_cot_pi, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_cot_pi(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function sinh(x::ArbFieldElem) z = parent(x)() - ccall((:arb_sinh, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_sinh(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function cosh(x::ArbFieldElem) z = parent(x)() - ccall((:arb_cosh, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_cosh(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function tanh(x::ArbFieldElem) z = parent(x)() - ccall((:arb_tanh, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_tanh(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function coth(x::ArbFieldElem) z = parent(x)() - ccall((:arb_coth, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_coth(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function atan(x::ArbFieldElem) z = parent(x)() - ccall((:arb_atan, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_atan(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function asin(x::ArbFieldElem) z = parent(x)() - ccall((:arb_asin, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_asin(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function acos(x::ArbFieldElem) z = parent(x)() - ccall((:arb_acos, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_acos(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function atanh(x::ArbFieldElem) z = parent(x)() - ccall((:arb_atanh, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_atanh(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function asinh(x::ArbFieldElem) z = parent(x)() - ccall((:arb_asinh, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_asinh(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function acosh(x::ArbFieldElem) z = parent(x)() - ccall((:arb_acosh, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_acosh(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1272,7 +1238,7 @@ Return the Gamma function evaluated at $x$. """ function gamma(x::ArbFieldElem) z = parent(x)() - ccall((:arb_gamma, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_gamma(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1283,7 +1249,7 @@ Return the logarithm of the Gamma function evaluated at $x$. """ function lgamma(x::ArbFieldElem) z = parent(x)() - ccall((:arb_lgamma, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_lgamma(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1294,7 +1260,7 @@ Return the reciprocal of the Gamma function evaluated at $x$. """ function rgamma(x::ArbFieldElem) z = parent(x)() - ccall((:arb_rgamma, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_rgamma(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1306,7 +1272,7 @@ i.e. $\psi(x)$. """ function digamma(x::ArbFieldElem) z = parent(x)() - ccall((:arb_digamma, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_digamma(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1317,8 +1283,7 @@ Return the upper incomplete gamma function $\Gamma(s,x)$. """ function gamma(s::ArbFieldElem, x::ArbFieldElem) z = parent(s)() - ccall((:arb_hypgeom_gamma_upper, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int, Int), z, s, x, 0, parent(s).prec) + @ccall libflint.arb_hypgeom_gamma_upper(z::Ref{ArbFieldElem}, s::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, 0::Int, parent(s).prec::Int)::Nothing return z end @@ -1330,8 +1295,7 @@ $\Gamma(s,x) / \Gamma(s)$. """ function gamma_regularized(s::ArbFieldElem, x::ArbFieldElem) z = parent(s)() - ccall((:arb_hypgeom_gamma_upper, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int, Int), z, s, x, 1, parent(s).prec) + @ccall libflint.arb_hypgeom_gamma_upper(z::Ref{ArbFieldElem}, s::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, 1::Int, parent(s).prec::Int)::Nothing return z end @@ -1342,8 +1306,7 @@ Return the lower incomplete gamma function $\gamma(s,x) / \Gamma(s)$. """ function gamma_lower(s::ArbFieldElem, x::ArbFieldElem) z = parent(s)() - ccall((:arb_hypgeom_gamma_lower, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int, Int), z, s, x, 0, parent(s).prec) + @ccall libflint.arb_hypgeom_gamma_lower(z::Ref{ArbFieldElem}, s::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, 0::Int, parent(s).prec::Int)::Nothing return z end @@ -1355,8 +1318,7 @@ $\gamma(s,x) / \Gamma(s)$. """ function gamma_lower_regularized(s::ArbFieldElem, x::ArbFieldElem) z = parent(s)() - ccall((:arb_hypgeom_gamma_lower, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int, Int), z, s, x, 1, parent(s).prec) + @ccall libflint.arb_hypgeom_gamma_lower(z::Ref{ArbFieldElem}, s::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, 1::Int, parent(s).prec::Int)::Nothing return z end @@ -1368,60 +1330,53 @@ Return the Riemann zeta function evaluated at $x$. """ function zeta(x::ArbFieldElem) z = parent(x)() - ccall((:arb_zeta, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, parent(x).prec) + @ccall libflint.arb_zeta(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function sincos(x::ArbFieldElem) s = parent(x)() c = parent(x)() - ccall((:arb_sin_cos, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), s, c, x, parent(x).prec) + @ccall libflint.arb_sin_cos(s::Ref{ArbFieldElem}, c::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return (s, c) end function sincospi(x::ArbFieldElem) s = parent(x)() c = parent(x)() - ccall((:arb_sin_cos_pi, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), s, c, x, parent(x).prec) + @ccall libflint.arb_sin_cos_pi(s::Ref{ArbFieldElem}, c::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return (s, c) end function sinpi(x::QQFieldElem, r::ArbField) z = r() - ccall((:arb_sin_pi_fmpq, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{QQFieldElem}, Int), z, x, precision(r)) + @ccall libflint.arb_sin_pi_fmpq(z::Ref{ArbFieldElem}, x::Ref{QQFieldElem}, precision(r)::Int)::Nothing return z end function cospi(x::QQFieldElem, r::ArbField) z = r() - ccall((:arb_cos_pi_fmpq, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{QQFieldElem}, Int), z, x, precision(r)) + @ccall libflint.arb_cos_pi_fmpq(z::Ref{ArbFieldElem}, x::Ref{QQFieldElem}, precision(r)::Int)::Nothing return z end function sincospi(x::QQFieldElem, r::ArbField) s = r() c = r() - ccall((:arb_sin_cos_pi_fmpq, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{QQFieldElem}, Int), s, c, x, precision(r)) + @ccall libflint.arb_sin_cos_pi_fmpq(s::Ref{ArbFieldElem}, c::Ref{ArbFieldElem}, x::Ref{QQFieldElem}, precision(r)::Int)::Nothing return (s, c) end function sinhcosh(x::ArbFieldElem) s = parent(x)() c = parent(x)() - ccall((:arb_sinh_cosh, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), s, c, x, parent(x).prec) + @ccall libflint.arb_sinh_cosh(s::Ref{ArbFieldElem}, c::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return (s, c) end function atan(y::ArbFieldElem, x::ArbFieldElem) z = parent(y)() - ccall((:arb_atan2, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, y, x, parent(y).prec) + @ccall libflint.arb_atan2(z::Ref{ArbFieldElem}, y::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(y).prec::Int)::Nothing return z end @@ -1441,8 +1396,7 @@ Return the arithmetic-geometric mean of $x$ and $y$ """ function agm(x::ArbFieldElem, y::ArbFieldElem) z = parent(x)() - ccall((:arb_agm, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, y, parent(x).prec) + @ccall libflint.arb_agm(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end @@ -1453,22 +1407,19 @@ Return the Hurwitz zeta function $\zeta(s,a)$. """ function zeta(s::ArbFieldElem, a::ArbFieldElem) z = parent(s)() - ccall((:arb_hurwitz_zeta, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, s, a, parent(s).prec) + @ccall libflint.arb_hurwitz_zeta(z::Ref{ArbFieldElem}, s::Ref{ArbFieldElem}, a::Ref{ArbFieldElem}, parent(s).prec::Int)::Nothing return z end function hypot(x::ArbFieldElem, y::ArbFieldElem) z = parent(x)() - ccall((:arb_hypot, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, y, parent(x).prec) + @ccall libflint.arb_hypot(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function root(x::ArbFieldElem, n::UInt) z = parent(x)() - ccall((:arb_root, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, UInt, Int), z, x, n, parent(x).prec) + @ccall libflint.arb_root(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, n::UInt, parent(x).prec::Int)::Nothing return z end @@ -1491,7 +1442,7 @@ factorial(x::ArbFieldElem) = gamma(x+1) function factorial(n::UInt, r::ArbField) z = r() - ccall((:arb_fac_ui, libflint), Nothing, (Ref{ArbFieldElem}, UInt, Int), z, n, r.prec) + @ccall libflint.arb_fac_ui(z::Ref{ArbFieldElem}, n::UInt, r.prec::Int)::Nothing return z end @@ -1509,8 +1460,7 @@ Return the binomial coefficient ${x \choose n}$. """ function binomial(x::ArbFieldElem, n::UInt) z = parent(x)() - ccall((:arb_bin_ui, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, UInt, Int), z, x, n, parent(x).prec) + @ccall libflint.arb_bin_ui(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, n::UInt, parent(x).prec::Int)::Nothing return z end @@ -1521,8 +1471,7 @@ Return the binomial coefficient ${n \choose k}$ in the given Arb field. """ function binomial(n::UInt, k::UInt, r::ArbField) z = r() - ccall((:arb_bin_uiui, libflint), Nothing, - (Ref{ArbFieldElem}, UInt, UInt, Int), z, n, k, r.prec) + @ccall libflint.arb_bin_uiui(z::Ref{ArbFieldElem}, n::UInt, k::UInt, r.prec::Int)::Nothing return z end @@ -1533,15 +1482,13 @@ Return the $n$-th Fibonacci number in the given Arb field. """ function fibonacci(n::ZZRingElem, r::ArbField) z = r() - ccall((:arb_fib_fmpz, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ZZRingElem}, Int), z, n, r.prec) + @ccall libflint.arb_fib_fmpz(z::Ref{ArbFieldElem}, n::Ref{ZZRingElem}, r.prec::Int)::Nothing return z end function fibonacci(n::UInt, r::ArbField) z = r() - ccall((:arb_fib_ui, libflint), Nothing, - (Ref{ArbFieldElem}, UInt, Int), z, n, r.prec) + @ccall libflint.arb_fib_ui(z::Ref{ArbFieldElem}, n::UInt, r.prec::Int)::Nothing return z end @@ -1559,8 +1506,7 @@ Return the Gamma function evaluated at $x$ in the given Arb field. """ function gamma(x::ZZRingElem, r::ArbField) z = r() - ccall((:arb_gamma_fmpz, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ZZRingElem}, Int), z, x, r.prec) + @ccall libflint.arb_gamma_fmpz(z::Ref{ArbFieldElem}, x::Ref{ZZRingElem}, r.prec::Int)::Nothing return z end @@ -1571,16 +1517,14 @@ Return the Gamma function evaluated at $x$ in the given Arb field. """ function gamma(x::QQFieldElem, r::ArbField) z = r() - ccall((:arb_gamma_fmpq, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{QQFieldElem}, Int), z, x, r.prec) + @ccall libflint.arb_gamma_fmpq(z::Ref{ArbFieldElem}, x::Ref{QQFieldElem}, r.prec::Int)::Nothing return z end function zeta(n::UInt, r::ArbField) z = r() - ccall((:arb_zeta_ui, libflint), Nothing, - (Ref{ArbFieldElem}, UInt, Int), z, n, r.prec) + @ccall libflint.arb_zeta_ui(z::Ref{ArbFieldElem}, n::UInt, r.prec::Int)::Nothing return z end @@ -1594,8 +1538,7 @@ zeta(n::Int, r::ArbField) = n >= 0 ? zeta(UInt(n), r) : zeta(r(n)) function bernoulli(n::UInt, r::ArbField) z = r() - ccall((:arb_bernoulli_ui, libflint), Nothing, - (Ref{ArbFieldElem}, UInt, Int), z, n, r.prec) + @ccall libflint.arb_bernoulli_ui(z::Ref{ArbFieldElem}, n::UInt, r.prec::Int)::Nothing return z end @@ -1608,8 +1551,7 @@ bernoulli(n::Int, r::ArbField) = n >= 0 ? bernoulli(UInt(n), r) : throw(DomainEr function rising_factorial(x::ArbFieldElem, n::UInt) z = parent(x)() - ccall((:arb_rising_ui, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, UInt, Int), z, x, n, parent(x).prec) + @ccall libflint.arb_rising_ui(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, n::UInt, parent(x).prec::Int)::Nothing return z end @@ -1622,8 +1564,7 @@ rising_factorial(x::ArbFieldElem, n::Int) = n < 0 ? throw(DomainError(n, "Index function rising_factorial(x::QQFieldElem, n::UInt, r::ArbField) z = r() - ccall((:arb_rising_fmpq_ui, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{QQFieldElem}, UInt, Int), z, x, n, r.prec) + @ccall libflint.arb_rising_fmpq_ui(z::Ref{ArbFieldElem}, x::Ref{QQFieldElem}, n::UInt, r.prec::Int)::Nothing return z end @@ -1638,8 +1579,7 @@ rising_factorial(x::QQFieldElem, n::Int, r::ArbField) = n < 0 ? throw(DomainErro function rising_factorial2(x::ArbFieldElem, n::UInt) z = parent(x)() w = parent(x)() - ccall((:arb_rising2_ui, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, UInt, Int), z, w, x, n, parent(x).prec) + @ccall libflint.arb_rising2_ui(z::Ref{ArbFieldElem}, w::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, n::UInt, parent(x).prec::Int)::Nothing return (z, w) end @@ -1653,15 +1593,13 @@ rising_factorial2(x::ArbFieldElem, n::Int) = n < 0 ? throw(DomainError(n, "Index function polylog(s::ArbFieldElem, a::ArbFieldElem) z = parent(s)() - ccall((:arb_polylog, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, s, a, parent(s).prec) + @ccall libflint.arb_polylog(z::Ref{ArbFieldElem}, s::Ref{ArbFieldElem}, a::Ref{ArbFieldElem}, parent(s).prec::Int)::Nothing return z end function polylog(s::Int, a::ArbFieldElem) z = parent(a)() - ccall((:arb_polylog_si, libflint), Nothing, - (Ref{ArbFieldElem}, Int, Ref{ArbFieldElem}, Int), z, s, a, parent(a).prec) + @ccall libflint.arb_polylog_si(z::Ref{ArbFieldElem}, s::Int, a::Ref{ArbFieldElem}, parent(a).prec::Int)::Nothing return z end @@ -1673,31 +1611,27 @@ Return the polylogarithm Li$_s(a)$. function chebyshev_t(n::UInt, x::ArbFieldElem) z = parent(x)() - ccall((:arb_chebyshev_t_ui, libflint), Nothing, - (Ref{ArbFieldElem}, UInt, Ref{ArbFieldElem}, Int), z, n, x, parent(x).prec) + @ccall libflint.arb_chebyshev_t_ui(z::Ref{ArbFieldElem}, n::UInt, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function chebyshev_u(n::UInt, x::ArbFieldElem) z = parent(x)() - ccall((:arb_chebyshev_u_ui, libflint), Nothing, - (Ref{ArbFieldElem}, UInt, Ref{ArbFieldElem}, Int), z, n, x, parent(x).prec) + @ccall libflint.arb_chebyshev_u_ui(z::Ref{ArbFieldElem}, n::UInt, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z end function chebyshev_t2(n::UInt, x::ArbFieldElem) z = parent(x)() w = parent(x)() - ccall((:arb_chebyshev_t2_ui, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, UInt, Ref{ArbFieldElem}, Int), z, w, n, x, parent(x).prec) + @ccall libflint.arb_chebyshev_t2_ui(z::Ref{ArbFieldElem}, w::Ref{ArbFieldElem}, n::UInt, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z, w end function chebyshev_u2(n::UInt, x::ArbFieldElem) z = parent(x)() w = parent(x)() - ccall((:arb_chebyshev_u2_ui, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, UInt, Ref{ArbFieldElem}, Int), z, w, n, x, parent(x).prec) + @ccall libflint.arb_chebyshev_u2_ui(z::Ref{ArbFieldElem}, w::Ref{ArbFieldElem}, n::UInt, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return z, w end @@ -1736,8 +1670,7 @@ Return the Bell number $B_n$ as an element of $r$. """ function bell(n::ZZRingElem, r::ArbField) z = r() - ccall((:arb_bell_fmpz, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ZZRingElem}, Int), z, n, r.prec) + @ccall libflint.arb_bell_fmpz(z::Ref{ArbFieldElem}, n::Ref{ZZRingElem}, r.prec::Int)::Nothing return z end @@ -1755,8 +1688,7 @@ Return the number of partitions $p(n)$ as an element of $r$. """ function numpart(n::ZZRingElem, r::ArbField) z = r() - ccall((:arb_partitions_fmpz, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ZZRingElem}, Int), z, n, r.prec) + @ccall libflint.arb_partitions_fmpz(z::Ref{ArbFieldElem}, n::Ref{ZZRingElem}, r.prec::Int)::Nothing return z end @@ -1780,9 +1712,7 @@ Return the Airy function $\operatorname{Ai}(x)$. """ function airy_ai(x::ArbFieldElem) ai = parent(x)() - ccall((:arb_hypgeom_airy, libflint), Nothing, - (Ref{ArbFieldElem}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ref{ArbFieldElem}, Int), - ai, C_NULL, C_NULL, C_NULL, x, parent(x).prec) + @ccall libflint.arb_hypgeom_airy(ai::Ref{ArbFieldElem}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return ai end @@ -1793,9 +1723,7 @@ Return the Airy function $\operatorname{Bi}(x)$. """ function airy_bi(x::ArbFieldElem) bi = parent(x)() - ccall((:arb_hypgeom_airy, libflint), Nothing, - (Ptr{Cvoid}, Ptr{Cvoid}, Ref{ArbFieldElem}, Ptr{Cvoid}, Ref{ArbFieldElem}, Int), - C_NULL, C_NULL, bi, C_NULL, x, parent(x).prec) + @ccall libflint.arb_hypgeom_airy(C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, bi::Ref{ArbFieldElem}, C_NULL::Ptr{Cvoid}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return bi end @@ -1806,9 +1734,7 @@ Return the derivative of the Airy function $\operatorname{Ai}^\prime(x)$. """ function airy_ai_prime(x::ArbFieldElem) ai_prime = parent(x)() - ccall((:arb_hypgeom_airy, libflint), Nothing, - (Ptr{Cvoid}, Ref{ArbFieldElem}, Ptr{Cvoid}, Ptr{Cvoid}, Ref{ArbFieldElem}, Int), - C_NULL, ai_prime, C_NULL, C_NULL, x, parent(x).prec) + @ccall libflint.arb_hypgeom_airy(C_NULL::Ptr{Cvoid}, ai_prime::Ref{ArbFieldElem}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return ai_prime end @@ -1819,9 +1745,7 @@ Return the derivative of the Airy function $\operatorname{Bi}^\prime(x)$. """ function airy_bi_prime(x::ArbFieldElem) bi_prime = parent(x)() - ccall((:arb_hypgeom_airy, libflint), Nothing, - (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), - C_NULL, C_NULL, C_NULL, bi_prime, x, parent(x).prec) + @ccall libflint.arb_hypgeom_airy(C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid}, bi_prime::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, parent(x).prec::Int)::Nothing return bi_prime end @@ -1910,8 +1834,7 @@ function simplest_rational_inside(x::ArbFieldElem) b = ZZRingElem() e = ZZRingElem() - ccall((:arb_get_interval_fmpz_2exp, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ArbFieldElem}), a, b, e, x) + @ccall libflint.arb_get_interval_fmpz_2exp(a::Ref{ZZRingElem}, b::Ref{ZZRingElem}, e::Ref{ZZRingElem}, x::Ref{ArbFieldElem})::Nothing !fits(Int, e) && error("Result does not fit into an QQFieldElem") _e = Int(e) if e >= 0 @@ -1956,7 +1879,7 @@ end function addmul!(z::ArbFieldElem, x::ArbFieldElem, y::ZZRingElem) q = max(bits(z), bits(x)) - ccall((:arb_addmul_fmpz, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ZZRingElem}, Int), z, x, y, q) + @ccall libflint.arb_addmul_fmpz(z::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, y::Ref{ZZRingElem}, q::Int)::Nothing return z end @@ -1967,77 +1890,69 @@ end ################################################################################ function _arb_set(x::ArbFieldElemOrPtr, y::Int) - ccall((:arb_set_si, libflint), Nothing, (Ref{ArbFieldElem}, Int), x, y) + @ccall libflint.arb_set_si(x::Ref{ArbFieldElem}, y::Int)::Nothing end function _arb_set(x::ArbFieldElemOrPtr, y::UInt) - ccall((:arb_set_ui, libflint), Nothing, (Ref{ArbFieldElem}, UInt), x, y) + @ccall libflint.arb_set_ui(x::Ref{ArbFieldElem}, y::UInt)::Nothing end function _arb_set(x::ArbFieldElemOrPtr, y::Float64) - ccall((:arb_set_d, libflint), Nothing, (Ref{ArbFieldElem}, Float64), x, y) + @ccall libflint.arb_set_d(x::Ref{ArbFieldElem}, y::Float64)::Nothing end function _arb_set(x::ArbFieldElemOrPtr, y::Union{Int,UInt,Float64}, p::Int) _arb_set(x, y) - ccall((:arb_set_round, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), x, x, p) + @ccall libflint.arb_set_round(x::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, p::Int)::Nothing end function _arb_set(x::ArbFieldElemOrPtr, y::ZZRingElem) - ccall((:arb_set_fmpz, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ZZRingElem}), x, y) + @ccall libflint.arb_set_fmpz(x::Ref{ArbFieldElem}, y::Ref{ZZRingElem})::Nothing end function _arb_set(x::ArbFieldElemOrPtr, y::ZZRingElem, p::Int) - ccall((:arb_set_round_fmpz, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ZZRingElem}, Int), x, y, p) + @ccall libflint.arb_set_round_fmpz(x::Ref{ArbFieldElem}, y::Ref{ZZRingElem}, p::Int)::Nothing end function _arb_set(x::ArbFieldElemOrPtr, y::QQFieldElem, p::Int) - ccall((:arb_set_fmpq, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{QQFieldElem}, Int), x, y, p) + @ccall libflint.arb_set_fmpq(x::Ref{ArbFieldElem}, y::Ref{QQFieldElem}, p::Int)::Nothing end function _arb_set(x::ArbFieldElemOrPtr, y::ArbFieldElemOrPtr) - ccall((:arb_set, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y) + @ccall libflint.arb_set(x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem})::Nothing end function _arb_set(x::ArbFieldElemOrPtr, y::Ptr{arb_struct}) - ccall((:arb_set, libflint), Nothing, (Ref{ArbFieldElem}, Ptr{arb_struct}), x, y) + @ccall libflint.arb_set(x::Ref{ArbFieldElem}, y::Ptr{arb_struct})::Nothing end function _arb_set(x::Ptr{arb_struct}, y::ArbFieldElemOrPtr) - ccall((:arb_set, libflint), Nothing, (Ptr{arb_struct}, Ref{ArbFieldElem}) , x, y) + @ccall libflint.arb_set(x::Ptr{arb_struct}, y::Ref{ArbFieldElem})::Nothing end function _arb_set(x::ArbFieldElemOrPtr, y::ArbFieldElemOrPtr, p::Int) - ccall((:arb_set_round, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), x, y, p) + @ccall libflint.arb_set_round(x::Ref{ArbFieldElem}, y::Ref{ArbFieldElem}, p::Int)::Nothing end function _arb_set(x::ArbFieldElemOrPtr, y::AbstractString, p::Int) s = string(y) - err = ccall((:arb_set_str, libflint), Int32, - (Ref{ArbFieldElem}, Ptr{UInt8}, Int), x, s, p) + err = @ccall libflint.arb_set_str(x::Ref{ArbFieldElem}, s::Ptr{UInt8}, p::Int)::Int32 err == 0 || error("Invalid real string: $(repr(s))") end function _arb_set(x::ArbFieldElemOrPtr, y::BigFloat) m = _mid_ptr(x) r = _rad_ptr(x) - ccall((:arf_set_mpfr, libflint), Nothing, - (Ptr{arf_struct}, Ref{BigFloat}), m, y) - ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct}, ), r) + @ccall libflint.arf_set_mpfr(m::Ptr{arf_struct}, y::Ref{BigFloat})::Nothing + @ccall libflint.mag_zero(r::Ptr{mag_struct})::Nothing end function _arb_set(x::ArbFieldElemOrPtr, y::BigFloat, p::Int) m = _mid_ptr(x) r = _rad_ptr(x) - ccall((:arf_set_mpfr, libflint), Nothing, - (Ptr{arf_struct}, Ref{BigFloat}), m, y) - ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct}, ), r) - ccall((:arb_set_round, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), x, x, p) + @ccall libflint.arf_set_mpfr(m::Ptr{arf_struct}, y::Ref{BigFloat})::Nothing + @ccall libflint.mag_zero(r::Ptr{mag_struct})::Nothing + @ccall libflint.arb_set_round(x::Ref{ArbFieldElem}, x::Ref{ArbFieldElem}, p::Int)::Nothing end function _arb_set(x::ArbFieldElemOrPtr, y::Integer) @@ -2123,23 +2038,17 @@ function rand(r::ArbField; randtype::Symbol=:urandom) x = r() if randtype == :urandom - ccall((:arb_urandom, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{rand_ctx}, Int), x, state, r.prec) + @ccall libflint.arb_urandom(x::Ref{ArbFieldElem}, state::Ref{rand_ctx}, r.prec::Int)::Nothing elseif randtype == :randtest - ccall((:arb_randtest, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{rand_ctx}, Int, Int), x, state, r.prec, 30) + @ccall libflint.arb_randtest(x::Ref{ArbFieldElem}, state::Ref{rand_ctx}, r.prec::Int, 30::Int)::Nothing elseif randtype == :randtest_exact - ccall((:arb_randtest_exact, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{rand_ctx}, Int, Int), x, state, r.prec, 30) + @ccall libflint.arb_randtest_exact(x::Ref{ArbFieldElem}, state::Ref{rand_ctx}, r.prec::Int, 30::Int)::Nothing elseif randtype == :randtest_precise - ccall((:arb_randtest_precise, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{rand_ctx}, Int, Int), x, state, r.prec, 30) + @ccall libflint.arb_randtest_precise(x::Ref{ArbFieldElem}, state::Ref{rand_ctx}, r.prec::Int, 30::Int)::Nothing elseif randtype == :randtest_wide - ccall((:arb_randtest_wide, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{rand_ctx}, Int, Int), x, state, r.prec, 30) + @ccall libflint.arb_randtest_wide(x::Ref{ArbFieldElem}, state::Ref{rand_ctx}, r.prec::Int, 30::Int)::Nothing elseif randtype == :randtest_special - ccall((:arb_randtest_special, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{rand_ctx}, Int, Int), x, state, r.prec, 30) + @ccall libflint.arb_randtest_special(x::Ref{ArbFieldElem}, state::Ref{rand_ctx}, r.prec::Int, 30::Int)::Nothing else error("Arb random generation `" * String(randtype) * "` is not defined") end diff --git a/src/arb/arb_mat.jl b/src/arb/arb_mat.jl index b0daa8ff4..4a725c455 100644 --- a/src/arb/arb_mat.jl +++ b/src/arb/arb_mat.jl @@ -80,7 +80,7 @@ number_of_columns(a::ArbMatrix) = a.c function deepcopy_internal(x::ArbMatrix, dict::IdDict) z = ArbMatrix(nrows(x), ncols(x)) - ccall((:arb_mat_set, libflint), Nothing, (Ref{ArbMatrix}, Ref{ArbMatrix}), z, x) + @ccall libflint.arb_mat_set(z::Ref{ArbMatrix}, x::Ref{ArbMatrix})::Nothing z.base_ring = x.base_ring return z end @@ -101,8 +101,7 @@ end function transpose(x::ArbMatrix) z = similar(x, ncols(x), nrows(x)) - ccall((:arb_mat_transpose, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}), z, x) + @ccall libflint.arb_mat_transpose(z::Ref{ArbMatrix}, x::Ref{ArbMatrix})::Nothing return z end @@ -115,27 +114,21 @@ end function +(x::ArbMatrix, y::ArbMatrix) check_parent(x, y) z = similar(x) - ccall((:arb_mat_add, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Ref{ArbMatrix}, Int), - z, x, y, precision(parent(x))) + @ccall libflint.arb_mat_add(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, y::Ref{ArbMatrix}, precision(parent(x))::Int)::Nothing return z end function -(x::ArbMatrix, y::ArbMatrix) check_parent(x, y) z = similar(x) - ccall((:arb_mat_sub, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Ref{ArbMatrix}, Int), - z, x, y, precision(parent(x))) + @ccall libflint.arb_mat_sub(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, y::Ref{ArbMatrix}, precision(parent(x))::Int)::Nothing return z end function *(x::ArbMatrix, y::ArbMatrix) ncols(x) != nrows(y) && error("Matrices have wrong dimensions") z = similar(x, nrows(x), ncols(y)) - ccall((:arb_mat_mul, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Ref{ArbMatrix}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.arb_mat_mul(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, y::Ref{ArbMatrix}, precision(base_ring(x))::Int)::Nothing return z end @@ -148,17 +141,13 @@ end function ^(x::ArbMatrix, y::UInt) nrows(x) != ncols(x) && error("Matrix must be square") z = similar(x) - ccall((:arb_mat_pow_ui, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, UInt, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.arb_mat_pow_ui(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, y::UInt, precision(base_ring(x))::Int)::Nothing return z end function *(x::ArbMatrix, y::Int) z = similar(x) - ccall((:arb_mat_scalar_mul_si, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Int, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.arb_mat_scalar_mul_si(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, y::Int, precision(base_ring(x))::Int)::Nothing return z end @@ -170,9 +159,7 @@ end function *(x::ArbMatrix, y::ZZRingElem) z = similar(x) - ccall((:arb_mat_scalar_mul_fmpz, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Ref{ZZRingElem}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.arb_mat_scalar_mul_fmpz(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, y::Ref{ZZRingElem}, precision(base_ring(x))::Int)::Nothing return z end @@ -180,9 +167,7 @@ end function *(x::ArbMatrix, y::ArbFieldElem) z = similar(x) - ccall((:arb_mat_scalar_mul_arb, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Ref{ArbFieldElem}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.arb_mat_scalar_mul_arb(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, y::Ref{ArbFieldElem}, precision(base_ring(x))::Int)::Nothing return z end @@ -252,8 +237,7 @@ end function ldexp(x::ArbMatrix, y::Int) z = similar(x) - ccall((:arb_mat_scalar_mul_2exp_si, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Int), z, x, y) + @ccall libflint.arb_mat_scalar_mul_2exp_si(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, y::Int)::Nothing return z end @@ -270,20 +254,19 @@ Return `true` if the matrices of balls $x$ and $y$ are precisely equal, i.e. if all matrix entries have the same midpoints and radii. """ function isequal(x::ArbMatrix, y::ArbMatrix) - r = ccall((:arb_mat_equal, libflint), Cint, - (Ref{ArbMatrix}, Ref{ArbMatrix}), x, y) + r = @ccall libflint.arb_mat_equal(x::Ref{ArbMatrix}, y::Ref{ArbMatrix})::Cint return Bool(r) end function ==(x::ArbMatrix, y::ArbMatrix) fl = check_parent(x, y, false) !fl && return false - r = ccall((:arb_mat_eq, libflint), Cint, (Ref{ArbMatrix}, Ref{ArbMatrix}), x, y) + r = @ccall libflint.arb_mat_eq(x::Ref{ArbMatrix}, y::Ref{ArbMatrix})::Cint return Bool(r) end function !=(x::ArbMatrix, y::ArbMatrix) - r = ccall((:arb_mat_ne, libflint), Cint, (Ref{ArbMatrix}, Ref{ArbMatrix}), x, y) + r = @ccall libflint.arb_mat_ne(x::Ref{ArbMatrix}, y::Ref{ArbMatrix})::Cint return Bool(r) end @@ -294,8 +277,7 @@ Returns `true` if all entries of $x$ overlap with the corresponding entry of $y$, otherwise return `false`. """ function overlaps(x::ArbMatrix, y::ArbMatrix) - r = ccall((:arb_mat_overlaps, libflint), Cint, - (Ref{ArbMatrix}, Ref{ArbMatrix}), x, y) + r = @ccall libflint.arb_mat_overlaps(x::Ref{ArbMatrix}, y::Ref{ArbMatrix})::Cint return Bool(r) end @@ -306,8 +288,7 @@ Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ function contains(x::ArbMatrix, y::ArbMatrix) - r = ccall((:arb_mat_contains, libflint), Cint, - (Ref{ArbMatrix}, Ref{ArbMatrix}), x, y) + r = @ccall libflint.arb_mat_contains(x::Ref{ArbMatrix}, y::Ref{ArbMatrix})::Cint return Bool(r) end @@ -324,8 +305,7 @@ Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ function contains(x::ArbMatrix, y::ZZMatrix) - r = ccall((:arb_mat_contains_fmpz_mat, libflint), Cint, - (Ref{ArbMatrix}, Ref{ZZMatrix}), x, y) + r = @ccall libflint.arb_mat_contains_fmpz_mat(x::Ref{ArbMatrix}, y::Ref{ZZMatrix})::Cint return Bool(r) end @@ -337,8 +317,7 @@ Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ function contains(x::ArbMatrix, y::QQMatrix) - r = ccall((:arb_mat_contains_fmpq_mat, libflint), Cint, - (Ref{ArbMatrix}, Ref{QQMatrix}), x, y) + r = @ccall libflint.arb_mat_contains_fmpq_mat(x::Ref{ArbMatrix}, y::Ref{QQMatrix})::Cint return Bool(r) end @@ -376,8 +355,7 @@ end function is_invertible_with_inverse(x::ArbMatrix) ncols(x) != nrows(x) && return false, x z = similar(x) - r = ccall((:arb_mat_inv, libflint), Cint, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Int), z, x, precision(base_ring(x))) + r = @ccall libflint.arb_mat_inv(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, precision(base_ring(x))::Int)::Cint return Bool(r), z end @@ -401,25 +379,19 @@ end function divexact(x::ArbMatrix, y::Int; check::Bool=true) y == 0 && throw(DivideError()) z = similar(x) - ccall((:arb_mat_scalar_div_si, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Int, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.arb_mat_scalar_div_si(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, y::Int, precision(base_ring(x))::Int)::Nothing return z end function divexact(x::ArbMatrix, y::ZZRingElem; check::Bool=true) z = similar(x) - ccall((:arb_mat_scalar_div_fmpz, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Ref{ZZRingElem}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.arb_mat_scalar_div_fmpz(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, y::Ref{ZZRingElem}, precision(base_ring(x))::Int)::Nothing return z end function divexact(x::ArbMatrix, y::ArbFieldElem; check::Bool=true) z = similar(x) - ccall((:arb_mat_scalar_div_arb, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Ref{ArbFieldElem}, Int), - z, x, y, precision(base_ring(x))) + @ccall libflint.arb_mat_scalar_div_arb(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, y::Ref{ArbFieldElem}, precision(base_ring(x))::Int)::Nothing return z end @@ -432,8 +404,7 @@ end function charpoly(x::ArbPolyRing, y::ArbMatrix) base_ring(y) != base_ring(x) && error("Base rings must coincide") z = x() - ccall((:arb_mat_charpoly, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbMatrix}, Int), z, y, precision(base_ring(y))) + @ccall libflint.arb_mat_charpoly(z::Ref{ArbPolyRingElem}, y::Ref{ArbMatrix}, precision(base_ring(y))::Int)::Nothing return z end @@ -446,8 +417,7 @@ end function det(x::ArbMatrix) ncols(x) != nrows(x) && error("Matrix must be square") z = base_ring(x)() - ccall((:arb_mat_det, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbMatrix}, Int), z, x, precision(base_ring(x))) + @ccall libflint.arb_mat_det(z::Ref{ArbFieldElem}, x::Ref{ArbMatrix}, precision(base_ring(x))::Int)::Nothing return z end @@ -460,8 +430,7 @@ end function Base.exp(x::ArbMatrix) ncols(x) != nrows(x) && error("Matrix must be square") z = similar(x) - ccall((:arb_mat_exp, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Int), z, x, precision(base_ring(x))) + @ccall libflint.arb_mat_exp(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, precision(base_ring(x))::Int)::Nothing return z end @@ -475,7 +444,7 @@ function cholesky(x::ArbMatrix) ncols(x) != nrows(x) && error("Matrix must be square") z = similar(x, nrows(x), ncols(x)) p = precision(base_ring(x)) - fl = ccall((:arb_mat_cho, libflint), Cint, (Ref{ArbMatrix}, Ref{ArbMatrix}, Int), z, x, p) + fl = @ccall libflint.arb_mat_cho(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, p::Int)::Cint fl == 0 && error("Matrix is not positive definite") return z end @@ -483,9 +452,7 @@ end function lu!(P::Perm, z::ArbMatrix, x::ArbMatrix) parent(P).n != nrows(x) && error("Permutation does not match matrix") P.d .-= 1 - r = ccall((:arb_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{ArbMatrix}, Ref{ArbMatrix}, Int), - P.d, z, x, precision(base_ring(x))) + r = @ccall libflint.arb_mat_lu(P.d::Ptr{Int}, z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, precision(base_ring(x))::Int)::Cint r == 0 && error("Could not find $(nrows(x)) invertible pivot elements") P.d .+= 1 inv!(P) @@ -497,18 +464,14 @@ function lu!(P::Perm, x::ArbMatrix) end function _solve!(z::ArbMatrix, x::ArbMatrix, y::ArbMatrix) - r = ccall((:arb_mat_solve, libflint), Cint, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Ref{ArbMatrix}, Int), - z, x, y, precision(base_ring(x))) + r = @ccall libflint.arb_mat_solve(z::Ref{ArbMatrix}, x::Ref{ArbMatrix}, y::Ref{ArbMatrix}, precision(base_ring(x))::Int)::Cint r == 0 && error("Matrix cannot be inverted numerically") nothing end function _solve_lu_precomp!(z::ArbMatrix, P::Perm, LU::ArbMatrix, y::ArbMatrix) Q = inv(P) - ccall((:arb_mat_solve_lu_precomp, libflint), Nothing, - (Ref{ArbMatrix}, Ptr{Int}, Ref{ArbMatrix}, Ref{ArbMatrix}, Int), - z, Q.d .- 1, LU, y, precision(base_ring(LU))) + @ccall libflint.arb_mat_solve_lu_precomp(z::Ref{ArbMatrix}, (Q.d .- 1)::Ptr{Int}, LU::Ref{ArbMatrix}, y::Ref{ArbMatrix}, precision(base_ring(LU))::Int)::Nothing nothing end @@ -520,9 +483,7 @@ function _solve_lu_precomp(P::Perm, LU::ArbMatrix, y::ArbMatrix) end function _solve_cholesky_precomp!(z::ArbMatrix, cho::ArbMatrix, y::ArbMatrix) - ccall((:arb_mat_solve_cho_precomp, libflint), Nothing, - (Ref{ArbMatrix}, Ref{ArbMatrix}, Ref{ArbMatrix}, Int), - z, cho, y, precision(base_ring(cho))) + @ccall libflint.arb_mat_solve_cho_precomp(z::Ref{ArbMatrix}, cho::Ref{ArbMatrix}, y::Ref{ArbMatrix}, precision(base_ring(cho))::Int)::Nothing nothing end @@ -635,9 +596,7 @@ function swap_rows(x::ArbMatrix, i::Int, j::Int) end function swap_rows!(x::ArbMatrix, i::Int, j::Int) - ccall((:arb_mat_swap_rows, libflint), Nothing, - (Ref{ArbMatrix}, Ptr{Nothing}, Int, Int), - x, C_NULL, i - 1, j - 1) + @ccall libflint.arb_mat_swap_rows(x::Ref{ArbMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int)::Nothing end ################################################################################ @@ -656,13 +615,10 @@ function bound_inf_norm(x::ArbMatrix) z = ArbFieldElem() GC.@preserve x z begin t = _rad_ptr(z) - ccall((:arb_mat_bound_inf_norm, libflint), Nothing, - (Ptr{mag_struct}, Ref{ArbMatrix}), t, x) + @ccall libflint.arb_mat_bound_inf_norm(t::Ptr{mag_struct}, x::Ref{ArbMatrix})::Nothing s = _mid_ptr(z) - ccall((:arf_set_mag, libflint), Nothing, - (Ptr{arf_struct}, Ptr{mag_struct}), s, t) - ccall((:mag_zero, libflint), Nothing, - (Ptr{mag_struct},), t) + @ccall libflint.arf_set_mag(s::Ptr{arf_struct}, t::Ptr{mag_struct})::Nothing + @ccall libflint.mag_zero(t::Ptr{mag_struct})::Nothing end return base_ring(x)(z) end @@ -810,8 +766,7 @@ end ################################################################################ @inline mat_entry_ptr(A::ArbMatrix, i::Int, j::Int) = -ccall((:arb_mat_entry_ptr, libflint), - Ptr{ArbFieldElem}, (Ref{ArbMatrix}, Int, Int), A, i-1, j-1) +@ccall libflint.arb_mat_entry_ptr(A::Ref{ArbMatrix}, (i-1)::Int, (j-1)::Int)::Ptr{ArbFieldElem} ############################################################################### # diff --git a/src/arb/arb_poly.jl b/src/arb/arb_poly.jl index 2eb1156b3..abf53d25a 100644 --- a/src/arb/arb_poly.jl +++ b/src/arb/arb_poly.jl @@ -16,12 +16,10 @@ elem_type(::Type{ArbPolyRing}) = ArbPolyRingElem dense_poly_type(::Type{ArbFieldElem}) = ArbPolyRingElem -length(x::ArbPolyRingElem) = ccall((:arb_poly_length, libflint), Int, - (Ref{ArbPolyRingElem},), x) +length(x::ArbPolyRingElem) = @ccall libflint.arb_poly_length(x::Ref{ArbPolyRingElem})::Int function set_length!(x::ArbPolyRingElem, n::Int) - ccall((:_arb_poly_set_length, libflint), Nothing, - (Ref{ArbPolyRingElem}, Int), x, n) + @ccall libflint._arb_poly_set_length(x::Ref{ArbPolyRingElem}, n::Int)::Nothing return x end @@ -30,8 +28,7 @@ degree(x::ArbPolyRingElem) = length(x) - 1 function coeff(a::ArbPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) t = parent(a).base_ring() - ccall((:arb_poly_get_coeff_arb, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbPolyRingElem}, Int), t, a, n) + @ccall libflint.arb_poly_get_coeff_arb(t::Ref{ArbFieldElem}, a::Ref{ArbPolyRingElem}, n::Int)::Nothing return t end @@ -113,8 +110,7 @@ end ############################################################################### function isequal(x::ArbPolyRingElem, y::ArbPolyRingElem) - return ccall((:arb_poly_equal, libflint), Bool, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}), x, y) + return @ccall libflint.arb_poly_equal(x::Ref{ArbPolyRingElem}, y::Ref{ArbPolyRingElem})::Bool end @doc raw""" @@ -124,8 +120,7 @@ Return `true` if the coefficient balls of $x$ overlap the coefficient balls of $y$, otherwise return `false`. """ function overlaps(x::ArbPolyRingElem, y::ArbPolyRingElem) - return ccall((:arb_poly_overlaps, libflint), Bool, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}), x, y) + return @ccall libflint.arb_poly_overlaps(x::Ref{ArbPolyRingElem}, y::Ref{ArbPolyRingElem})::Bool end @doc raw""" @@ -135,8 +130,7 @@ Return `true` if the coefficient balls of $x$ contain the corresponding coefficient balls of $y$, otherwise return `false`. """ function contains(x::ArbPolyRingElem, y::ArbPolyRingElem) - return ccall((:arb_poly_contains, libflint), Bool, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}), x, y) + return @ccall libflint.arb_poly_contains(x::Ref{ArbPolyRingElem}, y::Ref{ArbPolyRingElem})::Bool end @doc raw""" @@ -146,8 +140,7 @@ Return `true` if the coefficient balls of $x$ contain the corresponding exact coefficients of $y$, otherwise return `false`. """ function contains(x::ArbPolyRingElem, y::ZZPolyRingElem) - return ccall((:arb_poly_contains_fmpz_poly, libflint), Bool, - (Ref{ArbPolyRingElem}, Ref{ZZPolyRingElem}), x, y) + return @ccall libflint.arb_poly_contains_fmpz_poly(x::Ref{ArbPolyRingElem}, y::Ref{ZZPolyRingElem})::Bool end @doc raw""" @@ -157,8 +150,7 @@ Return `true` if the coefficient balls of $x$ contain the corresponding exact coefficients of $y$, otherwise return `false`. """ function contains(x::ArbPolyRingElem, y::QQPolyRingElem) - return ccall((:arb_poly_contains_fmpq_poly, libflint), Bool, - (Ref{ArbPolyRingElem}, Ref{QQPolyRingElem}), x, y) + return @ccall libflint.arb_poly_contains_fmpq_poly(x::Ref{ArbPolyRingElem}, y::Ref{QQPolyRingElem})::Bool end function ==(x::ArbPolyRingElem, y::ArbPolyRingElem) @@ -191,8 +183,7 @@ In the former case, $z$ is set to the integer polynomial. """ function unique_integer(x::ArbPolyRingElem) z = ZZPolyRing(ZZ, var(parent(x)))() - unique = ccall((:arb_poly_get_unique_fmpz_poly, libflint), Int, - (Ref{ZZPolyRingElem}, Ref{ArbPolyRingElem}), z, x) + unique = @ccall libflint.arb_poly_get_unique_fmpz_poly(z::Ref{ZZPolyRingElem}, x::Ref{ArbPolyRingElem})::Int return (unique != 0, z) end @@ -205,16 +196,14 @@ end function shift_left(x::ArbPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:arb_poly_shift_left, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Int), z, x, len) + @ccall libflint.arb_poly_shift_left(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, len::Int)::Nothing return z end function shift_right(x::ArbPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:arb_poly_shift_right, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Int), z, x, len) + @ccall libflint.arb_poly_shift_right(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, len::Int)::Nothing return z end @@ -251,9 +240,7 @@ end function ^(x::ArbPolyRingElem, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() - ccall((:arb_poly_pow_ui, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, UInt, Int), - z, x, y, precision(parent(x))) + @ccall libflint.arb_poly_pow_ui(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, y::UInt, precision(parent(x))::Int)::Nothing return z end @@ -337,17 +324,14 @@ function truncate(a::ArbPolyRingElem, n::Int) end # todo: implement set_trunc in ArbFieldElem z = deepcopy(a) - ccall((:arb_poly_truncate, libflint), Nothing, - (Ref{ArbPolyRingElem}, Int), z, n) + @ccall libflint.arb_poly_truncate(z::Ref{ArbPolyRingElem}, n::Int)::Nothing return z end function mullow(x::ArbPolyRingElem, y::ArbPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() - ccall((:arb_poly_mullow, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Int, Int), - z, x, y, n, precision(parent(x))) + @ccall libflint.arb_poly_mullow(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, y::Ref{ArbPolyRingElem}, n::Int, precision(parent(x))::Int)::Nothing return z end @@ -373,17 +357,13 @@ end function evaluate(x::ArbPolyRingElem, y::ArbFieldElem) z = parent(y)() - ccall((:arb_poly_evaluate, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbPolyRingElem}, Ref{ArbFieldElem}, Int), - z, x, y, precision(parent(y))) + @ccall libflint.arb_poly_evaluate(z::Ref{ArbFieldElem}, x::Ref{ArbPolyRingElem}, y::Ref{ArbFieldElem}, precision(parent(y))::Int)::Nothing return z end function evaluate(x::ArbPolyRingElem, y::AcbFieldElem) z = parent(y)() - ccall((:arb_poly_evaluate_acb, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{ArbPolyRingElem}, Ref{AcbFieldElem}, Int), - z, x, y, precision(parent(y))) + @ccall libflint.arb_poly_evaluate_acb(z::Ref{AcbFieldElem}, x::Ref{ArbPolyRingElem}, y::Ref{AcbFieldElem}, precision(parent(y))::Int)::Nothing return z end @@ -402,18 +382,14 @@ its derivative evaluated at $y$. function evaluate2(x::ArbPolyRingElem, y::ArbFieldElem) z = parent(y)() w = parent(y)() - ccall((:arb_poly_evaluate2, libflint), Nothing, - (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Ref{ArbPolyRingElem}, Ref{ArbFieldElem}, Int), - z, w, x, y, precision(parent(y))) + @ccall libflint.arb_poly_evaluate2(z::Ref{ArbFieldElem}, w::Ref{ArbFieldElem}, x::Ref{ArbPolyRingElem}, y::Ref{ArbFieldElem}, precision(parent(y))::Int)::Nothing return z, w end function evaluate2(x::ArbPolyRingElem, y::AcbFieldElem) z = parent(y)() w = parent(y)() - ccall((:arb_poly_evaluate2_acb, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{ArbPolyRingElem}, Ref{AcbFieldElem}, Int), - z, w, x, y, precision(parent(y))) + @ccall libflint.arb_poly_evaluate2_acb(z::Ref{AcbFieldElem}, w::Ref{AcbFieldElem}, x::Ref{ArbPolyRingElem}, y::Ref{AcbFieldElem}, precision(parent(y))::Int)::Nothing return z, w end @@ -427,9 +403,7 @@ evaluate2(x::ArbPolyRingElem, y::Any) = evaluate2(x, base_ring(parent(x))(y)) function AbstractAlgebra._compose_right(x::ArbPolyRingElem, y::ArbPolyRingElem) z = parent(x)() - ccall((:arb_poly_compose, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Int), - z, x, y, precision(parent(x))) + @ccall libflint.arb_poly_compose(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, y::Ref{ArbPolyRingElem}, precision(parent(x))::Int)::Nothing return z end @@ -441,15 +415,13 @@ end function derivative(x::ArbPolyRingElem) z = parent(x)() - ccall((:arb_poly_derivative, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Int), z, x, precision(parent(x))) + @ccall libflint.arb_poly_derivative(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, precision(parent(x))::Int)::Nothing return z end function integral(x::ArbPolyRingElem) z = parent(x)() - ccall((:arb_poly_integral, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Int), z, x, precision(parent(x))) + @ccall libflint.arb_poly_integral(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, precision(parent(x))::Int)::Nothing return z end @@ -460,7 +432,7 @@ end ############################################################################### function arb_vec(b::Vector{ArbFieldElem}) - v = ccall((:_arb_vec_init, libflint), Ptr{arb_struct}, (Int,), length(b)) + v = @ccall libflint._arb_vec_init(length(b)::Int)::Ptr{arb_struct} for i in 1:length(b) _arb_set(v + (i-1)*sizeof(arb_struct), b[i]) end @@ -484,8 +456,7 @@ Construct a polynomial in the given polynomial ring from a list of its roots. function from_roots(R::ArbPolyRing, b::Vector{ArbFieldElem}) z = R() tmp = arb_vec(b) - ccall((:arb_poly_product_roots, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ptr{arb_struct}, Int, Int), z, tmp, length(b), precision(R)) + @ccall libflint.arb_poly_product_roots(z::Ref{ArbPolyRingElem}, tmp::Ptr{arb_struct}, length(b)::Int, precision(R)::Int)::Nothing arb_vec_clear(tmp, length(b)) return z end @@ -496,9 +467,7 @@ end function evaluate_fast(x::ArbPolyRingElem, b::Vector{ArbFieldElem}) tmp = arb_vec(b) - ccall((:arb_poly_evaluate_vec_fast, libflint), Nothing, - (Ptr{arb_struct}, Ref{ArbPolyRingElem}, Ptr{arb_struct}, Int, Int), - tmp, x, tmp, length(b), precision(parent(x))) + @ccall libflint.arb_poly_evaluate_vec_fast(tmp::Ptr{arb_struct}, x::Ref{ArbPolyRingElem}, tmp::Ptr{arb_struct}, length(b)::Int, precision(parent(x))::Int)::Nothing res = array(base_ring(parent(x)), tmp, length(b)) arb_vec_clear(tmp, length(b)) return res @@ -509,9 +478,7 @@ function interpolate_newton(R::ArbPolyRing, xs::Vector{ArbFieldElem}, ys::Vector z = R() xsv = arb_vec(xs) ysv = arb_vec(ys) - ccall((:arb_poly_interpolate_newton, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ptr{arb_struct}, Ptr{arb_struct}, Int, Int), - z, xsv, ysv, length(xs), precision(R)) + @ccall libflint.arb_poly_interpolate_newton(z::Ref{ArbPolyRingElem}, xsv::Ptr{arb_struct}, ysv::Ptr{arb_struct}, length(xs)::Int, precision(R)::Int)::Nothing arb_vec_clear(xsv, length(xs)) arb_vec_clear(ysv, length(ys)) return z @@ -522,9 +489,7 @@ function interpolate_barycentric(R::ArbPolyRing, xs::Vector{ArbFieldElem}, ys::V z = R() xsv = arb_vec(xs) ysv = arb_vec(ys) - ccall((:arb_poly_interpolate_barycentric, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ptr{arb_struct}, Ptr{arb_struct}, Int, Int), - z, xsv, ysv, length(xs), precision(R)) + @ccall libflint.arb_poly_interpolate_barycentric(z::Ref{ArbPolyRingElem}, xsv::Ptr{arb_struct}, ysv::Ptr{arb_struct}, length(xs)::Int, precision(R)::Int)::Nothing arb_vec_clear(xsv, length(xs)) arb_vec_clear(ysv, length(ys)) return z @@ -535,9 +500,7 @@ function interpolate_fast(R::ArbPolyRing, xs::Vector{ArbFieldElem}, ys::Vector{A z = R() xsv = arb_vec(xs) ysv = arb_vec(ys) - ccall((:arb_poly_interpolate_fast, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ptr{arb_struct}, Ptr{arb_struct}, Int, Int), - z, xsv, ysv, length(xs), precision(R)) + @ccall libflint.arb_poly_interpolate_fast(z::Ref{ArbPolyRingElem}, xsv::Ptr{arb_struct}, ysv::Ptr{arb_struct}, length(xs)::Int, precision(R)::Int)::Nothing arb_vec_clear(xsv, length(xs)) arb_vec_clear(ysv, length(ys)) return z @@ -569,13 +532,11 @@ function roots_upper_bound(x::ArbPolyRingElem) p = precision(base_ring(x)) GC.@preserve x z begin t = _rad_ptr(z) - ccall((:arb_poly_root_bound_fujiwara, libflint), Nothing, - (Ptr{mag_struct}, Ref{ArbPolyRingElem}), t, x) + @ccall libflint.arb_poly_root_bound_fujiwara(t::Ptr{mag_struct}, x::Ref{ArbPolyRingElem})::Nothing s = _mid_ptr(z) - ccall((:arf_set_mag, libflint), Nothing, (Ptr{arf_struct}, Ptr{mag_struct}), s, t) - ccall((:arf_set_round, libflint), Nothing, - (Ptr{arf_struct}, Ptr{arf_struct}, Int, Cint), s, s, p, ARB_RND_CEIL) - ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct},), t) + @ccall libflint.arf_set_mag(s::Ptr{arf_struct}, t::Ptr{mag_struct})::Nothing + @ccall libflint.arf_set_round(s::Ptr{arf_struct}, s::Ptr{arf_struct}, p::Int, ARB_RND_CEIL::Cint)::Nothing + @ccall libflint.mag_zero(t::Ptr{mag_struct})::Nothing end return z end @@ -602,20 +563,17 @@ function neg!(z::ArbPolyRingElemOrPtr, a::ArbPolyRingElemOrPtr) end function fit!(z::ArbPolyRingElem, n::Int) - ccall((:arb_poly_fit_length, libflint), Nothing, - (Ref{ArbPolyRingElem}, Int), z, n) + @ccall libflint.arb_poly_fit_length(z::Ref{ArbPolyRingElem}, n::Int)::Nothing return nothing end function setcoeff!(z::ArbPolyRingElem, n::Int, x::ArbFieldElem) - ccall((:arb_poly_set_coeff_arb, libflint), Nothing, - (Ref{ArbPolyRingElem}, Int, Ref{ArbFieldElem}), z, n, x) + @ccall libflint.arb_poly_set_coeff_arb(z::Ref{ArbPolyRingElem}, n::Int, x::Ref{ArbFieldElem})::Nothing return z end function setcoeff!(z::ArbPolyRingElem, n::Int, x::Int) - ccall((:arb_poly_set_coeff_si, libflint), Nothing, - (Ref{ArbPolyRingElem}, Int, Int), z, n, x) + @ccall libflint.arb_poly_set_coeff_si(z::Ref{ArbPolyRingElem}, n::Int, x::Int)::Nothing return z end @@ -628,16 +586,12 @@ setcoeff!(z::ArbPolyRingElem, n::Int, x::Integer) = setcoeff!(z, n, flintify(x)) # function add!(z::ArbPolyRingElem, x::ArbPolyRingElem, y::ArbPolyRingElem) - ccall((:arb_poly_add, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Int), - z, x, y, precision(parent(z))) + @ccall libflint.arb_poly_add(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, y::Ref{ArbPolyRingElem}, precision(parent(z))::Int)::Nothing return z end function add!(z::ArbPolyRingElem, x::ArbPolyRingElem, y::Int) - ccall((:arb_poly_add_si, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Int, Int), - z, x, y, precision(parent(z))) + @ccall libflint.arb_poly_add_si(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, y::Int, precision(parent(z))::Int)::Nothing return z end @@ -652,9 +606,7 @@ add!(z::ArbPolyRingElem, x::Union{ArbFieldElem,IntegerUnion}, y::ArbPolyRingElem # function sub!(z::ArbPolyRingElem, x::ArbPolyRingElem, y::ArbPolyRingElem) - ccall((:arb_poly_sub, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Int), - z, x, y, precision(parent(z))) + @ccall libflint.arb_poly_sub(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, y::Ref{ArbPolyRingElem}, precision(parent(z))::Int)::Nothing return z end @@ -665,16 +617,12 @@ sub!(z::ArbPolyRingElem, x::Union{ArbFieldElem,IntegerUnion}, y::ArbPolyRingElem # function mul!(z::ArbPolyRingElem, x::ArbPolyRingElem, y::ArbPolyRingElem) - ccall((:arb_poly_mul, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Int), - z, x, y, precision(parent(z))) + @ccall libflint.arb_poly_mul(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, y::Ref{ArbPolyRingElem}, precision(parent(z))::Int)::Nothing return z end function mul!(z::ArbPolyRingElem, x::ArbPolyRingElem, y::ArbFieldElem) - ccall((:arb_poly_scalar_mul, libflint), Nothing, - (Ref{ArbPolyRingElem}, Ref{ArbPolyRingElem}, Ref{ArbFieldElem}, Int), - z, x, y, precision(parent(z))) + @ccall libflint.arb_poly_scalar_mul(z::Ref{ArbPolyRingElem}, x::Ref{ArbPolyRingElem}, y::Ref{ArbFieldElem}, precision(parent(z))::Int)::Nothing return z end diff --git a/src/calcium/CalciumTypes.jl b/src/calcium/CalciumTypes.jl index 4778fdbf6..ef4e48551 100644 --- a/src/calcium/CalciumTypes.jl +++ b/src/calcium/CalciumTypes.jl @@ -106,7 +106,7 @@ mutable struct QQBarFieldElem <: FieldElem function QQBarFieldElem() z = new() - ccall((:qqbar_init, libflint), Nothing, (Ref{QQBarFieldElem}, ), z) + @ccall libflint.qqbar_init(z::Ref{QQBarFieldElem})::Nothing finalizer(_qqbar_clear_fn, z) return z end @@ -114,7 +114,7 @@ mutable struct QQBarFieldElem <: FieldElem end function _qqbar_clear_fn(a::QQBarFieldElem) - ccall((:qqbar_clear, libflint), Nothing, (Ref{QQBarFieldElem},), a) + @ccall libflint.qqbar_clear(a::Ref{QQBarFieldElem})::Nothing end ################################################################################ @@ -164,14 +164,14 @@ const ca_ctx_options = [ function CalciumField(; extended::Bool=false, options::Dict{Symbol,Int}=Dict{Symbol,Int}()) C = new() - ccall((:ca_ctx_init, libflint), Nothing, (Ref{CalciumField}, ), C) + @ccall libflint.ca_ctx_init(C::Ref{CalciumField})::Nothing finalizer(_CalciumField_clear_fn, C) C.extended = extended for (opt, value) in options i = findfirst(isequal(opt), ca_ctx_options) (i === nothing) && error("unknown option ", opt) - ccall((:ca_ctx_set_option, libflint), Nothing, (Ref{CalciumField}, Int, Int), C, i - 1, value) + @ccall libflint.ca_ctx_set_option(C::Ref{CalciumField}, (i - 1)::Int, value::Int)::Nothing end C.refcount = 1 @@ -182,7 +182,7 @@ end function options(C::CalciumField) d = Dict{Symbol,Int}() for i=1:length(ca_ctx_options) - d[ca_ctx_options[i]] = ccall((:ca_ctx_get_option, libflint), Int, (Ref{CalciumField}, Int), C, i - 1) + d[ca_ctx_options[i]] = @ccall libflint.ca_ctx_get_option(C::Ref{CalciumField}, (i - 1)::Int)::Int end return d end @@ -190,7 +190,7 @@ end function decrement_refcount(C::CalciumField) C.refcount -= 1 if C.refcount == 0 - ccall((:ca_ctx_clear, libflint), Nothing, (Ref{CalciumField},), C) + @ccall libflint.ca_ctx_clear(C::Ref{CalciumField})::Nothing end end @@ -210,8 +210,7 @@ mutable struct CalciumFieldElem <: FieldElem function CalciumFieldElem(ctx::CalciumField) z = new() - ccall((:ca_init, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumField}), z, ctx) + @ccall libflint.ca_init(z::Ref{CalciumFieldElem}, ctx::Ref{CalciumField})::Nothing z.parent = ctx z.parent.refcount += 1 finalizer(_ca_clear_fn, z) @@ -221,8 +220,7 @@ mutable struct CalciumFieldElem <: FieldElem end function _ca_clear_fn(a::CalciumFieldElem) - ccall((:ca_clear, libflint), - Nothing, (Ref{CalciumFieldElem}, Ref{CalciumField}), a, a.parent) + @ccall libflint.ca_clear(a::Ref{CalciumFieldElem}, a.parent::Ref{CalciumField})::Nothing decrement_refcount(a.parent) end diff --git a/src/calcium/ca.jl b/src/calcium/ca.jl index 9b6b4af33..c85afe3ba 100644 --- a/src/calcium/ca.jl +++ b/src/calcium/ca.jl @@ -27,8 +27,7 @@ characteristic(a::CalciumField) = 0 function deepcopy_internal(a::CalciumFieldElem, dict::IdDict) C = a.parent r = C() - ccall((:ca_set, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_set(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing return r end @@ -49,9 +48,7 @@ function same_parent(a::CalciumFieldElem, b::CalciumFieldElem) else C = a.parent r = C() - ccall((:ca_transfer, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumField}, Ref{CalciumFieldElem}, Ref{CalciumField}), - r, a.parent, b, b.parent) + @ccall libflint.ca_transfer(r::Ref{CalciumFieldElem}, a.parent::Ref{CalciumField}, b::Ref{CalciumFieldElem}, b.parent::Ref{CalciumField})::Nothing check_special(r) return (a, r) end @@ -93,10 +90,9 @@ function show(io::IO, C::CalciumField) end function native_string(x::CalciumFieldElem) - cstr = ccall((:ca_get_str, libflint), - Ptr{UInt8}, (Ref{CalciumFieldElem}, Ref{CalciumField}), x, x.parent) + cstr = @ccall libflint.ca_get_str(x::Ref{CalciumFieldElem}, x.parent::Ref{CalciumField})::Ptr{UInt8} res = unsafe_string(cstr) - ccall((:flint_free, libflint), Nothing, (Ptr{UInt8},), cstr) + @ccall libflint.flint_free(cstr::Ptr{UInt8})::Nothing return res end @@ -130,17 +126,11 @@ function rand(C::CalciumField; depth::Int, bits::Int, bits = max(bits, 1) if randtype == :null - ccall((:ca_randtest, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{rand_ctx}, Int, Int, Ref{CalciumField}), - x, state, depth, bits, C) + @ccall libflint.ca_randtest(x::Ref{CalciumFieldElem}, state::Ref{rand_ctx}, depth::Int, bits::Int, C::Ref{CalciumField})::Nothing elseif randtype == :rational - ccall((:ca_randtest_rational, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{rand_ctx}, Int, Ref{CalciumField}), - x, state, bits, C) + @ccall libflint.ca_randtest_rational(x::Ref{CalciumFieldElem}, state::Ref{rand_ctx}, bits::Int, C::Ref{CalciumField})::Nothing elseif randtype == :special - ccall((:ca_randtest_special, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{rand_ctx}, Int, Int, Ref{CalciumField}), - x, state, depth, bits, C) + @ccall libflint.ca_randtest_special(x::Ref{CalciumFieldElem}, state::Ref{rand_ctx}, depth::Int, bits::Int, C::Ref{CalciumField})::Nothing else error("randtype not defined") end @@ -158,16 +148,14 @@ end function ==(a::CalciumFieldElem, b::CalciumFieldElem) a, b = same_parent(a, b) C = a.parent - t = ccall((:ca_check_equal, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), a, b, C) + t = @ccall libflint.ca_check_equal(a::Ref{CalciumFieldElem}, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :isequal) end function isless(a::CalciumFieldElem, b::CalciumFieldElem) a, b = same_parent(a, b) C = a.parent - t = ccall((:ca_check_lt, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), a, b, C) + t = @ccall libflint.ca_check_lt(a::Ref{CalciumFieldElem}, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :isless) end @@ -187,8 +175,7 @@ Return whether `a` is a number, i.e. not an infinity or undefined. """ function is_number(a::CalciumFieldElem) C = a.parent - t = ccall((:ca_check_is_number, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C) + t = @ccall libflint.ca_check_is_number(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :is_number) end @@ -199,8 +186,7 @@ Return whether `a` is the number 0. """ function iszero(a::CalciumFieldElem) C = a.parent - t = ccall((:ca_check_is_zero, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C) + t = @ccall libflint.ca_check_is_zero(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :iszero) end @@ -211,8 +197,7 @@ Return whether `a` is the number 1. """ function isone(a::CalciumFieldElem) C = a.parent - t = ccall((:ca_check_is_one, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C) + t = @ccall libflint.ca_check_is_one(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :isone) end @@ -223,8 +208,7 @@ Return whether `a` is an algebraic number. """ function is_algebraic(a::CalciumFieldElem) C = a.parent - t = ccall((:ca_check_is_algebraic, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C) + t = @ccall libflint.ca_check_is_algebraic(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :is_algebraic) end @@ -235,8 +219,7 @@ Return whether `a` is a rational number. """ function is_rational(a::CalciumFieldElem) C = a.parent - t = ccall((:ca_check_is_rational, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C) + t = @ccall libflint.ca_check_is_rational(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :is_rational) end @@ -247,8 +230,7 @@ Return whether `a` is an integer. """ function isinteger(a::CalciumFieldElem) C = a.parent - t = ccall((:ca_check_is_integer, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C) + t = @ccall libflint.ca_check_is_integer(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :isinteger) end @@ -260,8 +242,7 @@ if `a` is a pure real infinity. """ function isreal(a::CalciumFieldElem) C = a.parent - t = ccall((:ca_check_is_real, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C) + t = @ccall libflint.ca_check_is_real(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :isreal) end @@ -273,8 +254,7 @@ if `a` is a pure imaginary infinity. """ function is_imaginary(a::CalciumFieldElem) C = a.parent - t = ccall((:ca_check_is_imaginary, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C) + t = @ccall libflint.ca_check_is_imaginary(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :is_imaginary) end @@ -285,8 +265,7 @@ Return whether `a` is the special value *Undefined*. """ function is_undefined(a::CalciumFieldElem) C = a.parent - t = ccall((:ca_check_is_undefined, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C) + t = @ccall libflint.ca_check_is_undefined(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :is_undefined) end @@ -297,8 +276,7 @@ Return whether `a` is any infinity (signed or unsigned). """ function isinf(a::CalciumFieldElem) C = a.parent - t = ccall((:ca_check_is_infinity, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C) + t = @ccall libflint.ca_check_is_infinity(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :isinf) end @@ -309,8 +287,7 @@ Return whether `a` is unsigned infinity. """ function is_uinf(a::CalciumFieldElem) C = a.parent - t = ccall((:ca_check_is_uinf, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C) + t = @ccall libflint.ca_check_is_uinf(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :is_uinf) end @@ -321,8 +298,7 @@ Return whether `a` is any signed infinity. """ function is_signed_inf(a::CalciumFieldElem) C = a.parent - t = ccall((:ca_check_is_signed_inf, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C) + t = @ccall libflint.ca_check_is_signed_inf(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint return truth_as_bool(t, :is_signed_inf) end @@ -334,8 +310,7 @@ property and not a mathematical predicate. """ function is_unknown(a::CalciumFieldElem) C = a.parent - t = Bool(ccall((:ca_is_unknown, libflint), Cint, - (Ref{CalciumFieldElem}, Ref{CalciumField}), a, C)) + t = Bool(@ccall libflint.ca_is_unknown(a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint) return t end @@ -361,8 +336,7 @@ function +(a::CalciumFieldElem, b::CalciumFieldElem) a, b = same_parent(a, b) C = a.parent r = C() - ccall((:ca_add, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_add(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -370,8 +344,7 @@ end function -(a::Int, b::CalciumFieldElem) C = b.parent r = C() - ccall((:ca_si_sub, libflint), Nothing, - (Ref{CalciumFieldElem}, Int, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_si_sub(r::Ref{CalciumFieldElem}, a::Int, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -380,8 +353,7 @@ function *(a::CalciumFieldElem, b::CalciumFieldElem) a, b = same_parent(a, b) C = a.parent r = C() - ccall((:ca_mul, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_mul(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -395,8 +367,7 @@ end function +(a::CalciumFieldElem, b::Int) C = a.parent r = C() - ccall((:ca_add_si, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Int, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_add_si(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Int, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -404,8 +375,7 @@ end function +(a::CalciumFieldElem, b::ZZRingElem) C = a.parent r = C() - ccall((:ca_add_fmpz, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{ZZRingElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_add_fmpz(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{ZZRingElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -413,8 +383,7 @@ end function +(a::CalciumFieldElem, b::QQFieldElem) C = a.parent r = C() - ccall((:ca_add_fmpq, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{QQFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_add_fmpq(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{QQFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -430,8 +399,7 @@ function -(a::CalciumFieldElem, b::CalciumFieldElem) a, b = same_parent(a, b) C = a.parent r = C() - ccall((:ca_sub, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_sub(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -439,8 +407,7 @@ end function -(a::CalciumFieldElem, b::Int) C = a.parent r = C() - ccall((:ca_sub_si, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Int, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_sub_si(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Int, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -448,8 +415,7 @@ end function -(a::CalciumFieldElem, b::ZZRingElem) C = a.parent r = C() - ccall((:ca_sub_fmpz, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{ZZRingElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_sub_fmpz(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{ZZRingElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -457,8 +423,7 @@ end function -(a::CalciumFieldElem, b::QQFieldElem) C = a.parent r = C() - ccall((:ca_sub_fmpq, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{QQFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_sub_fmpq(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{QQFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -468,8 +433,7 @@ end function -(a::ZZRingElem, b::CalciumFieldElem) C = b.parent r = C() - ccall((:ca_fmpz_sub, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{ZZRingElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_fmpz_sub(r::Ref{CalciumFieldElem}, a::Ref{ZZRingElem}, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -477,8 +441,7 @@ end function -(a::QQFieldElem, b::CalciumFieldElem) C = b.parent r = C() - ccall((:ca_fmpq_sub, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{QQFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_fmpq_sub(r::Ref{CalciumFieldElem}, a::Ref{QQFieldElem}, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -489,8 +452,7 @@ end function *(a::CalciumFieldElem, b::Int) C = a.parent r = C() - ccall((:ca_mul_si, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Int, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_mul_si(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Int, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -498,8 +460,7 @@ end function *(a::CalciumFieldElem, b::ZZRingElem) C = a.parent r = C() - ccall((:ca_mul_fmpz, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{ZZRingElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_mul_fmpz(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{ZZRingElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -507,8 +468,7 @@ end function *(a::CalciumFieldElem, b::QQFieldElem) C = a.parent r = C() - ccall((:ca_mul_fmpq, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{QQFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_mul_fmpq(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{QQFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -530,8 +490,7 @@ function //(a::CalciumFieldElem, b::CalciumFieldElem) a, b = same_parent(a, b) C = a.parent r = C() - ccall((:ca_div, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_div(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -541,8 +500,7 @@ divexact(a::CalciumFieldElem, b::CalciumFieldElem; check::Bool=true) = a // b function inv(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_inv, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_inv(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -556,8 +514,7 @@ end function //(a::CalciumFieldElem, b::Int) C = a.parent r = C() - ccall((:ca_div_si, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Int, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_div_si(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Int, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -565,8 +522,7 @@ end function //(a::CalciumFieldElem, b::ZZRingElem) C = a.parent r = C() - ccall((:ca_div_fmpz, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{ZZRingElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_div_fmpz(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{ZZRingElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -574,8 +530,7 @@ end function //(a::CalciumFieldElem, b::QQFieldElem) C = a.parent r = C() - ccall((:ca_div_fmpq, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{QQFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_div_fmpq(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{QQFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -585,8 +540,7 @@ end function //(a::Int, b::CalciumFieldElem) C = b.parent r = C() - ccall((:ca_si_div, libflint), Nothing, - (Ref{CalciumFieldElem}, Int, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_si_div(r::Ref{CalciumFieldElem}, a::Int, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -594,8 +548,7 @@ end function //(a::ZZRingElem, b::CalciumFieldElem) C = b.parent r = C() - ccall((:ca_fmpz_div, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{ZZRingElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_fmpz_div(r::Ref{CalciumFieldElem}, a::Ref{ZZRingElem}, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -603,8 +556,7 @@ end function //(a::QQFieldElem, b::CalciumFieldElem) C = b.parent r = C() - ccall((:ca_fmpq_div, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{QQFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_fmpq_div(r::Ref{CalciumFieldElem}, a::Ref{QQFieldElem}, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -630,8 +582,7 @@ function ^(a::CalciumFieldElem, b::CalciumFieldElem) a, b = same_parent(a, b) C = a.parent r = C() - ccall((:ca_pow, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_pow(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -639,8 +590,7 @@ end function ^(a::CalciumFieldElem, b::Int) C = a.parent r = C() - ccall((:ca_pow_si, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Int, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_pow_si(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Int, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -648,8 +598,7 @@ end function ^(a::CalciumFieldElem, b::ZZRingElem) C = a.parent r = C() - ccall((:ca_pow_fmpz, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{ZZRingElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_pow_fmpz(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{ZZRingElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -657,8 +606,7 @@ end function ^(a::CalciumFieldElem, b::QQFieldElem) C = a.parent r = C() - ccall((:ca_pow_fmpq, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{QQFieldElem}, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_pow_fmpq(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Ref{QQFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -684,7 +632,7 @@ Return the constant $\pi$ as an element of `C`. """ function const_pi(C::CalciumField) r = C() - ccall((:ca_pi, libflint), Nothing, (Ref{CalciumFieldElem}, Ref{CalciumField}), r, C) + @ccall libflint.ca_pi(r::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing return r end @@ -695,7 +643,7 @@ Return Euler's constant $\gamma$ as an element of `C`. """ function const_euler(C::CalciumField) r = C() - ccall((:ca_euler, libflint), Nothing, (Ref{CalciumFieldElem}, Ref{CalciumField}), r, C) + @ccall libflint.ca_euler(r::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing return r end @@ -706,7 +654,7 @@ Return the imaginary unit $i$ as an element of `C`. """ function onei(C::CalciumField) r = C() - ccall((:ca_i, libflint), Nothing, (Ref{CalciumFieldElem}, Ref{CalciumField}), r, C) + @ccall libflint.ca_i(r::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing return r end @@ -718,8 +666,7 @@ This throws an exception if `C` does not allow special values. """ function unsigned_infinity(C::CalciumField) r = C() - ccall((:ca_uinf, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumField}), r, C) + @ccall libflint.ca_uinf(r::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -732,8 +679,7 @@ This throws an exception if `C` does not allow special values. """ function infinity(C::CalciumField) r = C() - ccall((:ca_pos_inf, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumField}), r, C) + @ccall libflint.ca_pos_inf(r::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -748,8 +694,7 @@ does not allow special values. function infinity(a::CalciumFieldElem) C = parent(a) r = C() - ccall((:ca_pos_inf, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumField}), r, C) + @ccall libflint.ca_pos_inf(r::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing r *= a check_special(r) return r @@ -763,8 +708,7 @@ This throws an exception if `C` does not allow special values. """ function undefined(C::CalciumField) r = C() - ccall((:ca_undefined, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumField}), r, C) + @ccall libflint.ca_undefined(r::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -777,8 +721,7 @@ This throws an exception if `C` does not allow special values. """ function unknown(C::CalciumField) r = C() - ccall((:ca_unknown, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumField}), r, C) + @ccall libflint.ca_unknown(r::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -797,8 +740,7 @@ Return the real part of `a`. function real(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_re, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_re(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -811,8 +753,7 @@ Return the imaginary part of `a`. function imag(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_im, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_im(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -825,8 +766,7 @@ Return the complex argument of `a`. function angle(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_arg, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_arg(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -843,8 +783,7 @@ at zero. function csgn(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_csgn, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_csgn(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -859,8 +798,7 @@ extracts the sign when `a` is a signed infinity. function sign(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_sgn, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_sgn(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -873,8 +811,7 @@ Return the absolute value of `a`. function abs(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_abs, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_abs(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -892,14 +829,11 @@ function conj(a::CalciumFieldElem; form::Symbol=:default) C = a.parent r = C() if form == :default - ccall((:ca_conj, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_conj(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :deep - ccall((:ca_conj_deep, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_conj_deep(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :shallow - ccall((:ca_conj_shallow, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_conj_shallow(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing else error("unknown form: ", form) end @@ -915,8 +849,7 @@ Return the floor function of `a`. function floor(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_floor, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_floor(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -929,8 +862,7 @@ Return the ceiling function of `a`. function ceil(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_ceil, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_ceil(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -949,8 +881,7 @@ Return the principal square root of `a`. function Base.sqrt(a::CalciumFieldElem; check::Bool=true) C = a.parent r = C() - ccall((:ca_sqrt, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_sqrt(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -963,8 +894,7 @@ Return the exponential function of `a`. function exp(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_exp, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_exp(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -977,8 +907,7 @@ Return the natural logarithm of `a`. function log(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_log, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_log(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -998,11 +927,9 @@ function pow(a::CalciumFieldElem, b::Int; form::Symbol=:default) C = a.parent r = C() if form == :default - ccall((:ca_pow_si, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Int, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_pow_si(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Int, C::Ref{CalciumField})::Nothing elseif form == :arithmetic - ccall((:ca_pow_si_arithmetic, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Int, Ref{CalciumField}), r, a, b, C) + @ccall libflint.ca_pow_si_arithmetic(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, b::Int, C::Ref{CalciumField})::Nothing else error("unknown form: ", form) end @@ -1025,17 +952,13 @@ function sin(a::CalciumFieldElem; form::Symbol=:default) C = a.parent r = C() if form == :default - ccall((:ca_sin, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_sin(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :exponential - ccall((:ca_sin_cos_exponential, libflint), Nothing, - (Ref{CalciumFieldElem}, Ptr{Nothing}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, C_NULL, a, C) + @ccall libflint.ca_sin_cos_exponential(r::Ref{CalciumFieldElem}, C_NULL::Ptr{Nothing}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :tangent - ccall((:ca_sin_cos_tangent, libflint), Nothing, - (Ref{CalciumFieldElem}, Ptr{Nothing}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, C_NULL, a, C) + @ccall libflint.ca_sin_cos_tangent(r::Ref{CalciumFieldElem}, C_NULL::Ptr{Nothing}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :direct - ccall((:ca_sin_cos_direct, libflint), Nothing, - (Ref{CalciumFieldElem}, Ptr{Nothing}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, C_NULL, a, C) + @ccall libflint.ca_sin_cos_direct(r::Ref{CalciumFieldElem}, C_NULL::Ptr{Nothing}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing else error("unknown form: ", form) end @@ -1058,17 +981,13 @@ function cos(a::CalciumFieldElem; form::Symbol=:default) C = a.parent r = C() if form == :default - ccall((:ca_cos, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_cos(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :exponential - ccall((:ca_sin_cos_exponential, libflint), Nothing, - (Ptr{Nothing}, Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), C_NULL, r, a, C) + @ccall libflint.ca_sin_cos_exponential(C_NULL::Ptr{Nothing}, r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :tangent - ccall((:ca_sin_cos_tangent, libflint), Nothing, - (Ptr{Nothing}, Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), C_NULL, r, a, C) + @ccall libflint.ca_sin_cos_tangent(C_NULL::Ptr{Nothing}, r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :direct || form == :sine_cosine - ccall((:ca_sin_cos_direct, libflint), Nothing, - (Ptr{Nothing}, Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), C_NULL, r, a, C) + @ccall libflint.ca_sin_cos_direct(C_NULL::Ptr{Nothing}, r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing else error("unknown form: ", form) end @@ -1091,17 +1010,13 @@ function tan(a::CalciumFieldElem; form::Symbol=:default) C = a.parent r = C() if form == :default - ccall((:ca_tan, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_tan(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :exponential - ccall((:ca_tan_exponential, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_tan_exponential(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :direct || form == :tangent - ccall((:ca_tan_direct, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_tan_direct(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :sine_cosine - ccall((:ca_tan_sine_cosine, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_tan_sine_cosine(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing else error("unknown form: ", form) end @@ -1123,14 +1038,11 @@ function atan(a::CalciumFieldElem; form::Symbol=:default) C = a.parent r = C() if form == :default - ccall((:ca_atan, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_atan(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :logarithm - ccall((:ca_atan_logarithm, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_atan_logarithm(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :direct || form == :arctangent - ccall((:ca_atan_direct, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_atan_direct(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing else error("unknown form: ", form) end @@ -1152,14 +1064,11 @@ function asin(a::CalciumFieldElem; form::Symbol=:default) C = a.parent r = C() if form == :default - ccall((:ca_asin, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_asin(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :logarithm - ccall((:ca_asin_logarithm, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_asin_logarithm(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :direct - ccall((:ca_asin_direct, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_asin_direct(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing else error("unknown form: ", form) end @@ -1181,14 +1090,11 @@ function acos(a::CalciumFieldElem; form::Symbol=:default) C = a.parent r = C() if form == :default - ccall((:ca_acos, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_acos(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :logarithm - ccall((:ca_acos_logarithm, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_acos_logarithm(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing elseif form == :direct - ccall((:ca_acos_direct, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_acos_direct(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing else error("unknown form: ", form) end @@ -1204,8 +1110,7 @@ Return the gamma function of `a`. function gamma(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_gamma, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_gamma(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -1218,8 +1123,7 @@ Return the error function of `a`. function erf(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_erf, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_erf(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -1232,8 +1136,7 @@ Return the imaginary error function of `a`. function erfi(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_erfi, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_erfi(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -1246,8 +1149,7 @@ Return the complementary error function of `a`. function erfc(a::CalciumFieldElem) C = a.parent r = C() - ccall((:ca_erfc, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), r, a, C) + @ccall libflint.ca_erfc(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -1285,8 +1187,7 @@ heuristic for simplification. function complex_normal_form(a::CalciumFieldElem; deep::Bool=true) C = a.parent r = C() - ccall((:ca_rewrite_complex_normal_form, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Cint, Ref{CalciumField}), r, a, deep, C) + @ccall libflint.ca_rewrite_complex_normal_form(r::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, deep::Cint, C::Ref{CalciumField})::Nothing check_special(r) return r end @@ -1300,8 +1201,7 @@ end function QQFieldElem(a::CalciumFieldElem) C = a.parent res = QQFieldElem() - ok = Bool(ccall((:ca_get_fmpq, libflint), Cint, - (Ref{QQFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), res, a, C)) + ok = Bool(@ccall libflint.ca_get_fmpq(res::Ref{QQFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint) !ok && error("unable to convert to a rational number") return res end @@ -1309,8 +1209,7 @@ end function ZZRingElem(a::CalciumFieldElem) C = a.parent res = ZZRingElem() - ok = Bool(ccall((:ca_get_fmpz, libflint), Cint, - (Ref{ZZRingElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), res, a, C)) + ok = Bool(@ccall libflint.ca_get_fmpz(res::Ref{ZZRingElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint) !ok && error("unable to convert to an integer") return res end @@ -1318,8 +1217,7 @@ end function QQBarFieldElem(a::CalciumFieldElem) C = a.parent res = QQBarFieldElem() - ok = Bool(ccall((:ca_get_qqbar, libflint), Cint, - (Ref{QQBarFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), res, a, C)) + ok = Bool(@ccall libflint.ca_get_qqbar(res::Ref{QQBarFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Cint) !ok && error("unable to convert to an algebraic number") return res end @@ -1333,11 +1231,9 @@ function (R::AcbField)(a::CalciumFieldElem; parts::Bool=false) prec = precision(R) z = R() if parts - ccall((:ca_get_acb_accurate_parts, libflint), - Nothing, (Ref{AcbFieldElem}, Ref{CalciumFieldElem}, Int, Ref{CalciumField}), z, a, prec, C) + @ccall libflint.ca_get_acb_accurate_parts(z::Ref{AcbFieldElem}, a::Ref{CalciumFieldElem}, prec::Int, C::Ref{CalciumField})::Nothing else - ccall((:ca_get_acb, libflint), - Nothing, (Ref{AcbFieldElem}, Ref{CalciumFieldElem}, Int, Ref{CalciumField}), z, a, prec, C) + @ccall libflint.ca_get_acb(z::Ref{AcbFieldElem}, a::Ref{CalciumFieldElem}, prec::Int, C::Ref{CalciumField})::Nothing end return z end @@ -1380,19 +1276,19 @@ end function zero!(z::CalciumFieldElem) C = z.parent - ccall((:ca_zero, libflint), Nothing, (Ref{CalciumFieldElem}, Ref{CalciumField}), z, C) + @ccall libflint.ca_zero(z::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing return z end function one!(z::CalciumFieldElem) C = z.parent - ccall((:ca_one, libflint), Nothing, (Ref{CalciumFieldElem}, Ref{CalciumField}), z, C) + @ccall libflint.ca_one(z::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing return z end function neg!(z::CalciumFieldElem, a::CalciumFieldElem) C = z.parent - ccall((:ca_neg, libflint), Nothing, (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), z, a, C) + @ccall libflint.ca_neg(z::Ref{CalciumFieldElem}, a::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing return z end @@ -1401,8 +1297,7 @@ function mul!(z::CalciumFieldElem, x::CalciumFieldElem, y::CalciumFieldElem) error("different parents in in-place operation") end C = z.parent - ccall((:ca_mul, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), z, x, y, C) + @ccall libflint.ca_mul(z::Ref{CalciumFieldElem}, x::Ref{CalciumFieldElem}, y::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(z) return z end @@ -1412,8 +1307,7 @@ function add!(z::CalciumFieldElem, x::CalciumFieldElem, y::CalciumFieldElem) error("different parents in in-place operation") end C = z.parent - ccall((:ca_add, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumFieldElem}, Ref{CalciumField}), z, x, y, C) + @ccall libflint.ca_add(z::Ref{CalciumFieldElem}, x::Ref{CalciumFieldElem}, y::Ref{CalciumFieldElem}, C::Ref{CalciumField})::Nothing check_special(z) return z end @@ -1435,38 +1329,32 @@ function (C::CalciumField)(v::CalciumFieldElem) return v end r = C() - ccall((:ca_transfer, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{CalciumField}, Ref{CalciumFieldElem}, Ref{CalciumField}), - r, C, v, D) + @ccall libflint.ca_transfer(r::Ref{CalciumFieldElem}, C::Ref{CalciumField}, v::Ref{CalciumFieldElem}, D::Ref{CalciumField})::Nothing check_special(r) return r end function (C::CalciumField)(v::Int) z = CalciumFieldElem(C) - ccall((:ca_set_si, libflint), Nothing, - (Ref{CalciumFieldElem}, Int, Ref{CalciumField}), z, v, C) + @ccall libflint.ca_set_si(z::Ref{CalciumFieldElem}, v::Int, C::Ref{CalciumField})::Nothing return z end function (C::CalciumField)(v::ZZRingElem) z = CalciumFieldElem(C) - ccall((:ca_set_fmpz, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{ZZRingElem}, Ref{CalciumField}), z, v, C) + @ccall libflint.ca_set_fmpz(z::Ref{CalciumFieldElem}, v::Ref{ZZRingElem}, C::Ref{CalciumField})::Nothing return z end function (C::CalciumField)(v::QQFieldElem) z = CalciumFieldElem(C) - ccall((:ca_set_fmpq, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{QQFieldElem}, Ref{CalciumField}), z, v, C) + @ccall libflint.ca_set_fmpq(z::Ref{CalciumFieldElem}, v::Ref{QQFieldElem}, C::Ref{CalciumField})::Nothing return z end function (C::CalciumField)(v::QQBarFieldElem) z = CalciumFieldElem(C) - ccall((:ca_set_qqbar, libflint), Nothing, - (Ref{CalciumFieldElem}, Ref{QQBarFieldElem}, Ref{CalciumField}), z, v, C) + @ccall libflint.ca_set_qqbar(z::Ref{CalciumFieldElem}, v::Ref{QQBarFieldElem}, C::Ref{CalciumField})::Nothing return z end diff --git a/src/calcium/qqbar.jl b/src/calcium/qqbar.jl index eba280ce0..14e28eab5 100644 --- a/src/calcium/qqbar.jl +++ b/src/calcium/qqbar.jl @@ -44,7 +44,7 @@ end function QQBarFieldElem(a::Int) z = QQBarFieldElem() - ccall((:qqbar_set_si, libflint), Nothing, (Ref{QQBarFieldElem}, Int, ), z, a) + @ccall libflint.qqbar_set_si(z::Ref{QQBarFieldElem}, a::Int)::Nothing return z end @@ -52,22 +52,19 @@ function QQBarFieldElem(a::Complex) r = QQBarFieldElem(real(a)) s = QQBarFieldElem(imag(a)) z = QQBarFieldElem() - ccall((:qqbar_set_re_im, libflint), - Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, r, s) + @ccall libflint.qqbar_set_re_im(z::Ref{QQBarFieldElem}, r::Ref{QQBarFieldElem}, s::Ref{QQBarFieldElem})::Nothing return z end function QQBarFieldElem(a::ZZRingElem) z = QQBarFieldElem() - ccall((:qqbar_set_fmpz, libflint), - Nothing, (Ref{QQBarFieldElem}, Ref{ZZRingElem}, ), z, a) + @ccall libflint.qqbar_set_fmpz(z::Ref{QQBarFieldElem}, a::Ref{ZZRingElem})::Nothing return z end function QQBarFieldElem(a::QQFieldElem) z = QQBarFieldElem() - ccall((:qqbar_set_fmpq, libflint), - Nothing, (Ref{QQBarFieldElem}, Ref{QQFieldElem}, ), z, a) + @ccall libflint.qqbar_set_fmpq(z::Ref{QQBarFieldElem}, a::Ref{QQFieldElem})::Nothing return z end @@ -77,7 +74,7 @@ QQBarFieldElem(a::Integer) = QQBarFieldElem(ZZRingElem(a)) function deepcopy_internal(a::QQBarFieldElem, dict::IdDict) z = QQBarFieldElem() - ccall((:qqbar_set, libflint), Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a) + @ccall libflint.qqbar_set(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem})::Nothing return z end @@ -101,22 +98,20 @@ canonical_unit(a::QQBarFieldElem) = a #= function qqbar_vec(n::Int) -return ccall((:_qqbar_vec_init, libflint), Ptr{qqbar_struct}, (Int,), n) +return @ccall libflint._qqbar_vec_init(n::Int)::Ptr{qqbar_struct} end function array(R::QQBarField, v::Ptr{qqbar_struct}, n::Int) r = Vector{QQBarFieldElem}(undef, n) for i=1:n r[i] = R() -ccall((:qqbar_set, libflint), Nothing, (Ref{QQBarFieldElem}, Ptr{qqbar_struct}), -r[i], v + (i-1)*sizeof(qqbar_struct)) +@ccall libflint.qqbar_set(r[i]::Ref{QQBarFieldElem}, (v + (i-1)*sizeof(qqbar_struct))::Ptr{qqbar_struct})::Nothing end return r end function qqbar_vec_clear(v::Ptr{qqbar_struct}, n::Int) -ccall((:_qqbar_vec_clear, libflint), -Nothing, (Ptr{qqbar_struct}, Int), v, n) +@ccall libflint._qqbar_vec_clear(v::Ptr{qqbar_struct}, n::Int)::Nothing end function roots(R::QQBarField, f::ZZPolyRingElem) @@ -125,8 +120,7 @@ if deg <= 0 return QQBarFieldElem[] end roots = qqbar_vec(deg) -ccall((:qqbar_roots_fmpz_poly, libflint), -Nothing, (Ptr{qqbar_struct}, Ref{ZZPolyRingElem}, Int), roots, f, 0) +@ccall libflint.qqbar_roots_fmpz_poly(roots::Ptr{qqbar_struct}, f::Ref{ZZPolyRingElem}, 0::Int)::Nothing res = array(R, roots, deg) qqbar_vec_clear(roots, deg) return res @@ -134,10 +128,9 @@ end =# function native_string(x::QQBarFieldElem) - cstr = ccall((:qqbar_get_str_nd, libflint), - Ptr{UInt8}, (Ref{QQBarFieldElem}, Int), x, Int(6)) + cstr = @ccall libflint.qqbar_get_str_nd(x::Ref{QQBarFieldElem}, Int(6)::Int)::Ptr{UInt8} number = unsafe_string(cstr) - ccall((:flint_free, libflint), Nothing, (Ptr{UInt8},), cstr) + @ccall libflint.flint_free(cstr::Ptr{UInt8})::Nothing number = number[1:first(findfirst(" (", number)::UnitRange)-1] number = replace(number, "I" => "im") @@ -186,7 +179,7 @@ one(::Type{QQBarFieldElem}) = QQBarFieldElem(1) Return the degree of the minimal polynomial of `x`. """ function degree(x::QQBarFieldElem) - return ccall((:qqbar_degree, libflint), Int, (Ref{QQBarFieldElem}, ), x) + return @ccall libflint.qqbar_degree(x::Ref{QQBarFieldElem})::Int end @doc raw""" @@ -195,7 +188,7 @@ end Return whether `x` is the number 0. """ function iszero(x::QQBarFieldElem) - return Bool(ccall((:qqbar_is_zero, libflint), Cint, (Ref{QQBarFieldElem},), x)) + return Bool(@ccall libflint.qqbar_is_zero(x::Ref{QQBarFieldElem})::Cint) end @doc raw""" @@ -204,7 +197,7 @@ end Return whether `x` is the number 1. """ function isone(x::QQBarFieldElem) - return Bool(ccall((:qqbar_is_one, libflint), Cint, (Ref{QQBarFieldElem},), x)) + return Bool(@ccall libflint.qqbar_is_one(x::Ref{QQBarFieldElem})::Cint) end @doc raw""" @@ -213,7 +206,7 @@ end Return whether `x` is an integer. """ function isinteger(x::QQBarFieldElem) - return Bool(ccall((:qqbar_is_integer, libflint), Cint, (Ref{QQBarFieldElem},), x)) + return Bool(@ccall libflint.qqbar_is_integer(x::Ref{QQBarFieldElem})::Cint) end @doc raw""" @@ -222,7 +215,7 @@ end Return whether `x` is a rational number. """ function is_rational(x::QQBarFieldElem) - return Bool(ccall((:qqbar_is_rational, libflint), Cint, (Ref{QQBarFieldElem},), x)) + return Bool(@ccall libflint.qqbar_is_rational(x::Ref{QQBarFieldElem})::Cint) end @doc raw""" @@ -231,7 +224,7 @@ end Return whether `x` is a real number. """ function isreal(x::QQBarFieldElem) - return Bool(ccall((:qqbar_is_real, libflint), Cint, (Ref{QQBarFieldElem},), x)) + return Bool(@ccall libflint.qqbar_is_real(x::Ref{QQBarFieldElem})::Cint) end @doc raw""" @@ -240,8 +233,7 @@ end Return whether `x` is an algebraic integer. """ function is_algebraic_integer(x::QQBarFieldElem) - return Bool(ccall((:qqbar_is_algebraic_integer, libflint), - Cint, (Ref{QQBarFieldElem},), x)) + return Bool(@ccall libflint.qqbar_is_algebraic_integer(x::Ref{QQBarFieldElem})::Cint) end @doc raw""" @@ -251,8 +243,7 @@ Return the minimal polynomial of `x` as an element of the polynomial ring `R`. """ function minpoly(R::ZZPolyRing, x::QQBarFieldElem) z = R() - ccall((:fmpz_poly_set, libflint), - Nothing, (Ref{ZZPolyRingElem}, Ref{QQBarFieldElem}, ), z, x) + @ccall libflint.fmpz_poly_set(z::Ref{ZZPolyRingElem}, x::Ref{QQBarFieldElem})::Nothing return z end @@ -263,8 +254,7 @@ Return the minimal polynomial of `x` as an element of the polynomial ring `R`. """ function minpoly(R::QQPolyRing, x::QQBarFieldElem) z = R() - ccall((:fmpq_poly_set_fmpz_poly, libflint), - Nothing, (Ref{QQPolyRingElem}, Ref{QQBarFieldElem}, ), z, x) + @ccall libflint.fmpq_poly_set_fmpz_poly(z::Ref{QQPolyRingElem}, x::Ref{QQBarFieldElem})::Nothing return z end @@ -277,8 +267,7 @@ minimal polynomial of `x`. The result is returned as an `ZZRingElem`. function denominator(x::QQBarFieldElem) d = degree(x) q = ZZRingElem() - ccall((:fmpz_poly_get_coeff_fmpz, libflint), - Nothing, (Ref{ZZRingElem}, Ref{QQBarFieldElem}, Int), q, x, d) + @ccall libflint.fmpz_poly_get_coeff_fmpz(q::Ref{ZZRingElem}, x::Ref{QQBarFieldElem}, d::Int)::Nothing return q end @@ -299,7 +288,7 @@ Return the height of the algebraic number `x`. The result is an `ZZRingElem` int """ function height(x::QQBarFieldElem) z = ZZRingElem() - ccall((:qqbar_height, libflint), Nothing, (Ref{ZZRingElem}, Ref{QQBarFieldElem}, ), z, x) + @ccall libflint.qqbar_height(z::Ref{ZZRingElem}, x::Ref{QQBarFieldElem})::Nothing return z end @@ -310,7 +299,7 @@ Return the height of the algebraic number `x` measured in bits. The result is a Julia integer. """ function height_bits(x::QQBarFieldElem) - return ccall((:qqbar_height_bits, libflint), Int, (Ref{QQBarFieldElem}, ), x) + return @ccall libflint.qqbar_height_bits(x::Ref{QQBarFieldElem})::Int end @@ -338,15 +327,12 @@ function rand(R::QQBarField; degree::Int, bits::Int, bits <= 0 && error("bits must be positive") if randtype == :null - ccall((:qqbar_randtest, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{rand_ctx}, Int, Int), x, state, degree, bits) + @ccall libflint.qqbar_randtest(x::Ref{QQBarFieldElem}, state::Ref{rand_ctx}, degree::Int, bits::Int)::Nothing elseif randtype == :real - ccall((:qqbar_randtest_real, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{rand_ctx}, Int, Int), x, state, degree, bits) + @ccall libflint.qqbar_randtest_real(x::Ref{QQBarFieldElem}, state::Ref{rand_ctx}, degree::Int, bits::Int)::Nothing elseif randtype == :nonreal degree < 2 && error("nonreal requires degree >= 2") - ccall((:qqbar_randtest_nonreal, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{rand_ctx}, Int, Int), x, state, degree, bits) + @ccall libflint.qqbar_randtest_nonreal(x::Ref{QQBarFieldElem}, state::Ref{rand_ctx}, degree::Int, bits::Int)::Nothing else error("randtype not defined") end @@ -370,29 +356,25 @@ end function +(a::QQBarFieldElem, b::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_add, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a, b) + @ccall libflint.qqbar_add(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Nothing return z end function +(a::QQBarFieldElem, b::QQFieldElem) z = QQBarFieldElem() - ccall((:qqbar_add_fmpq, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{QQFieldElem}), z, a, b) + @ccall libflint.qqbar_add_fmpq(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{QQFieldElem})::Nothing return z end function +(a::QQBarFieldElem, b::ZZRingElem) z = QQBarFieldElem() - ccall((:qqbar_add_fmpz, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{ZZRingElem}), z, a, b) + @ccall libflint.qqbar_add_fmpz(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{ZZRingElem})::Nothing return z end function +(a::QQBarFieldElem, b::Int) z = QQBarFieldElem() - ccall((:qqbar_add_si, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Int), z, a, b) + @ccall libflint.qqbar_add_si(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Int)::Nothing return z end @@ -402,78 +384,67 @@ end function -(a::QQBarFieldElem, b::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_sub, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a, b) + @ccall libflint.qqbar_sub(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Nothing return z end function -(a::QQBarFieldElem, b::QQFieldElem) z = QQBarFieldElem() - ccall((:qqbar_sub_fmpq, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{QQFieldElem}), z, a, b) + @ccall libflint.qqbar_sub_fmpq(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{QQFieldElem})::Nothing return z end function -(a::QQBarFieldElem, b::ZZRingElem) z = QQBarFieldElem() - ccall((:qqbar_sub_fmpz, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{ZZRingElem}), z, a, b) + @ccall libflint.qqbar_sub_fmpz(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{ZZRingElem})::Nothing return z end function -(a::QQBarFieldElem, b::Int) z = QQBarFieldElem() - ccall((:qqbar_sub_si, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Int), z, a, b) + @ccall libflint.qqbar_sub_si(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Int)::Nothing return z end function -(a::QQFieldElem, b::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_fmpq_sub, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQFieldElem}, Ref{QQBarFieldElem}), z, a, b) + @ccall libflint.qqbar_fmpq_sub(z::Ref{QQBarFieldElem}, a::Ref{QQFieldElem}, b::Ref{QQBarFieldElem})::Nothing return z end function -(a::ZZRingElem, b::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_fmpz_sub, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{ZZRingElem}, Ref{QQBarFieldElem}), z, a, b) + @ccall libflint.qqbar_fmpz_sub(z::Ref{QQBarFieldElem}, a::Ref{ZZRingElem}, b::Ref{QQBarFieldElem})::Nothing return z end function -(a::Int, b::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_si_sub, libflint), Nothing, - (Ref{QQBarFieldElem}, Int, Ref{QQBarFieldElem}), z, a, b) + @ccall libflint.qqbar_si_sub(z::Ref{QQBarFieldElem}, a::Int, b::Ref{QQBarFieldElem})::Nothing return z end function *(a::QQBarFieldElem, b::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_mul, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a, b) + @ccall libflint.qqbar_mul(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Nothing return z end function *(a::QQBarFieldElem, b::QQFieldElem) z = QQBarFieldElem() - ccall((:qqbar_mul_fmpq, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{QQFieldElem}), z, a, b) + @ccall libflint.qqbar_mul_fmpq(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{QQFieldElem})::Nothing return z end function *(a::QQBarFieldElem, b::ZZRingElem) z = QQBarFieldElem() - ccall((:qqbar_mul_fmpz, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{ZZRingElem}), z, a, b) + @ccall libflint.qqbar_mul_fmpz(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{ZZRingElem})::Nothing return z end function *(a::QQBarFieldElem, b::Int) z = QQBarFieldElem() - ccall((:qqbar_mul_si, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Int), z, a, b) + @ccall libflint.qqbar_mul_si(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Int)::Nothing return z end @@ -483,8 +454,7 @@ end function ^(a::QQBarFieldElem, b::QQBarFieldElem) z = QQBarFieldElem() - ok = Bool(ccall((:qqbar_pow, libflint), Cint, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a, b)) + ok = Bool(@ccall libflint.qqbar_pow(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Cint) !ok && throw(DomainError((a, b))) return z end @@ -506,63 +476,56 @@ end function inv(a::QQBarFieldElem) iszero(a) && throw(DivideError()) z = QQBarFieldElem() - ccall((:qqbar_inv, libflint), Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a) + @ccall libflint.qqbar_inv(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem})::Nothing return z end function divexact(a::QQBarFieldElem, b::QQBarFieldElem; check::Bool=true) iszero(b) && throw(DivideError()) z = QQBarFieldElem() - ccall((:qqbar_div, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a, b) + @ccall libflint.qqbar_div(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Nothing return z end function divexact(a::QQBarFieldElem, b::QQFieldElem; check::Bool=true) iszero(b) && throw(DivideError()) z = QQBarFieldElem() - ccall((:qqbar_div_fmpq, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{QQFieldElem}), z, a, b) + @ccall libflint.qqbar_div_fmpq(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{QQFieldElem})::Nothing return z end function divexact(a::QQBarFieldElem, b::ZZRingElem; check::Bool=true) iszero(b) && throw(DivideError()) z = QQBarFieldElem() - ccall((:qqbar_div_fmpz, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{ZZRingElem}), z, a, b) + @ccall libflint.qqbar_div_fmpz(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Ref{ZZRingElem})::Nothing return z end function divexact(a::QQBarFieldElem, b::Int; check::Bool=true) iszero(b) && throw(DivideError()) z = QQBarFieldElem() - ccall((:qqbar_div_si, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Int), z, a, b) + @ccall libflint.qqbar_div_si(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Int)::Nothing return z end function divexact(a::QQFieldElem, b::QQBarFieldElem; check::Bool=true) iszero(b) && throw(DivideError()) z = QQBarFieldElem() - ccall((:qqbar_fmpq_div, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQFieldElem}, Ref{QQBarFieldElem}), z, a, b) + @ccall libflint.qqbar_fmpq_div(z::Ref{QQBarFieldElem}, a::Ref{QQFieldElem}, b::Ref{QQBarFieldElem})::Nothing return z end function divexact(a::ZZRingElem, b::QQBarFieldElem; check::Bool=true) iszero(b) && throw(DivideError()) z = QQBarFieldElem() - ccall((:qqbar_fmpz_div, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{ZZRingElem}, Ref{QQBarFieldElem}), z, a, b) + @ccall libflint.qqbar_fmpz_div(z::Ref{QQBarFieldElem}, a::Ref{ZZRingElem}, b::Ref{QQBarFieldElem})::Nothing return z end function divexact(a::Int, b::QQBarFieldElem; check::Bool=true) iszero(b) && throw(DivideError()) z = QQBarFieldElem() - ccall((:qqbar_si_div, libflint), Nothing, - (Ref{QQBarFieldElem}, Int, Ref{QQBarFieldElem}), z, a, b) + @ccall libflint.qqbar_si_div(z::Ref{QQBarFieldElem}, a::Int, b::Ref{QQBarFieldElem})::Nothing return z end @@ -577,15 +540,13 @@ end function <<(a::QQBarFieldElem, b::Int) z = QQBarFieldElem() - ccall((:qqbar_mul_2exp_si, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Int), z, a, b) + @ccall libflint.qqbar_mul_2exp_si(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, b::Int)::Nothing return z end function >>(a::QQBarFieldElem, b::Int) z = QQBarFieldElem() - ccall((:qqbar_mul_2exp_si, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Int), z, a, -b) + @ccall libflint.qqbar_mul_2exp_si(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, (-b)::Int)::Nothing return z end @@ -597,15 +558,13 @@ end function evaluate(x::QQPolyRingElem, y::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_evaluate_fmpq_poly, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQPolyRingElem}, Ref{QQBarFieldElem}), z, x, y) + @ccall libflint.qqbar_evaluate_fmpq_poly(z::Ref{QQBarFieldElem}, x::Ref{QQPolyRingElem}, y::Ref{QQBarFieldElem})::Nothing return z end function evaluate(x::ZZPolyRingElem, y::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_evaluate_fmpz_poly, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{ZZPolyRingElem}, Ref{QQBarFieldElem}), z, x, y) + @ccall libflint.qqbar_evaluate_fmpz_poly(z::Ref{QQBarFieldElem}, x::Ref{ZZPolyRingElem}, y::Ref{QQBarFieldElem})::Nothing return z end @@ -616,15 +575,13 @@ end ############################################################################### function ==(a::QQBarFieldElem, b::QQBarFieldElem) - return Bool(ccall((:qqbar_equal, libflint), Cint, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), a, b)) + return Bool(@ccall libflint.qqbar_equal(a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Cint) end function cmp(a::QQBarFieldElem, b::QQBarFieldElem) !isreal(a) && throw(DomainError(a, "comparing nonreal numbers")) !isreal(b) && throw(DomainError(b, "comparing nonreal numbers")) - return ccall((:qqbar_cmp_re, libflint), Cint, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), a, b) + return @ccall libflint.qqbar_cmp_re(a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Cint end isless(a::QQBarFieldElem, b::QQBarFieldElem) = cmp(a, b) < 0 @@ -639,18 +596,12 @@ is_positive(a::QQBarFieldElem) = a > 0 is_negative(a::QQBarFieldElem) = a < 0 # todo: export the cmp functions? -cmp_real(a::QQBarFieldElem, b::QQBarFieldElem) = ccall((:qqbar_cmp_re, libflint), - Cint, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), a, b) -cmp_imag(a::QQBarFieldElem, b::QQBarFieldElem) = ccall((:qqbar_cmp_im, libflint), - Cint, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), a, b) -cmpabs(a::QQBarFieldElem, b::QQBarFieldElem) = ccall((:qqbar_cmpabs, libflint), - Cint, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), a, b) -cmpabs_real(a::QQBarFieldElem, b::QQBarFieldElem) = ccall((:qqbar_cmpabs_re, libflint), - Cint, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), a, b) -cmpabs_imag(a::QQBarFieldElem, b::QQBarFieldElem) = ccall((:qqbar_cmpabs_im, libflint), - Cint, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), a, b) -cmp_root_order(a::QQBarFieldElem, b::QQBarFieldElem) = ccall((:qqbar_cmp_root_order, libflint), - Cint, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), a, b) +cmp_real(a::QQBarFieldElem, b::QQBarFieldElem) = @ccall libflint.qqbar_cmp_re(a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Cint +cmp_imag(a::QQBarFieldElem, b::QQBarFieldElem) = @ccall libflint.qqbar_cmp_im(a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Cint +cmpabs(a::QQBarFieldElem, b::QQBarFieldElem) = @ccall libflint.qqbar_cmpabs(a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Cint +cmpabs_real(a::QQBarFieldElem, b::QQBarFieldElem) = @ccall libflint.qqbar_cmpabs_re(a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Cint +cmpabs_imag(a::QQBarFieldElem, b::QQBarFieldElem) = @ccall libflint.qqbar_cmpabs_im(a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Cint +cmp_root_order(a::QQBarFieldElem, b::QQBarFieldElem) = @ccall libflint.qqbar_cmp_root_order(a::Ref{QQBarFieldElem}, b::Ref{QQBarFieldElem})::Cint @doc raw""" is_equal_real(a::QQBarFieldElem, b::QQBarFieldElem) @@ -746,7 +697,7 @@ Return the real part of `a`. """ function real(a::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_re, libflint), Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a) + @ccall libflint.qqbar_re(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem})::Nothing return z end @@ -757,7 +708,7 @@ Return the imaginary part of `a`. """ function imag(a::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_im, libflint), Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a) + @ccall libflint.qqbar_im(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem})::Nothing return z end @@ -768,7 +719,7 @@ Return the absolute value of `a`. """ function abs(a::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_abs, libflint), Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a) + @ccall libflint.qqbar_abs(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem})::Nothing return z end @@ -779,7 +730,7 @@ Return the complex conjugate of `a`. """ function conj(a::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_conj, libflint), Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a) + @ccall libflint.qqbar_conj(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem})::Nothing return z end @@ -790,7 +741,7 @@ Return the squared absolute value of `a`. """ function abs2(a::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_abs2, libflint), Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a) + @ccall libflint.qqbar_abs2(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem})::Nothing return z end @@ -802,7 +753,7 @@ and as $a / |a|$ otherwise. """ function sign(a::QQBarFieldElem) z = QQBarFieldElem() - ccall((:qqbar_sgn, libflint), Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a) + @ccall libflint.qqbar_sgn(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem})::Nothing return z end @@ -845,7 +796,7 @@ end function floor(::Type{ZZRingElem}, a::QQBarFieldElem) z = ZZRingElem() - ccall((:qqbar_floor, libflint), Nothing, (Ref{ZZRingElem}, Ref{QQBarFieldElem}, ), z, a) + @ccall libflint.qqbar_floor(z::Ref{ZZRingElem}, a::Ref{QQBarFieldElem})::Nothing return z end @@ -855,7 +806,7 @@ end function ceil(::Type{ZZRingElem}, a::QQBarFieldElem) z = ZZRingElem() - ccall((:qqbar_ceil, libflint), Nothing, (Ref{ZZRingElem}, Ref{QQBarFieldElem}, ), z, a) + @ccall libflint.qqbar_ceil(z::Ref{ZZRingElem}, a::Ref{QQBarFieldElem})::Nothing return z end @@ -914,8 +865,7 @@ Return the principal square root of `a`. """ function sqrt(a::QQBarFieldElem; check::Bool=true) z = QQBarFieldElem() - ccall((:qqbar_sqrt, libflint), - Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a) + @ccall libflint.qqbar_sqrt(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem})::Nothing return z end @@ -927,28 +877,25 @@ Return the principal `n`-th root of `a`. Requires positive `n`. function root(a::QQBarFieldElem, n::Int) n <= 0 && throw(DomainError(n)) z = QQBarFieldElem() - ccall((:qqbar_root_ui, libflint), - Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, UInt), z, a, n) + @ccall libflint.qqbar_root_ui(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem}, n::UInt)::Nothing return z end function qqbar_vec(n::Int) - return ccall((:_qqbar_vec_init, libflint), Ptr{qqbar_struct}, (Int,), n) + return @ccall libflint._qqbar_vec_init(n::Int)::Ptr{qqbar_struct} end function array(R::QQBarField, v::Ptr{qqbar_struct}, n::Int) r = Vector{QQBarFieldElem}(undef, n) for i=1:n r[i] = R() - ccall((:qqbar_set, libflint), Nothing, (Ref{QQBarFieldElem}, Ptr{qqbar_struct}), - r[i], v + (i-1)*sizeof(qqbar_struct)) + @ccall libflint.qqbar_set(r[i]::Ref{QQBarFieldElem}, (v + (i-1)*sizeof(qqbar_struct))::Ptr{qqbar_struct})::Nothing end return r end function qqbar_vec_clear(v::Ptr{qqbar_struct}, n::Int) - ccall((:_qqbar_vec_clear, libflint), - Nothing, (Ptr{qqbar_struct}, Int), v, n) + @ccall libflint._qqbar_vec_clear(v::Ptr{qqbar_struct}, n::Int)::Nothing end @doc raw""" @@ -965,8 +912,7 @@ function roots(R::QQBarField, f::ZZPolyRingElem) return QQBarFieldElem[] end roots = qqbar_vec(deg) - ccall((:qqbar_roots_fmpz_poly, libflint), - Nothing, (Ptr{qqbar_struct}, Ref{ZZPolyRingElem}, Int), roots, f, 0) + @ccall libflint.qqbar_roots_fmpz_poly(roots::Ptr{qqbar_struct}, f::Ref{ZZPolyRingElem}, 0::Int)::Nothing res = array(R, roots, deg) qqbar_vec_clear(roots, deg) return res @@ -986,8 +932,7 @@ function roots(R::QQBarField, f::QQPolyRingElem) return QQBarFieldElem[] end roots = qqbar_vec(deg) - ccall((:qqbar_roots_fmpq_poly, libflint), - Nothing, (Ptr{qqbar_struct}, Ref{QQPolyRingElem}, Int), roots, f, 0) + @ccall libflint.qqbar_roots_fmpq_poly(roots::Ptr{qqbar_struct}, f::Ref{QQPolyRingElem}, 0::Int)::Nothing res = array(R, roots, deg) qqbar_vec_clear(roots, deg) return res @@ -1006,8 +951,7 @@ function conjugates(a::QQBarFieldElem) return [a] end conjugates = qqbar_vec(deg) - ccall((:qqbar_conjugates, libflint), - Nothing, (Ptr{qqbar_struct}, Ref{QQBarFieldElem}), conjugates, a) + @ccall libflint.qqbar_conjugates(conjugates::Ptr{qqbar_struct}, a::Ref{QQBarFieldElem})::Nothing res = array(parent(a), conjugates, deg) qqbar_vec_clear(conjugates, deg) return res @@ -1021,8 +965,7 @@ function _eigvals_internal(R::QQBarField, A::ZZMatrix) return QQBarFieldElem[] end roots = qqbar_vec(n) - ccall((:qqbar_eigenvalues_fmpz_mat, libflint), - Nothing, (Ptr{qqbar_struct}, Ref{ZZMatrix}, Int), roots, A, 0) + @ccall libflint.qqbar_eigenvalues_fmpz_mat(roots::Ptr{qqbar_struct}, A::Ref{ZZMatrix}, 0::Int)::Nothing res = array(R, roots, n) qqbar_vec_clear(roots, n) return res @@ -1036,8 +979,7 @@ function _eigvals_internal(R::QQBarField, A::QQMatrix) return QQBarFieldElem[] end roots = qqbar_vec(n) - ccall((:qqbar_eigenvalues_fmpq_mat, libflint), - Nothing, (Ptr{qqbar_struct}, Ref{QQMatrix}, Int), roots, A, 0) + @ccall libflint.qqbar_eigenvalues_fmpq_mat(roots::Ptr{qqbar_struct}, A::Ref{QQMatrix}, 0::Int)::Nothing res = array(R, roots, n) qqbar_vec_clear(roots, n) return res @@ -1099,8 +1041,7 @@ of algebraic numbers `C`. function root_of_unity(C::QQBarField, n::Int) n <= 0 && throw(DomainError(n)) z = QQBarFieldElem() - ccall((:qqbar_root_of_unity, libflint), - Nothing, (Ref{QQBarFieldElem}, Int, UInt), z, 1, n) + @ccall libflint.qqbar_root_of_unity(z::Ref{QQBarFieldElem}, 1::Int, n::UInt)::Nothing return z end @@ -1113,8 +1054,7 @@ of algebraic numbers `C`. function root_of_unity(C::QQBarField, n::Int, k::Int) n <= 0 && throw(DomainError(n)) z = QQBarFieldElem() - ccall((:qqbar_root_of_unity, libflint), - Nothing, (Ref{QQBarFieldElem}, Int, UInt), z, k, n) + @ccall libflint.qqbar_root_of_unity(z::Ref{QQBarFieldElem}, k::Int, n::UInt)::Nothing return z end @@ -1124,8 +1064,7 @@ end Return whether the given algebraic number is a root of unity. """ function is_root_of_unity(a::QQBarFieldElem) - return Bool(ccall((:qqbar_is_root_of_unity, libflint), - Cint, (Ptr{Int}, Ptr{Int}, Ref{QQBarFieldElem}), C_NULL, C_NULL, a)) + return Bool(@ccall libflint.qqbar_is_root_of_unity(C_NULL::Ptr{Int}, C_NULL::Ptr{Int}, a::Ref{QQBarFieldElem})::Cint) end @doc raw""" @@ -1138,8 +1077,7 @@ $0 \le p < q$. Throws if `a` is not a root of unity. function root_of_unity_as_args(a::QQBarFieldElem) p = Vector{Int}(undef, 1) q = Vector{Int}(undef, 1) - if !Bool(ccall((:qqbar_is_root_of_unity, libflint), - Cint, (Ptr{Int}, Ptr{Int}, Ref{QQBarFieldElem}), p, q, a)) + if !Bool(@ccall libflint.qqbar_is_root_of_unity(p::Ptr{Int}, q::Ptr{Int}, a::Ref{QQBarFieldElem})::Cint) throw(DomainError(a, "value is not a root of unity")) end return (q[1], p[1]) @@ -1156,8 +1094,7 @@ function exp_pi_i(a::QQBarFieldElem) p = Int(numerator(r)) q = Int(denominator(r)) z = QQBarFieldElem() - ccall((:qqbar_exp_pi_i, libflint), - Nothing, (Ref{QQBarFieldElem}, Int, Int), z, p, q) + @ccall libflint.qqbar_exp_pi_i(z::Ref{QQBarFieldElem}, p::Int, q::Int)::Nothing return z end @@ -1185,7 +1122,7 @@ function sinpi(a::QQBarFieldElem) p = Int(numerator(r)) q = Int(denominator(r)) z = QQBarFieldElem() - ccall((:qqbar_sin_pi, libflint), Nothing, (Ref{QQBarFieldElem}, Int, Int), z, p, q) + @ccall libflint.qqbar_sin_pi(z::Ref{QQBarFieldElem}, p::Int, q::Int)::Nothing return z end @@ -1213,7 +1150,7 @@ function cospi(a::QQBarFieldElem) p = Int(numerator(r)) q = Int(denominator(r)) z = QQBarFieldElem() - ccall((:qqbar_cos_pi, libflint), Nothing, (Ref{QQBarFieldElem}, Int, Int), z, p, q) + @ccall libflint.qqbar_cos_pi(z::Ref{QQBarFieldElem}, p::Int, q::Int)::Nothing return z end @@ -1241,9 +1178,9 @@ function sincospi(a::QQBarFieldElem) p = Int(numerator(r)) q = Int(denominator(r)) s = QQBarFieldElem() - ccall((:qqbar_sin_pi, libflint), Nothing, (Ref{QQBarFieldElem}, Int, Int), s, p, q) + @ccall libflint.qqbar_sin_pi(s::Ref{QQBarFieldElem}, p::Int, q::Int)::Nothing c = QQBarFieldElem() - ccall((:qqbar_cos_pi, libflint), Nothing, (Ref{QQBarFieldElem}, Int, Int), c, p, q) + @ccall libflint.qqbar_cos_pi(c::Ref{QQBarFieldElem}, p::Int, q::Int)::Nothing return s, c end @@ -1259,8 +1196,7 @@ function tanpi(a::QQBarFieldElem) p = Int(numerator(r)) q = Int(denominator(r)) z = QQBarFieldElem() - if !Bool(ccall((:qqbar_tan_pi, libflint), - Cint, (Ref{QQBarFieldElem}, Int, Int), z, p, q)) + if !Bool(@ccall libflint.qqbar_tan_pi(z::Ref{QQBarFieldElem}, p::Int, q::Int)::Cint) throw(DomainError(a, "function value is not algebraic")) end return z @@ -1275,8 +1211,7 @@ Throws if this value is transcendental or undefined. function atanpi(a::QQBarFieldElem) p = Vector{Int}(undef, 1) q = Vector{Int}(undef, 1) - if !Bool(ccall((:qqbar_atan_pi, libflint), - Cint, (Ptr{Int}, Ptr{Int}, Ref{QQBarFieldElem}), p, q, a)) + if !Bool(@ccall libflint.qqbar_atan_pi(p::Ptr{Int}, q::Ptr{Int}, a::Ref{QQBarFieldElem})::Cint) throw(DomainError(a, "function value is not algebraic")) end return QQBarFieldElem(p[1]) // q[1] @@ -1291,8 +1226,7 @@ Throws if this value is transcendental. function asinpi(a::QQBarFieldElem) p = Vector{Int}(undef, 1) q = Vector{Int}(undef, 1) - if !Bool(ccall((:qqbar_asin_pi, libflint), - Cint, (Ptr{Int}, Ptr{Int}, Ref{QQBarFieldElem}), p, q, a)) + if !Bool(@ccall libflint.qqbar_asin_pi(p::Ptr{Int}, q::Ptr{Int}, a::Ref{QQBarFieldElem})::Cint) throw(DomainError(a, "function value is not algebraic")) end return QQBarFieldElem(p[1]) // q[1] @@ -1307,8 +1241,7 @@ Throws if this value is transcendental. function acospi(a::QQBarFieldElem) p = Vector{Int}(undef, 1) q = Vector{Int}(undef, 1) - if !Bool(ccall((:qqbar_acos_pi, libflint), - Cint, (Ptr{Int}, Ptr{Int}, Ref{QQBarFieldElem}), p, q, a)) + if !Bool(@ccall libflint.qqbar_acos_pi(p::Ptr{Int}, q::Ptr{Int}, a::Ref{QQBarFieldElem})::Cint) throw(DomainError(a, "function value is not algebraic")) end return QQBarFieldElem(p[1]) // q[1] @@ -1323,8 +1256,7 @@ Throws if this value is transcendental or undefined. function log_pi_i(a::QQBarFieldElem) p = Vector{Int}(undef, 1) q = Vector{Int}(undef, 1) - if !Bool(ccall((:qqbar_log_pi_i, libflint), - Cint, (Ptr{Int}, Ptr{Int}, Ref{QQBarFieldElem}), p, q, a)) + if !Bool(@ccall libflint.qqbar_log_pi_i(p::Ptr{Int}, q::Ptr{Int}, a::Ref{QQBarFieldElem})::Cint) throw(DomainError(a, "function value is not algebraic")) end return QQBarFieldElem(p[1]) // q[1] @@ -1369,9 +1301,7 @@ function guess(R::QQBarField, x::T, maxdeg::Int, maxbits::Int=0) where {T <: Uni maxbits = prec end res = QQBarFieldElem() - found = Bool(ccall((:qqbar_guess, libflint), - Cint, (Ref{QQBarFieldElem}, Ref{T}, Int, Int, Int, Int), - res, x, maxdeg, maxbits, 0, prec)) + found = Bool(@ccall libflint.qqbar_guess(res::Ref{QQBarFieldElem}, x::Ref{T}, maxdeg::Int, maxbits::Int, 0::Int, prec::Int)::Cint) if !found error("No suitable algebraic number found") end @@ -1403,8 +1333,7 @@ Throws if `a` is not a real number. function (R::ArbField)(a::QQBarFieldElem) prec = precision(R) z = R() - ccall((:qqbar_get_arb, libflint), - Nothing, (Ref{ArbFieldElem}, Ref{QQBarFieldElem}, Int), z, a, prec) + @ccall libflint.qqbar_get_arb(z::Ref{ArbFieldElem}, a::Ref{QQBarFieldElem}, prec::Int)::Nothing !isfinite(z) && throw(DomainError(a, "nonreal algebraic number")) return z end @@ -1417,8 +1346,7 @@ Convert `a` to a complex ball with the precision of the parent field `R`. function (R::AcbField)(a::QQBarFieldElem) prec = precision(R) z = R() - ccall((:qqbar_get_acb, libflint), - Nothing, (Ref{AcbFieldElem}, Ref{QQBarFieldElem}, Int), z, a, prec) + @ccall libflint.qqbar_get_acb(z::Ref{AcbFieldElem}, a::Ref{QQBarFieldElem}, prec::Int)::Nothing return z end @@ -1431,8 +1359,7 @@ Throws if `a` is not a real number. function (R::RealField)(a::QQBarFieldElem) prec = precision(Balls) z = R() - ccall((:qqbar_get_arb, libflint), - Nothing, (Ref{RealFieldElem}, Ref{QQBarFieldElem}, Int), z, a, prec) + @ccall libflint.qqbar_get_arb(z::Ref{RealFieldElem}, a::Ref{QQBarFieldElem}, prec::Int)::Nothing !isfinite(z) && throw(DomainError(a, "nonreal algebraic number")) return z end @@ -1445,8 +1372,7 @@ Convert `a` to a complex ball with the precision of the parent field `R`. function (R::ComplexField)(a::QQBarFieldElem) prec = precision(Balls) z = R() - ccall((:qqbar_get_acb, libflint), - Nothing, (Ref{ComplexFieldElem}, Ref{QQBarFieldElem}, Int), z, a, prec) + @ccall libflint.qqbar_get_acb(z::Ref{ComplexFieldElem}, a::Ref{QQBarFieldElem}, prec::Int)::Nothing return z end @@ -1494,29 +1420,27 @@ end ############################################################################### function zero!(z::QQBarFieldElem) - ccall((:qqbar_zero, libflint), Nothing, (Ref{QQBarFieldElem},), z) + @ccall libflint.qqbar_zero(z::Ref{QQBarFieldElem})::Nothing return z end function one!(z::QQBarFieldElem) - ccall((:qqbar_one, libflint), Nothing, (Ref{QQBarFieldElem},), z) + @ccall libflint.qqbar_one(z::Ref{QQBarFieldElem})::Nothing return z end function neg!(z::QQBarFieldElem, a::QQBarFieldElem) - ccall((:qqbar_neg, libflint), Nothing, (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, a) + @ccall libflint.qqbar_neg(z::Ref{QQBarFieldElem}, a::Ref{QQBarFieldElem})::Nothing return z end function mul!(z::QQBarFieldElem, x::QQBarFieldElem, y::QQBarFieldElem) - ccall((:qqbar_mul, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, x, y) + @ccall libflint.qqbar_mul(z::Ref{QQBarFieldElem}, x::Ref{QQBarFieldElem}, y::Ref{QQBarFieldElem})::Nothing return z end function add!(z::QQBarFieldElem, x::QQBarFieldElem, y::QQBarFieldElem) - ccall((:qqbar_add, libflint), Nothing, - (Ref{QQBarFieldElem}, Ref{QQBarFieldElem}, Ref{QQBarFieldElem}), z, x, y) + @ccall libflint.qqbar_add(z::Ref{QQBarFieldElem}, x::Ref{QQBarFieldElem}, y::Ref{QQBarFieldElem})::Nothing return z end diff --git a/src/flint/FlintTypes.jl b/src/flint/FlintTypes.jl index e8a86a1dc..4e521954b 100644 --- a/src/flint/FlintTypes.jl +++ b/src/flint/FlintTypes.jl @@ -46,41 +46,41 @@ mutable struct ZZRingElem <: RingElem function ZZRingElem() z = new() - ccall((:fmpz_init, libflint), Nothing, (Ref{ZZRingElem},), z) + @ccall libflint.fmpz_init(z::Ref{ZZRingElem})::Nothing finalizer(_fmpz_clear_fn, z) return z end function ZZRingElem(x::Int) z = new() - ccall((:fmpz_init_set_si, libflint), Nothing, (Ref{ZZRingElem}, Int), z, x) + @ccall libflint.fmpz_init_set_si(z::Ref{ZZRingElem}, x::Int)::Nothing finalizer(_fmpz_clear_fn, z) return z end function ZZRingElem(x::UInt) z = new() - ccall((:fmpz_init_set_ui, libflint), Nothing, (Ref{ZZRingElem}, UInt), z, x) + @ccall libflint.fmpz_init_set_ui(z::Ref{ZZRingElem}, x::UInt)::Nothing finalizer(_fmpz_clear_fn, z) return z end function ZZRingElem(x::BigInt) z = ZZRingElem() - ccall((:fmpz_set_mpz, libflint), Nothing, (Ref{ZZRingElem}, Ref{BigInt}), z, x) + @ccall libflint.fmpz_set_mpz(z::Ref{ZZRingElem}, x::Ref{BigInt})::Nothing return z end function ZZRingElem(x::Ptr{Culong}, len::Clong) z = ZZRingElem() - ccall((:fmpz_set_ui_array, libflint), Nothing, (Ref{ZZRingElem}, Ptr{Culong}, Clong), z, x, len) + @ccall libflint.fmpz_set_ui_array(z::Ref{ZZRingElem}, x::Ptr{Culong}, len::Clong)::Nothing return z end function ZZRingElem(x::Float64) !isinteger(x) && throw(InexactError(:convert, ZZRingElem, x)) z = ZZRingElem() - ccall((:fmpz_set_d, libflint), Nothing, (Ref{ZZRingElem}, Cdouble), z, x) + @ccall libflint.fmpz_set_d(z::Ref{ZZRingElem}, x::Cdouble)::Nothing return z end @@ -88,7 +88,7 @@ mutable struct ZZRingElem <: RingElem end function _fmpz_clear_fn(a::ZZRingElem) - ccall((:fmpz_clear, libflint), Nothing, (Ref{ZZRingElem},), a) + @ccall libflint.fmpz_clear(a::Ref{ZZRingElem})::Nothing end mutable struct fmpz_factor @@ -100,15 +100,14 @@ mutable struct fmpz_factor function fmpz_factor() z = new() - ccall((:fmpz_factor_init, libflint), Nothing, (Ref{fmpz_factor}, ), z) + @ccall libflint.fmpz_factor_init(z::Ref{fmpz_factor})::Nothing finalizer(_fmpz_factor_clear_fn, z) return z end end function _fmpz_factor_clear_fn(a::fmpz_factor) - ccall((:fmpz_factor_clear, libflint), Nothing, - (Ref{fmpz_factor}, ), a) + @ccall libflint.fmpz_factor_clear(a::Ref{fmpz_factor})::Nothing end struct ZZRingElemUnitRange <: AbstractUnitRange{ZZRingElem} @@ -130,7 +129,7 @@ mutable struct n_factor function n_factor() z = new() - ccall((:n_factor_init, libflint), Nothing, (Ref{n_factor}, ), z) + @ccall libflint.n_factor_init(z::Ref{n_factor})::Nothing # no finalizer needed return z end @@ -176,7 +175,7 @@ mutable struct QQFieldElem <: FracElem{ZZRingElem} function QQFieldElem() z = new() - ccall((:fmpq_init, libflint), Nothing, (Ref{QQFieldElem},), z) + @ccall libflint.fmpq_init(z::Ref{QQFieldElem})::Nothing finalizer(_fmpq_clear_fn, z) return z end @@ -220,7 +219,7 @@ mutable struct QQFieldElem <: FracElem{ZZRingElem} QQFieldElem(a::QQFieldElem) = a end -_fmpq_clear_fn(a::QQFieldElem) = ccall((:fmpq_clear, libflint), Nothing, (Ref{QQFieldElem},), a) +_fmpq_clear_fn(a::QQFieldElem) = @ccall libflint.fmpq_clear(a::Ref{QQFieldElem})::Nothing ############################################################################### # @@ -248,15 +247,14 @@ mutable struct ZZPolyRingElem <: PolyRingElem{ZZRingElem} function ZZPolyRingElem() z = new() - ccall((:fmpz_poly_init, libflint), Nothing, (Ref{ZZPolyRingElem},), z) + @ccall libflint.fmpz_poly_init(z::Ref{ZZPolyRingElem})::Nothing finalizer(_fmpz_poly_clear_fn, z) return z end function ZZPolyRingElem(a::Vector{<:Union{Integer,ZZRingElem}}) z = new() - ccall((:fmpz_poly_init2, libflint), Nothing, - (Ref{ZZPolyRingElem}, Int), z, length(a)) + @ccall libflint.fmpz_poly_init2(z::Ref{ZZPolyRingElem}, length(a)::Int)::Nothing for i = 1:length(a) setcoeff!(z, i - 1, a[i]) end @@ -270,7 +268,7 @@ mutable struct ZZPolyRingElem <: PolyRingElem{ZZRingElem} end function _fmpz_poly_clear_fn(a::ZZPolyRingElem) - ccall((:fmpz_poly_clear, libflint), Nothing, (Ref{ZZPolyRingElem},), a) + @ccall libflint.fmpz_poly_clear(a::Ref{ZZPolyRingElem})::Nothing end mutable struct fmpz_poly_factor @@ -282,16 +280,14 @@ mutable struct fmpz_poly_factor function fmpz_poly_factor() z = new() - ccall((:fmpz_poly_factor_init, libflint), Nothing, - (Ref{fmpz_poly_factor}, ), z) + @ccall libflint.fmpz_poly_factor_init(z::Ref{fmpz_poly_factor})::Nothing finalizer(_fmpz_poly_factor_clear_fn, z) return z end end function _fmpz_poly_factor_clear_fn(f::fmpz_poly_factor) - ccall((:fmpz_poly_factor_clear, libflint), Nothing, - (Ref{fmpz_poly_factor}, ), f) + @ccall libflint.fmpz_poly_factor_clear(f::Ref{fmpz_poly_factor})::Nothing nothing end @@ -324,15 +320,14 @@ mutable struct QQPolyRingElem <: PolyRingElem{QQFieldElem} function QQPolyRingElem() z = new() - ccall((:fmpq_poly_init, libflint), Nothing, (Ref{QQPolyRingElem},), z) + @ccall libflint.fmpq_poly_init(z::Ref{QQPolyRingElem})::Nothing finalizer(_fmpq_poly_clear_fn, z) return z end function QQPolyRingElem(a::Vector{<:Union{Integer,Rational,ZZRingElem,QQFieldElem}}) z = new() - ccall((:fmpq_poly_init2, libflint), Nothing, - (Ref{QQPolyRingElem}, Int), z, length(a)) + @ccall libflint.fmpq_poly_init2(z::Ref{QQPolyRingElem}, length(a)::Int)::Nothing for i = 1:length(a) setcoeff!(z, i - 1, a[i]) end @@ -351,7 +346,7 @@ mutable struct QQPolyRingElem <: PolyRingElem{QQFieldElem} end function _fmpq_poly_clear_fn(a::QQPolyRingElem) - ccall((:fmpq_poly_clear, libflint), Nothing, (Ref{QQPolyRingElem},), a) + @ccall libflint.fmpq_poly_clear(a::Ref{QQPolyRingElem})::Nothing end ############################################################################### @@ -373,7 +368,7 @@ For the modulus being a [`ZZRingElem`](@ref) see [`ZZModRing`](@ref). function zzModRing(n::UInt, cached::Bool=true) return get_cached!(NmodRingID, n, cached) do - ninv = ccall((:n_preinvert_limb, libflint), UInt, (UInt,), n) + ninv = @ccall libflint.n_preinvert_limb(n::UInt)::UInt return new(n, ninv) end end @@ -409,7 +404,7 @@ Implementation for $p$ being a machine integer [`Int`](@ref). function fpField(n::UInt, cached::Bool=true) return get_cached!(GaloisFieldID, n, cached) do - ninv = ccall((:n_preinvert_limb, libflint), UInt, (UInt,), n) + ninv = @ccall libflint.n_preinvert_limb(n::UInt)::UInt return new(n, ninv) end end @@ -453,7 +448,7 @@ mutable struct fmpz_mod_ctx_struct end function _fmpz_mod_ctx_clear_fn(a::fmpz_mod_ctx_struct) - ccall((:fmpz_mod_ctx_clear, libflint), Nothing, (Ref{fmpz_mod_ctx_struct},), a) + @ccall libflint.fmpz_mod_ctx_clear(a::Ref{fmpz_mod_ctx_struct})::Nothing end @doc raw""" @@ -470,7 +465,7 @@ For the modulus being an [`Int`](@ref) see [`zzModRing`](@ref). function ZZModRing(n::ZZRingElem, cached::Bool=true) return get_cached!(FmpzModRingID, n, cached) do ninv = fmpz_mod_ctx_struct() - ccall((:fmpz_mod_ctx_init, libflint), Nothing, (Ref{fmpz_mod_ctx_struct}, Ref{ZZRingElem}), ninv, n) + @ccall libflint.fmpz_mod_ctx_init(ninv::Ref{fmpz_mod_ctx_struct}, n::Ref{ZZRingElem})::Nothing return new(n, ninv) end end @@ -507,8 +502,7 @@ Implementation for $p$ being a big integer [`ZZRingElem`](@ref). function FpField(n::ZZRingElem, cached::Bool=true) return get_cached!(GaloisFmpzFieldID, n, cached) do ninv = fmpz_mod_ctx_struct() - ccall((:fmpz_mod_ctx_init, libflint), Nothing, - (Ref{fmpz_mod_ctx_struct}, Ref{ZZRingElem}), ninv, n) + @ccall libflint.fmpz_mod_ctx_init(ninv::Ref{fmpz_mod_ctx_struct}, n::Ref{ZZRingElem})::Nothing return new(n, ninv) end end @@ -558,7 +552,7 @@ mutable struct zzModPolyRingElem <: PolyRingElem{zzModRingElem} function zzModPolyRingElem(n::UInt) z = new() - ccall((:nmod_poly_init, libflint), Nothing, (Ref{zzModPolyRingElem}, UInt), z, n) + @ccall libflint.nmod_poly_init(z::Ref{zzModPolyRingElem}, n::UInt)::Nothing finalizer(_nmod_poly_clear_fn, z) return z end @@ -575,8 +569,7 @@ mutable struct zzModPolyRingElem <: PolyRingElem{zzModRingElem} function zzModPolyRingElem(n::UInt, arr::Vector{ZZRingElem}) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{zzModPolyRingElem}, UInt, Int), z, n, length(arr)) + @ccall libflint.nmod_poly_init2(z::Ref{zzModPolyRingElem}, n::UInt, length(arr)::Int)::Nothing finalizer(_nmod_poly_clear_fn, z) for i in 1:length(arr) setcoeff!(z, i - 1, arr[i]) @@ -586,8 +579,7 @@ mutable struct zzModPolyRingElem <: PolyRingElem{zzModRingElem} function zzModPolyRingElem(n::UInt, arr::Vector{UInt}) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{zzModPolyRingElem}, UInt, Int), z, n, length(arr)) + @ccall libflint.nmod_poly_init2(z::Ref{zzModPolyRingElem}, n::UInt, length(arr)::Int)::Nothing finalizer(_nmod_poly_clear_fn, z) for i in 1:length(arr) setcoeff!(z, i - 1, arr[i]) @@ -597,8 +589,7 @@ mutable struct zzModPolyRingElem <: PolyRingElem{zzModRingElem} function zzModPolyRingElem(n::UInt, arr::Vector{zzModRingElem}) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{zzModPolyRingElem}, UInt, Int), z, n, length(arr)) + @ccall libflint.nmod_poly_init2(z::Ref{zzModPolyRingElem}, n::UInt, length(arr)::Int)::Nothing finalizer(_nmod_poly_clear_fn, z) for i in 1:length(arr) setcoeff!(z, i-1, arr[i].data) @@ -608,27 +599,23 @@ mutable struct zzModPolyRingElem <: PolyRingElem{zzModRingElem} function zzModPolyRingElem(n::UInt, f::ZZPolyRingElem) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{zzModPolyRingElem}, UInt, Int), z, n, length(f)) - ccall((:fmpz_poly_get_nmod_poly, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{ZZPolyRingElem}), z, f) + @ccall libflint.nmod_poly_init2(z::Ref{zzModPolyRingElem}, n::UInt, length(f)::Int)::Nothing + @ccall libflint.fmpz_poly_get_nmod_poly(z::Ref{zzModPolyRingElem}, f::Ref{ZZPolyRingElem})::Nothing finalizer(_nmod_poly_clear_fn, z) return z end function zzModPolyRingElem(n::UInt, f::zzModPolyRingElem) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{zzModPolyRingElem}, UInt, Int), z, n, length(f)) - ccall((:nmod_poly_set, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}), z, f) + @ccall libflint.nmod_poly_init2(z::Ref{zzModPolyRingElem}, n::UInt, length(f)::Int)::Nothing + @ccall libflint.nmod_poly_set(z::Ref{zzModPolyRingElem}, f::Ref{zzModPolyRingElem})::Nothing finalizer(_nmod_poly_clear_fn, z) return z end end function _nmod_poly_clear_fn(x::zzModPolyRingElem) - ccall((:nmod_poly_clear, libflint), Nothing, (Ref{zzModPolyRingElem}, ), x) + @ccall libflint.nmod_poly_clear(x::Ref{zzModPolyRingElem})::Nothing end mutable struct nmod_poly_factor @@ -640,8 +627,7 @@ mutable struct nmod_poly_factor function nmod_poly_factor(n::UInt) z = new() - ccall((:nmod_poly_factor_init, libflint), Nothing, - (Ref{nmod_poly_factor}, ), z) + @ccall libflint.nmod_poly_factor_init(z::Ref{nmod_poly_factor})::Nothing z.n = n finalizer(_nmod_poly_factor_clear_fn, z) return z @@ -649,8 +635,7 @@ mutable struct nmod_poly_factor end function _nmod_poly_factor_clear_fn(a::nmod_poly_factor) - ccall((:nmod_poly_factor_clear, libflint), Nothing, - (Ref{nmod_poly_factor}, ), a) + @ccall libflint.nmod_poly_factor_clear(a::Ref{nmod_poly_factor})::Nothing end ################################################################################ @@ -685,7 +670,7 @@ mutable struct fpPolyRingElem <: PolyRingElem{fpFieldElem} function fpPolyRingElem(n::UInt) z = new() - ccall((:nmod_poly_init, libflint), Nothing, (Ref{fpPolyRingElem}, UInt), z, n) + @ccall libflint.nmod_poly_init(z::Ref{fpPolyRingElem}, n::UInt)::Nothing finalizer(_gfp_poly_clear_fn, z) return z end @@ -702,8 +687,7 @@ mutable struct fpPolyRingElem <: PolyRingElem{fpFieldElem} function fpPolyRingElem(n::UInt, arr::Vector{ZZRingElem}) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{fpPolyRingElem}, UInt, Int), z, n, length(arr)) + @ccall libflint.nmod_poly_init2(z::Ref{fpPolyRingElem}, n::UInt, length(arr)::Int)::Nothing finalizer(_gfp_poly_clear_fn, z) for i in 1:length(arr) setcoeff!(z, i - 1, arr[i]) @@ -713,8 +697,7 @@ mutable struct fpPolyRingElem <: PolyRingElem{fpFieldElem} function fpPolyRingElem(n::UInt, arr::Vector{UInt}) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{fpPolyRingElem}, UInt, Int), z, n, length(arr)) + @ccall libflint.nmod_poly_init2(z::Ref{fpPolyRingElem}, n::UInt, length(arr)::Int)::Nothing finalizer(_gfp_poly_clear_fn, z) for i in 1:length(arr) setcoeff!(z, i - 1, arr[i]) @@ -724,8 +707,7 @@ mutable struct fpPolyRingElem <: PolyRingElem{fpFieldElem} function fpPolyRingElem(n::UInt, arr::Vector{fpFieldElem}) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{fpPolyRingElem}, UInt, Int), z, n, length(arr)) + @ccall libflint.nmod_poly_init2(z::Ref{fpPolyRingElem}, n::UInt, length(arr)::Int)::Nothing finalizer(_gfp_poly_clear_fn, z) for i in 1:length(arr) setcoeff!(z, i-1, arr[i].data) @@ -735,27 +717,23 @@ mutable struct fpPolyRingElem <: PolyRingElem{fpFieldElem} function fpPolyRingElem(n::UInt, f::ZZPolyRingElem) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{fpPolyRingElem}, UInt, Int), z, n, length(f)) - ccall((:fmpz_poly_get_nmod_poly, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{ZZPolyRingElem}), z, f) + @ccall libflint.nmod_poly_init2(z::Ref{fpPolyRingElem}, n::UInt, length(f)::Int)::Nothing + @ccall libflint.fmpz_poly_get_nmod_poly(z::Ref{fpPolyRingElem}, f::Ref{ZZPolyRingElem})::Nothing finalizer(_gfp_poly_clear_fn, z) return z end function fpPolyRingElem(n::UInt, f::fpPolyRingElem) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{fpPolyRingElem}, UInt, Int), z, n, length(f)) - ccall((:nmod_poly_set, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), z, f) + @ccall libflint.nmod_poly_init2(z::Ref{fpPolyRingElem}, n::UInt, length(f)::Int)::Nothing + @ccall libflint.nmod_poly_set(z::Ref{fpPolyRingElem}, f::Ref{fpPolyRingElem})::Nothing finalizer(_gfp_poly_clear_fn, z) return z end end function _gfp_poly_clear_fn(x::fpPolyRingElem) - ccall((:nmod_poly_clear, libflint), Nothing, (Ref{fpPolyRingElem}, ), x) + @ccall libflint.nmod_poly_clear(x::Ref{fpPolyRingElem})::Nothing end mutable struct gfp_poly_factor @@ -767,8 +745,7 @@ mutable struct gfp_poly_factor function gfp_poly_factor(n::UInt) z = new() - ccall((:nmod_poly_factor_init, libflint), Nothing, - (Ref{gfp_poly_factor}, ), z) + @ccall libflint.nmod_poly_factor_init(z::Ref{gfp_poly_factor})::Nothing z.n = n finalizer(_gfp_poly_factor_clear_fn, z) return z @@ -776,8 +753,7 @@ mutable struct gfp_poly_factor end function _gfp_poly_factor_clear_fn(a::gfp_poly_factor) - ccall((:nmod_poly_factor_clear, libflint), Nothing, - (Ref{gfp_poly_factor}, ), a) + @ccall libflint.nmod_poly_factor_clear(a::Ref{gfp_poly_factor})::Nothing end ############################################################################### @@ -810,9 +786,7 @@ mutable struct ZZModPolyRingElem <: PolyRingElem{ZZModRingElem} function ZZModPolyRingElem(n::fmpz_mod_ctx_struct) z = new() - ccall((:fmpz_mod_poly_init, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - z, n) + @ccall libflint.fmpz_mod_poly_init(z::Ref{ZZModPolyRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_fmpz_mod_poly_clear_fn, z) return z end @@ -824,9 +798,7 @@ mutable struct ZZModPolyRingElem <: PolyRingElem{ZZModRingElem} function ZZModPolyRingElem(n::fmpz_mod_ctx_struct, a::ZZRingElem) z = ZZModPolyRingElem(n) - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Int, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z, 0, a, n) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{ZZModPolyRingElem}, 0::Int, a::Ref{ZZRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -836,9 +808,7 @@ mutable struct ZZModPolyRingElem <: PolyRingElem{ZZModRingElem} function ZZModPolyRingElem(n::fmpz_mod_ctx_struct, a::UInt) z = ZZModPolyRingElem(n) - ccall((:fmpz_mod_poly_set_coeff_ui, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Int, UInt, Ref{fmpz_mod_ctx_struct}), - z, 0, a, n) + @ccall libflint.fmpz_mod_poly_set_coeff_ui(z::Ref{ZZModPolyRingElem}, 0::Int, a::UInt, n::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -849,13 +819,9 @@ mutable struct ZZModPolyRingElem <: PolyRingElem{ZZModRingElem} function ZZModPolyRingElem(n::fmpz_mod_ctx_struct, arr::Vector{ZZRingElem}) length(arr) == 0 && error("Array must have length > 0") z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, length(arr), n) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{ZZModPolyRingElem}, length(arr)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing for i in 1:length(arr) - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Int, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z, i - 1, arr[i], n) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{ZZModPolyRingElem}, (i - 1)::Int, arr[i]::Ref{ZZRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing end finalizer(_fmpz_mod_poly_clear_fn, z) return z @@ -867,13 +833,9 @@ mutable struct ZZModPolyRingElem <: PolyRingElem{ZZModRingElem} function ZZModPolyRingElem(n::fmpz_mod_ctx_struct, arr::Vector{ZZModRingElem}) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, length(arr), n) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{ZZModPolyRingElem}, length(arr)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing for i in 1:length(arr) - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Int, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z, i - 1, arr[i].data, n) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{ZZModPolyRingElem}, (i - 1)::Int, arr[i].data::Ref{ZZRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing end finalizer(_fmpz_mod_poly_clear_fn, z) return z @@ -885,12 +847,8 @@ mutable struct ZZModPolyRingElem <: PolyRingElem{ZZModRingElem} function ZZModPolyRingElem(n::fmpz_mod_ctx_struct, f::ZZPolyRingElem) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, length(f), n) - ccall((:fmpz_mod_poly_set_fmpz_poly, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{ZZPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - z, f, n) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{ZZModPolyRingElem}, length(f)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing + @ccall libflint.fmpz_mod_poly_set_fmpz_poly(z::Ref{ZZModPolyRingElem}, f::Ref{ZZPolyRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_fmpz_mod_poly_clear_fn, z) return z end @@ -901,12 +859,8 @@ mutable struct ZZModPolyRingElem <: PolyRingElem{ZZModRingElem} function ZZModPolyRingElem(n::fmpz_mod_ctx_struct, f::ZZModPolyRingElem) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, length(f), n) - ccall((:fmpz_mod_poly_set, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - z, f, n) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{ZZModPolyRingElem}, length(f)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing + @ccall libflint.fmpz_mod_poly_set(z::Ref{ZZModPolyRingElem}, f::Ref{ZZModPolyRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_fmpz_mod_poly_clear_fn, z) return z end @@ -917,9 +871,7 @@ mutable struct ZZModPolyRingElem <: PolyRingElem{ZZModRingElem} end function _fmpz_mod_poly_clear_fn(x::ZZModPolyRingElem) - ccall((:fmpz_mod_poly_clear, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - x, base_ring(parent(x)).ninv) + @ccall libflint.fmpz_mod_poly_clear(x::Ref{ZZModPolyRingElem}, base_ring(parent(x)).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end mutable struct fmpz_mod_poly_factor @@ -933,9 +885,7 @@ mutable struct fmpz_mod_poly_factor function fmpz_mod_poly_factor(n::fmpz_mod_ctx_struct) z = new() - ccall((:fmpz_mod_poly_factor_init, libflint), Nothing, - (Ref{fmpz_mod_poly_factor}, Ref{fmpz_mod_ctx_struct}), - z, n) + @ccall libflint.fmpz_mod_poly_factor_init(z::Ref{fmpz_mod_poly_factor}, n::Ref{fmpz_mod_ctx_struct})::Nothing z.n = n finalizer(_fmpz_mod_poly_factor_clear_fn, z) return z @@ -947,9 +897,7 @@ mutable struct fmpz_mod_poly_factor end function _fmpz_mod_poly_factor_clear_fn(a::fmpz_mod_poly_factor) - ccall((:fmpz_mod_poly_factor_clear, libflint), Nothing, - (Ref{fmpz_mod_poly_factor}, Ref{fmpz_mod_ctx_struct}), - a, a.n) + @ccall libflint.fmpz_mod_poly_factor_clear(a::Ref{fmpz_mod_poly_factor}, a.n::Ref{fmpz_mod_ctx_struct})::Nothing end ############################################################################### @@ -983,9 +931,7 @@ mutable struct FpPolyRingElem <: PolyRingElem{FpFieldElem} function FpPolyRingElem(n::fmpz_mod_ctx_struct) z = new() - ccall((:fmpz_mod_poly_init, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - z, n) + @ccall libflint.fmpz_mod_poly_init(z::Ref{FpPolyRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_fmpz_mod_poly_clear_fn, z) return z end @@ -996,9 +942,7 @@ mutable struct FpPolyRingElem <: PolyRingElem{FpFieldElem} function FpPolyRingElem(n::fmpz_mod_ctx_struct, a::ZZRingElem) z = FpPolyRingElem(n) - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{FpPolyRingElem}, Int, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z, 0, a, n) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{FpPolyRingElem}, 0::Int, a::Ref{ZZRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -1008,9 +952,7 @@ mutable struct FpPolyRingElem <: PolyRingElem{FpFieldElem} function FpPolyRingElem(n::fmpz_mod_ctx_struct, a::UInt) z = FpPolyRingElem(n) - ccall((:fmpz_mod_poly_set_coeff_ui, libflint), Nothing, - (Ref{FpPolyRingElem}, Int, UInt, Ref{fmpz_mod_ctx_struct}), - z, 0, a, n) + @ccall libflint.fmpz_mod_poly_set_coeff_ui(z::Ref{FpPolyRingElem}, 0::Int, a::UInt, n::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -1021,13 +963,9 @@ mutable struct FpPolyRingElem <: PolyRingElem{FpFieldElem} function FpPolyRingElem(n::fmpz_mod_ctx_struct, arr::Vector{ZZRingElem}) length(arr) == 0 && error("Array must have length > 0") z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{FpPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, length(arr), n) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{FpPolyRingElem}, length(arr)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing for i in 1:length(arr) - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{FpPolyRingElem}, Int, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z, i - 1, arr[i], n) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{FpPolyRingElem}, (i - 1)::Int, arr[i]::Ref{ZZRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing end finalizer(_fmpz_mod_poly_clear_fn, z) return z @@ -1039,13 +977,9 @@ mutable struct FpPolyRingElem <: PolyRingElem{FpFieldElem} function FpPolyRingElem(n::fmpz_mod_ctx_struct, arr::Vector{FpFieldElem}) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{FpPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, length(arr), n) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{FpPolyRingElem}, length(arr)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing for i in 1:length(arr) - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{FpPolyRingElem}, Int, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z, i - 1, arr[i].data, n) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{FpPolyRingElem}, (i - 1)::Int, arr[i].data::Ref{ZZRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing end finalizer(_fmpz_mod_poly_clear_fn, z) return z @@ -1057,12 +991,8 @@ mutable struct FpPolyRingElem <: PolyRingElem{FpFieldElem} function FpPolyRingElem(n::fmpz_mod_ctx_struct, f::ZZPolyRingElem) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{FpPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, length(f), n) - ccall((:fmpz_mod_poly_set_fmpz_poly, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{ZZPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - z, f, n) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{FpPolyRingElem}, length(f)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing + @ccall libflint.fmpz_mod_poly_set_fmpz_poly(z::Ref{FpPolyRingElem}, f::Ref{ZZPolyRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_fmpz_mod_poly_clear_fn, z) return z end @@ -1073,12 +1003,8 @@ mutable struct FpPolyRingElem <: PolyRingElem{FpFieldElem} function FpPolyRingElem(n::fmpz_mod_ctx_struct, f::FpPolyRingElem) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{FpPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, length(f), n) - ccall((:fmpz_mod_poly_set, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - z, f, n) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{FpPolyRingElem}, length(f)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing + @ccall libflint.fmpz_mod_poly_set(z::Ref{FpPolyRingElem}, f::Ref{FpPolyRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_fmpz_mod_poly_clear_fn, z) return z end @@ -1089,9 +1015,7 @@ mutable struct FpPolyRingElem <: PolyRingElem{FpFieldElem} end function _fmpz_mod_poly_clear_fn(x::FpPolyRingElem) - ccall((:fmpz_mod_poly_clear, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - x, base_ring(parent(x)).ninv) + @ccall libflint.fmpz_mod_poly_clear(x::Ref{FpPolyRingElem}, base_ring(parent(x)).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end mutable struct gfp_fmpz_poly_factor @@ -1105,9 +1029,7 @@ mutable struct gfp_fmpz_poly_factor function gfp_fmpz_poly_factor(n::fmpz_mod_ctx_struct) z = new() - ccall((:fmpz_mod_poly_factor_init, libflint), Nothing, - (Ref{gfp_fmpz_poly_factor}, Ref{fmpz_mod_ctx_struct}), - z, n) + @ccall libflint.fmpz_mod_poly_factor_init(z::Ref{gfp_fmpz_poly_factor}, n::Ref{fmpz_mod_ctx_struct})::Nothing z.n = n finalizer(_gfp_fmpz_poly_factor_clear_fn, z) return z @@ -1119,9 +1041,7 @@ mutable struct gfp_fmpz_poly_factor end function _gfp_fmpz_poly_factor_clear_fn(a::gfp_fmpz_poly_factor) - ccall((:fmpz_mod_poly_factor_clear, libflint), Nothing, - (Ref{gfp_fmpz_poly_factor}, Ref{fmpz_mod_ctx_struct}), - a, a.n) + @ccall libflint.fmpz_mod_poly_factor_clear(a::Ref{gfp_fmpz_poly_factor}, a.n::Ref{fmpz_mod_ctx_struct})::Nothing end ############################################################################### @@ -1156,9 +1076,7 @@ const flint_orderings = [:lex, :deglex, :degrevlex] end z = new() - ccall((:fmpz_mpoly_ctx_init, libflint), Nothing, - (Ref{ZZMPolyRing}, Int, Int), - z, length(s), ord) + @ccall libflint.fmpz_mpoly_ctx_init(z::Ref{ZZMPolyRing}, length(s)::Int, ord::Int)::Nothing z.S = s finalizer(_fmpz_mpoly_ctx_clear_fn, z) return z @@ -1168,8 +1086,7 @@ end ZZMPolyRing(::ZZRing, s::Vector{Symbol}, S::Symbol, cached::Bool=true) = ZZMPolyRing(s, S, cached) function _fmpz_mpoly_ctx_clear_fn(a::ZZMPolyRing) - ccall((:fmpz_mpoly_ctx_clear, libflint), Nothing, - (Ref{ZZMPolyRing},), a) + @ccall libflint.fmpz_mpoly_ctx_clear(a::Ref{ZZMPolyRing})::Nothing end const FmpzMPolyID = CacheDictType{Tuple{Vector{Symbol}, Symbol}, ZZMPolyRing}() @@ -1186,8 +1103,7 @@ mutable struct ZZMPolyRingElem <: MPolyRingElem{ZZRingElem} function ZZMPolyRingElem(ctx::ZZMPolyRing) z = new() - ccall((:fmpz_mpoly_init, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing},), z, ctx) + @ccall libflint.fmpz_mpoly_init(z::Ref{ZZMPolyRingElem}, ctx::Ref{ZZMPolyRing})::Nothing z.parent = ctx finalizer(_fmpz_mpoly_clear_fn, z) return z @@ -1195,15 +1111,12 @@ mutable struct ZZMPolyRingElem <: MPolyRingElem{ZZRingElem} function ZZMPolyRingElem(ctx::ZZMPolyRing, a::Vector{ZZRingElem}, b::Vector{Vector{UInt}}) z = new() - ccall((:fmpz_mpoly_init2, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing},), z, length(a), ctx) + @ccall libflint.fmpz_mpoly_init2(z::Ref{ZZMPolyRingElem}, length(a)::Int, ctx::Ref{ZZMPolyRing})::Nothing z.parent = ctx finalizer(_fmpz_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:fmpz_mpoly_push_term_fmpz_ui, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZRingElem}, Ptr{UInt}, Ref{ZZMPolyRing}), - z, a[i], b[i], ctx) + @ccall libflint.fmpz_mpoly_push_term_fmpz_ui(z::Ref{ZZMPolyRingElem}, a[i]::Ref{ZZRingElem}, b[i]::Ptr{UInt}, ctx::Ref{ZZMPolyRing})::Nothing end sort_terms!(z) @@ -1213,15 +1126,12 @@ mutable struct ZZMPolyRingElem <: MPolyRingElem{ZZRingElem} function ZZMPolyRingElem(ctx::ZZMPolyRing, a::Vector{ZZRingElem}, b::Vector{Vector{Int}}) z = new() - ccall((:fmpz_mpoly_init2, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing},), z, length(a), ctx) + @ccall libflint.fmpz_mpoly_init2(z::Ref{ZZMPolyRingElem}, length(a)::Int, ctx::Ref{ZZMPolyRing})::Nothing z.parent = ctx finalizer(_fmpz_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:fmpz_mpoly_push_term_fmpz_ui, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZRingElem}, Ptr{Int}, Ref{ZZMPolyRing}), - z, a[i], b[i], ctx) + @ccall libflint.fmpz_mpoly_push_term_fmpz_ui(z::Ref{ZZMPolyRingElem}, a[i]::Ref{ZZRingElem}, b[i]::Ptr{Int}, ctx::Ref{ZZMPolyRing})::Nothing end sort_terms!(z) @@ -1231,15 +1141,12 @@ mutable struct ZZMPolyRingElem <: MPolyRingElem{ZZRingElem} function ZZMPolyRingElem(ctx::ZZMPolyRing, a::Vector{ZZRingElem}, b::Vector{Vector{ZZRingElem}}) z = new() - ccall((:fmpz_mpoly_init2, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing},), z, length(a), ctx) + @ccall libflint.fmpz_mpoly_init2(z::Ref{ZZMPolyRingElem}, length(a)::Int, ctx::Ref{ZZMPolyRing})::Nothing z.parent = ctx finalizer(_fmpz_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:fmpz_mpoly_push_term_fmpz_fmpz, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZRingElem}, Ptr{Ref{ZZRingElem}}, Ref{ZZMPolyRing}), - z, a[i], b[i], ctx) + @ccall libflint.fmpz_mpoly_push_term_fmpz_fmpz(z::Ref{ZZMPolyRingElem}, a[i]::Ref{ZZRingElem}, b[i]::Ptr{Ref{ZZRingElem}}, ctx::Ref{ZZMPolyRing})::Nothing end sort_terms!(z) @@ -1249,22 +1156,19 @@ mutable struct ZZMPolyRingElem <: MPolyRingElem{ZZRingElem} function ZZMPolyRingElem(ctx::ZZMPolyRing, a::ZZRingElem) z = ZZMPolyRingElem(ctx) - ccall((:fmpz_mpoly_set_fmpz, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZRingElem}, Ref{ZZMPolyRing}), z, a, ctx) + @ccall libflint.fmpz_mpoly_set_fmpz(z::Ref{ZZMPolyRingElem}, a::Ref{ZZRingElem}, ctx::Ref{ZZMPolyRing})::Nothing return z end function ZZMPolyRingElem(ctx::ZZMPolyRing, a::Int) z = ZZMPolyRingElem(ctx) - ccall((:fmpz_mpoly_set_si, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), z, a, ctx) + @ccall libflint.fmpz_mpoly_set_si(z::Ref{ZZMPolyRingElem}, a::Int, ctx::Ref{ZZMPolyRing})::Nothing return z end function ZZMPolyRingElem(ctx::ZZMPolyRing, a::UInt) z = ZZMPolyRingElem(ctx) - ccall((:fmpz_mpoly_set_ui, libflint), Nothing, - (Ref{ZZMPolyRingElem}, UInt, Ref{ZZMPolyRing}), z, a, ctx) + @ccall libflint.fmpz_mpoly_set_ui(z::Ref{ZZMPolyRingElem}, a::UInt, ctx::Ref{ZZMPolyRing})::Nothing return z end @@ -1272,8 +1176,7 @@ mutable struct ZZMPolyRingElem <: MPolyRingElem{ZZRingElem} end function _fmpz_mpoly_clear_fn(a::ZZMPolyRingElem) - ccall((:fmpz_mpoly_clear, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), a, a.parent) + @ccall libflint.fmpz_mpoly_clear(a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing end mutable struct fmpz_mpoly_factor @@ -1289,9 +1192,7 @@ mutable struct fmpz_mpoly_factor function fmpz_mpoly_factor(ctx::ZZMPolyRing) z = new() - ccall((:fmpz_mpoly_factor_init, libflint), Nothing, - (Ref{fmpz_mpoly_factor}, Ref{ZZMPolyRing}), - z, ctx) + @ccall libflint.fmpz_mpoly_factor_init(z::Ref{fmpz_mpoly_factor}, ctx::Ref{ZZMPolyRing})::Nothing z.parent = ctx finalizer(_fmpz_mpoly_factor_clear_fn, z) return z @@ -1299,9 +1200,7 @@ mutable struct fmpz_mpoly_factor end function _fmpz_mpoly_factor_clear_fn(f::fmpz_mpoly_factor) - ccall((:fmpz_mpoly_factor_clear, libflint), Nothing, - (Ref{fmpz_mpoly_factor}, Ref{ZZMPolyRing}), - f, f.parent) + @ccall libflint.fmpz_mpoly_factor_clear(f::Ref{fmpz_mpoly_factor}, f.parent::Ref{ZZMPolyRing})::Nothing end ############################################################################### @@ -1334,9 +1233,7 @@ end end z = new() - ccall((:fmpq_mpoly_ctx_init, libflint), Nothing, - (Ref{QQMPolyRing}, Int, Int), - z, length(s), ord) + @ccall libflint.fmpq_mpoly_ctx_init(z::Ref{QQMPolyRing}, length(s)::Int, ord::Int)::Nothing z.S = s finalizer(_fmpq_mpoly_ctx_clear_fn, z) return z @@ -1346,8 +1243,7 @@ end QQMPolyRing(::QQField, s::Vector{Symbol}, S::Symbol, cached::Bool=true) = QQMPolyRing(s, S, cached) function _fmpq_mpoly_ctx_clear_fn(a::QQMPolyRing) - ccall((:fmpq_mpoly_ctx_clear, libflint), Nothing, - (Ref{QQMPolyRing},), a) + @ccall libflint.fmpq_mpoly_ctx_clear(a::Ref{QQMPolyRing})::Nothing end const FmpqMPolyID = CacheDictType{Tuple{Vector{Symbol}, Symbol}, QQMPolyRing}() @@ -1365,8 +1261,7 @@ mutable struct QQMPolyRingElem <: MPolyRingElem{QQFieldElem} function QQMPolyRingElem(ctx::QQMPolyRing) z = new() - ccall((:fmpq_mpoly_init, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing},), z, ctx) + @ccall libflint.fmpq_mpoly_init(z::Ref{QQMPolyRingElem}, ctx::Ref{QQMPolyRing})::Nothing z.parent = ctx finalizer(_fmpq_mpoly_clear_fn, z) return z @@ -1374,15 +1269,12 @@ mutable struct QQMPolyRingElem <: MPolyRingElem{QQFieldElem} function QQMPolyRingElem(ctx::QQMPolyRing, a::Vector{QQFieldElem}, b::Vector{Vector{UInt}}) z = new() - ccall((:fmpq_mpoly_init2, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing},), z, length(a), ctx) + @ccall libflint.fmpq_mpoly_init2(z::Ref{QQMPolyRingElem}, length(a)::Int, ctx::Ref{QQMPolyRing})::Nothing z.parent = ctx finalizer(_fmpq_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:fmpq_mpoly_push_term_fmpq_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQFieldElem}, Ptr{UInt}, Ref{QQMPolyRing}), - z, a[i], b[i], ctx) + @ccall libflint.fmpq_mpoly_push_term_fmpq_ui(z::Ref{QQMPolyRingElem}, a[i]::Ref{QQFieldElem}, b[i]::Ptr{UInt}, ctx::Ref{QQMPolyRing})::Nothing end sort_terms!(z) @@ -1392,15 +1284,12 @@ mutable struct QQMPolyRingElem <: MPolyRingElem{QQFieldElem} function QQMPolyRingElem(ctx::QQMPolyRing, a::Vector{QQFieldElem}, b::Vector{Vector{Int}}) z = new() - ccall((:fmpq_mpoly_init2, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing},), z, length(a), ctx) + @ccall libflint.fmpq_mpoly_init2(z::Ref{QQMPolyRingElem}, length(a)::Int, ctx::Ref{QQMPolyRing})::Nothing z.parent = ctx finalizer(_fmpq_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:fmpq_mpoly_push_term_fmpq_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQFieldElem}, Ptr{Int}, Ref{QQMPolyRing}), - z, a[i], b[i], ctx) + @ccall libflint.fmpq_mpoly_push_term_fmpq_ui(z::Ref{QQMPolyRingElem}, a[i]::Ref{QQFieldElem}, b[i]::Ptr{Int}, ctx::Ref{QQMPolyRing})::Nothing end sort_terms!(z) @@ -1410,15 +1299,12 @@ mutable struct QQMPolyRingElem <: MPolyRingElem{QQFieldElem} function QQMPolyRingElem(ctx::QQMPolyRing, a::Vector{QQFieldElem}, b::Vector{Vector{ZZRingElem}}) z = new() - ccall((:fmpq_mpoly_init2, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing},), z, length(a), ctx) + @ccall libflint.fmpq_mpoly_init2(z::Ref{QQMPolyRingElem}, length(a)::Int, ctx::Ref{QQMPolyRing})::Nothing z.parent = ctx finalizer(_fmpq_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:fmpq_mpoly_push_term_fmpq_fmpz, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQFieldElem}, Ptr{Ref{ZZRingElem}}, Ref{QQMPolyRing}), - z, a[i], b[i], ctx) + @ccall libflint.fmpq_mpoly_push_term_fmpq_fmpz(z::Ref{QQMPolyRingElem}, a[i]::Ref{QQFieldElem}, b[i]::Ptr{Ref{ZZRingElem}}, ctx::Ref{QQMPolyRing})::Nothing end sort_terms!(z) @@ -1428,36 +1314,31 @@ mutable struct QQMPolyRingElem <: MPolyRingElem{QQFieldElem} function QQMPolyRingElem(ctx::QQMPolyRing, a::ZZRingElem) z = QQMPolyRingElem(ctx) - ccall((:fmpq_mpoly_set_fmpz, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{ZZRingElem}, Ref{QQMPolyRing}), z, a, ctx) + @ccall libflint.fmpq_mpoly_set_fmpz(z::Ref{QQMPolyRingElem}, a::Ref{ZZRingElem}, ctx::Ref{QQMPolyRing})::Nothing return z end function QQMPolyRingElem(ctx::QQMPolyRing, a::QQFieldElem) z = QQMPolyRingElem(ctx) - ccall((:fmpq_mpoly_set_fmpq, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQFieldElem}, Ref{QQMPolyRing}), z, a, ctx) + @ccall libflint.fmpq_mpoly_set_fmpq(z::Ref{QQMPolyRingElem}, a::Ref{QQFieldElem}, ctx::Ref{QQMPolyRing})::Nothing return z end function QQMPolyRingElem(ctx::QQMPolyRing, a::Int) z = QQMPolyRingElem(ctx) - ccall((:fmpq_mpoly_set_si, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), z, a, ctx) + @ccall libflint.fmpq_mpoly_set_si(z::Ref{QQMPolyRingElem}, a::Int, ctx::Ref{QQMPolyRing})::Nothing return z end function QQMPolyRingElem(ctx::QQMPolyRing, a::UInt) z = QQMPolyRingElem(ctx) - ccall((:fmpq_mpoly_set_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, UInt, Ref{QQMPolyRing}), z, a, ctx) + @ccall libflint.fmpq_mpoly_set_ui(z::Ref{QQMPolyRingElem}, a::UInt, ctx::Ref{QQMPolyRing})::Nothing return z end end function _fmpq_mpoly_clear_fn(a::QQMPolyRingElem) - ccall((:fmpq_mpoly_clear, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, a.parent) + @ccall libflint.fmpq_mpoly_clear(a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing end mutable struct fmpq_mpoly_factor @@ -1473,9 +1354,7 @@ mutable struct fmpq_mpoly_factor function fmpq_mpoly_factor(ctx::QQMPolyRing) z = new() - ccall((:fmpq_mpoly_factor_init, libflint), Nothing, - (Ref{fmpq_mpoly_factor}, Ref{QQMPolyRing}), - z, ctx) + @ccall libflint.fmpq_mpoly_factor_init(z::Ref{fmpq_mpoly_factor}, ctx::Ref{QQMPolyRing})::Nothing z.parent = ctx finalizer(_fmpq_mpoly_factor_clear_fn, z) return z @@ -1483,9 +1362,7 @@ mutable struct fmpq_mpoly_factor end function _fmpq_mpoly_factor_clear_fn(f::fmpq_mpoly_factor) - ccall((:fmpq_mpoly_factor_clear, libflint), Nothing, - (Ref{fmpq_mpoly_factor}, Ref{QQMPolyRing}), - f, f.parent) + @ccall libflint.fmpq_mpoly_factor_clear(f::Ref{fmpq_mpoly_factor}, f.parent::Ref{QQMPolyRing})::Nothing end ############################################################################### @@ -1524,9 +1401,7 @@ end end z = new() - ccall((:nmod_mpoly_ctx_init, libflint), Nothing, - (Ref{zzModMPolyRing}, Int, Cint, UInt), - z, length(s), ord, R.n) + @ccall libflint.nmod_mpoly_ctx_init(z::Ref{zzModMPolyRing}, length(s)::Int, ord::Cint, R.n::UInt)::Nothing z.base_ring = R z.S = s finalizer(_nmod_mpoly_ctx_clear_fn, z) @@ -1536,8 +1411,7 @@ end end function _nmod_mpoly_ctx_clear_fn(a::zzModMPolyRing) - ccall((:nmod_mpoly_ctx_clear, libflint), Nothing, - (Ref{zzModMPolyRing},), a) + @ccall libflint.nmod_mpoly_ctx_clear(a::Ref{zzModMPolyRing})::Nothing end const NmodMPolyID = CacheDictType{Tuple{zzModRing, Vector{Symbol}, Symbol}, zzModMPolyRing}() @@ -1555,8 +1429,7 @@ mutable struct zzModMPolyRingElem <: MPolyRingElem{zzModRingElem} function zzModMPolyRingElem(ctx::zzModMPolyRing) z = new() - ccall((:nmod_mpoly_init, libflint), Nothing, - (Ref{zzModMPolyRingElem}, Ref{zzModMPolyRing},), z, ctx) + @ccall libflint.nmod_mpoly_init(z::Ref{zzModMPolyRingElem}, ctx::Ref{zzModMPolyRing})::Nothing z.parent = ctx finalizer(_nmod_mpoly_clear_fn, z) return z @@ -1564,15 +1437,12 @@ mutable struct zzModMPolyRingElem <: MPolyRingElem{zzModRingElem} function zzModMPolyRingElem(ctx::zzModMPolyRing, a::Vector{zzModRingElem}, b::Vector{Vector{UInt}}) z = new() - ccall((:nmod_mpoly_init2, libflint), Nothing, - (Ref{zzModMPolyRingElem}, Int, Ref{zzModMPolyRing},), z, length(a), ctx) + @ccall libflint.nmod_mpoly_init2(z::Ref{zzModMPolyRingElem}, length(a)::Int, ctx::Ref{zzModMPolyRing})::Nothing z.parent = ctx finalizer(_nmod_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:nmod_mpoly_push_term_ui_ui, libflint), Nothing, - (Ref{zzModMPolyRingElem}, UInt, Ptr{UInt}, Ref{zzModMPolyRing}), - z, a[i].data, b[i], ctx) + @ccall libflint.nmod_mpoly_push_term_ui_ui(z::Ref{zzModMPolyRingElem}, a[i].data::UInt, b[i]::Ptr{UInt}, ctx::Ref{zzModMPolyRing})::Nothing end sort_terms!(z) @@ -1582,15 +1452,12 @@ mutable struct zzModMPolyRingElem <: MPolyRingElem{zzModRingElem} function zzModMPolyRingElem(ctx::zzModMPolyRing, a::Vector{zzModRingElem}, b::Vector{Vector{Int}}) z = new() - ccall((:nmod_mpoly_init2, libflint), Nothing, - (Ref{zzModMPolyRingElem}, Int, Ref{zzModMPolyRing},), z, length(a), ctx) + @ccall libflint.nmod_mpoly_init2(z::Ref{zzModMPolyRingElem}, length(a)::Int, ctx::Ref{zzModMPolyRing})::Nothing z.parent = ctx finalizer(_nmod_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:nmod_mpoly_push_term_ui_ui, libflint), Nothing, - (Ref{zzModMPolyRingElem}, UInt, Ptr{Int}, Ref{zzModMPolyRing}), - z, a[i].data, b[i], ctx) + @ccall libflint.nmod_mpoly_push_term_ui_ui(z::Ref{zzModMPolyRingElem}, a[i].data::UInt, b[i]::Ptr{Int}, ctx::Ref{zzModMPolyRing})::Nothing end sort_terms!(z) @@ -1600,15 +1467,12 @@ mutable struct zzModMPolyRingElem <: MPolyRingElem{zzModRingElem} function zzModMPolyRingElem(ctx::zzModMPolyRing, a::Vector{zzModRingElem}, b::Vector{Vector{ZZRingElem}}) z = new() - ccall((:nmod_mpoly_init2, libflint), Nothing, - (Ref{zzModMPolyRingElem}, Int, Ref{zzModMPolyRing},), z, length(a), ctx) + @ccall libflint.nmod_mpoly_init2(z::Ref{zzModMPolyRingElem}, length(a)::Int, ctx::Ref{zzModMPolyRing})::Nothing z.parent = ctx finalizer(_nmod_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:nmod_mpoly_push_term_ui_fmpz, libflint), Nothing, - (Ref{zzModMPolyRingElem}, UInt, Ptr{Ref{ZZRingElem}}, Ref{zzModMPolyRing}), - z, a[i].data, b[i], ctx) + @ccall libflint.nmod_mpoly_push_term_ui_fmpz(z::Ref{zzModMPolyRingElem}, a[i].data::UInt, b[i]::Ptr{Ref{ZZRingElem}}, ctx::Ref{zzModMPolyRing})::Nothing end sort_terms!(z) @@ -1618,22 +1482,19 @@ mutable struct zzModMPolyRingElem <: MPolyRingElem{zzModRingElem} function zzModMPolyRingElem(ctx::zzModMPolyRing, a::UInt) z = zzModMPolyRingElem(ctx) - ccall((:nmod_mpoly_set_ui, libflint), Nothing, - (Ref{zzModMPolyRingElem}, UInt, Ref{zzModMPolyRing}), z, a, ctx) + @ccall libflint.nmod_mpoly_set_ui(z::Ref{zzModMPolyRingElem}, a::UInt, ctx::Ref{zzModMPolyRing})::Nothing return z end function zzModMPolyRingElem(ctx::zzModMPolyRing, a::zzModRingElem) z = zzModMPolyRingElem(ctx) - ccall((:nmod_mpoly_set_ui, libflint), Nothing, - (Ref{zzModMPolyRingElem}, UInt, Ref{zzModMPolyRing}), z, a.data, ctx) + @ccall libflint.nmod_mpoly_set_ui(z::Ref{zzModMPolyRingElem}, a.data::UInt, ctx::Ref{zzModMPolyRing})::Nothing return z end end function _nmod_mpoly_clear_fn(a::zzModMPolyRingElem) - ccall((:nmod_mpoly_clear, libflint), Nothing, - (Ref{zzModMPolyRingElem}, Ref{zzModMPolyRing}), a, a.parent) + @ccall libflint.nmod_mpoly_clear(a::Ref{zzModMPolyRingElem}, a.parent::Ref{zzModMPolyRing})::Nothing end mutable struct nmod_mpoly_factor @@ -1648,9 +1509,7 @@ mutable struct nmod_mpoly_factor function nmod_mpoly_factor(ctx::zzModMPolyRing) z = new() - ccall((:nmod_mpoly_factor_init, libflint), Nothing, - (Ref{nmod_mpoly_factor}, Ref{zzModMPolyRing}), - z, ctx) + @ccall libflint.nmod_mpoly_factor_init(z::Ref{nmod_mpoly_factor}, ctx::Ref{zzModMPolyRing})::Nothing z.parent = ctx finalizer(_nmod_mpoly_factor_clear_fn, z) return z @@ -1658,9 +1517,7 @@ mutable struct nmod_mpoly_factor end function _nmod_mpoly_factor_clear_fn(f::nmod_mpoly_factor) - ccall((:nmod_mpoly_factor_clear, libflint), Nothing, - (Ref{nmod_mpoly_factor}, Ref{zzModMPolyRing}), - f, f.parent) + @ccall libflint.nmod_mpoly_factor_clear(f::Ref{nmod_mpoly_factor}, f.parent::Ref{zzModMPolyRing})::Nothing end ################################################################################ @@ -1699,9 +1556,7 @@ end end z = new() - ccall((:nmod_mpoly_ctx_init, libflint), Nothing, - (Ref{fpMPolyRing}, Int, Cint, UInt), - z, length(s), ord, UInt(modulus(R))) + @ccall libflint.nmod_mpoly_ctx_init(z::Ref{fpMPolyRing}, length(s)::Int, ord::Cint, UInt(modulus(R))::UInt)::Nothing z.base_ring = R z.S = s finalizer(_gfp_mpoly_ctx_clear_fn, z) @@ -1711,8 +1566,7 @@ end end function _gfp_mpoly_ctx_clear_fn(a::fpMPolyRing) - ccall((:nmod_mpoly_ctx_clear, libflint), Nothing, - (Ref{fpMPolyRing},), a) + @ccall libflint.nmod_mpoly_ctx_clear(a::Ref{fpMPolyRing})::Nothing end const GFPMPolyID = CacheDictType{Tuple{fpField, Vector{Symbol}, Symbol}, fpMPolyRing}() @@ -1730,9 +1584,7 @@ mutable struct fpMPolyRingElem <: MPolyRingElem{fpFieldElem} function fpMPolyRingElem(ctx::fpMPolyRing) z = new() - ccall((:nmod_mpoly_init, libflint), Nothing, - (Ref{fpMPolyRingElem}, Ref{fpMPolyRing}), - z, ctx) + @ccall libflint.nmod_mpoly_init(z::Ref{fpMPolyRingElem}, ctx::Ref{fpMPolyRing})::Nothing z.parent = ctx finalizer(_gfp_mpoly_clear_fn, z) return z @@ -1740,16 +1592,12 @@ mutable struct fpMPolyRingElem <: MPolyRingElem{fpFieldElem} function fpMPolyRingElem(ctx::fpMPolyRing, a::Vector{fpFieldElem}, b::Vector{Vector{UInt}}) z = new() - ccall((:nmod_mpoly_init2, libflint), Nothing, - (Ref{fpMPolyRingElem}, Int, Ref{fpMPolyRing}), - z, length(a), ctx) + @ccall libflint.nmod_mpoly_init2(z::Ref{fpMPolyRingElem}, length(a)::Int, ctx::Ref{fpMPolyRing})::Nothing z.parent = ctx finalizer(_gfp_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:nmod_mpoly_push_term_ui_ui, libflint), Nothing, - (Ref{fpMPolyRingElem}, UInt, Ptr{UInt}, Ref{fpMPolyRing}), - z, a[i].data, b[i], ctx) + @ccall libflint.nmod_mpoly_push_term_ui_ui(z::Ref{fpMPolyRingElem}, a[i].data::UInt, b[i]::Ptr{UInt}, ctx::Ref{fpMPolyRing})::Nothing end sort_terms!(z) @@ -1759,16 +1607,12 @@ mutable struct fpMPolyRingElem <: MPolyRingElem{fpFieldElem} function fpMPolyRingElem(ctx::fpMPolyRing, a::Vector{fpFieldElem}, b::Vector{Vector{Int}}) z = new() - ccall((:nmod_mpoly_init2, libflint), Nothing, - (Ref{fpMPolyRingElem}, Int, Ref{fpMPolyRing}), - z, length(a), ctx) + @ccall libflint.nmod_mpoly_init2(z::Ref{fpMPolyRingElem}, length(a)::Int, ctx::Ref{fpMPolyRing})::Nothing z.parent = ctx finalizer(_gfp_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:nmod_mpoly_push_term_ui_ui, libflint), Nothing, - (Ref{fpMPolyRingElem}, UInt, Ptr{Int}, Ref{fpMPolyRing}), - z, a[i].data, b[i], ctx) + @ccall libflint.nmod_mpoly_push_term_ui_ui(z::Ref{fpMPolyRingElem}, a[i].data::UInt, b[i]::Ptr{Int}, ctx::Ref{fpMPolyRing})::Nothing end sort_terms!(z) @@ -1778,16 +1622,12 @@ mutable struct fpMPolyRingElem <: MPolyRingElem{fpFieldElem} function fpMPolyRingElem(ctx::fpMPolyRing, a::Vector{fpFieldElem}, b::Vector{Vector{ZZRingElem}}) z = new() - ccall((:nmod_mpoly_init2, libflint), Nothing, - (Ref{fpMPolyRingElem}, Int, Ref{fpMPolyRing}), - z, length(a), ctx) + @ccall libflint.nmod_mpoly_init2(z::Ref{fpMPolyRingElem}, length(a)::Int, ctx::Ref{fpMPolyRing})::Nothing z.parent = ctx finalizer(_gfp_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:nmod_mpoly_push_term_ui_fmpz, libflint), Nothing, - (Ref{fpMPolyRingElem}, UInt, Ptr{Ref{ZZRingElem}}, Ref{fpMPolyRing}), - z, a[i].data, b[i], ctx) + @ccall libflint.nmod_mpoly_push_term_ui_fmpz(z::Ref{fpMPolyRingElem}, a[i].data::UInt, b[i]::Ptr{Ref{ZZRingElem}}, ctx::Ref{fpMPolyRing})::Nothing end sort_terms!(z) @@ -1797,25 +1637,19 @@ mutable struct fpMPolyRingElem <: MPolyRingElem{fpFieldElem} function fpMPolyRingElem(ctx::fpMPolyRing, a::UInt) z = fpMPolyRingElem(ctx) - ccall((:nmod_mpoly_set_ui, libflint), Nothing, - (Ref{fpMPolyRingElem}, UInt, Ref{fpMPolyRing}), - z, a, ctx) + @ccall libflint.nmod_mpoly_set_ui(z::Ref{fpMPolyRingElem}, a::UInt, ctx::Ref{fpMPolyRing})::Nothing return z end function fpMPolyRingElem(ctx::fpMPolyRing, a::fpFieldElem) z = fpMPolyRingElem(ctx) - ccall((:nmod_mpoly_set_ui, libflint), Nothing, - (Ref{fpMPolyRingElem}, UInt, Ref{fpMPolyRing}), - z, a.data, ctx) + @ccall libflint.nmod_mpoly_set_ui(z::Ref{fpMPolyRingElem}, a.data::UInt, ctx::Ref{fpMPolyRing})::Nothing return z end end function _gfp_mpoly_clear_fn(a::fpMPolyRingElem) - ccall((:nmod_mpoly_clear, libflint), Nothing, - (Ref{fpMPolyRingElem}, Ref{fpMPolyRing}), - a, a.parent) + @ccall libflint.nmod_mpoly_clear(a::Ref{fpMPolyRingElem}, a.parent::Ref{fpMPolyRing})::Nothing end mutable struct gfp_mpoly_factor @@ -1830,9 +1664,7 @@ mutable struct gfp_mpoly_factor function gfp_mpoly_factor(ctx::fpMPolyRing) z = new() - ccall((:nmod_mpoly_factor_init, libflint), Nothing, - (Ref{gfp_mpoly_factor}, Ref{fpMPolyRing}), - z, ctx) + @ccall libflint.nmod_mpoly_factor_init(z::Ref{gfp_mpoly_factor}, ctx::Ref{fpMPolyRing})::Nothing z.parent = ctx finalizer(_gfp_mpoly_factor_clear_fn, z) return z @@ -1840,9 +1672,7 @@ mutable struct gfp_mpoly_factor end function _gfp_mpoly_factor_clear_fn(f::gfp_mpoly_factor) - ccall((:nmod_mpoly_factor_clear, libflint), Nothing, - (Ref{gfp_mpoly_factor}, Ref{fpMPolyRing}), - f, f.parent) + @ccall libflint.nmod_mpoly_factor_clear(f::Ref{gfp_mpoly_factor}, f.parent::Ref{fpMPolyRing})::Nothing end ################################################################################ @@ -1888,9 +1718,7 @@ end end z = new() - ccall((:fmpz_mod_mpoly_ctx_init, libflint), Nothing, - (Ref{FpMPolyRing}, Int, Cint, Ref{ZZRingElem}), - z, length(s), ord, modulus(R)) + @ccall libflint.fmpz_mod_mpoly_ctx_init(z::Ref{FpMPolyRing}, length(s)::Int, ord::Cint, modulus(R)::Ref{ZZRingElem})::Nothing z.base_ring = R z.S = s finalizer(_gfp_fmpz_mpoly_ctx_clear_fn, z) @@ -1900,8 +1728,7 @@ end end function _gfp_fmpz_mpoly_ctx_clear_fn(a::FpMPolyRing) - ccall((:fmpz_mod_mpoly_ctx_clear, libflint), Nothing, - (Ref{FpMPolyRing},), a) + @ccall libflint.fmpz_mod_mpoly_ctx_clear(a::Ref{FpMPolyRing})::Nothing end const GFPFmpzMPolyID = CacheDictType{Tuple{FpField, Vector{Symbol}, Symbol}, FpMPolyRing}() @@ -1919,9 +1746,7 @@ mutable struct FpMPolyRingElem <: MPolyRingElem{FpFieldElem} function FpMPolyRingElem(ctx::FpMPolyRing) z = new() - ccall((:fmpz_mod_mpoly_init, libflint), Nothing, - (Ref{FpMPolyRingElem}, Ref{FpMPolyRing}), - z, ctx) + @ccall libflint.fmpz_mod_mpoly_init(z::Ref{FpMPolyRingElem}, ctx::Ref{FpMPolyRing})::Nothing z.parent = ctx finalizer(_gfp_fmpz_mpoly_clear_fn, z) return z @@ -1929,21 +1754,15 @@ mutable struct FpMPolyRingElem <: MPolyRingElem{FpFieldElem} function FpMPolyRingElem(ctx::FpMPolyRing, a::Vector{FpFieldElem}, b::Vector{Vector{T}}) where T <: Union{UInt, Int, ZZRingElem} z = new() - ccall((:fmpz_mod_mpoly_init2, libflint), Nothing, - (Ref{FpMPolyRingElem}, Int, Ref{FpMPolyRing}), - z, length(a), ctx) + @ccall libflint.fmpz_mod_mpoly_init2(z::Ref{FpMPolyRingElem}, length(a)::Int, ctx::Ref{FpMPolyRing})::Nothing z.parent = ctx finalizer(_gfp_fmpz_mpoly_clear_fn, z) for i in 1:length(a) if T == ZZRingElem - ccall((:fmpz_mod_mpoly_push_term_fmpz_fmpz, libflint), Nothing, - (Ref{FpMPolyRingElem}, Ref{ZZRingElem}, Ptr{Ref{ZZRingElem}}, Ref{FpMPolyRing}), - z, a[i].data, b[i], ctx) + @ccall libflint.fmpz_mod_mpoly_push_term_fmpz_fmpz(z::Ref{FpMPolyRingElem}, a[i].data::Ref{ZZRingElem}, b[i]::Ptr{Ref{ZZRingElem}}, ctx::Ref{FpMPolyRing})::Nothing else - ccall((:fmpz_mod_mpoly_push_term_fmpz_ui, libflint), Nothing, - (Ref{FpMPolyRingElem}, Ref{ZZRingElem}, Ptr{UInt}, Ref{FpMPolyRing}), - z, a[i].data, b[i], ctx) + @ccall libflint.fmpz_mod_mpoly_push_term_fmpz_ui(z::Ref{FpMPolyRingElem}, a[i].data::Ref{ZZRingElem}, b[i]::Ptr{UInt}, ctx::Ref{FpMPolyRing})::Nothing end end @@ -1954,17 +1773,13 @@ mutable struct FpMPolyRingElem <: MPolyRingElem{FpFieldElem} function FpMPolyRingElem(ctx::FpMPolyRing, a::Union{ZZRingElem, FpFieldElem}) z = FpMPolyRingElem(ctx) - ccall((:fmpz_mod_mpoly_set_fmpz, libflint), Nothing, - (Ref{FpMPolyRingElem}, Ref{ZZRingElem}, Ref{FpMPolyRing}), - z, a isa ZZRingElem ? a : data(a), ctx) + @ccall libflint.fmpz_mod_mpoly_set_fmpz(z::Ref{FpMPolyRingElem}, a isa ZZRingElem ? a : data(a)::Ref{ZZRingElem}, ctx::Ref{FpMPolyRing})::Nothing return z end end function _gfp_fmpz_mpoly_clear_fn(a::FpMPolyRingElem) - ccall((:fmpz_mod_mpoly_clear, libflint), Nothing, - (Ref{FpMPolyRingElem}, Ref{FpMPolyRing}), - a, a.parent) + @ccall libflint.fmpz_mod_mpoly_clear(a::Ref{FpMPolyRingElem}, a.parent::Ref{FpMPolyRing})::Nothing end mutable struct gfp_fmpz_mpoly_factor @@ -1979,9 +1794,7 @@ mutable struct gfp_fmpz_mpoly_factor function gfp_fmpz_mpoly_factor(ctx::FpMPolyRing) z = new() - ccall((:fmpz_mod_mpoly_factor_init, libflint), Nothing, - (Ref{gfp_fmpz_mpoly_factor}, Ref{FpMPolyRing}), - z, ctx) + @ccall libflint.fmpz_mod_mpoly_factor_init(z::Ref{gfp_fmpz_mpoly_factor}, ctx::Ref{FpMPolyRing})::Nothing z.parent = ctx finalizer(_gfp_fmpz_mpoly_factor_clear_fn, z) return z @@ -1989,9 +1802,7 @@ mutable struct gfp_fmpz_mpoly_factor end function _gfp_fmpz_mpoly_factor_clear_fn(f::gfp_fmpz_mpoly_factor) - ccall((:fmpz_mod_mpoly_factor_clear, libflint), Nothing, - (Ref{gfp_fmpz_mpoly_factor}, Ref{FpMPolyRing}), - f, f.parent) + @ccall libflint.fmpz_mod_mpoly_factor_clear(f::Ref{gfp_fmpz_mpoly_factor}, f.parent::Ref{FpMPolyRing})::Nothing end ############################################################################### @@ -2038,9 +1849,7 @@ See [`FqPolyRepField`](@ref) for $p$ being a [`ZZRingElem`](@ref). See [`fqPolyR throw(DomainError(c, "the characteristic must be a prime")) return get_cached!(FqNmodFiniteFieldID, (c, deg, s), cached) do d = new() - ccall((:fq_nmod_ctx_init_ui, libflint), Nothing, - (Ref{fqPolyRepField}, UInt, Int, Ptr{UInt8}), - d, c, deg, string(s)) + @ccall libflint.fq_nmod_ctx_init_ui(d::Ref{fqPolyRepField}, c::UInt, deg::Int, string(s)::Ptr{UInt8})::Nothing finalizer(_FqNmodFiniteField_clear_fn, d) return d end @@ -2055,9 +1864,7 @@ See [`FqPolyRepField`](@ref) for $p$ being a [`ZZRingElem`](@ref). See [`fqPolyR throw(DomainError(base_ring(f), "the base ring of the polynomial must be a field")) return get_cached!(FqNmodFiniteFieldIDNmodPol, (parent(f), f, s), cached) do z = new() - ccall((:fq_nmod_ctx_init_modulus, libflint), Nothing, - (Ref{fqPolyRepField}, Ref{zzModPolyRingElem}, Ptr{UInt8}), - z, f, string(s)) + @ccall libflint.fq_nmod_ctx_init_modulus(z::Ref{fqPolyRepField}, f::Ref{zzModPolyRingElem}, string(s)::Ptr{UInt8})::Nothing finalizer(_FqNmodFiniteField_clear_fn, z) return z end @@ -2067,9 +1874,7 @@ See [`FqPolyRepField`](@ref) for $p$ being a [`ZZRingElem`](@ref). See [`fqPolyR # check ignored return get_cached!(FqNmodFiniteFieldIDGFPPol, (parent(f), f, s), cached) do z = new() - ccall((:fq_nmod_ctx_init_modulus, libflint), Nothing, - (Ref{fqPolyRepField}, Ref{fpPolyRingElem}, Ptr{UInt8}), - z, f, string(s)) + @ccall libflint.fq_nmod_ctx_init_modulus(z::Ref{fqPolyRepField}, f::Ref{fpPolyRingElem}, string(s)::Ptr{UInt8})::Nothing finalizer(_FqNmodFiniteField_clear_fn, z) return z end @@ -2087,7 +1892,7 @@ const FqNmodFiniteFieldIDGFPPol = CacheDictType{Tuple{fpPolyRing, fpPolyRingElem function _FqNmodFiniteField_clear_fn(a :: fqPolyRepField) - ccall((:fq_nmod_ctx_clear, libflint), Nothing, (Ref{fqPolyRepField},), a) + @ccall libflint.fq_nmod_ctx_clear(a::Ref{fqPolyRepField})::Nothing end @doc raw""" @@ -2107,8 +1912,7 @@ mutable struct fqPolyRepFieldElem <: FinFieldElem function fqPolyRepFieldElem(ctx::fqPolyRepField) d = new() - ccall((:fq_nmod_init2, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), d, ctx) + @ccall libflint.fq_nmod_init2(d::Ref{fqPolyRepFieldElem}, ctx::Ref{fqPolyRepField})::Nothing d.parent = ctx finalizer(_fq_nmod_clear_fn, d) return d @@ -2140,8 +1944,7 @@ mutable struct fqPolyRepFieldElem <: FinFieldElem end function _fq_nmod_clear_fn(a::fqPolyRepFieldElem) - ccall((:fq_nmod_clear, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), a, a.parent) + @ccall libflint.fq_nmod_clear(a::Ref{fqPolyRepFieldElem}, a.parent::Ref{fqPolyRepField})::Nothing end ############################################################################### @@ -2188,9 +1991,7 @@ A finite field. The constructor automatically determines a fast implementation. d.isabsolute = true d.isstandard = true finalizer(_FqDefaultFiniteField_clear_fn, d) - ccall((:fq_default_ctx_init, libflint), Nothing, - (Ref{FqField}, Ref{ZZRingElem}, Int, Ptr{UInt8}), - d, char, deg, d.var) + @ccall libflint.fq_default_ctx_init(d::Ref{FqField}, char::Ref{ZZRingElem}, deg::Int, d.var::Ptr{UInt8})::Nothing return d end end @@ -2203,9 +2004,7 @@ A finite field. The constructor automatically determines a fast implementation. z.isabsolute = true z.isstandard = true z.var = string(s) - ccall((:fq_default_ctx_init_modulus, libflint), Nothing, - (Ref{FqField}, Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}, Ptr{UInt8}), - z, f, base_ring(parent(f)).ninv, string(s)) + @ccall libflint.fq_default_ctx_init_modulus(z::Ref{FqField}, f::Ref{ZZModPolyRingElem}, base_ring(parent(f)).ninv::Ref{fmpz_mod_ctx_struct}, string(s)::Ptr{UInt8})::Nothing finalizer(_FqDefaultFiniteField_clear_fn, z) return z end @@ -2218,9 +2017,7 @@ A finite field. The constructor automatically determines a fast implementation. z.isabsolute = true z.isstandard = true z.var = string(s) - ccall((:fq_default_ctx_init_modulus, libflint), Nothing, - (Ref{FqField}, Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}, Ptr{UInt8}), - z, f, base_ring(parent(f)).ninv, string(s)) + @ccall libflint.fq_default_ctx_init_modulus(z::Ref{FqField}, f::Ref{FpPolyRingElem}, base_ring(parent(f)).ninv::Ref{fmpz_mod_ctx_struct}, string(s)::Ptr{UInt8})::Nothing finalizer(_FqDefaultFiniteField_clear_fn, z) return z end @@ -2234,9 +2031,7 @@ A finite field. The constructor automatically determines a fast implementation. z.isabsolute = true z.isstandard = true z.var = string(s) - ccall((:fq_default_ctx_init_modulus_nmod, libflint), Nothing, - (Ref{FqField}, Ref{zzModPolyRingElem}, Ptr{UInt8}), - z, f, string(s)) + @ccall libflint.fq_default_ctx_init_modulus_nmod(z::Ref{FqField}, f::Ref{zzModPolyRingElem}, string(s)::Ptr{UInt8})::Nothing finalizer(_FqDefaultFiniteField_clear_fn, z) return z end @@ -2249,9 +2044,7 @@ A finite field. The constructor automatically determines a fast implementation. z.isabsolute = true z.isstandard = true z.var = string(s) - ccall((:fq_default_ctx_init_modulus_nmod, libflint), Nothing, - (Ref{FqField}, Ref{fpPolyRingElem}, Ptr{UInt8}), - z, f, string(s)) + @ccall libflint.fq_default_ctx_init_modulus_nmod(z::Ref{FqField}, f::Ref{fpPolyRingElem}, string(s)::Ptr{UInt8})::Nothing finalizer(_FqDefaultFiniteField_clear_fn, z) return z end @@ -2269,7 +2062,7 @@ const FqDefaultFiniteFieldIDNmodPol = CacheDictType{Tuple{zzModPolyRingElem, Sym const FqDefaultFiniteFieldIDGFPNmodPol = CacheDictType{Tuple{fpPolyRingElem, Symbol}, FqField}() function _FqDefaultFiniteField_clear_fn(a :: FqField) - ccall((:fq_default_ctx_clear, libflint), Nothing, (Ref{FqField},), a) + @ccall libflint.fq_default_ctx_clear(a::Ref{FqField})::Nothing end @doc raw""" @@ -2284,8 +2077,7 @@ mutable struct FqFieldElem <: FinFieldElem function FqFieldElem(ctx::FqField) d = new() - ccall((:fq_default_init2, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqField}), d, ctx) + @ccall libflint.fq_default_init2(d::Ref{FqFieldElem}, ctx::Ref{FqField})::Nothing if _fq_default_ctx_type(ctx) != _FQ_DEFAULT_NMOD finalizer(_fq_default_clear_fn, d) end @@ -2311,8 +2103,7 @@ mutable struct FqFieldElem <: FinFieldElem end function _fq_default_clear_fn(a::FqFieldElem) - ccall((:fq_default_clear, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqField}), a, a.parent) + @ccall libflint.fq_default_clear(a::Ref{FqFieldElem}, a.parent::Ref{FqField})::Nothing end ############################################################################### @@ -2362,9 +2153,7 @@ See [`fqPolyRepField`](@ref) for $p$ being an [`Int`](@ref). See [`FqPolyRepFiel return get_cached!(FqFiniteFieldID, (char, deg, s), cached) do d = new() finalizer(_FqFiniteField_clear_fn, d) - ccall((:fq_ctx_init, libflint), Nothing, - (Ref{FqPolyRepField}, Ref{ZZRingElem}, Int, Ptr{UInt8}), - d, char, deg, string(s)) + @ccall libflint.fq_ctx_init(d::Ref{FqPolyRepField}, char::Ref{ZZRingElem}, deg::Int, string(s)::Ptr{UInt8})::Nothing return d end end @@ -2374,9 +2163,7 @@ See [`fqPolyRepField`](@ref) for $p$ being an [`Int`](@ref). See [`FqPolyRepFiel throw(DomainError(base_ring(f), "the base ring of the polynomial must be a field")) return get_cached!(FqFiniteFieldIDFmpzPol, (f, s), cached) do z = new() - ccall((:fq_ctx_init_modulus, libflint), Nothing, - (Ref{FqPolyRepField}, Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}, Ptr{UInt8}), - z, f, base_ring(parent(f)).ninv, string(s)) + @ccall libflint.fq_ctx_init_modulus(z::Ref{FqPolyRepField}, f::Ref{ZZModPolyRingElem}, base_ring(parent(f)).ninv::Ref{fmpz_mod_ctx_struct}, string(s)::Ptr{UInt8})::Nothing finalizer(_FqFiniteField_clear_fn, z) return z end @@ -2386,9 +2173,7 @@ See [`fqPolyRepField`](@ref) for $p$ being an [`Int`](@ref). See [`FqPolyRepFiel # check ignored return get_cached!(FqFiniteFieldIDGFPPol, (f, s), cached) do z = new() - ccall((:fq_ctx_init_modulus, libflint), Nothing, - (Ref{FqPolyRepField}, Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}, Ptr{UInt8}), - z, f, base_ring(parent(f)).ninv, string(s)) + @ccall libflint.fq_ctx_init_modulus(z::Ref{FqPolyRepField}, f::Ref{FpPolyRingElem}, base_ring(parent(f)).ninv::Ref{fmpz_mod_ctx_struct}, string(s)::Ptr{UInt8})::Nothing finalizer(_FqFiniteField_clear_fn, z) return z end @@ -2403,7 +2188,7 @@ const FqFiniteFieldIDFmpzPol = CacheDictType{Tuple{ZZModPolyRingElem, Symbol}, F const FqFiniteFieldIDGFPPol = CacheDictType{Tuple{FpPolyRingElem, Symbol}, FqPolyRepField}() function _FqFiniteField_clear_fn(a :: FqPolyRepField) - ccall((:fq_ctx_clear, libflint), Nothing, (Ref{FqPolyRepField},), a) + @ccall libflint.fq_ctx_clear(a::Ref{FqPolyRepField})::Nothing end @doc raw""" @@ -2420,8 +2205,7 @@ mutable struct FqPolyRepFieldElem <: FinFieldElem function FqPolyRepFieldElem(ctx::FqPolyRepField) d = new() - ccall((:fq_init2, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), d, ctx) + @ccall libflint.fq_init2(d::Ref{FqPolyRepFieldElem}, ctx::Ref{FqPolyRepField})::Nothing finalizer(_fq_clear_fn, d) d.parent = ctx return d @@ -2443,8 +2227,7 @@ mutable struct FqPolyRepFieldElem <: FinFieldElem end function _fq_clear_fn(a::FqPolyRepFieldElem) - ccall((:fq_clear, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), a, a.parent) + @ccall libflint.fq_clear(a::Ref{FqPolyRepFieldElem}, a.parent::Ref{FqPolyRepField})::Nothing end @@ -2503,9 +2286,7 @@ end end z = new() - ccall((:fq_nmod_mpoly_ctx_init, libflint), Nothing, - (Ref{fqPolyRepMPolyRing}, Int, Cint, Ref{fqPolyRepField}), - z, length(s), ord, R) + @ccall libflint.fq_nmod_mpoly_ctx_init(z::Ref{fqPolyRepMPolyRing}, length(s)::Int, ord::Cint, R::Ref{fqPolyRepField})::Nothing z.base_ring = R z.S = s finalizer(_fq_nmod_mpoly_ctx_clear_fn, z) @@ -2515,8 +2296,7 @@ end end function _fq_nmod_mpoly_ctx_clear_fn(a::fqPolyRepMPolyRing) - ccall((:fq_nmod_mpoly_ctx_clear, libflint), Nothing, - (Ref{fqPolyRepMPolyRing},), a) + @ccall libflint.fq_nmod_mpoly_ctx_clear(a::Ref{fqPolyRepMPolyRing})::Nothing end const FqNmodMPolyID = CacheDictType{Tuple{fqPolyRepField, Vector{Symbol}, Symbol}, fqPolyRepMPolyRing}() @@ -2534,8 +2314,7 @@ mutable struct fqPolyRepMPolyRingElem <: MPolyRingElem{fqPolyRepFieldElem} function fqPolyRepMPolyRingElem(ctx::fqPolyRepMPolyRing) z = new() - ccall((:fq_nmod_mpoly_init, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing},), z, ctx) + @ccall libflint.fq_nmod_mpoly_init(z::Ref{fqPolyRepMPolyRingElem}, ctx::Ref{fqPolyRepMPolyRing})::Nothing z.parent = ctx finalizer(_fq_nmod_mpoly_clear_fn, z) return z @@ -2543,15 +2322,12 @@ mutable struct fqPolyRepMPolyRingElem <: MPolyRingElem{fqPolyRepFieldElem} function fqPolyRepMPolyRingElem(ctx::fqPolyRepMPolyRing, a::Vector{fqPolyRepFieldElem}, b::Vector{Vector{UInt}}) z = new() - ccall((:fq_nmod_mpoly_init2, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing},), z, length(a), ctx) + @ccall libflint.fq_nmod_mpoly_init2(z::Ref{fqPolyRepMPolyRingElem}, length(a)::Int, ctx::Ref{fqPolyRepMPolyRing})::Nothing z.parent = ctx finalizer(_fq_nmod_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:fq_nmod_mpoly_push_term_fq_nmod_ui, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepFieldElem}, Ptr{UInt}, Ref{fqPolyRepMPolyRing}), - z, a[i], b[i], ctx) + @ccall libflint.fq_nmod_mpoly_push_term_fq_nmod_ui(z::Ref{fqPolyRepMPolyRingElem}, a[i]::Ref{fqPolyRepFieldElem}, b[i]::Ptr{UInt}, ctx::Ref{fqPolyRepMPolyRing})::Nothing end sort_terms!(z) @@ -2561,15 +2337,12 @@ mutable struct fqPolyRepMPolyRingElem <: MPolyRingElem{fqPolyRepFieldElem} function fqPolyRepMPolyRingElem(ctx::fqPolyRepMPolyRing, a::Vector{fqPolyRepFieldElem}, b::Vector{Vector{Int}}) z = new() - ccall((:fq_nmod_mpoly_init2, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing},), z, length(a), ctx) + @ccall libflint.fq_nmod_mpoly_init2(z::Ref{fqPolyRepMPolyRingElem}, length(a)::Int, ctx::Ref{fqPolyRepMPolyRing})::Nothing z.parent = ctx finalizer(_fq_nmod_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:fq_nmod_mpoly_push_term_fq_nmod_ui, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepFieldElem}, Ptr{Int}, Ref{fqPolyRepMPolyRing}), - z, a[i], b[i], ctx) + @ccall libflint.fq_nmod_mpoly_push_term_fq_nmod_ui(z::Ref{fqPolyRepMPolyRingElem}, a[i]::Ref{fqPolyRepFieldElem}, b[i]::Ptr{Int}, ctx::Ref{fqPolyRepMPolyRing})::Nothing end sort_terms!(z) @@ -2579,15 +2352,12 @@ mutable struct fqPolyRepMPolyRingElem <: MPolyRingElem{fqPolyRepFieldElem} function fqPolyRepMPolyRingElem(ctx::fqPolyRepMPolyRing, a::Vector{fqPolyRepFieldElem}, b::Vector{Vector{ZZRingElem}}) z = new() - ccall((:fq_nmod_mpoly_init2, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing},), z, length(a), ctx) + @ccall libflint.fq_nmod_mpoly_init2(z::Ref{fqPolyRepMPolyRingElem}, length(a)::Int, ctx::Ref{fqPolyRepMPolyRing})::Nothing z.parent = ctx finalizer(_fq_nmod_mpoly_clear_fn, z) for i in 1:length(a) - ccall((:fq_nmod_mpoly_push_term_fq_nmod_fmpz, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepFieldElem}, Ptr{Ref{ZZRingElem}}, Ref{fqPolyRepMPolyRing}), - z, a[i], b[i], ctx) + @ccall libflint.fq_nmod_mpoly_push_term_fq_nmod_fmpz(z::Ref{fqPolyRepMPolyRingElem}, a[i]::Ref{fqPolyRepFieldElem}, b[i]::Ptr{Ref{ZZRingElem}}, ctx::Ref{fqPolyRepMPolyRing})::Nothing end sort_terms!(z) @@ -2597,8 +2367,7 @@ mutable struct fqPolyRepMPolyRingElem <: MPolyRingElem{fqPolyRepFieldElem} function fqPolyRepMPolyRingElem(ctx::fqPolyRepMPolyRing, a::UInt) z = fqPolyRepMPolyRingElem(ctx) - ccall((:fq_nmod_mpoly_set_ui, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, UInt, Ref{fqPolyRepMPolyRing}), z, a, ctx) + @ccall libflint.fq_nmod_mpoly_set_ui(z::Ref{fqPolyRepMPolyRingElem}, a::UInt, ctx::Ref{fqPolyRepMPolyRing})::Nothing return z end @@ -2608,15 +2377,13 @@ mutable struct fqPolyRepMPolyRingElem <: MPolyRingElem{fqPolyRepFieldElem} function fqPolyRepMPolyRingElem(ctx::fqPolyRepMPolyRing, a::fqPolyRepFieldElem) z = fqPolyRepMPolyRingElem(ctx) - ccall((:fq_nmod_mpoly_set_fq_nmod, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepMPolyRing}), z, a, ctx) + @ccall libflint.fq_nmod_mpoly_set_fq_nmod(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepFieldElem}, ctx::Ref{fqPolyRepMPolyRing})::Nothing return z end end function _fq_nmod_mpoly_clear_fn(a::fqPolyRepMPolyRingElem) - ccall((:fq_nmod_mpoly_clear, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), a, a.parent) + @ccall libflint.fq_nmod_mpoly_clear(a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing end mutable struct fq_nmod_mpoly_factor @@ -2637,9 +2404,7 @@ mutable struct fq_nmod_mpoly_factor function fq_nmod_mpoly_factor(ctx::fqPolyRepMPolyRing) z = new() - ccall((:fq_nmod_mpoly_factor_init, libflint), Nothing, - (Ref{fq_nmod_mpoly_factor}, Ref{fqPolyRepMPolyRing}), - z, ctx) + @ccall libflint.fq_nmod_mpoly_factor_init(z::Ref{fq_nmod_mpoly_factor}, ctx::Ref{fqPolyRepMPolyRing})::Nothing z.parent = ctx finalizer(_fq_nmod_mpoly_factor_clear_fn, z) return z @@ -2647,9 +2412,7 @@ mutable struct fq_nmod_mpoly_factor end function _fq_nmod_mpoly_factor_clear_fn(f::fq_nmod_mpoly_factor) - ccall((:fq_nmod_mpoly_factor_clear, libflint), Nothing, - (Ref{fq_nmod_mpoly_factor}, Ref{fqPolyRepMPolyRing}), - f, f.parent) + @ccall libflint.fq_nmod_mpoly_factor_clear(f::Ref{fq_nmod_mpoly_factor}, f.parent::Ref{fqPolyRepMPolyRing})::Nothing end ############################################################################### @@ -2698,9 +2461,7 @@ A $p$-adic field for some prime $p$. Qp = get_cached!(PadicBase, p, cached) do d = new() - ccall((:padic_ctx_init, libflint), Nothing, - (Ref{PadicField}, Ref{ZZRingElem}, Int, Int, Cint), - d, p, 0, 0, 0) + @ccall libflint.padic_ctx_init(d::Ref{PadicField}, p::Ref{ZZRingElem}, 0::Int, 0::Int, 0::Cint)::Nothing finalizer(_padic_ctx_clear_fn, d) return d end @@ -2712,7 +2473,7 @@ end const PadicBase = CacheDictType{ZZRingElem, PadicField}() function _padic_ctx_clear_fn(a::PadicField) - ccall((:padic_ctx_clear, libflint), Nothing, (Ref{PadicField},), a) + @ccall libflint.padic_ctx_clear(a::Ref{PadicField})::Nothing end @doc raw""" @@ -2728,14 +2489,14 @@ mutable struct PadicFieldElem <: FlintLocalFieldElem function PadicFieldElem(prec::Int) d = new() - ccall((:padic_init2, libflint), Nothing, (Ref{PadicFieldElem}, Int), d, prec) + @ccall libflint.padic_init2(d::Ref{PadicFieldElem}, prec::Int)::Nothing finalizer(_padic_clear_fn, d) return d end end function _padic_clear_fn(a::PadicFieldElem) - ccall((:padic_clear, libflint), Nothing, (Ref{PadicFieldElem},), a) + @ccall libflint.padic_clear(a::Ref{PadicFieldElem})::Nothing end ############################################################################### @@ -2769,9 +2530,7 @@ A $p^n$-adic field for some prime power $p^n$. z = get_cached!(QadicBase, (base_field, d), cached) do zz = new() - ccall((:qadic_ctx_init, libflint), Nothing, - (Ref{QadicField}, Ref{ZZRingElem}, Int, Int, Int, Cstring, Cint), - zz, p, d, 0, 0, var, 0) + @ccall libflint.qadic_ctx_init(zz::Ref{QadicField}, p::Ref{ZZRingElem}, d::Int, 0::Int, 0::Int, var::Cstring, 0::Cint)::Nothing finalizer(_qadic_ctx_clear_fn, zz) return zz end @@ -2785,7 +2544,7 @@ end const QadicBase = CacheDictType{Tuple{PadicField, Int}, QadicField}() function _qadic_ctx_clear_fn(a::QadicField) - ccall((:qadic_ctx_clear, libflint), Nothing, (Ref{QadicField},), a) + @ccall libflint.qadic_ctx_clear(a::Ref{QadicField})::Nothing end @doc raw""" @@ -2803,14 +2562,14 @@ mutable struct QadicFieldElem <: FlintLocalFieldElem function QadicFieldElem(prec::Int) z = new() - ccall((:qadic_init2, libflint), Nothing, (Ref{QadicFieldElem}, Int), z, prec) + @ccall libflint.qadic_init2(z::Ref{QadicFieldElem}, prec::Int)::Nothing finalizer(_qadic_clear_fn, z) return z end end function _qadic_clear_fn(a::QadicFieldElem) - ccall((:qadic_clear, libflint), Nothing, (Ref{QadicFieldElem},), a) + @ccall libflint.qadic_clear(a::Ref{QadicFieldElem})::Nothing end ############################################################################### @@ -2844,19 +2603,16 @@ mutable struct ZZRelPowerSeriesRingElem <: RelPowerSeriesRingElem{ZZRingElem} function ZZRelPowerSeriesRingElem() z = new() - ccall((:fmpz_poly_init, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem},), z) + @ccall libflint.fmpz_poly_init(z::Ref{ZZRelPowerSeriesRingElem})::Nothing finalizer(_fmpz_rel_series_clear_fn, z) return z end function ZZRelPowerSeriesRingElem(a::Vector{ZZRingElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:fmpz_poly_init2, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Int), z, len) + @ccall libflint.fmpz_poly_init2(z::Ref{ZZRelPowerSeriesRingElem}, len::Int)::Nothing for i = 1:len - ccall((:fmpz_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Int, Ref{ZZRingElem}), z, i - 1, a[i]) + @ccall libflint.fmpz_poly_set_coeff_fmpz(z::Ref{ZZRelPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{ZZRingElem})::Nothing end z.prec = prec z.val = val @@ -2866,14 +2622,13 @@ mutable struct ZZRelPowerSeriesRingElem <: RelPowerSeriesRingElem{ZZRingElem} function ZZRelPowerSeriesRingElem(a::ZZRelPowerSeriesRingElem) z = ZZRelPowerSeriesRingElem() - ccall((:fmpz_poly_set, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}), z, a) + @ccall libflint.fmpz_poly_set(z::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem})::Nothing return z end end function _fmpz_rel_series_clear_fn(a::ZZRelPowerSeriesRingElem) - ccall((:fmpz_poly_clear, libflint), Nothing, (Ref{ZZRelPowerSeriesRingElem},), a) + @ccall libflint.fmpz_poly_clear(a::Ref{ZZRelPowerSeriesRingElem})::Nothing end ############################################################################### @@ -2904,19 +2659,16 @@ mutable struct ZZAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{ZZRingElem} function ZZAbsPowerSeriesRingElem() z = new() - ccall((:fmpz_poly_init, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem},), z) + @ccall libflint.fmpz_poly_init(z::Ref{ZZAbsPowerSeriesRingElem})::Nothing finalizer(_fmpz_abs_series_clear_fn, z) return z end function ZZAbsPowerSeriesRingElem(a::Vector{ZZRingElem}, len::Int, prec::Int) z = new() - ccall((:fmpz_poly_init2, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Int), z, len) + @ccall libflint.fmpz_poly_init2(z::Ref{ZZAbsPowerSeriesRingElem}, len::Int)::Nothing for i = 1:len - ccall((:fmpz_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Int, Ref{ZZRingElem}), z, i - 1, a[i]) + @ccall libflint.fmpz_poly_set_coeff_fmpz(z::Ref{ZZAbsPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{ZZRingElem})::Nothing end z.prec = prec finalizer(_fmpz_abs_series_clear_fn, z) @@ -2925,14 +2677,13 @@ mutable struct ZZAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{ZZRingElem} function ZZAbsPowerSeriesRingElem(a::ZZAbsPowerSeriesRingElem) z = ZZAbsPowerSeriesRingElem() - ccall((:fmpz_poly_set, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}), z, a) + @ccall libflint.fmpz_poly_set(z::Ref{ZZAbsPowerSeriesRingElem}, a::Ref{ZZAbsPowerSeriesRingElem})::Nothing return z end end function _fmpz_abs_series_clear_fn(a::ZZAbsPowerSeriesRingElem) - ccall((:fmpz_poly_clear, libflint), Nothing, (Ref{ZZAbsPowerSeriesRingElem},), a) + @ccall libflint.fmpz_poly_clear(a::Ref{ZZAbsPowerSeriesRingElem})::Nothing end ############################################################################### @@ -3019,19 +2770,16 @@ mutable struct ZZLaurentSeriesRingElem <: RingElem function ZZLaurentSeriesRingElem() z = new() - ccall((:fmpz_poly_init, libflint), Nothing, - (Ref{ZZLaurentSeriesRingElem},), z) + @ccall libflint.fmpz_poly_init(z::Ref{ZZLaurentSeriesRingElem})::Nothing finalizer(_fmpz_laurent_series_clear_fn, z) return z end function ZZLaurentSeriesRingElem(a::Vector{ZZRingElem}, len::Int, prec::Int, val::Int, scale::Int) z = new() - ccall((:fmpz_poly_init2, libflint), Nothing, - (Ref{ZZLaurentSeriesRingElem}, Int), z, len) + @ccall libflint.fmpz_poly_init2(z::Ref{ZZLaurentSeriesRingElem}, len::Int)::Nothing for i = 1:len - ccall((:fmpz_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZLaurentSeriesRingElem}, Int, Ref{ZZRingElem}), z, i - 1, a[i]) + @ccall libflint.fmpz_poly_set_coeff_fmpz(z::Ref{ZZLaurentSeriesRingElem}, (i - 1)::Int, a[i]::Ref{ZZRingElem})::Nothing end z.prec = prec z.val = val @@ -3042,14 +2790,13 @@ mutable struct ZZLaurentSeriesRingElem <: RingElem function ZZLaurentSeriesRingElem(a::ZZLaurentSeriesRingElem) z = ZZLaurentSeriesRingElem() - ccall((:fmpz_poly_set, libflint), Nothing, - (Ref{ZZLaurentSeriesRingElem}, Ref{ZZLaurentSeriesRingElem}), z, a) + @ccall libflint.fmpz_poly_set(z::Ref{ZZLaurentSeriesRingElem}, a::Ref{ZZLaurentSeriesRingElem})::Nothing return z end end function _fmpz_laurent_series_clear_fn(a::ZZLaurentSeriesRingElem) - ccall((:fmpz_poly_clear, libflint), Nothing, (Ref{ZZLaurentSeriesRingElem},), a) + @ccall libflint.fmpz_poly_clear(a::Ref{ZZLaurentSeriesRingElem})::Nothing end ############################################################################### @@ -3084,19 +2831,16 @@ mutable struct QQRelPowerSeriesRingElem <: RelPowerSeriesRingElem{QQFieldElem} function QQRelPowerSeriesRingElem() z = new() - ccall((:fmpq_poly_init, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem},), z) + @ccall libflint.fmpq_poly_init(z::Ref{QQRelPowerSeriesRingElem})::Nothing finalizer(_fmpq_rel_series_clear_fn, z) return z end function QQRelPowerSeriesRingElem(a::Vector{QQFieldElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:fmpq_poly_init2, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Int), z, len) + @ccall libflint.fmpq_poly_init2(z::Ref{QQRelPowerSeriesRingElem}, len::Int)::Nothing for i = 1:len - ccall((:fmpq_poly_set_coeff_fmpq, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Int, Ref{QQFieldElem}), z, i - 1, a[i]) + @ccall libflint.fmpq_poly_set_coeff_fmpq(z::Ref{QQRelPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{QQFieldElem})::Nothing end z.prec = prec z.val = val @@ -3106,14 +2850,13 @@ mutable struct QQRelPowerSeriesRingElem <: RelPowerSeriesRingElem{QQFieldElem} function QQRelPowerSeriesRingElem(a::QQRelPowerSeriesRingElem) z = QQRelPowerSeriesRingElem() - ccall((:fmpq_poly_set, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}), z, a) + @ccall libflint.fmpq_poly_set(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem})::Nothing return z end end function _fmpq_rel_series_clear_fn(a::QQRelPowerSeriesRingElem) - ccall((:fmpq_poly_clear, libflint), Nothing, (Ref{QQRelPowerSeriesRingElem},), a) + @ccall libflint.fmpq_poly_clear(a::Ref{QQRelPowerSeriesRingElem})::Nothing end ############################################################################### @@ -3147,19 +2890,16 @@ mutable struct QQAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{QQFieldElem} function QQAbsPowerSeriesRingElem() z = new() - ccall((:fmpq_poly_init, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem},), z) + @ccall libflint.fmpq_poly_init(z::Ref{QQAbsPowerSeriesRingElem})::Nothing finalizer(_fmpq_abs_series_clear_fn, z) return z end function QQAbsPowerSeriesRingElem(a::Vector{QQFieldElem}, len::Int, prec::Int) z = new() - ccall((:fmpq_poly_init2, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Int), z, len) + @ccall libflint.fmpq_poly_init2(z::Ref{QQAbsPowerSeriesRingElem}, len::Int)::Nothing for i = 1:len - ccall((:fmpq_poly_set_coeff_fmpq, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Int, Ref{QQFieldElem}), z, i - 1, a[i]) + @ccall libflint.fmpq_poly_set_coeff_fmpq(z::Ref{QQAbsPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{QQFieldElem})::Nothing end z.prec = prec finalizer(_fmpq_abs_series_clear_fn, z) @@ -3168,14 +2908,13 @@ mutable struct QQAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{QQFieldElem} function QQAbsPowerSeriesRingElem(a::QQAbsPowerSeriesRingElem) z = QQAbsPowerSeriesRingElem() - ccall((:fmpq_poly_set, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}), z, a) + @ccall libflint.fmpq_poly_set(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem})::Nothing return z end end function _fmpq_abs_series_clear_fn(a::QQAbsPowerSeriesRingElem) - ccall((:fmpq_poly_clear, libflint), Nothing, (Ref{QQAbsPowerSeriesRingElem},), a) + @ccall libflint.fmpq_poly_clear(a::Ref{QQAbsPowerSeriesRingElem})::Nothing end ############################################################################### @@ -3213,21 +2952,17 @@ mutable struct fpRelPowerSeriesRingElem <: RelPowerSeriesRingElem{fpFieldElem} function fpRelPowerSeriesRingElem(p::UInt) z = new() - ccall((:nmod_poly_init, libflint), Nothing, - (Ref{fpRelPowerSeriesRingElem}, UInt), z, p) + @ccall libflint.nmod_poly_init(z::Ref{fpRelPowerSeriesRingElem}, p::UInt)::Nothing finalizer(_gfp_rel_series_clear_fn, z) return z end function fpRelPowerSeriesRingElem(p::UInt, a::Vector{ZZRingElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{fpRelPowerSeriesRingElem}, UInt, Int), z, p, len) + @ccall libflint.nmod_poly_init2(z::Ref{fpRelPowerSeriesRingElem}, p::UInt, len::Int)::Nothing for i = 1:len - tt = ccall((:fmpz_fdiv_ui, libflint), UInt, - (Ref{ZZRingElem}, UInt), a[i], p) - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{fpRelPowerSeriesRingElem}, Int, UInt), z, i - 1, tt) + tt = @ccall libflint.fmpz_fdiv_ui(a[i]::Ref{ZZRingElem}, p::UInt)::UInt + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{fpRelPowerSeriesRingElem}, (i - 1)::Int, tt::UInt)::Nothing end z.prec = prec z.val = val @@ -3237,11 +2972,9 @@ mutable struct fpRelPowerSeriesRingElem <: RelPowerSeriesRingElem{fpFieldElem} function fpRelPowerSeriesRingElem(p::UInt, a::Vector{UInt}, len::Int, prec::Int, val::Int) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{fpRelPowerSeriesRingElem}, UInt, Int), z, p, len) + @ccall libflint.nmod_poly_init2(z::Ref{fpRelPowerSeriesRingElem}, p::UInt, len::Int)::Nothing for i = 1:len - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{fpRelPowerSeriesRingElem}, Int, UInt), z, i - 1, a[i]) + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{fpRelPowerSeriesRingElem}, (i - 1)::Int, a[i]::UInt)::Nothing end z.prec = prec z.val = val @@ -3251,11 +2984,9 @@ mutable struct fpRelPowerSeriesRingElem <: RelPowerSeriesRingElem{fpFieldElem} function fpRelPowerSeriesRingElem(p::UInt, a::Vector{fpFieldElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{fpRelPowerSeriesRingElem}, UInt, Int), z, p, len) + @ccall libflint.nmod_poly_init2(z::Ref{fpRelPowerSeriesRingElem}, p::UInt, len::Int)::Nothing for i = 1:len - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{fpRelPowerSeriesRingElem}, Int, UInt), z, i - 1, data(a[i])) + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{fpRelPowerSeriesRingElem}, (i - 1)::Int, data(a[i])::UInt)::Nothing end z.prec = prec z.val = val @@ -3266,8 +2997,7 @@ mutable struct fpRelPowerSeriesRingElem <: RelPowerSeriesRingElem{fpFieldElem} function fpRelPowerSeriesRingElem(a::fpRelPowerSeriesRingElem) p = modulus(base_ring(parent(a))) z = fpRelPowerSeriesRingElem(p) - ccall((:nmod_poly_set, libflint), Nothing, - (Ref{fpRelPowerSeriesRingElem}, Ref{fpRelPowerSeriesRingElem}), z, a) + @ccall libflint.nmod_poly_set(z::Ref{fpRelPowerSeriesRingElem}, a::Ref{fpRelPowerSeriesRingElem})::Nothing if isdefined(a, :parent) z.parent = a.parent end @@ -3276,7 +3006,7 @@ mutable struct fpRelPowerSeriesRingElem <: RelPowerSeriesRingElem{fpFieldElem} end function _gfp_rel_series_clear_fn(a::fpRelPowerSeriesRingElem) - ccall((:nmod_poly_clear, libflint), Nothing, (Ref{fpRelPowerSeriesRingElem},), a) + @ccall libflint.nmod_poly_clear(a::Ref{fpRelPowerSeriesRingElem})::Nothing end ############################################################################### @@ -3314,20 +3044,17 @@ mutable struct zzModRelPowerSeriesRingElem <: RelPowerSeriesRingElem{zzModRingEl function zzModRelPowerSeriesRingElem(p::UInt) z = new() - ccall((:nmod_poly_init, libflint), Nothing, - (Ref{zzModRelPowerSeriesRingElem}, UInt), z, p) + @ccall libflint.nmod_poly_init(z::Ref{zzModRelPowerSeriesRingElem}, p::UInt)::Nothing finalizer(_nmod_rel_series_clear_fn, z) return z end function zzModRelPowerSeriesRingElem(p::UInt, a::Vector{ZZRingElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{zzModRelPowerSeriesRingElem}, UInt, Int), z, p, len) + @ccall libflint.nmod_poly_init2(z::Ref{zzModRelPowerSeriesRingElem}, p::UInt, len::Int)::Nothing for i = 1:len - tt = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), a[i], p) - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{zzModRelPowerSeriesRingElem}, Int, UInt), z, i - 1, tt) + tt = @ccall libflint.fmpz_fdiv_ui(a[i]::Ref{ZZRingElem}, p::UInt)::UInt + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{zzModRelPowerSeriesRingElem}, (i - 1)::Int, tt::UInt)::Nothing end z.prec = prec z.val = val @@ -3337,11 +3064,9 @@ mutable struct zzModRelPowerSeriesRingElem <: RelPowerSeriesRingElem{zzModRingEl function zzModRelPowerSeriesRingElem(p::UInt, a::Vector{UInt}, len::Int, prec::Int, val::Int) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{zzModRelPowerSeriesRingElem}, UInt, Int), z, p, len) + @ccall libflint.nmod_poly_init2(z::Ref{zzModRelPowerSeriesRingElem}, p::UInt, len::Int)::Nothing for i = 1:len - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{zzModRelPowerSeriesRingElem}, Int, UInt), z, i - 1, a[i]) + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{zzModRelPowerSeriesRingElem}, (i - 1)::Int, a[i]::UInt)::Nothing end z.prec = prec z.val = val @@ -3351,11 +3076,9 @@ mutable struct zzModRelPowerSeriesRingElem <: RelPowerSeriesRingElem{zzModRingEl function zzModRelPowerSeriesRingElem(p::UInt, a::Vector{zzModRingElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{zzModRelPowerSeriesRingElem}, UInt, Int), z, p, len) + @ccall libflint.nmod_poly_init2(z::Ref{zzModRelPowerSeriesRingElem}, p::UInt, len::Int)::Nothing for i = 1:len - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{zzModRelPowerSeriesRingElem}, Int, UInt), z, i - 1, data(a[i])) + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{zzModRelPowerSeriesRingElem}, (i - 1)::Int, data(a[i])::UInt)::Nothing end z.prec = prec z.val = val @@ -3366,8 +3089,7 @@ mutable struct zzModRelPowerSeriesRingElem <: RelPowerSeriesRingElem{zzModRingEl function zzModRelPowerSeriesRingElem(a::zzModRelPowerSeriesRingElem) p = modulus(base_ring(parent(a))) z = zzModRelPowerSeriesRingElem(p) - ccall((:nmod_poly_set, libflint), Nothing, - (Ref{zzModRelPowerSeriesRingElem}, Ref{zzModRelPowerSeriesRingElem}), z, a) + @ccall libflint.nmod_poly_set(z::Ref{zzModRelPowerSeriesRingElem}, a::Ref{zzModRelPowerSeriesRingElem})::Nothing if isdefined(a, :parent) z.parent = a.parent end @@ -3376,7 +3098,7 @@ mutable struct zzModRelPowerSeriesRingElem <: RelPowerSeriesRingElem{zzModRingEl end function _nmod_rel_series_clear_fn(a::zzModRelPowerSeriesRingElem) - ccall((:nmod_poly_clear, libflint), Nothing, (Ref{zzModRelPowerSeriesRingElem},), a) + @ccall libflint.nmod_poly_clear(a::Ref{zzModRelPowerSeriesRingElem})::Nothing end ############################################################################### @@ -3413,9 +3135,7 @@ mutable struct FpRelPowerSeriesRingElem <: RelPowerSeriesRingElem{FpFieldElem} function FpRelPowerSeriesRingElem(p::fmpz_mod_ctx_struct) z = new() - ccall((:fmpz_mod_poly_init, libflint), Nothing, - (Ref{FpRelPowerSeriesRingElem}, Ref{fmpz_mod_ctx_struct}), - z, p) + @ccall libflint.fmpz_mod_poly_init(z::Ref{FpRelPowerSeriesRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_gfp_fmpz_rel_series_clear_fn, z) return z end @@ -3427,14 +3147,9 @@ mutable struct FpRelPowerSeriesRingElem <: RelPowerSeriesRingElem{FpFieldElem} function FpRelPowerSeriesRingElem(p::fmpz_mod_ctx_struct, a::Vector{ZZRingElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{FpRelPowerSeriesRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, len, p) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{FpRelPowerSeriesRingElem}, len::Int, p::Ref{fmpz_mod_ctx_struct})::Nothing for i = 1:len - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{FpRelPowerSeriesRingElem}, Int, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, i - 1, a[i], p) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{FpRelPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{ZZRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing end z.prec = prec z.val = val @@ -3450,14 +3165,9 @@ mutable struct FpRelPowerSeriesRingElem <: RelPowerSeriesRingElem{FpFieldElem} function FpRelPowerSeriesRingElem(p::fmpz_mod_ctx_struct, a::Vector{FpFieldElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{FpRelPowerSeriesRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, len, p) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{FpRelPowerSeriesRingElem}, len::Int, p::Ref{fmpz_mod_ctx_struct})::Nothing for i = 1:len - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{FpRelPowerSeriesRingElem}, Int, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, i - 1, data(a[i]), p) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{FpRelPowerSeriesRingElem}, (i - 1)::Int, data(a[i])::Ref{ZZRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing end z.prec = prec z.val = val @@ -3473,13 +3183,8 @@ mutable struct FpRelPowerSeriesRingElem <: RelPowerSeriesRingElem{FpFieldElem} function FpRelPowerSeriesRingElem(a::FpRelPowerSeriesRingElem) z = new() p = base_ring(parent(a)).ninv - ccall((:fmpz_mod_poly_init, libflint), Nothing, - (Ref{FpRelPowerSeriesRingElem}, Ref{fmpz_mod_ctx_struct}), - z, p) - ccall((:fmpz_mod_poly_set, libflint), Nothing, - (Ref{FpRelPowerSeriesRingElem}, Ref{FpRelPowerSeriesRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, a, p) + @ccall libflint.fmpz_mod_poly_init(z::Ref{FpRelPowerSeriesRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing + @ccall libflint.fmpz_mod_poly_set(z::Ref{FpRelPowerSeriesRingElem}, a::Ref{FpRelPowerSeriesRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_gfp_fmpz_rel_series_clear_fn, z) if isdefined(a, :parent) z.parent = a.parent @@ -3489,9 +3194,7 @@ mutable struct FpRelPowerSeriesRingElem <: RelPowerSeriesRingElem{FpFieldElem} end function _gfp_fmpz_rel_series_clear_fn(a::FpRelPowerSeriesRingElem) - ccall((:fmpz_mod_poly_clear, libflint), Nothing, - (Ref{FpRelPowerSeriesRingElem}, Ref{fmpz_mod_ctx_struct}), - a, base_ring(parent(a)).ninv) + @ccall libflint.fmpz_mod_poly_clear(a::Ref{FpRelPowerSeriesRingElem}, base_ring(parent(a)).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end ############################################################################### @@ -3528,9 +3231,7 @@ mutable struct ZZModRelPowerSeriesRingElem <: RelPowerSeriesRingElem{ZZModRingEl function ZZModRelPowerSeriesRingElem(p::fmpz_mod_ctx_struct) z = new() - ccall((:fmpz_mod_poly_init, libflint), Nothing, - (Ref{ZZModRelPowerSeriesRingElem}, Ref{fmpz_mod_ctx_struct}), - z, p) + @ccall libflint.fmpz_mod_poly_init(z::Ref{ZZModRelPowerSeriesRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_fmpz_mod_rel_series_clear_fn, z) return z end @@ -3542,14 +3243,9 @@ mutable struct ZZModRelPowerSeriesRingElem <: RelPowerSeriesRingElem{ZZModRingEl function ZZModRelPowerSeriesRingElem(p::fmpz_mod_ctx_struct, a::Vector{ZZRingElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{ZZModRelPowerSeriesRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, len, p) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{ZZModRelPowerSeriesRingElem}, len::Int, p::Ref{fmpz_mod_ctx_struct})::Nothing for i = 1:len - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZModRelPowerSeriesRingElem}, Int, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, i - 1, a[i], p) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{ZZModRelPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{ZZRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing end z.prec = prec z.val = val @@ -3565,14 +3261,9 @@ mutable struct ZZModRelPowerSeriesRingElem <: RelPowerSeriesRingElem{ZZModRingEl function ZZModRelPowerSeriesRingElem(p::fmpz_mod_ctx_struct, a::Vector{ZZModRingElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{ZZModRelPowerSeriesRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, len, p) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{ZZModRelPowerSeriesRingElem}, len::Int, p::Ref{fmpz_mod_ctx_struct})::Nothing for i = 1:len - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZModRelPowerSeriesRingElem}, Int, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, i - 1, data(a[i]), p) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{ZZModRelPowerSeriesRingElem}, (i - 1)::Int, data(a[i])::Ref{ZZRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing end z.prec = prec z.val = val @@ -3588,13 +3279,8 @@ mutable struct ZZModRelPowerSeriesRingElem <: RelPowerSeriesRingElem{ZZModRingEl function ZZModRelPowerSeriesRingElem(a::ZZModRelPowerSeriesRingElem) z = new() p = base_ring(parent(a)).ninv - ccall((:fmpz_mod_poly_init, libflint), Nothing, - (Ref{ZZModRelPowerSeriesRingElem}, Ref{fmpz_mod_ctx_struct}), - z, p) - ccall((:fmpz_mod_poly_set, libflint), Nothing, - (Ref{ZZModRelPowerSeriesRingElem}, Ref{ZZModRelPowerSeriesRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, a, p) + @ccall libflint.fmpz_mod_poly_init(z::Ref{ZZModRelPowerSeriesRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing + @ccall libflint.fmpz_mod_poly_set(z::Ref{ZZModRelPowerSeriesRingElem}, a::Ref{ZZModRelPowerSeriesRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_fmpz_mod_rel_series_clear_fn, z) if isdefined(a, :parent) z.parent = a.parent @@ -3604,9 +3290,7 @@ mutable struct ZZModRelPowerSeriesRingElem <: RelPowerSeriesRingElem{ZZModRingEl end function _fmpz_mod_rel_series_clear_fn(a::ZZModRelPowerSeriesRingElem) - ccall((:fmpz_mod_poly_clear, libflint), Nothing, - (Ref{ZZModRelPowerSeriesRingElem}, Ref{fmpz_mod_ctx_struct}), - a, base_ring(parent(a)).ninv) + @ccall libflint.fmpz_mod_poly_clear(a::Ref{ZZModRelPowerSeriesRingElem}, base_ring(parent(a)).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end ############################################################################### @@ -3642,9 +3326,7 @@ mutable struct FpAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{FpFieldElem} function FpAbsPowerSeriesRingElem(p::fmpz_mod_ctx_struct) z = new() - ccall((:fmpz_mod_poly_init, libflint), Nothing, - (Ref{FpAbsPowerSeriesRingElem}, Ref{fmpz_mod_ctx_struct}), - z, p) + @ccall libflint.fmpz_mod_poly_init(z::Ref{FpAbsPowerSeriesRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_gfp_fmpz_abs_series_clear_fn, z) return z end @@ -3656,14 +3338,9 @@ mutable struct FpAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{FpFieldElem} function FpAbsPowerSeriesRingElem(p::fmpz_mod_ctx_struct, a::Vector{ZZRingElem}, len::Int, prec::Int) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{FpAbsPowerSeriesRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, len, p) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{FpAbsPowerSeriesRingElem}, len::Int, p::Ref{fmpz_mod_ctx_struct})::Nothing for i = 1:len - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{FpAbsPowerSeriesRingElem}, Int, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, i - 1, a[i], p) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{FpAbsPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{ZZRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing end z.prec = prec finalizer(_gfp_fmpz_abs_series_clear_fn, z) @@ -3677,13 +3354,9 @@ mutable struct FpAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{FpFieldElem} function FpAbsPowerSeriesRingElem(p::fmpz_mod_ctx_struct, a::Vector{FpFieldElem}, len::Int, prec::Int) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{FpAbsPowerSeriesRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, len, p) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{FpAbsPowerSeriesRingElem}, len::Int, p::Ref{fmpz_mod_ctx_struct})::Nothing for i = 1:len - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{FpAbsPowerSeriesRingElem}, Int, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z, i - 1, data(a[i]), p) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{FpAbsPowerSeriesRingElem}, (i - 1)::Int, data(a[i])::Ref{ZZRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing end z.prec = prec finalizer(_gfp_fmpz_abs_series_clear_fn, z) @@ -3698,10 +3371,7 @@ mutable struct FpAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{FpFieldElem} function FpAbsPowerSeriesRingElem(a::FpAbsPowerSeriesRingElem) p = base_ring(parent(a)).ninv z = FpAbsPowerSeriesRingElem(p) - ccall((:fmpz_mod_poly_set, libflint), Nothing, - (Ref{FpAbsPowerSeriesRingElem}, Ref{FpAbsPowerSeriesRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, a, p) + @ccall libflint.fmpz_mod_poly_set(z::Ref{FpAbsPowerSeriesRingElem}, a::Ref{FpAbsPowerSeriesRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing if isdefined(a, :parent) z.parent = a.parent end @@ -3710,9 +3380,7 @@ mutable struct FpAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{FpFieldElem} end function _gfp_fmpz_abs_series_clear_fn(a::FpAbsPowerSeriesRingElem) - ccall((:fmpz_mod_poly_clear, libflint), Nothing, - (Ref{FpAbsPowerSeriesRingElem}, Ref{fmpz_mod_ctx_struct}), - a, base_ring(parent(a)).ninv) + @ccall libflint.fmpz_mod_poly_clear(a::Ref{FpAbsPowerSeriesRingElem}, base_ring(parent(a)).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end ############################################################################### @@ -3753,20 +3421,17 @@ mutable struct zzModAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{zzModRingEl function zzModAbsPowerSeriesRingElem(n::UInt) z = new() - ccall((:nmod_poly_init, libflint), Nothing, - (Ref{zzModAbsPowerSeriesRingElem}, UInt), z, n) + @ccall libflint.nmod_poly_init(z::Ref{zzModAbsPowerSeriesRingElem}, n::UInt)::Nothing finalizer(_nmod_abs_series_clear_fn, z) return z end function zzModAbsPowerSeriesRingElem(n::UInt, arr::Vector{ZZRingElem}, len::Int, prec::Int) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{zzModAbsPowerSeriesRingElem}, UInt, Int), z, n, length(arr)) + @ccall libflint.nmod_poly_init2(z::Ref{zzModAbsPowerSeriesRingElem}, n::UInt, length(arr)::Int)::Nothing for i in 1:len - tt = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), arr[i], n) - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{zzModAbsPowerSeriesRingElem}, Int, UInt), z, i - 1, tt) + tt = @ccall libflint.fmpz_fdiv_ui(arr[i]::Ref{ZZRingElem}, n::UInt)::UInt + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{zzModAbsPowerSeriesRingElem}, (i - 1)::Int, tt::UInt)::Nothing end z.prec = prec finalizer(_nmod_abs_series_clear_fn, z) @@ -3775,11 +3440,9 @@ mutable struct zzModAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{zzModRingEl function zzModAbsPowerSeriesRingElem(n::UInt, arr::Vector{UInt}, len::Int, prec::Int) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{zzModAbsPowerSeriesRingElem}, UInt, Int), z, n, length(arr)) + @ccall libflint.nmod_poly_init2(z::Ref{zzModAbsPowerSeriesRingElem}, n::UInt, length(arr)::Int)::Nothing for i in 1:len - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{zzModAbsPowerSeriesRingElem}, Int, UInt), z, i - 1, arr[i]) + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{zzModAbsPowerSeriesRingElem}, (i - 1)::Int, arr[i]::UInt)::Nothing end z.prec = prec finalizer(_nmod_abs_series_clear_fn, z) @@ -3788,11 +3451,9 @@ mutable struct zzModAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{zzModRingEl function zzModAbsPowerSeriesRingElem(n::UInt, arr::Vector{zzModRingElem}, len::Int, prec::Int) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{zzModAbsPowerSeriesRingElem}, UInt, Int), z, n, length(arr)) + @ccall libflint.nmod_poly_init2(z::Ref{zzModAbsPowerSeriesRingElem}, n::UInt, length(arr)::Int)::Nothing for i in 1:len - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{zzModAbsPowerSeriesRingElem}, Int, UInt), z, i-1, arr[i].data) + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{zzModAbsPowerSeriesRingElem}, (i-1)::Int, arr[i].data::UInt)::Nothing end z.prec = prec finalizer(_nmod_abs_series_clear_fn, z) @@ -3802,10 +3463,8 @@ mutable struct zzModAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{zzModRingEl function zzModAbsPowerSeriesRingElem(a::zzModAbsPowerSeriesRingElem) z = new() R = base_ring(a) - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{zzModAbsPowerSeriesRingElem}, UInt, Int), z, R.n, length(a)) - ccall((:nmod_poly_set, libflint), Nothing, - (Ref{zzModAbsPowerSeriesRingElem}, Ref{zzModAbsPowerSeriesRingElem}), z, a) + @ccall libflint.nmod_poly_init2(z::Ref{zzModAbsPowerSeriesRingElem}, R.n::UInt, length(a)::Int)::Nothing + @ccall libflint.nmod_poly_set(z::Ref{zzModAbsPowerSeriesRingElem}, a::Ref{zzModAbsPowerSeriesRingElem})::Nothing z.prec = a.prec finalizer(_nmod_abs_series_clear_fn, z) return z @@ -3813,7 +3472,7 @@ mutable struct zzModAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{zzModRingEl end function _nmod_abs_series_clear_fn(x::zzModAbsPowerSeriesRingElem) - ccall((:nmod_poly_clear, libflint), Nothing, (Ref{zzModAbsPowerSeriesRingElem}, ), x) + @ccall libflint.nmod_poly_clear(x::Ref{zzModAbsPowerSeriesRingElem})::Nothing end ############################################################################### @@ -3854,20 +3513,17 @@ mutable struct fpAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{fpFieldElem} function fpAbsPowerSeriesRingElem(n::UInt) z = new() - ccall((:nmod_poly_init, libflint), Nothing, - (Ref{fpAbsPowerSeriesRingElem}, UInt), z, n) + @ccall libflint.nmod_poly_init(z::Ref{fpAbsPowerSeriesRingElem}, n::UInt)::Nothing finalizer(_gfp_abs_series_clear_fn, z) return z end function fpAbsPowerSeriesRingElem(n::UInt, arr::Vector{ZZRingElem}, len::Int, prec::Int) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{fpAbsPowerSeriesRingElem}, UInt, Int), z, n, length(arr)) + @ccall libflint.nmod_poly_init2(z::Ref{fpAbsPowerSeriesRingElem}, n::UInt, length(arr)::Int)::Nothing for i in 1:len - tt = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), arr[i], n) - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{fpAbsPowerSeriesRingElem}, Int, UInt), z, i - 1, tt) + tt = @ccall libflint.fmpz_fdiv_ui(arr[i]::Ref{ZZRingElem}, n::UInt)::UInt + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{fpAbsPowerSeriesRingElem}, (i - 1)::Int, tt::UInt)::Nothing end z.prec = prec finalizer(_gfp_abs_series_clear_fn, z) @@ -3876,11 +3532,9 @@ mutable struct fpAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{fpFieldElem} function fpAbsPowerSeriesRingElem(n::UInt, arr::Vector{UInt}, len::Int, prec::Int) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{fpAbsPowerSeriesRingElem}, UInt, Int), z, n, length(arr)) + @ccall libflint.nmod_poly_init2(z::Ref{fpAbsPowerSeriesRingElem}, n::UInt, length(arr)::Int)::Nothing for i in 1:len - ccall((:nmod_poly_series_set_coeff_ui, libflint), Nothing, - (Ref{fpAbsPowerSeriesRingElem}, Int, UInt), z, i - 1, arr[i]) + @ccall libflint.nmod_poly_series_set_coeff_ui(z::Ref{fpAbsPowerSeriesRingElem}, (i - 1)::Int, arr[i]::UInt)::Nothing end z.prec = prec finalizer(_gfp_abs_series_clear_fn, z) @@ -3889,11 +3543,9 @@ mutable struct fpAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{fpFieldElem} function fpAbsPowerSeriesRingElem(n::UInt, arr::Vector{fpFieldElem}, len::Int, prec::Int) z = new() - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{fpAbsPowerSeriesRingElem}, UInt, Int), z, n, length(arr)) + @ccall libflint.nmod_poly_init2(z::Ref{fpAbsPowerSeriesRingElem}, n::UInt, length(arr)::Int)::Nothing for i in 1:len - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{fpAbsPowerSeriesRingElem}, Int, UInt), z, i-1, arr[i].data) + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{fpAbsPowerSeriesRingElem}, (i-1)::Int, arr[i].data::UInt)::Nothing end z.prec = prec finalizer(_gfp_abs_series_clear_fn, z) @@ -3903,10 +3555,8 @@ mutable struct fpAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{fpFieldElem} function fpAbsPowerSeriesRingElem(a::fpAbsPowerSeriesRingElem) z = new() R = base_ring(a) - ccall((:nmod_poly_init2, libflint), Nothing, - (Ref{fpAbsPowerSeriesRingElem}, UInt, Int), z, R.n, length(a)) - ccall((:nmod_poly_set, libflint), Nothing, - (Ref{fpAbsPowerSeriesRingElem}, Ref{fpAbsPowerSeriesRingElem}), z, a) + @ccall libflint.nmod_poly_init2(z::Ref{fpAbsPowerSeriesRingElem}, R.n::UInt, length(a)::Int)::Nothing + @ccall libflint.nmod_poly_set(z::Ref{fpAbsPowerSeriesRingElem}, a::Ref{fpAbsPowerSeriesRingElem})::Nothing z.prec = a.prec finalizer(_gfp_abs_series_clear_fn, z) return z @@ -3914,7 +3564,7 @@ mutable struct fpAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{fpFieldElem} end function _gfp_abs_series_clear_fn(x::fpAbsPowerSeriesRingElem) - ccall((:nmod_poly_clear, libflint), Nothing, (Ref{fpAbsPowerSeriesRingElem}, ), x) + @ccall libflint.nmod_poly_clear(x::Ref{fpAbsPowerSeriesRingElem})::Nothing end ############################################################################### @@ -3950,9 +3600,7 @@ mutable struct ZZModAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{ZZModRingEl function ZZModAbsPowerSeriesRingElem(p::fmpz_mod_ctx_struct) z = new() - ccall((:fmpz_mod_poly_init, libflint), Nothing, - (Ref{ZZModAbsPowerSeriesRingElem}, Ref{fmpz_mod_ctx_struct}), - z, p) + @ccall libflint.fmpz_mod_poly_init(z::Ref{ZZModAbsPowerSeriesRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_fmpz_mod_abs_series_clear_fn, z) return z end @@ -3964,14 +3612,9 @@ mutable struct ZZModAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{ZZModRingEl function ZZModAbsPowerSeriesRingElem(p::fmpz_mod_ctx_struct, a::Vector{ZZRingElem}, len::Int, prec::Int) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{ZZModAbsPowerSeriesRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, len, p) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{ZZModAbsPowerSeriesRingElem}, len::Int, p::Ref{fmpz_mod_ctx_struct})::Nothing for i = 1:len - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZModAbsPowerSeriesRingElem}, Int, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, i - 1, a[i], p) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{ZZModAbsPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{ZZRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing end z.prec = prec finalizer(_fmpz_mod_abs_series_clear_fn, z) @@ -3985,13 +3628,9 @@ mutable struct ZZModAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{ZZModRingEl function ZZModAbsPowerSeriesRingElem(p::fmpz_mod_ctx_struct, a::Vector{ZZModRingElem}, len::Int, prec::Int) z = new() - ccall((:fmpz_mod_poly_init2, libflint), Nothing, - (Ref{ZZModAbsPowerSeriesRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, len, p) + @ccall libflint.fmpz_mod_poly_init2(z::Ref{ZZModAbsPowerSeriesRingElem}, len::Int, p::Ref{fmpz_mod_ctx_struct})::Nothing for i = 1:len - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZModAbsPowerSeriesRingElem}, Int, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z, i - 1, data(a[i]), p) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{ZZModAbsPowerSeriesRingElem}, (i - 1)::Int, data(a[i])::Ref{ZZRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing end z.prec = prec finalizer(_fmpz_mod_abs_series_clear_fn, z) @@ -4006,10 +3645,7 @@ mutable struct ZZModAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{ZZModRingEl function ZZModAbsPowerSeriesRingElem(a::ZZModAbsPowerSeriesRingElem) p = base_ring(parent(a)).ninv z = ZZModAbsPowerSeriesRingElem(p) - ccall((:fmpz_mod_poly_set, libflint), Nothing, - (Ref{ZZModAbsPowerSeriesRingElem}, Ref{ZZModAbsPowerSeriesRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, a, p) + @ccall libflint.fmpz_mod_poly_set(z::Ref{ZZModAbsPowerSeriesRingElem}, a::Ref{ZZModAbsPowerSeriesRingElem}, p::Ref{fmpz_mod_ctx_struct})::Nothing z.prec = a.prec if isdefined(a, :parent) z.parent = a.parent @@ -4019,9 +3655,7 @@ mutable struct ZZModAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{ZZModRingEl end function _fmpz_mod_abs_series_clear_fn(a::ZZModAbsPowerSeriesRingElem) - ccall((:fmpz_mod_poly_clear, libflint), Nothing, - (Ref{ZZModAbsPowerSeriesRingElem}, Ref{fmpz_mod_ctx_struct}), - a, base_ring(parent(a)).ninv) + @ccall libflint.fmpz_mod_poly_clear(a::Ref{ZZModAbsPowerSeriesRingElem}, base_ring(parent(a)).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end @@ -4057,20 +3691,16 @@ mutable struct FqRelPowerSeriesRingElem <: RelPowerSeriesRingElem{FqFieldElem} function FqRelPowerSeriesRingElem(ctx::FqField) z = new() - ccall((:fq_default_poly_init, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqField}), z, ctx) + @ccall libflint.fq_default_poly_init(z::Ref{FqRelPowerSeriesRingElem}, ctx::Ref{FqField})::Nothing finalizer(_fq_default_rel_series_clear_fn, z) return z end function FqRelPowerSeriesRingElem(ctx::FqField, a::Vector{FqFieldElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:fq_default_poly_init2, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), z, len, ctx) + @ccall libflint.fq_default_poly_init2(z::Ref{FqRelPowerSeriesRingElem}, len::Int, ctx::Ref{FqField})::Nothing for i = 1:len - ccall((:fq_default_poly_set_coeff, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqFieldElem}, - Ref{FqField}), z, i - 1, a[i], ctx) + @ccall libflint.fq_default_poly_set_coeff(z::Ref{FqRelPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{FqFieldElem}, ctx::Ref{FqField})::Nothing end z.prec = prec z.val = val @@ -4080,11 +3710,8 @@ mutable struct FqRelPowerSeriesRingElem <: RelPowerSeriesRingElem{FqFieldElem} function FqRelPowerSeriesRingElem(ctx::FqField, a::FqRelPowerSeriesRingElem) z = new() - ccall((:fq_default_poly_init, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqField}), z, ctx) - ccall((:fq_default_poly_set, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqField}), z, a, ctx) + @ccall libflint.fq_default_poly_init(z::Ref{FqRelPowerSeriesRingElem}, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_set(z::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, ctx::Ref{FqField})::Nothing finalizer(_fq_default_rel_series_clear_fn, z) return z end @@ -4092,8 +3719,7 @@ end function _fq_default_rel_series_clear_fn(a::FqRelPowerSeriesRingElem) ctx = base_ring(a) - ccall((:fq_default_poly_clear, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqField}), a, ctx) + @ccall libflint.fq_default_poly_clear(a::Ref{FqRelPowerSeriesRingElem}, ctx::Ref{FqField})::Nothing end ############################################################################### @@ -4127,20 +3753,16 @@ mutable struct FqPolyRepRelPowerSeriesRingElem <: RelPowerSeriesRingElem{FqPolyR function FqPolyRepRelPowerSeriesRingElem(ctx::FqPolyRepField) z = new() - ccall((:fq_poly_init, libflint), Nothing, - (Ref{FqPolyRepRelPowerSeriesRingElem}, Ref{FqPolyRepField}), z, ctx) + @ccall libflint.fq_poly_init(z::Ref{FqPolyRepRelPowerSeriesRingElem}, ctx::Ref{FqPolyRepField})::Nothing finalizer(_fq_rel_series_clear_fn, z) return z end function FqPolyRepRelPowerSeriesRingElem(ctx::FqPolyRepField, a::Vector{FqPolyRepFieldElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:fq_poly_init2, libflint), Nothing, - (Ref{FqPolyRepRelPowerSeriesRingElem}, Int, Ref{FqPolyRepField}), z, len, ctx) + @ccall libflint.fq_poly_init2(z::Ref{FqPolyRepRelPowerSeriesRingElem}, len::Int, ctx::Ref{FqPolyRepField})::Nothing for i = 1:len - ccall((:fq_poly_set_coeff, libflint), Nothing, - (Ref{FqPolyRepRelPowerSeriesRingElem}, Int, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - z, i - 1, a[i], ctx) + @ccall libflint.fq_poly_set_coeff(z::Ref{FqPolyRepRelPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{FqPolyRepFieldElem}, ctx::Ref{FqPolyRepField})::Nothing end z.prec = prec z.val = val @@ -4150,10 +3772,8 @@ mutable struct FqPolyRepRelPowerSeriesRingElem <: RelPowerSeriesRingElem{FqPolyR function FqPolyRepRelPowerSeriesRingElem(ctx::FqPolyRepField, a::FqPolyRepRelPowerSeriesRingElem) z = new() - ccall((:fq_poly_init, libflint), Nothing, - (Ref{FqPolyRepRelPowerSeriesRingElem}, Ref{FqPolyRepField}), z, ctx) - ccall((:fq_poly_set, libflint), Nothing, - (Ref{FqPolyRepRelPowerSeriesRingElem}, Ref{FqPolyRepRelPowerSeriesRingElem}, Ref{FqPolyRepField}), z, a, ctx) + @ccall libflint.fq_poly_init(z::Ref{FqPolyRepRelPowerSeriesRingElem}, ctx::Ref{FqPolyRepField})::Nothing + @ccall libflint.fq_poly_set(z::Ref{FqPolyRepRelPowerSeriesRingElem}, a::Ref{FqPolyRepRelPowerSeriesRingElem}, ctx::Ref{FqPolyRepField})::Nothing finalizer(_fq_rel_series_clear_fn, z) return z end @@ -4161,8 +3781,7 @@ end function _fq_rel_series_clear_fn(a::FqPolyRepRelPowerSeriesRingElem) ctx = base_ring(a) - ccall((:fq_poly_clear, libflint), Nothing, - (Ref{FqPolyRepRelPowerSeriesRingElem}, Ref{FqPolyRepField}), a, ctx) + @ccall libflint.fq_poly_clear(a::Ref{FqPolyRepRelPowerSeriesRingElem}, ctx::Ref{FqPolyRepField})::Nothing end ############################################################################### @@ -4196,20 +3815,16 @@ mutable struct FqAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{FqFieldElem} function FqAbsPowerSeriesRingElem(ctx::FqField) z = new() - ccall((:fq_default_poly_init, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqField}), z, ctx) + @ccall libflint.fq_default_poly_init(z::Ref{FqAbsPowerSeriesRingElem}, ctx::Ref{FqField})::Nothing finalizer(_fq_default_abs_series_clear_fn, z) return z end function FqAbsPowerSeriesRingElem(ctx::FqField, a::Vector{FqFieldElem}, len::Int, prec::Int) z = new() - ccall((:fq_default_poly_init2, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), z, len, ctx) + @ccall libflint.fq_default_poly_init2(z::Ref{FqAbsPowerSeriesRingElem}, len::Int, ctx::Ref{FqField})::Nothing for i = 1:len - ccall((:fq_default_poly_set_coeff, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqFieldElem}, Ref{FqField}), - z, i - 1, a[i], ctx) + @ccall libflint.fq_default_poly_set_coeff(z::Ref{FqAbsPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{FqFieldElem}, ctx::Ref{FqField})::Nothing end z.prec = prec finalizer(_fq_default_abs_series_clear_fn, z) @@ -4218,10 +3833,8 @@ mutable struct FqAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{FqFieldElem} function FqAbsPowerSeriesRingElem(ctx::FqField, a::FqAbsPowerSeriesRingElem) z = new() - ccall((:fq_default_poly_init, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqField}), z, ctx) - ccall((:fq_default_poly_set, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, Ref{FqField}), z, a, ctx) + @ccall libflint.fq_default_poly_init(z::Ref{FqAbsPowerSeriesRingElem}, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_set(z::Ref{FqAbsPowerSeriesRingElem}, a::Ref{FqAbsPowerSeriesRingElem}, ctx::Ref{FqField})::Nothing finalizer(_fq_default_abs_series_clear_fn, z) return z end @@ -4229,8 +3842,7 @@ end function _fq_default_abs_series_clear_fn(a::FqAbsPowerSeriesRingElem) ctx = base_ring(a) - ccall((:fq_default_poly_clear, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqField}), a, ctx) + @ccall libflint.fq_default_poly_clear(a::Ref{FqAbsPowerSeriesRingElem}, ctx::Ref{FqField})::Nothing end ############################################################################### @@ -4263,20 +3875,16 @@ mutable struct FqPolyRepAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{FqPolyR function FqPolyRepAbsPowerSeriesRingElem(ctx::FqPolyRepField) z = new() - ccall((:fq_poly_init, libflint), Nothing, - (Ref{FqPolyRepAbsPowerSeriesRingElem}, Ref{FqPolyRepField}), z, ctx) + @ccall libflint.fq_poly_init(z::Ref{FqPolyRepAbsPowerSeriesRingElem}, ctx::Ref{FqPolyRepField})::Nothing finalizer(_fq_abs_series_clear_fn, z) return z end function FqPolyRepAbsPowerSeriesRingElem(ctx::FqPolyRepField, a::Vector{FqPolyRepFieldElem}, len::Int, prec::Int) z = new() - ccall((:fq_poly_init2, libflint), Nothing, - (Ref{FqPolyRepAbsPowerSeriesRingElem}, Int, Ref{FqPolyRepField}), z, len, ctx) + @ccall libflint.fq_poly_init2(z::Ref{FqPolyRepAbsPowerSeriesRingElem}, len::Int, ctx::Ref{FqPolyRepField})::Nothing for i = 1:len - ccall((:fq_poly_set_coeff, libflint), Nothing, - (Ref{FqPolyRepAbsPowerSeriesRingElem}, Int, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - z, i - 1, a[i], ctx) + @ccall libflint.fq_poly_set_coeff(z::Ref{FqPolyRepAbsPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{FqPolyRepFieldElem}, ctx::Ref{FqPolyRepField})::Nothing end z.prec = prec finalizer(_fq_abs_series_clear_fn, z) @@ -4285,10 +3893,8 @@ mutable struct FqPolyRepAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{FqPolyR function FqPolyRepAbsPowerSeriesRingElem(ctx::FqPolyRepField, a::FqPolyRepAbsPowerSeriesRingElem) z = new() - ccall((:fq_poly_init, libflint), Nothing, - (Ref{FqPolyRepAbsPowerSeriesRingElem}, Ref{FqPolyRepField}), z, ctx) - ccall((:fq_poly_set, libflint), Nothing, - (Ref{FqPolyRepAbsPowerSeriesRingElem}, Ref{FqPolyRepAbsPowerSeriesRingElem}, Ref{FqPolyRepField}), z, a, ctx) + @ccall libflint.fq_poly_init(z::Ref{FqPolyRepAbsPowerSeriesRingElem}, ctx::Ref{FqPolyRepField})::Nothing + @ccall libflint.fq_poly_set(z::Ref{FqPolyRepAbsPowerSeriesRingElem}, a::Ref{FqPolyRepAbsPowerSeriesRingElem}, ctx::Ref{FqPolyRepField})::Nothing finalizer(_fq_abs_series_clear_fn, z) return z end @@ -4296,8 +3902,7 @@ end function _fq_abs_series_clear_fn(a::FqPolyRepAbsPowerSeriesRingElem) ctx = base_ring(a) - ccall((:fq_poly_clear, libflint), Nothing, - (Ref{FqPolyRepAbsPowerSeriesRingElem}, Ref{FqPolyRepField}), a, ctx) + @ccall libflint.fq_poly_clear(a::Ref{FqPolyRepAbsPowerSeriesRingElem}, ctx::Ref{FqPolyRepField})::Nothing end ############################################################################### @@ -4332,20 +3937,16 @@ mutable struct fqPolyRepRelPowerSeriesRingElem <: RelPowerSeriesRingElem{fqPolyR function fqPolyRepRelPowerSeriesRingElem(ctx::fqPolyRepField) z = new() - ccall((:fq_nmod_poly_init, libflint), Nothing, - (Ref{fqPolyRepRelPowerSeriesRingElem}, Ref{fqPolyRepField}), z, ctx) + @ccall libflint.fq_nmod_poly_init(z::Ref{fqPolyRepRelPowerSeriesRingElem}, ctx::Ref{fqPolyRepField})::Nothing finalizer(_fq_nmod_rel_series_clear_fn, z) return z end function fqPolyRepRelPowerSeriesRingElem(ctx::fqPolyRepField, a::Vector{fqPolyRepFieldElem}, len::Int, prec::Int, val::Int) z = new() - ccall((:fq_nmod_poly_init2, libflint), Nothing, - (Ref{fqPolyRepRelPowerSeriesRingElem}, Int, Ref{fqPolyRepField}), z, len, ctx) + @ccall libflint.fq_nmod_poly_init2(z::Ref{fqPolyRepRelPowerSeriesRingElem}, len::Int, ctx::Ref{fqPolyRepField})::Nothing for i = 1:len - ccall((:fq_nmod_poly_set_coeff, libflint), Nothing, - (Ref{fqPolyRepRelPowerSeriesRingElem}, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, i - 1, a[i], ctx) + @ccall libflint.fq_nmod_poly_set_coeff(z::Ref{fqPolyRepRelPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{fqPolyRepFieldElem}, ctx::Ref{fqPolyRepField})::Nothing end z.prec = prec z.val = val @@ -4355,10 +3956,8 @@ mutable struct fqPolyRepRelPowerSeriesRingElem <: RelPowerSeriesRingElem{fqPolyR function fqPolyRepRelPowerSeriesRingElem(ctx::fqPolyRepField, a::fqPolyRepRelPowerSeriesRingElem) z = new() - ccall((:fq_nmod_poly_init, libflint), Nothing, - (Ref{fqPolyRepRelPowerSeriesRingElem}, Ref{fqPolyRepField}), z, ctx) - ccall((:fq_nmod_poly_set, libflint), Nothing, - (Ref{fqPolyRepRelPowerSeriesRingElem}, Ref{fqPolyRepRelPowerSeriesRingElem}, Ref{fqPolyRepField}), z, a, ctx) + @ccall libflint.fq_nmod_poly_init(z::Ref{fqPolyRepRelPowerSeriesRingElem}, ctx::Ref{fqPolyRepField})::Nothing + @ccall libflint.fq_nmod_poly_set(z::Ref{fqPolyRepRelPowerSeriesRingElem}, a::Ref{fqPolyRepRelPowerSeriesRingElem}, ctx::Ref{fqPolyRepField})::Nothing finalizer(_fq_nmod_rel_series_clear_fn, z) return z end @@ -4366,8 +3965,7 @@ end function _fq_nmod_rel_series_clear_fn(a::fqPolyRepRelPowerSeriesRingElem) ctx = base_ring(a) - ccall((:fq_nmod_poly_clear, libflint), Nothing, - (Ref{fqPolyRepRelPowerSeriesRingElem}, Ref{fqPolyRepField}), a, ctx) + @ccall libflint.fq_nmod_poly_clear(a::Ref{fqPolyRepRelPowerSeriesRingElem}, ctx::Ref{fqPolyRepField})::Nothing end ############################################################################### @@ -4401,20 +3999,16 @@ mutable struct fqPolyRepAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{fqPolyR function fqPolyRepAbsPowerSeriesRingElem(ctx::fqPolyRepField) z = new() - ccall((:fq_nmod_poly_init, libflint), Nothing, - (Ref{fqPolyRepAbsPowerSeriesRingElem}, Ref{fqPolyRepField}), z, ctx) + @ccall libflint.fq_nmod_poly_init(z::Ref{fqPolyRepAbsPowerSeriesRingElem}, ctx::Ref{fqPolyRepField})::Nothing finalizer(_fq_nmod_abs_series_clear_fn, z) return z end function fqPolyRepAbsPowerSeriesRingElem(ctx::fqPolyRepField, a::Vector{fqPolyRepFieldElem}, len::Int, prec::Int) z = new() - ccall((:fq_nmod_poly_init2, libflint), Nothing, - (Ref{fqPolyRepAbsPowerSeriesRingElem}, Int, Ref{fqPolyRepField}), z, len, ctx) + @ccall libflint.fq_nmod_poly_init2(z::Ref{fqPolyRepAbsPowerSeriesRingElem}, len::Int, ctx::Ref{fqPolyRepField})::Nothing for i = 1:len - ccall((:fq_nmod_poly_set_coeff, libflint), Nothing, - (Ref{fqPolyRepAbsPowerSeriesRingElem}, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, i - 1, a[i], ctx) + @ccall libflint.fq_nmod_poly_set_coeff(z::Ref{fqPolyRepAbsPowerSeriesRingElem}, (i - 1)::Int, a[i]::Ref{fqPolyRepFieldElem}, ctx::Ref{fqPolyRepField})::Nothing end z.prec = prec finalizer(_fq_nmod_abs_series_clear_fn, z) @@ -4423,10 +4017,8 @@ mutable struct fqPolyRepAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{fqPolyR function fqPolyRepAbsPowerSeriesRingElem(ctx::fqPolyRepField, a::fqPolyRepAbsPowerSeriesRingElem) z = new() - ccall((:fq_nmod_poly_init, libflint), Nothing, - (Ref{fqPolyRepAbsPowerSeriesRingElem}, Ref{fqPolyRepField}), z, ctx) - ccall((:fq_nmod_poly_set, libflint), Nothing, - (Ref{fqPolyRepAbsPowerSeriesRingElem}, Ref{fqPolyRepAbsPowerSeriesRingElem}, Ref{fqPolyRepField}), z, a, ctx) + @ccall libflint.fq_nmod_poly_init(z::Ref{fqPolyRepAbsPowerSeriesRingElem}, ctx::Ref{fqPolyRepField})::Nothing + @ccall libflint.fq_nmod_poly_set(z::Ref{fqPolyRepAbsPowerSeriesRingElem}, a::Ref{fqPolyRepAbsPowerSeriesRingElem}, ctx::Ref{fqPolyRepField})::Nothing finalizer(_fq_nmod_abs_series_clear_fn, z) return z end @@ -4434,8 +4026,7 @@ end function _fq_nmod_abs_series_clear_fn(a::fqPolyRepAbsPowerSeriesRingElem) ctx = base_ring(a) - ccall((:fq_nmod_poly_clear, libflint), Nothing, - (Ref{fqPolyRepAbsPowerSeriesRingElem}, Ref{fqPolyRepField}), a, ctx) + @ccall libflint.fq_nmod_poly_clear(a::Ref{fqPolyRepAbsPowerSeriesRingElem}, ctx::Ref{fqPolyRepField})::Nothing end ############################################################################### @@ -4462,23 +4053,21 @@ mutable struct QQMatrix <: MatElem{QQFieldElem} function QQMatrix(r::Int, c::Int) z = new() - ccall((:fmpq_mat_init, libflint), Nothing, - (Ref{QQMatrix}, Int, Int), z, r, c) + @ccall libflint.fmpq_mat_init(z::Ref{QQMatrix}, r::Int, c::Int)::Nothing finalizer(_fmpq_mat_clear_fn, z) return z end function QQMatrix(m::QQMatrix) z = new() - ccall((:fmpq_mat_init_set, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}), z, m) + @ccall libflint.fmpq_mat_init_set(z::Ref{QQMatrix}, m::Ref{QQMatrix})::Nothing finalizer(_fmpq_mat_clear_fn, z) return z end end function _fmpq_mat_clear_fn(a::QQMatrix) - ccall((:fmpq_mat_clear, libflint), Nothing, (Ref{QQMatrix},), a) + @ccall libflint.fmpq_mat_clear(a::Ref{QQMatrix})::Nothing end ############################################################################### @@ -4505,23 +4094,21 @@ mutable struct ZZMatrix <: MatElem{ZZRingElem} function ZZMatrix(r::Int, c::Int) z = new() - ccall((:fmpz_mat_init, libflint), Nothing, - (Ref{ZZMatrix}, Int, Int), z, r, c) + @ccall libflint.fmpz_mat_init(z::Ref{ZZMatrix}, r::Int, c::Int)::Nothing finalizer(_fmpz_mat_clear_fn, z) return z end function ZZMatrix(m::ZZMatrix) z = new() - ccall((:fmpz_mat_init_set, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}), z, m) + @ccall libflint.fmpz_mat_init_set(z::Ref{ZZMatrix}, m::Ref{ZZMatrix})::Nothing finalizer(_fmpz_mat_clear_fn, z) return z end end function _fmpz_mat_clear_fn(a::ZZMatrix) - ccall((:fmpz_mat_clear, libflint), Nothing, (Ref{ZZMatrix},), a) + @ccall libflint.fmpz_mat_clear(a::Ref{ZZMatrix})::Nothing end ############################################################################### @@ -4551,8 +4138,7 @@ mutable struct zzModMatrix <: MatElem{zzModRingElem} function zzModMatrix(r::Int, c::Int, n::UInt) z = new() - ccall((:nmod_mat_init, libflint), Nothing, - (Ref{zzModMatrix}, Int, Int, UInt), z, r, c, n) + @ccall libflint.nmod_mat_init(z::Ref{zzModMatrix}, r::Int, c::Int, n::UInt)::Nothing finalizer(_nmod_mat_clear_fn, z) return z end @@ -4595,8 +4181,7 @@ mutable struct zzModMatrix <: MatElem{zzModRingElem} t = ZZRingElem() for i = 1:r for j = 1:c - ccall((:fmpz_mod_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), t, arr[(i - 1) * c + j], n) + @ccall libflint.fmpz_mod_ui(t::Ref{ZZRingElem}, (arr[(i - 1) * c + j])::Ref{ZZRingElem}, n::UInt)::Nothing setindex!(z, t, i, j) end end @@ -4635,11 +4220,9 @@ mutable struct zzModMatrix <: MatElem{zzModRingElem} function zzModMatrix(n::UInt, b::ZZMatrix) z = new() - ccall((:nmod_mat_init, libflint), Nothing, - (Ref{zzModMatrix}, Int, Int, UInt), z, b.r, b.c, n) + @ccall libflint.nmod_mat_init(z::Ref{zzModMatrix}, b.r::Int, b.c::Int, n::UInt)::Nothing finalizer(_nmod_mat_clear_fn, z) - ccall((:fmpz_mat_get_nmod_mat, libflint), Nothing, - (Ref{zzModMatrix}, Ref{ZZMatrix}), z, b) + @ccall libflint.fmpz_mat_get_nmod_mat(z::Ref{zzModMatrix}, b::Ref{ZZMatrix})::Nothing return z end @@ -4657,7 +4240,7 @@ mutable struct zzModMatrix <: MatElem{zzModRingElem} end function _nmod_mat_clear_fn(mat::zzModMatrix) - ccall((:nmod_mat_clear, libflint), Nothing, (Ref{zzModMatrix}, ), mat) + @ccall libflint.nmod_mat_clear(mat::Ref{zzModMatrix})::Nothing end ############################################################################### @@ -4686,8 +4269,7 @@ mutable struct ZZModMatrix <: MatElem{ZZModRingElem} function ZZModMatrix(r::Int, c::Int, ctx::fmpz_mod_ctx_struct) z = new() - ccall((:fmpz_mod_mat_init, libflint), Nothing, - (Ref{ZZModMatrix}, Int, Int, Ref{fmpz_mod_ctx_struct}), z, r, c, ctx) + @ccall libflint.fmpz_mod_mat_init(z::Ref{ZZModMatrix}, r::Int, c::Int, ctx::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_fmpz_mod_mat_clear_fn, z) return z end @@ -4790,9 +4372,7 @@ mutable struct ZZModMatrix <: MatElem{ZZModRingElem} (n < 2) && error("Modulus must be >= 2") z = new() R = ZZModRing(n) - ccall((:fmpz_mod_mat_init, libflint), Nothing, - (Ref{ZZModMatrix}, Int, Int, Ref{fmpz_mod_ctx_struct}), - z, b.r, b.c, R.ninv) + @ccall libflint.fmpz_mod_mat_init(z::Ref{ZZModMatrix}, b.r::Int, b.c::Int, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_fmpz_mod_mat_clear_fn, z) for i = 1:b.r for j = 1:b.c @@ -4805,8 +4385,7 @@ end function _fmpz_mod_mat_clear_fn(mat::ZZModMatrix) - ccall((:fmpz_mod_mat_clear, libflint), Nothing, - (Ref{ZZModMatrix}, Ref{Nothing}), mat, C_NULL) # Hack + @ccall libflint.fmpz_mod_mat_clear(mat::Ref{ZZModMatrix}, C_NULL::Ref{Nothing})::Nothing # Hack end ############################################################################### @@ -4835,8 +4414,7 @@ mutable struct FpMatrix <: MatElem{FpFieldElem} function FpMatrix(r::Int, c::Int, ctx::fmpz_mod_ctx_struct) z = new() - ccall((:fmpz_mod_mat_init, libflint), Nothing, - (Ref{FpMatrix}, Int, Int, Ref{fmpz_mod_ctx_struct}), z, r, c, ctx) + @ccall libflint.fmpz_mod_mat_init(z::Ref{FpMatrix}, r::Int, c::Int, ctx::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_gfp_fmpz_mat_clear_fn, z) return z end @@ -4905,8 +4483,7 @@ mutable struct FpMatrix <: MatElem{FpFieldElem} end function _gfp_fmpz_mat_clear_fn(mat::FpMatrix) - ccall((:fmpz_mod_mat_clear, libflint), Nothing, - (Ref{FpMatrix}, Ref{Nothing}), mat, C_NULL) # Hack + @ccall libflint.fmpz_mod_mat_clear(mat::Ref{FpMatrix}, C_NULL::Ref{Nothing})::Nothing # Hack end ################################################################################ @@ -4936,8 +4513,7 @@ mutable struct fpMatrix <: MatElem{fpFieldElem} function fpMatrix(r::Int, c::Int, n::UInt) z = new() - ccall((:nmod_mat_init, libflint), Nothing, - (Ref{fpMatrix}, Int, Int, UInt), z, r, c, n) + @ccall libflint.nmod_mat_init(z::Ref{fpMatrix}, r::Int, c::Int, n::UInt)::Nothing finalizer(_gfp_mat_clear_fn, z) return z end @@ -4980,8 +4556,7 @@ mutable struct fpMatrix <: MatElem{fpFieldElem} t = ZZRingElem() for i = 1:r for j = 1:c - ccall((:fmpz_mod_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), t, arr[(i - 1) * c + j], n) + @ccall libflint.fmpz_mod_ui(t::Ref{ZZRingElem}, (arr[(i - 1) * c + j])::Ref{ZZRingElem}, n::UInt)::Nothing setindex!(z, t, i, j) end end @@ -5020,8 +4595,7 @@ mutable struct fpMatrix <: MatElem{fpFieldElem} function fpMatrix(n::UInt, b::ZZMatrix) z = fpMatrix(b.r, b.c, n) - ccall((:fmpz_mat_get_nmod_mat, libflint), Nothing, - (Ref{fpMatrix}, Ref{ZZMatrix}), z, b) + @ccall libflint.fmpz_mat_get_nmod_mat(z::Ref{fpMatrix}, b::Ref{ZZMatrix})::Nothing return z end @@ -5039,7 +4613,7 @@ mutable struct fpMatrix <: MatElem{fpFieldElem} end function _gfp_mat_clear_fn(mat::fpMatrix) - ccall((:nmod_mat_clear, libflint), Nothing, (Ref{fpMatrix}, ), mat) + @ccall libflint.nmod_mat_clear(mat::Ref{fpMatrix})::Nothing end ############################################################################### @@ -5070,43 +4644,32 @@ mutable struct FqPolyRingElem <: PolyRingElem{FqFieldElem} function FqPolyRingElem(ctx::FqField) z = new() - ccall((:fq_default_poly_init, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqField}), z, ctx) + @ccall libflint.fq_default_poly_init(z::Ref{FqPolyRingElem}, ctx::Ref{FqField})::Nothing finalizer(_fq_default_poly_clear_fn, z) return z end function FqPolyRingElem(a::FqPolyRingElem, ctx::FqField) z = new() - ccall((:fq_default_poly_init, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqField}), z, ctx) - ccall((:fq_default_poly_set, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqField}), - z, a, ctx) + @ccall libflint.fq_default_poly_init(z::Ref{FqPolyRingElem}, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_set(z::Ref{FqPolyRingElem}, a::Ref{FqPolyRingElem}, ctx::Ref{FqField})::Nothing finalizer(_fq_default_poly_clear_fn, z) return z end function FqPolyRingElem(a::FqFieldElem, ctx::FqField) z = new() - ccall((:fq_default_poly_init, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqField}), z, ctx) - ccall((:fq_default_poly_set_fq_default, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), - z, a, ctx) + @ccall libflint.fq_default_poly_init(z::Ref{FqPolyRingElem}, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_set_fq_default(z::Ref{FqPolyRingElem}, a::Ref{FqFieldElem}, ctx::Ref{FqField})::Nothing finalizer(_fq_default_poly_clear_fn, z) return z end function FqPolyRingElem(a::Vector{FqFieldElem}, ctx::FqField) z = new() - ccall((:fq_default_poly_init2, libflint), Nothing, - (Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, length(a), ctx) + @ccall libflint.fq_default_poly_init2(z::Ref{FqPolyRingElem}, length(a)::Int, ctx::Ref{FqField})::Nothing for i = 1:length(a) - ccall((:fq_default_poly_set_coeff, libflint), Nothing, - (Ref{FqPolyRingElem}, Int, Ref{FqFieldElem}, Ref{FqField}), - z, i - 1, a[i], ctx) + @ccall libflint.fq_default_poly_set_coeff(z::Ref{FqPolyRingElem}, (i - 1)::Int, a[i]::Ref{FqFieldElem}, ctx::Ref{FqField})::Nothing end finalizer(_fq_default_poly_clear_fn, z) return z @@ -5115,14 +4678,10 @@ mutable struct FqPolyRingElem <: PolyRingElem{FqFieldElem} function FqPolyRingElem(a::Vector{ZZRingElem}, ctx::FqField) z = new() temp = ctx() - ccall((:fq_default_poly_init2, libflint), Nothing, - (Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, length(a), ctx) + @ccall libflint.fq_default_poly_init2(z::Ref{FqPolyRingElem}, length(a)::Int, ctx::Ref{FqField})::Nothing for i = 1:length(a) temp = ctx(a[i]) - ccall((:fq_default_poly_set_coeff, libflint), Nothing, - (Ref{FqPolyRingElem}, Int, Ref{FqFieldElem}, Ref{FqField}), - z, i - 1, temp, ctx) + @ccall libflint.fq_default_poly_set_coeff(z::Ref{FqPolyRingElem}, (i - 1)::Int, temp::Ref{FqFieldElem}, ctx::Ref{FqField})::Nothing end finalizer(_fq_default_poly_clear_fn, z) return z @@ -5130,69 +4689,47 @@ mutable struct FqPolyRingElem <: PolyRingElem{FqFieldElem} function FqPolyRingElem(a::ZZPolyRingElem, ctx::FqField) z = new() - ccall((:fq_default_poly_init2, libflint), Nothing, - (Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, length(a), ctx) - ccall((:fq_default_poly_set_fmpz_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{ZZPolyRingElem}, Ref{FqField}), - z, a, ctx) + @ccall libflint.fq_default_poly_init2(z::Ref{FqPolyRingElem}, length(a)::Int, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_set_fmpz_poly(z::Ref{FqPolyRingElem}, a::Ref{ZZPolyRingElem}, ctx::Ref{FqField})::Nothing finalizer(_fq_default_poly_clear_fn, z) return z end function FqPolyRingElem(a::zzModPolyRingElem, ctx::FqField) z = new() - ccall((:fq_default_poly_init2, libflint), Nothing, - (Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, length(a), ctx) - ccall((:fq_default_poly_set_nmod_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{zzModPolyRingElem}, Ref{FqField}), - z, a, ctx) + @ccall libflint.fq_default_poly_init2(z::Ref{FqPolyRingElem}, length(a)::Int, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_set_nmod_poly(z::Ref{FqPolyRingElem}, a::Ref{zzModPolyRingElem}, ctx::Ref{FqField})::Nothing finalizer(_fq_default_poly_clear_fn, z) return z end function FqPolyRingElem(a::fpPolyRingElem, ctx::FqField) z = new() - ccall((:fq_default_poly_init2, libflint), Nothing, - (Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, length(a), ctx) - ccall((:fq_default_poly_set_nmod_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{fpPolyRingElem}, Ref{FqField}), - z, a, ctx) + @ccall libflint.fq_default_poly_init2(z::Ref{FqPolyRingElem}, length(a)::Int, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_set_nmod_poly(z::Ref{FqPolyRingElem}, a::Ref{fpPolyRingElem}, ctx::Ref{FqField})::Nothing finalizer(_fq_default_poly_clear_fn, z) return z end function FqPolyRingElem(a::ZZModPolyRingElem, ctx::FqField) z = new() - ccall((:fq_default_poly_init2, libflint), Nothing, - (Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, length(a), ctx) - ccall((:fq_default_poly_set_fmpz_mod_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{FqField}), - z, a, ctx) + @ccall libflint.fq_default_poly_init2(z::Ref{FqPolyRingElem}, length(a)::Int, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_set_fmpz_mod_poly(z::Ref{FqPolyRingElem}, a::Ref{ZZModPolyRingElem}, ctx::Ref{FqField})::Nothing finalizer(_fq_default_poly_clear_fn, z) return z end function FqPolyRingElem(a::FpPolyRingElem, ctx::FqField) z = new() - ccall((:fq_default_poly_init2, libflint), Nothing, - (Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, length(a), ctx) - ccall((:fq_default_poly_set_fmpz_mod_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FpPolyRingElem}, Ref{FqField}), - z, a, ctx) + @ccall libflint.fq_default_poly_init2(z::Ref{FqPolyRingElem}, length(a)::Int, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_set_fmpz_mod_poly(z::Ref{FqPolyRingElem}, a::Ref{FpPolyRingElem}, ctx::Ref{FqField})::Nothing finalizer(_fq_default_poly_clear_fn, z) return z end end function _fq_default_poly_clear_fn(a::FqPolyRingElem) - ccall((:fq_default_poly_clear, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqField}), - a, base_ring(a)) + @ccall libflint.fq_default_poly_clear(a::Ref{FqPolyRingElem}, base_ring(a)::Ref{FqField})::Nothing end mutable struct fq_default_poly_factor @@ -5203,8 +4740,7 @@ mutable struct fq_default_poly_factor function fq_default_poly_factor(ctx::FqField) z = new() - ccall((:fq_default_poly_factor_init, libflint), Nothing, - (Ref{fq_default_poly_factor}, Ref{FqField}), z, ctx) + @ccall libflint.fq_default_poly_factor_init(z::Ref{fq_default_poly_factor}, ctx::Ref{FqField})::Nothing z.base_field = ctx finalizer(_fq_default_poly_factor_clear_fn, z) return z @@ -5213,9 +4749,7 @@ end function _fq_default_poly_factor_clear_fn(a::fq_default_poly_factor) K = a.base_field - ccall((:fq_default_poly_factor_clear, libflint), Nothing, - (Ref{fq_default_poly_factor}, Ref{FqField}), - a, K) + @ccall libflint.fq_default_poly_factor_clear(a::Ref{fq_default_poly_factor}, K::Ref{FqField})::Nothing end ############################################################################### @@ -5245,7 +4779,7 @@ mutable struct FqPolyRepPolyRingElem <: PolyRingElem{FqPolyRepFieldElem} function FqPolyRepPolyRingElem() z = new() - ccall((:fq_poly_init, libflint), Nothing, (Ref{FqPolyRepPolyRingElem},), z) + @ccall libflint.fq_poly_init(z::Ref{FqPolyRepPolyRingElem})::Nothing finalizer(_fq_poly_clear_fn, z) return z end @@ -5253,11 +4787,8 @@ mutable struct FqPolyRepPolyRingElem <: PolyRingElem{FqPolyRepFieldElem} function FqPolyRepPolyRingElem(a::FqPolyRepPolyRingElem) z = new() ctx = base_ring(parent(a)) - ccall((:fq_poly_init, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), z, ctx) - ccall((:fq_poly_set, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - z, a, ctx) + @ccall libflint.fq_poly_init(z::Ref{FqPolyRepPolyRingElem}, ctx::Ref{FqPolyRepField})::Nothing + @ccall libflint.fq_poly_set(z::Ref{FqPolyRepPolyRingElem}, a::Ref{FqPolyRepPolyRingElem}, ctx::Ref{FqPolyRepField})::Nothing finalizer(_fq_poly_clear_fn, z) return z end @@ -5265,11 +4796,8 @@ mutable struct FqPolyRepPolyRingElem <: PolyRingElem{FqPolyRepFieldElem} function FqPolyRepPolyRingElem(a::FqPolyRepFieldElem) z = new() ctx = parent(a) - ccall((:fq_poly_init, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), z, ctx) - ccall((:fq_poly_set_fq, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - z, a, ctx) + @ccall libflint.fq_poly_init(z::Ref{FqPolyRepPolyRingElem}, ctx::Ref{FqPolyRepField})::Nothing + @ccall libflint.fq_poly_set_fq(z::Ref{FqPolyRepPolyRingElem}, a::Ref{FqPolyRepFieldElem}, ctx::Ref{FqPolyRepField})::Nothing finalizer(_fq_poly_clear_fn, z) return z end @@ -5277,13 +4805,9 @@ mutable struct FqPolyRepPolyRingElem <: PolyRingElem{FqPolyRepFieldElem} function FqPolyRepPolyRingElem(a::Vector{FqPolyRepFieldElem}) z = new() ctx = parent(a[1]) - ccall((:fq_poly_init2, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepField}), - z, length(a), ctx) + @ccall libflint.fq_poly_init2(z::Ref{FqPolyRepPolyRingElem}, length(a)::Int, ctx::Ref{FqPolyRepField})::Nothing for i = 1:length(a) - ccall((:fq_poly_set_coeff, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - z, i - 1, a[i], ctx) + @ccall libflint.fq_poly_set_coeff(z::Ref{FqPolyRepPolyRingElem}, (i - 1)::Int, a[i]::Ref{FqPolyRepFieldElem}, ctx::Ref{FqPolyRepField})::Nothing end finalizer(_fq_poly_clear_fn, z) return z @@ -5292,14 +4816,10 @@ mutable struct FqPolyRepPolyRingElem <: PolyRingElem{FqPolyRepFieldElem} function FqPolyRepPolyRingElem(a::Vector{ZZRingElem}, ctx::FqPolyRepField) z = new() temp = ctx() - ccall((:fq_poly_init2, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepField}), - z, length(a), ctx) + @ccall libflint.fq_poly_init2(z::Ref{FqPolyRepPolyRingElem}, length(a)::Int, ctx::Ref{FqPolyRepField})::Nothing for i = 1:length(a) temp = ctx(a[i]) - ccall((:fq_poly_set_coeff, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - z, i - 1, temp, ctx) + @ccall libflint.fq_poly_set_coeff(z::Ref{FqPolyRepPolyRingElem}, (i - 1)::Int, temp::Ref{FqPolyRepFieldElem}, ctx::Ref{FqPolyRepField})::Nothing end finalizer(_fq_poly_clear_fn, z) return z @@ -5307,14 +4827,10 @@ mutable struct FqPolyRepPolyRingElem <: PolyRingElem{FqPolyRepFieldElem} function FqPolyRepPolyRingElem(a::ZZPolyRingElem, ctx::FqPolyRepField) z = new() - ccall((:fq_poly_init2, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepField}), - z, length(a), ctx) + @ccall libflint.fq_poly_init2(z::Ref{FqPolyRepPolyRingElem}, length(a)::Int, ctx::Ref{FqPolyRepField})::Nothing for i = 1:length(a) temp = ctx(coeff(a, i-1)) - ccall((:fq_poly_set_coeff, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - z, i - 1, temp, ctx) + @ccall libflint.fq_poly_set_coeff(z::Ref{FqPolyRepPolyRingElem}, (i - 1)::Int, temp::Ref{FqPolyRepFieldElem}, ctx::Ref{FqPolyRepField})::Nothing end finalizer(_fq_poly_clear_fn, z) return z @@ -5322,7 +4838,7 @@ mutable struct FqPolyRepPolyRingElem <: PolyRingElem{FqPolyRepFieldElem} end function _fq_poly_clear_fn(a::FqPolyRepPolyRingElem) - ccall((:fq_poly_clear, libflint), Nothing, (Ref{FqPolyRepPolyRingElem},), a) + @ccall libflint.fq_poly_clear(a::Ref{FqPolyRepPolyRingElem})::Nothing end mutable struct fq_poly_factor @@ -5334,8 +4850,7 @@ mutable struct fq_poly_factor function fq_poly_factor(ctx::FqPolyRepField) z = new() - ccall((:fq_poly_factor_init, libflint), Nothing, - (Ref{fq_poly_factor}, Ref{FqPolyRepField}), z, ctx) + @ccall libflint.fq_poly_factor_init(z::Ref{fq_poly_factor}, ctx::Ref{FqPolyRepField})::Nothing z.base_field = ctx finalizer(_fq_poly_factor_clear_fn, z) return z @@ -5343,9 +4858,7 @@ mutable struct fq_poly_factor end function _fq_poly_factor_clear_fn(a::fq_poly_factor) - ccall((:fq_poly_factor_clear, libflint), Nothing, - (Ref{fq_poly_factor}, Ref{FqPolyRepField}), - a, a.base_field) + @ccall libflint.fq_poly_factor_clear(a::Ref{fq_poly_factor}, a.base_field::Ref{FqPolyRepField})::Nothing end ############################################################################### @@ -5375,7 +4888,7 @@ mutable struct fqPolyRepPolyRingElem <: PolyRingElem{fqPolyRepFieldElem} function fqPolyRepPolyRingElem() z = new() - ccall((:fq_nmod_poly_init, libflint), Nothing, (Ref{fqPolyRepPolyRingElem},), z) + @ccall libflint.fq_nmod_poly_init(z::Ref{fqPolyRepPolyRingElem})::Nothing finalizer(_fq_nmod_poly_clear_fn, z) return z end @@ -5383,11 +4896,8 @@ mutable struct fqPolyRepPolyRingElem <: PolyRingElem{fqPolyRepFieldElem} function fqPolyRepPolyRingElem(a::fqPolyRepPolyRingElem) z = new() ctx = base_ring(parent(a)) - ccall((:fq_nmod_poly_init, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), z, ctx) - ccall((:fq_nmod_poly_set, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - z, a, ctx) + @ccall libflint.fq_nmod_poly_init(z::Ref{fqPolyRepPolyRingElem}, ctx::Ref{fqPolyRepField})::Nothing + @ccall libflint.fq_nmod_poly_set(z::Ref{fqPolyRepPolyRingElem}, a::Ref{fqPolyRepPolyRingElem}, ctx::Ref{fqPolyRepField})::Nothing finalizer(_fq_nmod_poly_clear_fn, z) return z end @@ -5395,11 +4905,8 @@ mutable struct fqPolyRepPolyRingElem <: PolyRingElem{fqPolyRepFieldElem} function fqPolyRepPolyRingElem(a::fqPolyRepFieldElem) z = new() ctx = parent(a) - ccall((:fq_nmod_poly_init, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), z, ctx) - ccall((:fq_nmod_poly_set_fq_nmod, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, a, ctx) + @ccall libflint.fq_nmod_poly_init(z::Ref{fqPolyRepPolyRingElem}, ctx::Ref{fqPolyRepField})::Nothing + @ccall libflint.fq_nmod_poly_set_fq_nmod(z::Ref{fqPolyRepPolyRingElem}, a::Ref{fqPolyRepFieldElem}, ctx::Ref{fqPolyRepField})::Nothing finalizer(_fq_nmod_poly_clear_fn, z) return z end @@ -5407,13 +4914,9 @@ mutable struct fqPolyRepPolyRingElem <: PolyRingElem{fqPolyRepFieldElem} function fqPolyRepPolyRingElem(a::Vector{fqPolyRepFieldElem}) z = new() ctx = parent(a[1]) - ccall((:fq_nmod_poly_init2, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepField}), - z, length(a), ctx) + @ccall libflint.fq_nmod_poly_init2(z::Ref{fqPolyRepPolyRingElem}, length(a)::Int, ctx::Ref{fqPolyRepField})::Nothing for i = 1:length(a) - ccall((:fq_nmod_poly_set_coeff, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, i - 1, a[i], ctx) + @ccall libflint.fq_nmod_poly_set_coeff(z::Ref{fqPolyRepPolyRingElem}, (i - 1)::Int, a[i]::Ref{fqPolyRepFieldElem}, ctx::Ref{fqPolyRepField})::Nothing end finalizer(_fq_nmod_poly_clear_fn, z) return z @@ -5422,14 +4925,10 @@ mutable struct fqPolyRepPolyRingElem <: PolyRingElem{fqPolyRepFieldElem} function fqPolyRepPolyRingElem(a::Vector{ZZRingElem}, ctx::fqPolyRepField) z = new() temp = ctx() - ccall((:fq_nmod_poly_init2, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepField}), - z, length(a), ctx) + @ccall libflint.fq_nmod_poly_init2(z::Ref{fqPolyRepPolyRingElem}, length(a)::Int, ctx::Ref{fqPolyRepField})::Nothing for i = 1:length(a) temp = ctx(a[i]) - ccall((:fq_nmod_poly_set_coeff, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, i - 1, temp, ctx) + @ccall libflint.fq_nmod_poly_set_coeff(z::Ref{fqPolyRepPolyRingElem}, (i - 1)::Int, temp::Ref{fqPolyRepFieldElem}, ctx::Ref{fqPolyRepField})::Nothing end finalizer(_fq_nmod_poly_clear_fn, z) return z @@ -5437,14 +4936,10 @@ mutable struct fqPolyRepPolyRingElem <: PolyRingElem{fqPolyRepFieldElem} function fqPolyRepPolyRingElem(a::ZZPolyRingElem, ctx::fqPolyRepField) z = new() - ccall((:fq_nmod_poly_init2, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepField}), - z, length(a), ctx) + @ccall libflint.fq_nmod_poly_init2(z::Ref{fqPolyRepPolyRingElem}, length(a)::Int, ctx::Ref{fqPolyRepField})::Nothing for i = 1:length(a) temp = ctx(coeff(a,i-1)) - ccall((:fq_nmod_poly_set_coeff, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, i - 1, temp, ctx) + @ccall libflint.fq_nmod_poly_set_coeff(z::Ref{fqPolyRepPolyRingElem}, (i - 1)::Int, temp::Ref{fqPolyRepFieldElem}, ctx::Ref{fqPolyRepField})::Nothing end finalizer(_fq_nmod_poly_clear_fn, z) return z @@ -5452,7 +4947,7 @@ mutable struct fqPolyRepPolyRingElem <: PolyRingElem{fqPolyRepFieldElem} end function _fq_nmod_poly_clear_fn(a::fqPolyRepPolyRingElem) - ccall((:fq_nmod_poly_clear, libflint), Nothing, (Ref{fqPolyRepPolyRingElem},), a) + @ccall libflint.fq_nmod_poly_clear(a::Ref{fqPolyRepPolyRingElem})::Nothing end mutable struct fq_nmod_poly_factor @@ -5464,8 +4959,7 @@ mutable struct fq_nmod_poly_factor function fq_nmod_poly_factor(ctx::fqPolyRepField) z = new() - ccall((:fq_nmod_poly_factor_init, libflint), Nothing, - (Ref{fq_nmod_poly_factor}, Ref{fqPolyRepField}), z, ctx) + @ccall libflint.fq_nmod_poly_factor_init(z::Ref{fq_nmod_poly_factor}, ctx::Ref{fqPolyRepField})::Nothing z.base_field = ctx finalizer(_fq_nmod_poly_factor_clear_fn, z) return z @@ -5473,9 +4967,7 @@ mutable struct fq_nmod_poly_factor end function _fq_nmod_poly_factor_clear_fn(a::fq_nmod_poly_factor) - ccall((:fq_nmod_poly_factor_clear, libflint), Nothing, - (Ref{fq_nmod_poly_factor}, Ref{fqPolyRepField}), - a, a.base_field) + @ccall libflint.fq_nmod_poly_factor_clear(a::Ref{fq_nmod_poly_factor}, a.base_field::Ref{fqPolyRepField})::Nothing end ############################################################################### @@ -5501,9 +4993,7 @@ mutable struct FqMatrix <: MatElem{FqFieldElem} function FqMatrix(r::Int, c::Int, ctx::FqField) z = new() - ccall((:fq_default_mat_init, libflint), Nothing, - (Ref{FqMatrix}, Int, Int, Ref{FqField}), - z, r, c, ctx) + @ccall libflint.fq_default_mat_init(z::Ref{FqMatrix}, r::Int, c::Int, ctx::Ref{FqField})::Nothing z.base_ring = ctx finalizer(_fq_default_mat_clear_fn, z) return z @@ -5540,9 +5030,7 @@ mutable struct FqMatrix <: MatElem{FqFieldElem} r = nrows(m) c = ncols(m) z = FqMatrix(r, c, ctx) - ccall((:fq_default_mat_set_fmpz_mat, libflint), Nothing, - (Ref{FqMatrix}, Ref{ZZMatrix}, Ref{FqField}), - z, m, ctx) + @ccall libflint.fq_default_mat_set_fmpz_mat(z::Ref{FqMatrix}, m::Ref{ZZMatrix}, ctx::Ref{FqField})::Nothing return z end @@ -5550,9 +5038,7 @@ mutable struct FqMatrix <: MatElem{FqFieldElem} r = nrows(m) c = ncols(m) z = FqMatrix(r, c, ctx) - ccall((:fq_default_mat_set_fmpz_mod_mat, libflint), Nothing, - (Ref{FqMatrix}, Ref{ZZModMatrix}, Ref{FqField}), - z, m, ctx) + @ccall libflint.fq_default_mat_set_fmpz_mod_mat(z::Ref{FqMatrix}, m::Ref{ZZModMatrix}, ctx::Ref{FqField})::Nothing return z end @@ -5560,9 +5046,7 @@ mutable struct FqMatrix <: MatElem{FqFieldElem} r = nrows(m) c = ncols(m) z = FqMatrix(r, c, ctx) - ccall((:fq_default_mat_set_nmod_mat, libflint), Nothing, - (Ref{FqMatrix}, Ref{zzModMatrix}, Ref{FqField}), - z, m, ctx) + @ccall libflint.fq_default_mat_set_nmod_mat(z::Ref{FqMatrix}, m::Ref{zzModMatrix}, ctx::Ref{FqField})::Nothing return z end @@ -5570,16 +5054,13 @@ mutable struct FqMatrix <: MatElem{FqFieldElem} r = nrows(m) c = ncols(m) z = FqMatrix(r, c, ctx) - ccall((:fq_default_mat_set_nmod_mat, libflint), Nothing, - (Ref{FqMatrix}, Ref{fpMatrix}, Ref{FqField}), - z, m, ctx) + @ccall libflint.fq_default_mat_set_nmod_mat(z::Ref{FqMatrix}, m::Ref{fpMatrix}, ctx::Ref{FqField})::Nothing return z end end function _fq_default_mat_clear_fn(a::FqMatrix) - ccall((:fq_default_mat_clear, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqField}), a, base_ring(a)) + @ccall libflint.fq_default_mat_clear(a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing end ############################################################################### @@ -5605,8 +5086,7 @@ mutable struct FqPolyRepMatrix <: MatElem{FqPolyRepFieldElem} function FqPolyRepMatrix(r::Int, c::Int, ctx::FqPolyRepField) z = new() - ccall((:fq_mat_init, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Int, Int, Ref{FqPolyRepField}), z, r, c, ctx) + @ccall libflint.fq_mat_init(z::Ref{FqPolyRepMatrix}, r::Int, c::Int, ctx::Ref{FqPolyRepField})::Nothing z.base_ring = ctx finalizer(_fq_mat_clear_fn, z) return z @@ -5648,8 +5128,7 @@ mutable struct FqPolyRepMatrix <: MatElem{FqPolyRepFieldElem} el1 = mat_entry_ptr(z, i, j) el2 = mat_entry_ptr(m, i, j) - ccall((:fq_set_fmpz, libflint), Nothing, - (Ptr{FqPolyRepFieldElem}, Ptr{ZZRingElem}, Ref{FqPolyRepField}), el1, el2, ctx) + @ccall libflint.fq_set_fmpz(el1::Ptr{FqPolyRepFieldElem}, el2::Ptr{ZZRingElem}, ctx::Ref{FqPolyRepField})::Nothing end end return z @@ -5657,7 +5136,7 @@ mutable struct FqPolyRepMatrix <: MatElem{FqPolyRepFieldElem} end function _fq_mat_clear_fn(a::FqPolyRepMatrix) - ccall((:fq_mat_clear, libflint), Nothing, (Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), a, base_ring(a)) + @ccall libflint.fq_mat_clear(a::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Nothing end ############################################################################### @@ -5683,8 +5162,7 @@ mutable struct fqPolyRepMatrix <: MatElem{fqPolyRepFieldElem} function fqPolyRepMatrix(r::Int, c::Int, ctx::fqPolyRepField) z = new() - ccall((:fq_nmod_mat_init, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Int, Int, Ref{fqPolyRepField}), z, r, c, ctx) + @ccall libflint.fq_nmod_mat_init(z::Ref{fqPolyRepMatrix}, r::Int, c::Int, ctx::Ref{fqPolyRepField})::Nothing z.base_ring = ctx finalizer(_fq_nmod_mat_clear_fn, z) return z @@ -5726,8 +5204,7 @@ mutable struct fqPolyRepMatrix <: MatElem{fqPolyRepFieldElem} el1 = mat_entry_ptr(z, i, j) el2 = mat_entry_ptr(m, i, j) - ccall((:fq_nmod_set_fmpz, libflint), Nothing, - (Ptr{fqPolyRepFieldElem}, Ptr{ZZRingElem}, Ref{fqPolyRepField}), el1, el2, ctx) + @ccall libflint.fq_nmod_set_fmpz(el1::Ptr{fqPolyRepFieldElem}, el2::Ptr{ZZRingElem}, ctx::Ref{fqPolyRepField})::Nothing end end return z @@ -5735,7 +5212,7 @@ mutable struct fqPolyRepMatrix <: MatElem{fqPolyRepFieldElem} end function _fq_nmod_mat_clear_fn(a::fqPolyRepMatrix) - ccall((:fq_nmod_mat_clear, libflint), Nothing, (Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), a, base_ring(a)) + @ccall libflint.fq_nmod_mat_clear(a::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Nothing end ################################################################################ @@ -5752,14 +5229,14 @@ if NEW_FLINT function rand_ctx() a = new() - ccall((:flint_rand_init, libflint), Cvoid, (Ref{rand_ctx},), a) + @ccall libflint.flint_rand_init(a::Ref{rand_ctx})::Cvoid finalizer(_rand_ctx_clear_fn, a) return a end end function _rand_ctx_clear_fn(a::rand_ctx) - ccall((:flint_rand_clear, libflint), Cvoid, (Ref{rand_ctx},), a) + @ccall libflint.flint_rand_clear(a::Ref{rand_ctx})::Cvoid nothing end else @@ -5768,14 +5245,14 @@ else function rand_ctx() a = new() - ccall((:flint_randinit, libflint), Cvoid, (Ref{rand_ctx},), a) + @ccall libflint.flint_randinit(a::Ref{rand_ctx})::Cvoid finalizer(_rand_ctx_clear_fn, a) return a end end function _rand_ctx_clear_fn(a::rand_ctx) - ccall((:flint_randclear, libflint), Cvoid, (Ref{rand_ctx},), a) + @ccall libflint.flint_randclear(a::Ref{rand_ctx})::Cvoid nothing end end diff --git a/src/flint/fmpq.jl b/src/flint/fmpq.jl index 462e1548e..77fd77d5a 100644 --- a/src/flint/fmpq.jl +++ b/src/flint/fmpq.jl @@ -87,7 +87,7 @@ Return the sign of $a$ ($-1$, $0$ or $1$) as a fraction. """ sign(a::QQFieldElem) = QQFieldElem(sign(numerator(a))) -sign(::Type{Int}, a::QQFieldElem) = Int(ccall((:fmpq_sgn, libflint), Cint, (Ref{QQFieldElem},), a)) +sign(::Type{Int}, a::QQFieldElem) = Int(@ccall libflint.fmpq_sgn(a::Ref{QQFieldElem})::Cint) Base.signbit(a::QQFieldElem) = signbit(sign(Int, a)) @@ -96,7 +96,7 @@ is_positive(n::QQFieldElem) = sign(Int, n) > 0 function abs(a::QQFieldElem) z = QQFieldElem() - ccall((:fmpq_abs, libflint), Nothing, (Ref{QQFieldElem}, Ref{QQFieldElem}), z, a) + @ccall libflint.fmpq_abs(z::Ref{QQFieldElem}, a::Ref{QQFieldElem})::Nothing return z end @@ -130,7 +130,7 @@ values of the numerator and denominator. """ function height(a::QQFieldElem) temp = ZZRingElem() - ccall((:fmpq_height, libflint), Nothing, (Ref{ZZRingElem}, Ref{QQFieldElem}), temp, a) + @ccall libflint.fmpq_height(temp::Ref{ZZRingElem}, a::Ref{QQFieldElem})::Nothing return temp end @@ -140,7 +140,7 @@ end Return the number of bits of the height of the fraction $a$. """ function height_bits(a::QQFieldElem) - return ccall((:fmpq_height_bits, libflint), Int, (Ref{QQFieldElem},), a) + return @ccall libflint.fmpq_height_bits(a::Ref{QQFieldElem})::Int end function deepcopy_internal(a::QQFieldElem, dict::IdDict) @@ -372,14 +372,13 @@ end ############################################################################### function ==(a::QQFieldElem, b::Int) - return ccall((:fmpq_equal_si, libflint), Bool, (Ref{QQFieldElem}, Int), a, b) + return @ccall libflint.fmpq_equal_si(a::Ref{QQFieldElem}, b::Int)::Bool end ==(a::Int, b::QQFieldElem) = b == a function ==(a::QQFieldElem, b::ZZRingElem) - return ccall((:fmpq_equal_fmpz, libflint), Bool, - (Ref{QQFieldElem}, Ref{ZZRingElem}), a, b) + return @ccall libflint.fmpq_equal_fmpz(a::Ref{QQFieldElem}, b::Ref{ZZRingElem})::Bool end ==(a::ZZRingElem, b::QQFieldElem) = b == a @@ -413,8 +412,7 @@ isless(a::QQFieldElem, b::Float64) = isless(BigFloat(a), b) function ^(a::QQFieldElem, b::Int) iszero(a) && b < 0 && throw(DivideError()) temp = QQFieldElem() - ccall((:fmpq_pow_si, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Int), temp, a, b) + @ccall libflint.fmpq_pow_si(temp::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Int)::Nothing return temp end @@ -438,8 +436,7 @@ Return $a/2^b$. """ function >>(a::QQFieldElem, b::Int) z = QQFieldElem() - ccall((:fmpq_div_2exp, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Int), z, a, b) + @ccall libflint.fmpq_div_2exp(z::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Int)::Nothing return z end @@ -450,8 +447,7 @@ Return $a \times 2^b$. """ function <<(a::QQFieldElem, b::Int) z = QQFieldElem() - ccall((:fmpq_mul_2exp, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Int), z, a, b) + @ccall libflint.fmpq_mul_2exp(z::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Int)::Nothing return z end @@ -548,7 +544,7 @@ function inv(a::QQFieldElem) error("Element not invertible") end z = QQFieldElem() - ccall((:fmpq_inv, libflint), Nothing, (Ref{QQFieldElem}, Ref{QQFieldElem}), z, a) + @ccall libflint.fmpq_inv(z::Ref{QQFieldElem}, a::Ref{QQFieldElem})::Nothing return z end @@ -635,8 +631,7 @@ julia> mod(ZZ(1)//2, ZZ(5)) function mod(a::QQFieldElem, b::ZZRingElem) iszero(b) && throw(DivideError()) z = ZZRingElem() - ccall((:fmpq_mod_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{QQFieldElem}, Ref{ZZRingElem}), z, a, b) + @ccall libflint.fmpq_mod_fmpz(z::Ref{ZZRingElem}, a::Ref{QQFieldElem}, b::Ref{ZZRingElem})::Nothing return z end @@ -650,8 +645,7 @@ mod(a::QQFieldElem, b::Integer) = mod(a, ZZRingElem(b)) function gcd(a::QQFieldElem, b::QQFieldElem) z = QQFieldElem() - ccall((:fmpq_gcd, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Ref{QQFieldElem}), z, a, b) + @ccall libflint.fmpq_gcd(z::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Ref{QQFieldElem})::Nothing return z end @@ -751,9 +745,7 @@ Returns a tuple (`success`, `n/d`), where `success` signals the success of recon """ function reconstruct(a::ZZRingElem, m::ZZRingElem, N::ZZRingElem, D::ZZRingElem) c = QQFieldElem() - success = Bool(ccall((:fmpq_reconstruct_fmpz_2, libflint), Cint, - (Ref{QQFieldElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - c, a, m, N, D)) + success = Bool(@ccall libflint.fmpq_reconstruct_fmpz_2(c::Ref{QQFieldElem}, a::Ref{ZZRingElem}, m::Ref{ZZRingElem}, N::Ref{ZZRingElem}, D::Ref{ZZRingElem})::Cint) return success, c end @@ -765,8 +757,7 @@ Returns a tuple (`success`, `n/d`), where `success` signals the success of recon """ function unsafe_reconstruct(a::ZZRingElem, m::ZZRingElem) c = QQFieldElem() - success = Bool(ccall((:fmpq_reconstruct_fmpz, libflint), Cint, - (Ref{QQFieldElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), c, a, m)) + success = Bool(@ccall libflint.fmpq_reconstruct_fmpz(c::Ref{QQFieldElem}, a::Ref{ZZRingElem}, m::Ref{ZZRingElem})::Cint) return success, c end @@ -799,7 +790,7 @@ julia> next_minimal(ZZ(2)//3) function next_minimal(a::QQFieldElem) a < 0 && throw(DomainError(a, "Argument must be non-negative")) c = QQFieldElem() - ccall((:fmpq_next_minimal, libflint), Nothing, (Ref{QQFieldElem}, Ref{QQFieldElem}), c, a) + @ccall libflint.fmpq_next_minimal(c::Ref{QQFieldElem}, a::Ref{QQFieldElem})::Nothing return c end @@ -822,8 +813,7 @@ julia> next_signed_minimal(-ZZ(21)//31) """ function next_signed_minimal(a::QQFieldElem) c = QQFieldElem() - ccall((:fmpq_next_signed_minimal, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}), c, a) + @ccall libflint.fmpq_next_signed_minimal(c::Ref{QQFieldElem}, a::Ref{QQFieldElem})::Nothing return c end @@ -849,8 +839,7 @@ julia> next_calkin_wilf(ZZ(321)//113) function next_calkin_wilf(a::QQFieldElem) a < 0 && throw(DomainError(a, "Argument must be non-negative")) c = QQFieldElem() - ccall((:fmpq_next_calkin_wilf, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}), c, a) + @ccall libflint.fmpq_next_calkin_wilf(c::Ref{QQFieldElem}, a::Ref{QQFieldElem})::Nothing return c end @@ -872,8 +861,7 @@ julia> next_signed_calkin_wilf(-ZZ(51)//(17)) """ function next_signed_calkin_wilf(a::QQFieldElem) c = QQFieldElem() - ccall((:fmpq_next_signed_calkin_wilf, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}), c, a) + @ccall libflint.fmpq_next_signed_calkin_wilf(c::Ref{QQFieldElem}, a::Ref{QQFieldElem})::Nothing return c end @@ -900,7 +888,7 @@ julia> a = harmonic(12) function harmonic(n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) c = QQFieldElem() - ccall((:fmpq_harmonic_ui, libflint), Nothing, (Ref{QQFieldElem}, Int), c, n) + @ccall libflint.fmpq_harmonic_ui(c::Ref{QQFieldElem}, n::Int)::Nothing return c end @@ -921,7 +909,7 @@ julia> d = bernoulli(12) function bernoulli(n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) c = QQFieldElem() - ccall((:bernoulli_fmpq_ui, libflint), Nothing, (Ref{QQFieldElem}, Int), c, n) + @ccall libflint.bernoulli_fmpq_ui(c::Ref{QQFieldElem}, n::Int)::Nothing return c end @@ -947,7 +935,7 @@ julia> e = bernoulli(100) function bernoulli_cache(n::Int) n = n + 1 n < 0 && throw(DomainError(n, "Index must be non-negative")) - ccall((:bernoulli_cache_compute, libflint), Nothing, (Int,), n) + @ccall libflint.bernoulli_cache_compute(n::Int)::Nothing end @doc raw""" @@ -967,8 +955,7 @@ julia> c = dedekind_sum(-120, ZZ(1305)) """ function dedekind_sum(h::ZZRingElem, k::ZZRingElem) c = QQFieldElem() - ccall((:fmpq_dedekind_sum, libflint), Nothing, - (Ref{QQFieldElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), c, h, k) + @ccall libflint.fmpq_dedekind_sum(c::Ref{QQFieldElem}, h::Ref{ZZRingElem}, k::Ref{ZZRingElem})::Nothing return c end @@ -992,9 +979,7 @@ function _fmpq_simplest_between(l_num::ZZRingElem, l_den::ZZRingElem, n = ZZRingElem() d = ZZRingElem() - ccall((:_fmpq_simplest_between, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - n, d, l_num, l_den, r_num, r_den) + @ccall libflint._fmpq_simplest_between(n::Ref{ZZRingElem}, d::Ref{ZZRingElem}, l_num::Ref{ZZRingElem}, l_den::Ref{ZZRingElem}, r_num::Ref{ZZRingElem}, r_den::Ref{ZZRingElem})::Nothing return n//d end @@ -1016,8 +1001,7 @@ julia> simplest_between(QQ(1//10), QQ(3//10)) """ function simplest_between(l::QQFieldElem, r::QQFieldElem) z = QQFieldElem() - ccall((:fmpq_simplest_between, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Ref{QQFieldElem}), z, l, r) + @ccall libflint.fmpq_simplest_between(z::Ref{QQFieldElem}, l::Ref{QQFieldElem}, r::Ref{QQFieldElem})::Nothing return z end @@ -1043,7 +1027,7 @@ function one!(c::QQFieldElemOrPtr) end function neg!(z::QQFieldElemOrPtr, a::QQFieldElemOrPtr) - ccall((:fmpq_neg, libflint), Nothing, (Ref{QQFieldElem}, Ref{QQFieldElem}), z, a) + @ccall libflint.fmpq_neg(z::Ref{QQFieldElem}, a::Ref{QQFieldElem})::Nothing return z end @@ -1088,26 +1072,22 @@ end # function add!(c::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::QQFieldElemOrPtr) - ccall((:fmpq_add, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Ref{QQFieldElem}), c, a, b) + @ccall libflint.fmpq_add(c::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Ref{QQFieldElem})::Nothing return c end function add!(c::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::ZZRingElemOrPtr) - ccall((:fmpq_add_fmpz, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Ref{ZZRingElem}), c, a, b) + @ccall libflint.fmpq_add_fmpz(c::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Ref{ZZRingElem})::Nothing return c end function add!(c::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::Int) - ccall((:fmpq_add_si, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Int), c, a, b) + @ccall libflint.fmpq_add_si(c::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Int)::Nothing return c end function add!(c::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::UInt) - ccall((:fmpq_add_ui, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Int), c, a, b) + @ccall libflint.fmpq_add_ui(c::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Int)::Nothing return c end @@ -1117,25 +1097,22 @@ add!(c::QQFieldElemOrPtr, a::Union{ZZRingElemOrPtr, Integer, Rational}, b::QQFie # function sub!(z::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::QQFieldElemOrPtr) - ccall((:fmpq_sub, libflint), Nothing, (Ref{QQFieldElem}, Ref{QQFieldElem}, Ref{QQFieldElem}), z, a, b) + @ccall libflint.fmpq_sub(z::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Ref{QQFieldElem})::Nothing return z end function sub!(z::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::ZZRingElemOrPtr) - ccall((:fmpq_sub_fmpz, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Ref{ZZRingElem}), z, a, b) + @ccall libflint.fmpq_sub_fmpz(z::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Ref{ZZRingElem})::Nothing return z end function sub!(z::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::Int) - ccall((:fmpq_sub_si, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Int), z, a, b) + @ccall libflint.fmpq_sub_si(z::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Int)::Nothing return z end function sub!(z::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::UInt) - ccall((:fmpq_sub_ui, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, UInt), z, a, b) + @ccall libflint.fmpq_sub_ui(z::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::UInt)::Nothing return z end @@ -1145,26 +1122,22 @@ sub!(c::QQFieldElemOrPtr, a::Union{ZZRingElemOrPtr, Integer, Rational}, b::QQFie # function mul!(c::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::QQFieldElemOrPtr) - ccall((:fmpq_mul, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Ref{QQFieldElem}), c, a, b) + @ccall libflint.fmpq_mul(c::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Ref{QQFieldElem})::Nothing return c end function mul!(c::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::ZZRingElemOrPtr) - ccall((:fmpq_mul_fmpz, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Ref{ZZRingElem}), c, a, b) + @ccall libflint.fmpq_mul_fmpz(c::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Ref{ZZRingElem})::Nothing return c end function mul!(c::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::Int) - ccall((:fmpq_mul_si, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Int), c, a, b) + @ccall libflint.fmpq_mul_si(c::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Int)::Nothing return c end function mul!(c::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::UInt) - ccall((:fmpq_mul_ui, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, UInt), c, a, b) + @ccall libflint.fmpq_mul_ui(c::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::UInt)::Nothing return c end @@ -1174,26 +1147,24 @@ mul!(c::QQFieldElemOrPtr, a::Union{ZZRingElemOrPtr, Integer, Rational}, b::QQFie # function addmul!(c::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::QQFieldElemOrPtr) - ccall((:fmpq_addmul, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Ref{QQFieldElem}), c, a, b) + @ccall libflint.fmpq_addmul(c::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Ref{QQFieldElem})::Nothing return c end function submul!(c::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::QQFieldElemOrPtr) - ccall((:fmpq_submul, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQFieldElem}, Ref{QQFieldElem}), c, a, b) + @ccall libflint.fmpq_submul(c::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Ref{QQFieldElem})::Nothing return c end # function divexact!(z::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::QQFieldElemOrPtr) - ccall((:fmpq_div, libflint), Nothing, (Ref{QQFieldElem}, Ref{QQFieldElem}, Ref{QQFieldElem}), z, a, b) + @ccall libflint.fmpq_div(z::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Ref{QQFieldElem})::Nothing return z end function divexact!(z::QQFieldElemOrPtr, a::QQFieldElemOrPtr, b::ZZRingElemOrPtr) - ccall((:fmpq_div_fmpz, libflint), Nothing, (Ref{QQFieldElem}, Ref{QQFieldElem}, Ref{ZZRingElem}), z, a, b) + @ccall libflint.fmpq_div_fmpz(z::Ref{QQFieldElem}, a::Ref{QQFieldElem}, b::Ref{ZZRingElem})::Nothing return z end @@ -1256,8 +1227,7 @@ denominator can be smaller than $b$ bits. function rand_bits(::QQField, b::Int) b > 0 || throw(DomainError(b, "Bit count must be positive")) z = QQFieldElem() - ccall((:fmpq_randbits, libflint), Nothing, (Ref{QQFieldElem}, Ref{rand_ctx}, Int), - z, _flint_rand_states[Threads.threadid()], b) + @ccall libflint.fmpq_randbits(z::Ref{QQFieldElem}, _flint_rand_states[Threads.threadid()]::Ref{rand_ctx}, b::Int)::Nothing return z end @@ -1295,8 +1265,7 @@ end function Base.Rational{BigInt}(z::QQFieldElem) r = Rational{BigInt}(0) - ccall((:fmpq_get_mpz_frac, libflint), Nothing, - (Ref{BigInt}, Ref{BigInt}, Ref{QQFieldElem}), r.num, r.den, z) + @ccall libflint.fmpq_get_mpz_frac(r.num::Ref{BigInt}, r.den::Ref{BigInt}, z::Ref{QQFieldElem})::Nothing return r end @@ -1316,7 +1285,7 @@ end function BigFloat(a::QQFieldElem) r = BigFloat(0) - ccall((:fmpq_get_mpfr, libflint), Cint, (Ref{BigFloat}, Ref{QQFieldElem}, Int32), r, a, __get_rounding_mode()) + @ccall libflint.fmpq_get_mpfr(r::Ref{BigFloat}, a::Ref{QQFieldElem}, __get_rounding_mode()::Int32)::Cint return r end diff --git a/src/flint/fmpq_abs_series.jl b/src/flint/fmpq_abs_series.jl index 010b4a601..3cc82e806 100644 --- a/src/flint/fmpq_abs_series.jl +++ b/src/flint/fmpq_abs_series.jl @@ -43,14 +43,12 @@ max_precision(R::QQAbsPowerSeriesRing) = R.prec_max function normalise(a::QQAbsPowerSeriesRingElem, len::Int) if len > 0 c = QQFieldElem() - ccall((:fmpq_poly_get_coeff_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQAbsPowerSeriesRingElem}, Int), c, a, len - 1) + @ccall libflint.fmpq_poly_get_coeff_fmpq(c::Ref{QQFieldElem}, a::Ref{QQAbsPowerSeriesRingElem}, (len - 1)::Int)::Nothing end while len > 0 && iszero(c) len -= 1 if len > 0 - ccall((:fmpq_poly_get_coeff_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQAbsPowerSeriesRingElem}, Int), c, a, len - 1) + @ccall libflint.fmpq_poly_get_coeff_fmpq(c::Ref{QQFieldElem}, a::Ref{QQAbsPowerSeriesRingElem}, (len - 1)::Int)::Nothing end end @@ -62,13 +60,12 @@ function coeff(x::QQAbsPowerSeriesRingElem, n::Int) return QQFieldElem(0) end z = QQFieldElem() - ccall((:fmpq_poly_get_coeff_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQAbsPowerSeriesRingElem}, Int), z, x, n) + @ccall libflint.fmpq_poly_get_coeff_fmpq(z::Ref{QQFieldElem}, x::Ref{QQAbsPowerSeriesRingElem}, n::Int)::Nothing return z end function length(x::QQAbsPowerSeriesRingElem) - return ccall((:fmpq_poly_length, libflint), Int, (Ref{QQAbsPowerSeriesRingElem},), x) + return @ccall libflint.fmpq_poly_length(x::Ref{QQAbsPowerSeriesRingElem})::Int end precision(x::QQAbsPowerSeriesRingElem) = x.prec @@ -91,8 +88,7 @@ function deepcopy_internal(a::QQAbsPowerSeriesRingElem, dict::IdDict) end function is_gen(a::QQAbsPowerSeriesRingElem) - return precision(a) == 0 || ccall((:fmpq_poly_is_gen, libflint), Bool, - (Ref{QQAbsPowerSeriesRingElem},), a) + return precision(a) == 0 || @ccall libflint.fmpq_poly_is_gen(a::Ref{QQAbsPowerSeriesRingElem})::Bool end iszero(a::QQAbsPowerSeriesRingElem) = length(a) == 0 @@ -100,8 +96,7 @@ iszero(a::QQAbsPowerSeriesRingElem) = length(a) == 0 is_unit(a::QQAbsPowerSeriesRingElem) = valuation(a) == 0 && is_unit(coeff(a, 0)) function isone(a::QQAbsPowerSeriesRingElem) - return precision(a) == 0 || ccall((:fmpq_poly_is_one, libflint), Bool, - (Ref{QQAbsPowerSeriesRingElem},), a) + return precision(a) == 0 || @ccall libflint.fmpq_poly_is_one(a::Ref{QQAbsPowerSeriesRingElem})::Bool end # todo: write an fmpq_poly_valuation @@ -161,9 +156,7 @@ end function -(x::QQAbsPowerSeriesRingElem) z = parent(x)() - ccall((:fmpq_poly_neg, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}), - z, x) + @ccall libflint.fmpq_poly_neg(z::Ref{QQAbsPowerSeriesRingElem}, x::Ref{QQAbsPowerSeriesRingElem})::Nothing z.prec = x.prec return z end @@ -187,9 +180,7 @@ function +(a::QQAbsPowerSeriesRingElem, b::QQAbsPowerSeriesRingElem) lenz = max(lena, lenb) z = parent(a)() z.prec = prec - ccall((:fmpq_poly_add_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpq_poly_add_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, b::Ref{QQAbsPowerSeriesRingElem}, lenz::Int)::Nothing return z end @@ -206,9 +197,7 @@ function -(a::QQAbsPowerSeriesRingElem, b::QQAbsPowerSeriesRingElem) lenz = max(lena, lenb) z = parent(a)() z.prec = prec - ccall((:fmpq_poly_sub_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpq_poly_sub_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, b::Ref{QQAbsPowerSeriesRingElem}, lenz::Int)::Nothing return z end @@ -235,9 +224,7 @@ function *(a::QQAbsPowerSeriesRingElem, b::QQAbsPowerSeriesRingElem) lenz = min(lena + lenb - 1, prec) - ccall((:fmpq_poly_mullow, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpq_poly_mullow(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, b::Ref{QQAbsPowerSeriesRingElem}, lenz::Int)::Nothing return z end @@ -251,27 +238,21 @@ end function *(x::Int, y::QQAbsPowerSeriesRingElem) z = parent(y)() z.prec = y.prec - ccall((:fmpq_poly_scalar_mul_si, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, y, x) + @ccall libflint.fmpq_poly_scalar_mul_si(z::Ref{QQAbsPowerSeriesRingElem}, y::Ref{QQAbsPowerSeriesRingElem}, x::Int)::Nothing return z end function *(x::ZZRingElem, y::QQAbsPowerSeriesRingElem) z = parent(y)() z.prec = y.prec - ccall((:fmpq_poly_scalar_mul_fmpz, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Ref{ZZRingElem}), - z, y, x) + @ccall libflint.fmpq_poly_scalar_mul_fmpz(z::Ref{QQAbsPowerSeriesRingElem}, y::Ref{QQAbsPowerSeriesRingElem}, x::Ref{ZZRingElem})::Nothing return z end function *(x::QQFieldElem, y::QQAbsPowerSeriesRingElem) z = parent(y)() z.prec = y.prec - ccall((:fmpq_poly_scalar_mul_fmpq, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Ref{QQFieldElem}), - z, y, x) + @ccall libflint.fmpq_poly_scalar_mul_fmpq(z::Ref{QQAbsPowerSeriesRingElem}, y::Ref{QQAbsPowerSeriesRingElem}, x::Ref{QQFieldElem})::Nothing return z end @@ -310,12 +291,8 @@ function shift_left(x::QQAbsPowerSeriesRingElem, len::Int) z.prec = x.prec + len z.prec = min(z.prec, max_precision(parent(x))) zlen = min(z.prec, xlen + len) - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, x, len) - ccall((:fmpq_poly_set_trunc, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, z, zlen) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQAbsPowerSeriesRingElem}, x::Ref{QQAbsPowerSeriesRingElem}, len::Int)::Nothing + @ccall libflint.fmpq_poly_set_trunc(z::Ref{QQAbsPowerSeriesRingElem}, z::Ref{QQAbsPowerSeriesRingElem}, zlen::Int)::Nothing return z end @@ -327,9 +304,7 @@ function shift_right(x::QQAbsPowerSeriesRingElem, len::Int) z.prec = max(0, x.prec - len) else z.prec = x.prec - len - ccall((:fmpq_poly_shift_right, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, x, len) + @ccall libflint.fmpq_poly_shift_right(z::Ref{QQAbsPowerSeriesRingElem}, x::Ref{QQAbsPowerSeriesRingElem}, len::Int)::Nothing end return z end @@ -349,9 +324,7 @@ function truncate!(x::QQAbsPowerSeriesRingElem, k::Int) if precision(x) <= k return x end - ccall((:fmpq_poly_truncate, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Int), - x, k) + @ccall libflint.fmpq_poly_truncate(x::Ref{QQAbsPowerSeriesRingElem}, k::Int)::Nothing x.prec = k return x end @@ -406,9 +379,7 @@ function ==(x::QQAbsPowerSeriesRingElem, y::QQAbsPowerSeriesRingElem) n = max(length(x), length(y)) n = min(n, prec) - return Bool(ccall((:fmpq_poly_equal_trunc, libflint), Cint, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - x, y, n)) + return Bool(@ccall libflint.fmpq_poly_equal_trunc(x::Ref{QQAbsPowerSeriesRingElem}, y::Ref{QQAbsPowerSeriesRingElem}, n::Int)::Cint) end function isequal(x::QQAbsPowerSeriesRingElem, y::QQAbsPowerSeriesRingElem) @@ -418,9 +389,7 @@ function isequal(x::QQAbsPowerSeriesRingElem, y::QQAbsPowerSeriesRingElem) if x.prec != y.prec || length(x) != length(y) return false end - return Bool(ccall((:fmpq_poly_equal, libflint), Cint, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}), - x, y)) + return Bool(@ccall libflint.fmpq_poly_equal(x::Ref{QQAbsPowerSeriesRingElem}, y::Ref{QQAbsPowerSeriesRingElem})::Cint) end ############################################################################### @@ -458,9 +427,7 @@ function divexact(x::QQAbsPowerSeriesRingElem, y::QQAbsPowerSeriesRingElem; chec prec = min(x.prec, y.prec - v2 + v1) z = parent(x)() z.prec = prec - ccall((:fmpq_poly_div_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, x, y, prec) + @ccall libflint.fmpq_poly_div_series(z::Ref{QQAbsPowerSeriesRingElem}, x::Ref{QQAbsPowerSeriesRingElem}, y::Ref{QQAbsPowerSeriesRingElem}, prec::Int)::Nothing return z end @@ -474,9 +441,7 @@ function divexact(x::QQAbsPowerSeriesRingElem, y::Int; check::Bool=true) y == 0 && throw(DivideError()) z = parent(x)() z.prec = x.prec - ccall((:fmpq_poly_scalar_div_si, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, x, y) + @ccall libflint.fmpq_poly_scalar_div_si(z::Ref{QQAbsPowerSeriesRingElem}, x::Ref{QQAbsPowerSeriesRingElem}, y::Int)::Nothing return z end @@ -484,9 +449,7 @@ function divexact(x::QQAbsPowerSeriesRingElem, y::ZZRingElem; check::Bool=true) iszero(y) && throw(DivideError()) z = parent(x)() z.prec = x.prec - ccall((:fmpq_poly_scalar_div_fmpz, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Ref{ZZRingElem}), - z, x, y) + @ccall libflint.fmpq_poly_scalar_div_fmpz(z::Ref{QQAbsPowerSeriesRingElem}, x::Ref{QQAbsPowerSeriesRingElem}, y::Ref{ZZRingElem})::Nothing return z end @@ -494,9 +457,7 @@ function divexact(x::QQAbsPowerSeriesRingElem, y::QQFieldElem; check::Bool=true) iszero(y) && throw(DivideError()) z = parent(x)() z.prec = x.prec - ccall((:fmpq_poly_scalar_div_fmpq, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Ref{QQFieldElem}), - z, x, y) + @ccall libflint.fmpq_poly_scalar_div_fmpq(z::Ref{QQAbsPowerSeriesRingElem}, x::Ref{QQAbsPowerSeriesRingElem}, y::Ref{QQFieldElem})::Nothing return z end @@ -515,9 +476,7 @@ function inv(a::QQAbsPowerSeriesRingElem) !is_unit(a) && error("Unable to invert power series") ainv = parent(a)() ainv.prec = a.prec - ccall((:fmpq_poly_inv_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - ainv, a, a.prec) + @ccall libflint.fmpq_poly_inv_series(ainv::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return ainv end @@ -534,9 +493,7 @@ function Base.exp(a::QQAbsPowerSeriesRingElem) end z = parent(a)() z.prec = a.prec - ccall((:fmpq_poly_exp_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_exp_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return z end @@ -547,9 +504,7 @@ function log(a::QQAbsPowerSeriesRingElem) end z = parent(a)() z.prec = a.prec - ccall((:fmpq_poly_log_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_log_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return z end @@ -560,9 +515,7 @@ function tan(a::QQAbsPowerSeriesRingElem) end z = parent(a)() z.prec = a.prec - ccall((:fmpq_poly_tan_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_tan_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return z end @@ -573,9 +526,7 @@ function tanh(a::QQAbsPowerSeriesRingElem) end z = parent(a)() z.prec = a.prec - ccall((:fmpq_poly_tanh_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_tanh_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return z end @@ -586,9 +537,7 @@ function sin(a::QQAbsPowerSeriesRingElem) end z = parent(a)() z.prec = a.prec - ccall((:fmpq_poly_sin_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_sin_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return z end @@ -599,9 +548,7 @@ function sinh(a::QQAbsPowerSeriesRingElem) end z = parent(a)() z.prec = a.prec - ccall((:fmpq_poly_sinh_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_sinh_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return z end @@ -612,9 +559,7 @@ function cos(a::QQAbsPowerSeriesRingElem) end z = parent(a)() z.prec = a.prec - ccall((:fmpq_poly_cos_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_cos_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return z end @@ -625,9 +570,7 @@ function cosh(a::QQAbsPowerSeriesRingElem) end z = parent(a)() z.prec = a.prec - ccall((:fmpq_poly_cosh_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_cosh_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return z end @@ -638,9 +581,7 @@ function asin(a::QQAbsPowerSeriesRingElem) end z = parent(a)() z.prec = a.prec - ccall((:fmpq_poly_asin_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_asin_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return z end @@ -651,9 +592,7 @@ function asinh(a::QQAbsPowerSeriesRingElem) end z = parent(a)() z.prec = a.prec - ccall((:fmpq_poly_asinh_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_asinh_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return z end @@ -664,9 +603,7 @@ function atan(a::QQAbsPowerSeriesRingElem) end z = parent(a)() z.prec = a.prec - ccall((:fmpq_poly_atan_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_atan_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return z end @@ -677,9 +614,7 @@ function atanh(a::QQAbsPowerSeriesRingElem) end z = parent(a)() z.prec = a.prec - ccall((:fmpq_poly_atanh_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_atanh_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return z end @@ -696,9 +631,7 @@ function Base.sqrt(a::QQAbsPowerSeriesRingElem; check::Bool=true) s = sqrt(c; check=check) a = divexact(a, c) z.prec = a.prec - div(v, 2) - ccall((:fmpq_poly_sqrt_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_sqrt_series(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, a.prec::Int)::Nothing if !isone(s) z *= s end @@ -715,29 +648,24 @@ end ############################################################################### function zero!(z::QQAbsPowerSeriesRingElem) - ccall((:fmpq_poly_zero, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem},), z) + @ccall libflint.fmpq_poly_zero(z::Ref{QQAbsPowerSeriesRingElem})::Nothing z.prec = parent(z).prec_max return z end function one!(z::QQAbsPowerSeriesRingElem) - ccall((:fmpq_poly_one, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem},), z) + @ccall libflint.fmpq_poly_one(z::Ref{QQAbsPowerSeriesRingElem})::Nothing z.prec = parent(z).prec_max return z end function fit!(z::QQAbsPowerSeriesRingElem, n::Int) - ccall((:fmpq_poly_fit_length, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Int), z, n) + @ccall libflint.fmpq_poly_fit_length(z::Ref{QQAbsPowerSeriesRingElem}, n::Int)::Nothing return nothing end function setcoeff!(z::QQAbsPowerSeriesRingElem, n::Int, x::QQFieldElem) - ccall((:fmpq_poly_set_coeff_fmpq, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Int, Ref{QQFieldElem}), - z, n, x) + @ccall libflint.fmpq_poly_set_coeff_fmpq(z::Ref{QQAbsPowerSeriesRingElem}, n::Int, x::Ref{QQFieldElem})::Nothing return z end @@ -760,9 +688,7 @@ function mul!(z::QQAbsPowerSeriesRingElem, a::QQAbsPowerSeriesRingElem, b::QQAbs end z.prec = prec - ccall((:fmpq_poly_mullow, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpq_poly_mullow(z::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, b::Ref{QQAbsPowerSeriesRingElem}, lenz::Int)::Nothing return z end @@ -777,16 +703,12 @@ function add!(c::QQAbsPowerSeriesRingElem, a::QQAbsPowerSeriesRingElem, b::QQAbs lenc = max(lena, lenb) c.prec = prec - ccall((:fmpq_poly_add_series, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Ref{QQAbsPowerSeriesRingElem}, - Ref{QQAbsPowerSeriesRingElem}, Int), - c, a, b, lenc) + @ccall libflint.fmpq_poly_add_series(c::Ref{QQAbsPowerSeriesRingElem}, a::Ref{QQAbsPowerSeriesRingElem}, b::Ref{QQAbsPowerSeriesRingElem}, lenc::Int)::Nothing return c end function set_length!(a::QQAbsPowerSeriesRingElem, n::Int) - ccall((:_fmpq_poly_set_length, libflint), Nothing, - (Ref{QQAbsPowerSeriesRingElem}, Int), a, n) + @ccall libflint._fmpq_poly_set_length(a::Ref{QQAbsPowerSeriesRingElem}, n::Int)::Nothing return a end diff --git a/src/flint/fmpq_mat.jl b/src/flint/fmpq_mat.jl index 4d3e79041..25af8c9dc 100644 --- a/src/flint/fmpq_mat.jl +++ b/src/flint/fmpq_mat.jl @@ -51,9 +51,7 @@ function Base.view(x::QQMatrix, r1::Int, c1::Int, r2::Int, c2::Int) b = QQMatrix() b.view_parent = x - ccall((:fmpq_mat_window_init, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}, Int, Int, Int, Int), - b, x, r1 - 1, c1 - 1, r2, c2) + @ccall libflint.fmpq_mat_window_init(b::Ref{QQMatrix}, x::Ref{QQMatrix}, (r1 - 1)::Int, (c1 - 1)::Int, r2::Int, c2::Int)::Nothing finalizer(_fmpq_mat_window_clear_fn, b) return b end @@ -63,7 +61,7 @@ function Base.view(x::QQMatrix, r::AbstractUnitRange{Int}, c::AbstractUnitRange{ end function _fmpq_mat_window_clear_fn(a::QQMatrix) - ccall((:fmpq_mat_window_clear, libflint), Nothing, (Ref{QQMatrix},), a) + @ccall libflint.fmpq_mat_window_clear(a::Ref{QQMatrix})::Nothing end function sub(x::QQMatrix, r1::Int, c1::Int, r2::Int, c2::Int) @@ -112,16 +110,14 @@ function setindex!(a::QQMatrix, b::QQMatrix, r::UnitRange{Int64}, c::UnitRange{I _checkbounds(a, r, c) size(b) == (length(r), length(c)) || throw(DimensionMismatch("tried to assign a $(size(b, 1))x$(size(b, 2)) matrix to a $(length(r))x$(length(c)) destination")) A = view(a, r, c) - ccall((:fmpq_mat_set, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}), A, b) + @ccall libflint.fmpq_mat_set(A::Ref{QQMatrix}, b::Ref{QQMatrix})::Nothing end number_of_rows(a::QQMatrix) = a.r number_of_columns(a::QQMatrix) = a.c -iszero(a::QQMatrix) = ccall((:fmpq_mat_is_zero, libflint), Bool, - (Ref{QQMatrix},), a) +iszero(a::QQMatrix) = @ccall libflint.fmpq_mat_is_zero(a::Ref{QQMatrix})::Bool @inline function is_zero_entry(A::QQMatrix, i::Int, j::Int) @boundscheck _checkbounds(A, i, j) @@ -131,8 +127,7 @@ iszero(a::QQMatrix) = ccall((:fmpq_mat_is_zero, libflint), Bool, end end -isone(a::QQMatrix) = ccall((:fmpq_mat_is_one, libflint), Bool, - (Ref{QQMatrix},), a) +isone(a::QQMatrix) = @ccall libflint.fmpq_mat_is_one(a::Ref{QQMatrix})::Bool function deepcopy_internal(d::QQMatrix, dict::IdDict) z = QQMatrix(d) @@ -213,8 +208,7 @@ end transpose!(A::Union{ZZMatrix,QQMatrix}) = is_square(A) ? transpose!(A, A) : transpose(A) function transpose!(A::QQMatrixOrPtr, B::QQMatrixOrPtr) - ccall((:fmpq_mat_transpose, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}), A, B) + @ccall libflint.fmpq_mat_transpose(A::Ref{QQMatrix}, B::Ref{QQMatrix})::Nothing return A end @@ -225,8 +219,7 @@ end ############################################################################### function swap_rows!(x::QQMatrixOrPtr, i::Int, j::Int) - ccall((:fmpq_mat_swap_rows, libflint), Nothing, - (Ref{QQMatrix}, Ptr{Nothing}, Int, Int), x, C_NULL, i - 1, j - 1) + @ccall libflint.fmpq_mat_swap_rows(x::Ref{QQMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int)::Nothing return x end @@ -237,8 +230,7 @@ function swap_rows(x::QQMatrix, i::Int, j::Int) end function swap_cols!(x::QQMatrixOrPtr, i::Int, j::Int) - ccall((:fmpq_mat_swap_cols, libflint), Nothing, - (Ref{QQMatrix}, Ptr{Nothing}, Int, Int), x, C_NULL, i - 1, j - 1) + @ccall libflint.fmpq_mat_swap_cols(x::Ref{QQMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int)::Nothing return x end @@ -249,16 +241,14 @@ function swap_cols(x::QQMatrix, i::Int, j::Int) end function reverse_rows!(x::QQMatrixOrPtr) - ccall((:fmpq_mat_invert_rows, libflint), Nothing, - (Ref{QQMatrix}, Ptr{Nothing}), x, C_NULL) + @ccall libflint.fmpq_mat_invert_rows(x::Ref{QQMatrix}, C_NULL::Ptr{Nothing})::Nothing return x end reverse_rows(x::QQMatrix) = reverse_rows!(deepcopy(x)) function reverse_cols!(x::QQMatrixOrPtr) - ccall((:fmpq_mat_invert_cols, libflint), Nothing, - (Ref{QQMatrix}, Ptr{Nothing}), x, C_NULL) + @ccall libflint.fmpq_mat_invert_cols(x::Ref{QQMatrix}, C_NULL::Ptr{Nothing})::Nothing return x end @@ -335,8 +325,7 @@ end function ==(x::QQMatrix, y::QQMatrix) fl = check_parent(x, y, false) - fl && ccall((:fmpq_mat_equal, libflint), Bool, - (Ref{QQMatrix}, Ref{QQMatrix}), x, y) + fl && @ccall libflint.fmpq_mat_equal(x::Ref{QQMatrix}, y::Ref{QQMatrix})::Bool end isequal(x::QQMatrix, y::QQMatrix) = ==(x, y) @@ -378,8 +367,7 @@ end function inv(x::QQMatrix) !is_square(x) && error("Matrix not invertible") z = similar(x) - success = ccall((:fmpq_mat_inv, libflint), Cint, - (Ref{QQMatrix}, Ref{QQMatrix}), z, x) + success = @ccall libflint.fmpq_mat_inv(z::Ref{QQMatrix}, x::Ref{QQMatrix})::Cint success == 0 && error("Matrix not invertible") return z end @@ -425,8 +413,7 @@ divexact(x::QQMatrix, y::Rational; check::Bool=true) = divexact(x, QQFieldElem(y function kronecker_product(x::QQMatrix, y::QQMatrix) z = similar(x, nrows(x)*nrows(y), ncols(x)*ncols(y)) - ccall((:fmpq_mat_kronecker_product, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}, Ref{QQMatrix}), z, x, y) + @ccall libflint.fmpq_mat_kronecker_product(z::Ref{QQMatrix}, x::Ref{QQMatrix}, y::Ref{QQMatrix})::Nothing return z end @@ -439,8 +426,7 @@ end function charpoly(R::QQPolyRing, x::QQMatrix) nrows(x) != ncols(x) && error("Non-square") z = R() - ccall((:fmpq_mat_charpoly, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQMatrix}), z, x) + @ccall libflint.fmpq_mat_charpoly(z::Ref{QQPolyRingElem}, x::Ref{QQMatrix})::Nothing return z end @@ -453,8 +439,7 @@ end function minpoly(R::QQPolyRing, x::QQMatrix) nrows(x) != ncols(x) && error("Non-square") z = R() - ccall((:fmpq_mat_minpoly, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQMatrix}), z, x) + @ccall libflint.fmpq_mat_minpoly(z::Ref{QQPolyRingElem}, x::Ref{QQMatrix})::Nothing return z end @@ -467,8 +452,7 @@ end function det(x::QQMatrix) nrows(x) != ncols(x) && error("Non-square matrix") z = QQFieldElem() - ccall((:fmpq_mat_det, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQMatrix}), z, x) + @ccall libflint.fmpq_mat_det(z::Ref{QQFieldElem}, x::Ref{QQMatrix})::Nothing return z end @@ -502,8 +486,7 @@ julia> B = gram_schmidt_orthogonalisation(A) """ function gram_schmidt_orthogonalisation(x::QQMatrix) z = similar(x) - ccall((:fmpq_mat_gso, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}), z, x) + @ccall libflint.fmpq_mat_gso(z::Ref{QQMatrix}, x::Ref{QQMatrix})::Nothing return z end @@ -521,8 +504,7 @@ entries $H_{i,j} = 1/(i + j - 1)$. """ function hilbert(R::QQMatrixSpace) z = R() - ccall((:fmpq_mat_hilbert_matrix, libflint), Bool, - (Ref{QQMatrix},), z) + @ccall libflint.fmpq_mat_hilbert_matrix(z::Ref{QQMatrix})::Bool return z end @@ -534,8 +516,7 @@ end function rank(x::QQMatrix) z = similar(x) - r = ccall((:fmpq_mat_rref, libflint), Int, - (Ref{QQMatrix}, Ref{QQMatrix}), z, x) + r = @ccall libflint.fmpq_mat_rref(z::Ref{QQMatrix}, x::Ref{QQMatrix})::Int return r end @@ -547,14 +528,12 @@ end function rref(x::QQMatrix) z = similar(x) - r = ccall((:fmpq_mat_rref, libflint), Int, - (Ref{QQMatrix}, Ref{QQMatrix}), z, x) + r = @ccall libflint.fmpq_mat_rref(z::Ref{QQMatrix}, x::Ref{QQMatrix})::Int return r, z end function rref!(x::QQMatrix) - r = ccall((:fmpq_mat_rref, libflint), Int, - (Ref{QQMatrix}, Ref{QQMatrix}), x, x) + r = @ccall libflint.fmpq_mat_rref(x::Ref{QQMatrix}, x::Ref{QQMatrix})::Int return r end @@ -574,8 +553,7 @@ function _solve_dixon(a::QQMatrix, b::QQMatrix) nrows(a) != ncols(a) && error("Not a square matrix in solve") nrows(b) != nrows(a) && error("Incompatible dimensions in solve") z = similar(b) - nonsing = ccall((:fmpq_mat_solve_dixon, libflint), Bool, - (Ref{QQMatrix}, Ref{QQMatrix}, Ref{QQMatrix}), z, a, b) + nonsing = @ccall libflint.fmpq_mat_solve_dixon(z::Ref{QQMatrix}, a::Ref{QQMatrix}, b::Ref{QQMatrix})::Bool !nonsing && error("Singular matrix in solve") return z end @@ -598,8 +576,7 @@ function Solve._can_solve_internal_no_check(::Solve.RREFTrait, A::QQMatrix, b::Q end x = similar(A, ncols(A), ncols(b)) - fl = ccall((:fmpq_mat_can_solve_multi_mod, libflint), Cint, - (Ref{QQMatrix}, Ref{QQMatrix}, Ref{QQMatrix}), x, A, b) + fl = @ccall libflint.fmpq_mat_can_solve_multi_mod(x::Ref{QQMatrix}, A::Ref{QQMatrix}, b::Ref{QQMatrix})::Cint if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) @@ -616,8 +593,7 @@ end function tr(x::QQMatrix) nrows(x) != ncols(x) && error("Not a square matrix in trace") d = QQFieldElem() - ccall((:fmpq_mat_trace, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQMatrix}), d, x) + @ccall libflint.fmpq_mat_trace(d::Ref{QQFieldElem}, x::Ref{QQMatrix})::Nothing return d end @@ -630,16 +606,14 @@ end function hcat(a::QQMatrix, b::QQMatrix) nrows(a) != nrows(b) && error("Incompatible number of rows in hcat") c = similar(a, nrows(a), ncols(a) + ncols(b)) - ccall((:fmpq_mat_concat_horizontal, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}, Ref{QQMatrix}), c, a, b) + @ccall libflint.fmpq_mat_concat_horizontal(c::Ref{QQMatrix}, a::Ref{QQMatrix}, b::Ref{QQMatrix})::Nothing return c end function vcat(a::QQMatrix, b::QQMatrix) ncols(a) != ncols(b) && error("Incompatible number of columns in vcat") c = similar(a, nrows(a) + nrows(b), ncols(a)) - ccall((:fmpq_mat_concat_vertical, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}, Ref{QQMatrix}), c, a, b) + @ccall libflint.fmpq_mat_concat_vertical(c::Ref{QQMatrix}, a::Ref{QQMatrix}, b::Ref{QQMatrix})::Nothing return c end @@ -650,8 +624,7 @@ end ############################################################################### function similarity!(z::QQMatrix, r::Int, d::QQFieldElem) - ccall((:fmpq_mat_similarity, libflint), Nothing, - (Ref{QQMatrix}, Int, Ref{QQFieldElem}), z, r - 1, d) + @ccall libflint.fmpq_mat_similarity(z::Ref{QQMatrix}, (r - 1)::Int, d::Ref{QQFieldElem})::Nothing end ############################################################################### @@ -661,32 +634,27 @@ end ############################################################################### function zero!(z::QQMatrixOrPtr) - ccall((:fmpq_mat_zero, libflint), Nothing, - (Ref{QQMatrix},), z) + @ccall libflint.fmpq_mat_zero(z::Ref{QQMatrix})::Nothing return z end function one!(z::QQMatrixOrPtr) - ccall((:fmpq_mat_one, libflint), Nothing, - (Ref{QQMatrix},), z) + @ccall libflint.fmpq_mat_one(z::Ref{QQMatrix})::Nothing return z end function neg!(z::QQMatrixOrPtr, a::QQMatrixOrPtr) - ccall((:fmpq_mat_neg, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}), z, a) + @ccall libflint.fmpq_mat_neg(z::Ref{QQMatrix}, a::Ref{QQMatrix})::Nothing return z end function add!(z::QQMatrixOrPtr, x::QQMatrixOrPtr, y::QQMatrixOrPtr) - ccall((:fmpq_mat_add, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}, Ref{QQMatrix}), z, x, y) + @ccall libflint.fmpq_mat_add(z::Ref{QQMatrix}, x::Ref{QQMatrix}, y::Ref{QQMatrix})::Nothing return z end function sub!(z::QQMatrixOrPtr, x::QQMatrixOrPtr, y::QQMatrixOrPtr) - ccall((:fmpq_mat_sub, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}, Ref{QQMatrix}), z, x, y) + @ccall libflint.fmpq_mat_sub(z::Ref{QQMatrix}, x::Ref{QQMatrix}, y::Ref{QQMatrix})::Nothing return z end @@ -694,8 +662,7 @@ end # matrix x matrix # function mul!(z::QQMatrixOrPtr, x::QQMatrixOrPtr, y::QQMatrixOrPtr) - ccall((:fmpq_mat_mul, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}, Ref{QQMatrix}), z, x, y) + @ccall libflint.fmpq_mat_mul(z::Ref{QQMatrix}, x::Ref{QQMatrix}, y::Ref{QQMatrix})::Nothing return z end @@ -703,30 +670,22 @@ end # matrix x vector, vector x matrix # function mul!(z::Vector{QQFieldElem}, a::Vector{QQFieldElem}, b::QQMatrixOrPtr) - ccall((:fmpq_mat_fmpq_vec_mul_ptr, libflint), Nothing, - (Ptr{Ref{QQFieldElem}}, Ptr{Ref{QQFieldElem}}, Int, Ref{QQMatrix}), - z, a, length(a), b) + @ccall libflint.fmpq_mat_fmpq_vec_mul_ptr(z::Ptr{Ref{QQFieldElem}}, a::Ptr{Ref{QQFieldElem}}, length(a)::Int, b::Ref{QQMatrix})::Nothing return z end function mul!(z::Vector{QQFieldElem}, a::QQMatrixOrPtr, b::Vector{QQFieldElem}) - ccall((:fmpq_mat_mul_fmpq_vec_ptr, libflint), Nothing, - (Ptr{Ref{QQFieldElem}}, Ref{QQMatrix}, Ptr{Ref{QQFieldElem}}, Int), - z, a, b, length(b)) + @ccall libflint.fmpq_mat_mul_fmpq_vec_ptr(z::Ptr{Ref{QQFieldElem}}, a::Ref{QQMatrix}, b::Ptr{Ref{QQFieldElem}}, length(b)::Int)::Nothing return z end function mul!(z::Vector{QQFieldElem}, a::Vector{ZZRingElem}, b::QQMatrixOrPtr) - ccall((:fmpq_mat_fmpz_vec_mul_ptr, libflint), Nothing, - (Ptr{Ref{QQFieldElem}}, Ptr{Ref{ZZRingElem}}, Int, Ref{QQMatrix}), - z, a, length(a), b) + @ccall libflint.fmpq_mat_fmpz_vec_mul_ptr(z::Ptr{Ref{QQFieldElem}}, a::Ptr{Ref{ZZRingElem}}, length(a)::Int, b::Ref{QQMatrix})::Nothing return z end function mul!(z::Vector{QQFieldElem}, a::QQMatrixOrPtr, b::Vector{ZZRingElem}) - ccall((:fmpq_mat_mul_fmpz_vec_ptr, libflint), Nothing, - (Ptr{Ref{QQFieldElem}}, Ref{QQMatrix}, Ptr{Ref{ZZRingElem}}, Int), - z, a, b, length(b)) + @ccall libflint.fmpq_mat_mul_fmpz_vec_ptr(z::Ptr{Ref{QQFieldElem}}, a::Ref{QQMatrix}, b::Ptr{Ref{ZZRingElem}}, length(b)::Int)::Nothing return z end @@ -734,14 +693,12 @@ end # matrix x scalar, scalar x matrix # function mul!(z::QQMatrixOrPtr, a::QQMatrixOrPtr, b::QQFieldElemOrPtr) - ccall((:fmpq_mat_scalar_mul_fmpq, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}, Ref{QQFieldElem}), z, a, b) + @ccall libflint.fmpq_mat_scalar_mul_fmpq(z::Ref{QQMatrix}, a::Ref{QQMatrix}, b::Ref{QQFieldElem})::Nothing return z end function mul!(z::QQMatrixOrPtr, a::QQMatrixOrPtr, b::ZZRingElemOrPtr) - ccall((:fmpq_mat_scalar_mul_fmpz, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}, Ref{ZZRingElem}), z, a, b) + @ccall libflint.fmpq_mat_scalar_mul_fmpz(z::Ref{QQMatrix}, a::Ref{QQMatrix}, b::Ref{ZZRingElem})::Nothing return z end @@ -760,8 +717,7 @@ function divexact!(z::QQMatrixOrPtr, x::QQMatrixOrPtr, y::QQFieldElemOrPtr) end function divexact!(z::QQMatrixOrPtr, x::QQMatrixOrPtr, y::ZZRingElemOrPtr) - ccall((:fmpq_mat_scalar_div_fmpz, libflint), Nothing, - (Ref{QQMatrix}, Ref{QQMatrix}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpq_mat_scalar_div_fmpz(z::Ref{QQMatrix}, x::Ref{QQMatrix}, y::Ref{ZZRingElem})::Nothing return z end @@ -854,7 +810,7 @@ end function (a::QQMatrixSpace)(M::ZZMatrix) (ncols(a) == ncols(M) && nrows(a) == nrows(M)) || error("wrong matrix dimension") z = a() - ccall((:fmpq_mat_set_fmpz_mat, libflint), Nothing, (Ref{QQMatrix}, Ref{ZZMatrix}), z, M) + @ccall libflint.fmpq_mat_set_fmpz_mat(z::Ref{QQMatrix}, M::Ref{ZZMatrix})::Nothing return z end @@ -969,14 +925,11 @@ mat_entry_ptr(A::QQMatrix, i::Int, j::Int) = unsafe_load(A.rows, i) + (j-1)*size function nullspace(A::QQMatrix) AZZ = zero_matrix(ZZ, nrows(A), ncols(A)) - ccall((:fmpq_mat_get_fmpz_mat_rowwise, libflint), Nothing, - (Ref{ZZMatrix}, Ptr{Nothing}, Ref{QQMatrix}), AZZ, C_NULL, A) + @ccall libflint.fmpq_mat_get_fmpz_mat_rowwise(AZZ::Ref{ZZMatrix}, C_NULL::Ptr{Nothing}, A::Ref{QQMatrix})::Nothing N = similar(AZZ, ncols(A), ncols(A)) - nullity = ccall((:fmpz_mat_nullspace, libflint), Int, - (Ref{ZZMatrix}, Ref{ZZMatrix}), N, AZZ) + nullity = @ccall libflint.fmpz_mat_nullspace(N::Ref{ZZMatrix}, AZZ::Ref{ZZMatrix})::Int NQQ = similar(A, ncols(A), ncols(A)) - ccall((:fmpq_mat_set_fmpz_mat, libflint), Nothing, - (Ref{QQMatrix}, Ref{ZZMatrix}), NQQ, N) + @ccall libflint.fmpq_mat_set_fmpz_mat(NQQ::Ref{QQMatrix}, N::Ref{ZZMatrix})::Nothing # Now massage the result until it looks like what the generic AbstractAlgebra # nullspace would return: remove zero columns and rescale the columns so that diff --git a/src/flint/fmpq_mpoly.jl b/src/flint/fmpq_mpoly.jl index 0c22bc10a..d374cc36e 100644 --- a/src/flint/fmpq_mpoly.jl +++ b/src/flint/fmpq_mpoly.jl @@ -21,13 +21,12 @@ symbols(a::QQMPolyRing) = a.S parent(a::QQMPolyRingElem) = a.parent -number_of_variables(a::QQMPolyRing) = ccall((:fmpq_mpoly_ctx_nvars, libflint), Int, - (Ref{QQMPolyRing}, ), a) +number_of_variables(a::QQMPolyRing) = @ccall libflint.fmpq_mpoly_ctx_nvars(a::Ref{QQMPolyRing})::Int base_ring(a::QQMPolyRing) = QQ function internal_ordering(a::QQMPolyRing) - b = ccall((:fmpq_mpoly_ctx_ord, libflint), Cint, (Ref{QQMPolyRing}, ), a) + b = @ccall libflint.fmpq_mpoly_ctx_ord(a::Ref{QQMPolyRing})::Cint return flint_orderings[b + 1] end @@ -35,8 +34,7 @@ function gens(R::QQMPolyRing) A = Vector{QQMPolyRingElem}(undef, R.nvars) for i = 1:R.nvars z = R() - ccall((:fmpq_mpoly_gen, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), z, i - 1, R) + @ccall libflint.fmpq_mpoly_gen(z::Ref{QQMPolyRingElem}, (i - 1)::Int, R::Ref{QQMPolyRing})::Nothing A[i] = z end return A @@ -46,8 +44,7 @@ function gen(R::QQMPolyRing, i::Int) n = nvars(R) (i <= 0 || i > n) && error("Index must be between 1 and $n") z = R() - ccall((:fmpq_mpoly_gen, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), z, i - 1, R) + @ccall libflint.fmpq_mpoly_gen(z::Ref{QQMPolyRingElem}, (i - 1)::Int, R::Ref{QQMPolyRing})::Nothing return z end @@ -55,9 +52,7 @@ function is_gen(a::QQMPolyRingElem, i::Int) n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") R = parent(a) - return Bool(ccall((:fmpq_mpoly_is_gen, libflint), Cint, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - a, i - 1, a.parent)) + return Bool(@ccall libflint.fmpq_mpoly_is_gen(a::Ref{QQMPolyRingElem}, (i - 1)::Int, a.parent::Ref{QQMPolyRing})::Cint) end function is_gen(a::QQMPolyRingElem) @@ -70,40 +65,34 @@ end function deepcopy_internal(a::QQMPolyRingElem, dict::IdDict) z = parent(a)() - ccall((:fmpq_mpoly_set, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - z, a, a.parent) + @ccall libflint.fmpq_mpoly_set(z::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing return z end function length(a::QQMPolyRingElem) - n = ccall((:fmpq_mpoly_length, libflint), Int, (Ref{QQMPolyRingElem}, ), a) + n = @ccall libflint.fmpq_mpoly_length(a::Ref{QQMPolyRingElem})::Int return n end function one(R::QQMPolyRing) z = R() - ccall((:fmpq_mpoly_one, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), z, R) + @ccall libflint.fmpq_mpoly_one(z::Ref{QQMPolyRingElem}, R::Ref{QQMPolyRing})::Nothing return z end function zero(R::QQMPolyRing) z = R() - ccall((:fmpq_mpoly_zero, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), z, R) + @ccall libflint.fmpq_mpoly_zero(z::Ref{QQMPolyRingElem}, R::Ref{QQMPolyRing})::Nothing return z end function isone(a::QQMPolyRingElem) - b = ccall((:fmpq_mpoly_is_one, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, a.parent) + b = @ccall libflint.fmpq_mpoly_is_one(a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Cint return Bool(b) end function iszero(a::QQMPolyRingElem) - b = ccall((:fmpq_mpoly_is_zero, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, a.parent) + b = @ccall libflint.fmpq_mpoly_is_zero(a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Cint return Bool(b) end @@ -120,22 +109,19 @@ function is_unit(a::QQMPolyRingElem) end function is_constant(a::QQMPolyRingElem) - b = ccall((:fmpq_mpoly_is_fmpq, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, parent(a)) + b = @ccall libflint.fmpq_mpoly_is_fmpq(a::Ref{QQMPolyRingElem}, parent(a)::Ref{QQMPolyRing})::Cint return Bool(b) end function content(a::QQMPolyRingElem) c = QQFieldElem() - ccall((:fmpq_mpoly_content, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), c, a, parent(a)) + @ccall libflint.fmpq_mpoly_content(c::Ref{QQFieldElem}, a::Ref{QQMPolyRingElem}, parent(a)::Ref{QQMPolyRing})::Nothing return c end function denominator(a::QQMPolyRingElem) c = ZZRingElem() - ccall((:fmpq_mpoly_get_denominator, libflint), Nothing, - (Ref{ZZRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), c, a, parent(a)) + @ccall libflint.fmpq_mpoly_get_denominator(c::Ref{ZZRingElem}, a::Ref{QQMPolyRingElem}, parent(a)::Ref{QQMPolyRing})::Nothing return c end @@ -154,9 +140,7 @@ function coeff(a::QQMPolyRingElem, i::Int) z = QQFieldElem() n = length(a) (i < 1 || i > n) && error("Index must be between 1 and $(length(a))") - ccall((:fmpq_mpoly_get_term_coeff_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - z, a, i - 1, a.parent) + @ccall libflint.fmpq_mpoly_get_term_coeff_fmpq(z::Ref{QQFieldElem}, a::Ref{QQMPolyRingElem}, (i - 1)::Int, a.parent::Ref{QQMPolyRing})::Nothing return z end @@ -164,9 +148,7 @@ function coeff(a::QQMPolyRingElem, b::QQMPolyRingElem) check_parent(a, b) !isone(length(b)) && error("Second argument must be a monomial") z = QQFieldElem() - ccall((:fmpq_mpoly_get_coeff_fmpq_monomial, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - z, a, b, parent(a)) + @ccall libflint.fmpq_mpoly_get_coeff_fmpq_monomial(z::Ref{QQFieldElem}, a::Ref{QQMPolyRingElem}, b::Ref{QQMPolyRingElem}, parent(a)::Ref{QQMPolyRing})::Nothing return z end @@ -189,8 +171,7 @@ function degree(a::QQMPolyRingElem, i::Int) n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") if degrees_fit_int(a) - d = ccall((:fmpq_mpoly_degree_si, libflint), Int, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), a, i - 1, a.parent) + d = @ccall libflint.fmpq_mpoly_degree_si(a::Ref{QQMPolyRingElem}, (i - 1)::Int, a.parent::Ref{QQMPolyRing})::Int return d else return Int(degree_fmpz(a, i)) @@ -202,16 +183,13 @@ function degree_fmpz(a::QQMPolyRingElem, i::Int) n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") d = ZZRingElem() - ccall((:fmpq_mpoly_degree_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - d, a, i - 1, a.parent) + @ccall libflint.fmpq_mpoly_degree_fmpz(d::Ref{ZZRingElem}, a::Ref{QQMPolyRingElem}, (i - 1)::Int, a.parent::Ref{QQMPolyRing})::Nothing return d end # Return true if degrees fit into an Int function degrees_fit_int(a::QQMPolyRingElem) - b = ccall((:fmpq_mpoly_degrees_fit_si, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, a.parent) + b = @ccall libflint.fmpq_mpoly_degrees_fit_si(a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Cint return Bool(b) end @@ -221,9 +199,7 @@ function degrees(a::QQMPolyRingElem) throw(OverflowError("degrees of polynomial do not fit into Int")) end degs = Vector{Int}(undef, nvars(parent(a))) - ccall((:fmpq_mpoly_degrees_si, libflint), Nothing, - (Ptr{Int}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - degs, a, a.parent) + @ccall libflint.fmpq_mpoly_degrees_si(degs::Ptr{Int}, a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing return degs end @@ -234,16 +210,13 @@ function degrees_fmpz(a::QQMPolyRingElem) for i in 1:n degs[i] = ZZRingElem() end - ccall((:fmpq_mpoly_degrees_fmpz, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - degs, a, a.parent) + @ccall libflint.fmpq_mpoly_degrees_fmpz(degs::Ptr{Ref{ZZRingElem}}, a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing return degs end # Return true if degree fits into an Int function total_degree_fits_int(a::QQMPolyRingElem) - b = ccall((:fmpq_mpoly_total_degree_fits_si, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, a.parent) + b = @ccall libflint.fmpq_mpoly_total_degree_fits_si(a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Cint return Bool(b) end @@ -252,17 +225,14 @@ function total_degree(a::QQMPolyRingElem) if !total_degree_fits_int(a) throw(OverflowError("Total degree of polynomial does not fit into Int")) end - d = ccall((:fmpq_mpoly_total_degree_si, libflint), Int, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, a.parent) + d = @ccall libflint.fmpq_mpoly_total_degree_si(a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Int return d end # Total degree as an ZZRingElem function total_degree_fmpz(a::QQMPolyRingElem) d = ZZRingElem() - ccall((:fmpq_mpoly_total_degree_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - d, a, a.parent) + @ccall libflint.fmpq_mpoly_total_degree_fmpz(d::Ref{ZZRingElem}, a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing return d end @@ -286,10 +256,7 @@ function coeff(a::QQMPolyRingElem, vars::Vector{Int}, exps::Vector{Int}) error("Exponent cannot be negative") end end - ccall((:fmpq_mpoly_get_coeff_vars_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ptr{Int}, - Ptr{Int}, Int, Ref{QQMPolyRing}), - z, a, vars, exps, length(vars), a.parent) + @ccall libflint.fmpq_mpoly_get_coeff_vars_ui(z::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, vars::Ptr{Int}, exps::Ptr{Int}, length(vars)::Int, a.parent::Ref{QQMPolyRing})::Nothing return z end @@ -362,18 +329,14 @@ end function ^(a::QQMPolyRingElem, b::Int) b < 0 && throw(DomainError(b, "Exponent must be non-negative")) z = parent(a)() - ccall((:fmpq_mpoly_pow_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - z, a, b, parent(a)) + @ccall libflint.fmpq_mpoly_pow_ui(z::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, b::Int, parent(a)::Ref{QQMPolyRing})::Nothing return z end function ^(a::QQMPolyRingElem, b::ZZRingElem) b < 0 && throw(DomainError(b, "Exponent must be non-negative")) z = parent(a)() - ccall((:fmpq_mpoly_pow_fmpz, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{ZZRingElem}, Ref{QQMPolyRing}), - z, a, b, parent(a)) + @ccall libflint.fmpq_mpoly_pow_fmpz(z::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, b::Ref{ZZRingElem}, parent(a)::Ref{QQMPolyRing})::Nothing return z end @@ -386,9 +349,7 @@ end function gcd(a::QQMPolyRingElem, b::QQMPolyRingElem) check_parent(a, b) z = parent(a)() - r = ccall((:fmpq_mpoly_gcd, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - z, a, b, a.parent) + r = @ccall libflint.fmpq_mpoly_gcd(z::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, b::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Cint r == 0 && error("Unable to compute gcd") return z end @@ -397,10 +358,7 @@ function gcd_with_cofactors(a::QQMPolyRingElem, b::QQMPolyRingElem) z = parent(a)() abar = parent(a)() bbar = parent(a)() - r = ccall((:fmpq_mpoly_gcd_cofactors, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, - Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - z, abar, bbar, a, b, a.parent) + r = @ccall libflint.fmpq_mpoly_gcd_cofactors(z::Ref{QQMPolyRingElem}, abar::Ref{QQMPolyRingElem}, bbar::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, b::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Cint r == 0 && error("Unable to compute gcd") return z, abar, bbar end @@ -417,22 +375,14 @@ function (::Type{Fac{QQMPolyRingElem}})(fac::fmpq_mpoly_factor, preserve_input:: for i in 0:fac.num-1 f = R() if preserve_input - ccall((:fmpq_mpoly_factor_get_base, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{fmpq_mpoly_factor}, Int, Ref{QQMPolyRing}), - f, fac, i, R) + @ccall libflint.fmpq_mpoly_factor_get_base(f::Ref{QQMPolyRingElem}, fac::Ref{fmpq_mpoly_factor}, i::Int, R::Ref{QQMPolyRing})::Nothing else - ccall((:fmpq_mpoly_factor_swap_base, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{fmpq_mpoly_factor}, Int, Ref{QQMPolyRing}), - f, fac, i, R) + @ccall libflint.fmpq_mpoly_factor_swap_base(f::Ref{QQMPolyRingElem}, fac::Ref{fmpq_mpoly_factor}, i::Int, R::Ref{QQMPolyRing})::Nothing end - F.fac[f] = ccall((:fmpq_mpoly_factor_get_exp_si, libflint), Int, - (Ref{fmpq_mpoly_factor}, Int, Ref{QQMPolyRing}), - fac, i, R) + F.fac[f] = @ccall libflint.fmpq_mpoly_factor_get_exp_si(fac::Ref{fmpq_mpoly_factor}, i::Int, R::Ref{QQMPolyRing})::Int end c = QQFieldElem() - ccall((:fmpq_mpoly_factor_get_constant_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{fmpq_mpoly_factor}), - c, fac) + @ccall libflint.fmpq_mpoly_factor_get_constant_fmpq(c::Ref{QQFieldElem}, fac::Ref{fmpq_mpoly_factor})::Nothing F.unit = R(c) return F end @@ -441,9 +391,7 @@ function factor(a::QQMPolyRingElem) iszero(a) && throw(ArgumentError("Argument must be non-zero")) R = parent(a) fac = fmpq_mpoly_factor(R) - ok = ccall((:fmpq_mpoly_factor, libflint), Cint, - (Ref{fmpq_mpoly_factor}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - fac, a, R) + ok = @ccall libflint.fmpq_mpoly_factor(fac::Ref{fmpq_mpoly_factor}, a::Ref{QQMPolyRingElem}, R::Ref{QQMPolyRing})::Cint ok == 0 && error("unable to compute factorization") return Fac{QQMPolyRingElem}(fac, false) end @@ -452,9 +400,7 @@ function factor_squarefree(a::QQMPolyRingElem) iszero(a) && throw(ArgumentError("Argument must be non-zero")) R = parent(a) fac = fmpq_mpoly_factor(R) - ok = ccall((:fmpq_mpoly_factor_squarefree, libflint), Cint, - (Ref{fmpq_mpoly_factor}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - fac, a, R) + ok = @ccall libflint.fmpq_mpoly_factor_squarefree(fac::Ref{fmpq_mpoly_factor}, a::Ref{QQMPolyRingElem}, R::Ref{QQMPolyRing})::Cint ok == 0 && error("unable to compute factorization") return Fac{QQMPolyRingElem}(fac, false) end @@ -467,16 +413,12 @@ function sqrt(a::QQMPolyRingElem; check::Bool=true) end function is_square(a::QQMPolyRingElem) - return Bool(ccall((:fmpq_mpoly_is_square, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - a, a.parent)) + return Bool(@ccall libflint.fmpq_mpoly_is_square(a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Cint) end function is_square_with_sqrt(a::QQMPolyRingElem) q = parent(a)() - flag = ccall((:fmpq_mpoly_sqrt, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - q, a, a.parent) + flag = @ccall libflint.fmpq_mpoly_sqrt(q::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Cint return (Bool(flag), q) end @@ -488,16 +430,12 @@ end function ==(a::QQMPolyRingElem, b::QQMPolyRingElem) check_parent(a, b) - return Bool(ccall((:fmpq_mpoly_equal, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - a, b, a.parent)) + return Bool(@ccall libflint.fmpq_mpoly_equal(a::Ref{QQMPolyRingElem}, b::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Cint) end function Base.isless(a::QQMPolyRingElem, b::QQMPolyRingElem) (!is_monomial(a) || !is_monomial(b)) && error("Not monomials in comparison") - return ccall((:fmpq_mpoly_cmp, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - a, b, a.parent) < 0 + return @ccall libflint.fmpq_mpoly_cmp(a::Ref{QQMPolyRingElem}, b::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Cint < 0 end ############################################################################### @@ -507,25 +445,19 @@ end ############################################################################### function ==(a::QQMPolyRingElem, b::QQFieldElem) - return Bool(ccall((:fmpq_mpoly_equal_fmpq, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQFieldElem}, Ref{QQMPolyRing}), - a, b, a.parent)) + return Bool(@ccall libflint.fmpq_mpoly_equal_fmpq(a::Ref{QQMPolyRingElem}, b::Ref{QQFieldElem}, a.parent::Ref{QQMPolyRing})::Cint) end ==(a::QQFieldElem, b::QQMPolyRingElem) = b == a function ==(a::QQMPolyRingElem, b::ZZRingElem) - return Bool(ccall((:fmpq_mpoly_equal_fmpz, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{ZZRingElem}, Ref{QQMPolyRing}), - a, b, a.parent)) + return Bool(@ccall libflint.fmpq_mpoly_equal_fmpz(a::Ref{QQMPolyRingElem}, b::Ref{ZZRingElem}, a.parent::Ref{QQMPolyRing})::Cint) end ==(a::ZZRingElem, b::QQMPolyRingElem) = b == a function ==(a::QQMPolyRingElem, b::Int) - return Bool(ccall((:fmpq_mpoly_equal_si, libflint), Cint, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - a, b, a.parent)) + return Bool(@ccall libflint.fmpq_mpoly_equal_si(a::Ref{QQMPolyRingElem}, b::Int, a.parent::Ref{QQMPolyRing})::Cint) end ==(a::Int, b::QQMPolyRingElem) = b == a @@ -553,9 +485,7 @@ function divides(a::QQMPolyRingElem, b::QQMPolyRingElem) return false, zero(parent(a)) end z = parent(a)() - d = ccall((:fmpq_mpoly_divides, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - z, a, b, a.parent) + d = @ccall libflint.fmpq_mpoly_divides(z::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, b::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Cint return isone(d), z end @@ -568,10 +498,7 @@ end function Base.div(a::QQMPolyRingElem, b::QQMPolyRingElem) check_parent(a, b) q = parent(a)() - ccall((:fmpq_mpoly_div, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, - Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - q, a, b, a.parent) + @ccall libflint.fmpq_mpoly_div(q::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, b::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing return q end @@ -579,10 +506,7 @@ function Base.divrem(a::QQMPolyRingElem, b::QQMPolyRingElem) check_parent(a, b) q = parent(a)() r = parent(a)() - ccall((:fmpq_mpoly_divrem, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, - Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), - q, r, a, b, a.parent) + @ccall libflint.fmpq_mpoly_divrem(q::Ref{QQMPolyRingElem}, r::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, b::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing return q, r end @@ -590,10 +514,7 @@ function Base.divrem(a::QQMPolyRingElem, b::Vector{QQMPolyRingElem}) len = length(b) q = [parent(a)() for i in 1:len] r = parent(a)() - ccall((:fmpq_mpoly_divrem_ideal, libflint), Nothing, - (Ptr{Ref{QQMPolyRingElem}}, Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, - Ptr{Ref{QQMPolyRingElem}}, Int, Ref{QQMPolyRing}), - q, r, a, b, len, a.parent) + @ccall libflint.fmpq_mpoly_divrem_ideal(q::Ptr{Ref{QQMPolyRingElem}}, r::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, b::Ptr{Ref{QQMPolyRingElem}}, len::Int, a.parent::Ref{QQMPolyRing})::Nothing return q, r end @@ -620,9 +541,7 @@ function derivative(a::QQMPolyRingElem, i::Int) n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") z = parent(a)() - ccall((:fmpq_mpoly_derivative, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpq_mpoly_derivative(z::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{QQMPolyRing})::Nothing return z end @@ -630,9 +549,7 @@ function integral(a::QQMPolyRingElem, i::Int) n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") z = parent(a)() - ccall((:fmpq_mpoly_integral, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpq_mpoly_integral(z::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{QQMPolyRing})::Nothing return z end @@ -645,9 +562,7 @@ end function evaluate(a::QQMPolyRingElem, b::Vector{QQFieldElem}) length(b) != nvars(parent(a)) && error("Vector size incorrect in evaluate") z = QQFieldElem() - GC.@preserve b ccall((:fmpq_mpoly_evaluate_all_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQMPolyRingElem}, Ptr{QQFieldElem}, Ref{QQMPolyRing}), - z, a, b, parent(a)) + GC.@preserve b @ccall libflint.fmpq_mpoly_evaluate_all_fmpq(z::Ref{QQFieldElem}, a::Ref{QQMPolyRingElem}, b::Ptr{QQFieldElem}, parent(a)::Ref{QQMPolyRing})::Nothing return z end @@ -723,10 +638,7 @@ function evaluate(a::QQMPolyRingElem, bs::Vector{QQMPolyRingElem}) error("Number of variables does not match number of values") c = S() - fl = ccall((:fmpq_mpoly_compose_fmpq_mpoly, libflint), Cint, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ptr{Ref{QQMPolyRingElem}}, - Ref{QQMPolyRing}, Ref{QQMPolyRing}), - c, a, bs, R, S) + fl = @ccall libflint.fmpq_mpoly_compose_fmpq_mpoly(c::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, bs::Ptr{Ref{QQMPolyRingElem}}, R::Ref{QQMPolyRing}, S::Ref{QQMPolyRing})::Cint fl == 0 && error("Something wrong in evaluation.") return c end @@ -739,9 +651,7 @@ function evaluate(a::QQMPolyRingElem, bs::Vector{QQPolyRingElem}) error("Number of variables does not match number of values") c = S() - fl = ccall((:fmpq_mpoly_compose_fmpq_poly, libflint), Cint, - (Ref{QQPolyRingElem}, Ref{QQMPolyRingElem}, Ptr{Ref{QQPolyRingElem}}, - Ref{QQMPolyRing}), c, a, bs, R) + fl = @ccall libflint.fmpq_mpoly_compose_fmpq_poly(c::Ref{QQPolyRingElem}, a::Ref{QQMPolyRingElem}, bs::Ptr{Ref{QQPolyRingElem}}, R::Ref{QQMPolyRing})::Cint fl == 0 && error("Something wrong in evaluation.") return c end @@ -753,41 +663,32 @@ end ############################################################################### function zero!(a::QQMPolyRingElem) - ccall((:fmpq_mpoly_zero, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, a.parent) + @ccall libflint.fmpq_mpoly_zero(a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing return a end function one!(a::QQMPolyRingElem) - ccall((:fmpq_mpoly_one, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, parent(a)) + @ccall libflint.fmpq_mpoly_one(a::Ref{QQMPolyRingElem}, parent(a)::Ref{QQMPolyRing})::Nothing return a end function neg!(a::QQMPolyRingElem, b::QQMPolyRingElem) - ccall((:fmpq_mpoly_neg, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, b, parent(a)) + @ccall libflint.fmpq_mpoly_neg(a::Ref{QQMPolyRingElem}, b::Ref{QQMPolyRingElem}, parent(a)::Ref{QQMPolyRing})::Nothing return a end function add!(a::QQMPolyRingElem, b::QQMPolyRingElem, c::QQMPolyRingElem) - ccall((:fmpq_mpoly_add, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, - Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, b, c, a.parent) + @ccall libflint.fmpq_mpoly_add(a::Ref{QQMPolyRingElem}, b::Ref{QQMPolyRingElem}, c::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing return a end function mul!(a::QQMPolyRingElem, b::QQMPolyRingElem, c::QQMPolyRingElem) - ccall((:fmpq_mpoly_mul, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, - Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, b, c, a.parent) + @ccall libflint.fmpq_mpoly_mul(a::Ref{QQMPolyRingElem}, b::Ref{QQMPolyRingElem}, c::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing return a end function sub!(a::QQMPolyRingElem, b::QQMPolyRingElem, c::QQMPolyRingElem) - ccall((:fmpq_mpoly_sub, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, - Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, b, c, a.parent) + @ccall libflint.fmpq_mpoly_sub(a::Ref{QQMPolyRingElem}, b::Ref{QQMPolyRingElem}, c::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing return a end @@ -839,12 +740,9 @@ divexact!(a::QQMPolyRingElem, b::QQMPolyRingElem, c::RationalUnion) = divexact!( # must be removed with combine_like_terms! function setcoeff!(a::QQMPolyRingElem, n::Int, c::QQFieldElem) if n > length(a) - ccall((:fmpq_mpoly_resize, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), a, n, a.parent) + @ccall libflint.fmpq_mpoly_resize(a::Ref{QQMPolyRingElem}, n::Int, a.parent::Ref{QQMPolyRing})::Nothing end - ccall((:fmpq_mpoly_set_term_coeff_fmpq, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ref{QQFieldElem}, Ref{QQMPolyRing}), - a, n - 1, c, a.parent) + @ccall libflint.fmpq_mpoly_set_term_coeff_fmpq(a::Ref{QQMPolyRingElem}, (n - 1)::Int, c::Ref{QQFieldElem}, a.parent::Ref{QQMPolyRing})::Nothing return a end @@ -864,8 +762,7 @@ setcoeff!(a, i, QQFieldElem(c)) # Remove zero terms and combine adjacent terms if they have the same monomial # no sorting is performed function combine_like_terms!(a::QQMPolyRingElem) - ccall((:fmpq_mpoly_combine_like_terms, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, a.parent) + @ccall libflint.fmpq_mpoly_combine_like_terms(a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing return a end @@ -876,37 +773,27 @@ end ############################################################################### function exponent_vector_fits(::Type{Int}, a::QQMPolyRingElem, i::Int) - b = ccall((:fmpq_mpoly_term_exp_fits_si, libflint), Cint, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - a, i - 1, a.parent) + b = @ccall libflint.fmpq_mpoly_term_exp_fits_si(a::Ref{QQMPolyRingElem}, (i - 1)::Int, a.parent::Ref{QQMPolyRing})::Cint return Bool(b) end function exponent_vector_fits(::Type{UInt}, a::QQMPolyRingElem, i::Int) - b = ccall((:fmpq_mpoly_term_exp_fits_ui, libflint), Cint, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - a, i - 1, a.parent) + b = @ccall libflint.fmpq_mpoly_term_exp_fits_ui(a::Ref{QQMPolyRingElem}, (i - 1)::Int, a.parent::Ref{QQMPolyRing})::Cint return Bool(b) end function exponent_vector!(z::Vector{Int}, a::QQMPolyRingElem, i::Int) - ccall((:fmpq_mpoly_get_term_exp_si, libflint), Nothing, - (Ptr{Int}, Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpq_mpoly_get_term_exp_si(z::Ptr{Int}, a::Ref{QQMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{QQMPolyRing})::Nothing return z end function exponent_vector!(z::Vector{UInt}, a::QQMPolyRingElem, i::Int) - ccall((:fmpq_mpoly_get_term_exp_ui, libflint), Nothing, - (Ptr{UInt}, Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpq_mpoly_get_term_exp_ui(z::Ptr{UInt}, a::Ref{QQMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{QQMPolyRing})::Nothing return z end function exponent_vector!(z::Vector{ZZRingElem}, a::QQMPolyRingElem, i::Int) - ccall((:fmpq_mpoly_get_term_exp_fmpz, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpq_mpoly_get_term_exp_fmpz(z::Ptr{Ref{ZZRingElem}}, a::Ref{QQMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{QQMPolyRing})::Nothing return z end @@ -920,12 +807,9 @@ end # they don't fit into 31/63 bits function set_exponent_vector!(a::QQMPolyRingElem, n::Int, exps::Vector{UInt}) if n > length(a) - ccall((:fmpq_mpoly_resize, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), a, n, a.parent) + @ccall libflint.fmpq_mpoly_resize(a::Ref{QQMPolyRingElem}, n::Int, a.parent::Ref{QQMPolyRing})::Nothing end - ccall((:fmpq_mpoly_set_term_exp_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ptr{UInt}, Ref{QQMPolyRing}), - a, n - 1, exps, parent(a)) + @ccall libflint.fmpq_mpoly_set_term_exp_ui(a::Ref{QQMPolyRingElem}, (n - 1)::Int, exps::Ptr{UInt}, parent(a)::Ref{QQMPolyRing})::Nothing return a end @@ -934,12 +818,9 @@ end # no check is performed function set_exponent_vector!(a::QQMPolyRingElem, n::Int, exps::Vector{Int}) if n > length(a) - ccall((:fmpq_mpoly_resize, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), a, n, a.parent) + @ccall libflint.fmpq_mpoly_resize(a::Ref{QQMPolyRingElem}, n::Int, a.parent::Ref{QQMPolyRing})::Nothing end - ccall((:fmpq_mpoly_set_term_exp_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ptr{Int}, Ref{QQMPolyRing}), - a, n - 1, exps, parent(a)) + @ccall libflint.fmpq_mpoly_set_term_exp_ui(a::Ref{QQMPolyRingElem}, (n - 1)::Int, exps::Ptr{Int}, parent(a)::Ref{QQMPolyRing})::Nothing return a end @@ -947,30 +828,23 @@ end # No sort is performed, so this is unsafe function set_exponent_vector!(a::QQMPolyRingElem, n::Int, exps::Vector{ZZRingElem}) if n > length(a) - ccall((:fmpq_mpoly_resize, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), a, n, a.parent) + @ccall libflint.fmpq_mpoly_resize(a::Ref{QQMPolyRingElem}, n::Int, a.parent::Ref{QQMPolyRing})::Nothing end - GC.@preserve exps ccall((:fmpq_mpoly_set_term_exp_fmpz, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ptr{ZZRingElem}, Ref{QQMPolyRing}), - a, n - 1, exps, parent(a)) + GC.@preserve exps @ccall libflint.fmpq_mpoly_set_term_exp_fmpz(a::Ref{QQMPolyRingElem}, (n - 1)::Int, exps::Ptr{ZZRingElem}, parent(a)::Ref{QQMPolyRing})::Nothing return a end # Return j-th coordinate of i-th exponent vector function exponent(a::QQMPolyRingElem, i::Int, j::Int) (j < 1 || j > nvars(parent(a))) && error("Invalid variable index") - return ccall((:fmpq_mpoly_get_term_var_exp_ui, libflint), Int, - (Ref{QQMPolyRingElem}, Int, Int, Ref{QQMPolyRing}), - a, i - 1, j - 1, a.parent) + return @ccall libflint.fmpq_mpoly_get_term_var_exp_ui(a::Ref{QQMPolyRingElem}, (i - 1)::Int, (j - 1)::Int, a.parent::Ref{QQMPolyRing})::Int end # Return the coefficient of the term with the given exponent vector # Return zero if there is no such term function coeff(a::QQMPolyRingElem, exps::Vector{UInt}) z = QQFieldElem() - ccall((:fmpq_mpoly_get_coeff_fmpq_ui, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQMPolyRingElem}, Ptr{UInt}, Ref{QQMPolyRing}), - z, a, exps, parent(a)) + @ccall libflint.fmpq_mpoly_get_coeff_fmpq_ui(z::Ref{QQFieldElem}, a::Ref{QQMPolyRingElem}, exps::Ptr{UInt}, parent(a)::Ref{QQMPolyRing})::Nothing return z end @@ -978,27 +852,21 @@ end # Return zero if there is no such term function coeff(a::QQMPolyRingElem, exps::Vector{Int}) z = QQFieldElem() - ccall((:fmpq_mpoly_get_coeff_fmpq_ui, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQMPolyRingElem}, Ptr{Int}, Ref{QQMPolyRing}), - z, a, exps, parent(a)) + @ccall libflint.fmpq_mpoly_get_coeff_fmpq_ui(z::Ref{QQFieldElem}, a::Ref{QQMPolyRingElem}, exps::Ptr{Int}, parent(a)::Ref{QQMPolyRing})::Nothing return z end # Set the coefficient of the term with the given exponent vector to the # given QQFieldElem. Removal of a zero term is performed. function setcoeff!(a::QQMPolyRingElem, exps::Vector{UInt}, b::QQFieldElem) - ccall((:fmpq_mpoly_set_coeff_fmpq_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQFieldElem}, Ptr{UInt}, Ref{QQMPolyRing}), - a, b, exps, parent(a)) + @ccall libflint.fmpq_mpoly_set_coeff_fmpq_ui(a::Ref{QQMPolyRingElem}, b::Ref{QQFieldElem}, exps::Ptr{UInt}, parent(a)::Ref{QQMPolyRing})::Nothing return a end # Set the coefficient of the term with the given exponent vector to the # given QQFieldElem. Removal of a zero term is performed. function setcoeff!(a::QQMPolyRingElem, exps::Vector{Int}, b::QQFieldElem) - ccall((:fmpq_mpoly_set_coeff_fmpq_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQFieldElem}, Ptr{Int}, Ref{QQMPolyRing}), - a, b, exps, parent(a)) + @ccall libflint.fmpq_mpoly_set_coeff_fmpq_ui(a::Ref{QQMPolyRingElem}, b::Ref{QQFieldElem}, exps::Ptr{Int}, parent(a)::Ref{QQMPolyRing})::Nothing return a end @@ -1011,8 +879,7 @@ setcoeff!(a::QQMPolyRingElem, exps::Vector{Int}, b::RationalUnion) = setcoeff!(a # out of order. Note that like terms are not combined and zeros are not # removed. For that, call combine_like_terms! function sort_terms!(a::QQMPolyRingElem) - ccall((:fmpq_mpoly_sort_terms, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRing}), a, a.parent) + @ccall libflint.fmpq_mpoly_sort_terms(a::Ref{QQMPolyRingElem}, a.parent::Ref{QQMPolyRing})::Nothing return a end @@ -1021,9 +888,7 @@ function term(a::QQMPolyRingElem, i::Int) z = parent(a)() n = length(a) (i < 1 || i > n) && error("Index must be between 1 and $(length(a))") - ccall((:fmpq_mpoly_get_term, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - z, a, i - 1, a.parent) + @ccall libflint.fmpq_mpoly_get_term(z::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, (i - 1)::Int, a.parent::Ref{QQMPolyRing})::Nothing return z end @@ -1032,17 +897,13 @@ function monomial(a::QQMPolyRingElem, i::Int) z = parent(a)() n = length(a) (i < 1 || i > n) && error("Index must be between 1 and $(length(a))") - ccall((:fmpq_mpoly_get_term_monomial, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - z, a, i - 1, a.parent) + @ccall libflint.fmpq_mpoly_get_term_monomial(z::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, (i - 1)::Int, a.parent::Ref{QQMPolyRing})::Nothing return z end # Sets the given polynomial m to the i-th monomial of the polynomial function monomial!(m::QQMPolyRingElem, a::QQMPolyRingElem, i::Int) - ccall((:fmpq_mpoly_get_term_monomial, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQMPolyRingElem}, Int, Ref{QQMPolyRing}), - m, a, i - 1, a.parent) + @ccall libflint.fmpq_mpoly_get_term_monomial(m::Ref{QQMPolyRingElem}, a::Ref{QQMPolyRingElem}, (i - 1)::Int, a.parent::Ref{QQMPolyRing})::Nothing return m end @@ -1067,30 +928,22 @@ promote_rule(::Type{QQMPolyRingElem}, ::Type{QQFieldElem}) = QQMPolyRingElem ############################################################################### function _push_term!(z::QQMPolyRingElem, c::QQFieldElem, exp::Vector{Int}) - ccall((:fmpq_mpoly_push_term_fmpq_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{QQFieldElem}, Ptr{UInt}, Ref{QQMPolyRing}), - z, c, exp, parent(z)) + @ccall libflint.fmpq_mpoly_push_term_fmpq_ui(z::Ref{QQMPolyRingElem}, c::Ref{QQFieldElem}, exp::Ptr{UInt}, parent(z)::Ref{QQMPolyRing})::Nothing return z end function _push_term!(z::QQMPolyRingElem, c::ZZRingElem, exp::Vector{Int}) - ccall((:fmpq_mpoly_push_term_fmpz_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, Ref{ZZRingElem}, Ptr{UInt}, Ref{QQMPolyRing}), - z, c, exp, parent(z)) + @ccall libflint.fmpq_mpoly_push_term_fmpz_ui(z::Ref{QQMPolyRingElem}, c::Ref{ZZRingElem}, exp::Ptr{UInt}, parent(z)::Ref{QQMPolyRing})::Nothing return z end function _push_term!(z::QQMPolyRingElem, c::Int, exp::Vector{Int}) - ccall((:fmpq_mpoly_push_term_si_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, Int, Ptr{UInt}, Ref{QQMPolyRing}), - z, c, exp, parent(z)) + @ccall libflint.fmpq_mpoly_push_term_si_ui(z::Ref{QQMPolyRingElem}, c::Int, exp::Ptr{UInt}, parent(z)::Ref{QQMPolyRing})::Nothing return z end function _push_term!(z::QQMPolyRingElem, c::UInt, exp::Vector{Int}) - ccall((:fmpq_mpoly_push_term_ui_ui, libflint), Nothing, - (Ref{QQMPolyRingElem}, UInt, Ptr{UInt}, Ref{QQMPolyRing}), - z, c, exp, parent(z)) + @ccall libflint.fmpq_mpoly_push_term_ui_ui(z::Ref{QQMPolyRingElem}, c::UInt, exp::Ptr{UInt}, parent(z)::Ref{QQMPolyRing})::Nothing return z end diff --git a/src/flint/fmpq_poly.jl b/src/flint/fmpq_poly.jl index ab8c2f904..1daf03970 100644 --- a/src/flint/fmpq_poly.jl +++ b/src/flint/fmpq_poly.jl @@ -36,25 +36,21 @@ $a$. """ function denominator(a::QQPolyRingElem) z = ZZRingElem() - ccall((:fmpq_poly_get_denominator, libflint), Nothing, - (Ref{ZZRingElem}, Ref{QQPolyRingElem}), z, a) + @ccall libflint.fmpq_poly_get_denominator(z::Ref{ZZRingElem}, a::Ref{QQPolyRingElem})::Nothing return z end -length(x::QQPolyRingElem) = ccall((:fmpq_poly_length, libflint), Int, - (Ref{QQPolyRingElem},), x) +length(x::QQPolyRingElem) = @ccall libflint.fmpq_poly_length(x::Ref{QQPolyRingElem})::Int function set_length!(x::QQPolyRingElem, n::Int) - ccall((:_fmpq_poly_set_length, libflint), Nothing, - (Ref{QQPolyRingElem}, Int), x, n) + @ccall libflint._fmpq_poly_set_length(x::Ref{QQPolyRingElem}, n::Int)::Nothing return x end function coeff(x::QQPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = QQFieldElem() - ccall((:fmpq_poly_get_coeff_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQPolyRingElem}, Int), z, x, n) + @ccall libflint.fmpq_poly_get_coeff_fmpq(z::Ref{QQFieldElem}, x::Ref{QQPolyRingElem}, n::Int)::Nothing return z end @@ -64,8 +60,7 @@ one(a::QQPolyRing) = a(1) gen(a::QQPolyRing) = a([zero(base_ring(a)), one(base_ring(a))]) -is_gen(x::QQPolyRingElem) = ccall((:fmpq_poly_is_gen, libflint), Bool, - (Ref{QQPolyRingElem},), x) +is_gen(x::QQPolyRingElem) = @ccall libflint.fmpq_poly_is_gen(x::Ref{QQPolyRingElem})::Bool function deepcopy_internal(a::QQPolyRingElem, dict::IdDict) z = QQPolyRingElem(a) @@ -170,9 +165,7 @@ end function ^(x::QQPolyRingElem, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() - ccall((:fmpq_poly_pow, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Int), - z, x, y) + @ccall libflint.fmpq_poly_pow(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, y::Int)::Nothing return z end @@ -184,8 +177,7 @@ end function ==(x::QQPolyRingElem, y::QQPolyRingElem) check_parent(x, y) - return ccall((:fmpq_poly_equal, libflint), Bool, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}), x, y) + return @ccall libflint.fmpq_poly_equal(x::Ref{QQPolyRingElem}, y::Ref{QQPolyRingElem})::Bool end ############################################################################### @@ -199,8 +191,7 @@ function ==(x::QQPolyRingElem, y::QQFieldElem) return false elseif length(x) == 1 z = QQFieldElem() - ccall((:fmpq_poly_get_coeff_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQPolyRingElem}, Int), z, x, 0) + @ccall libflint.fmpq_poly_get_coeff_fmpq(z::Ref{QQFieldElem}, x::Ref{QQPolyRingElem}, 0::Int)::Nothing return z == y else return iszero(y) @@ -227,8 +218,7 @@ function truncate(a::QQPolyRingElem, n::Int) end z = parent(a)() - ccall((:fmpq_poly_set_trunc, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Int), z, a, n) + @ccall libflint.fmpq_poly_set_trunc(z::Ref{QQPolyRingElem}, a::Ref{QQPolyRingElem}, n::Int)::Nothing return z end @@ -237,8 +227,7 @@ function mullow(x::QQPolyRingElem, y::QQPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() - ccall((:fmpq_poly_mullow, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Int), z, x, y, n) + @ccall libflint.fmpq_poly_mullow(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, y::Ref{QQPolyRingElem}, n::Int)::Nothing return z end @@ -251,8 +240,7 @@ end function reverse(x::QQPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Length must be non-negative")) z = parent(x)() - ccall((:fmpq_poly_reverse, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Int), z, x, len) + @ccall libflint.fmpq_poly_reverse(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, len::Int)::Nothing return z end @@ -265,16 +253,14 @@ end function shift_left(x::QQPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Int), z, x, len) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, len::Int)::Nothing return z end function shift_right(x::QQPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:fmpq_poly_shift_right, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Int), z, x, len) + @ccall libflint.fmpq_poly_shift_right(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, len::Int)::Nothing return z end @@ -288,9 +274,7 @@ function mod(x::QQPolyRingElem, y::QQPolyRingElem) check_parent(x, y) iszero(y) && throw(DivideError()) r = parent(x)() - ccall((:fmpq_poly_rem, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Ref{QQPolyRingElem}), - r, x, y) + @ccall libflint.fmpq_poly_rem(r::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, y::Ref{QQPolyRingElem})::Nothing return r end @@ -301,9 +285,7 @@ function Base.divrem(x::QQPolyRingElem, y::QQPolyRingElem) iszero(y) && throw(DivideError()) q = parent(x)() r = parent(x)() - ccall((:fmpq_poly_divrem, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Ref{QQPolyRingElem}), - q, r, x, y) + @ccall libflint.fmpq_poly_divrem(q::Ref{QQPolyRingElem}, r::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, y::Ref{QQPolyRingElem})::Nothing return q, r end @@ -317,8 +299,7 @@ function Base.div(x::QQPolyRingElem, y::QQPolyRingElem) check_parent(x, y) iszero(y) && throw(DivideError()) z = parent(x)() - ccall((:fmpq_poly_div, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Ref{QQPolyRingElem}), z, x, y) + @ccall libflint.fmpq_poly_div(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, y::Ref{QQPolyRingElem})::Nothing return z end @@ -341,24 +322,21 @@ end function divexact(x::QQPolyRingElem, y::ZZRingElem; check::Bool=true) iszero(y) && throw(DivideError()) z = parent(x)() - ccall((:fmpq_poly_scalar_div_fmpz, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpq_poly_scalar_div_fmpz(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, y::Ref{ZZRingElem})::Nothing return z end function divexact(x::QQPolyRingElem, y::QQFieldElem; check::Bool=true) iszero(y) && throw(DivideError()) z = parent(x)() - ccall((:fmpq_poly_scalar_div_fmpq, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Ref{QQFieldElem}), z, x, y) + @ccall libflint.fmpq_poly_scalar_div_fmpq(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, y::Ref{QQFieldElem})::Nothing return z end function divexact(x::QQPolyRingElem, y::Int; check::Bool=true) y == 0 && throw(DivideError()) z = parent(x)() - ccall((:fmpq_poly_scalar_div_si, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Int), z, x, y) + @ccall libflint.fmpq_poly_scalar_div_si(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, y::Int)::Nothing return z end @@ -392,22 +370,19 @@ end function gcd(x::QQPolyRingElem, y::QQPolyRingElem) check_parent(x, y) z = parent(x)() - ccall((:fmpq_poly_gcd, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Ref{QQPolyRingElem}), z, x, y) + @ccall libflint.fmpq_poly_gcd(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, y::Ref{QQPolyRingElem})::Nothing return z end function content(x::QQPolyRingElem) z = QQFieldElem() - ccall((:fmpq_poly_content, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQPolyRingElem}), z, x) + @ccall libflint.fmpq_poly_content(z::Ref{QQFieldElem}, x::Ref{QQPolyRingElem})::Nothing return z end function primpart(x::QQPolyRingElem) z = parent(x)() - ccall((:fmpq_poly_primitive_part, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}), z, x) + @ccall libflint.fmpq_poly_primitive_part(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem})::Nothing return z end @@ -419,15 +394,13 @@ end function evaluate(x::QQPolyRingElem, y::ZZRingElem) z = QQFieldElem() - ccall((:fmpq_poly_evaluate_fmpz, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQPolyRingElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpq_poly_evaluate_fmpz(z::Ref{QQFieldElem}, x::Ref{QQPolyRingElem}, y::Ref{ZZRingElem})::Nothing return z end function evaluate(x::QQPolyRingElem, y::QQFieldElem) z = QQFieldElem() - ccall((:fmpq_poly_evaluate_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQPolyRingElem}, Ref{QQFieldElem}), z, x, y) + @ccall libflint.fmpq_poly_evaluate_fmpq(z::Ref{QQFieldElem}, x::Ref{QQPolyRingElem}, y::Ref{QQFieldElem})::Nothing return z end @@ -444,8 +417,7 @@ evaluate(x::QQPolyRingElem, y::Rational) = evaluate(x, QQFieldElem(y)) function AbstractAlgebra._compose_right(x::QQPolyRingElem, y::QQPolyRingElem) check_parent(x, y) z = parent(x)() - ccall((:fmpq_poly_compose, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Ref{QQPolyRingElem}), z, x, y) + @ccall libflint.fmpq_poly_compose(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, y::Ref{QQPolyRingElem})::Nothing return z end @@ -457,8 +429,7 @@ end function derivative(x::QQPolyRingElem) z = parent(x)() - ccall((:fmpq_poly_derivative, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}), z, x) + @ccall libflint.fmpq_poly_derivative(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem})::Nothing return z end @@ -470,8 +441,7 @@ end function integral(x::QQPolyRingElem) z = parent(x)() - ccall((:fmpq_poly_integral, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}), z, x) + @ccall libflint.fmpq_poly_integral(z::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem})::Nothing return z end @@ -484,8 +454,7 @@ end function resultant(x::QQPolyRingElem, y::QQPolyRingElem) check_parent(x, y) z = QQFieldElem() - ccall((:fmpq_poly_resultant, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQPolyRingElem}, Ref{QQPolyRingElem}), z, x, y) + @ccall libflint.fmpq_poly_resultant(z::Ref{QQFieldElem}, x::Ref{QQPolyRingElem}, y::Ref{QQPolyRingElem})::Nothing return z end @@ -500,9 +469,7 @@ function gcdx(x::QQPolyRingElem, y::QQPolyRingElem) z = parent(x)() u = parent(x)() v = parent(x)() - ccall((:fmpq_poly_xgcd, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, Ref{QQPolyRingElem}, - Ref{QQPolyRingElem}), z, u, v, x, y) + @ccall libflint.fmpq_poly_xgcd(z::Ref{QQPolyRingElem}, u::Ref{QQPolyRingElem}, v::Ref{QQPolyRingElem}, x::Ref{QQPolyRingElem}, y::Ref{QQPolyRingElem})::Nothing return (z, u, v) end @@ -517,8 +484,7 @@ function sqrt(x::QQPolyRingElem; check::Bool=true) d = denominator(x) sd = sqrt(d; check=check) n = polynomial(ZZ, [], cached = false) - ccall((:fmpq_poly_get_numerator, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{QQPolyRingElem}), n, x) + @ccall libflint.fmpq_poly_get_numerator(n::Ref{ZZPolyRingElem}, x::Ref{QQPolyRingElem})::Nothing sn = sqrt(n; check=check) s = R(sn) return divexact(s, sd) @@ -530,8 +496,7 @@ function is_square(x::QQPolyRingElem) return false end n = polynomial(ZZ, []) - ccall((:fmpq_poly_get_numerator, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{QQPolyRingElem}), n, x) + @ccall libflint.fmpq_poly_get_numerator(n::Ref{ZZPolyRingElem}, x::Ref{QQPolyRingElem})::Nothing if !is_square(n) return false end @@ -546,8 +511,7 @@ function is_square_with_sqrt(x::QQPolyRingElem) return false, zero(R) end n = polynomial(ZZ, []) - ccall((:fmpq_poly_get_numerator, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{QQPolyRingElem}), n, x) + @ccall libflint.fmpq_poly_get_numerator(n::Ref{ZZPolyRingElem}, x::Ref{QQPolyRingElem})::Nothing f2, s2 = is_square_with_sqrt(n) if !f2 return false, zero(R) @@ -576,18 +540,15 @@ for (factor_fn, factor_fn_inner, flint_fn) in function $factor_fn_inner(x::QQPolyRingElem) res = Dict{QQPolyRingElem, Int}() y = ZZPolyRingElem() - ccall((:fmpq_poly_get_numerator, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{QQPolyRingElem}), y, x) + @ccall libflint.fmpq_poly_get_numerator(y::Ref{ZZPolyRingElem}, x::Ref{QQPolyRingElem})::Nothing fac = fmpz_poly_factor() ccall(($flint_fn, libflint), Nothing, (Ref{fmpz_poly_factor}, Ref{ZZPolyRingElem}), fac, y) z = ZZRingElem() - ccall((:fmpz_poly_factor_get_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{fmpz_poly_factor}), z, fac) + @ccall libflint.fmpz_poly_factor_get_fmpz(z::Ref{ZZRingElem}, fac::Ref{fmpz_poly_factor})::Nothing f = ZZPolyRingElem() for i in 1:fac.num - ccall((:fmpz_poly_factor_get_fmpz_poly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{fmpz_poly_factor}, Int), f, fac, i - 1) + @ccall libflint.fmpz_poly_factor_get_fmpz_poly(f::Ref{ZZPolyRingElem}, fac::Ref{fmpz_poly_factor}, (i - 1)::Int)::Nothing e = unsafe_load(fac.exp, i) res[parent(x)(f)] = e end @@ -625,8 +586,7 @@ julia> signature(x^3 + 3x + 1) """ function signature(f::QQPolyRingElem) z = ZZPolyRingElem() - ccall((:fmpq_poly_get_numerator, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{QQPolyRingElem}), z, f) + @ccall libflint.fmpq_poly_get_numerator(z::Ref{ZZPolyRingElem}, f::Ref{QQPolyRingElem})::Nothing return signature(z) end @@ -854,8 +814,7 @@ promote_rule(::Type{QQPolyRingElem}, ::Type{Rational{T}}) where T <: Union{Int, ############################################################################### function fmpq_poly_to_nmod_poly_raw!(r::zzModPolyRingElem, a::QQPolyRingElem) - ccall((:fmpq_poly_get_nmod_poly, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{QQPolyRingElem}), r, a) + @ccall libflint.fmpq_poly_get_nmod_poly(r::Ref{zzModPolyRingElem}, a::Ref{QQPolyRingElem})::Nothing return r end @@ -866,8 +825,7 @@ function (R::zzModPolyRing)(g::QQPolyRingElem) end function fmpq_poly_to_gfp_poly_raw!(r::fpPolyRingElem, a::QQPolyRingElem) - ccall((:fmpq_poly_get_nmod_poly, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{QQPolyRingElem}), r, a) + @ccall libflint.fmpq_poly_get_nmod_poly(r::Ref{fpPolyRingElem}, a::Ref{QQPolyRingElem})::Nothing return r end @@ -878,17 +836,11 @@ function (R::fpPolyRing)(g::QQPolyRingElem) end function fmpq_poly_to_fq_default_poly_raw!(r::FqPolyRingElem, a::QQPolyRingElem, t1::ZZPolyRingElem=ZZPolyRingElem(), t2::ZZRingElem=ZZRingElem()) - ccall((:fmpq_poly_get_numerator, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{QQPolyRingElem}), t1, a) - ccall((:fq_default_poly_set_fmpz_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{ZZPolyRingElem}, Ref{FqField}), - r, t1, base_ring(parent(r))) - ccall((:fmpq_poly_get_denominator, libflint), Nothing, - (Ref{ZZRingElem}, Ref{QQPolyRingElem}), t2, a) + @ccall libflint.fmpq_poly_get_numerator(t1::Ref{ZZPolyRingElem}, a::Ref{QQPolyRingElem})::Nothing + @ccall libflint.fq_default_poly_set_fmpz_poly(r::Ref{FqPolyRingElem}, t1::Ref{ZZPolyRingElem}, base_ring(parent(r))::Ref{FqField})::Nothing + @ccall libflint.fmpq_poly_get_denominator(t2::Ref{ZZRingElem}, a::Ref{QQPolyRingElem})::Nothing if !isone(t2) - ccall((:fq_default_poly_scalar_div_fq_default, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), - r, r, coefficient_ring(r)(t2), coefficient_ring(r)) + @ccall libflint.fq_default_poly_scalar_div_fq_default(r::Ref{FqPolyRingElem}, r::Ref{FqPolyRingElem}, coefficient_ring(r)(t2)::Ref{FqFieldElem}, coefficient_ring(r)::Ref{FqField})::Nothing end return r end @@ -900,20 +852,13 @@ function (R::FqPolyRing)(g::QQPolyRingElem) end function fmpq_poly_to_fmpz_mod_poly_raw!(r::ZZModPolyRingElem, a::QQPolyRingElem, t1::ZZPolyRingElem=ZZPolyRingElem(), t2::ZZRingElem=ZZRingElem()) - ccall((:fmpq_poly_get_numerator, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{QQPolyRingElem}), t1, a) - ccall((:fmpz_mod_poly_set_fmpz_poly, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{ZZPolyRingElem}, Ref{fmpz_mod_ctx_struct}), r, t1, base_ring(parent(r)).ninv) - ccall((:fmpq_poly_get_denominator, libflint), Nothing, - (Ref{ZZRingElem}, Ref{QQPolyRingElem}), t2, a) + @ccall libflint.fmpq_poly_get_numerator(t1::Ref{ZZPolyRingElem}, a::Ref{QQPolyRingElem})::Nothing + @ccall libflint.fmpz_mod_poly_set_fmpz_poly(r::Ref{ZZModPolyRingElem}, t1::Ref{ZZPolyRingElem}, base_ring(parent(r)).ninv::Ref{fmpz_mod_ctx_struct})::Nothing + @ccall libflint.fmpq_poly_get_denominator(t2::Ref{ZZRingElem}, a::Ref{QQPolyRingElem})::Nothing if !isone(t2) - res = ccall((:fmpz_invmod, libflint), Cint, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - t2, t2, modulus(base_ring(r))) + res = @ccall libflint.fmpz_invmod(t2::Ref{ZZRingElem}, t2::Ref{ZZRingElem}, modulus(base_ring(r))::Ref{ZZRingElem})::Cint @assert res != 0 - ccall((:fmpz_mod_poly_scalar_mul_fmpz, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - r, r, t2, base_ring(parent(r)).ninv) + @ccall libflint.fmpz_mod_poly_scalar_mul_fmpz(r::Ref{ZZModPolyRingElem}, r::Ref{ZZModPolyRingElem}, t2::Ref{ZZRingElem}, base_ring(parent(r)).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end return r end @@ -925,20 +870,13 @@ function (R::ZZModPolyRing)(g::QQPolyRingElem) end function fmpq_poly_to_gfp_fmpz_poly_raw!(r::FpPolyRingElem, a::QQPolyRingElem, t1::ZZPolyRingElem=ZZPolyRingElem(), t2::ZZRingElem=ZZRingElem()) - ccall((:fmpq_poly_get_numerator, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{QQPolyRingElem}), t1, a) - ccall((:fmpz_mod_poly_set_fmpz_poly, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{ZZPolyRingElem}, Ref{fmpz_mod_ctx_struct}), r, t1, base_ring(parent(r)).ninv) - ccall((:fmpq_poly_get_denominator, libflint), Nothing, - (Ref{ZZRingElem}, Ref{QQPolyRingElem}), t2, a) + @ccall libflint.fmpq_poly_get_numerator(t1::Ref{ZZPolyRingElem}, a::Ref{QQPolyRingElem})::Nothing + @ccall libflint.fmpz_mod_poly_set_fmpz_poly(r::Ref{FpPolyRingElem}, t1::Ref{ZZPolyRingElem}, base_ring(parent(r)).ninv::Ref{fmpz_mod_ctx_struct})::Nothing + @ccall libflint.fmpq_poly_get_denominator(t2::Ref{ZZRingElem}, a::Ref{QQPolyRingElem})::Nothing if !isone(t2) - res = ccall((:fmpz_invmod, libflint), Cint, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - t2, t2, modulus(base_ring(r))) + res = @ccall libflint.fmpz_invmod(t2::Ref{ZZRingElem}, t2::Ref{ZZRingElem}, modulus(base_ring(r))::Ref{ZZRingElem})::Cint @assert res != 0 - ccall((:fmpz_mod_poly_scalar_mul_fmpz, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - r, r, t2, base_ring(parent(r)).ninv) + @ccall libflint.fmpz_mod_poly_scalar_mul_fmpz(r::Ref{FpPolyRingElem}, r::Ref{FpPolyRingElem}, t2::Ref{ZZRingElem}, base_ring(parent(r)).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end return r end @@ -952,8 +890,7 @@ end function (a::ZZPolyRing)(b::QQPolyRingElem) (!isone(denominator(b))) && error("Denominator has to be 1") z = a() - ccall((:fmpq_poly_get_numerator, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{QQPolyRingElem}), z, b) + @ccall libflint.fmpq_poly_get_numerator(z::Ref{ZZPolyRingElem}, b::Ref{QQPolyRingElem})::Nothing return z end @@ -1008,7 +945,7 @@ end function (a::QQPolyRing)(b::Vector{ZZRingElem}, copy::Bool=true) x = a() for i=1:length(b) - ccall((:fmpq_poly_set_coeff_fmpz, libflint), Cvoid, (Ref{QQPolyRingElem}, Int, Ref{ZZRingElem}), x, i - 1, b[i]) + @ccall libflint.fmpq_poly_set_coeff_fmpz(x::Ref{QQPolyRingElem}, (i - 1)::Int, b[i]::Ref{ZZRingElem})::Cvoid end return x end diff --git a/src/flint/fmpq_rel_series.jl b/src/flint/fmpq_rel_series.jl index 20eb22554..e61cb56e7 100644 --- a/src/flint/fmpq_rel_series.jl +++ b/src/flint/fmpq_rel_series.jl @@ -39,21 +39,19 @@ max_precision(R::QQRelPowerSeriesRing) = R.prec_max function normalise(a::QQRelPowerSeriesRingElem, len::Int) if len > 0 c = QQFieldElem() - ccall((:fmpq_poly_get_coeff_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQRelPowerSeriesRingElem}, Int), c, a, len - 1) + @ccall libflint.fmpq_poly_get_coeff_fmpq(c::Ref{QQFieldElem}, a::Ref{QQRelPowerSeriesRingElem}, (len - 1)::Int)::Nothing end while len > 0 && iszero(c) len -= 1 if len > 0 - ccall((:fmpq_poly_get_coeff_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQRelPowerSeriesRingElem}, Int), c, a, len - 1) + @ccall libflint.fmpq_poly_get_coeff_fmpq(c::Ref{QQFieldElem}, a::Ref{QQRelPowerSeriesRingElem}, (len - 1)::Int)::Nothing end end return len end function pol_length(x::QQRelPowerSeriesRingElem) - return ccall((:fmpq_poly_length, libflint), Int, (Ref{QQRelPowerSeriesRingElem},), x) + return @ccall libflint.fmpq_poly_length(x::Ref{QQRelPowerSeriesRingElem})::Int end precision(x::QQRelPowerSeriesRingElem) = x.prec @@ -63,8 +61,7 @@ function polcoeff(x::QQRelPowerSeriesRingElem, n::Int) return QQFieldElem(0) end z = QQFieldElem() - ccall((:fmpq_poly_get_coeff_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQRelPowerSeriesRingElem}, Int), z, x, n) + @ccall libflint.fmpq_poly_get_coeff_fmpq(z::Ref{QQFieldElem}, x::Ref{QQRelPowerSeriesRingElem}, n::Int)::Nothing return z end @@ -99,8 +96,7 @@ function renormalize!(z::QQRelPowerSeriesRingElem) z.val = zprec else z.val = zval + i - ccall((:fmpq_poly_shift_right, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), z, z, i) + @ccall libflint.fmpq_poly_shift_right(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, i::Int)::Nothing end return nothing end @@ -153,9 +149,7 @@ end function -(x::QQRelPowerSeriesRingElem) z = parent(x)() - ccall((:fmpq_poly_neg, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}), - z, x) + @ccall libflint.fmpq_poly_neg(z::Ref{QQRelPowerSeriesRingElem}, x::Ref{QQRelPowerSeriesRingElem})::Nothing z.prec = x.prec z.val = x.val return z @@ -181,28 +175,18 @@ function +(a::QQRelPowerSeriesRingElem, b::QQRelPowerSeriesRingElem) ccall((:fmpq_poly_set_trunc, libflint), Nothing, (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), z, b, max(0, lenz - b.val + a.val)) - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, b.val - a.val) - ccall((:fmpq_poly_add_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a, lenz) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, (b.val - a.val)::Int)::Nothing + @ccall libflint.fmpq_poly_add_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, lenz::Int)::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:fmpq_poly_set_trunc, libflint), Nothing, (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), z, a, max(0, lenz - a.val + b.val)) - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.val - b.val) - ccall((:fmpq_poly_add_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, b, lenz) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, (a.val - b.val)::Int)::Nothing + @ccall libflint.fmpq_poly_add_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, b::Ref{QQRelPowerSeriesRingElem}, lenz::Int)::Nothing else lenz = max(lena, lenb) - ccall((:fmpq_poly_add_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpq_poly_add_series(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, b::Ref{QQRelPowerSeriesRingElem}, lenz::Int)::Nothing end z.prec = prec z.val = val @@ -225,30 +209,19 @@ function -(a::QQRelPowerSeriesRingElem, b::QQRelPowerSeriesRingElem) ccall((:fmpq_poly_set_trunc, libflint), Nothing, (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), z, b, max(0, lenz - b.val + a.val)) - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, b.val - a.val) - ccall((:fmpq_poly_neg, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}), z, z) - ccall((:fmpq_poly_add_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a, lenz) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, (b.val - a.val)::Int)::Nothing + @ccall libflint.fmpq_poly_neg(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem})::Nothing + @ccall libflint.fmpq_poly_add_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, lenz::Int)::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:fmpq_poly_set_trunc, libflint), Nothing, (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), z, a, max(0, lenz - a.val + b.val)) - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.val - b.val) - ccall((:fmpq_poly_sub_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, b, lenz) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, (a.val - b.val)::Int)::Nothing + @ccall libflint.fmpq_poly_sub_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, b::Ref{QQRelPowerSeriesRingElem}, lenz::Int)::Nothing else lenz = max(lena, lenb) - ccall((:fmpq_poly_sub_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpq_poly_sub_series(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, b::Ref{QQRelPowerSeriesRingElem}, lenz::Int)::Nothing end z.prec = prec z.val = val @@ -272,9 +245,7 @@ function *(a::QQRelPowerSeriesRingElem, b::QQRelPowerSeriesRingElem) return z end lenz = min(lena + lenb - 1, prec) - ccall((:fmpq_poly_mullow, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpq_poly_mullow(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, b::Ref{QQRelPowerSeriesRingElem}, lenz::Int)::Nothing return z end @@ -288,9 +259,7 @@ function *(x::Int, y::QQRelPowerSeriesRingElem) z = parent(y)() z.prec = y.prec z.val = y.val - ccall((:fmpq_poly_scalar_mul_si, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, y, x) + @ccall libflint.fmpq_poly_scalar_mul_si(z::Ref{QQRelPowerSeriesRingElem}, y::Ref{QQRelPowerSeriesRingElem}, x::Int)::Nothing return z end @@ -300,9 +269,7 @@ function *(x::ZZRingElem, y::QQRelPowerSeriesRingElem) z = parent(y)() z.prec = y.prec z.val = y.val - ccall((:fmpq_poly_scalar_mul_fmpz, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{ZZRingElem}), - z, y, x) + @ccall libflint.fmpq_poly_scalar_mul_fmpz(z::Ref{QQRelPowerSeriesRingElem}, y::Ref{QQRelPowerSeriesRingElem}, x::Ref{ZZRingElem})::Nothing return z end @@ -310,9 +277,7 @@ function *(x::QQFieldElem, y::QQRelPowerSeriesRingElem) z = parent(y)() z.prec = y.prec z.val = y.val - ccall((:fmpq_poly_scalar_mul_fmpq, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQFieldElem}), - z, y, x) + @ccall libflint.fmpq_poly_scalar_mul_fmpq(z::Ref{QQRelPowerSeriesRingElem}, y::Ref{QQRelPowerSeriesRingElem}, x::Ref{QQFieldElem})::Nothing return z end @@ -372,9 +337,7 @@ function shift_right(x::QQRelPowerSeriesRingElem, len::Int) z.prec = max(0, x.prec - len) z.val = max(0, xval - len) zlen = min(xlen + xval - len, xlen) - ccall((:fmpq_poly_shift_right, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, x, xlen - zlen) + @ccall libflint.fmpq_poly_shift_right(z::Ref{QQRelPowerSeriesRingElem}, x::Ref{QQRelPowerSeriesRingElem}, (xlen - zlen)::Int)::Nothing renormalize!(z) end return z @@ -399,9 +362,7 @@ function truncate!(x::QQRelPowerSeriesRingElem, k::Int) x = zero!(x) x.val = k else - ccall((:fmpq_poly_truncate, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Int), - x, k - valuation(x)) + @ccall libflint.fmpq_poly_truncate(x::Ref{QQRelPowerSeriesRingElem}, (k - valuation(x))::Int)::Nothing end x.prec = k return x @@ -467,9 +428,7 @@ function ==(x::QQRelPowerSeriesRingElem, y::QQRelPowerSeriesRingElem) if xlen != ylen return false end - return Bool(ccall((:fmpq_poly_equal_trunc, libflint), Cint, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - x, y, xlen)) + return Bool(@ccall libflint.fmpq_poly_equal_trunc(x::Ref{QQRelPowerSeriesRingElem}, y::Ref{QQRelPowerSeriesRingElem}, xlen::Int)::Cint) end function isequal(x::QQRelPowerSeriesRingElem, y::QQRelPowerSeriesRingElem) @@ -479,9 +438,7 @@ function isequal(x::QQRelPowerSeriesRingElem, y::QQRelPowerSeriesRingElem) if x.prec != y.prec || x.val != y.val || pol_length(x) != pol_length(y) return false end - return Bool(ccall((:fmpq_poly_equal, libflint), Cint, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}), - x, y)) + return Bool(@ccall libflint.fmpq_poly_equal(x::Ref{QQRelPowerSeriesRingElem}, y::Ref{QQRelPowerSeriesRingElem})::Cint) end ############################################################################### @@ -498,8 +455,7 @@ function ==(x::QQRelPowerSeriesRingElem, y::QQFieldElem) elseif pol_length(x) == 1 if x.val == 0 z = QQFieldElem() - ccall((:fmpq_poly_get_coeff_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQRelPowerSeriesRingElem}, Int), z, x, 0) + @ccall libflint.fmpq_poly_get_coeff_fmpq(z::Ref{QQFieldElem}, x::Ref{QQRelPowerSeriesRingElem}, 0::Int)::Nothing return z == y else return false @@ -517,10 +473,8 @@ function ==(x::QQRelPowerSeriesRingElem, y::ZZRingElem) elseif pol_length(x) == 1 if x.val == 0 z = QQFieldElem() - ccall((:fmpq_poly_get_coeff_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{QQRelPowerSeriesRingElem}, Int), z, x, 0) - return isone(denominator(z)) && ccall((:fmpz_equal, libflint), Bool, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), numerator(z), y, 0) + @ccall libflint.fmpq_poly_get_coeff_fmpq(z::Ref{QQFieldElem}, x::Ref{QQRelPowerSeriesRingElem}, 0::Int)::Nothing + return isone(denominator(z)) && @ccall libflint.fmpz_equal(numerator(z)::Ref{ZZRingElem}, y::Ref{ZZRingElem}, 0::Int)::Bool else return false end @@ -564,9 +518,7 @@ function divexact(x::QQRelPowerSeriesRingElem, y::QQRelPowerSeriesRingElem; chec z.val = xval - yval z.prec = prec + z.val if prec != 0 - ccall((:fmpq_poly_div_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, x, y, prec) + @ccall libflint.fmpq_poly_div_series(z::Ref{QQRelPowerSeriesRingElem}, x::Ref{QQRelPowerSeriesRingElem}, y::Ref{QQRelPowerSeriesRingElem}, prec::Int)::Nothing end return z end @@ -582,9 +534,7 @@ function divexact(x::QQRelPowerSeriesRingElem, y::Int; check::Bool=true) z = parent(x)() z.prec = x.prec z.val = x.val - ccall((:fmpq_poly_scalar_div_si, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, x, y) + @ccall libflint.fmpq_poly_scalar_div_si(z::Ref{QQRelPowerSeriesRingElem}, x::Ref{QQRelPowerSeriesRingElem}, y::Int)::Nothing return z end @@ -594,9 +544,7 @@ function divexact(x::QQRelPowerSeriesRingElem, y::ZZRingElem; check::Bool=true) z.prec = x.prec z.prec = x.prec z.val = x.val - ccall((:fmpq_poly_scalar_div_fmpz, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{ZZRingElem}), - z, x, y) + @ccall libflint.fmpq_poly_scalar_div_fmpz(z::Ref{QQRelPowerSeriesRingElem}, x::Ref{QQRelPowerSeriesRingElem}, y::Ref{ZZRingElem})::Nothing return z end @@ -606,9 +554,7 @@ function divexact(x::QQRelPowerSeriesRingElem, y::QQFieldElem; check::Bool=true) z.prec = x.prec z.prec = x.prec z.val = x.val - ccall((:fmpq_poly_scalar_div_fmpq, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQFieldElem}), - z, x, y) + @ccall libflint.fmpq_poly_scalar_div_fmpq(z::Ref{QQRelPowerSeriesRingElem}, x::Ref{QQRelPowerSeriesRingElem}, y::Ref{QQFieldElem})::Nothing return z end @@ -628,9 +574,7 @@ function inv(a::QQRelPowerSeriesRingElem) ainv = parent(a)() ainv.prec = a.prec ainv.val = 0 - ccall((:fmpq_poly_inv_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - ainv, a, a.prec) + @ccall libflint.fmpq_poly_inv_series(ainv::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing return ainv end @@ -648,12 +592,8 @@ function Base.exp(a::QQRelPowerSeriesRingElem) z = parent(a)() z.prec = a.prec z.val = 0 - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.val) - ccall((:fmpq_poly_exp_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.prec) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.val::Int)::Nothing + @ccall libflint.fmpq_poly_exp_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing renormalize!(z) return z end @@ -666,9 +606,7 @@ function log(a::QQRelPowerSeriesRingElem) z = parent(a)() z.prec = a.prec z.val = 0 - ccall((:fmpq_poly_log_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_log_series(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing renormalize!(z) return z end @@ -681,12 +619,8 @@ function tan(a::QQRelPowerSeriesRingElem) z = parent(a)() z.prec = a.prec z.val = 0 - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.val) - ccall((:fmpq_poly_tan_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.prec) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.val::Int)::Nothing + @ccall libflint.fmpq_poly_tan_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing renormalize!(z) return z end @@ -699,12 +633,8 @@ function tanh(a::QQRelPowerSeriesRingElem) z = parent(a)() z.prec = a.prec z.val = 0 - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.val) - ccall((:fmpq_poly_tanh_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.prec) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.val::Int)::Nothing + @ccall libflint.fmpq_poly_tanh_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing renormalize!(z) return z end @@ -717,15 +647,9 @@ function sin(a::QQRelPowerSeriesRingElem) z = parent(a)() z.prec = a.prec z.val = 0 - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.val) - ccall((:fmpq_poly_truncate, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Int), - z, a.prec) - ccall((:fmpq_poly_sin_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.prec) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.val::Int)::Nothing + @ccall libflint.fmpq_poly_truncate(z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing + @ccall libflint.fmpq_poly_sin_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing renormalize!(z) return z end @@ -738,12 +662,8 @@ function sinh(a::QQRelPowerSeriesRingElem) z = parent(a)() z.prec = a.prec z.val = 0 - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.val) - ccall((:fmpq_poly_sinh_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.prec) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.val::Int)::Nothing + @ccall libflint.fmpq_poly_sinh_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing renormalize!(z) return z end @@ -756,15 +676,9 @@ function cos(a::QQRelPowerSeriesRingElem) z = parent(a)() z.prec = a.prec z.val = 0 - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.val) - ccall((:fmpq_poly_truncate, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Int), - z, a.prec) - ccall((:fmpq_poly_cos_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.prec) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.val::Int)::Nothing + @ccall libflint.fmpq_poly_truncate(z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing + @ccall libflint.fmpq_poly_cos_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing renormalize!(z) return z end @@ -777,12 +691,8 @@ function cosh(a::QQRelPowerSeriesRingElem) z = parent(a)() z.prec = a.prec z.val = 0 - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.val) - ccall((:fmpq_poly_cosh_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.prec) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.val::Int)::Nothing + @ccall libflint.fmpq_poly_cosh_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing renormalize!(z) return z end @@ -795,12 +705,8 @@ function asin(a::QQRelPowerSeriesRingElem) z = parent(a)() z.prec = a.prec z.val = 0 - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.val) - ccall((:fmpq_poly_asin_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.prec) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.val::Int)::Nothing + @ccall libflint.fmpq_poly_asin_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing renormalize!(z) return z end @@ -813,12 +719,8 @@ function asinh(a::QQRelPowerSeriesRingElem) z = parent(a)() z.prec = a.prec z.val = 0 - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.val) - ccall((:fmpq_poly_asinh_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.prec) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.val::Int)::Nothing + @ccall libflint.fmpq_poly_asinh_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing renormalize!(z) return z end @@ -831,12 +733,8 @@ function atan(a::QQRelPowerSeriesRingElem) z = parent(a)() z.prec = a.prec z.val = 0 - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.val) - ccall((:fmpq_poly_atan_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.prec) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.val::Int)::Nothing + @ccall libflint.fmpq_poly_atan_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing renormalize!(z) return z end @@ -849,12 +747,8 @@ function atanh(a::QQRelPowerSeriesRingElem) z = parent(a)() z.prec = a.prec z.val = 0 - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.val) - ccall((:fmpq_poly_atanh_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, a.prec) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.val::Int)::Nothing + @ccall libflint.fmpq_poly_atanh_series(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing renormalize!(z) return z end @@ -874,9 +768,7 @@ function Base.sqrt(a::QQRelPowerSeriesRingElem; check::Bool=true) c = coeff(a, v) s = sqrt(c; check=check) a = divexact(a, c) - ccall((:fmpq_poly_sqrt_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.fmpq_poly_sqrt_series(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, a.prec::Int)::Nothing if !isone(s) z *= s end @@ -890,31 +782,26 @@ end ############################################################################### function zero!(z::QQRelPowerSeriesRingElem) - ccall((:fmpq_poly_zero, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem},), z) + @ccall libflint.fmpq_poly_zero(z::Ref{QQRelPowerSeriesRingElem})::Nothing z.prec = parent(z).prec_max z.val = parent(z).prec_max return z end function one!(z::QQRelPowerSeriesRingElem) - ccall((:fmpq_poly_one, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem},), z) + @ccall libflint.fmpq_poly_one(z::Ref{QQRelPowerSeriesRingElem})::Nothing z.prec = parent(z).prec_max z.val = 0 return z end function fit!(z::QQRelPowerSeriesRingElem, n::Int) - ccall((:fmpq_poly_fit_length, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Int), z, n) + @ccall libflint.fmpq_poly_fit_length(z::Ref{QQRelPowerSeriesRingElem}, n::Int)::Nothing return nothing end function setcoeff!(z::QQRelPowerSeriesRingElem, n::Int, x::QQFieldElem) - ccall((:fmpq_poly_set_coeff_fmpq, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Int, Ref{QQFieldElem}), - z, n, x) + @ccall libflint.fmpq_poly_set_coeff_fmpq(z::Ref{QQRelPowerSeriesRingElem}, n::Int, x::Ref{QQFieldElem})::Nothing return z end @@ -932,9 +819,7 @@ function mul!(z::QQRelPowerSeriesRingElem, a::QQRelPowerSeriesRingElem, b::QQRel if lena <= 0 || lenb <= 0 lenz = 0 end - ccall((:fmpq_poly_mullow, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpq_poly_mullow(z::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, b::Ref{QQRelPowerSeriesRingElem}, lenz::Int)::Nothing return z end @@ -952,28 +837,18 @@ function add!(a::QQRelPowerSeriesRingElem, b::QQRelPowerSeriesRingElem) ccall((:fmpq_poly_set_trunc, libflint), Nothing, (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), z, b, max(0, lenz - b.val + a.val)) - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - z, z, b.val - a.val) - ccall((:fmpq_poly_add_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - a, a, z, lenz) + @ccall libflint.fmpq_poly_shift_left(z::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, (b.val - a.val)::Int)::Nothing + @ccall libflint.fmpq_poly_add_series(a::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, z::Ref{QQRelPowerSeriesRingElem}, lenz::Int)::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:fmpq_poly_truncate, libflint), Nothing, (Ref{QQRelPowerSeriesRingElem}, Int), a, max(0, lenz - a.val + b.val)) - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - a, a, a.val - b.val) - ccall((:fmpq_poly_add_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - a, a, b, lenz) + @ccall libflint.fmpq_poly_shift_left(a::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, (a.val - b.val)::Int)::Nothing + @ccall libflint.fmpq_poly_add_series(a::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, b::Ref{QQRelPowerSeriesRingElem}, lenz::Int)::Nothing else lenz = max(lena, lenb) - ccall((:fmpq_poly_add_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - a, a, b, lenz) + @ccall libflint.fmpq_poly_add_series(a::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, b::Ref{QQRelPowerSeriesRingElem}, lenz::Int)::Nothing end a.prec = prec a.val = val @@ -998,28 +873,18 @@ function add!(c::QQRelPowerSeriesRingElem, a::QQRelPowerSeriesRingElem, b::QQRel ccall((:fmpq_poly_set_trunc, libflint), Nothing, (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), c, b, max(0, lenc - b.val + a.val)) - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - c, c, b.val - a.val) - ccall((:fmpq_poly_add_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - c, c, a, lenc) + @ccall libflint.fmpq_poly_shift_left(c::Ref{QQRelPowerSeriesRingElem}, c::Ref{QQRelPowerSeriesRingElem}, (b.val - a.val)::Int)::Nothing + @ccall libflint.fmpq_poly_add_series(c::Ref{QQRelPowerSeriesRingElem}, c::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, lenc::Int)::Nothing elseif b.val < a.val lenc = max(lena + a.val - b.val, lenb) ccall((:fmpq_poly_set_trunc, libflint), Nothing, (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), c, a, max(0, lenc - a.val + b.val)) - ccall((:fmpq_poly_shift_left, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - c, c, a.val - b.val) - ccall((:fmpq_poly_add_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - c, c, b, lenc) + @ccall libflint.fmpq_poly_shift_left(c::Ref{QQRelPowerSeriesRingElem}, c::Ref{QQRelPowerSeriesRingElem}, (a.val - b.val)::Int)::Nothing + @ccall libflint.fmpq_poly_add_series(c::Ref{QQRelPowerSeriesRingElem}, c::Ref{QQRelPowerSeriesRingElem}, b::Ref{QQRelPowerSeriesRingElem}, lenc::Int)::Nothing else lenc = max(lena, lenb) - ccall((:fmpq_poly_add_series, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Ref{QQRelPowerSeriesRingElem}, Int), - c, a, b, lenc) + @ccall libflint.fmpq_poly_add_series(c::Ref{QQRelPowerSeriesRingElem}, a::Ref{QQRelPowerSeriesRingElem}, b::Ref{QQRelPowerSeriesRingElem}, lenc::Int)::Nothing end c.prec = prec c.val = val @@ -1028,8 +893,7 @@ function add!(c::QQRelPowerSeriesRingElem, a::QQRelPowerSeriesRingElem, b::QQRel end function set_length!(a::QQRelPowerSeriesRingElem, n::Int) - ccall((:_fmpq_poly_set_length, libflint), Nothing, - (Ref{QQRelPowerSeriesRingElem}, Int), a, n) + @ccall libflint._fmpq_poly_set_length(a::Ref{QQRelPowerSeriesRingElem}, n::Int)::Nothing return a end diff --git a/src/flint/fmpz.jl b/src/flint/fmpz.jl index b9d41c67d..f191ff9f6 100644 --- a/src/flint/fmpz.jl +++ b/src/flint/fmpz.jl @@ -229,8 +229,7 @@ is_positive(n::ZZRingElemOrPtr) = sign(Int, n) > 0 Return `true` if $a$ fits into an `Int`, otherwise return `false`. """ -fits(::Type{Int}, a::ZZRingElem) = ccall((:fmpz_fits_si, libflint), Bool, - (Ref{ZZRingElem},), a) +fits(::Type{Int}, a::ZZRingElem) = @ccall libflint.fmpz_fits_si(a::Ref{ZZRingElem})::Bool @doc raw""" fits(::Type{UInt}, a::ZZRingElem) @@ -239,7 +238,7 @@ Return `true` if $a$ fits into a `UInt`, otherwise return `false`. """ @inline function fits(::Type{UInt}, a::ZZRingElem) a < 0 && return false - return ccall((:fmpz_abs_fits_ui, libflint), Bool, (Ref{ZZRingElem},), a) + return @ccall libflint.fmpz_abs_fits_ui(a::Ref{ZZRingElem})::Bool end if Culong !== UInt @@ -253,7 +252,7 @@ end Return the number of limbs required to store the absolute value of $a$. """ -size(a::ZZRingElem) = Int(ccall((:fmpz_size, libflint), Cint, (Ref{ZZRingElem},), a)) +size(a::ZZRingElem) = Int(@ccall libflint.fmpz_size(a::Ref{ZZRingElem})::Cint) is_unit(a::ZZRingElemOrPtr) = data(a) == 1 || data(a) == -1 @@ -285,8 +284,8 @@ function numerator(a::ZZRingElem) return a end -isodd(a::ZZRingElemOrPtr) = ccall((:fmpz_is_odd, libflint), Cint, (Ref{ZZRingElem},), a) % Bool -iseven(a::ZZRingElemOrPtr) = ccall((:fmpz_is_even, libflint), Cint, (Ref{ZZRingElem},), a) % Bool +isodd(a::ZZRingElemOrPtr) = @ccall libflint.fmpz_is_odd(a::Ref{ZZRingElem})::Cint % Bool +iseven(a::ZZRingElemOrPtr) = @ccall libflint.fmpz_is_even(a::Ref{ZZRingElem})::Cint % Bool ############################################################################### # @@ -345,13 +344,13 @@ end function ~(x::ZZRingElem) z = ZZRingElem() - ccall((:fmpz_complement, libflint), Nothing, (Ref{ZZRingElem}, Ref{ZZRingElem}), z, x) + @ccall libflint.fmpz_complement(z::Ref{ZZRingElem}, x::Ref{ZZRingElem})::Nothing return z end function abs(x::ZZRingElem) z = ZZRingElem() - ccall((:fmpz_abs, libflint), Nothing, (Ref{ZZRingElem}, Ref{ZZRingElem}), z, x) + @ccall libflint.fmpz_abs(z::Ref{ZZRingElem}, x::Ref{ZZRingElem})::Nothing return z end @@ -409,8 +408,7 @@ end function Base.div(x::ZZRingElem, y::ZZRingElem) iszero(y) && throw(DivideError()) z = ZZRingElem() - ccall((:fmpz_tdiv_q, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpz_tdiv_q(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Nothing return z end @@ -427,8 +425,7 @@ end function divides(x::ZZRingElem, y::ZZRingElem) z = ZZRingElem() - res = ccall((:fmpz_divides, libflint), Bool, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z, x, y) + res = @ccall libflint.fmpz_divides(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Bool return res, z end @@ -484,7 +481,7 @@ function rem(x::ZZRingElem, c::ZZRingElem) end function rem(a::ZZRingElem, b::UInt) - return ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), a, b) + return @ccall libflint.fmpz_fdiv_ui(a::Ref{ZZRingElem}, b::UInt)::UInt end ############################################################################### @@ -578,56 +575,49 @@ divexact(x::Integer, y::ZZRingElem; check::Bool=true) = divexact(ZZRingElem(x), function tdivpow2(x::ZZRingElem, c::Int) c < 0 && throw(DomainError(c, "Exponent must be non-negative")) z = ZZRingElem() - ccall((:fmpz_tdiv_q_2exp, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, c) + @ccall libflint.fmpz_tdiv_q_2exp(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, c::Int)::Nothing return z end function fdivpow2(x::ZZRingElem, c::Int) c < 0 && throw(DomainError(c, "Exponent must be non-negative")) z = ZZRingElem() - ccall((:fmpz_fdiv_q_2exp, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, c) + @ccall libflint.fmpz_fdiv_q_2exp(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, c::Int)::Nothing return z end function fmodpow2(x::ZZRingElem, c::Int) c < 0 && throw(DomainError(c, "Exponent must be non-negative")) z = ZZRingElem() - ccall((:fmpz_fdiv_r_2exp, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, c) + @ccall libflint.fmpz_fdiv_r_2exp(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, c::Int)::Nothing return z end function cdivpow2(x::ZZRingElem, c::Int) c < 0 && throw(DomainError(c, "Exponent must be non-negative")) z = ZZRingElem() - ccall((:fmpz_cdiv_q_2exp, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, c) + @ccall libflint.fmpz_cdiv_q_2exp(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, c::Int)::Nothing return z end function tdiv(x::ZZRingElem, c::Int) c == 0 && throw(DivideError()) z = ZZRingElem() - ccall((:fmpz_tdiv_q_si, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, c) + @ccall libflint.fmpz_tdiv_q_si(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, c::Int)::Nothing return z end function fdiv(x::ZZRingElem, c::Int) c == 0 && throw(DivideError()) z = ZZRingElem() - ccall((:fmpz_fdiv_q_si, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, c) + @ccall libflint.fmpz_fdiv_q_si(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, c::Int)::Nothing return z end function cdiv(x::ZZRingElem, c::Int) c == 0 && throw(DivideError()) z = ZZRingElem() - ccall((:fmpz_cdiv_q_si, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, c) + @ccall libflint.fmpz_cdiv_q_si(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, c::Int)::Nothing return z end @@ -680,8 +670,7 @@ function tdivrem(x::ZZRingElem, y::ZZRingElem) iszero(y) && throw(DivideError()) z1 = ZZRingElem() z2 = ZZRingElem() - ccall((:fmpz_tdiv_qr, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z1, z2, x, y) + @ccall libflint.fmpz_tdiv_qr(z1::Ref{ZZRingElem}, z2::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Nothing z1, z2 end @@ -689,8 +678,7 @@ function fdivrem(x::ZZRingElem, y::ZZRingElem) iszero(y) && throw(DivideError()) z1 = ZZRingElem() z2 = ZZRingElem() - ccall((:fmpz_fdiv_qr, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z1, z2, x, y) + @ccall libflint.fmpz_fdiv_qr(z1::Ref{ZZRingElem}, z2::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Nothing z1, z2 end @@ -698,8 +686,7 @@ function cdivrem(x::ZZRingElem, y::ZZRingElem) iszero(y) && throw(DivideError()) z1 = ZZRingElem() z2 = ZZRingElem() - ccall((:fmpz_cdiv_qr, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z1, z2, x, y) + @ccall libflint.fmpz_cdiv_qr(z1::Ref{ZZRingElem}, z2::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Nothing z1, z2 end @@ -710,7 +697,7 @@ end function nfdivrem(a::ZZRingElem, b::ZZRingElem) q, r = tdivrem(a, b) - c = ccall((:fmpz_cmp2abs, libflint), Cint, (Ref{ZZRingElem}, Ref{ZZRingElem}), b, r) + c = @ccall libflint.fmpz_cmp2abs(b::Ref{ZZRingElem}, r::Ref{ZZRingElem})::Cint if c <= 0 if sign(Int, b) != sign(Int, r) sub!(q, q, UInt(1)) @@ -725,7 +712,7 @@ end function ncdivrem(a::ZZRingElem, b::ZZRingElem) q, r = tdivrem(a, b) - c = ccall((:fmpz_cmp2abs, libflint), Cint, (Ref{ZZRingElem}, Ref{ZZRingElem}), b, r) + c = @ccall libflint.fmpz_cmp2abs(b::Ref{ZZRingElem}, r::Ref{ZZRingElem})::Cint if c <= 0 if sign(Int, b) == sign(Int, r) add!(q, q, UInt(1)) @@ -742,8 +729,7 @@ function ndivrem(x::ZZRingElem, y::ZZRingElem) iszero(y) && throw(DivideError()) z1 = ZZRingElem() z2 = ZZRingElem() - ccall((:fmpz_ndiv_qr, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z1, z2, x, y) + @ccall libflint.fmpz_ndiv_qr(z1::Ref{ZZRingElem}, z2::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Nothing z1, z2 end @@ -780,8 +766,7 @@ function ^(x::ZZRingElem, y::Union{Int, UInt, ZZRingElem}) deepcopy(x) else z = ZZRingElem() - ccall((:fmpz_pow_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), z, x, UInt(y)) + @ccall libflint.fmpz_pow_ui(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, UInt(y)::UInt)::Nothing z end end @@ -817,8 +802,7 @@ end ############################################################################### function cmp(x::ZZRingElemOrPtr, y::ZZRingElemOrPtr) - Int(ccall((:fmpz_cmp, libflint), Cint, - (Ref{ZZRingElem}, Ref{ZZRingElem}), x, y)) + Int(@ccall libflint.fmpz_cmp(x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Cint) end ==(x::ZZRingElem, y::ZZRingElem) = cmp(x,y) == 0 @@ -828,8 +812,7 @@ end <(x::ZZRingElem, y::ZZRingElem) = cmp(x,y) < 0 function cmpabs(x::ZZRingElemOrPtr, y::ZZRingElemOrPtr) - Int(ccall((:fmpz_cmpabs, libflint), Cint, - (Ref{ZZRingElem}, Ref{ZZRingElem}), x, y)) + Int(@ccall libflint.fmpz_cmpabs(x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Cint) end isless(x::ZZRingElem, y::ZZRingElem) = x < y @@ -855,7 +838,7 @@ end ############################################################################### function cmp(x::ZZRingElemOrPtr, y::Int) - Int(ccall((:fmpz_cmp_si, libflint), Cint, (Ref{ZZRingElem}, Int), x, y)) + Int(@ccall libflint.fmpz_cmp_si(x::Ref{ZZRingElem}, y::Int)::Cint) end ==(x::ZZRingElem, y::Int) = cmp(x,y) == 0 @@ -871,7 +854,7 @@ end <(x::Int, y::ZZRingElem) = cmp(y,x) > 0 function cmp(x::ZZRingElemOrPtr, y::UInt) - Int(ccall((:fmpz_cmp_ui, libflint), Cint, (Ref{ZZRingElem}, UInt), x, y)) + Int(@ccall libflint.fmpz_cmp_ui(x::Ref{ZZRingElem}, y::UInt)::Cint) end ==(x::ZZRingElem, y::UInt) = cmp(x,y) == 0 @@ -932,8 +915,7 @@ function <<(x::ZZRingElem, c::Int) c < 0 && throw(DomainError(c, "Exponent must be non-negative")) c == 0 && return x z = ZZRingElem() - ccall((:fmpz_mul_2exp, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, c) + @ccall libflint.fmpz_mul_2exp(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, c::Int)::Nothing return z end @@ -946,8 +928,7 @@ function >>(x::ZZRingElem, c::Int) c < 0 && throw(DomainError(c, "Exponent must be non-negative")) c == 0 && return x z = ZZRingElem() - ccall((:fmpz_fdiv_q_2exp, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, c) + @ccall libflint.fmpz_fdiv_q_2exp(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, c::Int)::Nothing return z end @@ -958,8 +939,7 @@ end ############################################################################### function mod!(r::ZZRingElem, x::ZZRingElem, y::ZZRingElem) - ccall((:fmpz_fdiv_r, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), r, x, y) + @ccall libflint.fmpz_fdiv_r(r::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Nothing return r end @@ -971,7 +951,7 @@ end function mod(x::ZZRingElem, c::UInt) c == 0 && throw(DivideError()) - ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), x, c) + @ccall libflint.fmpz_fdiv_ui(x::Ref{ZZRingElem}, c::UInt)::UInt end function mod_sym(a::ZZRingElem, b::ZZRingElem) @@ -999,9 +979,7 @@ function powermod(x::ZZRingElem, p::ZZRingElem, m::ZZRingElem) p = -p end r = ZZRingElem() - ccall((:fmpz_powm, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - r, x, p, m) + @ccall libflint.fmpz_powm(r::Ref{ZZRingElem}, x::Ref{ZZRingElem}, p::Ref{ZZRingElem}, m::Ref{ZZRingElem})::Nothing return r end @@ -1017,9 +995,7 @@ function powermod(x::ZZRingElem, p::Int, m::ZZRingElem) p = -p end r = ZZRingElem() - ccall((:fmpz_powm_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int, Ref{ZZRingElem}), - r, x, p, m) + @ccall libflint.fmpz_powm_ui(r::Ref{ZZRingElem}, x::Ref{ZZRingElem}, p::Int, m::Ref{ZZRingElem})::Nothing return r end @@ -1053,8 +1029,7 @@ function invmod(x::ZZRingElem, m::ZZRingElem) if isone(m) return ZZRingElem(0) end - if ccall((:fmpz_invmod, libflint), Cint, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z, x, m) == 0 + if @ccall libflint.fmpz_invmod(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, m::Ref{ZZRingElem})::Cint == 0 error("Impossible inverse in invmod") end return z @@ -1150,9 +1125,7 @@ end # requires a < b function _gcdinv(a::UInt, b::UInt) s = Ref{UInt}() - g = ccall((:n_gcdinv, libflint), UInt, - (Ptr{UInt}, UInt, UInt), - s, a, b) + g = @ccall libflint.n_gcdinv(s::Ptr{UInt}, a::UInt, b::UInt)::UInt return g, s[] end @@ -1232,14 +1205,12 @@ julia> flog(ZZ(12), 3) function flog(x::ZZRingElem, c::ZZRingElem) c <= 0 && throw(DomainError(c, "Base must be non-negative")) x <= 0 && throw(DomainError(x, "Argument must be non-negative")) - return ccall((:fmpz_flog, libflint), Int, - (Ref{ZZRingElem}, Ref{ZZRingElem}), x, c) + return @ccall libflint.fmpz_flog(x::Ref{ZZRingElem}, c::Ref{ZZRingElem})::Int end function flog(x::ZZRingElem, c::Int) c <= 0 && throw(DomainError(c, "Base must be non-negative")) - return ccall((:fmpz_flog_ui, libflint), Int, - (Ref{ZZRingElem}, Int), x, c) + return @ccall libflint.fmpz_flog_ui(x::Ref{ZZRingElem}, c::Int)::Int end @doc raw""" @@ -1262,14 +1233,12 @@ julia> clog(ZZ(12), 3) function clog(x::ZZRingElem, c::ZZRingElem) c <= 0 && throw(DomainError(c, "Base must be non-negative")) x <= 0 && throw(DomainError(x, "Argument must be non-negative")) - return ccall((:fmpz_clog, libflint), Int, - (Ref{ZZRingElem}, Ref{ZZRingElem}), x, c) + return @ccall libflint.fmpz_clog(x::Ref{ZZRingElem}, c::Ref{ZZRingElem})::Int end function clog(x::ZZRingElem, c::Int) c <= 0 && throw(DomainError(c, "Base must be non-negative")) - return ccall((:fmpz_clog_ui, libflint), Int, - (Ref{ZZRingElem}, Int), x, c) + return @ccall libflint.fmpz_clog_ui(x::Ref{ZZRingElem}, c::Int)::Int end ############################################################################### @@ -1400,8 +1369,7 @@ function gcdx(a::ZZRingElem, b::ZZRingElem) d = ZZ() x = ZZ() y = ZZ() - ccall((:fmpz_xgcd_canonical_bezout, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), d, x, y, a, b) + @ccall libflint.fmpz_xgcd_canonical_bezout(d::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem}, a::Ref{ZZRingElem}, b::Ref{ZZRingElem})::Nothing return d, x, y end @@ -1410,9 +1378,7 @@ function gcdinv(a::ZZRingElem, b::ZZRingElem) b < a && throw(DomainError((a, b), "First argument must be smaller than second argument")) g = ZZRingElem() s = ZZRingElem() - ccall((:fmpz_gcdinv, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - g, s, a, b) + @ccall libflint.fmpz_gcdinv(g::Ref{ZZRingElem}, s::Ref{ZZRingElem}, a::Ref{ZZRingElem}, b::Ref{ZZRingElem})::Nothing return g, s end @@ -1449,7 +1415,7 @@ julia> isqrt(ZZ(13)) function isqrt(x::ZZRingElem) is_negative(x) && throw(DomainError(x, "Argument must be non-negative")) z = ZZRingElem() - ccall((:fmpz_sqrt, libflint), Nothing, (Ref{ZZRingElem}, Ref{ZZRingElem}), z, x) + @ccall libflint.fmpz_sqrt(z::Ref{ZZRingElem}, x::Ref{ZZRingElem})::Nothing return z end @@ -1471,8 +1437,7 @@ function isqrtrem(x::ZZRingElem) is_negative(x) && throw(DomainError(x, "Argument must be non-negative")) s = ZZRingElem() r = ZZRingElem() - ccall((:fmpz_sqrtrem, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), s, r, x) + @ccall libflint.fmpz_sqrtrem(s::Ref{ZZRingElem}, r::Ref{ZZRingElem}, x::Ref{ZZRingElem})::Nothing return s, r end @@ -1491,8 +1456,7 @@ function Base.sqrt(x::ZZRingElem; check=true) return s end -is_square(x::ZZRingElem) = Bool(ccall((:fmpz_is_square, libflint), Cint, - (Ref{ZZRingElem},), x)) +is_square(x::ZZRingElem) = Bool(@ccall libflint.fmpz_is_square(x::Ref{ZZRingElem})::Cint) function is_square_with_sqrt(x::ZZRingElem) if is_negative(x) @@ -1530,8 +1494,7 @@ function root(x::ZZRingElem, n::Int; check::Bool=true) x < 0 && iseven(n) && throw(DomainError((x, n), "Argument `x` must be positive if exponent `n` is even")) n <= 0 && throw(DomainError(n, "Exponent must be positive")) z = ZZRingElem() - res = ccall((:fmpz_root, libflint), Bool, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, n) + res = @ccall libflint.fmpz_root(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, n::Int)::Bool check && !res && error("Not a perfect n-th power (n = $n)") return z end @@ -1553,8 +1516,7 @@ function iroot(x::ZZRingElem, n::Int) x < 0 && iseven(n) && throw(DomainError((x, n), "Argument `x` must be positive if exponent `n` is even")) n <= 0 && throw(DomainError(n, "Exponent must be positive")) z = ZZRingElem() - ccall((:fmpz_root, libflint), Bool, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, n) + @ccall libflint.fmpz_root(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, n::Int)::Bool return z end @@ -1581,13 +1543,11 @@ end function _factor_trial_range(N::ZZRingElem, start::Int = 0, np::Int = 10^5) F = fmpz_factor() - ccall((:fmpz_factor_trial_range, libflint), Nothing, - (Ref{fmpz_factor}, Ref{ZZRingElem}, UInt, UInt), F, N, start, np) + @ccall libflint.fmpz_factor_trial_range(F::Ref{fmpz_factor}, N::Ref{ZZRingElem}, start::UInt, np::UInt)::Nothing res = Dict{ZZRingElem, Int}() for i in 1:F.num z = ZZRingElem() - ccall((:fmpz_factor_get_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{fmpz_factor}, Int), z, F, i - 1) + @ccall libflint.fmpz_factor_get_fmpz(z::Ref{ZZRingElem}, F::Ref{fmpz_factor}, (i - 1)::Int)::Nothing res[z] = unsafe_load(F.exp, i) end return res, canonical_unit(N) @@ -1643,7 +1603,7 @@ Return the prime divisors of $a$ in an array. We require $a \neq 0$. """ prime_divisors(a::Int) = Int.(prime_divisors(ZZ(a))) -is_prime(x::UInt) = Bool(ccall((:n_is_prime, libflint), Cint, (UInt,), x)) +is_prime(x::UInt) = Bool(@ccall libflint.n_is_prime(x::UInt)::Cint) @doc raw""" is_prime(x::ZZRingElem) @@ -1660,7 +1620,7 @@ true """ function is_prime(x::ZZRingElem) !is_probable_prime(x) && return false - return Bool(ccall((:fmpz_is_prime, libflint), Cint, (Ref{ZZRingElem},), x)) + return Bool(@ccall libflint.fmpz_is_prime(x::Ref{ZZRingElem})::Cint) end function is_prime(n::Int) @@ -1677,8 +1637,7 @@ Return `true` if $x$ is very probably a prime number, otherwise return `false`. No counterexamples are known to this test, but it is conjectured that infinitely many exist. """ -is_probable_prime(x::ZZRingElem) = Bool(ccall((:fmpz_is_probabprime, libflint), Cint, - (Ref{ZZRingElem},), x)) +is_probable_prime(x::ZZRingElem) = Bool(@ccall libflint.fmpz_is_probabprime(x::Ref{ZZRingElem})::Cint) @doc raw""" next_prime(x::ZZRingElem, proved = true) @@ -1688,9 +1647,7 @@ If a second argument of `false` is specified, the return is only probably prime. """ function next_prime(x::ZZRingElem, proved::Bool = true) z = ZZRingElem() - ccall((:fmpz_nextprime, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Cint), - z, x, proved) + @ccall libflint.fmpz_nextprime(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, proved::Cint)::Nothing return z end @@ -1699,9 +1656,7 @@ function next_prime(x::UInt, proved::Bool = true) (Base.GMP.BITS_PER_LIMB == 32 && x >= 0xfffffffb) error("No larger single-limb prime exists") end - return ccall((:n_nextprime, libflint), UInt, - (UInt, Cint), - x, proved) + return @ccall libflint.n_nextprime(x::UInt, proved::Cint)::UInt end function next_prime(x::Int, proved::Bool = true) @@ -1709,7 +1664,7 @@ function next_prime(x::Int, proved::Bool = true) end function remove!(z::ZZRingElemOrPtr, a::ZZRingElemOrPtr, b::ZZRingElemOrPtr) - v = ccall((:fmpz_remove, libflint), Clong, (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z, a, b) + v = @ccall libflint.fmpz_remove(z::Ref{ZZRingElem}, a::Ref{ZZRingElem}, b::Ref{ZZRingElem})::Clong return Int(v), z end @@ -1730,10 +1685,8 @@ function remove(a::UInt, b::UInt) b <= 1 && error("Factor <= 1") a == 0 && error("Not yet implemented") q = Ref(a) - binv = ccall((:n_precompute_inverse, libflint), Float64, (UInt,), b) - v = ccall((:n_remove2_precomp, libflint), Cint, - (Ptr{UInt}, UInt, Float64), - q, b, binv) + binv = @ccall libflint.n_precompute_inverse(b::UInt)::Float64 + v = @ccall libflint.n_remove2_precomp(q::Ptr{UInt}, b::UInt, binv::Float64)::Cint return (Int(v), q[]) end @@ -1788,8 +1741,7 @@ function divisor_lenstra(n::ZZRingElem, r::ZZRingElem, m::ZZRingElem) m <= r && throw(DomainError((m, r), "Modulus must be bigger than residue class")) n <= m && throw(DomainError((n, m), "Argument must be bigger than modulus")) z = ZZRingElem() - if !Bool(ccall((:fmpz_divisor_in_residue_class_lenstra, libflint), - Cint, (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z, n, r, m)) + if !Bool(@ccall libflint.fmpz_divisor_in_residue_class_lenstra(z::Ref{ZZRingElem}, n::Ref{ZZRingElem}, r::Ref{ZZRingElem}, m::Ref{ZZRingElem})::Cint) z = 0 end return z @@ -1811,7 +1763,7 @@ julia> factorial(ZZ(100)) function factorial(x::ZZRingElem) x < 0 && throw(DomainError(x, "Argument must be non-negative")) z = ZZRingElem() - ccall((:fmpz_fac_ui, libflint), Nothing, (Ref{ZZRingElem}, UInt), z, UInt(x)) + @ccall libflint.fmpz_fac_ui(z::Ref{ZZRingElem}, UInt(x)::UInt)::Nothing return z end @@ -1824,8 +1776,7 @@ If $n < 0$ we throw a `DomainError()`. function rising_factorial(x::ZZRingElem, n::Int) n < 0 && throw(DomainError(n, "Argument must be non-negative")) z = ZZRingElem() - ccall((:fmpz_rfac_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), z, x, UInt(n)) + @ccall libflint.fmpz_rfac_ui(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, UInt(n)::UInt)::Nothing return z end @@ -1850,8 +1801,7 @@ function primorial(x::Int) throw(OverflowError("primorial(::Int)")) end z = ZZRingElem() - ccall((:fmpz_primorial, libflint), Nothing, - (Ref{ZZRingElem}, UInt), z, UInt(x)) + @ccall libflint.fmpz_primorial(z::Ref{ZZRingElem}, UInt(x)::UInt)::Nothing return Int(z) end @@ -1864,8 +1814,7 @@ equal to $x$. If $x < 0$ we throw a `DomainError()`. function primorial(x::ZZRingElem) x < 0 && throw(DomainError(x, "Argument must be non-negative")) z = ZZRingElem() - ccall((:fmpz_primorial, libflint), Nothing, - (Ref{ZZRingElem}, UInt), z, UInt(x)) + @ccall libflint.fmpz_primorial(z::Ref{ZZRingElem}, UInt(x)::UInt)::Nothing return z end @@ -1881,8 +1830,7 @@ function fibonacci(x::Int) throw(OverflowError("fibonacci(::Int)")) end z = ZZRingElem() - ccall((:fmpz_fib_ui, libflint), Nothing, - (Ref{ZZRingElem}, UInt), z, UInt(abs(x))) + @ccall libflint.fmpz_fib_ui(z::Ref{ZZRingElem}, UInt(abs(x))::UInt)::Nothing return x < 0 ? (iseven(x) ? -Int(z) : Int(z)) : Int(z) end @@ -1894,8 +1842,7 @@ $F_{i + 1} = F_i + F_{i - 1}$ for all integers $i$. """ function fibonacci(x::ZZRingElem) z = ZZRingElem() - ccall((:fmpz_fib_ui, libflint), Nothing, - (Ref{ZZRingElem}, UInt), z, UInt(abs(x))) + @ccall libflint.fmpz_fib_ui(z::Ref{ZZRingElem}, UInt(abs(x))::UInt)::Nothing return x < 0 ? (iseven(x) ? -z : z) : z end @@ -1907,8 +1854,7 @@ Return the Bell number $B_x$. function bell(x::Int) x < 0 && throw(DomainError(x, "Argument must be non-negative")) z = ZZRingElem() - ccall((:arith_bell_number, libflint), Nothing, - (Ref{ZZRingElem}, UInt), z, UInt(x)) + @ccall libflint.arith_bell_number(z::Ref{ZZRingElem}, UInt(x)::UInt)::Nothing return Int(z) end @@ -1920,8 +1866,7 @@ Return the Bell number $B_x$. function bell(x::ZZRingElem) x < 0 && throw(DomainError(x, "Argument must be non-negative")) z = ZZRingElem() - ccall((:arith_bell_number, libflint), Nothing, - (Ref{ZZRingElem}, UInt), z, UInt(x)) + @ccall libflint.arith_bell_number(z::Ref{ZZRingElem}, UInt(x)::UInt)::Nothing return z end @@ -1929,8 +1874,7 @@ end # which has silly gnu problems on windows # TODO: fib_ui, pow_ui, fac_ui ditto function _binomial!(z::ZZRingElem, n::Culong, k::Culong) - ccall((:fmpz_bin_uiui, libflint), Nothing, - (Ref{ZZRingElem}, UInt, UInt), z, UInt(n), UInt(k)) + @ccall libflint.fmpz_bin_uiui(z::Ref{ZZRingElem}, UInt(n)::UInt, UInt(k)::UInt)::Nothing return z end @@ -1986,8 +1930,7 @@ Return the binomial coefficient $\frac{n!}{(n - k)!k!}$ as an `ZZRingElem`. """ function binomial(n::UInt, k::UInt, ::ZZRing) z = ZZRingElem() - ccall((:fmpz_bin_uiui, libflint), Nothing, - (Ref{ZZRingElem}, UInt, UInt), z, n, k) + @ccall libflint.fmpz_bin_uiui(z::Ref{ZZRingElem}, n::UInt, k::UInt)::Nothing return z end @@ -1999,8 +1942,7 @@ returned is either $-1$, $0$ or $1$. If $x \leq 0$ we throw a `DomainError()`. """ function moebius_mu(x::ZZRingElem) x <= 0 && throw(DomainError(x, "Argument must be positive")) - return Int(ccall((:fmpz_moebius_mu, libflint), Cint, - (Ref{ZZRingElem},), x)) + return Int(@ccall libflint.fmpz_moebius_mu(x::Ref{ZZRingElem})::Cint) end @doc raw""" @@ -2022,8 +1964,7 @@ function jacobi_symbol(x::ZZRingElem, y::ZZRingElem) if x < 0 || x >= y x = mod(x, y) end - return Int(ccall((:fmpz_jacobi, libflint), Cint, - (Ref{ZZRingElem}, Ref{ZZRingElem}), x, y)) + return Int(@ccall libflint.fmpz_jacobi(x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Cint) end jacobi_symbol(x::IntegerUnion, y::IntegerUnion) = jacobi_symbol(ZZ(x), ZZ(y)) @@ -2039,7 +1980,7 @@ function jacobi_symbol(x::Int, y::Int) if x < 0 || x >= y x = mod(x, y) end - return Int(ccall((:n_jacobi, libflint), Cint, (Int, UInt), x, UInt(y))) + return Int(@ccall libflint.n_jacobi(x::Int, UInt(y)::UInt)::Cint) end @doc raw""" @@ -2051,13 +1992,11 @@ The definition is as per Henri Cohen's book, "A Course in Computational Algebraic Number Theory", Definition 1.4.8. """ function kronecker_symbol(x::Int, y::Int) - return Int(ccall((:z_kronecker, libflint), Cint, - (Int, Int), x, y)) + return Int(@ccall libflint.z_kronecker(x::Int, y::Int)::Cint) end function kronecker_symbol(x::ZZRingElem, y::ZZRingElem) - return Int(ccall((:fmpz_kronecker, libflint), Cint, - (Ref{ZZRingElem}, Ref{ZZRingElem}), x, y)) + return Int(@ccall libflint.fmpz_kronecker(x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Cint) end @doc raw""" @@ -2085,8 +2024,7 @@ function divisor_sigma(x::ZZRingElem, y::Int) x <= 0 && throw(DomainError(x, "Argument must be positive")) y < 0 && throw(DomainError(y, "Power must be non-negative")) z = ZZRingElem() - ccall((:fmpz_divisor_sigma, libflint), Nothing, - (Ref{ZZRingElem}, UInt, Ref{ZZRingElem}), z, UInt(y), x) + @ccall libflint.fmpz_divisor_sigma(z::Ref{ZZRingElem}, UInt(y)::UInt, x::Ref{ZZRingElem})::Nothing return z end @@ -2114,8 +2052,7 @@ julia> euler_phi(12480) function euler_phi(x::ZZRingElem) x <= 0 && throw(DomainError(x, "Argument must be positive")) z = ZZRingElem() - ccall((:fmpz_euler_phi, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}), z, x) + @ccall libflint.fmpz_euler_phi(z::Ref{ZZRingElem}, x::Ref{ZZRingElem})::Nothing return z end @@ -2146,8 +2083,7 @@ function number_of_partitions(x::Int) return 0 end z = ZZRingElem() - ccall((:partitions_fmpz_ui, libflint), Nothing, - (Ref{ZZRingElem}, UInt), z, x) + @ccall libflint.partitions_fmpz_ui(z::Ref{ZZRingElem}, x::UInt)::Nothing return Int(z) end @@ -2156,8 +2092,7 @@ function number_of_partitions(x::ZZRingElem) if x < 0 return z end - ccall((:partitions_fmpz_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, 0) + @ccall libflint.partitions_fmpz_fmpz(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, 0::Int)::Nothing return z end @@ -2237,10 +2172,9 @@ julia> base(ZZ(12), 13) """ function base(n::ZZRingElem, b::Integer) 2 <= b <= 62 || error("invalid base: $b") - p = ccall((:fmpz_get_str,libflint), Ptr{UInt8}, - (Ptr{UInt8}, Cint, Ref{ZZRingElem}), C_NULL, b, n) + p = @ccall libflint.fmpz_get_str(C_NULL::Ptr{UInt8}, b::Cint, n::Ref{ZZRingElem})::Ptr{UInt8} s = unsafe_string(p) - ccall((:flint_free, libflint), Nothing, (Ptr{UInt8},), p) + @ccall libflint.flint_free(p::Ptr{UInt8})::Nothing return s end @@ -2336,8 +2270,7 @@ julia> popcount(ZZ(12)) 2 ``` """ -popcount(x::ZZRingElem) = Int(ccall((:fmpz_popcnt, libflint), UInt, - (Ref{ZZRingElem},), x)) +popcount(x::ZZRingElem) = Int(@ccall libflint.fmpz_popcnt(x::Ref{ZZRingElem})::UInt) @doc raw""" prevpow2(x::ZZRingElem) @@ -2367,8 +2300,7 @@ nextpow2(x::ZZRingElem) = x < 0 ? -nextpow2(-x) : Return the number of trailing zeros in the binary representation of $x$. """ -trailing_zeros(x::ZZRingElem) = ccall((:fmpz_val2, libflint), Int, - (Ref{ZZRingElem},), x) +trailing_zeros(x::ZZRingElem) = @ccall libflint.fmpz_val2(x::Ref{ZZRingElem})::Int ############################################################################### # @@ -2396,7 +2328,7 @@ julia> a """ function clrbit!(x::ZZRingElem, c::Int) c < 0 && throw(DomainError(c, "Second argument must be non-negative")) - ccall((:fmpz_clrbit, libflint), Nothing, (Ref{ZZRingElem}, UInt), x, c) + @ccall libflint.fmpz_clrbit(x::Ref{ZZRingElem}, c::UInt)::Nothing end @doc raw""" @@ -2419,7 +2351,7 @@ julia> a """ function setbit!(x::ZZRingElem, c::Int) c < 0 && throw(DomainError(c, "Second argument must be non-negative")) - ccall((:fmpz_setbit, libflint), Nothing, (Ref{ZZRingElem}, UInt), x, c) + @ccall libflint.fmpz_setbit(x::Ref{ZZRingElem}, c::UInt)::Nothing end @doc raw""" @@ -2442,7 +2374,7 @@ julia> a """ function combit!(x::ZZRingElem, c::Int) c < 0 && throw(DomainError(c, "Second argument must be non-negative")) - ccall((:fmpz_combit, libflint), Nothing, (Ref{ZZRingElem}, UInt), x, c) + @ccall libflint.fmpz_combit(x::Ref{ZZRingElem}, c::UInt)::Nothing end @doc raw""" @@ -2464,9 +2396,7 @@ true ``` """ function tstbit(x::ZZRingElem, c::Int) - return c >= 0 && Bool(ccall((:fmpz_tstbit, libflint), Cint, - (Ref{ZZRingElem}, UInt), - x, c)) + return c >= 0 && Bool(@ccall libflint.fmpz_tstbit(x::Ref{ZZRingElem}, c::UInt)::Cint) end ############################################################################### @@ -2485,9 +2415,7 @@ function one!(z::ZZRingElemOrPtr) end function neg!(z::ZZRingElemOrPtr, a::ZZRingElemOrPtr) - ccall((:fmpz_neg, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}), - z, a) + @ccall libflint.fmpz_neg(z::Ref{ZZRingElem}, a::Ref{ZZRingElem})::Nothing return z end @@ -2509,33 +2437,28 @@ end set!(z::ZZRingElemOrPtr, a::Integer) = set!(z, flintify(a)) function swap!(a::ZZRingElemOrPtr, b::ZZRingElemOrPtr) - ccall((:fmpz_swap, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}), - a, b) + @ccall libflint.fmpz_swap(a::Ref{ZZRingElem}, b::Ref{ZZRingElem})::Nothing end # function add!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::ZZRingElemOrPtr) - ccall((:fmpz_add, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpz_add(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Nothing return z end function add!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::Int) - ccall((:fmpz_add_si, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, y) + @ccall libflint.fmpz_add_si(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Int)::Nothing return z end function add!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::UInt) - ccall((:fmpz_add_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), z, x, y) + @ccall libflint.fmpz_add_ui(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::UInt)::Nothing return z end function add!(a::ZZRingElemOrPtr, b::ZZRingElemOrPtr, c::Ptr{Int}) - ccall((:fmpz_add, libflint), Nothing, (Ref{ZZRingElem}, Ref{ZZRingElem}, Ptr{Int}), a, b, c) + @ccall libflint.fmpz_add(a::Ref{ZZRingElem}, b::Ref{ZZRingElem}, c::Ptr{Int})::Nothing return a end @@ -2545,23 +2468,17 @@ add!(z::ZZRingElemOrPtr, x::Integer, y::ZZRingElemOrPtr) = add!(z, y, x) # function sub!(z::ZZRingElemOrPtr, a::ZZRingElemOrPtr, b::ZZRingElemOrPtr) - ccall((:fmpz_sub, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - z, a, b) + @ccall libflint.fmpz_sub(z::Ref{ZZRingElem}, a::Ref{ZZRingElem}, b::Ref{ZZRingElem})::Nothing return z end function sub!(z::ZZRingElemOrPtr, a::ZZRingElemOrPtr, b::Int) - ccall((:fmpz_sub_si, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), - z, a, b) + @ccall libflint.fmpz_sub_si(z::Ref{ZZRingElem}, a::Ref{ZZRingElem}, b::Int)::Nothing return z end function sub!(z::ZZRingElemOrPtr, a::ZZRingElemOrPtr, b::UInt) - ccall((:fmpz_sub_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), - z, a, b) + @ccall libflint.fmpz_sub_ui(z::Ref{ZZRingElem}, a::Ref{ZZRingElem}, b::UInt)::Nothing return z end @@ -2571,20 +2488,17 @@ sub!(z::ZZRingElemOrPtr, a::Integer, b::ZZRingElemOrPtr) = neg!(sub!(z, b, a)) # function mul!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::ZZRingElemOrPtr) - ccall((:fmpz_mul, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpz_mul(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Nothing return z end function mul!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::Int) - ccall((:fmpz_mul_si, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, y) + @ccall libflint.fmpz_mul_si(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Int)::Nothing return z end function mul!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::UInt) - ccall((:fmpz_mul_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), z, x, y) + @ccall libflint.fmpz_mul_ui(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::UInt)::Nothing return z end @@ -2592,27 +2506,24 @@ mul!(z::ZZRingElemOrPtr, a::ZZRingElemOrPtr, b::Integer) = mul!(z, a, flintify(b mul!(z::ZZRingElemOrPtr, x::Integer, y::ZZRingElemOrPtr) = mul!(z, y, x) function mul!(a::ZZRingElemOrPtr, b::ZZRingElemOrPtr, c::Ptr{Int}) - ccall((:fmpz_mul, libflint), Nothing, (Ref{ZZRingElem}, Ref{ZZRingElem}, Ptr{Int}), a, b, c) + @ccall libflint.fmpz_mul(a::Ref{ZZRingElem}, b::Ref{ZZRingElem}, c::Ptr{Int})::Nothing return a end # function addmul!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::ZZRingElemOrPtr) - ccall((:fmpz_addmul, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpz_addmul(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Nothing return z end function addmul!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::Int) - ccall((:fmpz_addmul_si, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, y) + @ccall libflint.fmpz_addmul_si(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Int)::Nothing return z end function addmul!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::UInt) - ccall((:fmpz_addmul_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), z, x, y) + @ccall libflint.fmpz_addmul_ui(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::UInt)::Nothing return z end @@ -2623,20 +2534,17 @@ addmul!(z::ZZRingElemOrPtr, x::Integer, y::ZZRingElemOrPtr) = addmul!(z, y, x) addmul!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::Union{ZZRingElemOrPtr,Integer}, ::ZZRingElemOrPtr) = addmul!(z, x, y) function submul!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::ZZRingElemOrPtr) - ccall((:fmpz_submul, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpz_submul(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Nothing return z end function submul!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::Int) - ccall((:fmpz_submul_si, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, x, y) + @ccall libflint.fmpz_submul_si(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Int)::Nothing return z end function submul!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::UInt) - ccall((:fmpz_submul_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), z, x, y) + @ccall libflint.fmpz_submul_ui(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::UInt)::Nothing return z end @@ -2651,8 +2559,7 @@ submul!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::Union{ZZRingElemOrPtr,Integer Return $r = a b + c d$, changing $r$ in-place. """ function fmma!(r::ZZRingElemOrPtr, a::ZZRingElemOrPtr, b::ZZRingElemOrPtr, c::ZZRingElemOrPtr, d::ZZRingElemOrPtr) - ccall((:fmpz_fmma, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), r, a, b, c, d) + @ccall libflint.fmpz_fmma(r::Ref{ZZRingElem}, a::Ref{ZZRingElem}, b::Ref{ZZRingElem}, c::Ref{ZZRingElem}, d::Ref{ZZRingElem})::Nothing return r end @@ -2662,8 +2569,7 @@ end Return $r = a b - c d$, changing $r$ in-place. """ function fmms!(r::ZZRingElemOrPtr, a::ZZRingElemOrPtr, b::ZZRingElemOrPtr, c::ZZRingElemOrPtr, d::ZZRingElemOrPtr) - ccall((:fmpz_fmms, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), r, a, b, c, d) + @ccall libflint.fmpz_fmms(r::Ref{ZZRingElem}, a::Ref{ZZRingElem}, b::Ref{ZZRingElem}, c::Ref{ZZRingElem}, d::Ref{ZZRingElem})::Nothing return r end @@ -2689,21 +2595,17 @@ divexact!(z::ZZRingElemOrPtr, a::ZZRingElemOrPtr, b::Integer) = divexact!(z, a, # function pow!(z::ZZRingElemOrPtr, a::ZZRingElemOrPtr, b::Integer) - ccall((:fmpz_pow_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), - z, a, UInt(b)) + @ccall libflint.fmpz_pow_ui(z::Ref{ZZRingElem}, a::Ref{ZZRingElem}, UInt(b)::UInt)::Nothing return z end function lcm!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::ZZRingElemOrPtr) - ccall((:fmpz_lcm, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpz_lcm(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Nothing return z end function gcd!(z::ZZRingElemOrPtr, x::ZZRingElemOrPtr, y::ZZRingElemOrPtr) - ccall((:fmpz_gcd, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpz_gcd(z::Ref{ZZRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Nothing return z end @@ -2761,9 +2663,7 @@ function parse(::Type{ZZRingElem}, s::AbstractString, base::Int = 10) s2 = string(s) end z = ZZRingElem() - err = ccall((:fmpz_set_str, libflint), - Int32, (Ref{ZZRingElem}, Ptr{UInt8}, Int32), - z, s2, base) + err = @ccall libflint.fmpz_set_str(z::Ref{ZZRingElem}, s2::Ptr{UInt8}, base::Int32)::Int32 err == 0 || error("Invalid big integer: $(repr(s))") return sgn < 0 ? -z : z end @@ -2792,8 +2692,7 @@ Return a random signed integer whose absolute value has $b$ bits. function rand_bits(::ZZRing, b::Int) b >= 0 || throw(DomainError(b, "Bit count must be non-negative")) z = ZZRingElem() - ccall((:fmpz_randbits, libflint), Nothing,(Ref{ZZRingElem}, Ref{rand_ctx}, Int), - z, _flint_rand_states[Threads.threadid()], b) + @ccall libflint.fmpz_randbits(z::Ref{ZZRingElem}, _flint_rand_states[Threads.threadid()]::Ref{rand_ctx}, b::Int)::Nothing return z end @@ -2806,9 +2705,7 @@ probable prime is required, one can pass `proved=false`. function rand_bits_prime(::ZZRing, n::Int, proved::Bool = true) n < 2 && throw(DomainError(n, "No primes with that many bits")) z = ZZRingElem() - ccall((:fmpz_randprime, libflint), Nothing, - (Ref{ZZRingElem}, Ref{rand_ctx}, Int, Cint), - z, _flint_rand_states[Threads.threadid()], n, Cint(proved)) + @ccall libflint.fmpz_randprime(z::Ref{ZZRingElem}, _flint_rand_states[Threads.threadid()]::Ref{rand_ctx}, n::Int, Cint(proved)::Cint)::Nothing return z end @@ -2867,7 +2764,7 @@ end function rand(rng::AbstractRNG, sp::SamplerFmpz) z = ZZRingElem() # this make sure z is backed up by an mpz_t object: - ccall((:fmpz_init2, libflint), Nothing, (Ref{ZZRingElem}, UInt), z, sp.nlimbsmax) + @ccall libflint.fmpz_init2(z::Ref{ZZRingElem}, sp.nlimbsmax::UInt)::Nothing @assert !_fmpz_is_small(z) GC.@preserve z begin x = _as_bigint(z) @@ -2917,8 +2814,7 @@ function rand(rng::AbstractRNG, a::ZZRingElemUnitRange) while true s = ZZRingElem(0) for i = 1:nl - ccall((:fmpz_mul_2exp, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), s, s, c) + @ccall libflint.fmpz_mul_2exp(s::Ref{ZZRingElem}, s::Ref{ZZRingElem}, c::Int)::Nothing add!(s, s, rand(rng, Base.GMP.Limb)) end if high > 0 @@ -2979,24 +2875,24 @@ convert(::Type{ZZRingElem}, a::Integer) = ZZRingElem(a) function (::Type{BigInt})(a::ZZRingElem) r = BigInt() - ccall((:fmpz_get_mpz, libflint), Nothing, (Ref{BigInt}, Ref{ZZRingElem}), r, a) + @ccall libflint.fmpz_get_mpz(r::Ref{BigInt}, a::Ref{ZZRingElem})::Nothing return r end function (::Type{Int})(a::ZZRingElem) (a > typemax(Int) || a < typemin(Int)) && throw(InexactError(:convert, Int, a)) - return ccall((:fmpz_get_si, libflint), Int, (Ref{ZZRingElem},), a) + return @ccall libflint.fmpz_get_si(a::Ref{ZZRingElem})::Int end function (::Type{UInt})(a::ZZRingElem) (a > typemax(UInt) || a < 0) && throw(InexactError(:convert, UInt, a)) - return ccall((:fmpz_get_ui, libflint), UInt, (Ref{ZZRingElem}, ), a) + return @ccall libflint.fmpz_get_ui(a::Ref{ZZRingElem})::UInt end if Culong !== UInt function (::Type{Culong})(a::ZZRingElem) fits(Culong, a) || throw(InexactError(:convert, Culong, a)) - return ccall((:fmpz_get_ui, libflint), UInt, (Ref{ZZRingElem}, ), a)%Culong + return @ccall libflint.fmpz_get_ui(a::Ref{ZZRingElem})::UInt%Culong end end @@ -3012,7 +2908,7 @@ convert(::Type{T}, a::ZZRingElem) where T <: Integer = T(a) function (::Type{Float64})(n::ZZRingElem) # rounds to zero - ccall((:fmpz_get_d, libflint), Float64, (Ref{ZZRingElem},), n) + @ccall libflint.fmpz_get_d(n::Ref{ZZRingElem})::Float64 end convert(::Type{Float64}, n::ZZRingElem) = Float64(n) @@ -3043,7 +2939,7 @@ promote_rule(::Type{ZZRingElem}, ::Type{T}) where {T <: Integer} = ZZRingElem # ex is not guaranteed to be maximal function _is_perfect_power(a::ZZRingElem) rt = ZZRingElem() - ex = ccall((:fmpz_is_perfect_power, libflint), Int, (Ref{ZZRingElem}, Ref{ZZRingElem}), rt, a) + ex = @ccall libflint.fmpz_is_perfect_power(rt::Ref{ZZRingElem}, a::Ref{ZZRingElem})::Int return rt, ex end @@ -3293,7 +3189,7 @@ Nemo.bits(a::ZZRingElem) = BitsFmpz(a) #= wrong order, thus disabled function getindex(B::BitsFmpz, i::Int) -return ccall((:fmpz_tstbit, libflint), Int, (Ref{ZZRingElem}, Int), B.L.a, i) != 0 +return @ccall libflint.fmpz_tstbit(B.L.a::Ref{ZZRingElem}, i::Int)::Int != 0 end =# end @@ -3312,8 +3208,6 @@ using .BitsMod # This bypasses the computation of general bounds. function resultant(f::ZZPolyRingElem, g::ZZPolyRingElem, d::ZZRingElem, nb::Int) z = ZZRingElem() - ccall((:fmpz_poly_resultant_modular_div, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZRingElem}, Int), - z, f, g, d, nb) + @ccall libflint.fmpz_poly_resultant_modular_div(z::Ref{ZZRingElem}, f::Ref{ZZPolyRingElem}, g::Ref{ZZPolyRingElem}, d::Ref{ZZRingElem}, nb::Int)::Nothing return z end diff --git a/src/flint/fmpz_abs_series.jl b/src/flint/fmpz_abs_series.jl index 6e2a97ed4..510bcd089 100644 --- a/src/flint/fmpz_abs_series.jl +++ b/src/flint/fmpz_abs_series.jl @@ -42,14 +42,12 @@ max_precision(R::ZZAbsPowerSeriesRing) = R.prec_max function normalise(a::ZZAbsPowerSeriesRingElem, len::Int) if len > 0 c = ZZRingElem() - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), c, a, len - 1) + @ccall libflint.fmpz_poly_get_coeff_fmpz(c::Ref{ZZRingElem}, a::Ref{ZZAbsPowerSeriesRingElem}, (len - 1)::Int)::Nothing end while len > 0 && iszero(c) len -= 1 if len > 0 - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), c, a, len - 1) + @ccall libflint.fmpz_poly_get_coeff_fmpz(c::Ref{ZZRingElem}, a::Ref{ZZAbsPowerSeriesRingElem}, (len - 1)::Int)::Nothing end end @@ -57,7 +55,7 @@ function normalise(a::ZZAbsPowerSeriesRingElem, len::Int) end function length(x::ZZAbsPowerSeriesRingElem) - return ccall((:fmpz_poly_length, libflint), Int, (Ref{ZZAbsPowerSeriesRingElem},), x) + return @ccall libflint.fmpz_poly_length(x::Ref{ZZAbsPowerSeriesRingElem})::Int end precision(x::ZZAbsPowerSeriesRingElem) = x.prec @@ -67,8 +65,7 @@ function coeff(x::ZZAbsPowerSeriesRingElem, n::Int) return ZZRingElem(0) end z = ZZRingElem() - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), z, x, n) + @ccall libflint.fmpz_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{ZZAbsPowerSeriesRingElem}, n::Int)::Nothing return z end @@ -90,8 +87,7 @@ function deepcopy_internal(a::ZZAbsPowerSeriesRingElem, dict::IdDict) end function is_gen(a::ZZAbsPowerSeriesRingElem) - return precision(a) == 0 || ccall((:fmpz_poly_is_gen, libflint), Bool, - (Ref{ZZAbsPowerSeriesRingElem},), a) + return precision(a) == 0 || @ccall libflint.fmpz_poly_is_gen(a::Ref{ZZAbsPowerSeriesRingElem})::Bool end iszero(a::ZZAbsPowerSeriesRingElem) = length(a) == 0 @@ -99,8 +95,7 @@ iszero(a::ZZAbsPowerSeriesRingElem) = length(a) == 0 is_unit(a::ZZAbsPowerSeriesRingElem) = valuation(a) == 0 && is_unit(coeff(a, 0)) function isone(a::ZZAbsPowerSeriesRingElem) - return precision(a) == 0 || ccall((:fmpz_poly_is_one, libflint), Bool, - (Ref{ZZAbsPowerSeriesRingElem},), a) + return precision(a) == 0 || @ccall libflint.fmpz_poly_is_one(a::Ref{ZZAbsPowerSeriesRingElem})::Bool end # todo: write an fmpz_poly_valuation @@ -173,9 +168,7 @@ end function -(x::ZZAbsPowerSeriesRingElem) z = parent(x)() - ccall((:fmpz_poly_neg, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}), - z, x) + @ccall libflint.fmpz_poly_neg(z::Ref{ZZAbsPowerSeriesRingElem}, x::Ref{ZZAbsPowerSeriesRingElem})::Nothing z.prec = x.prec return z end @@ -199,9 +192,7 @@ function +(a::ZZAbsPowerSeriesRingElem, b::ZZAbsPowerSeriesRingElem) lenz = max(lena, lenb) z = parent(a)() z.prec = prec - ccall((:fmpz_poly_add_series, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpz_poly_add_series(z::Ref{ZZAbsPowerSeriesRingElem}, a::Ref{ZZAbsPowerSeriesRingElem}, b::Ref{ZZAbsPowerSeriesRingElem}, lenz::Int)::Nothing return z end @@ -218,9 +209,7 @@ function -(a::ZZAbsPowerSeriesRingElem, b::ZZAbsPowerSeriesRingElem) lenz = max(lena, lenb) z = parent(a)() z.prec = prec - ccall((:fmpz_poly_sub_series, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpz_poly_sub_series(z::Ref{ZZAbsPowerSeriesRingElem}, a::Ref{ZZAbsPowerSeriesRingElem}, b::Ref{ZZAbsPowerSeriesRingElem}, lenz::Int)::Nothing return z end @@ -247,9 +236,7 @@ function *(a::ZZAbsPowerSeriesRingElem, b::ZZAbsPowerSeriesRingElem) lenz = min(lena + lenb - 1, prec) - ccall((:fmpz_poly_mullow, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpz_poly_mullow(z::Ref{ZZAbsPowerSeriesRingElem}, a::Ref{ZZAbsPowerSeriesRingElem}, b::Ref{ZZAbsPowerSeriesRingElem}, lenz::Int)::Nothing return z end @@ -262,9 +249,7 @@ end function *(x::Int, y::ZZAbsPowerSeriesRingElem) z = parent(y)() z.prec = y.prec - ccall((:fmpz_poly_scalar_mul_si, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - z, y, x) + @ccall libflint.fmpz_poly_scalar_mul_si(z::Ref{ZZAbsPowerSeriesRingElem}, y::Ref{ZZAbsPowerSeriesRingElem}, x::Int)::Nothing return z end @@ -273,9 +258,7 @@ end function *(x::ZZRingElem, y::ZZAbsPowerSeriesRingElem) z = parent(y)() z.prec = y.prec - ccall((:fmpz_poly_scalar_mul_fmpz, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZRingElem}), - z, y, x) + @ccall libflint.fmpz_poly_scalar_mul_fmpz(z::Ref{ZZAbsPowerSeriesRingElem}, y::Ref{ZZAbsPowerSeriesRingElem}, x::Ref{ZZRingElem})::Nothing return z end @@ -298,12 +281,8 @@ function shift_left(x::ZZAbsPowerSeriesRingElem, len::Int) z.prec = x.prec + len z.prec = min(z.prec, max_precision(parent(x))) zlen = min(z.prec, xlen + len) - ccall((:fmpz_poly_shift_left, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - z, x, len) - ccall((:fmpz_poly_set_trunc, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - z, z, zlen) + @ccall libflint.fmpz_poly_shift_left(z::Ref{ZZAbsPowerSeriesRingElem}, x::Ref{ZZAbsPowerSeriesRingElem}, len::Int)::Nothing + @ccall libflint.fmpz_poly_set_trunc(z::Ref{ZZAbsPowerSeriesRingElem}, z::Ref{ZZAbsPowerSeriesRingElem}, zlen::Int)::Nothing return z end @@ -315,9 +294,7 @@ function shift_right(x::ZZAbsPowerSeriesRingElem, len::Int) z.prec = max(0, x.prec - len) else z.prec = x.prec - len - ccall((:fmpz_poly_shift_right, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - z, x, len) + @ccall libflint.fmpz_poly_shift_right(z::Ref{ZZAbsPowerSeriesRingElem}, x::Ref{ZZAbsPowerSeriesRingElem}, len::Int)::Nothing end return z end @@ -337,9 +314,7 @@ function truncate!(x::ZZAbsPowerSeriesRingElem, k::Int) if precision(x) <= k return x end - ccall((:fmpz_poly_truncate, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Int), - x, k) + @ccall libflint.fmpz_poly_truncate(x::Ref{ZZAbsPowerSeriesRingElem}, k::Int)::Nothing x.prec = k return x end @@ -364,9 +339,7 @@ function ^(a::ZZAbsPowerSeriesRingElem, b::Int) z = parent(a)() z.prec = a.prec + (b - 1)*valuation(a) z.prec = min(z.prec, max_precision(parent(a))) - ccall((:fmpz_poly_pow_trunc, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int, Int), - z, a, b, z.prec) + @ccall libflint.fmpz_poly_pow_trunc(z::Ref{ZZAbsPowerSeriesRingElem}, a::Ref{ZZAbsPowerSeriesRingElem}, b::Int, z.prec::Int)::Nothing end return z end @@ -384,9 +357,7 @@ function ==(x::ZZAbsPowerSeriesRingElem, y::ZZAbsPowerSeriesRingElem) n = max(length(x), length(y)) n = min(n, prec) - return Bool(ccall((:fmpz_poly_equal_trunc, libflint), Cint, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - x, y, n)) + return Bool(@ccall libflint.fmpz_poly_equal_trunc(x::Ref{ZZAbsPowerSeriesRingElem}, y::Ref{ZZAbsPowerSeriesRingElem}, n::Int)::Cint) end function isequal(x::ZZAbsPowerSeriesRingElem, y::ZZAbsPowerSeriesRingElem) @@ -396,9 +367,7 @@ function isequal(x::ZZAbsPowerSeriesRingElem, y::ZZAbsPowerSeriesRingElem) if x.prec != y.prec || length(x) != length(y) return false end - return Bool(ccall((:fmpz_poly_equal, libflint), Cint, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}), - x, y)) + return Bool(@ccall libflint.fmpz_poly_equal(x::Ref{ZZAbsPowerSeriesRingElem}, y::Ref{ZZAbsPowerSeriesRingElem})::Cint) end ############################################################################### @@ -412,10 +381,8 @@ function ==(x::ZZAbsPowerSeriesRingElem, y::ZZRingElem) return false elseif length(x) == 1 z = ZZRingElem() - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), z, x, 0) - return ccall((:fmpz_equal, libflint), Bool, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, y, 0) + @ccall libflint.fmpz_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{ZZAbsPowerSeriesRingElem}, 0::Int)::Nothing + return @ccall libflint.fmpz_equal(z::Ref{ZZRingElem}, y::Ref{ZZRingElem}, 0::Int)::Bool else return precision(x) == 0 || iszero(y) end @@ -448,9 +415,7 @@ function divexact(x::ZZAbsPowerSeriesRingElem, y::ZZAbsPowerSeriesRingElem; chec prec = min(x.prec, y.prec - v2 + v1) z = parent(x)() z.prec = prec - ccall((:fmpz_poly_div_series, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - z, x, y, prec) + @ccall libflint.fmpz_poly_div_series(z::Ref{ZZAbsPowerSeriesRingElem}, x::Ref{ZZAbsPowerSeriesRingElem}, y::Ref{ZZAbsPowerSeriesRingElem}, prec::Int)::Nothing return z end @@ -464,9 +429,7 @@ function divexact(x::ZZAbsPowerSeriesRingElem, y::Int; check::Bool=true) y == 0 && throw(DivideError()) z = parent(x)() z.prec = x.prec - ccall((:fmpz_poly_scalar_divexact_si, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - z, x, y) + @ccall libflint.fmpz_poly_scalar_divexact_si(z::Ref{ZZAbsPowerSeriesRingElem}, x::Ref{ZZAbsPowerSeriesRingElem}, y::Int)::Nothing return z end @@ -474,9 +437,7 @@ function divexact(x::ZZAbsPowerSeriesRingElem, y::ZZRingElem; check::Bool=true) iszero(y) && throw(DivideError()) z = parent(x)() z.prec = x.prec - ccall((:fmpz_poly_scalar_divexact_fmpz, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZRingElem}), - z, x, y) + @ccall libflint.fmpz_poly_scalar_divexact_fmpz(z::Ref{ZZAbsPowerSeriesRingElem}, x::Ref{ZZAbsPowerSeriesRingElem}, y::Ref{ZZRingElem})::Nothing return z end @@ -493,9 +454,7 @@ function inv(a::ZZAbsPowerSeriesRingElem) !is_unit(a) && error("Unable to invert power series") ainv = parent(a)() ainv.prec = a.prec - ccall((:fmpz_poly_inv_series, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - ainv, a, a.prec) + @ccall libflint.fmpz_poly_inv_series(ainv::Ref{ZZAbsPowerSeriesRingElem}, a::Ref{ZZAbsPowerSeriesRingElem}, a.prec::Int)::Nothing return ainv end @@ -509,9 +468,7 @@ function Base.sqrt(a::ZZAbsPowerSeriesRingElem; check::Bool=true) asqrt = parent(a)() v = valuation(a) asqrt.prec = a.prec - div(v, 2) - flag = Bool(ccall((:fmpz_poly_sqrt_series, libflint), Cint, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - asqrt, a, a.prec)) + flag = Bool(@ccall libflint.fmpz_poly_sqrt_series(asqrt::Ref{ZZAbsPowerSeriesRingElem}, a::Ref{ZZAbsPowerSeriesRingElem}, a.prec::Int)::Cint) check && !flag && error("Not a square") return asqrt end @@ -523,29 +480,24 @@ end ############################################################################### function zero!(z::ZZAbsPowerSeriesRingElem) - ccall((:fmpz_poly_zero, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem},), z) + @ccall libflint.fmpz_poly_zero(z::Ref{ZZAbsPowerSeriesRingElem})::Nothing z.prec = parent(z).prec_max return z end function one!(z::ZZAbsPowerSeriesRingElem) - ccall((:fmpz_poly_one, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem},), z) + @ccall libflint.fmpz_poly_one(z::Ref{ZZAbsPowerSeriesRingElem})::Nothing z.prec = parent(z).prec_max return z end function fit!(z::ZZAbsPowerSeriesRingElem, n::Int) - ccall((:fmpz_poly_fit_length, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Int), z, n) + @ccall libflint.fmpz_poly_fit_length(z::Ref{ZZAbsPowerSeriesRingElem}, n::Int)::Nothing return nothing end function setcoeff!(z::ZZAbsPowerSeriesRingElem, n::Int, x::ZZRingElem) - ccall((:fmpz_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Int, Ref{ZZRingElem}), - z, n, x) + @ccall libflint.fmpz_poly_set_coeff_fmpz(z::Ref{ZZAbsPowerSeriesRingElem}, n::Int, x::Ref{ZZRingElem})::Nothing return z end @@ -568,9 +520,7 @@ function mul!(z::ZZAbsPowerSeriesRingElem, a::ZZAbsPowerSeriesRingElem, b::ZZAbs end z.prec = prec - ccall((:fmpz_poly_mullow, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpz_poly_mullow(z::Ref{ZZAbsPowerSeriesRingElem}, a::Ref{ZZAbsPowerSeriesRingElem}, b::Ref{ZZAbsPowerSeriesRingElem}, lenz::Int)::Nothing return z end @@ -585,15 +535,12 @@ function add!(c::ZZAbsPowerSeriesRingElem, a::ZZAbsPowerSeriesRingElem, b::ZZAbs lenc = max(lena, lenb) c.prec = prec - ccall((:fmpz_poly_add_series, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Ref{ZZAbsPowerSeriesRingElem}, Int), - c, a, b, lenc) + @ccall libflint.fmpz_poly_add_series(c::Ref{ZZAbsPowerSeriesRingElem}, a::Ref{ZZAbsPowerSeriesRingElem}, b::Ref{ZZAbsPowerSeriesRingElem}, lenc::Int)::Nothing return c end function set_length!(a::ZZAbsPowerSeriesRingElem, n::Int) - ccall((:_fmpz_poly_set_length, libflint), Nothing, - (Ref{ZZAbsPowerSeriesRingElem}, Int), a, n) + @ccall libflint._fmpz_poly_set_length(a::Ref{ZZAbsPowerSeriesRingElem}, n::Int)::Nothing return a end diff --git a/src/flint/fmpz_factor.jl b/src/flint/fmpz_factor.jl index e446c44c4..88347866f 100644 --- a/src/flint/fmpz_factor.jl +++ b/src/flint/fmpz_factor.jl @@ -7,12 +7,11 @@ # raw fmpz_factor version function _factor(a::ZZRingElem) F = fmpz_factor() - ccall((:fmpz_factor, libflint), Nothing, (Ref{fmpz_factor}, Ref{ZZRingElem}), F, a) + @ccall libflint.fmpz_factor(F::Ref{fmpz_factor}, a::Ref{ZZRingElem})::Nothing res = Dict{ZZRingElem, Int}() for i in 1:F.num z = ZZRingElem() - ccall((:fmpz_factor_get_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{fmpz_factor}, Int), z, F, i - 1) + @ccall libflint.fmpz_factor_get_fmpz(z::Ref{ZZRingElem}, F::Ref{fmpz_factor}, (i - 1)::Int)::Nothing res[z] = unsafe_load(F.exp, i) end return res, canonical_unit(a) @@ -23,7 +22,7 @@ function factor(a::T) where T <: Union{Int, UInt} u = sign(a) a = u < 0 ? -a : a F = n_factor() - ccall((:n_factor, libflint), Nothing, (Ref{n_factor}, UInt), F, a) + @ccall libflint.n_factor(F::Ref{n_factor}, a::UInt)::Nothing res = Dict{T, Int}() for i in 1:F.num z = F.p[i] @@ -41,9 +40,7 @@ end function _ecm(a::ZZRingElem, B1::UInt, B2::UInt, ncrv::UInt, rnd = _flint_rand_states[Threads.threadid()]) f = ZZRingElem() - r = ccall((:fmpz_factor_ecm, libflint), Int32, - (Ref{ZZRingElem}, UInt, UInt, UInt, Ref{rand_ctx}, Ref{ZZRingElem}), - f, ncrv, B1, B2, rnd, a) + r = @ccall libflint.fmpz_factor_ecm(f::Ref{ZZRingElem}, ncrv::UInt, B1::UInt, B2::UInt, rnd::Ref{rand_ctx}, a::Ref{ZZRingElem})::Int32 return r, f end @@ -184,12 +181,11 @@ end function factor_trial_range(N::ZZRingElem, start::Int=0, np::Int=10^5) F = fmpz_factor() - ccall((:fmpz_factor_trial_range, libflint), Nothing, (Ref{fmpz_factor}, Ref{ZZRingElem}, UInt, UInt), F, N, start, np) + @ccall libflint.fmpz_factor_trial_range(F::Ref{fmpz_factor}, N::Ref{ZZRingElem}, start::UInt, np::UInt)::Nothing res = Dict{ZZRingElem,Int}() for i in 1:F.num z = ZZRingElem() - ccall((:fmpz_factor_get_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{fmpz_factor}, Int), z, F, i - 1) + @ccall libflint.fmpz_factor_get_fmpz(z::Ref{ZZRingElem}, F::Ref{fmpz_factor}, (i - 1)::Int)::Nothing res[z] = unsafe_load(F.exp, i) end return res, canonical_unit(N) diff --git a/src/flint/fmpz_laurent_series.jl b/src/flint/fmpz_laurent_series.jl index c87da2c3b..7430aa82b 100644 --- a/src/flint/fmpz_laurent_series.jl +++ b/src/flint/fmpz_laurent_series.jl @@ -124,8 +124,7 @@ function polcoeff(a::ZZLaurentSeriesRingElem, n::Int) return ZZRingElem(0) end z = ZZRingElem() - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZLaurentSeriesRingElem}, Int), z, a, n) + @ccall libflint.fmpz_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, a::Ref{ZZLaurentSeriesRingElem}, n::Int)::Nothing return z end @@ -511,9 +510,7 @@ function *(a::ZZLaurentSeriesRingElem, b::ZZLaurentSeriesRingElem) lenb = pol_length(b) lenz = div(prec + sz - 1, sz) z = parent(a)() - ccall((:fmpz_poly_mullow, libflint), Nothing, - (Ref{ZZLaurentSeriesRingElem}, Ref{ZZLaurentSeriesRingElem}, Ref{ZZLaurentSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpz_poly_mullow(z::Ref{ZZLaurentSeriesRingElem}, a::Ref{ZZLaurentSeriesRingElem}, b::Ref{ZZLaurentSeriesRingElem}, lenz::Int)::Nothing z = set_precision!(z, prec + zval) z = set_valuation!(z, zval) z = set_scale!(z, sz) @@ -626,9 +623,7 @@ function mullow(a::ZZLaurentSeriesRingElem, b::ZZLaurentSeriesRingElem, n::Int) prec = min(precision(a), precision(b)) z = parent(a)() lenz = min(lena + lenb - 1, div(n + s - 1, s)) - ccall((:fmpz_poly_mullow, libflint), Nothing, - (Ref{ZZLaurentSeriesRingElem}, Ref{ZZLaurentSeriesRingElem}, Ref{ZZLaurentSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpz_poly_mullow(z::Ref{ZZLaurentSeriesRingElem}, a::Ref{ZZLaurentSeriesRingElem}, b::Ref{ZZLaurentSeriesRingElem}, lenz::Int)::Nothing z = set_precision!(z, prec) z = set_valuation!(z, valuation(a) + valuation(b)) z = set_scale!(z, s) @@ -867,9 +862,7 @@ function divexact(a::ZZLaurentSeriesRingElem, b::ZZLaurentSeriesRingElem; check: lenb = pol_length(b) lenz = div(prec + sz - 1, sz) z = parent(a)() - ccall((:fmpz_poly_div_series, libflint), Nothing, - (Ref{ZZLaurentSeriesRingElem}, Ref{ZZLaurentSeriesRingElem}, Ref{ZZLaurentSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpz_poly_div_series(z::Ref{ZZLaurentSeriesRingElem}, a::Ref{ZZLaurentSeriesRingElem}, b::Ref{ZZLaurentSeriesRingElem}, lenz::Int)::Nothing z = set_precision!(z, prec + zval) z = set_valuation!(z, zval) z = set_scale!(z, sz) @@ -926,9 +919,7 @@ function inv(a::ZZLaurentSeriesRingElem) ainv = set_scale!(ainv, sa) !is_unit(a1) && error("Unable to invert power series") z = parent(a)() - ccall((:fmpz_poly_inv_series, libflint), Nothing, - (Ref{ZZLaurentSeriesRingElem}, Ref{ZZLaurentSeriesRingElem}, Int), - ainv, a, lenz) + @ccall libflint.fmpz_poly_inv_series(ainv::Ref{ZZLaurentSeriesRingElem}, a::Ref{ZZLaurentSeriesRingElem}, lenz::Int)::Nothing ainv = rescale!(ainv) return ainv end @@ -958,9 +949,7 @@ function sqrt(a::ZZLaurentSeriesRingElem; check::Bool=true) zlen = div(prec + s - 1, s) asqrt = set_precision!(asqrt, prec + aval2) asqrt = set_valuation!(asqrt, aval2) - flag = Bool(ccall((:fmpz_poly_sqrt_series, libflint), Cint, - (Ref{ZZLaurentSeriesRingElem}, Ref{ZZLaurentSeriesRingElem}, Int), - asqrt, a, zlen)) + flag = Bool(@ccall libflint.fmpz_poly_sqrt_series(asqrt::Ref{ZZLaurentSeriesRingElem}, a::Ref{ZZLaurentSeriesRingElem}, zlen::Int)::Cint) check && flag == false && error("Not a square in sqrt") asqrt = set_scale!(asqrt, s) asqrt = rescale!(asqrt) @@ -1027,8 +1016,7 @@ end ############################################################################### function zero!(a::ZZLaurentSeriesRingElem) - ccall((:fmpz_poly_zero, libflint), Nothing, - (Ref{ZZLaurentSeriesRingElem},), a) + @ccall libflint.fmpz_poly_zero(a::Ref{ZZLaurentSeriesRingElem})::Nothing a = set_precision!(a, parent(a).prec_max) a = set_valuation!(a, parent(a).prec_max) a = set_scale!(a, 1) @@ -1036,9 +1024,7 @@ function zero!(a::ZZLaurentSeriesRingElem) end function setcoeff!(c::ZZLaurentSeriesRingElem, n::Int, a::ZZRingElem) - ccall((:fmpz_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZLaurentSeriesRingElem}, Int, Ref{ZZRingElem}), - c, n, a) + @ccall libflint.fmpz_poly_set_coeff_fmpz(c::Ref{ZZLaurentSeriesRingElem}, n::Int, a::Ref{ZZRingElem})::Nothing return c end @@ -1062,8 +1048,7 @@ function mul!(c::ZZLaurentSeriesRingElem, a::ZZLaurentSeriesRingElem, b::ZZLaure lena = min(lena*sa, prec) lenb = min(lenb*sb, prec) if lena == 0 || lenb == 0 - ccall((:fmpz_poly_zero, libflint), Nothing, - (Ref{ZZLaurentSeriesRingElem},), c) + @ccall libflint.fmpz_poly_zero(c::Ref{ZZLaurentSeriesRingElem})::Nothing c = set_precision!(c, prec + aval + bval) c = set_valuation!(c, aval + bval) c = set_scale!(c, 1) @@ -1077,8 +1062,7 @@ function mul!(c::ZZLaurentSeriesRingElem, a::ZZLaurentSeriesRingElem, b::ZZLaure lena = pol_length(a) lenb = pol_length(b) lenc = min(lena + lenb - 1, div(prec + sz - 1, sz)) - ccall((:fmpz_poly_mullow, libflint), Nothing, - (Ref{ZZLaurentSeriesRingElem}, Ref{ZZLaurentSeriesRingElem}, Ref{ZZLaurentSeriesRingElem}, Int), c, a, b, lenc) + @ccall libflint.fmpz_poly_mullow(c::Ref{ZZLaurentSeriesRingElem}, a::Ref{ZZLaurentSeriesRingElem}, b::Ref{ZZLaurentSeriesRingElem}, lenc::Int)::Nothing end c = set_valuation!(c, aval + bval) c = set_precision!(c, prec + c.val) diff --git a/src/flint/fmpz_mat.jl b/src/flint/fmpz_mat.jl index ce5e8e791..67d3d61bf 100644 --- a/src/flint/fmpz_mat.jl +++ b/src/flint/fmpz_mat.jl @@ -58,9 +58,7 @@ function Base.view(x::ZZMatrix, r1::Int, c1::Int, r2::Int, c2::Int) b = ZZMatrix() b.view_parent = x - ccall((:fmpz_mat_window_init, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Int, Int, Int, Int), - b, x, r1 - 1, c1 - 1, r2, c2) + @ccall libflint.fmpz_mat_window_init(b::Ref{ZZMatrix}, x::Ref{ZZMatrix}, (r1 - 1)::Int, (c1 - 1)::Int, r2::Int, c2::Int)::Nothing finalizer(_fmpz_mat_window_clear_fn, b) return b end @@ -71,9 +69,7 @@ function Base.reshape(x::ZZMatrix, r::Int, c::Int) b = ZZMatrix() b.view_parent = x - ccall((:fmpz_mat_window_init, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Int, Int, Int, Int), - b, x, 0, 0, r, c) + @ccall libflint.fmpz_mat_window_init(b::Ref{ZZMatrix}, x::Ref{ZZMatrix}, 0::Int, 0::Int, r::Int, c::Int)::Nothing finalizer(_fmpz_mat_window_clear_fn, b) return b end @@ -84,7 +80,7 @@ function Base.view(x::ZZMatrix, r::UnitRange{Int}, c::UnitRange{Int}) end function _fmpz_mat_window_clear_fn(a::ZZMatrix) - ccall((:fmpz_mat_window_clear, libflint), Nothing, (Ref{ZZMatrix},), a) + @ccall libflint.fmpz_mat_window_clear(a::Ref{ZZMatrix})::Nothing end function sub(x::ZZMatrix, r1::Int, c1::Int, r2::Int, c2::Int) @@ -132,19 +128,16 @@ function setindex!(a::ZZMatrix, b::ZZMatrix, r::UnitRange{Int64}, c::UnitRange{I _checkbounds(a, r, c) size(b) == (length(r), length(c)) || throw(DimensionMismatch("tried to assign a $(size(b, 1))x$(size(b, 2)) matrix to a $(length(r))x$(length(c)) destination")) A = view(a, r, c) - ccall((:fmpz_mat_set, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}), A, b) + @ccall libflint.fmpz_mat_set(A::Ref{ZZMatrix}, b::Ref{ZZMatrix})::Nothing end @inline number_of_rows(a::ZZMatrix) = a.r @inline number_of_columns(a::ZZMatrix) = a.c -iszero(a::ZZMatrix) = ccall((:fmpz_mat_is_zero, libflint), Bool, - (Ref{ZZMatrix},), a) +iszero(a::ZZMatrix) = @ccall libflint.fmpz_mat_is_zero(a::Ref{ZZMatrix})::Bool -isone(a::ZZMatrix) = ccall((:fmpz_mat_is_one, libflint), Bool, - (Ref{ZZMatrix},), a) +isone(a::ZZMatrix) = @ccall libflint.fmpz_mat_is_one(a::Ref{ZZMatrix})::Bool @inline function is_zero_entry(A::ZZMatrix, i::Int, j::Int) @boundscheck _checkbounds(A, i, j) @@ -217,14 +210,12 @@ end function transpose(x::ZZMatrix) z = similar(x, ncols(x), nrows(x)) - ccall((:fmpz_mat_transpose, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}), z, x) + @ccall libflint.fmpz_mat_transpose(z::Ref{ZZMatrix}, x::Ref{ZZMatrix})::Nothing return z end function transpose!(A::ZZMatrix, B::ZZMatrix) - ccall((:fmpz_mat_transpose, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}), A, B) + @ccall libflint.fmpz_mat_transpose(A::Ref{ZZMatrix}, B::Ref{ZZMatrix})::Nothing return A end @@ -235,8 +226,7 @@ end ############################################################################### function swap_rows!(x::ZZMatrix, i::Int, j::Int) - ccall((:fmpz_mat_swap_rows, libflint), Nothing, - (Ref{ZZMatrix}, Ptr{Nothing}, Int, Int), x, C_NULL, i - 1, j - 1) + @ccall libflint.fmpz_mat_swap_rows(x::Ref{ZZMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int)::Nothing return x end @@ -247,8 +237,7 @@ function swap_rows(x::ZZMatrix, i::Int, j::Int) end function swap_cols!(x::ZZMatrix, i::Int, j::Int) - ccall((:fmpz_mat_swap_cols, libflint), Nothing, - (Ref{ZZMatrix}, Ptr{Nothing}, Int, Int), x, C_NULL, i - 1, j - 1) + @ccall libflint.fmpz_mat_swap_cols(x::Ref{ZZMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int)::Nothing return x end @@ -259,16 +248,14 @@ function swap_cols(x::ZZMatrix, i::Int, j::Int) end function reverse_rows!(x::ZZMatrix) - ccall((:fmpz_mat_invert_rows, libflint), Nothing, - (Ref{ZZMatrix}, Ptr{Nothing}), x, C_NULL) + @ccall libflint.fmpz_mat_invert_rows(x::Ref{ZZMatrix}, C_NULL::Ptr{Nothing})::Nothing return x end reverse_rows(x::ZZMatrix) = reverse_rows!(deepcopy(x)) function reverse_cols!(x::ZZMatrix) - ccall((:fmpz_mat_invert_cols, libflint), Nothing, - (Ref{ZZMatrix}, Ptr{Nothing}), x, C_NULL) + @ccall libflint.fmpz_mat_invert_cols(x::Ref{ZZMatrix}, C_NULL::Ptr{Nothing})::Nothing return x end @@ -358,9 +345,7 @@ Return $2^yx$. function <<(x::ZZMatrix, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = similar(x) - ccall((:fmpz_mat_scalar_mul_2exp, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Int), - z, x, y) + @ccall libflint.fmpz_mat_scalar_mul_2exp(z::Ref{ZZMatrix}, x::Ref{ZZMatrix}, y::Int)::Nothing return z end @@ -372,9 +357,7 @@ Return $x/2^y$ where rounding is towards zero. function >>(x::ZZMatrix, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = similar(x) - ccall((:fmpz_mat_scalar_tdiv_q_2exp, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Int), - z, x, y) + @ccall libflint.fmpz_mat_scalar_tdiv_q_2exp(z::Ref{ZZMatrix}, x::Ref{ZZMatrix}, y::Int)::Nothing return z end @@ -388,9 +371,7 @@ function ^(x::ZZMatrix, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) nrows(x) != ncols(x) && error("Incompatible matrix dimensions") z = similar(x) - ccall((:fmpz_mat_pow, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Int), - z, x, y) + @ccall libflint.fmpz_mat_pow(z::Ref{ZZMatrix}, x::Ref{ZZMatrix}, y::Int)::Nothing return z end @@ -402,8 +383,7 @@ end function ==(x::ZZMatrix, y::ZZMatrix) b = check_parent(x, y, false) - b && ccall((:fmpz_mat_equal, libflint), Bool, - (Ref{ZZMatrix}, Ref{ZZMatrix}), x, y) + b && @ccall libflint.fmpz_mat_equal(x::Ref{ZZMatrix}, y::Ref{ZZMatrix})::Bool end isequal(x::ZZMatrix, y::ZZMatrix) = ==(x, y) @@ -440,7 +420,7 @@ end function compare_index(A::ZZMatrix, i::Int, j::Int, b::ZZRingElem) GC.@preserve A begin a = mat_entry_ptr(A, i, j) - return ccall((:fmpz_cmp, libflint), Cint, (Ptr{ZZRingElem}, Ref{ZZRingElem}), a, b) + return @ccall libflint.fmpz_cmp(a::Ptr{ZZRingElem}, b::Ref{ZZRingElem})::Cint end end @@ -454,8 +434,7 @@ function inv(x::ZZMatrix) !is_square(x) && error("Matrix not invertible") z = similar(x) d = ZZRingElem() - ccall((:fmpz_mat_inv, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZRingElem}, Ref{ZZMatrix}), z, d, x) + @ccall libflint.fmpz_mat_inv(z::Ref{ZZMatrix}, d::Ref{ZZRingElem}, x::Ref{ZZMatrix})::Nothing if isone(d) return z end @@ -491,8 +470,7 @@ julia> B, d = pseudo_inv(A) function pseudo_inv(x::ZZMatrix) z = similar(x) d = ZZRingElem() - ccall((:fmpz_mat_inv, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZRingElem}, Ref{ZZMatrix}), z, d, x) + @ccall libflint.fmpz_mat_inv(z::Ref{ZZMatrix}, d::Ref{ZZRingElem}, x::Ref{ZZMatrix})::Nothing if !iszero(d) return (z, d) end @@ -518,8 +496,7 @@ end function divexact(x::ZZMatrix, y::Int; check::Bool=true) z = similar(x) - ccall((:fmpz_mat_scalar_divexact_si, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Int), z, x, y) + @ccall libflint.fmpz_mat_scalar_divexact_si(z::Ref{ZZMatrix}, x::Ref{ZZMatrix}, y::Int)::Nothing return z end @@ -528,8 +505,7 @@ divexact(x::ZZMatrix, y::ZZRingElem; check::Bool=true) = divexact!(similar(x), x divexact(x::ZZMatrix, y::Integer; check::Bool=true) = divexact(x, ZZRingElem(y); check=check) function divexact!(a::ZZMatrix, b::ZZMatrix, d::ZZRingElem) - ccall((:fmpz_mat_scalar_divexact_fmpz, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZRingElem}), a, b, d) + @ccall libflint.fmpz_mat_scalar_divexact_fmpz(a::Ref{ZZMatrix}, b::Ref{ZZMatrix}, d::Ref{ZZRingElem})::Nothing return a end @@ -541,8 +517,7 @@ end function kronecker_product(x::ZZMatrix, y::ZZMatrix) z = similar(x, nrows(x)*nrows(y), ncols(x)*ncols(y)) - ccall((:fmpz_mat_kronecker_product, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZMatrix}), z, x, y) + @ccall libflint.fmpz_mat_kronecker_product(z::Ref{ZZMatrix}, x::Ref{ZZMatrix}, y::Ref{ZZMatrix})::Nothing return z end @@ -559,8 +534,7 @@ Reduce the entries of $x$ modulo $y$ and return the result. """ function reduce_mod(x::ZZMatrix, y::ZZRingElem) z = similar(x) - ccall((:fmpz_mat_scalar_mod_fmpz, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpz_mat_scalar_mod_fmpz(z::Ref{ZZMatrix}, x::Ref{ZZMatrix}, y::Ref{ZZRingElem})::Nothing return z end @@ -582,7 +556,7 @@ function mod!(M::ZZMatrix, p::ZZRingElem) for i = 1:nrows(M) for j = 1:ncols(M) z = mat_entry_ptr(M, i, j) - ccall((:fmpz_mod, libflint), Nothing, (Ptr{ZZRingElem}, Ptr{ZZRingElem}, Ref{ZZRingElem}), z, z, p) + @ccall libflint.fmpz_mod(z::Ptr{ZZRingElem}, z::Ptr{ZZRingElem}, p::Ref{ZZRingElem})::Nothing end end end @@ -607,7 +581,7 @@ Reduces every entry modulo $p$ in-place, into the symmetric residue system. """ function mod_sym!(M::ZZMatrix, B::ZZRingElem) @assert !iszero(B) - ccall((:fmpz_mat_scalar_smod, libflint), Nothing, (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZRingElem}), M, M, B) + @ccall libflint.fmpz_mat_scalar_smod(M::Ref{ZZMatrix}, M::Ref{ZZMatrix}, B::Ref{ZZRingElem})::Nothing end mod_sym!(M::ZZMatrix, B::Integer) = mod_sym!(M, ZZRingElem(B)) @@ -618,7 +592,7 @@ Reduces every entry modulo $p$ into the symmetric residue system. """ function mod_sym(M::ZZMatrix, B::ZZRingElem) N = zero_matrix(ZZ, nrows(M), ncols(M)) - ccall((:fmpz_mat_scalar_smod, libflint), Nothing, (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZRingElem}), N, M, B) + @ccall libflint.fmpz_mat_scalar_smod(N::Ref{ZZMatrix}, M::Ref{ZZMatrix}, B::Ref{ZZRingElem})::Nothing return N end mod_sym(M::ZZMatrix, B::Integer) = mod_sym(M, ZZRingElem(B)) @@ -639,9 +613,7 @@ function fflu(x::ZZMatrix, P = SymmetricGroup(nrows(x))) p.d .-= 1 - r = ccall((:fmpz_mat_fflu, libflint), Int, - (Ref{ZZMatrix}, Ref{ZZRingElem}, Ptr{Int}, Ref{ZZMatrix}, Int), - U, d, p.d, x, 0) + r = @ccall libflint.fmpz_mat_fflu(U::Ref{ZZMatrix}, d::Ref{ZZRingElem}, p.d::Ptr{Int}, x::Ref{ZZMatrix}, 0::Int)::Int p.d .+= 1 @@ -678,8 +650,7 @@ end function charpoly(R::ZZPolyRing, x::ZZMatrix) nrows(x) != ncols(x) && error("Non-square") z = R() - ccall((:fmpz_mat_charpoly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZMatrix}), z, x) + @ccall libflint.fmpz_mat_charpoly(z::Ref{ZZPolyRingElem}, x::Ref{ZZMatrix})::Nothing return z end @@ -692,8 +663,7 @@ end function minpoly(R::ZZPolyRing, x::ZZMatrix) nrows(x) != ncols(x) && error("Non-square") z = R() - ccall((:fmpz_mat_minpoly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZMatrix}), z, x) + @ccall libflint.fmpz_mat_minpoly(z::Ref{ZZPolyRingElem}, x::Ref{ZZMatrix})::Nothing return z end @@ -706,8 +676,7 @@ end function det(x::ZZMatrix) nrows(x) != ncols(x) && error("Non-square matrix") z = ZZRingElem() - ccall((:fmpz_mat_det, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZMatrix}), z, x) + @ccall libflint.fmpz_mat_det(z::Ref{ZZRingElem}, x::Ref{ZZMatrix})::Nothing return z end @@ -720,8 +689,7 @@ is nonzero, otherwise return zero. function det_divisor(x::ZZMatrix) nrows(x) != ncols(x) && error("Non-square matrix") z = ZZRingElem() - ccall((:fmpz_mat_det_divisor, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZMatrix}), z, x) + @ccall libflint.fmpz_mat_det_divisor(z::Ref{ZZRingElem}, x::Ref{ZZMatrix})::Nothing return z end @@ -735,8 +703,7 @@ otherwise a heuristic algorithm is used. function det_given_divisor(x::ZZMatrix, d::ZZRingElem, proved=true) nrows(x) != ncols(x) && error("Non-square") z = ZZRingElem() - ccall((:fmpz_mat_det_modular_given_divisor, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZMatrix}, Ref{ZZRingElem}, Cint), z, x, d, proved) + @ccall libflint.fmpz_mat_det_modular_given_divisor(z::Ref{ZZRingElem}, x::Ref{ZZMatrix}, d::Ref{ZZRingElem}, proved::Cint)::Nothing return z end @@ -809,12 +776,12 @@ function maximum(f::typeof(abs), a::ZZMatrix) for i = 1:nrows(a) for j = 1:ncols(a) z = mat_entry_ptr(a, i, j) - if ccall((:fmpz_cmpabs, libflint), Cint, (Ptr{ZZRingElem}, Ptr{ZZRingElem}), m, z) < 0 + if @ccall libflint.fmpz_cmpabs(m::Ptr{ZZRingElem}, z::Ptr{ZZRingElem})::Cint < 0 m = z end end end - ccall((:fmpz_abs, libflint), Nothing, (Ref{ZZRingElem}, Ptr{ZZRingElem}), r, m) + @ccall libflint.fmpz_abs(r::Ref{ZZRingElem}, m::Ptr{ZZRingElem})::Nothing end return r end @@ -826,7 +793,7 @@ function maximum(a::ZZMatrix) for i = 1:nrows(a) for j = 1:ncols(a) z = mat_entry_ptr(a, i, j) - if ccall((:fmpz_cmp, libflint), Cint, (Ptr{ZZRingElem}, Ptr{ZZRingElem}), m, z) < 0 + if @ccall libflint.fmpz_cmp(m::Ptr{ZZRingElem}, z::Ptr{ZZRingElem})::Cint < 0 m = z end end @@ -843,7 +810,7 @@ function minimum(a::ZZMatrix) for i = 1:nrows(a) for j = 1:ncols(a) z = mat_entry_ptr(a, i, j) - if ccall((:fmpz_cmp, libflint), Cint, (Ptr{ZZRingElem}, Ptr{ZZRingElem}), m, z) > 0 + if @ccall libflint.fmpz_cmp(m::Ptr{ZZRingElem}, z::Ptr{ZZRingElem})::Cint > 0 m = z end end @@ -861,8 +828,7 @@ end function gram(x::ZZMatrix) z = similar(x, nrows(x), nrows(x)) - ccall((:fmpz_mat_gram, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}), z, x) + @ccall libflint.fmpz_mat_gram(z::Ref{ZZMatrix}, x::Ref{ZZMatrix})::Nothing return z end @@ -881,8 +847,7 @@ columns must be equal. function hadamard(R::ZZMatrixSpace) nrows(R) != ncols(R) && error("Unable to create Hadamard matrix") z = R() - success = ccall((:fmpz_mat_hadamard, libflint), Bool, - (Ref{ZZMatrix},), z) + success = @ccall libflint.fmpz_mat_hadamard(z::Ref{ZZMatrix})::Bool !success && error("Unable to create Hadamard matrix") return z end @@ -893,8 +858,7 @@ end Return `true` if the given matrix is Hadamard, otherwise return `false`. """ function is_hadamard(x::ZZMatrix) - return ccall((:fmpz_mat_is_hadamard, libflint), Bool, - (Ref{ZZMatrix},), x) + return @ccall libflint.fmpz_mat_is_hadamard(x::Ref{ZZMatrix})::Bool end ############################################################################### @@ -918,19 +882,18 @@ Return the Hermite Normal Form of $x$. function __hnf(x) z = similar(x) - ccall((:fmpz_mat_hnf, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}), z, x) + @ccall libflint.fmpz_mat_hnf(z::Ref{ZZMatrix}, x::Ref{ZZMatrix})::Nothing return z end function hnf!(x::ZZMatrix) if nrows(x) * ncols(x) > 100 z = hnf(x) - ccall((:fmpz_mat_set, libflint), Nothing, (Ref{ZZMatrix}, Ref{ZZMatrix}), x, z) + @ccall libflint.fmpz_mat_set(x::Ref{ZZMatrix}, z::Ref{ZZMatrix})::Nothing return x end - ccall((:fmpz_mat_hnf, libflint), Nothing, (Ref{ZZMatrix}, Ref{ZZMatrix}), x, x) + @ccall libflint.fmpz_mat_hnf(x::Ref{ZZMatrix}, x::Ref{ZZMatrix})::Nothing return x end @@ -947,8 +910,7 @@ is a transformation matrix so that $H = Tx$. function __hnf_with_transform(x::ZZMatrix) z = similar(x) u = similar(x, nrows(x), nrows(x)) - ccall((:fmpz_mat_hnf_transform, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZMatrix}), z, u, x) + @ccall libflint.fmpz_mat_hnf_transform(z::Ref{ZZMatrix}, u::Ref{ZZMatrix}, x::Ref{ZZMatrix})::Nothing return z, u end @@ -960,8 +922,7 @@ determinant of the nonzero rows of $x$. """ function hnf_modular(x::ZZMatrix, d::ZZRingElem) z = similar(x) - ccall((:fmpz_mat_hnf_modular, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZRingElem}), z, x, d) + @ccall libflint.fmpz_mat_hnf_modular(z::Ref{ZZMatrix}, x::Ref{ZZMatrix}, d::Ref{ZZRingElem})::Nothing return z end @@ -975,8 +936,7 @@ function hnf_modular_eldiv(x::ZZMatrix, d::ZZRingElem) (nrows(x) < ncols(x)) && error("Matrix must have at least as many rows as columns") z = deepcopy(x) - ccall((:fmpz_mat_hnf_modular_eldiv, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZRingElem}), z, d) + @ccall libflint.fmpz_mat_hnf_modular_eldiv(z::Ref{ZZMatrix}, d::Ref{ZZRingElem})::Nothing return z end @@ -987,8 +947,7 @@ Return `true` if the given matrix is in Hermite Normal Form, otherwise return `false`. """ function is_hnf(x::ZZMatrix) - return ccall((:fmpz_mat_is_in_hnf, libflint), Bool, - (Ref{ZZMatrix},), x) + return @ccall libflint.fmpz_mat_is_in_hnf(x::Ref{ZZMatrix})::Bool end ############################################################################### @@ -1029,8 +988,7 @@ function lll_with_transform(x::ZZMatrix, ctx::LLLContext = LLLContext(0.99, 0.51 for i in 1:nrows(u) u[i, i] = 1 end - ccall((:fmpz_lll, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{LLLContext}), z, u, ctx) + @ccall libflint.fmpz_lll(z::Ref{ZZMatrix}, u::Ref{ZZMatrix}, ctx::Ref{LLLContext})::Nothing return z, u end @@ -1068,8 +1026,7 @@ function lll!(x::ZZMatrix, ctx::LLLContext = LLLContext(0.99, 0.51)) if nrows(x) == 0 return x end - ccall((:fmpz_lll, libflint), Nothing, - (Ref{ZZMatrix}, Ptr{nothing}, Ref{LLLContext}), x, C_NULL, ctx) + @ccall libflint.fmpz_lll(x::Ref{ZZMatrix}, C_NULL::Ptr{nothing}, ctx::Ref{LLLContext})::Nothing return x end @@ -1090,8 +1047,7 @@ function lll_gram_with_transform(x::ZZMatrix, ctx::LLLContext = LLLContext(0.99, for i in 1:nrows(u) u[i, i] = 1 end - ccall((:fmpz_lll, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{LLLContext}), z, u, ctx) + @ccall libflint.fmpz_lll(z::Ref{ZZMatrix}, u::Ref{ZZMatrix}, ctx::Ref{LLLContext})::Nothing return z, u end @@ -1123,8 +1079,7 @@ $\eta = 0.51$. These defaults can be overridden by specifying an optional contex object. """ function lll_gram!(x::ZZMatrix, ctx::LLLContext = LLLContext(0.99, 0.51, :gram)) - ccall((:fmpz_lll, libflint), Nothing, - (Ref{ZZMatrix}, Ptr{Nothing}, Ref{LLLContext}), x, C_NULL, ctx) + @ccall libflint.fmpz_lll(x::Ref{ZZMatrix}, C_NULL::Ptr{Nothing}, ctx::Ref{LLLContext})::Nothing return x end @@ -1141,8 +1096,7 @@ function lll_with_removal_transform(x::ZZMatrix, b::ZZRingElem, ctx::LLLContext for i in 1:nrows(u) u[i, i] = 1 end - d = Int(ccall((:fmpz_lll_with_removal, libflint), Cint, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZRingElem}, Ref{LLLContext}), z, u, b, ctx)) + d = Int(@ccall libflint.fmpz_lll_with_removal(z::Ref{ZZMatrix}, u::Ref{ZZMatrix}, b::Ref{ZZRingElem}, ctx::Ref{LLLContext})::Cint) return d, z, u end @@ -1155,8 +1109,7 @@ are the rows remaining after removal. """ function lll_with_removal(x::ZZMatrix, b::ZZRingElem, ctx::LLLContext = LLLContext(0.99, 0.51)) z = deepcopy(x) - d = Int(ccall((:fmpz_lll_with_removal, libflint), Cint, - (Ref{ZZMatrix}, Ptr{Nothing}, Ref{ZZRingElem}, Ref{LLLContext}), z, C_NULL, b, ctx)) + d = Int(@ccall libflint.fmpz_lll_with_removal(z::Ref{ZZMatrix}, C_NULL::Ptr{Nothing}, b::Ref{ZZRingElem}, ctx::Ref{LLLContext})::Cint) return d, z end @@ -1195,8 +1148,7 @@ $\mathbb{Q}$. function nullspace_right_rational(x::ZZMatrix) z = similar(x) u = similar(x, ncols(x), ncols(x)) - rank = ccall((:fmpz_mat_nullspace, libflint), Int, - (Ref{ZZMatrix}, Ref{ZZMatrix}), u, x) + rank = @ccall libflint.fmpz_mat_nullspace(u::Ref{ZZMatrix}, x::Ref{ZZMatrix})::Int return rank, u end @@ -1207,8 +1159,7 @@ end ############################################################################### function rank(x::ZZMatrix) - return ccall((:fmpz_mat_rank, libflint), Int, - (Ref{ZZMatrix},), x) + return @ccall libflint.fmpz_mat_rank(x::Ref{ZZMatrix})::Int end ############################################################################### @@ -1220,8 +1171,7 @@ end function rref(x::ZZMatrix) z = similar(x) d = ZZRingElem() - r = ccall((:fmpz_mat_rref, libflint), Int, - (Ref{ZZMatrix}, Ref{ZZRingElem}, Ref{ZZMatrix}), z, d, x) + r = @ccall libflint.fmpz_mat_rref(z::Ref{ZZMatrix}, d::Ref{ZZRingElem}, x::Ref{ZZMatrix})::Int return r, z, d end @@ -1238,8 +1188,7 @@ Compute the Smith normal form of $x$. """ function snf(x::ZZMatrix) z = similar(x) - ccall((:fmpz_mat_snf, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}), z, x) + @ccall libflint.fmpz_mat_snf(z::Ref{ZZMatrix}, x::Ref{ZZMatrix})::Nothing return z end @@ -1250,8 +1199,7 @@ Given a diagonal matrix $x$ compute the Smith normal form of $x$. """ function snf_diagonal(x::ZZMatrix) z = similar(x) - ccall((:fmpz_mat_snf_diagonal, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}), z, x) + @ccall libflint.fmpz_mat_snf_diagonal(z::Ref{ZZMatrix}, x::Ref{ZZMatrix})::Nothing return z end @@ -1261,8 +1209,7 @@ end Return `true` if $x$ is in Smith normal form, otherwise return `false`. """ function is_snf(x::ZZMatrix) - return ccall((:fmpz_mat_is_in_snf, libflint), Bool, - (Ref{ZZMatrix},), x) + return @ccall libflint.fmpz_mat_is_in_snf(x::Ref{ZZMatrix})::Bool end ################################################################################ @@ -1579,8 +1526,7 @@ function _solve_rational(a::ZZMatrix, b::ZZMatrix) nrows(b) != nrows(a) && error("Incompatible dimensions in _solve_rational") z = similar(b) d = ZZRingElem() - nonsing = ccall((:fmpz_mat_solve, libflint), Bool, - (Ref{ZZMatrix}, Ref{ZZRingElem}, Ref{ZZMatrix}, Ref{ZZMatrix}), z, d, a, b) + nonsing = @ccall libflint.fmpz_mat_solve(z::Ref{ZZMatrix}, d::Ref{ZZRingElem}, a::Ref{ZZMatrix}, b::Ref{ZZMatrix})::Bool !nonsing && error("Singular matrix in _solve_rational") return z, d end @@ -1602,8 +1548,7 @@ function _solve_dixon(a::ZZMatrix, b::ZZMatrix) nrows(b) != nrows(a) && error("Incompatible dimensions in solve") z = similar(b) d = ZZRingElem() - nonsing = ccall((:fmpz_mat_solve_dixon, libflint), Bool, - (Ref{ZZMatrix}, Ref{ZZRingElem}, Ref{ZZMatrix}, Ref{ZZMatrix}), z, d, a, b) + nonsing = @ccall libflint.fmpz_mat_solve_dixon(z::Ref{ZZMatrix}, d::Ref{ZZRingElem}, a::Ref{ZZMatrix}, b::Ref{ZZMatrix})::Bool !nonsing && error("Singular matrix in solve") return z, d end @@ -1731,8 +1676,7 @@ end function tr(x::ZZMatrix) nrows(x) != ncols(x) && error("Not a square matrix in trace") d = ZZRingElem() - ccall((:fmpz_mat_trace, libflint), Int, - (Ref{ZZRingElem}, Ref{ZZMatrix}), d, x) + @ccall libflint.fmpz_mat_trace(d::Ref{ZZRingElem}, x::Ref{ZZMatrix})::Int return d end @@ -1744,8 +1688,7 @@ end function content(x::ZZMatrix) d = ZZRingElem() - ccall((:fmpz_mat_content, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZMatrix}), d, x) + @ccall libflint.fmpz_mat_content(d::Ref{ZZRingElem}, x::Ref{ZZMatrix})::Nothing return d end @@ -1758,16 +1701,14 @@ end function hcat(a::ZZMatrix, b::ZZMatrix) nrows(a) != nrows(b) && error("Incompatible number of rows in hcat") c = similar(a, nrows(a), ncols(a) + ncols(b)) - ccall((:fmpz_mat_concat_horizontal, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZMatrix}), c, a, b) + @ccall libflint.fmpz_mat_concat_horizontal(c::Ref{ZZMatrix}, a::Ref{ZZMatrix}, b::Ref{ZZMatrix})::Nothing return c end function vcat(a::ZZMatrix, b::ZZMatrix) ncols(a) != ncols(b) && error("Incompatible number of columns in vcat") c = similar(a, nrows(a) + nrows(b), ncols(a)) - ccall((:fmpz_mat_concat_vertical, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZMatrix}), c, a, b) + @ccall libflint.fmpz_mat_concat_vertical(c::Ref{ZZMatrix}, a::Ref{ZZMatrix}, b::Ref{ZZMatrix})::Nothing return c end @@ -1778,55 +1719,47 @@ end ############################################################################### function zero!(z::ZZMatrixOrPtr) - ccall((:fmpz_mat_zero, libflint), Nothing, - (Ref{ZZMatrix},), z) + @ccall libflint.fmpz_mat_zero(z::Ref{ZZMatrix})::Nothing return z end function one!(z::ZZMatrixOrPtr) - ccall((:fmpz_mat_one, libflint), Nothing, - (Ref{ZZMatrix},), z) + @ccall libflint.fmpz_mat_one(z::Ref{ZZMatrix})::Nothing return z end function neg!(z::ZZMatrixOrPtr, w::ZZMatrixOrPtr) - ccall((:fmpz_mat_neg, libflint), Nothing, (Ref{ZZMatrix}, Ref{ZZMatrix}), z, w) + @ccall libflint.fmpz_mat_neg(z::Ref{ZZMatrix}, w::Ref{ZZMatrix})::Nothing return z end function add!(z::ZZMatrixOrPtr, x::ZZMatrixOrPtr, y::ZZMatrixOrPtr) - ccall((:fmpz_mat_add, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZMatrix}), z, x, y) + @ccall libflint.fmpz_mat_add(z::Ref{ZZMatrix}, x::Ref{ZZMatrix}, y::Ref{ZZMatrix})::Nothing return z end function sub!(z::ZZMatrixOrPtr, x::ZZMatrixOrPtr, y::ZZMatrixOrPtr) - ccall((:fmpz_mat_sub, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZMatrix}), z, x, y) + @ccall libflint.fmpz_mat_sub(z::Ref{ZZMatrix}, x::Ref{ZZMatrix}, y::Ref{ZZMatrix})::Nothing return z end function mul!(z::ZZMatrixOrPtr, x::ZZMatrixOrPtr, y::ZZMatrixOrPtr) - ccall((:fmpz_mat_mul, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZMatrix}), z, x, y) + @ccall libflint.fmpz_mat_mul(z::Ref{ZZMatrix}, x::Ref{ZZMatrix}, y::Ref{ZZMatrix})::Nothing return z end function mul!(z::ZZMatrixOrPtr, a::ZZMatrixOrPtr, b::Int) - ccall((:fmpz_mat_scalar_mul_si, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Int), z, a, b) + @ccall libflint.fmpz_mat_scalar_mul_si(z::Ref{ZZMatrix}, a::Ref{ZZMatrix}, b::Int)::Nothing return z end function mul!(z::ZZMatrixOrPtr, a::ZZMatrixOrPtr, b::UInt) - ccall((:fmpz_mat_scalar_mul_ui, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, UInt), z, a, b) + @ccall libflint.fmpz_mat_scalar_mul_ui(z::Ref{ZZMatrix}, a::Ref{ZZMatrix}, b::UInt)::Nothing return z end function mul!(z::ZZMatrixOrPtr, a::ZZMatrixOrPtr, b::ZZRingElemOrPtr) - ccall((:fmpz_mat_scalar_mul_fmpz, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZRingElem}), z, a, b) + @ccall libflint.fmpz_mat_scalar_mul_fmpz(z::Ref{ZZMatrix}, a::Ref{ZZMatrix}, b::Ref{ZZRingElem})::Nothing return z end @@ -1834,20 +1767,17 @@ mul!(z::ZZMatrixOrPtr, a::ZZMatrixOrPtr, b::Integer) = mul!(z, a, flintify(b)) mul!(z::ZZMatrixOrPtr, a::IntegerUnionOrPtr, b::ZZMatrixOrPtr) = mul!(z, b, a) function addmul!(z::ZZMatrixOrPtr, a::ZZMatrixOrPtr, b::ZZRingElemOrPtr) - ccall((:fmpz_mat_scalar_addmul_fmpz, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZRingElem}), z, a, b) + @ccall libflint.fmpz_mat_scalar_addmul_fmpz(z::Ref{ZZMatrix}, a::Ref{ZZMatrix}, b::Ref{ZZRingElem})::Nothing return z end function addmul!(z::ZZMatrixOrPtr, a::ZZMatrixOrPtr, b::Int) - ccall((:fmpz_mat_scalar_addmul_si, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, Int), z, a, b) + @ccall libflint.fmpz_mat_scalar_addmul_si(z::Ref{ZZMatrix}, a::Ref{ZZMatrix}, b::Int)::Nothing return z end function addmul!(z::ZZMatrixOrPtr, a::ZZMatrixOrPtr, b::UInt) - ccall((:fmpz_mat_scalar_addmul_ui, libflint), Nothing, - (Ref{ZZMatrix}, Ref{ZZMatrix}, UInt), z, a, b) + @ccall libflint.fmpz_mat_scalar_addmul_ui(z::Ref{ZZMatrix}, a::Ref{ZZMatrix}, b::UInt)::Nothing return z end @@ -1855,16 +1785,12 @@ addmul!(z::ZZMatrixOrPtr, a::ZZMatrixOrPtr, b::Integer) = addmul!(z, a, flintify addmul!(z::ZZMatrixOrPtr, a::IntegerUnionOrPtr, b::ZZMatrixOrPtr) = addmul!(z, b, a) function mul!(z::Vector{ZZRingElem}, a::ZZMatrixOrPtr, b::Vector{ZZRingElem}) - ccall((:fmpz_mat_mul_fmpz_vec_ptr, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ref{ZZMatrix}, Ptr{Ref{ZZRingElem}}, Int), - z, a, b, length(b)) + @ccall libflint.fmpz_mat_mul_fmpz_vec_ptr(z::Ptr{Ref{ZZRingElem}}, a::Ref{ZZMatrix}, b::Ptr{Ref{ZZRingElem}}, length(b)::Int)::Nothing return z end function mul!(z::Vector{ZZRingElem}, a::Vector{ZZRingElem}, b::ZZMatrixOrPtr) - ccall((:fmpz_mat_fmpz_vec_mul_ptr, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ptr{Ref{ZZRingElem}}, Int, Ref{ZZMatrix}), - z, a, length(a), b) + @ccall libflint.fmpz_mat_fmpz_vec_mul_ptr(z::Ptr{Ref{ZZRingElem}}, a::Ptr{Ref{ZZRingElem}}, length(a)::Int, b::Ref{ZZMatrix})::Nothing return z end @@ -1883,9 +1809,9 @@ function shift!(g::ZZMatrix, l::Int) for j = 1:ncols(g) z = mat_entry_ptr(g, i, j) if l > 0 - ccall((:fmpz_mul_2exp, libflint), Nothing, (Ptr{ZZRingElem}, Ptr{ZZRingElem}, Int), z, z, l) + @ccall libflint.fmpz_mul_2exp(z::Ptr{ZZRingElem}, z::Ptr{ZZRingElem}, l::Int)::Nothing else - ccall((:fmpz_tdiv_q_2exp, libflint), Nothing, (Ptr{ZZRingElem}, Ptr{ZZRingElem}, Int), z, z, -l) + @ccall libflint.fmpz_tdiv_q_2exp(z::Ptr{ZZRingElem}, z::Ptr{ZZRingElem}, (-l)::Int)::Nothing end end end @@ -1957,15 +1883,13 @@ end function map_entries(R::zzModRing, M::ZZMatrix) MR = zero_matrix(R, nrows(M), ncols(M)) - ccall((:fmpz_mat_get_nmod_mat, libflint), Nothing, - (Ref{zzModMatrix}, Ref{ZZMatrix}), MR, M) + @ccall libflint.fmpz_mat_get_nmod_mat(MR::Ref{zzModMatrix}, M::Ref{ZZMatrix})::Nothing return MR end function map_entries(F::fpField, M::ZZMatrix) MR = zero_matrix(F, nrows(M), ncols(M)) - ccall((:fmpz_mat_get_nmod_mat, libflint), Nothing, - (Ref{fpMatrix}, Ref{ZZMatrix}), MR, M) + @ccall libflint.fmpz_mat_get_nmod_mat(MR::Ref{fpMatrix}, M::Ref{ZZMatrix})::Nothing return MR end @@ -1976,8 +1900,7 @@ function map_entries(R::ZZModRing, M::ZZMatrix) for j = 1:ncols(M) m = mat_entry_ptr(M, i, j) n = mat_entry_ptr(N, i, j) - ccall((:fmpz_mod, libflint), Nothing, - (Ptr{ZZRingElem}, Ptr{ZZRingElem}, Ref{ZZRingElem}), n, m, R.n) + @ccall libflint.fmpz_mod(n::Ptr{ZZRingElem}, m::Ptr{ZZRingElem}, R.n::Ref{ZZRingElem})::Nothing end end end diff --git a/src/flint/fmpz_mod.jl b/src/flint/fmpz_mod.jl index 936b36747..4dbada723 100644 --- a/src/flint/fmpz_mod.jl +++ b/src/flint/fmpz_mod.jl @@ -65,9 +65,7 @@ characteristic(R::ZZModRing) = modulus(R) function _reduce(a::ZZRingElem, ctx::fmpz_mod_ctx_struct) b = ZZRingElem() - ccall((:fmpz_mod_set_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - b, a, ctx) + @ccall libflint.fmpz_mod_set_fmpz(b::Ref{ZZRingElem}, a::Ref{ZZRingElem}, ctx::Ref{fmpz_mod_ctx_struct})::Nothing return b end @@ -171,8 +169,7 @@ function *(x::ZZModRingElem, y::ZZModRingElem) check_parent(x, y) R = parent(x) d = ZZRingElem() - ccall((:fmpz_mod_mul, libflint), Nothing, (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - d, x.data, y.data, R.ninv) + @ccall libflint.fmpz_mod_mul(d::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, y.data::Ref{ZZRingElem}, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return ZZModRingElem(d, R) end @@ -210,9 +207,7 @@ function ^(x::ZZModRingElem, y::Int) y = -y end d = ZZRingElem() - ccall((:fmpz_mod_pow_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt, Ref{fmpz_mod_ctx_struct}), - d, x.data, y, R.ninv) + @ccall libflint.fmpz_mod_pow_ui(d::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, y::UInt, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return ZZModRingElem(d, R) end @@ -256,9 +251,7 @@ function inv(x::ZZModRingElem) end s = ZZRingElem() g = ZZRingElem() - ccall((:fmpz_gcdinv, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - g, s, x.data, R.n) + @ccall libflint.fmpz_gcdinv(g::Ref{ZZRingElem}, s::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, R.n::Ref{ZZRingElem})::Nothing g != 1 && error("Impossible inverse in ", R) return ZZModRingElem(s, R) end @@ -364,17 +357,13 @@ end function mul!(z::ZZModRingElem, x::ZZModRingElem, y::ZZModRingElem) R = parent(z) - ccall((:fmpz_mod_mul, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z.data, x.data, y.data, R.ninv) + @ccall libflint.fmpz_mod_mul(z.data::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, y.data::Ref{ZZRingElem}, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function add!(z::ZZModRingElem, x::ZZModRingElem, y::ZZModRingElem) R = parent(z) - ccall((:fmpz_mod_add, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z.data, x.data, y.data, R.ninv) + @ccall libflint.fmpz_mod_add(z.data::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, y.data::Ref{ZZRingElem}, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -440,8 +429,7 @@ end function (R::ZZModRing)(a::ZZRingElem) d = ZZRingElem() - ccall((:fmpz_mod, libflint), Nothing, (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - d, a, R.n) + @ccall libflint.fmpz_mod(d::Ref{ZZRingElem}, a::Ref{ZZRingElem}, R.n::Ref{ZZRingElem})::Nothing return ZZModRingElem(d, R) end diff --git a/src/flint/fmpz_mod_abs_series.jl b/src/flint/fmpz_mod_abs_series.jl index 5a9c5041a..e1b381177 100644 --- a/src/flint/fmpz_mod_abs_series.jl +++ b/src/flint/fmpz_mod_abs_series.jl @@ -50,18 +50,12 @@ for (etype, rtype, ctype, mtype, brtype) in ( p = a.parent.base_ring.ninv if len > 0 c = ZZRingElem() - ccall((:fmpz_mod_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Int, - Ref{($ctype)}), - c, a, len - 1, p) + @ccall libflint.fmpz_mod_poly_get_coeff_fmpz(c::Ref{ZZRingElem}, a::Ref{($etype)}, (len - 1)::Int, p::Ref{($ctype)})::Nothing end while len > 0 && iszero(c) len -= 1 if len > 0 - ccall((:fmpz_mod_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Int, - Ref{($ctype)}), - c, a, len - 1, p) + @ccall libflint.fmpz_mod_poly_get_coeff_fmpz(c::Ref{ZZRingElem}, a::Ref{($etype)}, (len - 1)::Int, p::Ref{($ctype)})::Nothing end end return len @@ -82,9 +76,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( return R(0) end z = ZZRingElem() - ccall((:fmpz_mod_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Int, Ref{($ctype)}), - z, x, n, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{($etype)}, n::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing return R(z) end @@ -107,9 +99,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( function is_gen(a::($etype)) return precision(a) == 0 || - Bool(ccall((:fmpz_mod_poly_is_gen, libflint), Cint, - (Ref{($etype)}, Ref{($ctype)}), - a, a.parent.base_ring.ninv)) + Bool(@ccall libflint.fmpz_mod_poly_is_gen(a::Ref{($etype)}, a.parent.base_ring.ninv::Ref{($ctype)})::Cint) end iszero(a::($etype)) = length(a) == 0 @@ -118,9 +108,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( function isone(a::($etype)) return precision(a) == 0 || - Bool(ccall((:fmpz_mod_poly_is_one, libflint), Cint, - (Ref{($etype)}, Ref{($ctype)}), - a, a.parent.base_ring.ninv)) + Bool(@ccall libflint.fmpz_mod_poly_is_one(a::Ref{($etype)}, a.parent.base_ring.ninv::Ref{($ctype)})::Cint) end # todo: write an fmpz_mod_poly_valuation @@ -182,10 +170,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( function -(x::($etype)) z = parent(x)() - ccall((:fmpz_mod_poly_neg, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($ctype)}), - z, x, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_neg(z::Ref{($etype)}, x::Ref{($etype)}, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing z.prec = x.prec return z end @@ -209,10 +194,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( lenz = max(lena, lenb) z = parent(a)() z.prec = prec - ccall((:fmpz_mod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, a, b, lenz, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_add_series(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int, a.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -229,10 +211,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( lenz = max(lena, lenb) z = parent(a)() z.prec = prec - ccall((:fmpz_mod_poly_sub_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, a, b, lenz, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_sub_series(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int, a.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -259,10 +238,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( lenz = min(lena + lenb - 1, prec) - ccall((:fmpz_mod_poly_mullow, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, a, b, lenz, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_mullow(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int, a.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -275,10 +251,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( function *(x::$(mtype), y::($etype)) z = parent(y)() z.prec = y.prec - ccall((:fmpz_mod_poly_scalar_mul_fmpz, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, - Ref{($ctype)}), - z, y, x.data, y.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_mul_fmpz(z::Ref{($etype)}, y::Ref{($etype)}, x.data::Ref{ZZRingElem}, y.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -287,10 +260,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( function *(x::ZZRingElem, y::($etype)) z = parent(y)() z.prec = y.prec - ccall((:fmpz_mod_poly_scalar_mul_fmpz, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, - Ref{($ctype)}), - z, y, x, y.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_mul_fmpz(z::Ref{($etype)}, y::Ref{($etype)}, x::Ref{ZZRingElem}, y.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -312,14 +282,8 @@ for (etype, rtype, ctype, mtype, brtype) in ( z.prec = min(z.prec, max_precision(parent(x))) zlen = min(z.prec, xlen + len) p = x.parent.base_ring.ninv - ccall((:fmpz_mod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, x, len, p) - ccall((:fmpz_mod_poly_set_trunc, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, z, zlen, p) + @ccall libflint.fmpz_mod_poly_shift_left(z::Ref{($etype)}, x::Ref{($etype)}, len::Int, p::Ref{($ctype)})::Nothing + @ccall libflint.fmpz_mod_poly_set_trunc(z::Ref{($etype)}, z::Ref{($etype)}, zlen::Int, p::Ref{($ctype)})::Nothing return z end @@ -331,10 +295,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( z.prec = max(0, x.prec - len) else z.prec = x.prec - len - ccall((:fmpz_mod_poly_shift_right, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, x, len, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_shift_right(z::Ref{($etype)}, x::Ref{($etype)}, len::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing end return z end @@ -354,9 +315,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( if precision(x) <= k return x end - ccall((:fmpz_mod_poly_truncate, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($ctype)}), - x, k, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_truncate(x::Ref{($etype)}, k::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing x.prec = k return x end @@ -381,10 +340,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( z = parent(a)() z.prec = a.prec + (b - 1)*valuation(a) z.prec = min(z.prec, max_precision(parent(a))) - ccall((:fmpz_mod_poly_pow_trunc, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt, Int, - Ref{($ctype)}), - z, a, b, z.prec, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_pow_trunc(z::Ref{($etype)}, a::Ref{($etype)}, b::UInt, z.prec::Int, a.parent.base_ring.ninv::Ref{($ctype)})::Nothing end return z end @@ -402,10 +358,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( n = max(length(x), length(y)) n = min(n, prec) - return Bool(ccall((:fmpz_mod_poly_equal_trunc, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - x, y, n, x.parent.base_ring.ninv)) + return Bool(@ccall libflint.fmpz_mod_poly_equal_trunc(x::Ref{($etype)}, y::Ref{($etype)}, n::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Cint) end function isequal(x::($etype), y::($etype)) @@ -415,9 +368,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( if x.prec != y.prec || length(x) != length(y) return false end - return Bool(ccall((:fmpz_mod_poly_equal, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($ctype)}), - x, y, x.parent.base_ring.ninv)) + return Bool(@ccall libflint.fmpz_mod_poly_equal(x::Ref{($etype)}, y::Ref{($etype)}, x.parent.base_ring.ninv::Ref{($ctype)})::Cint) end ############################################################################### @@ -431,12 +382,8 @@ for (etype, rtype, ctype, mtype, brtype) in ( return false elseif length(x) == 1 z = ZZRingElem() - ccall((:fmpz_mod_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, x, 0, x.parent.base_ring.ninv) - return ccall((:fmpz_equal, libflint), Bool, - (Ref{ZZRingElem}, Ref{ZZRingElem}), z, y) + @ccall libflint.fmpz_mod_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{($etype)}, 0::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing + return @ccall libflint.fmpz_equal(z::Ref{ZZRingElem}, y::Ref{ZZRingElem})::Bool else return precision(x) == 0 || iszero(y) end @@ -450,12 +397,8 @@ for (etype, rtype, ctype, mtype, brtype) in ( elseif length(x) == 1 z = ZZRingElem() r = mod(y, modulus(x)) - ccall((:fmpz_mod_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Int, Ref{($ctype)}), - z, x, 0, x.parent.base_ring.ninv) - return Bool(ccall((:fmpz_equal, libflint), Cint, - (Ref{ZZRingElem}, Ref{ZZRingElem}), - z, r)) + @ccall libflint.fmpz_mod_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{($etype)}, 0::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing + return Bool(@ccall libflint.fmpz_equal(z::Ref{ZZRingElem}, r::Ref{ZZRingElem})::Cint) else r = mod(y, modulus(x)) return precision(x) == 0 || iszero(r) @@ -489,10 +432,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( prec = min(x.prec, y.prec - v2 + v1) z = parent(x)() z.prec = prec - ccall((:fmpz_mod_poly_div_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, x, y, prec, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_div_series(z::Ref{($etype)}, x::Ref{($etype)}, y::Ref{($etype)}, prec::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -506,10 +446,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( iszero(y) && throw(DivideError()) z = parent(x)() z.prec = x.prec - ccall((:fmpz_mod_poly_scalar_div_fmpz, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, - Ref{($ctype)}), - z, x, data(y), x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_div_fmpz(z::Ref{($etype)}, x::Ref{($etype)}, data(y)::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -518,10 +455,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( z = parent(x)() z.prec = x.prec r = mod(y, modulus(x)) - ccall((:fmpz_mod_poly_scalar_div_fmpz, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, - Ref{($ctype)}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_div_fmpz(z::Ref{($etype)}, x::Ref{($etype)}, y::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -538,10 +472,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( !is_unit(a) && error("Unable to invert power series") ainv = parent(a)() ainv.prec = a.prec - ccall((:fmpz_mod_poly_inv_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - ainv, a, a.prec, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_inv_series(ainv::Ref{($etype)}, a::Ref{($etype)}, a.prec::Int, a.parent.base_ring.ninv::Ref{($ctype)})::Nothing return ainv end @@ -552,32 +483,24 @@ for (etype, rtype, ctype, mtype, brtype) in ( ############################################################################### function zero!(z::($etype)) - ccall((:fmpz_mod_poly_zero, libflint), Nothing, - (Ref{($etype)}, Ref{($ctype)}), - z, z.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_zero(z::Ref{($etype)}, z.parent.base_ring.ninv::Ref{($ctype)})::Nothing z.prec = parent(z).prec_max return z end function one!(z::($etype)) - ccall((:fmpz_mod_poly_one, libflint), Nothing, - (Ref{($etype)}, Ref{($ctype)}), - z, z.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_one(z::Ref{($etype)}, z.parent.base_ring.ninv::Ref{($ctype)})::Nothing z.prec = parent(z).prec_max return z end function fit!(z::($etype), n::Int) - ccall((:fmpz_mod_poly_fit_length, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($ctype)}), - z, n, z.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_fit_length(z::Ref{($etype)}, n::Int, z.parent.base_ring.ninv::Ref{($ctype)})::Nothing return nothing end function setcoeff!(z::($etype), n::Int, x::ZZRingElem) - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{($etype)}, Int, Ref{ZZRingElem}, Ref{($ctype)}), - z, n, x, z.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{($etype)}, n::Int, x::Ref{ZZRingElem}, z.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -604,10 +527,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( end z.prec = prec - ccall((:fmpz_mod_poly_mullow, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, a, b, lenz, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_mullow(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int, a.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -622,10 +542,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( lenc = max(lena, lenb) c.prec = prec - ccall((:fmpz_mod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - c, a, b, lenc, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_add_series(c::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenc::Int, a.parent.base_ring.ninv::Ref{($ctype)})::Nothing return c end @@ -757,10 +674,7 @@ function sqrt_classical(a::FpAbsPowerSeriesRingElem; check::Bool=true) end a = divexact(a, c) z.prec = a.prec - div(v, 2) - ccall((:fmpz_mod_poly_sqrt_series, libflint), Nothing, - (Ref{FpAbsPowerSeriesRingElem}, Ref{FpAbsPowerSeriesRingElem}, - Int, Ref{fmpz_mod_ctx_struct}), - z, a, a.prec, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_sqrt_series(z::Ref{FpAbsPowerSeriesRingElem}, a::Ref{FpAbsPowerSeriesRingElem}, a.prec::Int, a.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing if !isone(s) z *= s end diff --git a/src/flint/fmpz_mod_mat.jl b/src/flint/fmpz_mod_mat.jl index 289e82e17..a664fbf23 100644 --- a/src/flint/fmpz_mod_mat.jl +++ b/src/flint/fmpz_mod_mat.jl @@ -33,18 +33,14 @@ end @inline function getindex(a::T, i::Int, j::Int) where T <: Zmod_fmpz_mat @boundscheck _checkbounds(a, i, j) u = ZZRingElem() - ccall((:fmpz_mod_mat_get_entry, libflint), Nothing, - (Ref{ZZRingElem}, Ref{T}, Int, Int, Ref{fmpz_mod_ctx_struct}), - u, a, i - 1 , j - 1, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_get_entry(u::Ref{ZZRingElem}, a::Ref{T}, (i - 1)::Int, (j - 1)::Int, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return ZZModRingElem(u, base_ring(a)) # no reduction needed end # as above, but as a plain ZZRingElem, no bounds checking function getindex_raw(a::T, i::Int, j::Int) where T <: Zmod_fmpz_mat u = ZZRingElem() - ccall((:fmpz_mod_mat_get_entry, libflint), Nothing, - (Ref{ZZRingElem}, Ref{T}, Int, Int, Ref{fmpz_mod_ctx_struct}), - u, a, i - 1, j - 1, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_get_entry(u::Ref{ZZRingElem}, a::Ref{T}, (i - 1)::Int, (j - 1)::Int, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return u end @@ -66,17 +62,14 @@ end # as per setindex! but no reduction mod n and no bounds checking @inline function setindex_raw!(a::T, u::ZZRingElem, i::Int, j::Int) where T <: Zmod_fmpz_mat - ccall((:fmpz_mod_mat_set_entry, libflint), Nothing, - (Ref{T}, Int, Int, Ref{ZZRingElem}, Ref{Nothing}), - a, i - 1, j - 1, u, C_NULL) # ctx is not needed here + @ccall libflint.fmpz_mod_mat_set_entry(a::Ref{T}, (i - 1)::Int, (j - 1)::Int, u::Ref{ZZRingElem}, C_NULL::Ref{Nothing})::Nothing # ctx is not needed here end function setindex!(a::ZZModMatrix, b::ZZModMatrix, r::UnitRange{Int64}, c::UnitRange{Int64}) _checkbounds(a, r, c) size(b) == (length(r), length(c)) || throw(DimensionMismatch("tried to assign a $(size(b, 1))x$(size(b, 2)) matrix to a $(length(r))x$(length(c)) destination")) A = view(a, r, c) - ccall((:fmpz_mod_mat_set, libflint), Nothing, - (Ref{ZZModMatrix}, Ref{ZZModMatrix}, Ref{Nothing}), A, b, C_NULL) # ctx not used + @ccall libflint.fmpz_mod_mat_set(A::Ref{ZZModMatrix}, b::Ref{ZZModMatrix}, C_NULL::Ref{Nothing})::Nothing # ctx not used end function deepcopy_internal(a::ZZModMatrix, dict::IdDict) @@ -84,9 +77,7 @@ function deepcopy_internal(a::ZZModMatrix, dict::IdDict) if isdefined(a, :base_ring) z.base_ring = a.base_ring end - ccall((:fmpz_mod_mat_set, libflint), Nothing, - (Ref{ZZModMatrix}, Ref{ZZModMatrix}, Ref{fmpz_mod_ctx_struct}), - z, a, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_set(z::Ref{ZZModMatrix}, a::Ref{ZZModMatrix}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -102,8 +93,7 @@ function one(a::ZZModMatrixSpace) end function iszero(a::T) where T <: Zmod_fmpz_mat - r = ccall((:fmpz_mod_mat_is_zero, libflint), Cint, - (Ref{T}, Ref{fmpz_mod_ctx_struct}), a, base_ring(a).ninv) + r = @ccall libflint.fmpz_mod_mat_is_zero(a::Ref{T}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Cint return Bool(r) end @@ -114,9 +104,7 @@ end ################################################################################ ==(a::T, b::T) where T <: Zmod_fmpz_mat = (a.base_ring == b.base_ring) && -Bool(ccall((:fmpz_mod_mat_equal, libflint), Cint, - (Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - a, b, base_ring(a).ninv)) +Bool(@ccall libflint.fmpz_mod_mat_equal(a::Ref{T}, b::Ref{T}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Cint) isequal(a::T, b::T) where T <: Zmod_fmpz_mat = ==(a, b) @@ -128,15 +116,13 @@ isequal(a::T, b::T) where T <: Zmod_fmpz_mat = ==(a, b) function transpose(a::T) where T <: Zmod_fmpz_mat z = similar(a, ncols(a), nrows(a)) - ccall((:fmpz_mod_mat_transpose, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), z, a, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_transpose(z::Ref{T}, a::Ref{T}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function transpose!(a::T) where T <: Zmod_fmpz_mat !is_square(a) && error("Matrix must be a square matrix") - ccall((:fmpz_mod_mat_transpose, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), a, a, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_transpose(a::Ref{T}, a::Ref{T}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end ############################################################################### @@ -148,8 +134,7 @@ end #= Not currently implemented in Flint function swap_rows!(x::T, i::Int, j::Int) where T <: Zmod_fmpz_mat -ccall((:fmpz_mod_mat_swap_rows, libflint), Nothing, -(Ref{T}, Ptr{Nothing}, Int, Int), x, C_NULL, i - 1, j - 1) +@ccall libflint.fmpz_mod_mat_swap_rows(x::Ref{T}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int)::Nothing return x end @@ -160,8 +145,7 @@ return swap_rows!(y, i, j) end function swap_cols!(x::T, i::Int, j::Int) where T <: Zmod_fmpz_mat -ccall((:fmpz_mod_mat_swap_cols, libflint), Nothing, -(Ref{T}, Ptr{Nothing}, Int, Int), x, C_NULL, i - 1, j - 1) +@ccall libflint.fmpz_mod_mat_swap_cols(x::Ref{T}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int)::Nothing return x end @@ -172,16 +156,14 @@ return swap_cols!(y, i, j) end function reverse_rows!(x::T) where T <: Zmod_fmpz_mat -ccall((:fmpz_mod_mat_invert_rows, libflint), Nothing, -(Ref{T}, Ptr{Nothing}), x, C_NULL) +@ccall libflint.fmpz_mod_mat_invert_rows(x::Ref{T}, C_NULL::Ptr{Nothing})::Nothing return x end reverse_rows(x::T) where T <: Zmod_fmpz_mat = reverse_rows!(deepcopy(x)) function reverse_cols!(x::T) where T <: Zmod_fmpz_mat -ccall((:fmpz_mod_mat_invert_cols, libflint), Nothing, -(Ref{T}, Ptr{Nothing}), x, C_NULL) +@ccall libflint.fmpz_mod_mat_invert_cols(x::Ref{T}, C_NULL::Ptr{Nothing})::Nothing return x end @@ -206,18 +188,14 @@ reverse_cols(x::T) where T <: Zmod_fmpz_mat = reverse_cols!(deepcopy(x)) function +(x::T, y::T) where T <: Zmod_fmpz_mat check_parent(x,y) z = similar(x) - ccall((:fmpz_mod_mat_add, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, base_ring(x).ninv) + @ccall libflint.fmpz_mod_mat_add(z::Ref{T}, x::Ref{T}, y::Ref{T}, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function -(x::T, y::T) where T <: Zmod_fmpz_mat check_parent(x,y) z = similar(x) - ccall((:fmpz_mod_mat_sub, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, base_ring(x).ninv) + @ccall libflint.fmpz_mod_mat_sub(z::Ref{T}, x::Ref{T}, y::Ref{T}, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -225,9 +203,7 @@ function *(x::T, y::T) where T <: Zmod_fmpz_mat (base_ring(x) != base_ring(y)) && error("Base ring must be equal") (ncols(x) != nrows(y)) && error("Dimensions are wrong") z = similar(x, nrows(x), ncols(y)) - ccall((:fmpz_mod_mat_mul, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, base_ring(x).ninv) + @ccall libflint.fmpz_mod_mat_mul(z::Ref{T}, x::Ref{T}, y::Ref{T}, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -239,48 +215,37 @@ end ################################################################################ function zero!(a::T) where T <: Zmod_fmpz_mat - ccall((:fmpz_mod_mat_zero, libflint), Nothing, - (Ref{T}, Ref{fmpz_mod_ctx_struct}), a, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_zero(a::Ref{T}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return a end function one!(a::T) where T <: Zmod_fmpz_mat - ccall((:fmpz_mod_mat_one, libflint), Nothing, - (Ref{T}, Ref{fmpz_mod_ctx_struct}), a, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_one(a::Ref{T}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return a end function neg!(z::T, a::T) where T <: Zmod_fmpz_mat - ccall((:fmpz_mod_mat_neg, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), z, a, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_neg(z::Ref{T}, a::Ref{T}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function mul!(a::T, b::T, c::T) where T <: Zmod_fmpz_mat - ccall((:fmpz_mod_mat_mul, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - a, b, c, base_ring(b).ninv) + @ccall libflint.fmpz_mod_mat_mul(a::Ref{T}, b::Ref{T}, c::Ref{T}, base_ring(b).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return a end function add!(a::T, b::T, c::T) where T <: Zmod_fmpz_mat - ccall((:fmpz_mod_mat_add, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - a, b, c, base_ring(b).ninv) + @ccall libflint.fmpz_mod_mat_add(a::Ref{T}, b::Ref{T}, c::Ref{T}, base_ring(b).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return a end function mul!(z::Vector{ZZRingElem}, a::T, b::Vector{ZZRingElem}) where T <: Zmod_fmpz_mat - ccall((:fmpz_mod_mat_mul_fmpz_vec_ptr, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ref{T}, Ptr{Ref{ZZRingElem}}, Int, Ref{fmpz_mod_ctx_struct}), - z, a, b, length(b), base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_mul_fmpz_vec_ptr(z::Ptr{Ref{ZZRingElem}}, a::Ref{T}, b::Ptr{Ref{ZZRingElem}}, length(b)::Int, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function mul!(z::Vector{ZZRingElem}, a::Vector{ZZRingElem}, b::T) where T <: Zmod_fmpz_mat - ccall((:fmpz_mod_mat_fmpz_vec_mul_ptr, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ptr{Ref{ZZRingElem}}, Int, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, a, length(a), b, base_ring(b).ninv) + @ccall libflint.fmpz_mod_mat_fmpz_vec_mul_ptr(z::Ptr{Ref{ZZRingElem}}, a::Ptr{Ref{ZZRingElem}}, length(a)::Int, b::Ref{T}, base_ring(b).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -288,9 +253,7 @@ function Generic.add_one!(a::ZZModMatrix, i::Int, j::Int) @boundscheck _checkbounds(a, i, j) GC.@preserve a begin x = mat_entry_ptr(a, i, j) - ccall((:fmpz_mod_add_si, libflint), Nothing, - (Ptr{ZZRingElem}, Ptr{ZZRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - x, x, 1, base_ring(a).ninv) + @ccall libflint.fmpz_mod_add_si(x::Ptr{ZZRingElem}, x::Ptr{ZZRingElem}, 1::Int, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end return a end @@ -303,9 +266,7 @@ end function *(x::T, y::Int) where T <: Zmod_fmpz_mat z = similar(x) - ccall((:fmpz_mod_mat_scalar_mul_si, libflint), Nothing, - (Ref{T}, Ref{T}, Int, Ref{fmpz_mod_ctx_struct}), - z, x, y, base_ring(x).ninv) + @ccall libflint.fmpz_mod_mat_scalar_mul_si(z::Ref{T}, x::Ref{T}, y::Int, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -313,9 +274,7 @@ end function *(x::T, y::ZZRingElem) where T <: Zmod_fmpz_mat z = similar(x) - ccall((:fmpz_mod_mat_scalar_mul_fmpz, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z, x, y, base_ring(x).ninv) + @ccall libflint.fmpz_mod_mat_scalar_mul_fmpz(z::Ref{T}, x::Ref{T}, y::Ref{ZZRingElem}, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -346,8 +305,7 @@ x = inv(x) y = -y end z = similar(x) -ccall((:fmpz_mod_mat_pow, libflint), Nothing, -(Ref{T}, Ref{T}, Int), z, x, y) +@ccall libflint.fmpz_mod_mat_pow(z::Ref{T}, x::Ref{T}, y::Int)::Nothing return z end =# @@ -367,8 +325,7 @@ end ################################################################################ function strong_echelon_form!(a::T) where T <: Zmod_fmpz_mat - ccall((:fmpz_mod_mat_strong_echelon_form, libflint), Nothing, - (Ref{T}, Ref{fmpz_mod_ctx_struct}), a, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_strong_echelon_form(a::Ref{T}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end @doc raw""" @@ -386,8 +343,7 @@ function strong_echelon_form(a::ZZModMatrix) end function howell_form!(a::T) where T <: Zmod_fmpz_mat - ccall((:fmpz_mod_mat_howell_form, libflint), Nothing, - (Ref{T}, Ref{fmpz_mod_ctx_struct}), a, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_howell_form(a::Ref{T}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end @doc raw""" @@ -415,9 +371,7 @@ function tr(a::T) where T <: Zmod_fmpz_mat !is_square(a) && error("Matrix must be a square matrix") R = base_ring(a) r = ZZRingElem() - ccall((:fmpz_mod_mat_trace, libflint), Nothing, - (Ref{ZZRingElem}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - r, a, R.ninv) + @ccall libflint.fmpz_mod_mat_trace(r::Ref{ZZRingElem}, a::Ref{T}, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return elem_type(R)(r, R) end @@ -432,7 +386,7 @@ end function det(a::ZZModMatrix) !is_square(a) && error("Matrix must be a square matrix") if is_prime(a.n) -r = ccall((:fmpz_mod_mat_det, libflint), UInt, (Ref{ZZModMatrix}, ), a) +r = @ccall libflint.fmpz_mod_mat_det(a::Ref{ZZModMatrix})::UInt return base_ring(a)(r) else try @@ -454,7 +408,7 @@ end #= Not implemented in Flint yet function rank(a::T) where T <: Zmod_fmpz_mat -r = ccall((:fmpz_mod_mat_rank, libflint), Int, (Ref{T}, ), a) +r = @ccall libflint.fmpz_mod_mat_rank(a::Ref{T})::Int return r end @@ -490,8 +444,7 @@ end function inv(a::T) where T <: Zmod_fmpz_mat !is_square(a) && error("Matrix must be a square matrix") z = similar(a) -r = ccall((:fmpz_mod_mat_inv, libflint), Int, -(Ref{T}, Ref{T}), z, a) +r = @ccall libflint.fmpz_mod_mat_inv(z::Ref{T}, a::Ref{T})::Int !Bool(r) && error("Matrix not invertible") return z end @@ -512,8 +465,7 @@ function Solve._can_solve_internal_no_check(::Solve.LUTrait, A::ZZModMatrix, b:: x = similar(A, ncols(A), ncols(b)) # This is probably only correct if the characteristic is prime - fl = ccall((:fmpz_mod_mat_can_solve, libflint), Cint, - (Ref{ZZModMatrix}, Ref{ZZModMatrix}, Ref{ZZModMatrix}, Ref{fmpz_mod_ctx_struct}), x, A, b, base_ring(x).ninv) + fl = @ccall libflint.fmpz_mod_mat_can_solve(x::Ref{ZZModMatrix}, A::Ref{ZZModMatrix}, b::Ref{ZZModMatrix}, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Cint if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end @@ -534,8 +486,7 @@ end function lu!(P::Perm, x::T) where T <: Zmod_fmpz_mat P.d .-= 1 -rank = Int(ccall((:fmpz_mod_mat_lu, libflint), Cint, (Ptr{Int}, Ref{T}, Cint), -P.d, x, 0)) +rank = Int(@ccall libflint.fmpz_mod_mat_lu(P.d::Ptr{Int}, x::Ref{T}, 0::Cint)::Cint) P.d .+= 1 @@ -600,9 +551,7 @@ function Base.view(x::ZZModMatrix, r1::Int, c1::Int, r2::Int, c2::Int) z = ZZModMatrix() z.base_ring = x.base_ring z.view_parent = x - ccall((:fmpz_mod_mat_window_init, libflint), Nothing, - (Ref{ZZModMatrix}, Ref{ZZModMatrix}, Int, Int, Int, Int, Ref{fmpz_mod_ctx_struct}), - z, x, r1 - 1, c1 - 1, r2, c2, base_ring(x).ninv) + @ccall libflint.fmpz_mod_mat_window_init(z::Ref{ZZModMatrix}, x::Ref{ZZModMatrix}, (r1 - 1)::Int, (c1 - 1)::Int, r2::Int, c2::Int, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_fmpz_mod_mat_window_clear_fn, z) return z end @@ -612,8 +561,7 @@ function Base.view(x::T, r::AbstractUnitRange{Int}, c::AbstractUnitRange{Int}) w end function _fmpz_mod_mat_window_clear_fn(a::ZZModMatrix) - ccall((:fmpz_mod_mat_window_clear, libflint), Nothing, - (Ref{ZZModMatrix}, Ref{fmpz_mod_ctx_struct}), a, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_window_clear(a::Ref{ZZModMatrix}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end function sub(x::T, r1::Int, c1::Int, r2::Int, c2::Int) where T <: Zmod_fmpz_mat @@ -638,9 +586,7 @@ function hcat(x::T, y::T) where T <: Zmod_fmpz_mat (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") (x.r != y.r) && error("Matrices must have same number of rows") z = similar(x, nrows(x), ncols(x) + ncols(y)) - ccall((:fmpz_mod_mat_concat_horizontal, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, base_ring(x).ninv) + @ccall libflint.fmpz_mod_mat_concat_horizontal(z::Ref{T}, x::Ref{T}, y::Ref{T}, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -648,9 +594,7 @@ function vcat(x::T, y::T) where T <: Zmod_fmpz_mat (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") (x.c != y.c) && error("Matrices must have same number of columns") z = similar(x, nrows(x) + nrows(y), ncols(x)) - ccall((:fmpz_mod_mat_concat_vertical, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, base_ring(x).ninv) + @ccall libflint.fmpz_mod_mat_concat_vertical(z::Ref{T}, x::Ref{T}, y::Ref{T}, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -670,14 +614,12 @@ entries of the returned matrix are those of $a$ lifted to $\mathbb{Z}$. """ function lift(a::T) where {T <: Zmod_fmpz_mat} z = ZZMatrix(nrows(a), ncols(a)) -ccall((:fmpz_mat_set_fmpz_mod_mat, libflint), Nothing, -(Ref{ZZMatrix}, Ref{T}), z, a) +@ccall libflint.fmpz_mat_set_fmpz_mod_mat(z::Ref{ZZMatrix}, a::Ref{T})::Nothing return z end function lift!(z::ZZMatrix, a::T) where T <: Zmod_fmpz_mat -ccall((:fmpz_mat_set_fmpz_mod_mat, libflint), Nothing, -(Ref{ZZMatrix}, Ref{T}), z, a) +@ccall libflint.fmpz_mat_set_fmpz_mod_mat(z::Ref{ZZMatrix}, a::Ref{T})::Nothing return z end @@ -714,8 +656,7 @@ end function charpoly(R::ZZModPolyRing, a::ZZModMatrix) m = deepcopy(a) p = R() -ccall((:fmpz_mod_mat_charpoly, libflint), Nothing, -(Ref{ZZModPolyRingElem}, Ref{ZZModMatrix}), p, m) +@ccall libflint.fmpz_mod_mat_charpoly(p::Ref{ZZModPolyRingElem}, m::Ref{ZZModMatrix})::Nothing return p end @@ -731,8 +672,7 @@ end function minpoly(R::ZZModPolyRing, a::ZZModMatrix) p = R() -ccall((:fmpz_mod_mat_minpoly, libflint), Nothing, -(Ref{ZZModPolyRingElem}, Ref{ZZModMatrix}), p, a) +@ccall libflint.fmpz_mod_mat_minpoly(p::Ref{ZZModPolyRingElem}, a::Ref{ZZModMatrix})::Nothing return p end @@ -823,9 +763,7 @@ end function (a::ZZModMatrixSpace)(b::ZZMatrix) (ncols(a) != b.c || nrows(a) != b.r) && error("Dimensions do not fit") z = ZZModMatrix(b.r, b.c, base_ring(a).ninv) - ccall((:fmpz_mod_mat_set_fmpz_mat, libflint), Nothing, - (Ref{ZZModMatrix}, Ref{ZZMatrix}, Ref{fmpz_mod_ctx_struct}), - z, b, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_set_fmpz_mat(z::Ref{ZZModMatrix}, b::Ref{ZZMatrix}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing z.base_ring = a.base_ring return z end @@ -875,8 +813,7 @@ end function nullspace(M::ZZModMatrix) # Apparently this only works correctly if base_ring(M) is a field N = similar(M, ncols(M), ncols(M)) - nullity = ccall((:fmpz_mod_mat_nullspace, libflint), Int, - (Ref{ZZModMatrix}, Ref{ZZModMatrix}, Ref{fmpz_mod_ctx_struct}), N, M, base_ring(N).ninv) + nullity = @ccall libflint.fmpz_mod_mat_nullspace(N::Ref{ZZModMatrix}, M::Ref{ZZModMatrix}, base_ring(N).ninv::Ref{fmpz_mod_ctx_struct})::Int return nullity, view(N, 1:nrows(N), 1:nullity) end diff --git a/src/flint/fmpz_mod_mpoly.jl b/src/flint/fmpz_mod_mpoly.jl index 026441028..4d3e58f27 100644 --- a/src/flint/fmpz_mod_mpoly.jl +++ b/src/flint/fmpz_mod_mpoly.jl @@ -44,7 +44,7 @@ for (etype, rtype, ftype, ctype) in ( function internal_ordering(a::($rtype)) b = a.ord - # b = ccall((:fmpz_mod_mpoly_ctx_ord, libflint), Cint, (Ref{zzModMPolyRing}, ), a) + # b = @ccall libflint.fmpz_mod_mpoly_ctx_ord(a::Ref{zzModMPolyRing})::Cint return flint_orderings[b + 1] end @@ -52,9 +52,7 @@ for (etype, rtype, ftype, ctype) in ( A = Vector{($etype)}(undef, R.nvars) for i = 1:R.nvars z = R() - ccall((:fmpz_mod_mpoly_gen, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($rtype)}), - z, i - 1, R) + @ccall libflint.fmpz_mod_mpoly_gen(z::Ref{($etype)}, (i - 1)::Int, R::Ref{($rtype)})::Nothing A[i] = z end return A @@ -64,31 +62,23 @@ for (etype, rtype, ftype, ctype) in ( n = nvars(R) (i <= 0 || i > n) && error("Index must be between 1 and $n") z = R() - ccall((:fmpz_mod_mpoly_gen, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($rtype)}), - z, i - 1, R) + @ccall libflint.fmpz_mod_mpoly_gen(z::Ref{($etype)}, (i - 1)::Int, R::Ref{($rtype)})::Nothing return z end function is_gen(a::($etype), i::Int) n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") - return Bool(ccall((:fmpz_mod_mpoly_is_gen, libflint), Cint, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, i - 1, parent(a))) + return Bool(@ccall libflint.fmpz_mod_mpoly_is_gen(a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Cint) end function is_gen(a::($etype)) - return Bool(ccall((:fmpz_mod_mpoly_is_gen, libflint), Cint, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, -1, parent(a))) + return Bool(@ccall libflint.fmpz_mod_mpoly_is_gen(a::Ref{($etype)}, (-1)::Int, parent(a)::Ref{($rtype)})::Cint) end function deepcopy_internal(a::($etype), dict::IdDict) z = parent(a)() - ccall((:fmpz_mod_mpoly_set, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, parent(a)) + @ccall libflint.fmpz_mod_mpoly_set(z::Ref{($etype)}, a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return z end @@ -104,15 +94,11 @@ for (etype, rtype, ftype, ctype) in ( zero(R::($rtype)) = zero!(R()) function isone(a::($etype)) - return Bool(ccall((:fmpz_mod_mpoly_is_one, libflint), Cint, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a))) + return Bool(@ccall libflint.fmpz_mod_mpoly_is_one(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Cint) end function iszero(a::($etype)) - return Bool(ccall((:fmpz_mod_mpoly_is_zero, libflint), Cint, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a))) + return Bool(@ccall libflint.fmpz_mod_mpoly_is_zero(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Cint) end function is_monomial(a::($etype)) @@ -128,9 +114,7 @@ for (etype, rtype, ftype, ctype) in ( end function is_constant(a::($etype)) - return Bool(ccall((:fmpz_mod_mpoly_is_fmpz, libflint), Cint, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a))) + return Bool(@ccall libflint.fmpz_mod_mpoly_is_fmpz(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Cint) end function fit!(a::($etype), n::Int) @@ -158,9 +142,7 @@ for (etype, rtype, ftype, ctype) in ( n = length(a) (i < 1 || i > n) && error("Index must be between 1 and $(length(a))") z = ZZRingElem() - ccall((:fmpz_mod_mpoly_get_term_coeff_fmpz, libflint), UInt, - (Ref{ZZRingElem}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpz_mod_mpoly_get_term_coeff_fmpz(z::Ref{ZZRingElem}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::UInt return base_ring(parent(a))(z) end @@ -168,9 +150,7 @@ for (etype, rtype, ftype, ctype) in ( check_parent(a, b) !isone(length(b)) && error("Second argument must be a monomial") z = ZZRingElem() - ccall((:fmpz_mod_mpoly_get_coeff_fmpz_monomial, libflint), UInt, - (Ref{ZZRingElem}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_get_coeff_fmpz_monomial(z::Ref{ZZRingElem}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::UInt return base_ring(parent(a))(z) end @@ -193,9 +173,7 @@ for (etype, rtype, ftype, ctype) in ( n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") if degrees_fit_int(a) - d = ccall((:fmpz_mod_mpoly_degree_si, libflint), Int, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, i - 1, parent(a)) + d = @ccall libflint.fmpz_mod_mpoly_degree_si(a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Int return d else return Int(degree_fmpz(a, i)) @@ -207,17 +185,13 @@ for (etype, rtype, ftype, ctype) in ( n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") d = ZZRingElem() - ccall((:fmpz_mod_mpoly_degree_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Int, Ref{($rtype)}), - d, a, i - 1, parent(a)) + @ccall libflint.fmpz_mod_mpoly_degree_fmpz(d::Ref{ZZRingElem}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Nothing return d end # Return true if degrees fit into an Int function degrees_fit_int(a::($etype)) - return Bool(ccall((:fmpz_mod_mpoly_degrees_fit_si, libflint), Cint, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a))) + return Bool(@ccall libflint.fmpz_mod_mpoly_degrees_fit_si(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Cint) end # Return an array of the max degrees in each variable @@ -226,9 +200,7 @@ for (etype, rtype, ftype, ctype) in ( throw(OverflowError("degrees of polynomial do not fit into Int")) end degs = Vector{Int}(undef, nvars(parent(a))) - ccall((:fmpz_mod_mpoly_degrees_si, libflint), Nothing, - (Ptr{Int}, Ref{($etype)}, Ref{($rtype)}), - degs, a, parent(a)) + @ccall libflint.fmpz_mod_mpoly_degrees_si(degs::Ptr{Int}, a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return degs end @@ -239,17 +211,13 @@ for (etype, rtype, ftype, ctype) in ( for i in 1:n degs[i] = ZZRingElem() end - ccall((:fmpz_mod_mpoly_degrees_fmpz, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ref{($etype)}, Ref{($rtype)}), - degs, a, parent(a)) + @ccall libflint.fmpz_mod_mpoly_degrees_fmpz(degs::Ptr{Ref{ZZRingElem}}, a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return degs end # Return true if degree fits into an Int function total_degree_fits_int(a::($etype)) - return Bool(ccall((:fmpz_mod_mpoly_total_degree_fits_si, libflint), Cint, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a))) + return Bool(@ccall libflint.fmpz_mod_mpoly_total_degree_fits_si(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Cint) end # Total degree as an Int @@ -257,18 +225,14 @@ for (etype, rtype, ftype, ctype) in ( if !total_degree_fits_int(a) throw(OverflowError("Total degree of polynomial does not fit into Int")) end - d = ccall((:fmpz_mod_mpoly_total_degree_si, libflint), Int, - (Ref{($etype)}, Ref{($rtype)}), - a, a.parent) + d = @ccall libflint.fmpz_mod_mpoly_total_degree_si(a::Ref{($etype)}, a.parent::Ref{($rtype)})::Int return d end # Total degree as an ZZRingElem function total_degree_fmpz(a::($etype)) d = ZZRingElem() - ccall((:fmpz_mod_mpoly_total_degree_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Ref{($rtype)}), - d, a, parent(a)) + @ccall libflint.fmpz_mod_mpoly_total_degree_fmpz(d::Ref{ZZRingElem}, a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return d end @@ -287,9 +251,7 @@ for (etype, rtype, ftype, ctype) in ( 0 <= vars[i] < nvars(parent(a)) || error("Variable index not in range") exps[i] >= 0 || error("Exponent cannot be negative") end - ccall((:fmpz_mod_mpoly_get_coeff_vars_ui, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ptr{Int}, Ptr{Int}, Int, Ref{($rtype)}), - z, a, vars, exps, length(vars), parent(a)) + @ccall libflint.fmpz_mod_mpoly_get_coeff_vars_ui(z::Ref{($etype)}, a::Ref{($etype)}, vars::Ptr{Int}, exps::Ptr{Int}, length(vars)::Int, parent(a)::Ref{($rtype)})::Nothing return z end @@ -304,27 +266,21 @@ for (etype, rtype, ftype, ctype) in ( function +(a::($etype), b::($etype)) check_parent(a, b) z = parent(a)() - ccall((:fmpz_mod_mpoly_add, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_add(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return z end function -(a::($etype), b::($etype)) check_parent(a, b) z = parent(a)() - ccall((:fmpz_mod_mpoly_sub, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_sub(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return z end function *(a::($etype), b::($etype)) check_parent(a, b) z = parent(a)() - ccall((:fmpz_mod_mpoly_mul, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_mul(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return z end @@ -336,25 +292,19 @@ for (etype, rtype, ftype, ctype) in ( function +(a::($etype), b::UInt) z = parent(a)() - ccall((:fmpz_mod_mpoly_add_ui, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_add_ui(z::Ref{($etype)}, a::Ref{($etype)}, b::UInt, parent(a)::Ref{($rtype)})::Nothing return z end function +(a::($etype), b::Int) z = parent(a)() - ccall((:fmpz_mod_mpoly_add_si, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_add_si(z::Ref{($etype)}, a::Ref{($etype)}, b::Int, parent(a)::Ref{($rtype)})::Nothing return z end function +(a::($etype), b::ZZRingElem) z = parent(a)() - ccall((:fmpz_mod_mpoly_add_fmpz, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_add_fmpz(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{ZZRingElem}, parent(a)::Ref{($rtype)})::Nothing return z end @@ -368,25 +318,19 @@ for (etype, rtype, ftype, ctype) in ( function -(a::($etype), b::UInt) z = parent(a)() - ccall((:fmpz_mod_mpoly_sub_ui, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_sub_ui(z::Ref{($etype)}, a::Ref{($etype)}, b::UInt, parent(a)::Ref{($rtype)})::Nothing return z end function -(a::($etype), b::Int) z = parent(a)() - ccall((:fmpz_mod_mpoly_sub_si, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_sub_si(z::Ref{($etype)}, a::Ref{($etype)}, b::Int, parent(a)::Ref{($rtype)})::Nothing return z end function -(a::($etype), b::ZZRingElem) z = parent(a)() - ccall((:fmpz_mod_mpoly_sub_fmpz, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_sub_fmpz(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{ZZRingElem}, parent(a)::Ref{($rtype)})::Nothing return z end @@ -400,25 +344,19 @@ for (etype, rtype, ftype, ctype) in ( function *(a::($etype), b::UInt) z = parent(a)() - ccall((:fmpz_mod_mpoly_scalar_mul_ui, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_scalar_mul_ui(z::Ref{($etype)}, a::Ref{($etype)}, b::UInt, parent(a)::Ref{($rtype)})::Nothing return z end function *(a::($etype), b::Int) z = parent(a)() - ccall((:fmpz_mod_mpoly_scalar_mul_si, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_scalar_mul_si(z::Ref{($etype)}, a::Ref{($etype)}, b::Int, parent(a)::Ref{($rtype)})::Nothing return z end function *(a::($etype), b::ZZRingElem) z = parent(a)() - ccall((:fmpz_mod_mpoly_scalar_mul_fmpz, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_scalar_mul_fmpz(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{ZZRingElem}, parent(a)::Ref{($rtype)})::Nothing return z end @@ -441,18 +379,14 @@ for (etype, rtype, ftype, ctype) in ( function ^(a::($etype), b::Int) b >= 0 || throw(DomainError(b, "Exponent must be non-negative")) z = parent(a)() - ccall((:fmpz_mod_mpoly_pow_ui, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt, Ref{($rtype)}), - z, a, UInt(b), parent(a)) + @ccall libflint.fmpz_mod_mpoly_pow_ui(z::Ref{($etype)}, a::Ref{($etype)}, UInt(b)::UInt, parent(a)::Ref{($rtype)})::Nothing return z end function ^(a::($etype), b::ZZRingElem) b >= 0 || throw(DomainError(b, "Exponent must be non-negative")) z = parent(a)() - ok = ccall((:fmpz_mod_mpoly_pow_fmpz, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, Ref{($rtype)}), - z, a, b, parent(a)) + ok = @ccall libflint.fmpz_mod_mpoly_pow_fmpz(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{ZZRingElem}, parent(a)::Ref{($rtype)})::Cint iszero(ok) && error("Unable to compute power") return z end @@ -466,9 +400,7 @@ for (etype, rtype, ftype, ctype) in ( function gcd(a::($etype), b::($etype)) check_parent(a, b) z = parent(a)() - ok = ccall((:fmpz_mod_mpoly_gcd, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, b, a.parent) + ok = @ccall libflint.fmpz_mod_mpoly_gcd(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, a.parent::Ref{($rtype)})::Cint iszero(ok) && error("Unable to compute gcd") return z end @@ -485,22 +417,14 @@ for (etype, rtype, ftype, ctype) in ( for i in 0:fac.num-1 f = R() if preserve_input - ccall((:fmpz_mod_mpoly_factor_get_base, libflint), Nothing, - (Ref{($etype)}, Ref{($ftype)}, Int, Ref{($rtype)}), - f, fac, i, R) + @ccall libflint.fmpz_mod_mpoly_factor_get_base(f::Ref{($etype)}, fac::Ref{($ftype)}, i::Int, R::Ref{($rtype)})::Nothing else - ccall((:fmpz_mod_mpoly_factor_swap_base, libflint), Nothing, - (Ref{($etype)}, Ref{($ftype)}, Int, Ref{($rtype)}), - f, fac, i, R) + @ccall libflint.fmpz_mod_mpoly_factor_swap_base(f::Ref{($etype)}, fac::Ref{($ftype)}, i::Int, R::Ref{($rtype)})::Nothing end - F.fac[f] = ccall((:fmpz_mod_mpoly_factor_get_exp_si, libflint), Int, - (Ref{($ftype)}, Int, Ref{($rtype)}), - fac, i, R) + F.fac[f] = @ccall libflint.fmpz_mod_mpoly_factor_get_exp_si(fac::Ref{($ftype)}, i::Int, R::Ref{($rtype)})::Int end c = ZZRingElem() - ccall((:fmpz_mod_mpoly_factor_get_constant_fmpz, libflint), UInt, - (Ref{ZZRingElem}, Ref{($ftype)}), - c, fac) + @ccall libflint.fmpz_mod_mpoly_factor_get_constant_fmpz(c::Ref{ZZRingElem}, fac::Ref{($ftype)})::UInt F.unit = R(c) return F end @@ -509,9 +433,7 @@ for (etype, rtype, ftype, ctype) in ( iszero(a) && throw(ArgumentError("Argument must be non-zero")) R = parent(a) fac = ($ftype)(R) - ok = ccall((:fmpz_mod_mpoly_factor, libflint), Cint, - (Ref{($ftype)}, Ref{($etype)}, Ref{($rtype)}), - fac, a, R) + ok = @ccall libflint.fmpz_mod_mpoly_factor(fac::Ref{($ftype)}, a::Ref{($etype)}, R::Ref{($rtype)})::Cint iszero(ok) && error("unable to compute factorization") return Fac{($etype)}(fac, false) end @@ -520,9 +442,7 @@ for (etype, rtype, ftype, ctype) in ( iszero(a) && throw(ArgumentError("Argument must be non-zero")) R = parent(a) fac = ($ftype)(R) - ok = ccall((:fmpz_mod_mpoly_factor_squarefree, libflint), Cint, - (Ref{($ftype)}, Ref{($etype)}, Ref{($rtype)}), - fac, a, R) + ok = @ccall libflint.fmpz_mod_mpoly_factor_squarefree(fac::Ref{($ftype)}, a::Ref{($etype)}, R::Ref{($rtype)})::Cint iszero(ok) && error("unable to compute factorization") return Fac{($etype)}(fac, false) end @@ -535,16 +455,12 @@ for (etype, rtype, ftype, ctype) in ( end function is_square(a::($etype)) - return Bool(ccall((:fmpz_mod_mpoly_is_square, libflint), Cint, - (Ref{($etype)}, Ref{($rtype)}), - a, a.parent)) + return Bool(@ccall libflint.fmpz_mod_mpoly_is_square(a::Ref{($etype)}, a.parent::Ref{($rtype)})::Cint) end function is_square_with_sqrt(a::($etype)) q = parent(a)() - flag = ccall((:fmpz_mod_mpoly_sqrt, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - q, a, a.parent) + flag = @ccall libflint.fmpz_mod_mpoly_sqrt(q::Ref{($etype)}, a::Ref{($etype)}, a.parent::Ref{($rtype)})::Cint return (Bool(flag), q) end @@ -556,16 +472,12 @@ for (etype, rtype, ftype, ctype) in ( function ==(a::($etype), b::($etype)) check_parent(a, b) - return Bool(ccall((:fmpz_mod_mpoly_equal, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - a, b, a.parent)) + return Bool(@ccall libflint.fmpz_mod_mpoly_equal(a::Ref{($etype)}, b::Ref{($etype)}, a.parent::Ref{($rtype)})::Cint) end function Base.isless(a::($etype), b::($etype)) (!is_monomial(a) || !is_monomial(b)) && error("Not monomials in comparison") - return ccall((:fmpz_mod_mpoly_cmp, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - a, b, a.parent) < 0 + return @ccall libflint.fmpz_mod_mpoly_cmp(a::Ref{($etype)}, b::Ref{($etype)}, a.parent::Ref{($rtype)})::Cint < 0 end ############################################################################### @@ -575,25 +487,19 @@ for (etype, rtype, ftype, ctype) in ( ############################################################################### function ==(a::($etype), b::($ctype)) - return Bool(ccall((:fmpz_mod_mpoly_equal_fmpz, libflint), Cint, - (Ref{($etype)}, Ref{ZZRingElem}, Ref{($rtype)}), - a, data(b), a.parent)) + return Bool(@ccall libflint.fmpz_mod_mpoly_equal_fmpz(a::Ref{($etype)}, data(b)::Ref{ZZRingElem}, a.parent::Ref{($rtype)})::Cint) end ==(a::($ctype), b::($etype)) = b == a function ==(a::($etype), b::UInt) - return Bool(ccall((:fmpz_mod_mpoly_equal_ui, libflint), Cint, - (Ref{($etype)}, UInt, Ref{($rtype)}), - a, b, parent(a))) + return Bool(@ccall libflint.fmpz_mod_mpoly_equal_ui(a::Ref{($etype)}, b::UInt, parent(a)::Ref{($rtype)})::Cint) end ==(a::UInt, b::($etype)) = b == a function ==(a::($etype), b::Int) - return Bool(ccall((:fmpz_mod_mpoly_equal_si, libflint), Cint, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, b, parent(a))) + return Bool(@ccall libflint.fmpz_mod_mpoly_equal_si(a::Ref{($etype)}, b::Int, parent(a)::Ref{($rtype)})::Cint) end ==(a::Int, b::($etype)) = b == a @@ -621,9 +527,7 @@ for (etype, rtype, ftype, ctype) in ( return false, zero(parent(a)) end z = parent(a)() - d = ccall((:fmpz_mod_mpoly_divides, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, b, parent(a)) + d = @ccall libflint.fmpz_mod_mpoly_divides(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::Cint return isone(d), z end @@ -636,9 +540,7 @@ for (etype, rtype, ftype, ctype) in ( function Base.div(a::($etype), b::($etype)) check_parent(a, b) q = parent(a)() - ccall((:fmpz_mod_mpoly_div, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - q, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_div(q::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return q end @@ -646,10 +548,7 @@ for (etype, rtype, ftype, ctype) in ( check_parent(a, b) q = parent(a)() r = parent(a)() - ccall((:fmpz_mod_mpoly_divrem, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Ref{($rtype)}), - q, r, a, b, parent(a)) + @ccall libflint.fmpz_mod_mpoly_divrem(q::Ref{($etype)}, r::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return q, r end @@ -657,10 +556,7 @@ for (etype, rtype, ftype, ctype) in ( len = length(b) q = [parent(a)() for i in 1:len] r = parent(a)() - ccall((:fmpz_mod_mpoly_divrem_ideal, libflint), Nothing, - (Ptr{Ref{($etype)}}, Ref{($etype)}, Ref{($etype)}, - Ptr{Ref{($etype)}}, Int, Ref{($rtype)}), - q, r, a, b, len, parent(a)) + @ccall libflint.fmpz_mod_mpoly_divrem_ideal(q::Ptr{Ref{($etype)}}, r::Ref{($etype)}, a::Ref{($etype)}, b::Ptr{Ref{($etype)}}, len::Int, parent(a)::Ref{($rtype)})::Nothing return q, r end @@ -687,9 +583,7 @@ for (etype, rtype, ftype, ctype) in ( n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") z = parent(a)() - ccall((:fmpz_mod_mpoly_derivative, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpz_mod_mpoly_derivative(z::Ref{($etype)}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Nothing return z end @@ -742,37 +636,27 @@ for (etype, rtype, ftype, ctype) in ( ############################################################################### function zero!(a::($etype)) - ccall((:fmpz_mod_mpoly_zero, libflint), Nothing, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a)) + @ccall libflint.fmpz_mod_mpoly_zero(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return a end function one!(a::($etype)) - ccall((:fmpz_mod_mpoly_one, libflint), Nothing, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a)) + @ccall libflint.fmpz_mod_mpoly_one(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return a end function neg!(z::($etype), a::($etype)) - ccall((:fmpz_mod_mpoly_neg, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, parent(a)) + @ccall libflint.fmpz_mod_mpoly_neg(z::Ref{($etype)}, a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return z end function add!(a::($etype), b::($etype), c::($etype)) - ccall((:fmpz_mod_mpoly_add, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - a, b, c, parent(a)) + @ccall libflint.fmpz_mod_mpoly_add(a::Ref{($etype)}, b::Ref{($etype)}, c::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return a end function mul!(a::($etype), b::($etype), c::($etype)) - ccall((:fmpz_mod_mpoly_mul, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - a, b, c, parent(a)) + @ccall libflint.fmpz_mod_mpoly_mul(a::Ref{($etype)}, b::Ref{($etype)}, c::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return a end @@ -780,13 +664,9 @@ for (etype, rtype, ftype, ctype) in ( # must be removed with combine_like_terms! function setcoeff!(a::($etype), n::Int, c::($ctype)) if n > length(a) - ccall((:fmpz_mod_mpoly_resize, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, n, a.parent) + @ccall libflint.fmpz_mod_mpoly_resize(a::Ref{($etype)}, n::Int, a.parent::Ref{($rtype)})::Nothing end - ccall((:fmpz_mod_mpoly_set_term_coeff_fmpz, libflint), Nothing, - (Ref{($etype)}, Int, Ref{ZZRingElem}, Ref{($rtype)}), - a, n - 1, data(c), a.parent) + @ccall libflint.fmpz_mod_mpoly_set_term_coeff_fmpz(a::Ref{($etype)}, (n - 1)::Int, data(c)::Ref{ZZRingElem}, a.parent::Ref{($rtype)})::Nothing return a end @@ -801,9 +681,7 @@ for (etype, rtype, ftype, ctype) in ( # Remove zero terms and combine adjacent terms if they have the same monomial # no sorting is performed function combine_like_terms!(a::($etype)) - ccall((:fmpz_mod_mpoly_combine_like_terms, libflint), Nothing, - (Ref{($etype)}, Ref{($rtype)}), - a, a.parent) + @ccall libflint.fmpz_mod_mpoly_combine_like_terms(a::Ref{($etype)}, a.parent::Ref{($rtype)})::Nothing return a end @@ -814,37 +692,27 @@ for (etype, rtype, ftype, ctype) in ( ############################################################################### function exponent_vector_fits(::Type{Int}, a::($etype), i::Int) - b = ccall((:fmpz_mod_mpoly_term_exp_fits_si, libflint), Cint, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, i - 1, parent(a)) + b = @ccall libflint.fmpz_mod_mpoly_term_exp_fits_si(a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Cint return Bool(b) end function exponent_vector_fits(::Type{UInt}, a::($etype), i::Int) - b = ccall((:fmpz_mod_mpoly_term_exp_fits_ui, libflint), Cint, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, i - 1, parent(a)) + b = @ccall libflint.fmpz_mod_mpoly_term_exp_fits_ui(a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Cint return Bool(b) end function exponent_vector!(z::Vector{Int}, a::($etype), i::Int) - ccall((:fmpz_mod_mpoly_get_term_exp_si, libflint), Nothing, - (Ptr{Int}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpz_mod_mpoly_get_term_exp_si(z::Ptr{Int}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Nothing return z end function exponent_vector!(z::Vector{UInt}, a::($etype), i::Int) - ccall((:fmpz_mod_mpoly_get_term_exp_ui, libflint), Nothing, - (Ptr{UInt}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpz_mod_mpoly_get_term_exp_ui(z::Ptr{UInt}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Nothing return z end function exponent_vector!(z::Vector{ZZRingElem}, a::($etype), i::Int) - ccall((:fmpz_mod_mpoly_get_term_exp_fmpz, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpz_mod_mpoly_get_term_exp_fmpz(z::Ptr{Ref{ZZRingElem}}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Nothing return z end @@ -857,12 +725,9 @@ for (etype, rtype, ftype, ctype) in ( # No sort is performed, so this is unsafe. function set_exponent_vector!(a::($etype), n::Int, exps::Vector{UInt}) if n > length(a) - ccall((:fmpz_mod_mpoly_resize, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($rtype)}), a, n, a.parent) + @ccall libflint.fmpz_mod_mpoly_resize(a::Ref{($etype)}, n::Int, a.parent::Ref{($rtype)})::Nothing end - ccall((:fmpz_mod_mpoly_set_term_exp_ui, libflint), Nothing, - (Ref{($etype)}, Int, Ptr{UInt}, Ref{($rtype)}), - a, n - 1, exps, parent(a)) + @ccall libflint.fmpz_mod_mpoly_set_term_exp_ui(a::Ref{($etype)}, (n - 1)::Int, exps::Ptr{UInt}, parent(a)::Ref{($rtype)})::Nothing return a end @@ -871,13 +736,9 @@ for (etype, rtype, ftype, ctype) in ( # no check is performed function set_exponent_vector!(a::($etype), n::Int, exps::Vector{Int}) if n > length(a) - ccall((:fmpz_mod_mpoly_resize, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, n, parent(a)) + @ccall libflint.fmpz_mod_mpoly_resize(a::Ref{($etype)}, n::Int, parent(a)::Ref{($rtype)})::Nothing end - ccall((:fmpz_mod_mpoly_set_term_exp_ui, libflint), Nothing, - (Ref{($etype)}, Int, Ptr{Int}, Ref{($rtype)}), - a, n - 1, exps, parent(a)) + @ccall libflint.fmpz_mod_mpoly_set_term_exp_ui(a::Ref{($etype)}, (n - 1)::Int, exps::Ptr{Int}, parent(a)::Ref{($rtype)})::Nothing return a end @@ -885,31 +746,23 @@ for (etype, rtype, ftype, ctype) in ( # No sort is performed, so this is unsafe function set_exponent_vector!(a::($etype), n::Int, exps::Vector{ZZRingElem}) if n > length(a) - ccall((:fmpz_mod_mpoly_resize, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, n, parent(a)) + @ccall libflint.fmpz_mod_mpoly_resize(a::Ref{($etype)}, n::Int, parent(a)::Ref{($rtype)})::Nothing end - ccall((:fmpz_mod_mpoly_set_term_exp_fmpz, libflint), Nothing, - (Ref{($etype)}, Int, Ptr{ZZRingElem}, Ref{($rtype)}), - a, n - 1, exps, parent(a)) + @ccall libflint.fmpz_mod_mpoly_set_term_exp_fmpz(a::Ref{($etype)}, (n - 1)::Int, exps::Ptr{ZZRingElem}, parent(a)::Ref{($rtype)})::Nothing return a end # Return j-th coordinate of i-th exponent vector function exponent(a::($etype), i::Int, j::Int) (j < 1 || j > nvars(parent(a))) && error("Invalid variable index") - return ccall((:fmpz_mod_mpoly_get_term_var_exp_ui, libflint), Int, - (Ref{($etype)}, Int, Int, Ref{($rtype)}), - a, i - 1, j - 1, parent(a)) + return @ccall libflint.fmpz_mod_mpoly_get_term_var_exp_ui(a::Ref{($etype)}, (i - 1)::Int, (j - 1)::Int, parent(a)::Ref{($rtype)})::Int end # Return the coefficient of the term with the given exponent vector # Return zero if there is no such term function coeff(a::($etype), exps::Vector{UInt}) z = ZZRingElem() - ccall((:fmpz_mod_mpoly_get_coeff_fmpz_ui, libflint), UInt, - (Ref{ZZRingElem}, Ref{($etype)}, Ptr{UInt}, Ref{($rtype)}), - z, a, exps, parent(a)) + @ccall libflint.fmpz_mod_mpoly_get_coeff_fmpz_ui(z::Ref{ZZRingElem}, a::Ref{($etype)}, exps::Ptr{UInt}, parent(a)::Ref{($rtype)})::UInt return base_ring(parent(a))(z) end @@ -917,27 +770,21 @@ for (etype, rtype, ftype, ctype) in ( # Return zero if there is no such term function coeff(a::($etype), exps::Vector{Int}) z = ZZRingElem() - ccall((:fmpz_mod_mpoly_get_coeff_fmpz_ui, libflint), UInt, - (Ref{ZZRingElem}, Ref{($etype)}, Ptr{Int}, Ref{($rtype)}), - z, a, exps, parent(a)) + @ccall libflint.fmpz_mod_mpoly_get_coeff_fmpz_ui(z::Ref{ZZRingElem}, a::Ref{($etype)}, exps::Ptr{Int}, parent(a)::Ref{($rtype)})::UInt return base_ring(parent(a))(z) end # Set the coefficient of the term with the given exponent vector to the # given ZZRingElem. Removal of a zero term is performed. function setcoeff!(a::($etype), exps::Vector{UInt}, b::($ctype)) - ccall((:fmpz_mod_mpoly_set_coeff_fmpz_ui, libflint), Nothing, - (Ref{($etype)}, Ref{ZZRingElem}, Ptr{UInt}, Ref{($rtype)}), - a, data(b), exps, parent(a)) + @ccall libflint.fmpz_mod_mpoly_set_coeff_fmpz_ui(a::Ref{($etype)}, data(b)::Ref{ZZRingElem}, exps::Ptr{UInt}, parent(a)::Ref{($rtype)})::Nothing return a end # Set the coefficient of the term with the given exponent vector to the # given ZZRingElem. Removal of a zero term is performed. function setcoeff!(a::($etype), exps::Vector{Int}, b::($ctype)) - ccall((:fmpz_mod_mpoly_set_coeff_fmpz_ui, libflint), Nothing, - (Ref{($etype)}, Ref{ZZRingElem}, Ptr{Int}, Ref{($rtype)}), - a, data(b), exps, parent(a)) + @ccall libflint.fmpz_mod_mpoly_set_coeff_fmpz_ui(a::Ref{($etype)}, data(b)::Ref{ZZRingElem}, exps::Ptr{Int}, parent(a)::Ref{($rtype)})::Nothing return a end @@ -951,26 +798,20 @@ for (etype, rtype, ftype, ctype) in ( # out of order. Note that like terms are not combined and zeros are not # removed. For that, call combine_like_terms! function sort_terms!(a::($etype)) - ccall((:fmpz_mod_mpoly_sort_terms, libflint), Nothing, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a)) + @ccall libflint.fmpz_mod_mpoly_sort_terms(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return a end # Return the i-th term of the polynomial, as a polynomial function term(a::($etype), i::Int) z = parent(a)() - ccall((:fmpz_mod_mpoly_get_term, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpz_mod_mpoly_get_term(z::Ref{($etype)}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Nothing return z end # Sets the given polynomial m to the i-th monomial of the polynomial function monomial!(m::($etype), a::($etype), i::Int) - ccall((:fmpz_mod_mpoly_get_term_monomial, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, Ref{($rtype)}), - m, a, i - 1, a.parent) + @ccall libflint.fmpz_mod_mpoly_get_term_monomial(m::Ref{($etype)}, a::Ref{($etype)}, (i - 1)::Int, a.parent::Ref{($rtype)})::Nothing return m end diff --git a/src/flint/fmpz_mod_poly.jl b/src/flint/fmpz_mod_poly.jl index ac6982c31..03b98dbf4 100644 --- a/src/flint/fmpz_mod_poly.jl +++ b/src/flint/fmpz_mod_poly.jl @@ -35,20 +35,18 @@ end function length(x::T) where {T <: Zmodn_fmpz_poly} return x.length - # return ccall((:fmpz_mod_poly_length, libflint), Int, (Ref{T}, Ref{fmpz_mod_ctx_struct}), x, x.parent.base_ring.ninv) + # return @ccall libflint.fmpz_mod_poly_length(x::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Int end function degree(x::T) where {T <: Zmodn_fmpz_poly} return x.length - 1 - # return ccall((:fmpz_mod_poly_degree, libflint), Int, (Ref{T}, Ref{fmpz_mod_ctx_struct}), x, x.parent.base_ring.ninv) + # return @ccall libflint.fmpz_mod_poly_degree(x::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Int end function coeff(x::T, n::Int) where {T <: Zmodn_fmpz_poly} n < 0 && throw(DomainError(n, "Index must be non-negative")) z = ZZRingElem() - ccall((:fmpz_mod_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{T}, Int, Ref{fmpz_mod_ctx_struct}), - z, x, n, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{T}, n::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return base_ring(x)(z) end @@ -136,27 +134,21 @@ canonical_unit(a::Zmodn_fmpz_poly) = canonical_unit(leading_coefficient(a)) function +(x::T, y::T) where {T <: Zmodn_fmpz_poly} check_parent(x,y) z = parent(x)() - ccall((:fmpz_mod_poly_add, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_add(z::Ref{T}, x::Ref{T}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function -(x::T, y::T) where {T <: Zmodn_fmpz_poly} check_parent(x,y) z = parent(x)() - ccall((:fmpz_mod_poly_sub, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_sub(z::Ref{T}, x::Ref{T}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function *(x::T, y::T) where {T <: Zmodn_fmpz_poly} check_parent(x,y) z = parent(x)() - ccall((:fmpz_mod_poly_mul, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_mul(z::Ref{T}, x::Ref{T}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -168,9 +160,7 @@ end function *(x::ZZModPolyRingElem, y::ZZRingElem) z = parent(x)() - ccall((:fmpz_mod_poly_scalar_mul_fmpz, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_mul_fmpz(z::Ref{ZZModPolyRingElem}, x::Ref{ZZModPolyRingElem}, y::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -189,9 +179,7 @@ end function +(x::ZZModPolyRingElem, y::Int) z = parent(x)() - ccall((:fmpz_mod_poly_add_si, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_add_si(z::Ref{ZZModPolyRingElem}, x::Ref{ZZModPolyRingElem}, y::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -199,10 +187,7 @@ end function +(x::ZZModPolyRingElem, y::ZZRingElem) z = parent(x)() - ccall((:fmpz_mod_poly_add_fmpz, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_add_fmpz(z::Ref{ZZModPolyRingElem}, x::Ref{ZZModPolyRingElem}, y::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -221,35 +206,25 @@ end function -(x::ZZModPolyRingElem, y::Int) z = parent(x)() - ccall((:fmpz_mod_poly_sub_si, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_sub_si(z::Ref{ZZModPolyRingElem}, x::Ref{ZZModPolyRingElem}, y::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function -(x::Int, y::ZZModPolyRingElem) z = parent(y)() - ccall((:fmpz_mod_poly_si_sub, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Int, Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - z, x, y, y.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_si_sub(z::Ref{ZZModPolyRingElem}, x::Int, y::Ref{ZZModPolyRingElem}, y.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function -(x::ZZModPolyRingElem, y::ZZRingElem) z = parent(x)() - ccall((:fmpz_mod_poly_sub_fmpz, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_sub_fmpz(z::Ref{ZZModPolyRingElem}, x::Ref{ZZModPolyRingElem}, y::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function -(x::ZZRingElem, y::ZZModPolyRingElem) z = parent(y)() - ccall((:fmpz_mod_poly_fmpz_sub, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{ZZRingElem}, Ref{ZZModPolyRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, x, y, y.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_fmpz_sub(z::Ref{ZZModPolyRingElem}, x::Ref{ZZRingElem}, y::Ref{ZZModPolyRingElem}, y.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -276,9 +251,7 @@ end function ^(x::T, y::Int) where {T <: Zmodn_fmpz_poly} y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() - ccall((:fmpz_mod_poly_pow, libflint), Nothing, - (Ref{T}, Ref{T}, UInt, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_pow(z::Ref{T}, x::Ref{T}, y::UInt, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -290,9 +263,7 @@ end function ==(x::T, y::T) where {T <: Zmodn_fmpz_poly} check_parent(x, y) - return Bool(ccall((:fmpz_mod_poly_equal, libflint), Cint, - (Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - x, y, x.parent.base_ring.ninv)) + return Bool(@ccall libflint.fmpz_mod_poly_equal(x::Ref{T}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Cint) end ################################################################################ @@ -307,9 +278,7 @@ function ==(x::ZZModPolyRingElem, y::ZZModRingElem) return false elseif length(x) == 1 u = ZZRingElem() - ccall((:fmpz_mod_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZModPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - u, x, 0, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_get_coeff_fmpz(u::Ref{ZZRingElem}, x::Ref{ZZModPolyRingElem}, 0::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return u == y else return iszero(y) @@ -333,9 +302,7 @@ function truncate(a::T, n::Int) where {T <: Zmodn_fmpz_poly} return z end - ccall((:fmpz_mod_poly_truncate, libflint), Nothing, - (Ref{T}, Int, Ref{fmpz_mod_ctx_struct}), - z, n, z.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_truncate(z::Ref{T}, n::Int, z.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -344,9 +311,7 @@ function mullow(x::T, y::T, n::Int) where {T <: Zmodn_fmpz_poly} n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() - ccall((:fmpz_mod_poly_mullow, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Int, Ref{fmpz_mod_ctx_struct}), - z, x, y, n, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_mullow(z::Ref{T}, x::Ref{T}, y::Ref{T}, n::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -359,9 +324,7 @@ end function reverse(x::T, len::Int) where {T <: Zmodn_fmpz_poly} len < 0 && throw(DomainError(len, "Length must be non-negative")) z = parent(x)() - ccall((:fmpz_mod_poly_reverse, libflint), Nothing, - (Ref{T}, Ref{T}, Int, Ref{fmpz_mod_ctx_struct}), - z, x, len, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_reverse(z::Ref{T}, x::Ref{T}, len::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -374,18 +337,14 @@ end function shift_left(x::T, len::Int) where {T <: Zmodn_fmpz_poly} len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:fmpz_mod_poly_shift_left, libflint), Nothing, - (Ref{T}, Ref{T}, Int, Ref{fmpz_mod_ctx_struct}), - z, x, len, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_shift_left(z::Ref{T}, x::Ref{T}, len::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function shift_right(x::T, len::Int) where {T <: Zmodn_fmpz_poly} len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:fmpz_mod_poly_shift_right, libflint), Nothing, - (Ref{T}, Ref{T}, Int, Ref{fmpz_mod_ctx_struct}), - z, x, len, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_shift_right(z::Ref{T}, x::Ref{T}, len::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -401,9 +360,7 @@ function divexact(x::T, y::T; check::Bool=true) where {T <: Zmodn_fmpz_poly} d = ZZRingElem() q = parent(x)() r = parent(x)() - ccall((:fmpz_mod_poly_divrem_f, libflint), Nothing, - (Ref{ZZRingElem}, Ref{T}, Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - d, q, r, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_divrem_f(d::Ref{ZZRingElem}, q::Ref{T}, r::Ref{T}, x::Ref{T}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing _is_one_or_throw(d, y) return q end @@ -420,28 +377,21 @@ function divexact(x::ZZModPolyRingElem, y::ZZModRingElem; check::Bool=true) base_ring(x) != parent(y) && error("Elements must have same parent") iszero(y) && throw(DivideError()) q = parent(x)() - ccall((:fmpz_mod_poly_scalar_div_fmpz, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - q, x, y.data, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_div_fmpz(q::Ref{ZZModPolyRingElem}, x::Ref{ZZModPolyRingElem}, y.data::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return q end function divexact(x::T, y::ZZRingElem; check::Bool=true) where {T <: Zmodn_fmpz_poly} iszero(y) && throw(DivideError()) q = parent(x)() - ccall((:fmpz_mod_poly_scalar_div_fmpz, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - q, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_div_fmpz(q::Ref{T}, x::Ref{T}, y::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return q end function divexact(x::T, y::Int; check::Bool=true) where {T <: Zmodn_fmpz_poly} y == 0 && throw(DivideError()) q = parent(x)() - ccall((:fmpz_mod_poly_scalar_div_fmpz, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - q, x, ZZRingElem(y), x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_div_fmpz(q::Ref{T}, x::Ref{T}, ZZRingElem(y)::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return q end @@ -457,9 +407,7 @@ function Base.divrem(x::T, y::T) where {T <: Zmodn_fmpz_poly} q = parent(x)() r = parent(x)() d = ZZRingElem() - ccall((:fmpz_mod_poly_divrem_f, libflint), Nothing, - (Ref{ZZRingElem}, Ref{T}, Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - d, q, r, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_divrem_f(d::Ref{ZZRingElem}, q::Ref{T}, r::Ref{T}, x::Ref{T}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing _is_one_or_throw(d, y) return q, r end @@ -513,10 +461,7 @@ end function AbstractAlgebra.gcd_basecase(x::ZZModPolyRingElem, y::ZZModPolyRingElem) z = parent(x)() f = ZZRingElem() - ccall((:fmpz_mod_poly_gcd_euclidean_f, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZModPolyRingElem}, - Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - f, z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_gcd_euclidean_f(f::Ref{ZZRingElem}, z::Ref{ZZModPolyRingElem}, x::Ref{ZZModPolyRingElem}, y::Ref{ZZModPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing _is_one_or_throw(f, y) return z end @@ -527,10 +472,7 @@ function AbstractAlgebra.gcdx_basecase(x::ZZModPolyRingElem, y::ZZModPolyRingEle s = parent(x)() t = parent(x)() f = ZZRingElem() - ccall((:fmpz_mod_poly_xgcd_euclidean_f, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, - Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - f, g, s, t, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_xgcd_euclidean_f(f::Ref{ZZRingElem}, g::Ref{ZZModPolyRingElem}, s::Ref{ZZModPolyRingElem}, t::Ref{ZZModPolyRingElem}, x::Ref{ZZModPolyRingElem}, y::Ref{ZZModPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing _is_one_or_throw(f, y) return g, s, t end @@ -541,10 +483,7 @@ function AbstractAlgebra.gcdinv_basecase(x::ZZModPolyRingElem, y::ZZModPolyRingE g = parent(x)() s = parent(x)() f = ZZRingElem() - ccall((:fmpz_mod_poly_gcdinv_euclidean_f, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, - Ref{ZZModPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - f, g, s, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_gcdinv_euclidean_f(f::Ref{ZZRingElem}, g::Ref{ZZModPolyRingElem}, s::Ref{ZZModPolyRingElem}, x::Ref{ZZModPolyRingElem}, y::Ref{ZZModPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing _is_one_or_throw(f, y) return g, s end @@ -564,9 +503,7 @@ function invmod(x::T, y::T) where {T <: Zmodn_fmpz_poly} return parent(x)(inv(evaluate(x, coeff(y, 0)))) end z = parent(x)() - r = ccall((:fmpz_mod_poly_invmod, libflint), Cint, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + r = @ccall libflint.fmpz_mod_poly_invmod(z::Ref{T}, x::Ref{T}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Cint r == 0 ? error("Impossible inverse in invmod") : return z end @@ -574,9 +511,7 @@ function mulmod(x::T, y::T, z::T) where {T <: Zmodn_fmpz_poly} check_parent(x, y) check_parent(y, z) w = parent(x)() - ccall((:fmpz_mod_poly_mulmod, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - w, x, y, z, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_mulmod(w::Ref{T}, x::Ref{T}, y::Ref{T}, z::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return w end @@ -592,9 +527,7 @@ function powermod(x::T, e::Int, y::T) where {T <: Zmodn_fmpz_poly} e = -e end - ccall((:fmpz_mod_poly_powmod_ui_binexp, libflint), Nothing, - (Ref{T}, Ref{T}, UInt, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, e, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_powmod_ui_binexp(z::Ref{T}, x::Ref{T}, e::UInt, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -610,9 +543,7 @@ function powermod(x::T, e::ZZRingElem, y::T) where {T <: Zmodn_fmpz_poly} e = -e end - ccall((:fmpz_mod_poly_powmod_fmpz_binexp, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{ZZRingElem}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, e, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_powmod_fmpz_binexp(z::Ref{T}, x::Ref{T}, e::Ref{ZZRingElem}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -627,9 +558,7 @@ function resultant(x::T, y::T) where {T <: Zmodn_fmpz_poly} z = parent(x)() !is_probable_prime(modulus(x)) && error("Modulus not prime in resultant") r = ZZRingElem() - ccall((:fmpz_mod_poly_resultant, libflint), Nothing, - (Ref{ZZRingElem}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - r, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_resultant(r::Ref{ZZRingElem}, x::Ref{T}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return base_ring(x)(r) end @@ -642,9 +571,7 @@ end function evaluate(x::ZZModPolyRingElem, y::ZZModRingElem) base_ring(x) != parent(y) && error("Elements must have same parent") z = ZZRingElem() - ccall((:fmpz_mod_poly_evaluate_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZModPolyRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z, x, y.data, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_evaluate_fmpz(z::Ref{ZZRingElem}, x::Ref{ZZModPolyRingElem}, y.data::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return parent(y)(z) end @@ -656,9 +583,7 @@ end function derivative(x::T) where {T <: Zmodn_fmpz_poly} z = parent(x)() - ccall((:fmpz_mod_poly_derivative, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_derivative(z::Ref{T}, x::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -687,9 +612,7 @@ end function AbstractAlgebra._compose_right(x::T, y::T) where {T <: Zmodn_fmpz_poly} check_parent(x, y) z = parent(x)() - ccall((:fmpz_mod_poly_compose, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_compose(z::Ref{T}, x::Ref{T}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -708,9 +631,7 @@ specifies the ring to lift into. """ function lift(R::ZZPolyRing, y::ZZModPolyRingElem) z = ZZPolyRingElem() - ccall((:fmpz_mod_poly_get_fmpz_poly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - z, y, y.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_get_fmpz_poly(z::Ref{ZZPolyRingElem}, y::Ref{ZZModPolyRingElem}, y.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing z.parent = R return z end @@ -723,9 +644,7 @@ end function is_irreducible(x::ZZModPolyRingElem) !is_probable_prime(modulus(x)) && error("Modulus not prime in is_irreducible") - return Bool(ccall((:fmpz_mod_poly_is_irreducible, libflint), Cint, - (Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - x, x.parent.base_ring.ninv)) + return Bool(@ccall libflint.fmpz_mod_poly_is_irreducible(x::Ref{ZZModPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Cint) end ################################################################################ @@ -736,9 +655,7 @@ end function is_squarefree(x::ZZModPolyRingElem) !is_probable_prime(modulus(x)) && error("Modulus not prime in is_squarefree") - return Bool(ccall((:fmpz_mod_poly_is_squarefree, libflint), Cint, - (Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - x, x.parent.base_ring.ninv)) + return Bool(@ccall libflint.fmpz_mod_poly_is_squarefree(x::Ref{ZZModPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Cint) end ################################################################################ @@ -757,16 +674,11 @@ end function _factor(x::ZZModPolyRingElem) n = x.parent.base_ring.ninv fac = fmpz_mod_poly_factor(n) - ccall((:fmpz_mod_poly_factor, libflint), UInt, - (Ref{fmpz_mod_poly_factor}, Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - fac, x, n) + @ccall libflint.fmpz_mod_poly_factor(fac::Ref{fmpz_mod_poly_factor}, x::Ref{ZZModPolyRingElem}, n::Ref{fmpz_mod_ctx_struct})::UInt res = Dict{ZZModPolyRingElem, Int}() for i in 1:fac.num f = parent(x)() - ccall((:fmpz_mod_poly_factor_get_fmpz_mod_poly, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{fmpz_mod_poly_factor}, Int, - Ref{fmpz_mod_ctx_struct}), - f, fac, i - 1, n) + @ccall libflint.fmpz_mod_poly_factor_get_fmpz_mod_poly(f::Ref{ZZModPolyRingElem}, fac::Ref{fmpz_mod_poly_factor}, (i - 1)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing e = unsafe_load(fac.exp, i) res[f] = e end @@ -783,16 +695,11 @@ end function _factor_squarefree(x::ZZModPolyRingElem) n = x.parent.base_ring.ninv fac = fmpz_mod_poly_factor(n) - ccall((:fmpz_mod_poly_factor_squarefree, libflint), UInt, - (Ref{fmpz_mod_poly_factor}, Ref{ZZModPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - fac, x, n) + @ccall libflint.fmpz_mod_poly_factor_squarefree(fac::Ref{fmpz_mod_poly_factor}, x::Ref{ZZModPolyRingElem}, n::Ref{fmpz_mod_ctx_struct})::UInt res = Dict{ZZModPolyRingElem, Int}() for i in 1:fac.num f = parent(x)() - ccall((:fmpz_mod_poly_factor_get_fmpz_mod_poly, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{fmpz_mod_poly_factor}, Int, - Ref{fmpz_mod_ctx_struct}), - f, fac, i - 1, n) + @ccall libflint.fmpz_mod_poly_factor_get_fmpz_mod_poly(f::Ref{ZZModPolyRingElem}, fac::Ref{fmpz_mod_poly_factor}, (i - 1)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing e = unsafe_load(fac.exp, i) res[f] = e end @@ -811,17 +718,11 @@ function factor_distinct_deg(x::ZZModPolyRingElem) degss = [ pointer(degs) ] n = x.parent.base_ring.ninv fac = fmpz_mod_poly_factor(n) - ccall((:fmpz_mod_poly_factor_distinct_deg, libflint), UInt, - (Ref{fmpz_mod_poly_factor}, Ref{ZZModPolyRingElem}, Ptr{Ptr{Int}}, - Ref{fmpz_mod_ctx_struct}), - fac, x, degss, n) + @ccall libflint.fmpz_mod_poly_factor_distinct_deg(fac::Ref{fmpz_mod_poly_factor}, x::Ref{ZZModPolyRingElem}, degss::Ptr{Ptr{Int}}, n::Ref{fmpz_mod_ctx_struct})::UInt res = Dict{Int, ZZModPolyRingElem}() for i in 1:fac.num f = parent(x)() - ccall((:fmpz_mod_poly_factor_get_fmpz_mod_poly, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{fmpz_mod_poly_factor}, Int, - Ref{fmpz_mod_ctx_struct}), - f, fac, i - 1, n) + @ccall libflint.fmpz_mod_poly_factor_get_fmpz_mod_poly(f::Ref{ZZModPolyRingElem}, fac::Ref{fmpz_mod_poly_factor}, (i - 1)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing res[degs[i]] = f end return res @@ -832,24 +733,16 @@ function roots(a::ZZModPolyRingElem) n = R.base_ring.ninv fac = fmpz_mod_poly_factor(n) if is_probable_prime(n.n) - ccall((:fmpz_mod_poly_roots, libflint), UInt, - (Ref{fmpz_mod_poly_factor}, Ref{ZZModPolyRingElem}, Cint, Ref{fmpz_mod_ctx_struct}), - fac, a, 0, n) + @ccall libflint.fmpz_mod_poly_roots(fac::Ref{fmpz_mod_poly_factor}, a::Ref{ZZModPolyRingElem}, 0::Cint, n::Ref{fmpz_mod_ctx_struct})::UInt else nfac = fmpz_factor() - ccall((:fmpz_factor, libflint), Nothing, - (Ref{fmpz_factor}, Ref{ZZRingElem}), - nfac, R.base_ring.n) - ccall((:fmpz_mod_poly_roots_factored, libflint), UInt, - (Ref{fmpz_mod_poly_factor}, Ref{ZZModPolyRingElem}, Cint, Ref{fmpz_factor}, Ref{fmpz_mod_ctx_struct}), - fac, a, 0, nfac, n) + @ccall libflint.fmpz_factor(nfac::Ref{fmpz_factor}, R.base_ring.n::Ref{ZZRingElem})::Nothing + @ccall libflint.fmpz_mod_poly_roots_factored(fac::Ref{fmpz_mod_poly_factor}, a::Ref{ZZModPolyRingElem}, 0::Cint, nfac::Ref{fmpz_factor}, n::Ref{fmpz_mod_ctx_struct})::UInt end f = R() res = ZZModRingElem[] for i in 1:fac.num - ccall((:fmpz_mod_poly_factor_get_fmpz_mod_poly, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{fmpz_mod_poly_factor}, Int, Ref{fmpz_mod_ctx_struct}), - f, fac, i - 1, n) + @ccall libflint.fmpz_mod_poly_factor_get_fmpz_mod_poly(f::Ref{ZZModPolyRingElem}, fac::Ref{fmpz_mod_poly_factor}, (i - 1)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing @assert isone(coeff(f, 1)) push!(res, -coeff(f, 0)) end @@ -864,51 +757,37 @@ end ################################################################################ function zero!(x::T) where {T <: Zmodn_fmpz_poly} - ccall((:fmpz_mod_poly_zero, libflint), Nothing, - (Ref{T}, Ref{fmpz_mod_ctx_struct}), - x, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_zero(x::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return x end function one!(x::T) where {T <: Zmodn_fmpz_poly} - ccall((:fmpz_mod_poly_one, libflint), Nothing, - (Ref{T}, Ref{fmpz_mod_ctx_struct}), - x, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_one(x::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return x end function neg!(z::T, x::T) where {T <: Zmodn_fmpz_poly} - ccall((:fmpz_mod_poly_neg, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_neg(z::Ref{T}, x::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function fit!(x::T, n::Int) where {T <: Zmodn_fmpz_poly} - ccall((:fmpz_mod_poly_fit_length, libflint), Nothing, - (Ref{T}, Int, Ref{fmpz_mod_ctx_struct}), - x, n, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_fit_length(x::Ref{T}, n::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return nothing end function setcoeff!(x::T, n::Int, y::UInt) where {T <: Zmodn_fmpz_poly} - ccall((:fmpz_mod_poly_set_coeff_ui, libflint), Nothing, - (Ref{T}, Int, UInt, Ref{fmpz_mod_ctx_struct}), - x, n, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_set_coeff_ui(x::Ref{T}, n::Int, y::UInt, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return x end function setcoeff!(x::T, n::Int, y::Int) where {T <: Zmodn_fmpz_poly} - ccall((:fmpz_mod_poly_set_coeff_si, libflint), Nothing, - (Ref{T}, Int, UInt, Ref{fmpz_mod_ctx_struct}), - x, n, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_set_coeff_si(x::Ref{T}, n::Int, y::UInt, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return x end function setcoeff!(x::T, n::Int, y::ZZRingElem) where {T <: Zmodn_fmpz_poly} - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{T}, Int, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - x, n, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(x::Ref{T}, n::Int, y::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return x end @@ -917,23 +796,17 @@ setcoeff!(x::T, n::Int, y::Integer) where {T <: Zmodn_fmpz_poly} = setcoeff!(x, setcoeff!(x::ZZModPolyRingElem, n::Int, y::ZZModRingElem) = setcoeff!(x, n, y.data) function add!(z::T, x::T, y::T) where {T <: Zmodn_fmpz_poly} - ccall((:fmpz_mod_poly_add, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_add(z::Ref{T}, x::Ref{T}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function sub!(z::T, x::T, y::T) where {T <: Zmodn_fmpz_poly} - ccall((:fmpz_mod_poly_sub, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_sub(z::Ref{T}, x::Ref{T}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function mul!(z::T, x::T, y::T) where {T <: Zmodn_fmpz_poly} - ccall((:fmpz_mod_poly_mul, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_mul(z::Ref{T}, x::Ref{T}, y::Ref{T}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end diff --git a/src/flint/fmpz_mod_rel_series.jl b/src/flint/fmpz_mod_rel_series.jl index 3c7083193..cf8f43b90 100644 --- a/src/flint/fmpz_mod_rel_series.jl +++ b/src/flint/fmpz_mod_rel_series.jl @@ -47,10 +47,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( if len > 0 c = ZZRingElem() while len > 0 - ccall((:fmpz_mod_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Int, - Ref{($ctype)}), - c, a, len - 1, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_get_coeff_fmpz(c::Ref{ZZRingElem}, a::Ref{($etype)}, (len - 1)::Int, a.parent.base_ring.ninv::Ref{($ctype)})::Nothing if !iszero(c) break end @@ -75,9 +72,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( return R(0) end z = ZZRingElem() - ccall((:fmpz_mod_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Int, Ref{($ctype)}), - z, x, n, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{($etype)}, n::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing return R(z) end @@ -114,10 +109,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( z.val = zprec else z.val = zval + i - ccall((:fmpz_mod_poly_shift_right, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, z, i, z.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_shift_right(z::Ref{($etype)}, z::Ref{($etype)}, i::Int, z.parent.base_ring.ninv::Ref{($ctype)})::Nothing end return nothing end @@ -172,10 +164,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( function -(x::($etype)) z = parent(x)() - ccall((:fmpz_mod_poly_neg, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($ctype)}), - z, x, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_neg(z::Ref{($etype)}, x::Ref{($etype)}, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing z.prec = x.prec z.val = x.val return z @@ -203,34 +192,19 @@ for (etype, rtype, ctype, mtype, brtype) in ( (Ref{($etype)}, Ref{($etype)}, Int, Ref{($ctype)}), z, b, max(0, lenz - b.val + a.val), p) - ccall((:fmpz_mod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, z, b.val - a.val, p) - ccall((:fmpz_mod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, z, a, lenz, p) + @ccall libflint.fmpz_mod_poly_shift_left(z::Ref{($etype)}, z::Ref{($etype)}, (b.val - a.val)::Int, p::Ref{($ctype)})::Nothing + @ccall libflint.fmpz_mod_poly_add_series(z::Ref{($etype)}, z::Ref{($etype)}, a::Ref{($etype)}, lenz::Int, p::Ref{($ctype)})::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:fmpz_mod_poly_set_trunc, libflint), Nothing, (Ref{($etype)}, Ref{($etype)}, Int, Ref{($ctype)}), z, a, max(0, lenz - a.val + b.val), p) - ccall((:fmpz_mod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, z, a.val - b.val, p) - ccall((:fmpz_mod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, z, b, lenz, p) + @ccall libflint.fmpz_mod_poly_shift_left(z::Ref{($etype)}, z::Ref{($etype)}, (a.val - b.val)::Int, p::Ref{($ctype)})::Nothing + @ccall libflint.fmpz_mod_poly_add_series(z::Ref{($etype)}, z::Ref{($etype)}, b::Ref{($etype)}, lenz::Int, p::Ref{($ctype)})::Nothing else lenz = max(lena, lenb) - ccall((:fmpz_mod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, a, b, lenz, p) + @ccall libflint.fmpz_mod_poly_add_series(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int, p::Ref{($ctype)})::Nothing end z.prec = prec z.val = val @@ -255,38 +229,20 @@ for (etype, rtype, ctype, mtype, brtype) in ( (Ref{($etype)}, Ref{($etype)}, Int, Ref{($ctype)}), z, b, max(0, lenz - b.val + a.val), p) - ccall((:fmpz_mod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, z, b.val - a.val, p) - ccall((:fmpz_mod_poly_neg, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($ctype)}), - z, z, p) - ccall((:fmpz_mod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, z, a, lenz, p) + @ccall libflint.fmpz_mod_poly_shift_left(z::Ref{($etype)}, z::Ref{($etype)}, (b.val - a.val)::Int, p::Ref{($ctype)})::Nothing + @ccall libflint.fmpz_mod_poly_neg(z::Ref{($etype)}, z::Ref{($etype)}, p::Ref{($ctype)})::Nothing + @ccall libflint.fmpz_mod_poly_add_series(z::Ref{($etype)}, z::Ref{($etype)}, a::Ref{($etype)}, lenz::Int, p::Ref{($ctype)})::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:fmpz_mod_poly_set_trunc, libflint), Nothing, (Ref{($etype)}, Ref{($etype)}, Int, Ref{($ctype)}), z, a, max(0, lenz - a.val + b.val), p) - ccall((:fmpz_mod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, z, a.val - b.val, p) - ccall((:fmpz_mod_poly_sub_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, z, b, lenz, p) + @ccall libflint.fmpz_mod_poly_shift_left(z::Ref{($etype)}, z::Ref{($etype)}, (a.val - b.val)::Int, p::Ref{($ctype)})::Nothing + @ccall libflint.fmpz_mod_poly_sub_series(z::Ref{($etype)}, z::Ref{($etype)}, b::Ref{($etype)}, lenz::Int, p::Ref{($ctype)})::Nothing else lenz = max(lena, lenb) - ccall((:fmpz_mod_poly_sub_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, a, b, lenz, p) + @ccall libflint.fmpz_mod_poly_sub_series(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int, p::Ref{($ctype)})::Nothing end z.prec = prec z.val = val @@ -310,10 +266,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( return z end lenz = min(lena + lenb - 1, prec) - ccall((:fmpz_mod_poly_mullow, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, a, b, lenz, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_mullow(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int, a.parent.base_ring.ninv::Ref{($ctype)})::Nothing renormalize!(z) return z end @@ -328,10 +281,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( z = parent(y)() z.prec = y.prec z.val = y.val - ccall((:fmpz_mod_poly_scalar_mul_fmpz, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, - Ref{($ctype)}), - z, y, x.data, y.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_mul_fmpz(z::Ref{($etype)}, y::Ref{($etype)}, x.data::Ref{ZZRingElem}, y.parent.base_ring.ninv::Ref{($ctype)})::Nothing renormalize!(z) return z end @@ -342,10 +292,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( z = parent(y)() z.prec = y.prec z.val = y.val - ccall((:fmpz_mod_poly_scalar_mul_fmpz, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, - Ref{($ctype)}), - z, y, x, y.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_mul_fmpz(z::Ref{($etype)}, y::Ref{($etype)}, x::Ref{ZZRingElem}, y.parent.base_ring.ninv::Ref{($ctype)})::Nothing renormalize!(z) return z end @@ -384,10 +331,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( z.prec = max(0, x.prec - len) z.val = max(0, xval - len) zlen = min(xlen + xval - len, xlen) - ccall((:fmpz_mod_poly_shift_right, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, x, xlen - zlen, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_shift_right(z::Ref{($etype)}, x::Ref{($etype)}, (xlen - zlen)::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing renormalize!(z) end return z @@ -448,10 +392,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( z = parent(a)() z.prec = a.prec + (b - 1)*valuation(a) z.val = b*valuation(a) - ccall((:fmpz_mod_poly_pow_trunc, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt, Int, - Ref{($ctype)}), - z, a, b, z.prec - z.val, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_pow_trunc(z::Ref{($etype)}, a::Ref{($etype)}, b::UInt, (z.prec - z.val)::Int, a.parent.base_ring.ninv::Ref{($ctype)})::Nothing end renormalize!(z) return z @@ -477,10 +418,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( if xlen != ylen return false end - return Bool(ccall((:fmpz_mod_poly_equal_trunc, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - x, y, xlen, y.parent.base_ring.ninv)) + return Bool(@ccall libflint.fmpz_mod_poly_equal_trunc(x::Ref{($etype)}, y::Ref{($etype)}, xlen::Int, y.parent.base_ring.ninv::Ref{($ctype)})::Cint) end function isequal(x::($etype), y::($etype)) @@ -490,9 +428,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( if x.prec != y.prec || x.val != y.val || pol_length(x) != pol_length(y) return false end - return Bool(ccall((:fmpz_mod_poly_equal, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($ctype)}), - x, y, x.parent.base_ring.ninv)) + return Bool(@ccall libflint.fmpz_mod_poly_equal(x::Ref{($etype)}, y::Ref{($etype)}, x.parent.base_ring.ninv::Ref{($ctype)})::Cint) end ############################################################################### @@ -509,13 +445,8 @@ for (etype, rtype, ctype, mtype, brtype) in ( elseif pol_length(x) == 1 if x.val == 0 z = ZZRingElem() - ccall((:fmpz_mod_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, x, 0, x.parent.base_ring.ninv) - return Bool(ccall((:fmpz_equal, libflint), Cint, - (Ref{ZZRingElem}, Ref{ZZRingElem}), - z, y.data)) + @ccall libflint.fmpz_mod_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{($etype)}, 0::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing + return Bool(@ccall libflint.fmpz_equal(z::Ref{ZZRingElem}, y.data::Ref{ZZRingElem})::Cint) else return false end @@ -534,14 +465,9 @@ for (etype, rtype, ctype, mtype, brtype) in ( elseif pol_length(x) == 1 if x.val == 0 z = ZZRingElem() - ccall((:fmpz_mod_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, x, 0, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{($etype)}, 0::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing r = mod(y, modulus(x)) - return Bool(ccall((:fmpz_equal, libflint), Cint, - (Ref{ZZRingElem}, Ref{ZZRingElem}), - z, r)) + return Bool(@ccall libflint.fmpz_equal(z::Ref{ZZRingElem}, r::Ref{ZZRingElem})::Cint) else return false end @@ -580,10 +506,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( z.val = xval - yval z.prec = prec + z.val if prec != 0 - ccall((:fmpz_mod_poly_div_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, x, y, prec, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_div_series(z::Ref{($etype)}, x::Ref{($etype)}, y::Ref{($etype)}, prec::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing end return z end @@ -599,10 +522,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( z = parent(x)() z.prec = x.prec z.val = x.val - ccall((:fmpz_mod_poly_scalar_div_fmpz, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, - Ref{($ctype)}), - z, x, y.data, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_div_fmpz(z::Ref{($etype)}, x::Ref{($etype)}, y.data::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -613,10 +533,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( z.prec = x.prec z.val = x.val r = mod(y, modulus(x)) - ccall((:fmpz_mod_poly_scalar_div_fmpz, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, - Ref{($ctype)}), - z, x, r, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_div_fmpz(z::Ref{($etype)}, x::Ref{($etype)}, r::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -634,10 +551,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( ainv = parent(a)() ainv.prec = a.prec ainv.val = 0 - ccall((:fmpz_mod_poly_inv_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - ainv, a, a.prec, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_inv_series(ainv::Ref{($etype)}, a::Ref{($etype)}, a.prec::Int, a.parent.base_ring.ninv::Ref{($ctype)})::Nothing return ainv end @@ -686,41 +600,31 @@ for (etype, rtype, ctype, mtype, brtype) in ( ############################################################################### function zero!(x::($etype)) - ccall((:fmpz_mod_poly_zero, libflint), Nothing, - (Ref{($etype)}, Ref{($ctype)}), - x, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_zero(x::Ref{($etype)}, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing x.prec = parent(x).prec_max x.val = parent(x).prec_max return x end function one!(x::($etype)) - ccall((:fmpz_mod_poly_one, libflint), Nothing, - (Ref{($etype)}, Ref{($ctype)}), - x, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_one(x::Ref{($etype)}, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing x.prec = parent(x).prec_max x.val = 0 return x end function fit!(x::($etype), n::Int) - ccall((:fmpz_mod_poly_fit_length, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($ctype)}), - x, n, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_fit_length(x::Ref{($etype)}, n::Int, x.parent.base_ring.ninv::Ref{($ctype)})::Nothing return nothing end function setcoeff!(z::($etype), n::Int, x::ZZRingElem) - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{($etype)}, Int, Ref{ZZRingElem}, Ref{($ctype)}), - z, n, x, z.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{($etype)}, n::Int, x::Ref{ZZRingElem}, z.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end function setcoeff!(z::($etype), n::Int, x::($mtype)) - ccall((:fmpz_mod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{($etype)}, Int, Ref{ZZRingElem}, Ref{($ctype)}), - z, n, x.data, z.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{($etype)}, n::Int, x.data::Ref{ZZRingElem}, z.parent.base_ring.ninv::Ref{($ctype)})::Nothing return z end @@ -738,10 +642,7 @@ for (etype, rtype, ctype, mtype, brtype) in ( if lena <= 0 || lenb <= 0 lenz = 0 end - ccall((:fmpz_mod_poly_mullow, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - z, a, b, lenz, z.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_mullow(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int, z.parent.base_ring.ninv::Ref{($ctype)})::Nothing renormalize!(z) return z end @@ -762,33 +663,18 @@ for (etype, rtype, ctype, mtype, brtype) in ( (Ref{($etype)}, Ref{($etype)}, Int, Ref{($ctype)}), z, b, max(0, lenz - b.val + a.val), p) - ccall((:fmpz_mod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - z, z, b.val - a.val, p) - ccall((:fmpz_mod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - a, a, z, lenz, p) + @ccall libflint.fmpz_mod_poly_shift_left(z::Ref{($etype)}, z::Ref{($etype)}, (b.val - a.val)::Int, p::Ref{($ctype)})::Nothing + @ccall libflint.fmpz_mod_poly_add_series(a::Ref{($etype)}, a::Ref{($etype)}, z::Ref{($etype)}, lenz::Int, p::Ref{($ctype)})::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:fmpz_mod_poly_truncate, libflint), Nothing, (Ref{($etype)}, Int, Ref{($ctype)}), a, max(0, lenz - a.val + b.val), p) - ccall((:fmpz_mod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - a, a, a.val - b.val, p) - ccall((:fmpz_mod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - a, a, b, lenz, p) + @ccall libflint.fmpz_mod_poly_shift_left(a::Ref{($etype)}, a::Ref{($etype)}, (a.val - b.val)::Int, p::Ref{($ctype)})::Nothing + @ccall libflint.fmpz_mod_poly_add_series(a::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int, p::Ref{($ctype)})::Nothing else lenz = max(lena, lenb) - ccall((:fmpz_mod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - a, a, b, lenz, p) + @ccall libflint.fmpz_mod_poly_add_series(a::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int, p::Ref{($ctype)})::Nothing end a.prec = prec a.val = val @@ -815,34 +701,19 @@ for (etype, rtype, ctype, mtype, brtype) in ( (Ref{($etype)}, Ref{($etype)}, Int, Ref{($ctype)}), c, b, max(0, lenc - b.val + a.val), p) - ccall((:fmpz_mod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - c, c, b.val - a.val, p) - ccall((:fmpz_mod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - c, c, a, lenc, p) + @ccall libflint.fmpz_mod_poly_shift_left(c::Ref{($etype)}, c::Ref{($etype)}, (b.val - a.val)::Int, p::Ref{($ctype)})::Nothing + @ccall libflint.fmpz_mod_poly_add_series(c::Ref{($etype)}, c::Ref{($etype)}, a::Ref{($etype)}, lenc::Int, p::Ref{($ctype)})::Nothing elseif b.val < a.val lenc = max(lena + a.val - b.val, lenb) ccall((:fmpz_mod_poly_set_trunc, libflint), Nothing, (Ref{($etype)}, Ref{($etype)}, Int, Ref{($ctype)}), c, a, max(0, lenc - a.val + b.val), p) - ccall((:fmpz_mod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, - Ref{($ctype)}), - c, c, a.val - b.val, p) - ccall((:fmpz_mod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - c, c, b, lenc, p) + @ccall libflint.fmpz_mod_poly_shift_left(c::Ref{($etype)}, c::Ref{($etype)}, (a.val - b.val)::Int, p::Ref{($ctype)})::Nothing + @ccall libflint.fmpz_mod_poly_add_series(c::Ref{($etype)}, c::Ref{($etype)}, b::Ref{($etype)}, lenc::Int, p::Ref{($ctype)})::Nothing else lenc = max(lena, lenb) - ccall((:fmpz_mod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int, Ref{($ctype)}), - c, a, b, lenc, p) + @ccall libflint.fmpz_mod_poly_add_series(c::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenc::Int, p::Ref{($ctype)})::Nothing end c.prec = prec c.val = val @@ -989,10 +860,7 @@ function sqrt_classical(a::FpRelPowerSeriesRingElem; check::Bool=true) s = sqrt(c; check=check) end a = divexact(a, c) - ccall((:fmpz_mod_poly_sqrt_series, libflint), Nothing, - (Ref{FpRelPowerSeriesRingElem}, Ref{FpRelPowerSeriesRingElem}, - Int, Ref{fmpz_mod_ctx_struct}), - z, a, a.prec, a.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_sqrt_series(z::Ref{FpRelPowerSeriesRingElem}, a::Ref{FpRelPowerSeriesRingElem}, a.prec::Int, a.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing if !isone(s) z *= s end diff --git a/src/flint/fmpz_mpoly.jl b/src/flint/fmpz_mpoly.jl index 5f1520ffb..19f3f7823 100644 --- a/src/flint/fmpz_mpoly.jl +++ b/src/flint/fmpz_mpoly.jl @@ -20,13 +20,12 @@ symbols(a::ZZMPolyRing) = a.S parent(a::ZZMPolyRingElem) = a.parent -number_of_variables(a::ZZMPolyRing) = ccall((:fmpz_mpoly_ctx_nvars, libflint), Int, - (Ref{ZZMPolyRing}, ), a) +number_of_variables(a::ZZMPolyRing) = @ccall libflint.fmpz_mpoly_ctx_nvars(a::Ref{ZZMPolyRing})::Int base_ring(a::ZZMPolyRing) = ZZ function internal_ordering(a::ZZMPolyRing) - b = ccall((:fmpz_mpoly_ctx_ord, libflint), Cint, (Ref{ZZMPolyRing}, ), a) + b = @ccall libflint.fmpz_mpoly_ctx_ord(a::Ref{ZZMPolyRing})::Cint return flint_orderings[b + 1] end @@ -34,8 +33,7 @@ function gens(R::ZZMPolyRing) A = Vector{ZZMPolyRingElem}(undef, R.nvars) for i = 1:R.nvars z = R() - ccall((:fmpz_mpoly_gen, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), z, i - 1, R) + @ccall libflint.fmpz_mpoly_gen(z::Ref{ZZMPolyRingElem}, (i - 1)::Int, R::Ref{ZZMPolyRing})::Nothing A[i] = z end return A @@ -45,8 +43,7 @@ function gen(R::ZZMPolyRing, i::Int) n = nvars(R) (i <= 0 || i > n) && error("Index must be between 1 and $n") z = R() - ccall((:fmpz_mpoly_gen, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), z, i - 1, R) + @ccall libflint.fmpz_mpoly_gen(z::Ref{ZZMPolyRingElem}, (i - 1)::Int, R::Ref{ZZMPolyRing})::Nothing return z end @@ -54,9 +51,7 @@ function is_gen(a::ZZMPolyRingElem, i::Int) n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") R = parent(a) - return Bool(ccall((:fmpz_mpoly_is_gen, libflint), Cint, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - a, i - 1, a.parent)) + return Bool(@ccall libflint.fmpz_mpoly_is_gen(a::Ref{ZZMPolyRingElem}, (i - 1)::Int, a.parent::Ref{ZZMPolyRing})::Cint) end function is_gen(a::ZZMPolyRingElem) @@ -69,14 +64,12 @@ end function deepcopy_internal(a::ZZMPolyRingElem, dict::IdDict) z = parent(a)() - ccall((:fmpz_mpoly_set, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - z, a, a.parent) + @ccall libflint.fmpz_mpoly_set(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return z end function length(a::ZZMPolyRingElem) - n = ccall((:fmpz_mpoly_length, libflint), Int, (Ref{ZZMPolyRingElem}, ), a) + n = @ccall libflint.fmpz_mpoly_length(a::Ref{ZZMPolyRingElem})::Int return n end @@ -85,14 +78,12 @@ one(R::ZZMPolyRing) = one!(R()) zero(R::ZZMPolyRing) = zero!(R()) function isone(a::ZZMPolyRingElem) - b = ccall((:fmpz_mpoly_is_one, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), a, a.parent) + b = @ccall libflint.fmpz_mpoly_is_one(a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Cint return Bool(b) end function iszero(a::ZZMPolyRingElem) - b = ccall((:fmpz_mpoly_is_zero, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), a, a.parent) + b = @ccall libflint.fmpz_mpoly_is_zero(a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Cint return Bool(b) end @@ -109,8 +100,7 @@ function is_unit(a::ZZMPolyRingElem) end function is_constant(a::ZZMPolyRingElem) - b = ccall((:fmpz_mpoly_is_fmpz, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), a, parent(a)) + b = @ccall libflint.fmpz_mpoly_is_fmpz(a::Ref{ZZMPolyRingElem}, parent(a)::Ref{ZZMPolyRing})::Cint return Bool(b) end @@ -130,9 +120,7 @@ function coeff(a::ZZMPolyRingElem, i::Int) n = length(a) # this check is not needed as fmpz_mpoly_get_term_coeff_fmpz throws (i < 1 || i > n) && error("Index must be between 1 and $(length(a))") - ccall((:fmpz_mpoly_get_term_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - z, a, i - 1, a.parent) + @ccall libflint.fmpz_mpoly_get_term_coeff_fmpz(z::Ref{ZZRingElem}, a::Ref{ZZMPolyRingElem}, (i - 1)::Int, a.parent::Ref{ZZMPolyRing})::Nothing return z end @@ -140,9 +128,7 @@ function coeff(a::ZZMPolyRingElem, b::ZZMPolyRingElem) check_parent(a, b) !isone(length(b)) && error("Second argument must be a monomial") z = ZZRingElem() - ccall((:fmpz_mpoly_get_coeff_fmpz_monomial, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mpoly_get_coeff_fmpz_monomial(z::Ref{ZZRingElem}, a::Ref{ZZMPolyRingElem}, b::Ref{ZZMPolyRingElem}, parent(a)::Ref{ZZMPolyRing})::Nothing return z end @@ -165,8 +151,7 @@ function degree(a::ZZMPolyRingElem, i::Int) n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") if degrees_fit_int(a) - d = ccall((:fmpz_mpoly_degree_si, libflint), Int, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), a, i - 1, a.parent) + d = @ccall libflint.fmpz_mpoly_degree_si(a::Ref{ZZMPolyRingElem}, (i - 1)::Int, a.parent::Ref{ZZMPolyRing})::Int return d else return Int(degree_fmpz(a, i)) @@ -178,16 +163,13 @@ function degree_fmpz(a::ZZMPolyRingElem, i::Int) n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") d = ZZRingElem() - ccall((:fmpz_mpoly_degree_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - d, a, i - 1, a.parent) + @ccall libflint.fmpz_mpoly_degree_fmpz(d::Ref{ZZRingElem}, a::Ref{ZZMPolyRingElem}, (i - 1)::Int, a.parent::Ref{ZZMPolyRing})::Nothing return d end # Return true if degrees fit into an Int function degrees_fit_int(a::ZZMPolyRingElem) - b = ccall((:fmpz_mpoly_degrees_fit_si, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), a, a.parent) + b = @ccall libflint.fmpz_mpoly_degrees_fit_si(a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Cint return Bool(b) end @@ -197,9 +179,7 @@ function degrees(a::ZZMPolyRingElem) throw(OverflowError("degrees of polynomial do not fit into Int")) end degs = Vector{Int}(undef, nvars(parent(a))) - ccall((:fmpz_mpoly_degrees_si, libflint), Nothing, - (Ptr{Int}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - degs, a, a.parent) + @ccall libflint.fmpz_mpoly_degrees_si(degs::Ptr{Int}, a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return degs end @@ -210,16 +190,13 @@ function degrees_fmpz(a::ZZMPolyRingElem) for i in 1:n degs[i] = ZZRingElem() end - ccall((:fmpz_mpoly_degrees_fmpz, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - degs, a, a.parent) + @ccall libflint.fmpz_mpoly_degrees_fmpz(degs::Ptr{Ref{ZZRingElem}}, a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return degs end # Return true if degree fits into an Int function total_degree_fits_int(a::ZZMPolyRingElem) - b = ccall((:fmpz_mpoly_total_degree_fits_si, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), a, a.parent) + b = @ccall libflint.fmpz_mpoly_total_degree_fits_si(a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Cint return Bool(b) end @@ -228,17 +205,14 @@ function total_degree(a::ZZMPolyRingElem) if !total_degree_fits_int(a) throw(OverflowError("Total degree of polynomial does not fit into Int")) end - d = ccall((:fmpz_mpoly_total_degree_si, libflint), Int, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), a, a.parent) + d = @ccall libflint.fmpz_mpoly_total_degree_si(a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Int return d end # Total degree as an ZZRingElem function total_degree_fmpz(a::ZZMPolyRingElem) d = ZZRingElem() - ccall((:fmpz_mpoly_total_degree_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - d, a, a.parent) + @ccall libflint.fmpz_mpoly_total_degree_fmpz(d::Ref{ZZRingElem}, a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return d end @@ -262,10 +236,7 @@ function coeff(a::ZZMPolyRingElem, vars::Vector{Int}, exps::Vector{Int}) error("Exponent cannot be negative") end end - ccall((:fmpz_mpoly_get_coeff_vars_ui, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ptr{Int}, - Ptr{Int}, Int, Ref{ZZMPolyRing}), - z, a, vars, exps, length(vars), a.parent) + @ccall libflint.fmpz_mpoly_get_coeff_vars_ui(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, vars::Ptr{Int}, exps::Ptr{Int}, length(vars)::Int, a.parent::Ref{ZZMPolyRing})::Nothing return z end @@ -277,9 +248,7 @@ end function -(a::ZZMPolyRingElem) z = parent(a)() - ccall((:fmpz_mpoly_neg, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - z, a, a.parent) + @ccall libflint.fmpz_mpoly_neg(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return z end @@ -340,18 +309,14 @@ end function ^(a::ZZMPolyRingElem, b::Int) b < 0 && throw(DomainError(b, "Exponent must be non-negative")) z = parent(a)() - ccall((:fmpz_mpoly_pow_ui, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mpoly_pow_ui(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, b::Int, parent(a)::Ref{ZZMPolyRing})::Nothing return z end function ^(a::ZZMPolyRingElem, b::ZZRingElem) b < 0 && throw(DomainError(b, "Exponent must be non-negative")) z = parent(a)() - ccall((:fmpz_mpoly_pow_fmpz, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZRingElem}, Ref{ZZMPolyRing}), - z, a, b, parent(a)) + @ccall libflint.fmpz_mpoly_pow_fmpz(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, b::Ref{ZZRingElem}, parent(a)::Ref{ZZMPolyRing})::Nothing return z end @@ -364,9 +329,7 @@ end function gcd(a::ZZMPolyRingElem, b::ZZMPolyRingElem) check_parent(a, b) z = parent(a)() - r = ccall((:fmpz_mpoly_gcd, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - z, a, b, a.parent) + r = @ccall libflint.fmpz_mpoly_gcd(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, b::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Cint r == 0 && error("Unable to compute gcd") return z end @@ -375,10 +338,7 @@ function gcd_with_cofactors(a::ZZMPolyRingElem, b::ZZMPolyRingElem) z = parent(a)() abar = parent(a)() bbar = parent(a)() - r = ccall((:fmpz_mpoly_gcd_cofactors, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, - Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - z, abar, bbar, a, b, a.parent) + r = @ccall libflint.fmpz_mpoly_gcd_cofactors(z::Ref{ZZMPolyRingElem}, abar::Ref{ZZMPolyRingElem}, bbar::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, b::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Cint r == 0 && error("Unable to compute gcd") return z, abar, bbar end @@ -396,29 +356,20 @@ function (::Type{Fac{ZZMPolyRingElem}})(fac::fmpz_mpoly_factor, preserve_input:: for i in 0:fac.num-1 f = R() if preserve_input - ccall((:fmpz_mpoly_factor_get_base, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{fmpz_mpoly_factor}, Int, Ref{ZZMPolyRing}), - f, fac, i, R) + @ccall libflint.fmpz_mpoly_factor_get_base(f::Ref{ZZMPolyRingElem}, fac::Ref{fmpz_mpoly_factor}, i::Int, R::Ref{ZZMPolyRing})::Nothing else - ccall((:fmpz_mpoly_factor_swap_base, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{fmpz_mpoly_factor}, Int, Ref{ZZMPolyRing}), - f, fac, i, R) + @ccall libflint.fmpz_mpoly_factor_swap_base(f::Ref{ZZMPolyRingElem}, fac::Ref{fmpz_mpoly_factor}, i::Int, R::Ref{ZZMPolyRing})::Nothing end - F.fac[f] = ccall((:fmpz_mpoly_factor_get_exp_si, libflint), Int, - (Ref{fmpz_mpoly_factor}, Int, Ref{ZZMPolyRing}), - fac, i, R) + F.fac[f] = @ccall libflint.fmpz_mpoly_factor_get_exp_si(fac::Ref{fmpz_mpoly_factor}, i::Int, R::Ref{ZZMPolyRing})::Int end c = ZZRingElem() - ccall((:fmpz_mpoly_factor_get_constant_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{fmpz_mpoly_factor}), - c, fac) + @ccall libflint.fmpz_mpoly_factor_get_constant_fmpz(c::Ref{ZZRingElem}, fac::Ref{fmpz_mpoly_factor})::Nothing sgnc = sign(Int, c) if sgnc != 0 G = fmpz_factor() - ccall((:fmpz_factor, libflint), Nothing, (Ref{fmpz_factor}, Ref{ZZRingElem}), G, c) + @ccall libflint.fmpz_factor(G::Ref{fmpz_factor}, c::Ref{ZZRingElem})::Nothing for i in 1:G.num - ccall((:fmpz_factor_get_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{fmpz_factor}, Int), c, G, i - 1) + @ccall libflint.fmpz_factor_get_fmpz(c::Ref{ZZRingElem}, G::Ref{fmpz_factor}, (i - 1)::Int)::Nothing F.fac[R(c)] = unsafe_load(G.exp, i) end end @@ -430,9 +381,7 @@ function factor(a::ZZMPolyRingElem) iszero(a) && throw(ArgumentError("Argument must be non-zero")) R = parent(a) fac = fmpz_mpoly_factor(R) - ok = ccall((:fmpz_mpoly_factor, libflint), Cint, - (Ref{fmpz_mpoly_factor}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - fac, a, R) + ok = @ccall libflint.fmpz_mpoly_factor(fac::Ref{fmpz_mpoly_factor}, a::Ref{ZZMPolyRingElem}, R::Ref{ZZMPolyRing})::Cint ok == 0 && error("unable to compute factorization") return Fac{ZZMPolyRingElem}(fac, false) end @@ -441,9 +390,7 @@ function factor_squarefree(a::ZZMPolyRingElem) iszero(a) && throw(ArgumentError("Argument must be non-zero")) R = parent(a) fac = fmpz_mpoly_factor(R) - ok = ccall((:fmpz_mpoly_factor_squarefree, libflint), Cint, - (Ref{fmpz_mpoly_factor}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - fac, a, R) + ok = @ccall libflint.fmpz_mpoly_factor_squarefree(fac::Ref{fmpz_mpoly_factor}, a::Ref{ZZMPolyRingElem}, R::Ref{ZZMPolyRing})::Cint ok == 0 && error("unable to compute factorization") return Fac{ZZMPolyRingElem}(fac, false) end @@ -451,24 +398,18 @@ end function sqrt(a::ZZMPolyRingElem; check::Bool=true) q = parent(a)() - flag = Bool(ccall((:fmpz_mpoly_sqrt_heap, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}, Cint), - q, a, a.parent, Cint(check))) + flag = Bool(@ccall libflint.fmpz_mpoly_sqrt_heap(q::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing}, Cint(check)::Cint)::Cint) check && !flag && error("Not a square") return q end function is_square(a::ZZMPolyRingElem) - return Bool(ccall((:fmpz_mpoly_is_square, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - a, a.parent)) + return Bool(@ccall libflint.fmpz_mpoly_is_square(a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Cint) end function is_square_with_sqrt(a::ZZMPolyRingElem) q = parent(a)() - flag = ccall((:fmpz_mpoly_sqrt, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - q, a, a.parent) + flag = @ccall libflint.fmpz_mpoly_sqrt(q::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Cint return (Bool(flag), q) end @@ -480,16 +421,12 @@ end function ==(a::ZZMPolyRingElem, b::ZZMPolyRingElem) check_parent(a, b) - return Bool(ccall((:fmpz_mpoly_equal, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - a, b, a.parent)) + return Bool(@ccall libflint.fmpz_mpoly_equal(a::Ref{ZZMPolyRingElem}, b::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Cint) end function Base.isless(a::ZZMPolyRingElem, b::ZZMPolyRingElem) (!is_monomial(a) || !is_monomial(b)) && error("Not monomials in comparison") - return ccall((:fmpz_mpoly_cmp, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - a, b, a.parent) < 0 + return @ccall libflint.fmpz_mpoly_cmp(a::Ref{ZZMPolyRingElem}, b::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Cint < 0 end ############################################################################### @@ -499,17 +436,13 @@ end ############################################################################### function ==(a::ZZMPolyRingElem, b::ZZRingElem) - return Bool(ccall((:fmpz_mpoly_equal_fmpz, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZRingElem}, Ref{ZZMPolyRing}), - a, b, a.parent)) + return Bool(@ccall libflint.fmpz_mpoly_equal_fmpz(a::Ref{ZZMPolyRingElem}, b::Ref{ZZRingElem}, a.parent::Ref{ZZMPolyRing})::Cint) end ==(a::ZZRingElem, b::ZZMPolyRingElem) = b == a function ==(a::ZZMPolyRingElem, b::Int) - return Bool(ccall((:fmpz_mpoly_equal_si, libflint), Cint, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - a, b, a.parent)) + return Bool(@ccall libflint.fmpz_mpoly_equal_si(a::Ref{ZZMPolyRingElem}, b::Int, a.parent::Ref{ZZMPolyRing})::Cint) end ==(a::Int, b::ZZMPolyRingElem) = b == a @@ -541,10 +474,7 @@ end function Base.div(a::ZZMPolyRingElem, b::ZZMPolyRingElem) check_parent(a, b) q = parent(a)() - ccall((:fmpz_mpoly_div, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, - Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - q, a, b, a.parent) + @ccall libflint.fmpz_mpoly_div(q::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, b::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return q end @@ -552,10 +482,7 @@ function Base.divrem(a::ZZMPolyRingElem, b::ZZMPolyRingElem) check_parent(a, b) q = parent(a)() r = parent(a)() - ccall((:fmpz_mpoly_divrem, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, - Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - q, r, a, b, a.parent) + @ccall libflint.fmpz_mpoly_divrem(q::Ref{ZZMPolyRingElem}, r::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, b::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return q, r end @@ -563,10 +490,7 @@ function Base.divrem(a::ZZMPolyRingElem, b::Vector{ZZMPolyRingElem}) len = length(b) q = [parent(a)() for i in 1:len] r = parent(a)() - ccall((:fmpz_mpoly_divrem_ideal, libflint), Nothing, - (Ptr{Ref{ZZMPolyRingElem}}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, - Ptr{Ref{ZZMPolyRingElem}}, Int, Ref{ZZMPolyRing}), - q, r, a, b, len, a.parent) + @ccall libflint.fmpz_mpoly_divrem_ideal(q::Ptr{Ref{ZZMPolyRingElem}}, r::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, b::Ptr{Ref{ZZMPolyRingElem}}, len::Int, a.parent::Ref{ZZMPolyRing})::Nothing return q, r end @@ -593,9 +517,7 @@ function derivative(a::ZZMPolyRingElem, i::Int) n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") z = parent(a)() - ccall((:fmpz_mpoly_derivative, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpz_mpoly_derivative(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{ZZMPolyRing})::Nothing return z end @@ -608,9 +530,7 @@ end function evaluate(a::ZZMPolyRingElem, b::Vector{ZZRingElem}) length(b) != nvars(parent(a)) && error("Vector size incorrect in evaluate") z = ZZRingElem() - GC.@preserve b ccall((:fmpz_mpoly_evaluate_all_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZMPolyRingElem}, Ptr{ZZRingElem}, Ref{ZZMPolyRing}), - z, a, b, parent(a)) + GC.@preserve b @ccall libflint.fmpz_mpoly_evaluate_all_fmpz(z::Ref{ZZRingElem}, a::Ref{ZZMPolyRingElem}, b::Ptr{ZZRingElem}, parent(a)::Ref{ZZMPolyRing})::Nothing return z end @@ -681,10 +601,7 @@ function evaluate(a::ZZMPolyRingElem, bs::Vector{ZZMPolyRingElem}) error("Number of variables does not match number of values") c = S() - fl = ccall((:fmpz_mpoly_compose_fmpz_mpoly, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ptr{Ref{ZZMPolyRingElem}}, - Ref{ZZMPolyRing}, Ref{ZZMPolyRing}), - c, a, bs, R, S) + fl = @ccall libflint.fmpz_mpoly_compose_fmpz_mpoly(c::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, bs::Ptr{Ref{ZZMPolyRingElem}}, R::Ref{ZZMPolyRing}, S::Ref{ZZMPolyRing})::Cint fl == 0 && error("Something wrong in evaluation.") return c end @@ -697,9 +614,7 @@ function evaluate(a::ZZMPolyRingElem, bs::Vector{ZZPolyRingElem}) error("Number of variables does not match number of values") c = S() - fl = ccall((:fmpz_mpoly_compose_fmpz_poly, libflint), Cint, - (Ref{ZZPolyRingElem}, Ref{ZZMPolyRingElem}, Ptr{Ref{ZZPolyRingElem}}, - Ref{ZZMPolyRing}), c, a, bs, R) + fl = @ccall libflint.fmpz_mpoly_compose_fmpz_poly(c::Ref{ZZPolyRingElem}, a::Ref{ZZMPolyRingElem}, bs::Ptr{Ref{ZZPolyRingElem}}, R::Ref{ZZMPolyRing})::Cint fl == 0 && error("Something wrong in evaluation.") return c end @@ -711,48 +626,37 @@ end ############################################################################### function zero!(a::ZZMPolyRingElem) - ccall((:fmpz_mpoly_zero, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), a, a.parent) + @ccall libflint.fmpz_mpoly_zero(a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return a end function one!(a::ZZMPolyRingElem) - ccall((:fmpz_mpoly_one, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), a, a.parent) + @ccall libflint.fmpz_mpoly_one(a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return a end function neg!(z::ZZMPolyRingElem, a::ZZMPolyRingElem) - ccall((:fmpz_mpoly_neg, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), z, a, a.parent) + @ccall libflint.fmpz_mpoly_neg(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return z end function add!(z::ZZMPolyRingElem, a::ZZMPolyRingElem, b::ZZMPolyRingElem) - ccall((:fmpz_mpoly_add, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, - Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), z, a, b, a.parent) + @ccall libflint.fmpz_mpoly_add(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, b::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return z end function sub!(z::ZZMPolyRingElem, a::ZZMPolyRingElem, b::ZZMPolyRingElem) - ccall((:fmpz_mpoly_sub, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, - Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), z, a, b, a.parent) + @ccall libflint.fmpz_mpoly_sub(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, b::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return z end function mul!(z::ZZMPolyRingElem, a::ZZMPolyRingElem, b::ZZMPolyRingElem) - ccall((:fmpz_mpoly_mul, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, - Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), z, a, b, a.parent) + @ccall libflint.fmpz_mpoly_mul(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, b::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return z end function divides!(z::ZZMPolyRingElem, a::ZZMPolyRingElem, b::ZZMPolyRingElem) - d = ccall((:fmpz_mpoly_divides, libflint), Cint, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), - z, a, b, parent(a)) + d = @ccall libflint.fmpz_mpoly_divides(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, b::Ref{ZZMPolyRingElem}, parent(a)::Ref{ZZMPolyRing})::Cint return Bool(d), z end @@ -807,12 +711,9 @@ divides!(a::ZZMPolyRingElem, b::ZZMPolyRingElem, c::RationalUnion) = divides!(a, # must be removed with combine_like_terms! function setcoeff!(a::ZZMPolyRingElem, n::Int, c::ZZRingElem) if n > length(a) - ccall((:fmpz_mpoly_resize, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), a, n, a.parent) + @ccall libflint.fmpz_mpoly_resize(a::Ref{ZZMPolyRingElem}, n::Int, a.parent::Ref{ZZMPolyRing})::Nothing end - ccall((:fmpz_mpoly_set_term_coeff_fmpz, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZRingElem}, Ref{ZZMPolyRing}), - a, n - 1, c, a.parent) + @ccall libflint.fmpz_mpoly_set_term_coeff_fmpz(a::Ref{ZZMPolyRingElem}, (n - 1)::Int, c::Ref{ZZRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return a end @@ -823,8 +724,7 @@ setcoeff!(a::ZZMPolyRingElem, i::Int, c::Integer) = setcoeff!(a, i, ZZRingElem(c # Remove zero terms and combine adjacent terms if they have the same monomial # no sorting is performed function combine_like_terms!(a::ZZMPolyRingElem) - ccall((:fmpz_mpoly_combine_like_terms, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), a, a.parent) + @ccall libflint.fmpz_mpoly_combine_like_terms(a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return a end @@ -835,37 +735,27 @@ end ############################################################################### function exponent_vector_fits(::Type{Int}, a::ZZMPolyRingElem, i::Int) - b = ccall((:fmpz_mpoly_term_exp_fits_ui, libflint), Cint, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - a, i - 1, a.parent) + b = @ccall libflint.fmpz_mpoly_term_exp_fits_ui(a::Ref{ZZMPolyRingElem}, (i - 1)::Int, a.parent::Ref{ZZMPolyRing})::Cint return Bool(b) end function exponent_vector_fits(::Type{UInt}, a::ZZMPolyRingElem, i::Int) - b = ccall((:fmpz_mpoly_term_exp_fits_si, libflint), Cint, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - a, i - 1, a.parent) + b = @ccall libflint.fmpz_mpoly_term_exp_fits_si(a::Ref{ZZMPolyRingElem}, (i - 1)::Int, a.parent::Ref{ZZMPolyRing})::Cint return Bool(b) end function exponent_vector!(z::Vector{Int}, a::ZZMPolyRingElem, i::Int) - ccall((:fmpz_mpoly_get_term_exp_si, libflint), Nothing, - (Ptr{Int}, Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpz_mpoly_get_term_exp_si(z::Ptr{Int}, a::Ref{ZZMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{ZZMPolyRing})::Nothing return z end function exponent_vector!(z::Vector{UInt}, a::ZZMPolyRingElem, i::Int) - ccall((:fmpz_mpoly_get_term_exp_ui, libflint), Nothing, - (Ptr{UInt}, Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpz_mpoly_get_term_exp_ui(z::Ptr{UInt}, a::Ref{ZZMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{ZZMPolyRing})::Nothing return z end function exponent_vector!(z::Vector{ZZRingElem}, a::ZZMPolyRingElem, i::Int) - ccall((:fmpz_mpoly_get_term_exp_fmpz, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fmpz_mpoly_get_term_exp_fmpz(z::Ptr{Ref{ZZRingElem}}, a::Ref{ZZMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{ZZMPolyRing})::Nothing return z end @@ -879,12 +769,9 @@ end # they don't fit into 31/63 bits function set_exponent_vector!(a::ZZMPolyRingElem, n::Int, exps::Vector{UInt}) if n > length(a) - ccall((:fmpz_mpoly_resize, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), a, n, a.parent) + @ccall libflint.fmpz_mpoly_resize(a::Ref{ZZMPolyRingElem}, n::Int, a.parent::Ref{ZZMPolyRing})::Nothing end - ccall((:fmpz_mpoly_set_term_exp_ui, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ptr{UInt}, Ref{ZZMPolyRing}), - a, n - 1, exps, parent(a)) + @ccall libflint.fmpz_mpoly_set_term_exp_ui(a::Ref{ZZMPolyRingElem}, (n - 1)::Int, exps::Ptr{UInt}, parent(a)::Ref{ZZMPolyRing})::Nothing return a end @@ -893,12 +780,9 @@ end # no check is performed function set_exponent_vector!(a::ZZMPolyRingElem, n::Int, exps::Vector{Int}) if n > length(a) - ccall((:fmpz_mpoly_resize, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), a, n, a.parent) + @ccall libflint.fmpz_mpoly_resize(a::Ref{ZZMPolyRingElem}, n::Int, a.parent::Ref{ZZMPolyRing})::Nothing end - ccall((:fmpz_mpoly_set_term_exp_ui, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ptr{Int}, Ref{ZZMPolyRing}), - a, n - 1, exps, parent(a)) + @ccall libflint.fmpz_mpoly_set_term_exp_ui(a::Ref{ZZMPolyRingElem}, (n - 1)::Int, exps::Ptr{Int}, parent(a)::Ref{ZZMPolyRing})::Nothing return a end @@ -906,31 +790,24 @@ end # No sort is performed, so this is unsafe function set_exponent_vector!(a::ZZMPolyRingElem, n::Int, exps::Vector{ZZRingElem}) if n > length(a) - ccall((:fmpz_mpoly_resize, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), a, n, a.parent) + @ccall libflint.fmpz_mpoly_resize(a::Ref{ZZMPolyRingElem}, n::Int, a.parent::Ref{ZZMPolyRing})::Nothing return a end - GC.@preserve exps ccall((:fmpz_mpoly_set_term_exp_fmpz, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ptr{ZZRingElem}, Ref{ZZMPolyRing}), - a, n - 1, exps, parent(a)) + GC.@preserve exps @ccall libflint.fmpz_mpoly_set_term_exp_fmpz(a::Ref{ZZMPolyRingElem}, (n - 1)::Int, exps::Ptr{ZZRingElem}, parent(a)::Ref{ZZMPolyRing})::Nothing return a end # Return j-th coordinate of i-th exponent vector function exponent(a::ZZMPolyRingElem, i::Int, j::Int) (j < 1 || j > nvars(parent(a))) && error("Invalid variable index") - return ccall((:fmpz_mpoly_get_term_var_exp_ui, libflint), Int, - (Ref{ZZMPolyRingElem}, Int, Int, Ref{ZZMPolyRing}), - a, i - 1, j - 1, a.parent) + return @ccall libflint.fmpz_mpoly_get_term_var_exp_ui(a::Ref{ZZMPolyRingElem}, (i - 1)::Int, (j - 1)::Int, a.parent::Ref{ZZMPolyRing})::Int end # Return the coefficient of the term with the given exponent vector # Return zero if there is no such term function coeff(a::ZZMPolyRingElem, exps::Vector{UInt}) z = ZZRingElem() - ccall((:fmpz_mpoly_get_coeff_fmpz_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZMPolyRingElem}, Ptr{UInt}, Ref{ZZMPolyRing}), - z, a, exps, parent(a)) + @ccall libflint.fmpz_mpoly_get_coeff_fmpz_ui(z::Ref{ZZRingElem}, a::Ref{ZZMPolyRingElem}, exps::Ptr{UInt}, parent(a)::Ref{ZZMPolyRing})::Nothing return z end @@ -938,27 +815,21 @@ end # Return zero if there is no such term function coeff(a::ZZMPolyRingElem, exps::Vector{Int}) z = ZZRingElem() - ccall((:fmpz_mpoly_get_coeff_fmpz_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZMPolyRingElem}, Ptr{Int}, Ref{ZZMPolyRing}), - z, a, exps, parent(a)) + @ccall libflint.fmpz_mpoly_get_coeff_fmpz_ui(z::Ref{ZZRingElem}, a::Ref{ZZMPolyRingElem}, exps::Ptr{Int}, parent(a)::Ref{ZZMPolyRing})::Nothing return z end # Set the coefficient of the term with the given exponent vector to the # given ZZRingElem. Removal of a zero term is performed. function setcoeff!(a::ZZMPolyRingElem, exps::Vector{UInt}, b::ZZRingElem) - ccall((:fmpz_mpoly_set_coeff_fmpz_ui, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZRingElem}, Ptr{UInt}, Ref{ZZMPolyRing}), - a, b, exps, parent(a)) + @ccall libflint.fmpz_mpoly_set_coeff_fmpz_ui(a::Ref{ZZMPolyRingElem}, b::Ref{ZZRingElem}, exps::Ptr{UInt}, parent(a)::Ref{ZZMPolyRing})::Nothing return a end # Set the coefficient of the term with the given exponent vector to the # given ZZRingElem. Removal of a zero term is performed. function setcoeff!(a::ZZMPolyRingElem, exps::Vector{Int}, b::ZZRingElem) - ccall((:fmpz_mpoly_set_coeff_fmpz_ui, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZRingElem}, Ptr{Int}, Ref{ZZMPolyRing}), - a, b, exps, parent(a)) + @ccall libflint.fmpz_mpoly_set_coeff_fmpz_ui(a::Ref{ZZMPolyRingElem}, b::Ref{ZZRingElem}, exps::Ptr{Int}, parent(a)::Ref{ZZMPolyRing})::Nothing return a end @@ -971,34 +842,27 @@ setcoeff!(a, exps, ZZRingElem(b)) # out of order. Note that like terms are not combined and zeros are not # removed. For that, call combine_like_terms! function sort_terms!(a::ZZMPolyRingElem) - ccall((:fmpz_mpoly_sort_terms, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRing}), a, a.parent) + @ccall libflint.fmpz_mpoly_sort_terms(a::Ref{ZZMPolyRingElem}, a.parent::Ref{ZZMPolyRing})::Nothing return a end # Return the i-th term of the polynomial, as a polynomial function term(a::ZZMPolyRingElem, i::Int) z = parent(a)() - ccall((:fmpz_mpoly_get_term, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - z, a, i - 1, a.parent) + @ccall libflint.fmpz_mpoly_get_term(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, (i - 1)::Int, a.parent::Ref{ZZMPolyRing})::Nothing return z end # Return the i-th monomial of the polynomial, as a polynomial function monomial(a::ZZMPolyRingElem, i::Int) z = parent(a)() - ccall((:fmpz_mpoly_get_term_monomial, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - z, a, i - 1, a.parent) + @ccall libflint.fmpz_mpoly_get_term_monomial(z::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, (i - 1)::Int, a.parent::Ref{ZZMPolyRing})::Nothing return z end # Sets the given polynomial m to the i-th monomial of the polynomial function monomial!(m::ZZMPolyRingElem, a::ZZMPolyRingElem, i::Int) - ccall((:fmpz_mpoly_get_term_monomial, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZMPolyRingElem}, Int, Ref{ZZMPolyRing}), - m, a, i - 1, a.parent) + @ccall libflint.fmpz_mpoly_get_term_monomial(m::Ref{ZZMPolyRingElem}, a::Ref{ZZMPolyRingElem}, (i - 1)::Int, a.parent::Ref{ZZMPolyRing})::Nothing return m end @@ -1019,23 +883,17 @@ promote_rule(::Type{ZZMPolyRingElem}, ::Type{ZZRingElem}) = ZZMPolyRingElem ############################################################################### function _push_term!(z::ZZMPolyRingElem, c::ZZRingElem, exp::Vector{Int}) - ccall((:fmpz_mpoly_push_term_fmpz_ui, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Ref{ZZRingElem}, Ptr{UInt}, Ref{ZZMPolyRing}), - z, c, exp, parent(z)) + @ccall libflint.fmpz_mpoly_push_term_fmpz_ui(z::Ref{ZZMPolyRingElem}, c::Ref{ZZRingElem}, exp::Ptr{UInt}, parent(z)::Ref{ZZMPolyRing})::Nothing return z end function _push_term!(z::ZZMPolyRingElem, c::Int, exp::Vector{Int}) - ccall((:fmpz_mpoly_push_term_si_ui, libflint), Nothing, - (Ref{ZZMPolyRingElem}, Int, Ptr{UInt}, Ref{ZZMPolyRing}), - z, c, exp, parent(z)) + @ccall libflint.fmpz_mpoly_push_term_si_ui(z::Ref{ZZMPolyRingElem}, c::Int, exp::Ptr{UInt}, parent(z)::Ref{ZZMPolyRing})::Nothing return z end function _push_term!(z::ZZMPolyRingElem, c::UInt, exp::Vector{Int}) - ccall((:fmpz_mpoly_push_term_ui_ui, libflint), Nothing, - (Ref{ZZMPolyRingElem}, UInt, Ptr{UInt}, Ref{ZZMPolyRing}), - z, c, exp, parent(z)) + @ccall libflint.fmpz_mpoly_push_term_ui_ui(z::Ref{ZZMPolyRingElem}, c::UInt, exp::Ptr{UInt}, parent(z)::Ref{ZZMPolyRing})::Nothing return z end diff --git a/src/flint/fmpz_poly.jl b/src/flint/fmpz_poly.jl index 47ea58480..7a8ce9c69 100644 --- a/src/flint/fmpz_poly.jl +++ b/src/flint/fmpz_poly.jl @@ -28,14 +28,12 @@ var(a::ZZPolyRing) = a.S # ############################################################################### -length(x::ZZPolyRingElem) = ccall((:fmpz_poly_length, libflint), Int, - (Ref{ZZPolyRingElem},), x) +length(x::ZZPolyRingElem) = @ccall libflint.fmpz_poly_length(x::Ref{ZZPolyRingElem})::Int function coeff(x::ZZPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = ZZRingElem() - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZPolyRingElem}, Int), z, x, n) + @ccall libflint.fmpz_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{ZZPolyRingElem}, n::Int)::Nothing return z end @@ -45,8 +43,7 @@ one(a::ZZPolyRing) = a(1) gen(a::ZZPolyRing) = a([zero(base_ring(a)), one(base_ring(a))]) -is_gen(x::ZZPolyRingElem) = ccall((:fmpz_poly_is_gen, libflint), Bool, - (Ref{ZZPolyRingElem},), x) +is_gen(x::ZZPolyRingElem) = @ccall libflint.fmpz_poly_is_gen(x::Ref{ZZPolyRingElem})::Bool function deepcopy_internal(a::ZZPolyRingElem, dict::IdDict) z = ZZPolyRingElem(a) @@ -61,8 +58,7 @@ Return the largest of the absolute values of the coefficients of a. """ function height(a::ZZPolyRingElem) z = ZZRingElem() - ccall((:fmpz_poly_height, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZPolyRingElem}), z, a) + @ccall libflint.fmpz_poly_height(z::Ref{ZZRingElem}, a::Ref{ZZPolyRingElem})::Nothing return z end @@ -165,9 +161,7 @@ end function ^(x::ZZPolyRingElem, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() - ccall((:fmpz_poly_pow, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Int), - z, x, y) + @ccall libflint.fmpz_poly_pow(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, y::Int)::Nothing return z end @@ -179,8 +173,7 @@ end function ==(x::ZZPolyRingElem, y::ZZPolyRingElem) check_parent(x, y) - return ccall((:fmpz_poly_equal, libflint), Bool, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), x, y) + return @ccall libflint.fmpz_poly_equal(x::Ref{ZZPolyRingElem}, y::Ref{ZZPolyRingElem})::Bool end ############################################################################### @@ -194,10 +187,8 @@ function ==(x::ZZPolyRingElem, y::ZZRingElem) return false elseif length(x) == 1 z = ZZRingElem() - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZPolyRingElem}, Int), z, x, 0) - return ccall((:fmpz_equal, libflint), Bool, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, y, 0) + @ccall libflint.fmpz_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{ZZPolyRingElem}, 0::Int)::Nothing + return @ccall libflint.fmpz_equal(z::Ref{ZZRingElem}, y::Ref{ZZRingElem}, 0::Int)::Bool else return iszero(y) end @@ -223,8 +214,7 @@ function truncate(a::ZZPolyRingElem, n::Int) end z = parent(a)() - ccall((:fmpz_poly_set_trunc, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Int), z, a, n) + @ccall libflint.fmpz_poly_set_trunc(z::Ref{ZZPolyRingElem}, a::Ref{ZZPolyRingElem}, n::Int)::Nothing return z end @@ -233,8 +223,7 @@ function mullow(x::ZZPolyRingElem, y::ZZPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() - ccall((:fmpz_poly_mullow, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Int), z, x, y, n) + @ccall libflint.fmpz_poly_mullow(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, y::Ref{ZZPolyRingElem}, n::Int)::Nothing return z end @@ -247,8 +236,7 @@ end function reverse(x::ZZPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Index must be non-negative")) z = parent(x)() - ccall((:fmpz_poly_reverse, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Int), z, x, len) + @ccall libflint.fmpz_poly_reverse(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, len::Int)::Nothing return z end @@ -261,16 +249,14 @@ end function shift_left(x::ZZPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:fmpz_poly_shift_left, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Int), z, x, len) + @ccall libflint.fmpz_poly_shift_left(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, len::Int)::Nothing return z end function shift_right(x::ZZPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:fmpz_poly_shift_right, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Int), z, x, len) + @ccall libflint.fmpz_poly_shift_right(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, len::Int)::Nothing return z end @@ -286,13 +272,10 @@ function divexact(x::ZZPolyRingElem, y::ZZPolyRingElem; check::Bool=true) z = parent(x)() if check r = parent(x)() - ccall((:fmpz_poly_divrem, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), - z, r, x, y) + @ccall libflint.fmpz_poly_divrem(z::Ref{ZZPolyRingElem}, r::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, y::Ref{ZZPolyRingElem})::Nothing r != 0 && error("Not an exact division") else - ccall((:fmpz_poly_div, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), z, x, y) + @ccall libflint.fmpz_poly_div(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, y::Ref{ZZPolyRingElem})::Nothing end return z end @@ -302,8 +285,7 @@ function Base.divrem(x::ZZPolyRingElem, y::ZZPolyRingElem) iszero(y) && throw(DivideError()) z = parent(x)() r = parent(x)() - ccall((:fmpz_poly_divrem, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), z, r, x, y) + @ccall libflint.fmpz_poly_divrem(z::Ref{ZZPolyRingElem}, r::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, y::Ref{ZZPolyRingElem})::Nothing return z, r end @@ -313,8 +295,7 @@ function divides(x::ZZPolyRingElem, y::ZZPolyRingElem) check_parent(x, y) iszero(y) && throw(DivideError()) z = parent(x)() - flag = Bool(ccall((:fmpz_poly_divides, libflint), Cint, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), z, x, y)) + flag = Bool(@ccall libflint.fmpz_poly_divides(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, y::Ref{ZZPolyRingElem})::Cint) return flag, z end @@ -327,16 +308,14 @@ end function divexact(x::ZZPolyRingElem, y::ZZRingElem; check::Bool=true) iszero(y) && throw(DivideError()) z = parent(x)() - ccall((:fmpz_poly_scalar_divexact_fmpz, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpz_poly_scalar_divexact_fmpz(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, y::Ref{ZZRingElem})::Nothing return z end function divexact(x::ZZPolyRingElem, y::Int; check::Bool=true) y == 0 && throw(DivideError()) z = parent(x)() - ccall((:fmpz_poly_scalar_divexact_si, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Int), z, x, y) + @ccall libflint.fmpz_poly_scalar_divexact_si(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, y::Int)::Nothing return z end @@ -354,8 +333,7 @@ function pseudorem(x::ZZPolyRingElem, y::ZZPolyRingElem) diff = length(x) - length(y) + 1 r = parent(x)() d = Vector{Int}(undef, 1) - ccall((:fmpz_poly_pseudo_rem, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ptr{Int}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), r, d, x, y) + @ccall libflint.fmpz_poly_pseudo_rem(r::Ref{ZZPolyRingElem}, d::Ptr{Int}, x::Ref{ZZPolyRingElem}, y::Ref{ZZPolyRingElem})::Nothing if (diff > d[1]) return leading_coefficient(y)^(diff - d[1])*r else @@ -370,9 +348,7 @@ function pseudodivrem(x::ZZPolyRingElem, y::ZZPolyRingElem) q = parent(x)() r = parent(x)() d = Vector{Int}(undef, 1) - ccall((:fmpz_poly_pseudo_divrem_divconquer, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ptr{Int}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), - q, r, d, x, y) + @ccall libflint.fmpz_poly_pseudo_divrem_divconquer(q::Ref{ZZPolyRingElem}, r::Ref{ZZPolyRingElem}, d::Ptr{Int}, x::Ref{ZZPolyRingElem}, y::Ref{ZZPolyRingElem})::Nothing if (diff > d[1]) m = leading_coefficient(y)^(diff - d[1]) return m*q, m*r @@ -390,22 +366,19 @@ end function gcd(x::ZZPolyRingElem, y::ZZPolyRingElem) check_parent(x, y) z = parent(x)() - ccall((:fmpz_poly_gcd, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), z, x, y) + @ccall libflint.fmpz_poly_gcd(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, y::Ref{ZZPolyRingElem})::Nothing return z end function content(x::ZZPolyRingElem) z = ZZRingElem() - ccall((:fmpz_poly_content, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZPolyRingElem}), z, x) + @ccall libflint.fmpz_poly_content(z::Ref{ZZRingElem}, x::Ref{ZZPolyRingElem})::Nothing return z end function primpart(x::ZZPolyRingElem) z = parent(x)() - ccall((:fmpz_poly_primitive_part, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), z, x) + @ccall libflint.fmpz_poly_primitive_part(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem})::Nothing return z end @@ -417,24 +390,21 @@ end function Base.sqrt(x::ZZPolyRingElem; check::Bool=true) z = parent(x)() - flag = Bool(ccall((:fmpz_poly_sqrt, libflint), Cint, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), z, x)) + flag = Bool(@ccall libflint.fmpz_poly_sqrt(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem})::Cint) check && flag == false && error("Not a square in sqrt") return z end function is_square(x::ZZPolyRingElem) z = parent(x)() - flag = Bool(ccall((:fmpz_poly_sqrt, libflint), Cint, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), z, x)) + flag = Bool(@ccall libflint.fmpz_poly_sqrt(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem})::Cint) return flag end function is_square_with_sqrt(x::ZZPolyRingElem) R = parent(x) z = R() - flag = Bool(ccall((:fmpz_poly_sqrt, libflint), Cint, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), z, x)) + flag = Bool(@ccall libflint.fmpz_poly_sqrt(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem})::Cint) if !flag return false, zero(R) end @@ -449,8 +419,7 @@ end function evaluate(x::ZZPolyRingElem, y::ZZRingElem) z = ZZRingElem() - ccall((:fmpz_poly_evaluate_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZPolyRingElem}, Ref{ZZRingElem}), z, x, y) + @ccall libflint.fmpz_poly_evaluate_fmpz(z::Ref{ZZRingElem}, x::Ref{ZZPolyRingElem}, y::Ref{ZZRingElem})::Nothing return z end @@ -465,8 +434,7 @@ evaluate(x::ZZPolyRingElem, y::Integer) = evaluate(x, ZZRingElem(y)) function AbstractAlgebra._compose_right(x::ZZPolyRingElem, y::ZZPolyRingElem) check_parent(x, y) z = parent(x)() - ccall((:fmpz_poly_compose, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), z, x, y) + @ccall libflint.fmpz_poly_compose(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, y::Ref{ZZPolyRingElem})::Nothing return z end @@ -478,8 +446,7 @@ end function derivative(x::ZZPolyRingElem) z = parent(x)() - ccall((:fmpz_poly_derivative, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), z, x) + @ccall libflint.fmpz_poly_derivative(z::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem})::Nothing return z end @@ -492,8 +459,7 @@ end function resultant(x::ZZPolyRingElem, y::ZZPolyRingElem) check_parent(x, y) z = ZZRingElem() - ccall((:fmpz_poly_resultant, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), z, x, y) + @ccall libflint.fmpz_poly_resultant(z::Ref{ZZRingElem}, x::Ref{ZZPolyRingElem}, y::Ref{ZZPolyRingElem})::Nothing return z end @@ -505,8 +471,7 @@ end function discriminant(x::ZZPolyRingElem) z = ZZRingElem() - ccall((:fmpz_poly_discriminant, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZPolyRingElem}), z, x) + @ccall libflint.fmpz_poly_discriminant(z::Ref{ZZRingElem}, x::Ref{ZZPolyRingElem})::Nothing return z end @@ -531,9 +496,7 @@ function resx(a::ZZPolyRingElem, b::ZZPolyRingElem) c2 = content(b) x = divexact(a, c1) y = divexact(b, c2) - ccall((:fmpz_poly_xgcd_modular, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), - z, u, v, x, y) + @ccall libflint.fmpz_poly_xgcd_modular(z::Ref{ZZRingElem}, u::Ref{ZZPolyRingElem}, v::Ref{ZZPolyRingElem}, x::Ref{ZZPolyRingElem}, y::Ref{ZZPolyRingElem})::Nothing r = z*c1^(lenb - 1)*c2^(lena - 1) if lenb > 1 u *= c1^(lenb - 2)*c2^(lena - 1) @@ -574,8 +537,7 @@ julia> signature(x^3 + 3x + 1) function signature(f::ZZPolyRingElem) r = Vector{Int}(undef, 1) s = Vector{Int}(undef, 1) - ccall((:fmpz_poly_signature, libflint), Nothing, - (Ptr{Int}, Ptr{Int}, Ref{ZZPolyRingElem}), r, s, f) + @ccall libflint.fmpz_poly_signature(r::Ptr{Int}, s::Ptr{Int}, f::Ref{ZZPolyRingElem})::Nothing return (r[1], s[1]) end @@ -599,9 +561,7 @@ function interpolate(R::ZZPolyRing, x::Vector{ZZRingElem}, ay[i] = y[i].d end - ccall((:fmpz_poly_interpolate_fmpz_vec, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ptr{Int}, Ptr{Int}, Int), - z, ax, ay, length(x)) + @ccall libflint.fmpz_poly_interpolate_fmpz_vec(z::Ref{ZZPolyRingElem}, ax::Ptr{Int}, ay::Ptr{Int}, length(x)::Int)::Nothing return z end @@ -634,12 +594,10 @@ for (factor_fn, factor_fn_inner, flint_fn) in (Ref{fmpz_poly_factor}, Ref{ZZPolyRingElem}), fac, x) res = Dict{ZZPolyRingElem,Int}() z = ZZRingElem() - ccall((:fmpz_poly_factor_get_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{fmpz_poly_factor}), z, fac) + @ccall libflint.fmpz_poly_factor_get_fmpz(z::Ref{ZZRingElem}, fac::Ref{fmpz_poly_factor})::Nothing for i in 1:fac.num f = parent(x)() - ccall((:fmpz_poly_factor_get_fmpz_poly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{fmpz_poly_factor}, Int), f, fac, i - 1) + @ccall libflint.fmpz_poly_factor_get_fmpz_poly(f::Ref{ZZPolyRingElem}, fac::Ref{fmpz_poly_factor}, (i - 1)::Int)::Nothing e = unsafe_load(fac.exp, i) res[f] = e end @@ -669,15 +627,13 @@ end function chebyshev_t(n::Int, x::ZZPolyRingElem) z = parent(x)() - ccall((:fmpz_poly_chebyshev_t, libflint), Nothing, - (Ref{ZZPolyRingElem}, Int), z, n) + @ccall libflint.fmpz_poly_chebyshev_t(z::Ref{ZZPolyRingElem}, n::Int)::Nothing return is_gen(x) ? z : compose(z, x, inner = :second) end function chebyshev_u(n::Int, x::ZZPolyRingElem) z = parent(x)() - ccall((:fmpz_poly_chebyshev_u, libflint), Nothing, - (Ref{ZZPolyRingElem}, Int), z, n) + @ccall libflint.fmpz_poly_chebyshev_u(z::Ref{ZZPolyRingElem}, n::Int)::Nothing return is_gen(x) ? z : compose(z, x, inner = :second) end @@ -690,8 +646,7 @@ $n$th primitive roots of unity. """ function cyclotomic(n::Int, x::ZZPolyRingElem) z = parent(x)() - ccall((:fmpz_poly_cyclotomic, libflint), Nothing, - (Ref{ZZPolyRingElem}, Int), z, n) + @ccall libflint.fmpz_poly_cyclotomic(z::Ref{ZZPolyRingElem}, n::Int)::Nothing return is_gen(x) ? z : compose(z, x; inner = :second) end @@ -707,8 +662,7 @@ taken. This polynomial has degree $2^n$ and is irreducible over the integers """ function swinnerton_dyer(n::Int, x::ZZPolyRingElem) z = parent(x)() - ccall((:fmpz_poly_swinnerton_dyer, libflint), Nothing, - (Ref{ZZPolyRingElem}, Int), z, n) + @ccall libflint.fmpz_poly_swinnerton_dyer(z::Ref{ZZPolyRingElem}, n::Int)::Nothing return is_gen(x) ? z : compose(z, x, inner = :second) end @@ -721,8 +675,7 @@ rational $a$. """ function cos_minpoly(n::Int, x::ZZPolyRingElem) z = parent(x)() - ccall((:fmpz_poly_cos_minpoly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Int), z, n) + @ccall libflint.fmpz_poly_cos_minpoly(z::Ref{ZZPolyRingElem}, n::Int)::Nothing return is_gen(x) ? z : compose(z, x, inner = :second) end @@ -735,8 +688,7 @@ $\vartheta(q) = 1 + \sum_{k=1}^{\infty} q^{k^2}$. """ function theta_qexp(e::Int, n::Int, x::ZZPolyRingElem) z = parent(x)() - ccall((:fmpz_poly_theta_qexp, libflint), Nothing, - (Ref{ZZPolyRingElem}, Int, Int), z, e, n) + @ccall libflint.fmpz_poly_theta_qexp(z::Ref{ZZPolyRingElem}, e::Int, n::Int)::Nothing return is_gen(x) ? z : compose(z, x, inner = :second) end @@ -753,8 +705,7 @@ $\tau(k)$. """ function eta_qexp(e::Int, n::Int, x::ZZPolyRingElem) z = parent(x)() - ccall((:fmpz_poly_eta_qexp, libflint), Nothing, - (Ref{ZZPolyRingElem}, Int, Int), z, e, n) + @ccall libflint.fmpz_poly_eta_qexp(z::Ref{ZZPolyRingElem}, e::Int, n::Int)::Nothing return is_gen(x) ? z : compose(z, x, inner = :second) end @@ -780,26 +731,22 @@ end ############################################################################### function zero!(z::ZZPolyRingElemOrPtr) - ccall((:fmpz_poly_zero, libflint), Nothing, - (Ref{ZZPolyRingElem},), z) + @ccall libflint.fmpz_poly_zero(z::Ref{ZZPolyRingElem})::Nothing return z end function one!(z::ZZPolyRingElemOrPtr) - ccall((:fmpz_poly_one, libflint), Nothing, - (Ref{ZZPolyRingElem},), z) + @ccall libflint.fmpz_poly_one(z::Ref{ZZPolyRingElem})::Nothing return z end function neg!(z::ZZPolyRingElemOrPtr, a::ZZPolyRingElemOrPtr) - ccall((:fmpz_poly_neg, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}), z, a) + @ccall libflint.fmpz_poly_neg(z::Ref{ZZPolyRingElem}, a::Ref{ZZPolyRingElem})::Nothing return z end function fit!(z::ZZPolyRingElemOrPtr, n::Int) - ccall((:fmpz_poly_fit_length, libflint), Nothing, - (Ref{ZZPolyRingElem}, Int), z, n) + @ccall libflint.fmpz_poly_fit_length(z::Ref{ZZPolyRingElem}, n::Int)::Nothing return nothing end @@ -947,8 +894,7 @@ promote_rule(::Type{ZZPolyRingElem}, ::Type{ZZRingElem}) = ZZPolyRingElem ############################################################################### function fmpz_poly_to_nmod_poly_raw!(r::zzModPolyRingElem, a::ZZPolyRingElem) - ccall((:fmpz_poly_get_nmod_poly, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{ZZPolyRingElem}), r, a) + @ccall libflint.fmpz_poly_get_nmod_poly(r::Ref{zzModPolyRingElem}, a::Ref{ZZPolyRingElem})::Nothing return r end @@ -959,8 +905,7 @@ function (Rx::zzModPolyRing)(f::ZZPolyRingElem) end function fmpz_poly_to_gfp_poly_raw!(r::fpPolyRingElem, a::ZZPolyRingElem) - ccall((:fmpz_poly_get_nmod_poly, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{ZZPolyRingElem}), r, a) + @ccall libflint.fmpz_poly_get_nmod_poly(r::Ref{fpPolyRingElem}, a::Ref{ZZPolyRingElem})::Nothing return r end @@ -1046,8 +991,6 @@ end function mulhigh_n(a::ZZPolyRingElem, b::ZZPolyRingElem, n::Int) c = parent(a)() #careful: as part of the interface, the coeffs 0 - (n-1) are random garbage - ccall((:fmpz_poly_mulhigh_n, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Ref{ZZPolyRingElem}, Cint), - c, a, b, n) + @ccall libflint.fmpz_poly_mulhigh_n(c::Ref{ZZPolyRingElem}, a::Ref{ZZPolyRingElem}, b::Ref{ZZPolyRingElem}, n::Cint)::Nothing return c end diff --git a/src/flint/fmpz_rel_series.jl b/src/flint/fmpz_rel_series.jl index 8331e1a15..2e0373d6d 100644 --- a/src/flint/fmpz_rel_series.jl +++ b/src/flint/fmpz_rel_series.jl @@ -39,21 +39,19 @@ max_precision(R::ZZRelPowerSeriesRing) = R.prec_max function normalise(a::ZZRelPowerSeriesRingElem, len::Int) if len > 0 c = ZZRingElem() - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), c, a, len - 1) + @ccall libflint.fmpz_poly_get_coeff_fmpz(c::Ref{ZZRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, (len - 1)::Int)::Nothing end while len > 0 && iszero(c) len -= 1 if len > 0 - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), c, a, len - 1) + @ccall libflint.fmpz_poly_get_coeff_fmpz(c::Ref{ZZRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, (len - 1)::Int)::Nothing end end return len end function pol_length(x::ZZRelPowerSeriesRingElem) - return ccall((:fmpz_poly_length, libflint), Int, (Ref{ZZRelPowerSeriesRingElem},), x) + return @ccall libflint.fmpz_poly_length(x::Ref{ZZRelPowerSeriesRingElem})::Int end precision(x::ZZRelPowerSeriesRingElem) = x.prec @@ -63,8 +61,7 @@ function polcoeff(x::ZZRelPowerSeriesRingElem, n::Int) return ZZRingElem(0) end z = ZZRingElem() - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), z, x, n) + @ccall libflint.fmpz_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{ZZRelPowerSeriesRingElem}, n::Int)::Nothing return z end @@ -99,8 +96,7 @@ function renormalize!(z::ZZRelPowerSeriesRingElem) z.val = zprec else z.val = zval + i - ccall((:fmpz_poly_shift_right, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), z, z, i) + @ccall libflint.fmpz_poly_shift_right(z::Ref{ZZRelPowerSeriesRingElem}, z::Ref{ZZRelPowerSeriesRingElem}, i::Int)::Nothing end return nothing end @@ -153,9 +149,7 @@ end function -(x::ZZRelPowerSeriesRingElem) z = parent(x)() - ccall((:fmpz_poly_neg, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}), - z, x) + @ccall libflint.fmpz_poly_neg(z::Ref{ZZRelPowerSeriesRingElem}, x::Ref{ZZRelPowerSeriesRingElem})::Nothing z.prec = x.prec z.val = x.val return z @@ -181,28 +175,18 @@ function +(a::ZZRelPowerSeriesRingElem, b::ZZRelPowerSeriesRingElem) ccall((:fmpz_poly_set_trunc, libflint), Nothing, (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), z, b, max(0, lenz - b.val + a.val)) - ccall((:fmpz_poly_shift_left, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, z, b.val - a.val) - ccall((:fmpz_poly_add_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, z, a, lenz) + @ccall libflint.fmpz_poly_shift_left(z::Ref{ZZRelPowerSeriesRingElem}, z::Ref{ZZRelPowerSeriesRingElem}, (b.val - a.val)::Int)::Nothing + @ccall libflint.fmpz_poly_add_series(z::Ref{ZZRelPowerSeriesRingElem}, z::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, lenz::Int)::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:fmpz_poly_set_trunc, libflint), Nothing, (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), z, a, max(0, lenz - a.val + b.val)) - ccall((:fmpz_poly_shift_left, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, z, a.val - b.val) - ccall((:fmpz_poly_add_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, z, b, lenz) + @ccall libflint.fmpz_poly_shift_left(z::Ref{ZZRelPowerSeriesRingElem}, z::Ref{ZZRelPowerSeriesRingElem}, (a.val - b.val)::Int)::Nothing + @ccall libflint.fmpz_poly_add_series(z::Ref{ZZRelPowerSeriesRingElem}, z::Ref{ZZRelPowerSeriesRingElem}, b::Ref{ZZRelPowerSeriesRingElem}, lenz::Int)::Nothing else lenz = max(lena, lenb) - ccall((:fmpz_poly_add_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpz_poly_add_series(z::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, b::Ref{ZZRelPowerSeriesRingElem}, lenz::Int)::Nothing end z.prec = prec z.val = val @@ -225,30 +209,19 @@ function -(a::ZZRelPowerSeriesRingElem, b::ZZRelPowerSeriesRingElem) ccall((:fmpz_poly_set_trunc, libflint), Nothing, (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), z, b, max(0, lenz - b.val + a.val)) - ccall((:fmpz_poly_shift_left, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, z, b.val - a.val) - ccall((:fmpz_poly_neg, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}), z, z) - ccall((:fmpz_poly_add_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, z, a, lenz) + @ccall libflint.fmpz_poly_shift_left(z::Ref{ZZRelPowerSeriesRingElem}, z::Ref{ZZRelPowerSeriesRingElem}, (b.val - a.val)::Int)::Nothing + @ccall libflint.fmpz_poly_neg(z::Ref{ZZRelPowerSeriesRingElem}, z::Ref{ZZRelPowerSeriesRingElem})::Nothing + @ccall libflint.fmpz_poly_add_series(z::Ref{ZZRelPowerSeriesRingElem}, z::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, lenz::Int)::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:fmpz_poly_set_trunc, libflint), Nothing, (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), z, a, max(0, lenz - a.val + b.val)) - ccall((:fmpz_poly_shift_left, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, z, a.val - b.val) - ccall((:fmpz_poly_sub_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, z, b, lenz) + @ccall libflint.fmpz_poly_shift_left(z::Ref{ZZRelPowerSeriesRingElem}, z::Ref{ZZRelPowerSeriesRingElem}, (a.val - b.val)::Int)::Nothing + @ccall libflint.fmpz_poly_sub_series(z::Ref{ZZRelPowerSeriesRingElem}, z::Ref{ZZRelPowerSeriesRingElem}, b::Ref{ZZRelPowerSeriesRingElem}, lenz::Int)::Nothing else lenz = max(lena, lenb) - ccall((:fmpz_poly_sub_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpz_poly_sub_series(z::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, b::Ref{ZZRelPowerSeriesRingElem}, lenz::Int)::Nothing end z.prec = prec z.val = val @@ -272,9 +245,7 @@ function *(a::ZZRelPowerSeriesRingElem, b::ZZRelPowerSeriesRingElem) return z end lenz = min(lena + lenb - 1, prec) - ccall((:fmpz_poly_mullow, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpz_poly_mullow(z::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, b::Ref{ZZRelPowerSeriesRingElem}, lenz::Int)::Nothing return z end @@ -289,9 +260,7 @@ function *(x::Int, y::ZZRelPowerSeriesRingElem) z = parent(y)() z.prec = y.prec z.val = y.val - ccall((:fmpz_poly_scalar_mul_si, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, y, x) + @ccall libflint.fmpz_poly_scalar_mul_si(z::Ref{ZZRelPowerSeriesRingElem}, y::Ref{ZZRelPowerSeriesRingElem}, x::Int)::Nothing return z end @@ -301,9 +270,7 @@ function *(x::ZZRingElem, y::ZZRelPowerSeriesRingElem) z = parent(y)() z.prec = y.prec z.val = y.val - ccall((:fmpz_poly_scalar_mul_fmpz, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRingElem}), - z, y, x) + @ccall libflint.fmpz_poly_scalar_mul_fmpz(z::Ref{ZZRelPowerSeriesRingElem}, y::Ref{ZZRelPowerSeriesRingElem}, x::Ref{ZZRingElem})::Nothing return z end @@ -341,9 +308,7 @@ function shift_right(x::ZZRelPowerSeriesRingElem, len::Int) z.prec = max(0, x.prec - len) z.val = max(0, xval - len) zlen = min(xlen + xval - len, xlen) - ccall((:fmpz_poly_shift_right, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, x, xlen - zlen) + @ccall libflint.fmpz_poly_shift_right(z::Ref{ZZRelPowerSeriesRingElem}, x::Ref{ZZRelPowerSeriesRingElem}, (xlen - zlen)::Int)::Nothing renormalize!(z) end return z @@ -368,9 +333,7 @@ function truncate!(x::ZZRelPowerSeriesRingElem, k::Int) x = zero!(x) x.val = k else - ccall((:fmpz_poly_truncate, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Int), - x, k - valuation(x)) + @ccall libflint.fmpz_poly_truncate(x::Ref{ZZRelPowerSeriesRingElem}, (k - valuation(x))::Int)::Nothing end x.prec = k return x @@ -402,9 +365,7 @@ function ^(a::ZZRelPowerSeriesRingElem, b::Int) z = parent(a)() z.prec = a.prec + (b - 1)*valuation(a) z.val = b*valuation(a) - ccall((:fmpz_poly_pow_trunc, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int, Int), - z, a, b, z.prec - z.val) + @ccall libflint.fmpz_poly_pow_trunc(z::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, b::Int, (z.prec - z.val)::Int)::Nothing end return z end @@ -429,9 +390,7 @@ function ==(x::ZZRelPowerSeriesRingElem, y::ZZRelPowerSeriesRingElem) if xlen != ylen return false end - return Bool(ccall((:fmpz_poly_equal_trunc, libflint), Cint, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - x, y, xlen)) + return Bool(@ccall libflint.fmpz_poly_equal_trunc(x::Ref{ZZRelPowerSeriesRingElem}, y::Ref{ZZRelPowerSeriesRingElem}, xlen::Int)::Cint) end function isequal(x::ZZRelPowerSeriesRingElem, y::ZZRelPowerSeriesRingElem) @@ -441,9 +400,7 @@ function isequal(x::ZZRelPowerSeriesRingElem, y::ZZRelPowerSeriesRingElem) if x.prec != y.prec || x.val != y.val || pol_length(x) != pol_length(y) return false end - return Bool(ccall((:fmpz_poly_equal, libflint), Cint, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}), - x, y)) + return Bool(@ccall libflint.fmpz_poly_equal(x::Ref{ZZRelPowerSeriesRingElem}, y::Ref{ZZRelPowerSeriesRingElem})::Cint) end ############################################################################### @@ -460,10 +417,8 @@ function ==(x::ZZRelPowerSeriesRingElem, y::ZZRingElem) elseif pol_length(x) == 1 if x.val == 0 z = ZZRingElem() - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), z, x, 0) - return ccall((:fmpz_equal, libflint), Bool, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Int), z, y, 0) + @ccall libflint.fmpz_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{ZZRelPowerSeriesRingElem}, 0::Int)::Nothing + return @ccall libflint.fmpz_equal(z::Ref{ZZRingElem}, y::Ref{ZZRingElem}, 0::Int)::Bool else return false end @@ -501,9 +456,7 @@ function divexact(x::ZZRelPowerSeriesRingElem, y::ZZRelPowerSeriesRingElem; chec z.val = xval - yval z.prec = prec + z.val if prec != 0 - ccall((:fmpz_poly_div_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, x, y, prec) + @ccall libflint.fmpz_poly_div_series(z::Ref{ZZRelPowerSeriesRingElem}, x::Ref{ZZRelPowerSeriesRingElem}, y::Ref{ZZRelPowerSeriesRingElem}, prec::Int)::Nothing end return z end @@ -519,9 +472,7 @@ function divexact(x::ZZRelPowerSeriesRingElem, y::Int; check::Bool=true) z = parent(x)() z.prec = x.prec z.val = x.val - ccall((:fmpz_poly_scalar_divexact_si, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, x, y) + @ccall libflint.fmpz_poly_scalar_divexact_si(z::Ref{ZZRelPowerSeriesRingElem}, x::Ref{ZZRelPowerSeriesRingElem}, y::Int)::Nothing return z end @@ -531,9 +482,7 @@ function divexact(x::ZZRelPowerSeriesRingElem, y::ZZRingElem; check::Bool=true) z.prec = x.prec z.prec = x.prec z.val = x.val - ccall((:fmpz_poly_scalar_divexact_fmpz, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRingElem}), - z, x, y) + @ccall libflint.fmpz_poly_scalar_divexact_fmpz(z::Ref{ZZRelPowerSeriesRingElem}, x::Ref{ZZRelPowerSeriesRingElem}, y::Ref{ZZRingElem})::Nothing return z end @@ -551,9 +500,7 @@ function inv(a::ZZRelPowerSeriesRingElem) ainv = parent(a)() ainv.prec = a.prec ainv.val = 0 - ccall((:fmpz_poly_inv_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - ainv, a, a.prec) + @ccall libflint.fmpz_poly_inv_series(ainv::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, a.prec::Int)::Nothing return ainv end @@ -568,9 +515,7 @@ function Base.sqrt(a::ZZRelPowerSeriesRingElem; check::Bool=true) val = div(valuation(a), 2) asqrt.prec = a.prec - val asqrt.val = val - flag = Bool(ccall((:fmpz_poly_sqrt_series, libflint), Cint, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - asqrt, a, a.prec - 2*val)) + flag = Bool(@ccall libflint.fmpz_poly_sqrt_series(asqrt::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, (a.prec - 2*val)::Int)::Cint) check && flag == false && error("Not a square in sqrt") return asqrt end @@ -582,31 +527,26 @@ end ############################################################################### function zero!(x::ZZRelPowerSeriesRingElem) - ccall((:fmpz_poly_zero, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem},), x) + @ccall libflint.fmpz_poly_zero(x::Ref{ZZRelPowerSeriesRingElem})::Nothing x.prec = parent(x).prec_max x.val = parent(x).prec_max return x end function one!(x::ZZRelPowerSeriesRingElem) - ccall((:fmpz_poly_one, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem},), x) + @ccall libflint.fmpz_poly_one(x::Ref{ZZRelPowerSeriesRingElem})::Nothing x.prec = parent(x).prec_max x.val = 0 return x end function fit!(z::ZZRelPowerSeriesRingElem, n::Int) - ccall((:fmpz_poly_fit_length, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Int), z, n) + @ccall libflint.fmpz_poly_fit_length(z::Ref{ZZRelPowerSeriesRingElem}, n::Int)::Nothing return nothing end function setcoeff!(z::ZZRelPowerSeriesRingElem, n::Int, x::ZZRingElem) - ccall((:fmpz_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Int, Ref{ZZRingElem}), - z, n, x) + @ccall libflint.fmpz_poly_set_coeff_fmpz(z::Ref{ZZRelPowerSeriesRingElem}, n::Int, x::Ref{ZZRingElem})::Nothing return z end @@ -624,9 +564,7 @@ function mul!(z::ZZRelPowerSeriesRingElem, a::ZZRelPowerSeriesRingElem, b::ZZRel if lena <= 0 || lenb <= 0 lenz = 0 end - ccall((:fmpz_poly_mullow, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, a, b, lenz) + @ccall libflint.fmpz_poly_mullow(z::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, b::Ref{ZZRelPowerSeriesRingElem}, lenz::Int)::Nothing return z end @@ -644,28 +582,18 @@ function add!(a::ZZRelPowerSeriesRingElem, b::ZZRelPowerSeriesRingElem) ccall((:fmpz_poly_set_trunc, libflint), Nothing, (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), z, b, max(0, lenz - b.val + a.val)) - ccall((:fmpz_poly_shift_left, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - z, z, b.val - a.val) - ccall((:fmpz_poly_add_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - a, a, z, lenz) + @ccall libflint.fmpz_poly_shift_left(z::Ref{ZZRelPowerSeriesRingElem}, z::Ref{ZZRelPowerSeriesRingElem}, (b.val - a.val)::Int)::Nothing + @ccall libflint.fmpz_poly_add_series(a::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, z::Ref{ZZRelPowerSeriesRingElem}, lenz::Int)::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:fmpz_poly_truncate, libflint), Nothing, (Ref{ZZRelPowerSeriesRingElem}, Int), a, max(0, lenz - a.val + b.val)) - ccall((:fmpz_poly_shift_left, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - a, a, a.val - b.val) - ccall((:fmpz_poly_add_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - a, a, b, lenz) + @ccall libflint.fmpz_poly_shift_left(a::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, (a.val - b.val)::Int)::Nothing + @ccall libflint.fmpz_poly_add_series(a::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, b::Ref{ZZRelPowerSeriesRingElem}, lenz::Int)::Nothing else lenz = max(lena, lenb) - ccall((:fmpz_poly_add_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - a, a, b, lenz) + @ccall libflint.fmpz_poly_add_series(a::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, b::Ref{ZZRelPowerSeriesRingElem}, lenz::Int)::Nothing end a.prec = prec a.val = val @@ -690,28 +618,18 @@ function add!(c::ZZRelPowerSeriesRingElem, a::ZZRelPowerSeriesRingElem, b::ZZRel ccall((:fmpz_poly_set_trunc, libflint), Nothing, (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), c, b, max(0, lenc - b.val + a.val)) - ccall((:fmpz_poly_shift_left, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - c, c, b.val - a.val) - ccall((:fmpz_poly_add_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - c, c, a, lenc) + @ccall libflint.fmpz_poly_shift_left(c::Ref{ZZRelPowerSeriesRingElem}, c::Ref{ZZRelPowerSeriesRingElem}, (b.val - a.val)::Int)::Nothing + @ccall libflint.fmpz_poly_add_series(c::Ref{ZZRelPowerSeriesRingElem}, c::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, lenc::Int)::Nothing elseif b.val < a.val lenc = max(lena + a.val - b.val, lenb) ccall((:fmpz_poly_set_trunc, libflint), Nothing, (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), c, a, max(0, lenc - a.val + b.val)) - ccall((:fmpz_poly_shift_left, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - c, c, a.val - b.val) - ccall((:fmpz_poly_add_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - c, c, b, lenc) + @ccall libflint.fmpz_poly_shift_left(c::Ref{ZZRelPowerSeriesRingElem}, c::Ref{ZZRelPowerSeriesRingElem}, (a.val - b.val)::Int)::Nothing + @ccall libflint.fmpz_poly_add_series(c::Ref{ZZRelPowerSeriesRingElem}, c::Ref{ZZRelPowerSeriesRingElem}, b::Ref{ZZRelPowerSeriesRingElem}, lenc::Int)::Nothing else lenc = max(lena, lenb) - ccall((:fmpz_poly_add_series, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Ref{ZZRelPowerSeriesRingElem}, Int), - c, a, b, lenc) + @ccall libflint.fmpz_poly_add_series(c::Ref{ZZRelPowerSeriesRingElem}, a::Ref{ZZRelPowerSeriesRingElem}, b::Ref{ZZRelPowerSeriesRingElem}, lenc::Int)::Nothing end c.prec = prec c.val = val @@ -720,8 +638,7 @@ function add!(c::ZZRelPowerSeriesRingElem, a::ZZRelPowerSeriesRingElem, b::ZZRel end function set_length!(a::ZZRelPowerSeriesRingElem, n::Int) - ccall((:_fmpz_poly_set_length, libflint), Nothing, - (Ref{ZZRelPowerSeriesRingElem}, Int), a, n) + @ccall libflint._fmpz_poly_set_length(a::Ref{ZZRelPowerSeriesRingElem}, n::Int)::Nothing return a end diff --git a/src/flint/fq.jl b/src/flint/fq.jl index 7ae85c0b3..1901cc3e7 100644 --- a/src/flint/fq.jl +++ b/src/flint/fq.jl @@ -32,8 +32,7 @@ function Base.hash(a::FqPolyRepFieldElem, h::UInt) b = 0xb310fb6ea97e1f1a%UInt z = ZZRingElem() for i in 0:degree(parent(a)) - 1 - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FqPolyRepFieldElem}, Int), z, a, i) + @ccall libflint.fmpz_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, a::Ref{FqPolyRepFieldElem}, i::Int)::Nothing b = xor(b, xor(hash(z, h), h)) b = (b << 1) | (b >> (sizeof(Int)*8 - 1)) end @@ -49,8 +48,7 @@ finite field element. function coeff(x::FqPolyRepFieldElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = ZZRingElem() - ccall((:fmpz_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FqPolyRepFieldElem}, Int), z, x, n) + @ccall libflint.fmpz_poly_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{FqPolyRepFieldElem}, n::Int)::Nothing return z end @@ -67,15 +65,13 @@ Conway polynomial automatically. """ function gen(a::FqPolyRepField) d = a() - ccall((:fq_gen, libflint), Nothing, (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), d, a) + @ccall libflint.fq_gen(d::Ref{FqPolyRepFieldElem}, a::Ref{FqPolyRepField})::Nothing return d end -iszero(a::FqPolyRepFieldElem) = ccall((:fq_is_zero, libflint), Bool, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), a, a.parent) +iszero(a::FqPolyRepFieldElem) = @ccall libflint.fq_is_zero(a::Ref{FqPolyRepFieldElem}, a.parent::Ref{FqPolyRepField})::Bool -isone(a::FqPolyRepFieldElem) = ccall((:fq_is_one, libflint), Bool, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), a, a.parent) +isone(a::FqPolyRepFieldElem) = @ccall libflint.fq_is_one(a::Ref{FqPolyRepFieldElem}, a.parent::Ref{FqPolyRepField})::Bool @doc raw""" is_gen(a::FqPolyRepFieldElem) @@ -85,20 +81,17 @@ finite field, otherwise return `false`. """ is_gen(a::FqPolyRepFieldElem) = a == gen(parent(a)) -is_unit(a::FqPolyRepFieldElem) = ccall((:fq_is_invertible, libflint), Bool, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), a, a.parent) +is_unit(a::FqPolyRepFieldElem) = @ccall libflint.fq_is_invertible(a::Ref{FqPolyRepFieldElem}, a.parent::Ref{FqPolyRepField})::Bool function characteristic(a::FqPolyRepField) d = ZZRingElem() - ccall((:__fq_ctx_prime, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FqPolyRepField}), d, a) + @ccall libflint.__fq_ctx_prime(d::Ref{ZZRingElem}, a::Ref{FqPolyRepField})::Nothing return d end function order(a::FqPolyRepField) d = ZZRingElem() - ccall((:fq_ctx_order, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FqPolyRepField}), d, a) + @ccall libflint.fq_ctx_order(d::Ref{ZZRingElem}, a::Ref{FqPolyRepField})::Nothing return d end @@ -108,7 +101,7 @@ end Return the degree of the given finite field. """ function degree(a::FqPolyRepField) - return ccall((:fq_ctx_degree, libflint), Int, (Ref{FqPolyRepField},), a) + return @ccall libflint.fq_ctx_degree(a::Ref{FqPolyRepField})::Int end function deepcopy_internal(d::FqPolyRepFieldElem, dict::IdDict) @@ -180,24 +173,21 @@ end function +(x::FqPolyRepFieldElem, y::FqPolyRepFieldElem) check_parent(x, y) z = parent(y)() - ccall((:fq_add, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, x, y, y.parent) + @ccall libflint.fq_add(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, y::Ref{FqPolyRepFieldElem}, y.parent::Ref{FqPolyRepField})::Nothing return z end function -(x::FqPolyRepFieldElem, y::FqPolyRepFieldElem) check_parent(x, y) z = parent(y)() - ccall((:fq_sub, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, x, y, y.parent) + @ccall libflint.fq_sub(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, y::Ref{FqPolyRepFieldElem}, y.parent::Ref{FqPolyRepField})::Nothing return z end function *(x::FqPolyRepFieldElem, y::FqPolyRepFieldElem) check_parent(x, y) z = parent(y)() - ccall((:fq_mul, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, x, y, y.parent) + @ccall libflint.fq_mul(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, y::Ref{FqPolyRepFieldElem}, y.parent::Ref{FqPolyRepField})::Nothing return z end @@ -209,8 +199,7 @@ end function *(x::Int, y::FqPolyRepFieldElem) z = parent(y)() - ccall((:fq_mul_si, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Int, Ref{FqPolyRepField}), z, y, x, y.parent) + @ccall libflint.fq_mul_si(z::Ref{FqPolyRepFieldElem}, y::Ref{FqPolyRepFieldElem}, x::Int, y.parent::Ref{FqPolyRepField})::Nothing return z end @@ -220,9 +209,7 @@ end function *(x::ZZRingElem, y::FqPolyRepFieldElem) z = parent(y)() - ccall((:fq_mul_fmpz, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{ZZRingElem}, Ref{FqPolyRepField}), - z, y, x, y.parent) + @ccall libflint.fq_mul_fmpz(z::Ref{FqPolyRepFieldElem}, y::Ref{FqPolyRepFieldElem}, x::Ref{ZZRingElem}, y.parent::Ref{FqPolyRepField})::Nothing return z end @@ -256,8 +243,7 @@ function ^(x::FqPolyRepFieldElem, y::Int) y = -y end z = parent(x)() - ccall((:fq_pow_ui, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Int, Ref{FqPolyRepField}), z, x, y, x.parent) + @ccall libflint.fq_pow_ui(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, y::Int, x.parent::Ref{FqPolyRepField})::Nothing return z end @@ -267,9 +253,7 @@ function ^(x::FqPolyRepFieldElem, y::ZZRingElem) y = -y end z = parent(x)() - ccall((:fq_pow, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{ZZRingElem}, Ref{FqPolyRepField}), - z, x, y, x.parent) + @ccall libflint.fq_pow(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, y::Ref{ZZRingElem}, x.parent::Ref{FqPolyRepField})::Nothing return z end @@ -281,8 +265,7 @@ end function ==(x::FqPolyRepFieldElem, y::FqPolyRepFieldElem) check_parent(x, y) - ccall((:fq_equal, libflint), Bool, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), x, y, y.parent) + @ccall libflint.fq_equal(x::Ref{FqPolyRepFieldElem}, y::Ref{FqPolyRepFieldElem}, y.parent::Ref{FqPolyRepField})::Bool end ############################################################################### @@ -309,8 +292,7 @@ function divexact(x::FqPolyRepFieldElem, y::FqPolyRepFieldElem; check::Bool=true check_parent(x, y) iszero(y) && throw(DivideError()) z = parent(y)() - ccall((:fq_div, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, x, y, y.parent) + @ccall libflint.fq_div(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, y::Ref{FqPolyRepFieldElem}, y.parent::Ref{FqPolyRepField})::Nothing return z end @@ -347,8 +329,7 @@ divexact(x::ZZRingElem, y::FqPolyRepFieldElem; check::Bool=true) = divexact(pare function inv(x::FqPolyRepFieldElem) iszero(x) && throw(DivideError()) z = parent(x)() - ccall((:fq_inv, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, x, x.parent) + @ccall libflint.fq_inv(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, x.parent::Ref{FqPolyRepField})::Nothing return z end @@ -360,24 +341,18 @@ end function sqrt(x::FqPolyRepFieldElem; check::Bool=true) z = parent(x)() - res = Bool(ccall((:fq_sqrt, libflint), Cint, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - z, x, x.parent)) + res = Bool(@ccall libflint.fq_sqrt(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, x.parent::Ref{FqPolyRepField})::Cint) check && !res && error("Not a square") return z end function is_square(x::FqPolyRepFieldElem) - return Bool(ccall((:fq_is_square, libflint), Cint, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - x, x.parent)) + return Bool(@ccall libflint.fq_is_square(x::Ref{FqPolyRepFieldElem}, x.parent::Ref{FqPolyRepField})::Cint) end function is_square_with_sqrt(x::FqPolyRepFieldElem) z = parent(x)() - flag = ccall((:fq_sqrt, libflint), Cint, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - z, x, x.parent) + flag = @ccall libflint.fq_sqrt(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, x.parent::Ref{FqPolyRepField})::Cint return (Bool(flag), z) end @@ -389,8 +364,7 @@ is the inverse operation to the Frobenius map $\sigma_p$. """ function pth_root(x::FqPolyRepFieldElem) z = parent(x)() - ccall((:fq_pth_root, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, x, x.parent) + @ccall libflint.fq_pth_root(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, x.parent::Ref{FqPolyRepField})::Nothing return z end @@ -402,8 +376,7 @@ is this value embedded in the original finite field. """ function tr(x::FqPolyRepFieldElem) z = ZZRingElem() - ccall((:fq_trace, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, x, x.parent) + @ccall libflint.fq_trace(z::Ref{ZZRingElem}, x::Ref{FqPolyRepFieldElem}, x.parent::Ref{FqPolyRepField})::Nothing return parent(x)(z) end @@ -415,8 +388,7 @@ is this value embedded in the original finite field. """ function norm(x::FqPolyRepFieldElem) z = ZZRingElem() - ccall((:fq_norm, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, x, x.parent) + @ccall libflint.fq_norm(z::Ref{ZZRingElem}, x::Ref{FqPolyRepFieldElem}, x.parent::Ref{FqPolyRepField})::Nothing return parent(x)(z) end @@ -430,8 +402,7 @@ $n$ is not specified. """ function frobenius(x::FqPolyRepFieldElem, n = 1) z = parent(x)() - ccall((:fq_frobenius, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Int, Ref{FqPolyRepField}), z, x, n, x.parent) + @ccall libflint.fq_frobenius(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, n::Int, x.parent::Ref{FqPolyRepField})::Nothing return z end @@ -448,9 +419,7 @@ Lift the finite field element `x` to a polynomial over the prime field. """ function lift(R::FpPolyRing, x::FqPolyRepFieldElem) c = R() - ccall((:fq_get_fmpz_mod_poly, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - c, x, parent(x)) + @ccall libflint.fq_get_fmpz_mod_poly(c::Ref{FpPolyRingElem}, x::Ref{FqPolyRepFieldElem}, parent(x)::Ref{FqPolyRepField})::Nothing return c end @@ -461,20 +430,17 @@ end ############################################################################### function zero!(z::FqPolyRepFieldElem) - ccall((:fq_zero, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, z.parent) + @ccall libflint.fq_zero(z::Ref{FqPolyRepFieldElem}, z.parent::Ref{FqPolyRepField})::Nothing return z end function one!(z::FqPolyRepFieldElem) - ccall((:fq_one, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, z.parent) + @ccall libflint.fq_one(z::Ref{FqPolyRepFieldElem}, z.parent::Ref{FqPolyRepField})::Nothing return z end function neg!(z::FqPolyRepFieldElem, a::FqPolyRepFieldElem) - ccall((:fq_neg, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, a, a.parent) + @ccall libflint.fq_neg(z::Ref{FqPolyRepFieldElem}, a::Ref{FqPolyRepFieldElem}, a.parent::Ref{FqPolyRepField})::Nothing return z end @@ -513,14 +479,12 @@ end # function mul!(z::FqPolyRepFieldElem, x::FqPolyRepFieldElem, y::FqPolyRepFieldElem) - ccall((:fq_mul, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, x, y, y.parent) + @ccall libflint.fq_mul(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, y::Ref{FqPolyRepFieldElem}, y.parent::Ref{FqPolyRepField})::Nothing return z end function add!(z::FqPolyRepFieldElem, x::FqPolyRepFieldElem, y::FqPolyRepFieldElem) - ccall((:fq_add, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), z, x, y, x.parent) + @ccall libflint.fq_add(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepFieldElem}, y::Ref{FqPolyRepFieldElem}, x.parent::Ref{FqPolyRepField})::Nothing return z end @@ -538,11 +502,8 @@ Return the modulus defining the finite field $k$. function modulus(k::FqPolyRepField, var::VarName=:T) p = characteristic(k) Q = polynomial(Native.GF(p), [], Symbol(var)) - P = ccall((:fq_ctx_modulus, libflint), Ref{FpPolyRingElem}, - (Ref{FqPolyRepField},), k) - ccall((:fmpz_mod_poly_set, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{FpField}), - Q, P, base_ring(Q)) + P = @ccall libflint.fq_ctx_modulus(k::Ref{FqPolyRepField})::Ref{FpPolyRingElem} + @ccall libflint.fmpz_mod_poly_set(Q::Ref{FpPolyRingElem}, P::Ref{FpPolyRingElem}, base_ring(Q)::Ref{FpField})::Nothing return Q end @@ -556,11 +517,8 @@ end function defining_polynomial(R::FpPolyRing, k::FqPolyRepField) Q = R() GC.@preserve k begin - P = ccall((:fq_ctx_modulus, libflint), Ptr{FpPolyRingElem}, - (Ref{FqPolyRepField},), k) - ccall((:fmpz_mod_poly_set, libflint), Nothing, - (Ref{FpPolyRingElem}, Ptr{FpPolyRingElem}), - Q, P) + P = @ccall libflint.fq_ctx_modulus(k::Ref{FqPolyRepField})::Ptr{FpPolyRingElem} + @ccall libflint.fmpz_mod_poly_set(Q::Ref{FpPolyRingElem}, P::Ptr{FpPolyRingElem})::Nothing end return Q end diff --git a/src/flint/fq_default.jl b/src/flint/fq_default.jl index ad6bc8e6d..8e3050e27 100644 --- a/src/flint/fq_default.jl +++ b/src/flint/fq_default.jl @@ -40,9 +40,7 @@ end function _coeff(x::FqFieldElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = ZZRingElem() - ccall((:fq_default_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FqFieldElem}, Int, Ref{FqField}), - z, x, n, parent(x)) + @ccall libflint.fq_default_get_coeff_fmpz(z::Ref{ZZRingElem}, x::Ref{FqFieldElem}, n::Int, parent(x)::Ref{FqField})::Nothing return z end @@ -52,37 +50,32 @@ one(a::FqField) = one!(a()) function _gen(a::FqField) d = a() - ccall((:fq_default_gen, libflint), Nothing, (Ref{FqFieldElem}, Ref{FqField}), d, a) + @ccall libflint.fq_default_gen(d::Ref{FqFieldElem}, a::Ref{FqField})::Nothing return d end -iszero(a::FqFieldElem) = ccall((:fq_default_is_zero, libflint), Bool, - (Ref{FqFieldElem}, Ref{FqField}), a, a.parent) +iszero(a::FqFieldElem) = @ccall libflint.fq_default_is_zero(a::Ref{FqFieldElem}, a.parent::Ref{FqField})::Bool -isone(a::FqFieldElem) = ccall((:fq_default_is_one, libflint), Bool, - (Ref{FqFieldElem}, Ref{FqField}), a, a.parent) +isone(a::FqFieldElem) = @ccall libflint.fq_default_is_one(a::Ref{FqFieldElem}, a.parent::Ref{FqField})::Bool _is_gen(a::FqFieldElem) = a == _gen(parent(a)) -is_unit(a::FqFieldElem) = ccall((:fq_default_is_invertible, libflint), Bool, - (Ref{FqFieldElem}, Ref{FqField}), a, a.parent) +is_unit(a::FqFieldElem) = @ccall libflint.fq_default_is_invertible(a::Ref{FqFieldElem}, a.parent::Ref{FqField})::Bool function characteristic(a::FqField) d = ZZRingElem() - ccall((:fq_default_ctx_prime, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FqField}), d, a) + @ccall libflint.fq_default_ctx_prime(d::Ref{ZZRingElem}, a::Ref{FqField})::Nothing return d end function order(a::FqField) d = ZZRingElem() - ccall((:fq_default_ctx_order, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FqField}), d, a) + @ccall libflint.fq_default_ctx_order(d::Ref{ZZRingElem}, a::Ref{FqField})::Nothing return d end function _degree(a::FqField) - return ccall((:fq_default_ctx_degree, libflint), Int, (Ref{FqField},), a) + return @ccall libflint.fq_default_ctx_degree(a::Ref{FqField})::Int end function deepcopy_internal(d::FqFieldElem, dict::IdDict) @@ -113,9 +106,7 @@ julia> lift(ZZ, K(3)) """ function lift(R::ZZRing, x::FqFieldElem) z = R() - ok = ccall((:fq_default_get_fmpz, libflint), Cint, - (Ref{ZZRingElem}, Ref{FqFieldElem}, Ref{FqField}), - z, x, parent(x)) + ok = @ccall libflint.fq_default_get_fmpz(z::Ref{ZZRingElem}, x::Ref{FqFieldElem}, parent(x)::Ref{FqField})::Cint ok == 0 && error("cannot lift") return z end @@ -123,58 +114,44 @@ end function lift(R::ZZPolyRing, x::FqFieldElem) p = R() !parent(x).isstandard && error("Cannot lift to integer polynomial") - ccall((:fq_default_get_fmpz_poly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), - p, x, parent(x)) + @ccall libflint.fq_default_get_fmpz_poly(p::Ref{ZZPolyRingElem}, x::Ref{FqFieldElem}, parent(x)::Ref{FqField})::Nothing return p end function (R::zzModPolyRing)(x::FqFieldElem) p = R() - ccall((:fq_default_get_nmod_poly, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), - p, x, parent(x)) + @ccall libflint.fq_default_get_nmod_poly(p::Ref{zzModPolyRingElem}, x::Ref{FqFieldElem}, parent(x)::Ref{FqField})::Nothing return p end function (R::fpPolyRing)(x::FqFieldElem) p = R() - ccall((:fq_default_get_nmod_poly, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), - p, x, parent(x)) + @ccall libflint.fq_default_get_nmod_poly(p::Ref{fpPolyRingElem}, x::Ref{FqFieldElem}, parent(x)::Ref{FqField})::Nothing return p end function (R::ZZModPolyRing)(x::FqFieldElem) p = R() - ccall((:fq_default_get_fmpz_mod_poly, libflint), Nothing, - (Ref{ZZModPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), - p, x, parent(x)) + @ccall libflint.fq_default_get_fmpz_mod_poly(p::Ref{ZZModPolyRingElem}, x::Ref{FqFieldElem}, parent(x)::Ref{FqField})::Nothing return p end function (R::FpPolyRing)(x::FqFieldElem) p = R() - ccall((:fq_default_get_fmpz_mod_poly, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), - p, x, parent(x)) + @ccall libflint.fq_default_get_fmpz_mod_poly(p::Ref{FpPolyRingElem}, x::Ref{FqFieldElem}, parent(x)::Ref{FqField})::Nothing return p end # with FqPolyRepFieldElem function _unchecked_coerce(a::FqPolyRepField, b::FqFieldElem) x = ZZPolyRingElem() - ccall((:fq_default_get_fmpz_poly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), - x, b, parent(b)) + @ccall libflint.fq_default_get_fmpz_poly(x::Ref{ZZPolyRingElem}, b::Ref{FqFieldElem}, parent(b)::Ref{FqField})::Nothing return FqPolyRepFieldElem(a, x) end function _unchecked_coerce(a::FqField, b::FqPolyRepFieldElem) x = ZZPolyRingElem() - ccall((:fq_get_fmpz_poly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - x, b, parent(b)) + @ccall libflint.fq_get_fmpz_poly(x::Ref{ZZPolyRingElem}, b::Ref{FqPolyRepFieldElem}, parent(b)::Ref{FqPolyRepField})::Nothing return FqFieldElem(a, x) end @@ -201,21 +178,15 @@ end # with fqPolyRepFieldElem function _unchecked_coerce(a::fqPolyRepField, b::FqFieldElem) x = zzModPolyRingElem(UInt(characteristic(a))) - ccall((:fq_default_get_nmod_poly, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), - x, b, parent(b)) + @ccall libflint.fq_default_get_nmod_poly(x::Ref{zzModPolyRingElem}, b::Ref{FqFieldElem}, parent(b)::Ref{FqField})::Nothing y = a() - ccall((:fq_nmod_set_nmod_poly, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{zzModPolyRingElem}, Ref{fqPolyRepField}), - y, x, a) + @ccall libflint.fq_nmod_set_nmod_poly(y::Ref{fqPolyRepFieldElem}, x::Ref{zzModPolyRingElem}, a::Ref{fqPolyRepField})::Nothing return y end function _unchecked_coerce(a::FqField, b::fqPolyRepFieldElem) x = zzModPolyRingElem(UInt(characteristic(parent(b)))) - ccall((:fq_nmod_get_nmod_poly, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - x, b, parent(b)) + @ccall libflint.fq_nmod_get_nmod_poly(x::Ref{zzModPolyRingElem}, b::Ref{fqPolyRepFieldElem}, parent(b)::Ref{fqPolyRepField})::Nothing return FqFieldElem(a, x) end @@ -250,7 +221,7 @@ domain(f::CanonicalFqDefaultMapInverse) = f.D codomain(f::CanonicalFqDefaultMapInverse) = f.C function _fq_default_ctx_type(F::FqField) - return ccall((:fq_default_ctx_type, libflint), Cint, (Ref{FqField},), F) + return @ccall libflint.fq_default_ctx_type(F::Ref{FqField})::Cint end function _get_raw_type(::Type{fqPolyRepField}, F::FqField) @@ -455,8 +426,7 @@ function ^(x::FqFieldElem, y::Int) y = -y end z = parent(x)() - ccall((:fq_default_pow_ui, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqFieldElem}, Int, Ref{FqField}), z, x, y, x.parent) + @ccall libflint.fq_default_pow_ui(z::Ref{FqFieldElem}, x::Ref{FqFieldElem}, y::Int, x.parent::Ref{FqField})::Nothing return z end @@ -466,9 +436,7 @@ function ^(x::FqFieldElem, y::ZZRingElem) y = -y end z = parent(x)() - ccall((:fq_default_pow, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqFieldElem}, Ref{ZZRingElem}, Ref{FqField}), - z, x, y, x.parent) + @ccall libflint.fq_default_pow(z::Ref{FqFieldElem}, x::Ref{FqFieldElem}, y::Ref{ZZRingElem}, x.parent::Ref{FqField})::Nothing return z end @@ -480,8 +448,7 @@ end function ==(x::FqFieldElem, y::FqFieldElem) check_parent(x, y) - ccall((:fq_default_equal, libflint), Bool, - (Ref{FqFieldElem}, Ref{FqFieldElem}, Ref{FqField}), x, y, y.parent) + @ccall libflint.fq_default_equal(x::Ref{FqFieldElem}, y::Ref{FqFieldElem}, y.parent::Ref{FqField})::Bool end ############################################################################### @@ -508,8 +475,7 @@ function divexact(x::FqFieldElem, y::FqFieldElem; check::Bool=true) if parent(x) === parent(y) iszero(y) && throw(DivideError()) z = parent(y)() - ccall((:fq_default_div, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqFieldElem}, Ref{FqFieldElem}, Ref{FqField}), z, x, y, y.parent) + @ccall libflint.fq_default_div(z::Ref{FqFieldElem}, x::Ref{FqFieldElem}, y::Ref{FqFieldElem}, y.parent::Ref{FqField})::Nothing return z end return divexact(_promote(x, y)...) @@ -551,8 +517,7 @@ divexact(x::ZZRingElem, y::FqFieldElem; check::Bool=true) = divexact(parent(y)(x function inv(x::FqFieldElem) iszero(x) && throw(DivideError()) z = parent(x)() - ccall((:fq_default_inv, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqFieldElem}, Ref{FqField}), z, x, x.parent) + @ccall libflint.fq_default_inv(z::Ref{FqFieldElem}, x::Ref{FqFieldElem}, x.parent::Ref{FqField})::Nothing return z end @@ -564,24 +529,18 @@ end function sqrt(x::FqFieldElem) z = parent(x)() - res = Bool(ccall((:fq_default_sqrt, libflint), Cint, - (Ref{FqFieldElem}, Ref{FqFieldElem}, Ref{FqField}), - z, x, x.parent)) + res = Bool(@ccall libflint.fq_default_sqrt(z::Ref{FqFieldElem}, x::Ref{FqFieldElem}, x.parent::Ref{FqField})::Cint) res || error("Not a square") return z end function is_square(x::FqFieldElem) - return Bool(ccall((:fq_default_is_square, libflint), Cint, - (Ref{FqFieldElem}, Ref{FqField}), - x, x.parent)) + return Bool(@ccall libflint.fq_default_is_square(x::Ref{FqFieldElem}, x.parent::Ref{FqField})::Cint) end function is_square_with_sqrt(x::FqFieldElem) z = parent(x)() - flag = ccall((:fq_default_sqrt, libflint), Cint, - (Ref{FqFieldElem}, Ref{FqFieldElem}, Ref{FqField}), - z, x, x.parent) + flag = @ccall libflint.fq_default_sqrt(z::Ref{FqFieldElem}, x::Ref{FqFieldElem}, x.parent::Ref{FqField})::Cint return (Bool(flag), z) end @@ -593,29 +552,25 @@ is the inverse operation to the absolute Frobenius map. """ function pth_root(x::FqFieldElem) z = parent(x)() - ccall((:fq_default_pth_root, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqFieldElem}, Ref{FqField}), z, x, x.parent) + @ccall libflint.fq_default_pth_root(z::Ref{FqFieldElem}, x::Ref{FqFieldElem}, x.parent::Ref{FqField})::Nothing return z end function _tr(x::FqFieldElem) z = ZZRingElem() - ccall((:fq_default_trace, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FqFieldElem}, Ref{FqField}), z, x, x.parent) + @ccall libflint.fq_default_trace(z::Ref{ZZRingElem}, x::Ref{FqFieldElem}, x.parent::Ref{FqField})::Nothing return z end function _norm(x::FqFieldElem) z = ZZRingElem() - ccall((:fq_default_norm, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FqFieldElem}, Ref{FqField}), z, x, x.parent) + @ccall libflint.fq_default_norm(z::Ref{ZZRingElem}, x::Ref{FqFieldElem}, x.parent::Ref{FqField})::Nothing return z end function _frobenius(x::FqFieldElem, n = 1) z = parent(x)() - ccall((:fq_default_frobenius, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqFieldElem}, Int, Ref{FqField}), z, x, n, x.parent) + @ccall libflint.fq_default_frobenius(z::Ref{FqFieldElem}, x::Ref{FqFieldElem}, n::Int, x.parent::Ref{FqField})::Nothing return z end @@ -626,22 +581,19 @@ end ############################################################################### function zero!(z::FqFieldElem) - ccall((:fq_default_zero, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqField}), z, z.parent) + @ccall libflint.fq_default_zero(z::Ref{FqFieldElem}, z.parent::Ref{FqField})::Nothing z.poly = nothing return z end function one!(z::FqFieldElem) - ccall((:fq_default_one, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqField}), z, z.parent) + @ccall libflint.fq_default_one(z::Ref{FqFieldElem}, z.parent::Ref{FqField})::Nothing z.poly = nothing return z end function neg!(z::FqFieldElem, a::FqFieldElem) - ccall((:fq_default_neg, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqFieldElem}, Ref{FqField}), z, a, a.parent) + @ccall libflint.fq_default_neg(z::Ref{FqFieldElem}, a::Ref{FqFieldElem}, a.parent::Ref{FqField})::Nothing z.poly = nothing return z end @@ -791,18 +743,14 @@ rand(R::FqField, b::AbstractArray) = rand(Random.GLOBAL_RNG, R, b) function modulus(R::FpPolyRing, k::FqField) Q = R() - ccall((:fq_default_ctx_modulus, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FqField}), - Q, k) + @ccall libflint.fq_default_ctx_modulus(Q::Ref{FpPolyRingElem}, k::Ref{FqField})::Nothing return Q end function modulus(k::FqField, var::String="T") p = characteristic(k) Q = polynomial(Native.GF(p), [], var, cached = false) - ccall((:fq_default_ctx_modulus, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FqField}), - Q, k) + @ccall libflint.fq_default_ctx_modulus(Q::Ref{FpPolyRingElem}, k::Ref{FqField})::Nothing return Q end diff --git a/src/flint/fq_default_abs_series.jl b/src/flint/fq_default_abs_series.jl index e979bdfd6..e7042245e 100644 --- a/src/flint/fq_default_abs_series.jl +++ b/src/flint/fq_default_abs_series.jl @@ -43,16 +43,12 @@ function normalise(a::FqAbsPowerSeriesRingElem, len::Int) ctx = base_ring(a) if len > 0 c = base_ring(a)() - ccall((:fq_default_poly_get_coeff, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - c, a, len - 1, ctx) + @ccall libflint.fq_default_poly_get_coeff(c::Ref{FqFieldElem}, a::Ref{FqAbsPowerSeriesRingElem}, (len - 1)::Int, ctx::Ref{FqField})::Nothing end while len > 0 && iszero(c) len -= 1 if len > 0 - ccall((:fq_default_poly_get_coeff, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - c, a, len - 1, ctx) + @ccall libflint.fq_default_poly_get_coeff(c::Ref{FqFieldElem}, a::Ref{FqAbsPowerSeriesRingElem}, (len - 1)::Int, ctx::Ref{FqField})::Nothing end end @@ -60,8 +56,7 @@ function normalise(a::FqAbsPowerSeriesRingElem, len::Int) end function length(x::FqAbsPowerSeriesRingElem) - return ccall((:fq_default_poly_length, libflint), Int, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqField}), x, base_ring(x)) + return @ccall libflint.fq_default_poly_length(x::Ref{FqAbsPowerSeriesRingElem}, base_ring(x)::Ref{FqField})::Int end precision(x::FqAbsPowerSeriesRingElem) = x.prec @@ -71,9 +66,7 @@ function coeff(x::FqAbsPowerSeriesRingElem, n::Int) return base_ring(x)() end z = base_ring(x)() - ccall((:fq_default_poly_get_coeff, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - z, x, n, base_ring(x)) + @ccall libflint.fq_default_poly_get_coeff(z::Ref{FqFieldElem}, x::Ref{FqAbsPowerSeriesRingElem}, n::Int, base_ring(x)::Ref{FqField})::Nothing return z end @@ -96,8 +89,7 @@ function deepcopy_internal(a::FqAbsPowerSeriesRingElem, dict::IdDict) end function is_gen(a::FqAbsPowerSeriesRingElem) - return precision(a) == 0 || ccall((:fq_default_poly_is_gen, libflint), Bool, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqField}), a, base_ring(a)) + return precision(a) == 0 || @ccall libflint.fq_default_poly_is_gen(a::Ref{FqAbsPowerSeriesRingElem}, base_ring(a)::Ref{FqField})::Bool end iszero(a::FqAbsPowerSeriesRingElem) = length(a) == 0 @@ -105,8 +97,7 @@ iszero(a::FqAbsPowerSeriesRingElem) = length(a) == 0 is_unit(a::FqAbsPowerSeriesRingElem) = valuation(a) == 0 && is_unit(coeff(a, 0)) function isone(a::FqAbsPowerSeriesRingElem) - return precision(a) == 0 || ccall((:fq_default_poly_is_one, libflint), Bool, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqField}), a, base_ring(a)) + return precision(a) == 0 || @ccall libflint.fq_default_poly_is_one(a::Ref{FqAbsPowerSeriesRingElem}, base_ring(a)::Ref{FqField})::Bool end # todo: write an fq_default_poly_valuation @@ -183,10 +174,7 @@ function +(a::FqAbsPowerSeriesRingElem, b::FqAbsPowerSeriesRingElem) lenz = max(lena, lenb) z = parent(a)() z.prec = prec - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, - Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - z, a, b, lenz, base_ring(a)) + @ccall libflint.fq_default_poly_add_series(z::Ref{FqAbsPowerSeriesRingElem}, a::Ref{FqAbsPowerSeriesRingElem}, b::Ref{FqAbsPowerSeriesRingElem}, lenz::Int, base_ring(a)::Ref{FqField})::Nothing return z end @@ -200,10 +188,7 @@ function -(a::FqAbsPowerSeriesRingElem, b::FqAbsPowerSeriesRingElem) lenz = max(lena, lenb) z = parent(a)() z.prec = prec - ccall((:fq_default_poly_sub_series, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, - Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - z, a, b, lenz, base_ring(a)) + @ccall libflint.fq_default_poly_sub_series(z::Ref{FqAbsPowerSeriesRingElem}, a::Ref{FqAbsPowerSeriesRingElem}, b::Ref{FqAbsPowerSeriesRingElem}, lenz::Int, base_ring(a)::Ref{FqField})::Nothing return z end @@ -223,10 +208,7 @@ function *(a::FqAbsPowerSeriesRingElem, b::FqAbsPowerSeriesRingElem) return z end lenz = min(lena + lenb - 1, prec) - ccall((:fq_default_poly_mullow, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, - Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - z, a, b, lenz, base_ring(a)) + @ccall libflint.fq_default_poly_mullow(z::Ref{FqAbsPowerSeriesRingElem}, a::Ref{FqAbsPowerSeriesRingElem}, b::Ref{FqAbsPowerSeriesRingElem}, lenz::Int, base_ring(a)::Ref{FqField})::Nothing return z end @@ -239,9 +221,7 @@ end function *(x::FqFieldElem, y::FqAbsPowerSeriesRingElem) z = parent(y)() z.prec = y.prec - ccall((:fq_default_poly_scalar_mul_fq_default, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, Ref{FqFieldElem}, Ref{FqField}), - z, y, x, base_ring(y)) + @ccall libflint.fq_default_poly_scalar_mul_fq_default(z::Ref{FqAbsPowerSeriesRingElem}, y::Ref{FqAbsPowerSeriesRingElem}, x::Ref{FqFieldElem}, base_ring(y)::Ref{FqField})::Nothing return z end @@ -292,12 +272,8 @@ function shift_left(x::FqAbsPowerSeriesRingElem, len::Int) z.prec = x.prec + len z.prec = min(z.prec, max_precision(parent(x))) zlen = min(z.prec, xlen + len) - ccall((:fq_default_poly_shift_left, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - z, x, len, base_ring(x)) - ccall((:fq_default_poly_set_trunc, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - z, z, zlen, base_ring(x)) + @ccall libflint.fq_default_poly_shift_left(z::Ref{FqAbsPowerSeriesRingElem}, x::Ref{FqAbsPowerSeriesRingElem}, len::Int, base_ring(x)::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_set_trunc(z::Ref{FqAbsPowerSeriesRingElem}, z::Ref{FqAbsPowerSeriesRingElem}, zlen::Int, base_ring(x)::Ref{FqField})::Nothing return z end @@ -309,9 +285,7 @@ function shift_right(x::FqAbsPowerSeriesRingElem, len::Int) z.prec = max(0, x.prec - len) else z.prec = x.prec - len - ccall((:fq_default_poly_shift_right, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - z, x, len, base_ring(x)) + @ccall libflint.fq_default_poly_shift_right(z::Ref{FqAbsPowerSeriesRingElem}, x::Ref{FqAbsPowerSeriesRingElem}, len::Int, base_ring(x)::Ref{FqField})::Nothing end return z end @@ -331,9 +305,7 @@ function truncate!(x::FqAbsPowerSeriesRingElem, k::Int) if precision(x) <= k return x end - ccall((:fq_default_poly_truncate, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - x, k, base_ring(x)) + @ccall libflint.fq_default_poly_truncate(x::Ref{FqAbsPowerSeriesRingElem}, k::Int, base_ring(x)::Ref{FqField})::Nothing x.prec = k return x end @@ -382,9 +354,7 @@ function ==(x::FqAbsPowerSeriesRingElem, y::FqAbsPowerSeriesRingElem) prec = min(x.prec, y.prec) n = max(length(x), length(y)) n = min(n, prec) - return Bool(ccall((:fq_default_poly_equal_trunc, libflint), Cint, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - x, y, n, base_ring(x))) + return Bool(@ccall libflint.fq_default_poly_equal_trunc(x::Ref{FqAbsPowerSeriesRingElem}, y::Ref{FqAbsPowerSeriesRingElem}, n::Int, base_ring(x)::Ref{FqField})::Cint) end function isequal(x::FqAbsPowerSeriesRingElem, y::FqAbsPowerSeriesRingElem) @@ -394,10 +364,7 @@ function isequal(x::FqAbsPowerSeriesRingElem, y::FqAbsPowerSeriesRingElem) if x.prec != y.prec || length(x) != length(y) return false end - return Bool(ccall((:fq_default_poly_equal, libflint), Cint, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, - Ref{FqField}), - x, y, base_ring(x))) + return Bool(@ccall libflint.fq_default_poly_equal(x::Ref{FqAbsPowerSeriesRingElem}, y::Ref{FqAbsPowerSeriesRingElem}, base_ring(x)::Ref{FqField})::Cint) end ############################################################################### @@ -411,9 +378,7 @@ function ==(x::FqAbsPowerSeriesRingElem, y::FqFieldElem) return false elseif length(x) == 1 z = base_ring(x)() - ccall((:fq_default_poly_get_coeff, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - z, x, 0, base_ring(x)) + @ccall libflint.fq_default_poly_get_coeff(z::Ref{FqFieldElem}, x::Ref{FqAbsPowerSeriesRingElem}, 0::Int, base_ring(x)::Ref{FqField})::Nothing return z == y else return precision(x) == 0 || iszero(y) @@ -427,9 +392,7 @@ function ==(x::FqAbsPowerSeriesRingElem, y::ZZRingElem) return false elseif length(x) == 1 z = base_ring(x)() - ccall((:fq_default_poly_get_coeff, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - z, x, 0, base_ring(x)) + @ccall libflint.fq_default_poly_get_coeff(z::Ref{FqFieldElem}, x::Ref{FqAbsPowerSeriesRingElem}, 0::Int, base_ring(x)::Ref{FqField})::Nothing return z == y else return precision(x) == 0 || iszero(y) @@ -463,10 +426,7 @@ function divexact(x::FqAbsPowerSeriesRingElem, y::FqAbsPowerSeriesRingElem; chec prec = min(x.prec, y.prec - v2 + v1) z = parent(x)() z.prec = prec - ccall((:fq_default_poly_div_series, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, - Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - z, x, y, prec, base_ring(x)) + @ccall libflint.fq_default_poly_div_series(z::Ref{FqAbsPowerSeriesRingElem}, x::Ref{FqAbsPowerSeriesRingElem}, y::Ref{FqAbsPowerSeriesRingElem}, prec::Int, base_ring(x)::Ref{FqField})::Nothing return z end @@ -480,9 +440,7 @@ function divexact(x::FqAbsPowerSeriesRingElem, y::FqFieldElem; check::Bool=true) iszero(y) && throw(DivideError()) z = parent(x)() z.prec = x.prec - ccall((:fq_default_poly_scalar_div_fq_default, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, Ref{FqFieldElem}, Ref{FqField}), - z, x, y, base_ring(x)) + @ccall libflint.fq_default_poly_scalar_div_fq_default(z::Ref{FqAbsPowerSeriesRingElem}, x::Ref{FqAbsPowerSeriesRingElem}, y::Ref{FqFieldElem}, base_ring(x)::Ref{FqField})::Nothing return z end @@ -497,9 +455,7 @@ function inv(a::FqAbsPowerSeriesRingElem) !is_unit(a) && error("Unable to invert power series") ainv = parent(a)() ainv.prec = a.prec - ccall((:fq_default_poly_inv_series, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - ainv, a, a.prec, base_ring(a)) + @ccall libflint.fq_default_poly_inv_series(ainv::Ref{FqAbsPowerSeriesRingElem}, a::Ref{FqAbsPowerSeriesRingElem}, a.prec::Int, base_ring(a)::Ref{FqField})::Nothing return ainv end @@ -561,10 +517,7 @@ function sqrt_classical(a::FqAbsPowerSeriesRingElem; check::Bool=true) end a = divexact(a, c) z.prec = a.prec - div(v, 2) - ccall((:fq_default_poly_sqrt_series, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, - Int, Ref{FqField}), - z, a, a.prec, base_ring(a)) + @ccall libflint.fq_default_poly_sqrt_series(z::Ref{FqAbsPowerSeriesRingElem}, a::Ref{FqAbsPowerSeriesRingElem}, a.prec::Int, base_ring(a)::Ref{FqField})::Nothing if !isone(s) z *= s end @@ -596,38 +549,30 @@ end ############################################################################### function zero!(z::FqAbsPowerSeriesRingElem) - ccall((:fq_default_poly_zero, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqField}), z, base_ring(z)) + @ccall libflint.fq_default_poly_zero(z::Ref{FqAbsPowerSeriesRingElem}, base_ring(z)::Ref{FqField})::Nothing z.prec = parent(z).prec_max return z end function one!(z::FqAbsPowerSeriesRingElem) - ccall((:fq_default_poly_one, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqField}), z, base_ring(z)) + @ccall libflint.fq_default_poly_one(z::Ref{FqAbsPowerSeriesRingElem}, base_ring(z)::Ref{FqField})::Nothing z.prec = parent(z).prec_max return z end function neg!(z::FqAbsPowerSeriesRingElem, a::FqAbsPowerSeriesRingElem) - ccall((:fq_default_poly_neg, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, Ref{FqField}), - z, a, base_ring(a)) + @ccall libflint.fq_default_poly_neg(z::Ref{FqAbsPowerSeriesRingElem}, a::Ref{FqAbsPowerSeriesRingElem}, base_ring(a)::Ref{FqField})::Nothing z.prec = a.prec return z end function fit!(z::FqAbsPowerSeriesRingElem, n::Int) - ccall((:fq_default_poly_fit_length, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - z, n, base_ring(z)) + @ccall libflint.fq_default_poly_fit_length(z::Ref{FqAbsPowerSeriesRingElem}, n::Int, base_ring(z)::Ref{FqField})::Nothing return nothing end function setcoeff!(z::FqAbsPowerSeriesRingElem, n::Int, x::FqFieldElem) - ccall((:fq_default_poly_set_coeff, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqFieldElem}, Ref{FqField}), - z, n, x, base_ring(z)) + @ccall libflint.fq_default_poly_set_coeff(z::Ref{FqAbsPowerSeriesRingElem}, n::Int, x::Ref{FqFieldElem}, base_ring(z)::Ref{FqField})::Nothing return z end @@ -645,10 +590,7 @@ function mul!(z::FqAbsPowerSeriesRingElem, a::FqAbsPowerSeriesRingElem, b::FqAbs lenz = 0 end z.prec = prec - ccall((:fq_default_poly_mullow, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, - Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - z, a, b, lenz, base_ring(z)) + @ccall libflint.fq_default_poly_mullow(z::Ref{FqAbsPowerSeriesRingElem}, a::Ref{FqAbsPowerSeriesRingElem}, b::Ref{FqAbsPowerSeriesRingElem}, lenz::Int, base_ring(z)::Ref{FqField})::Nothing return z end @@ -660,10 +602,7 @@ function add!(a::FqAbsPowerSeriesRingElem, b::FqAbsPowerSeriesRingElem) lenb = min(lenb, prec) lenz = max(lena, lenb) a.prec = prec - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, - Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - a, a, b, lenz, base_ring(a)) + @ccall libflint.fq_default_poly_add_series(a::Ref{FqAbsPowerSeriesRingElem}, a::Ref{FqAbsPowerSeriesRingElem}, b::Ref{FqAbsPowerSeriesRingElem}, lenz::Int, base_ring(a)::Ref{FqField})::Nothing return a end @@ -680,17 +619,12 @@ function add!(c::FqAbsPowerSeriesRingElem, a::FqAbsPowerSeriesRingElem, b::FqAbs lenb = min(lenb, prec) lenc = max(lena, lenb) c.prec = prec - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Ref{FqAbsPowerSeriesRingElem}, - Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - c, a, b, lenc, base_ring(a)) + @ccall libflint.fq_default_poly_add_series(c::Ref{FqAbsPowerSeriesRingElem}, a::Ref{FqAbsPowerSeriesRingElem}, b::Ref{FqAbsPowerSeriesRingElem}, lenc::Int, base_ring(a)::Ref{FqField})::Nothing return c end function set_length!(a::FqAbsPowerSeriesRingElem, n::Int64) - ccall((:_fq_default_poly_set_length, libflint), Nothing, - (Ref{FqAbsPowerSeriesRingElem}, Int, Ref{FqField}), - a, n, base_ring(a)) + @ccall libflint._fq_default_poly_set_length(a::Ref{FqAbsPowerSeriesRingElem}, n::Int, base_ring(a)::Ref{FqField})::Nothing return a end diff --git a/src/flint/fq_default_embed.jl b/src/flint/fq_default_embed.jl index f3f345cc3..328c55b41 100644 --- a/src/flint/fq_default_embed.jl +++ b/src/flint/fq_default_embed.jl @@ -11,12 +11,8 @@ end function _unchecked_coerce!(z::FqFieldElem, a::FqField, b::FqPolyRepFieldElem) x = ZZPolyRingElem() - ccall((:fq_get_fmpz_poly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - x, b, parent(b)) - ccall((:fq_default_set_fmpz_poly, libflint), Nothing, - (Ref{FqFieldElem}, Ref{ZZPolyRingElem}, Ref{FqField}), - z, x, a) + @ccall libflint.fq_get_fmpz_poly(x::Ref{ZZPolyRingElem}, b::Ref{FqPolyRepFieldElem}, parent(b)::Ref{FqPolyRepField})::Nothing + @ccall libflint.fq_default_set_fmpz_poly(z::Ref{FqFieldElem}, x::Ref{ZZPolyRingElem}, a::Ref{FqField})::Nothing end ############################################################################### @@ -53,9 +49,7 @@ function _fq_default_embed_gens( gen_sub1 = zero(sub_ctx1) gen_sup1 = zero(sup_ctx1) - ccall((:fq_embed_gens, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FpPolyRingElem}, Ref{FqPolyRepField}, Ref{FqPolyRepField}), - gen_sub1, gen_sup1, minpoly, sub_ctx1, sup_ctx1) + @ccall libflint.fq_embed_gens(gen_sub1::Ref{FqPolyRepFieldElem}, gen_sup1::Ref{FqPolyRepFieldElem}, minpoly::Ref{FpPolyRingElem}, sub_ctx1::Ref{FqPolyRepField}, sup_ctx1::Ref{FqPolyRepField})::Nothing _unchecked_coerce!(gen_sub, sub_ctx, gen_sub1) _unchecked_coerce!(gen_sup, sup_ctx, gen_sup1) diff --git a/src/flint/fq_default_extended.jl b/src/flint/fq_default_extended.jl index 1f4d5c9c0..b61212395 100644 --- a/src/flint/fq_default_extended.jl +++ b/src/flint/fq_default_extended.jl @@ -554,15 +554,13 @@ function _fq_field_from_fmpz_mod_poly_in_disguise(f::FqPolyRingElem, s::Symbol) z.defining_poly = f z.forwardmap = g -> begin y = FqFieldElem(z) - ccall((:fq_default_set_fmpz_mod_poly, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqPolyRingElem}, Ref{FqField}), y, g, z) + @ccall libflint.fq_default_set_fmpz_mod_poly(y::Ref{FqFieldElem}, g::Ref{FqPolyRingElem}, z::Ref{FqField})::Nothing @assert parent(y) === z return y end z.backwardmap = function(g, R = parent(f)) y = R() - ccall((:fq_default_get_fmpz_mod_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), y, g, z) + @ccall libflint.fq_default_get_fmpz_mod_poly(y::Ref{FqPolyRingElem}, g::Ref{FqFieldElem}, z::Ref{FqField})::Nothing return y end return z @@ -578,9 +576,7 @@ function _fq_field_from_nmod_poly_in_disguise(f::FqPolyRingElem, s::Symbol) z.var = string(s) ss = string(s) GC.@preserve ss begin - ccall((:fq_default_ctx_init_modulus_nmod, libflint), Nothing, - (Ref{FqField}, Ref{FqPolyRingElem}, Ptr{UInt8}), - z, f, ss) + @ccall libflint.fq_default_ctx_init_modulus_nmod(z::Ref{FqField}, f::Ref{FqPolyRingElem}, ss::Ptr{UInt8})::Nothing finalizer(_FqDefaultFiniteField_clear_fn, z) end z.isabsolute = true @@ -589,14 +585,12 @@ function _fq_field_from_nmod_poly_in_disguise(f::FqPolyRingElem, s::Symbol) z.defining_poly = f z.forwardmap = g -> begin y = FqFieldElem(z) - ccall((:fq_default_set_nmod_poly, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqPolyRingElem}, Ref{FqField}), y, g, z) + @ccall libflint.fq_default_set_nmod_poly(y::Ref{FqFieldElem}, g::Ref{FqPolyRingElem}, z::Ref{FqField})::Nothing return y end z.backwardmap = function(g, R = parent(f)) y = R() - ccall((:fq_default_get_nmod_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), y, g, z) + @ccall libflint.fq_default_get_nmod_poly(y::Ref{FqPolyRingElem}, g::Ref{FqFieldElem}, z::Ref{FqField})::Nothing return y end return z @@ -782,14 +776,12 @@ function (F::FqField)(p::FqPolyRingElem) characteristic(base_ring(p)) != characteristic(F) && error("Polynomial has wrong coefficient ring") if _fq_default_ctx_type(K) == _FQ_DEFAULT_NMOD y = FqFieldElem(F) - ccall((:fq_default_set_nmod_poly, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqPolyRingElem}, Ref{FqField}), y, p, F) + @ccall libflint.fq_default_set_nmod_poly(y::Ref{FqFieldElem}, p::Ref{FqPolyRingElem}, F::Ref{FqField})::Nothing return y else @assert _fq_default_ctx_type(K) == _FQ_DEFAULT_FMPZ_NMOD y = FqFieldElem(F) - ccall((:fq_default_set_fmpz_mod_poly, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqPolyRingElem}, Ref{FqField}), y, p, F) + @ccall libflint.fq_default_set_fmpz_mod_poly(y::Ref{FqFieldElem}, p::Ref{FqPolyRingElem}, F::Ref{FqField})::Nothing return y end end @@ -807,15 +799,11 @@ function _lift_standard(R::FqPolyRing, a::FqFieldElem) p = R() @assert F === base_field(parent(a)) if _fq_default_ctx_type(F) == _FQ_DEFAULT_NMOD - ccall((:fq_default_get_nmod_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), - p, a, K) + @ccall libflint.fq_default_get_nmod_poly(p::Ref{FqPolyRingElem}, a::Ref{FqFieldElem}, K::Ref{FqField})::Nothing return p else @assert _fq_default_ctx_type(F) == _FQ_DEFAULT_FMPZ_NMOD - ccall((:fq_default_get_fmpz_mod_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), - p, a, K) + @ccall libflint.fq_default_get_fmpz_mod_poly(p::Ref{FqPolyRingElem}, a::Ref{FqFieldElem}, K::Ref{FqField})::Nothing return p end end diff --git a/src/flint/fq_default_mat.jl b/src/flint/fq_default_mat.jl index befc02a98..11a1c77ae 100644 --- a/src/flint/fq_default_mat.jl +++ b/src/flint/fq_default_mat.jl @@ -29,19 +29,14 @@ zero(m::FqMatrix, R::FqField, r::Int, c::Int) = FqMatrix(r, c, R) function getindex!(v::FqFieldElem, a::FqMatrix, i::Int, j::Int) @boundscheck _checkbounds(a, i, j) - ccall((:fq_default_mat_entry, libflint), Ptr{FqFieldElem}, - (Ref{FqFieldElem}, Ref{FqMatrix}, Int, Int, Ref{FqField}), - v, a, i - 1 , j - 1, base_ring(a)) + @ccall libflint.fq_default_mat_entry(v::Ref{FqFieldElem}, a::Ref{FqMatrix}, (i - 1)::Int, (j - 1)::Int, base_ring(a)::Ref{FqField})::Ptr{FqFieldElem} return v end @inline function getindex(a::FqMatrix, i::Int, j::Int) @boundscheck _checkbounds(a, i, j) z = base_ring(a)() - ccall((:fq_default_mat_entry, libflint), Ptr{FqFieldElem}, - (Ref{FqFieldElem}, Ref{FqMatrix}, Int, Int, - Ref{FqField}), - z, a, i - 1 , j - 1, base_ring(a)) + @ccall libflint.fq_default_mat_entry(z::Ref{FqFieldElem}, a::Ref{FqMatrix}, (i - 1)::Int, (j - 1)::Int, base_ring(a)::Ref{FqField})::Ptr{FqFieldElem} return z end @@ -55,10 +50,7 @@ end @inline function setindex!(a::FqMatrix, u::ZZRingElem, i::Int, j::Int) @boundscheck _checkbounds(a, i, j) - ccall((:fq_default_mat_entry_set_fmpz, libflint), Nothing, - (Ref{FqMatrix}, Int, Int, Ref{ZZRingElem}, - Ref{FqField}), - a, i - 1, j - 1, u, base_ring(a)) + @ccall libflint.fq_default_mat_entry_set_fmpz(a::Ref{FqMatrix}, (i - 1)::Int, (j - 1)::Int, u::Ref{ZZRingElem}, base_ring(a)::Ref{FqField})::Nothing nothing end @@ -68,27 +60,21 @@ function setindex!(a::FqMatrix, b::FqMatrix, r::UnitRange{Int64}, c::UnitRange{I _checkbounds(a, r, c) size(b) == (length(r), length(c)) || throw(DimensionMismatch("tried to assign a $(size(b, 1))x$(size(b, 2)) matrix to a $(length(r))x$(length(c)) destination")) A = view(a, r, c) - ccall((:fq_default_mat_set, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), A, b, base_ring(a)) + @ccall libflint.fq_default_mat_set(A::Ref{FqMatrix}, b::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing end function deepcopy_internal(a::FqMatrix, dict::IdDict) z = FqMatrix(nrows(a), ncols(a), base_ring(a)) - ccall((:fq_default_mat_set, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), z, a, base_ring(a)) + @ccall libflint.fq_default_mat_set(z::Ref{FqMatrix}, a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing return z end function number_of_rows(a::FqMatrix) - return ccall((:fq_default_mat_nrows, libflint), Int, - (Ref{FqMatrix}, Ref{FqField}), - a, base_ring(a)) + return @ccall libflint.fq_default_mat_nrows(a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Int end function number_of_columns(a::FqMatrix) - return ccall((:fq_default_mat_ncols, libflint), Int, - (Ref{FqMatrix}, Ref{FqField}), - a, base_ring(a)) + return @ccall libflint.fq_default_mat_ncols(a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Int end base_ring(a::FqMatrix) = a.base_ring @@ -99,8 +85,7 @@ function one(a::FqMatrixSpace) end function iszero(a::FqMatrix) - r = ccall((:fq_default_mat_is_zero, libflint), Cint, - (Ref{FqMatrix}, Ref{FqField}), a, base_ring(a)) + r = @ccall libflint.fq_default_mat_is_zero(a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Cint return Bool(r) end @@ -108,8 +93,7 @@ end @boundscheck _checkbounds(A, i, j) GC.@preserve A begin x = fq_default_mat_entry_ptr(A, i, j) - return ccall((:fq_default_is_zero, libflint), Bool, - (Ptr{FqFieldElem}, Ref{FqField}), x, base_ring(A)) + return @ccall libflint.fq_default_is_zero(x::Ptr{FqFieldElem}, base_ring(A)::Ref{FqField})::Bool end end @@ -123,8 +107,7 @@ function ==(a::FqMatrix, b::FqMatrix) if !(a.base_ring == b.base_ring) return false end - r = ccall((:fq_default_mat_equal, libflint), Cint, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), a, b, base_ring(a)) + r = @ccall libflint.fq_default_mat_equal(a::Ref{FqMatrix}, b::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Cint return Bool(r) end @@ -139,10 +122,10 @@ isequal(a::FqMatrix, b::FqMatrix) = ==(a, b) function transpose(a::FqMatrix) z = similar(a, ncols(a), nrows(a)) if _fq_default_ctx_type(base_ring(a)) == _FQ_DEFAULT_NMOD - ccall((:nmod_mat_transpose, libflint), Nothing, (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), z, a, base_ring(a)) + @ccall libflint.nmod_mat_transpose(z::Ref{FqMatrix}, a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing return z elseif _fq_default_ctx_type(base_ring(a)) == _FQ_DEFAULT_FMPZ_NMOD - ccall((:fmpz_mod_mat_transpose, libflint), Nothing, (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), z, a, base_ring(a)) + @ccall libflint.fmpz_mod_mat_transpose(z::Ref{FqMatrix}, a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing return z end # There is no flint functionality for the other cases @@ -163,9 +146,7 @@ end ############################################################################### function swap_rows!(x::FqMatrix, i::Int, j::Int) - ccall((:fq_default_mat_swap_rows, libflint), Nothing, - (Ref{FqMatrix}, Ptr{Nothing}, Int, Int, Ref{FqField}), - x, C_NULL, i - 1, j - 1, base_ring(x)) + @ccall libflint.fq_default_mat_swap_rows(x::Ref{FqMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int, base_ring(x)::Ref{FqField})::Nothing return x end @@ -176,9 +157,7 @@ function swap_rows(x::FqMatrix, i::Int, j::Int) end function swap_cols!(x::FqMatrix, i::Int, j::Int) - ccall((:fq_default_mat_swap_cols, libflint), Nothing, - (Ref{FqMatrix}, Ptr{Nothing}, Int, Int, Ref{FqField}), - x, C_NULL, i - 1, j - 1, base_ring(x)) + @ccall libflint.fq_default_mat_swap_cols(x::Ref{FqMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int, base_ring(x)::Ref{FqField})::Nothing return x end @@ -189,16 +168,14 @@ function swap_cols(x::FqMatrix, i::Int, j::Int) end function reverse_rows!(x::FqMatrix) - ccall((:fq_default_mat_invert_rows, libflint), Nothing, - (Ref{FqMatrix}, Ptr{Nothing}, Ref{FqField}), x, C_NULL, base_ring(x)) + @ccall libflint.fq_default_mat_invert_rows(x::Ref{FqMatrix}, C_NULL::Ptr{Nothing}, base_ring(x)::Ref{FqField})::Nothing return x end reverse_rows(x::FqMatrix) = reverse_rows!(deepcopy(x)) function reverse_cols!(x::FqMatrix) - ccall((:fq_default_mat_invert_cols, libflint), Nothing, - (Ref{FqMatrix}, Ptr{Nothing}, Ref{FqField}), x, C_NULL, base_ring(x)) + @ccall libflint.fq_default_mat_invert_cols(x::Ref{FqMatrix}, C_NULL::Ptr{Nothing}, base_ring(x)::Ref{FqField})::Nothing return x end @@ -221,18 +198,14 @@ reverse_cols(x::FqMatrix) = reverse_cols!(deepcopy(x)) function +(x::FqMatrix, y::FqMatrix) check_parent(x,y) z = similar(x) - ccall((:fq_default_mat_add, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), - z, x, y, base_ring(x)) + @ccall libflint.fq_default_mat_add(z::Ref{FqMatrix}, x::Ref{FqMatrix}, y::Ref{FqMatrix}, base_ring(x)::Ref{FqField})::Nothing return z end function -(x::FqMatrix, y::FqMatrix) check_parent(x,y) z = similar(x) - ccall((:fq_default_mat_sub, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), - z, x, y, base_ring(x)) + @ccall libflint.fq_default_mat_sub(z::Ref{FqMatrix}, x::Ref{FqMatrix}, y::Ref{FqMatrix}, base_ring(x)::Ref{FqField})::Nothing return z end @@ -241,8 +214,7 @@ function *(x::FqMatrix, y::FqMatrix) (base_ring(x) != base_ring(y)) && error("Base ring must be equal") (ncols(x) != nrows(y)) && error("Dimensions are wrong") z = similar(x, nrows(x), ncols(y)) - ccall((:fq_default_mat_mul, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), z, x, y, base_ring(x)) + @ccall libflint.fq_default_mat_mul(z::Ref{FqMatrix}, x::Ref{FqMatrix}, y::Ref{FqMatrix}, base_ring(x)::Ref{FqField})::Nothing return z end @@ -254,27 +226,22 @@ end ################################################################################ function zero!(a::FqMatrix) - ccall((:fq_default_mat_zero, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqField}), a, base_ring(a)) + @ccall libflint.fq_default_mat_zero(a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing return a end function one!(a::FqMatrix) - ccall((:fq_default_mat_one, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqField}), a, base_ring(a)) + @ccall libflint.fq_default_mat_one(a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing return a end function neg!(z::FqMatrix, a::FqMatrix) - ccall((:fq_default_mat_neg, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), z, a, base_ring(a)) + @ccall libflint.fq_default_mat_neg(z::Ref{FqMatrix}, a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing return z end function mul!(a::FqMatrix, b::FqMatrix, c::FqMatrix) - ccall((:fq_default_mat_mul, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), - a, b, c, base_ring(a)) + @ccall libflint.fq_default_mat_mul(a::Ref{FqMatrix}, b::Ref{FqMatrix}, c::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing return a end @@ -289,7 +256,7 @@ function mul!(a::FqMatrix, b::FqMatrix, c::FqFieldElem) for j in 1:ncols(a) x = fq_default_mat_entry_ptr(a, i, j) y = fq_default_mat_entry_ptr(b, i, j) - ccall((:fq_default_mul, libflint), Nothing, (Ptr{FqFieldElem}, Ptr{FqFieldElem}, Ref{FqFieldElem}, Ref{FqField}), x, y, c, F) + @ccall libflint.fq_default_mul(x::Ptr{FqFieldElem}, y::Ptr{FqFieldElem}, c::Ref{FqFieldElem}, F::Ref{FqField})::Nothing end end end @@ -299,9 +266,7 @@ end mul!(a::FqMatrix, b::FqFieldElem, c::FqMatrix) = mul!(a, c, b) function add!(a::FqMatrix, b::FqMatrix, c::FqMatrix) - ccall((:fq_default_mat_add, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), - a, b, c, base_ring(a)) + @ccall libflint.fq_default_mat_add(a::Ref{FqMatrix}, b::Ref{FqMatrix}, c::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing return a end @@ -311,15 +276,9 @@ function Generic.add_one!(a::FqMatrix, i::Int, j::Int) GC.@preserve a begin x = fq_default_mat_entry_ptr(a, i, j) # There is no fq_default_add_one, but only ...sub_one - ccall((:fq_default_neg, libflint), Nothing, - (Ptr{FqFieldElem}, Ptr{FqFieldElem}, Ref{FqField}), - x, x, F) - ccall((:fq_default_sub_one, libflint), Nothing, - (Ptr{FqFieldElem}, Ptr{FqFieldElem}, Ref{FqField}), - x, x, F) - ccall((:fq_default_neg, libflint), Nothing, - (Ptr{FqFieldElem}, Ptr{FqFieldElem}, Ref{FqField}), - x, x, F) + @ccall libflint.fq_default_neg(x::Ptr{FqFieldElem}, x::Ptr{FqFieldElem}, F::Ref{FqField})::Nothing + @ccall libflint.fq_default_sub_one(x::Ptr{FqFieldElem}, x::Ptr{FqFieldElem}, F::Ref{FqField})::Nothing + @ccall libflint.fq_default_neg(x::Ptr{FqFieldElem}, x::Ptr{FqFieldElem}, F::Ref{FqField})::Nothing end return a end @@ -370,14 +329,12 @@ end function rref(a::FqMatrix) z = similar(a) - r = ccall((:fq_default_mat_rref, libflint), Int, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), z, a, base_ring(a)) + r = @ccall libflint.fq_default_mat_rref(z::Ref{FqMatrix}, a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Int return r, z end function rref!(a::FqMatrix) - r = ccall((:fq_default_mat_rref, libflint), Int, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), a, a, base_ring(a)) + r = @ccall libflint.fq_default_mat_rref(a::Ref{FqMatrix}, a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Int return r end @@ -430,8 +387,7 @@ end function inv(a::FqMatrix) !is_square(a) && error("Matrix must be a square matrix") z = similar(a) - r = ccall((:fq_default_mat_inv, libflint), Int, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), z, a, base_ring(a)) + r = @ccall libflint.fq_default_mat_inv(z::Ref{FqMatrix}, a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Int !Bool(r) && error("Matrix not invertible") return z end @@ -452,9 +408,7 @@ function Solve._can_solve_internal_no_check(::Solve.LUTrait, A::FqMatrix, b::FqM end x = similar(A, ncols(A), ncols(b)) - fl = ccall((:fq_default_mat_can_solve, libflint), Cint, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqMatrix}, - Ref{FqField}), x, A, b, base_ring(A)) + fl = @ccall libflint.fq_default_mat_can_solve(x::Ref{FqMatrix}, A::Ref{FqMatrix}, b::Ref{FqMatrix}, base_ring(A)::Ref{FqField})::Cint if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end @@ -464,16 +418,12 @@ end # Direct interface to the C functions to be able to write 'generic' code for # different matrix types function _solve_tril_right_flint!(x::FqMatrix, L::FqMatrix, B::FqMatrix, unit::Bool) - ccall((:fq_default_mat_solve_tril, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqMatrix}, Cint, Ref{FqField}), - x, L, B, Cint(unit), base_ring(L)) + @ccall libflint.fq_default_mat_solve_tril(x::Ref{FqMatrix}, L::Ref{FqMatrix}, B::Ref{FqMatrix}, Cint(unit)::Cint, base_ring(L)::Ref{FqField})::Nothing return nothing end function _solve_triu_right_flint!(x::FqMatrix, U::FqMatrix, B::FqMatrix, unit::Bool) - ccall((:fq_default_mat_solve_triu, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqMatrix}, Cint, Ref{FqField}), - x, U, B, Cint(unit), base_ring(U)) + @ccall libflint.fq_default_mat_solve_triu(x::Ref{FqMatrix}, U::Ref{FqMatrix}, B::Ref{FqMatrix}, Cint(unit)::Cint, base_ring(U)::Ref{FqField})::Nothing return nothing end @@ -486,9 +436,7 @@ end function lu!(P::Perm, x::FqMatrix) P.d .-= 1 - rank = Int(ccall((:fq_default_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{FqMatrix}, Cint, Ref{FqField}), - P.d, x, 0, base_ring(x))) + rank = Int(@ccall libflint.fq_default_mat_lu(P.d::Ptr{Int}, x::Ref{FqMatrix}, 0::Cint, base_ring(x)::Ref{FqField})::Cint) P.d .+= 1 @@ -551,9 +499,7 @@ function Base.view(x::FqMatrix, r1::Int, c1::Int, r2::Int, c2::Int) z = FqMatrix() z.base_ring = x.base_ring z.view_parent = x - ccall((:fq_default_mat_window_init, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Int, Int, Int, Int, Ref{FqField}), - z, x, r1 - 1, c1 - 1, r2, c2, base_ring(x)) + @ccall libflint.fq_default_mat_window_init(z::Ref{FqMatrix}, x::Ref{FqMatrix}, (r1 - 1)::Int, (c1 - 1)::Int, r2::Int, c2::Int, base_ring(x)::Ref{FqField})::Nothing finalizer(_fq_default_mat_window_clear_fn, z) return z end @@ -563,8 +509,7 @@ function Base.view(x::FqMatrix, r::AbstractUnitRange{Int}, c::AbstractUnitRange{ end function _fq_default_mat_window_clear_fn(a::FqMatrix) - ccall((:fq_default_mat_window_clear, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqField}), a, base_ring(a)) + @ccall libflint.fq_default_mat_window_clear(a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing end function sub(x::FqMatrix, r1::Int, c1::Int, r2::Int, c2::Int) @@ -587,10 +532,7 @@ function hcat(x::FqMatrix, y::FqMatrix) (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") (nrows(x) != nrows(y)) && error("Matrices must have same number of rows") z = similar(x, nrows(x), ncols(x) + ncols(y)) - ccall((:fq_default_mat_concat_horizontal, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqMatrix}, - Ref{FqField}), - z, x, y, base_ring(x)) + @ccall libflint.fq_default_mat_concat_horizontal(z::Ref{FqMatrix}, x::Ref{FqMatrix}, y::Ref{FqMatrix}, base_ring(x)::Ref{FqField})::Nothing return z end @@ -598,10 +540,7 @@ function vcat(x::FqMatrix, y::FqMatrix) (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") (ncols(x) != ncols(y)) && error("Matrices must have same number of columns") z = similar(x, nrows(x) + nrows(y), ncols(x)) - ccall((:fq_default_mat_concat_vertical, libflint), Nothing, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqMatrix}, - Ref{FqField}), - z, x, y, base_ring(x)) + @ccall libflint.fq_default_mat_concat_vertical(z::Ref{FqMatrix}, x::Ref{FqMatrix}, y::Ref{FqMatrix}, base_ring(x)::Ref{FqField})::Nothing return z end @@ -615,8 +554,7 @@ function charpoly(R::FqPolyRing, a::FqMatrix) !is_square(a) && error("Matrix must be square") base_ring(R) != base_ring(a) && error("Must have common base ring") p = R() - ccall((:fq_default_mat_charpoly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqMatrix}, Ref{FqField}), p, a, base_ring(a)) + @ccall libflint.fq_default_mat_charpoly(p::Ref{FqPolyRingElem}, a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing return p end @@ -624,8 +562,7 @@ function charpoly_danivlesky!(R::FqPolyRing, a::FqMatrix) !is_square(a) && error("Matrix must be square") base_ring(R) != base_ring(a) && error("Must have common base ring") p = R() - ccall((:fq_default_mat_charpoly_danilevsky, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqMatrix}, Ref{FqField}), p, a, base_ring(a)) + @ccall libflint.fq_default_mat_charpoly_danilevsky(p::Ref{FqPolyRingElem}, a::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing return p end @@ -641,8 +578,7 @@ function minpoly(R::FqPolyRing, a::FqMatrix) base_ring(R) != base_ring(a) && error("Must have common base ring") m = deepcopy(a) p = R() - ccall((:fq_default_mat_minpoly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqMatrix}, Ref{FqField}), p, m, base_ring(a)) + @ccall libflint.fq_default_mat_minpoly(p::Ref{FqPolyRingElem}, m::Ref{FqMatrix}, base_ring(a)::Ref{FqField})::Nothing return p end @@ -757,20 +693,15 @@ function fq_default_mat_entry_ptr(a::FqMatrix, i, j) t = _fq_default_ctx_type(base_ring(a)) ptr = pointer_from_objref(a) if t == _FQ_DEFAULT_FQ_ZECH - pptr = ccall((:fq_zech_mat_entry, libflint), Ptr{FqFieldElem}, - (Ptr{Cvoid}, Int, Int), ptr, i - 1, j - 1) + pptr = @ccall libflint.fq_zech_mat_entry(ptr::Ptr{Cvoid}, (i - 1)::Int, (j - 1)::Int)::Ptr{FqFieldElem} elseif t == _FQ_DEFAULT_FQ_NMOD - pptr = ccall((:fq_nmod_mat_entry, libflint), Ptr{FqFieldElem}, - (Ptr{Cvoid}, Int, Int), ptr, i - 1, j - 1) + pptr = @ccall libflint.fq_nmod_mat_entry(ptr::Ptr{Cvoid}, (i - 1)::Int, (j - 1)::Int)::Ptr{FqFieldElem} elseif t == _FQ_DEFAULT_FQ - pptr = ccall((:fq_mat_entry, libflint), Ptr{FqFieldElem}, - (Ptr{Cvoid}, Int, Int), ptr, i - 1, j - 1) + pptr = @ccall libflint.fq_mat_entry(ptr::Ptr{Cvoid}, (i - 1)::Int, (j - 1)::Int)::Ptr{FqFieldElem} elseif t == _FQ_DEFAULT_NMOD - pptr = ccall((:nmod_mat_entry_ptr, libflint), Ptr{FqFieldElem}, - (Ptr{Cvoid}, Int, Int), ptr, i - 1, j - 1) + pptr = @ccall libflint.nmod_mat_entry_ptr(ptr::Ptr{Cvoid}, (i - 1)::Int, (j - 1)::Int)::Ptr{FqFieldElem} else#if t == _FQ_DEFAULT_FMPZ_NMOD - pptr = ccall((:fmpz_mod_mat_entry, libflint), Ptr{FqFieldElem}, - (Ptr{Cvoid}, Int, Int), ptr, i - 1, j - 1) + pptr = @ccall libflint.fmpz_mod_mat_entry(ptr::Ptr{Cvoid}, (i - 1)::Int, (j - 1)::Int)::Ptr{FqFieldElem} end return pptr end @@ -783,7 +714,6 @@ end function nullspace(M::FqMatrix) N = similar(M, ncols(M), ncols(M)) - nullity = ccall((:fq_default_mat_nullspace, libflint), Int, - (Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), N, M, base_ring(M)) + nullity = @ccall libflint.fq_default_mat_nullspace(N::Ref{FqMatrix}, M::Ref{FqMatrix}, base_ring(M)::Ref{FqField})::Int return nullity, view(N, 1:nrows(N), 1:nullity) end diff --git a/src/flint/fq_default_poly.jl b/src/flint/fq_default_poly.jl index 95133a33f..ed010ffc5 100644 --- a/src/flint/fq_default_poly.jl +++ b/src/flint/fq_default_poly.jl @@ -31,24 +31,20 @@ var(a::FqPolyRing) = a.S function length(x::FqPolyRingElem) F = (x.parent).base_ring - ccall((:fq_default_poly_length, libflint), Int, - (Ref{FqPolyRingElem}, Ref{FqField}), x, F) + @ccall libflint.fq_default_poly_length(x::Ref{FqPolyRingElem}, F::Ref{FqField})::Int end function coeff(x::FqPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) F = (x.parent).base_ring temp = F(1) - ccall((:fq_default_poly_get_coeff, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqPolyRingElem}, Int, Ref{FqField}), - temp, x, n, F) + @ccall libflint.fq_default_poly_get_coeff(temp::Ref{FqFieldElem}, x::Ref{FqPolyRingElem}, n::Int, F::Ref{FqField})::Nothing return temp end function set_length!(x::FqPolyRingElem, n::Int) ctx = base_ring(x) - ccall((:_fq_default_poly_set_length, libflint), Nothing, - (Ref{FqPolyRingElem}, Int, Ref{FqField}), x, n, ctx) + @ccall libflint._fq_default_poly_set_length(x::Ref{FqPolyRingElem}, n::Int, ctx::Ref{FqField})::Nothing return x end @@ -58,17 +54,11 @@ one(a::FqPolyRing) = a(one(base_ring(a))) gen(a::FqPolyRing) = a([zero(base_ring(a)), one(base_ring(a))]) -is_gen(x::FqPolyRingElem) = ccall((:fq_default_poly_is_gen, libflint), Bool, - (Ref{FqPolyRingElem}, Ref{FqField}), - x, base_ring(x.parent)) +is_gen(x::FqPolyRingElem) = @ccall libflint.fq_default_poly_is_gen(x::Ref{FqPolyRingElem}, base_ring(x.parent)::Ref{FqField})::Bool -iszero(x::FqPolyRingElem) = ccall((:fq_default_poly_is_zero, libflint), Bool, - (Ref{FqPolyRingElem}, Ref{FqField}), - x, base_ring(x.parent)) +iszero(x::FqPolyRingElem) = @ccall libflint.fq_default_poly_is_zero(x::Ref{FqPolyRingElem}, base_ring(x.parent)::Ref{FqField})::Bool -isone(x::FqPolyRingElem) = ccall((:fq_default_poly_is_one, libflint), Bool, - (Ref{FqPolyRingElem}, Ref{FqField}), - x, base_ring(x.parent)) +isone(x::FqPolyRingElem) = @ccall libflint.fq_default_poly_is_one(x::Ref{FqPolyRingElem}, base_ring(x.parent)::Ref{FqField})::Bool degree(f::FqPolyRingElem) = length(f) - 1 @@ -120,30 +110,21 @@ canonical_unit(a::FqPolyRingElem) = canonical_unit(leading_coefficient(a)) function +(x::FqPolyRingElem, y::FqPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_default_poly_add, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqPolyRingElem}, Ref{FqField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_add(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z end function -(x::FqPolyRingElem, y::FqPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_default_poly_sub, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqPolyRingElem}, Ref{FqField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_sub(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z end function *(x::FqPolyRingElem, y::FqPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_default_poly_mul, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqPolyRingElem}, Ref{FqField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_mul(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -157,10 +138,7 @@ function *(x::FqFieldElem, y::FqPolyRingElem) parent(x) != base_ring(parent(y)) && error("Coefficient rings must be equal") z = parent(y)() - ccall((:fq_default_poly_scalar_mul_fq_default, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqFieldElem}, Ref{FqField}), - z, y, x, parent(x)) + @ccall libflint.fq_default_poly_scalar_mul_fq_default(z::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, x::Ref{FqFieldElem}, parent(x)::Ref{FqField})::Nothing return z end @@ -207,9 +185,7 @@ end function ^(x::FqPolyRingElem, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() - ccall((:fq_default_poly_pow, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_pow(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Int, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -221,9 +197,7 @@ end function ==(x::FqPolyRingElem, y::FqPolyRingElem) check_parent(x,y) - r = ccall((:fq_default_poly_equal, libflint), Cint, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqField}), - x, y, base_ring(parent(x))) + r = @ccall libflint.fq_default_poly_equal(x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Cint return Bool(r) end @@ -238,9 +212,7 @@ function ==(x::FqPolyRingElem, y::FqFieldElem) if length(x) > 1 return false elseif length(x) == 1 - r = ccall((:fq_default_poly_equal_fq_default, libflint), Cint, - (Ref{FqPolyRingElem}, Ref{FqFieldElem}, Ref{FqField}), - x, y, base_ring(parent(x))) + r = @ccall libflint.fq_default_poly_equal_fq_default(x::Ref{FqPolyRingElem}, y::Ref{FqFieldElem}, base_ring(parent(x))::Ref{FqField})::Cint return Bool(r) else return iszero(y) @@ -269,9 +241,7 @@ function truncate(x::FqPolyRingElem, n::Int) return x end z = parent(x)() - ccall((:fq_default_poly_set_trunc, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, x, n, base_ring(parent(x))) + @ccall libflint.fq_default_poly_set_trunc(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, n::Int, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -279,10 +249,7 @@ function mullow(x::FqPolyRingElem, y::FqPolyRingElem, n::Int) check_parent(x,y) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() - ccall((:fq_default_poly_mullow, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Int, Ref{FqField}), - z, x, y, n, base_ring(parent(x))) + @ccall libflint.fq_default_poly_mullow(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, n::Int, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -295,9 +262,7 @@ end function reverse(x::FqPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Index must be non-negative")) z = parent(x)() - ccall((:fq_default_poly_reverse, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, x, len, base_ring(parent(x))) + @ccall libflint.fq_default_poly_reverse(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, len::Int, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -310,18 +275,14 @@ end function shift_left(x::FqPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:fq_default_poly_shift_left, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, x, len, base_ring(parent(x))) + @ccall libflint.fq_default_poly_shift_left(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, len::Int, base_ring(parent(x))::Ref{FqField})::Nothing return z end function shift_right(x::FqPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:fq_default_poly_shift_right, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, x, len, base_ring(parent(x))) + @ccall libflint.fq_default_poly_shift_right(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, len::Int, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -345,9 +306,7 @@ end function rem(x::FqPolyRingElem, y::FqPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_default_poly_rem, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_rem(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -357,9 +316,7 @@ function Base.divrem(x::FqPolyRingElem, y::FqPolyRingElem) check_parent(x,y) z = parent(x)() r = parent(x)() - ccall((:fq_default_poly_divrem, libflint), Nothing, (Ref{FqPolyRingElem}, - Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqField}), z, r, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_divrem(z::Ref{FqPolyRingElem}, r::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z, r end @@ -372,9 +329,7 @@ end function sqrt(x::FqPolyRingElem; check::Bool=true) R = parent(x) s = R() - flag = Bool(ccall((:fq_default_poly_sqrt, libflint), Cint, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqField}), - s, x, base_ring(parent(x)))) + flag = Bool(@ccall libflint.fq_default_poly_sqrt(s::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Cint) check && !flag && error("Not a square in sqrt") return s end @@ -388,9 +343,7 @@ function is_square(x::FqPolyRingElem) end R = parent(x) s = R() - flag = Bool(ccall((:fq_default_poly_sqrt, libflint), Cint, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqField}), - s, x, base_ring(parent(x)))) + flag = Bool(@ccall libflint.fq_default_poly_sqrt(s::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Cint) return flag end @@ -403,9 +356,7 @@ function is_square_with_sqrt(x::FqPolyRingElem) return false, zero(R) end s = R() - flag = Bool(ccall((:fq_default_poly_sqrt, libflint), Cint, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqField}), - s, x, base_ring(parent(x)))) + flag = Bool(@ccall libflint.fq_default_poly_sqrt(s::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Cint) return flag, s end @@ -419,9 +370,7 @@ function remove(z::FqPolyRingElem, p::FqPolyRingElem) ok, v = _remove_check_simple_cases(z, p) ok && return v, zero(parent(z)) z = deepcopy(z) - v = ccall((:fq_default_poly_remove, libflint), Int, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqField}), - z, p, base_ring(parent(z))) + v = @ccall libflint.fq_default_poly_remove(z::Ref{FqPolyRingElem}, p::Ref{FqPolyRingElem}, base_ring(parent(z))::Ref{FqField})::Int return v, z end @@ -434,10 +383,7 @@ function divides(z::FqPolyRingElem, x::FqPolyRingElem) end check_parent(z, x) q = parent(z)() - v = Bool(ccall((:fq_default_poly_divides, libflint), Cint, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqPolyRingElem}, Ref{FqField}), - q, z, x, base_ring(parent(z)))) + v = Bool(@ccall libflint.fq_default_poly_divides(q::Ref{FqPolyRingElem}, z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, base_ring(parent(z))::Ref{FqField})::Cint) return v, q end @@ -459,9 +405,7 @@ function powermod(x::FqPolyRingElem, n::Int, y::FqPolyRingElem) n = -n end - ccall((:fq_default_poly_powmod_ui_binexp, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Int, Ref{FqPolyRingElem}, - Ref{FqField}), z, x, n, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_powmod_ui_binexp(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, n::Int, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -478,12 +422,9 @@ function powermod(x::FqPolyRingElem, n::ZZRingElem, y::FqPolyRingElem) end # https://github.com/flintlib/flint2/pull/1261 if _fq_default_ctx_type(base_ring(parent(x))) == 4 - ccall((:nmod_poly_powmod_fmpz_binexp, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{ZZRingElem}, Ref{FqPolyRingElem}), z, x, n, y) + @ccall libflint.nmod_poly_powmod_fmpz_binexp(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, n::Ref{ZZRingElem}, y::Ref{FqPolyRingElem})::Nothing else - ccall((:fq_default_poly_powmod_fmpz_binexp, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{ZZRingElem}, Ref{FqPolyRingElem}, - Ref{FqField}), z, x, n, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_powmod_fmpz_binexp(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, n::Ref{ZZRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing end return z end @@ -497,9 +438,7 @@ end function gcd(x::FqPolyRingElem, y::FqPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_default_poly_gcd, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_gcd(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -508,9 +447,7 @@ function gcdx(x::FqPolyRingElem, y::FqPolyRingElem) z = parent(x)() s = parent(x)() t = parent(x)() - ccall((:fq_default_poly_xgcd, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqField}), z, s, t, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_xgcd(z::Ref{FqPolyRingElem}, s::Ref{FqPolyRingElem}, t::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z, s, t end @@ -523,9 +460,7 @@ end function evaluate(x::FqPolyRingElem, y::FqFieldElem) base_ring(parent(x)) != parent(y) && error("Incompatible coefficient rings") z = parent(y)() - ccall((:fq_default_poly_evaluate_fq_default, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqPolyRingElem}, Ref{FqFieldElem}, - Ref{FqField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_evaluate_fq_default(z::Ref{FqFieldElem}, x::Ref{FqPolyRingElem}, y::Ref{FqFieldElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -538,9 +473,7 @@ end function AbstractAlgebra._compose_right(x::FqPolyRingElem, y::FqPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_default_poly_compose, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_compose(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -552,9 +485,7 @@ end function derivative(x::FqPolyRingElem) z = parent(x)() - ccall((:fq_default_poly_derivative, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqField}), - z, x, base_ring(parent(x))) + @ccall libflint.fq_default_poly_derivative(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -566,17 +497,13 @@ end function inflate(x::FqPolyRingElem, n::Int) z = parent(x)() - ccall((:fq_default_poly_inflate, libflint), Nothing, (Ref{FqPolyRingElem}, - Ref{FqPolyRingElem}, Culong, Ref{FqField}), - z, x, UInt(n), base_ring(parent(x))) + @ccall libflint.fq_default_poly_inflate(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, UInt(n)::Culong, base_ring(parent(x))::Ref{FqField})::Nothing return z end function deflate(x::FqPolyRingElem, n::Int) z = parent(x)() - ccall((:fq_default_poly_deflate, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Culong, Ref{FqField}), - z, x, UInt(n), base_ring(parent(x))) + @ccall libflint.fq_default_poly_deflate(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, UInt(n)::Culong, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -587,9 +514,7 @@ end ################################################################################ function is_irreducible(x::FqPolyRingElem) - return Bool(ccall((:fq_default_poly_is_irreducible, libflint), Int32, - (Ref{FqPolyRingElem}, Ref{FqField} ), - x, base_ring(parent(x)))) + return Bool(@ccall libflint.fq_default_poly_is_irreducible(x::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Int32) end ################################################################################ @@ -599,8 +524,7 @@ end ################################################################################ function is_squarefree(x::FqPolyRingElem) - return Bool(ccall((:fq_default_poly_is_squarefree, libflint), Int32, - (Ref{FqPolyRingElem}, Ref{FqField}), x, base_ring(parent(x)))) + return Bool(@ccall libflint.fq_default_poly_is_squarefree(x::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Int32) end ################################################################################ @@ -610,15 +534,11 @@ end ################################################################################ function exponent(x::fq_default_poly_factor, i::Int) - return ccall((:fq_default_poly_factor_exp, libflint), Int, - (Ref{fq_default_poly_factor}, Int, Ref{FqField}), - x, i, x.base_field) + return @ccall libflint.fq_default_poly_factor_exp(x::Ref{fq_default_poly_factor}, i::Int, x.base_field::Ref{FqField})::Int end function length(x::fq_default_poly_factor) - return ccall((:fq_default_poly_factor_length, libflint), Int, - (Ref{fq_default_poly_factor}, Ref{FqField}), - x, x.base_field) + return @ccall libflint.fq_default_poly_factor_length(x::Ref{fq_default_poly_factor}, x.base_field::Ref{FqField})::Int end function factor(x::FqPolyRingElem) @@ -632,15 +552,11 @@ function _factor(x::FqPolyRingElem) F = base_ring(R) a = F() fac = fq_default_poly_factor(F) - ccall((:fq_default_poly_factor, libflint), Nothing, (Ref{fq_default_poly_factor}, - Ref{FqFieldElem}, Ref{FqPolyRingElem}, Ref{FqField}), - fac, a, x, F) + @ccall libflint.fq_default_poly_factor(fac::Ref{fq_default_poly_factor}, a::Ref{FqFieldElem}, x::Ref{FqPolyRingElem}, F::Ref{FqField})::Nothing res = Dict{FqPolyRingElem,Int}() for i in 1:length(fac) f = R() - ccall((:fq_default_poly_factor_get_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{fq_default_poly_factor}, Int, - Ref{FqField}), f, fac, i - 1, F) + @ccall libflint.fq_default_poly_factor_get_poly(f::Ref{FqPolyRingElem}, fac::Ref{fq_default_poly_factor}, (i - 1)::Int, F::Ref{FqField})::Nothing e = exponent(fac, i - 1) res[f] = e end @@ -657,14 +573,11 @@ end function _factor_squarefree(x::FqPolyRingElem) F = base_ring(parent(x)) fac = fq_default_poly_factor(F) - ccall((:fq_default_poly_factor_squarefree, libflint), UInt, - (Ref{fq_default_poly_factor}, Ref{FqPolyRingElem}, Ref{FqField}), fac, x, F) + @ccall libflint.fq_default_poly_factor_squarefree(fac::Ref{fq_default_poly_factor}, x::Ref{FqPolyRingElem}, F::Ref{FqField})::UInt res = Dict{FqPolyRingElem,Int}() for i in 1:length(fac) f = parent(x)() - ccall((:fq_default_poly_factor_get_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{fq_default_poly_factor}, Int, - Ref{FqField}), f, fac, i-1, F) + @ccall libflint.fq_default_poly_factor_get_poly(f::Ref{FqPolyRingElem}, fac::Ref{fq_default_poly_factor}, (i-1)::Int, F::Ref{FqField})::Nothing e = exponent(fac, i - 1) res[f] = e end @@ -681,15 +594,11 @@ function factor_distinct_deg(x::FqPolyRingElem) F = base_ring(R) fac = fq_default_poly_factor(F) degrees = Vector{Int}(undef, degree(x)) - ccall((:fq_default_poly_factor_distinct_deg, libflint), Nothing, - (Ref{fq_default_poly_factor}, Ref{FqPolyRingElem}, Ref{Vector{Int}}, - Ref{FqField}), fac, x, degrees, F) + @ccall libflint.fq_default_poly_factor_distinct_deg(fac::Ref{fq_default_poly_factor}, x::Ref{FqPolyRingElem}, degrees::Ref{Vector{Int}}, F::Ref{FqField})::Nothing res = Dict{Int, FqPolyRingElem}() for i in 1:length(fac) f = R() - ccall((:fq_default_poly_factor_get_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{fq_default_poly_factor}, Int, - Ref{FqField}), f, fac, i-1, F) + @ccall libflint.fq_default_poly_factor_get_poly(f::Ref{FqPolyRingElem}, fac::Ref{fq_default_poly_factor}, (i-1)::Int, F::Ref{FqField})::Nothing res[degrees[i]] = f end return res @@ -699,15 +608,11 @@ function roots(x::FqPolyRingElem) R = parent(x) F = base_ring(R) fac = fq_default_poly_factor(F) - ccall((:fq_default_poly_roots, libflint), Nothing, - (Ref{fq_default_poly_factor}, Ref{FqPolyRingElem}, Cint, - Ref{FqField}), fac, x, 0, F) + @ccall libflint.fq_default_poly_roots(fac::Ref{fq_default_poly_factor}, x::Ref{FqPolyRingElem}, 0::Cint, F::Ref{FqField})::Nothing res = FqFieldElem[] for i in 1:length(fac) f = R() - ccall((:fq_default_poly_factor_get_poly, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{fq_default_poly_factor}, Int, - Ref{FqField}), f, fac, i-1, F) + @ccall libflint.fq_default_poly_factor_get_poly(f::Ref{FqPolyRingElem}, fac::Ref{fq_default_poly_factor}, (i-1)::Int, F::Ref{FqField})::Nothing @assert isone(coeff(f, 1)) push!(res, -coeff(f, 0)) end @@ -721,58 +626,42 @@ end ################################################################################ function zero!(z::FqPolyRingElem) - ccall((:fq_default_poly_zero, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqField}), - z, base_ring(parent(z))) + @ccall libflint.fq_default_poly_zero(z::Ref{FqPolyRingElem}, base_ring(parent(z))::Ref{FqField})::Nothing return z end function one!(z::FqPolyRingElem) - ccall((:fq_default_poly_one, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqField}), - z, base_ring(parent(z))) + @ccall libflint.fq_default_poly_one(z::Ref{FqPolyRingElem}, base_ring(parent(z))::Ref{FqField})::Nothing return z end function neg!(z::FqPolyRingElem, a::FqPolyRingElem) - ccall((:fq_default_poly_neg, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqField}), - z, a, base_ring(parent(a))) + @ccall libflint.fq_default_poly_neg(z::Ref{FqPolyRingElem}, a::Ref{FqPolyRingElem}, base_ring(parent(a))::Ref{FqField})::Nothing return z end function fit!(z::FqPolyRingElem, n::Int) - ccall((:fq_default_poly_fit_length, libflint), Nothing, - (Ref{FqPolyRingElem}, Int, Ref{FqField}), - z, n, base_ring(parent(z))) + @ccall libflint.fq_default_poly_fit_length(z::Ref{FqPolyRingElem}, n::Int, base_ring(parent(z))::Ref{FqField})::Nothing return nothing end function setcoeff!(z::FqPolyRingElem, n::Int, x::FqFieldElem) - ccall((:fq_default_poly_set_coeff, libflint), Nothing, - (Ref{FqPolyRingElem}, Int, Ref{FqFieldElem}, Ref{FqField}), - z, n, x, base_ring(parent(z))) + @ccall libflint.fq_default_poly_set_coeff(z::Ref{FqPolyRingElem}, n::Int, x::Ref{FqFieldElem}, base_ring(parent(z))::Ref{FqField})::Nothing return z end function mul!(z::FqPolyRingElem, x::FqPolyRingElem, y::FqPolyRingElem) - ccall((:fq_default_poly_mul, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_mul(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z end function add!(z::FqPolyRingElem, x::FqPolyRingElem, y::FqPolyRingElem) - ccall((:fq_default_poly_add, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_add(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z end function sub!(z::FqPolyRingElem, x::FqPolyRingElem, y::FqPolyRingElem) - ccall((:fq_default_poly_sub, libflint), Nothing, - (Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, - Ref{FqField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_default_poly_sub(z::Ref{FqPolyRingElem}, x::Ref{FqPolyRingElem}, y::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Nothing return z end @@ -886,15 +775,12 @@ function lift(R::ZZPolyRing, f::FqPolyRingElem) absolute_degree(F) != 1 && error("Must be a prime field.") if _fq_default_ctx_type(F) == _FQ_DEFAULT_NMOD z = R() - ccall((:fmpz_poly_set_nmod_poly_unsigned, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{FqPolyRingElem}), z, f) + @ccall libflint.fmpz_poly_set_nmod_poly_unsigned(z::Ref{ZZPolyRingElem}, f::Ref{FqPolyRingElem})::Nothing return z else @assert _fq_default_ctx_type(F) == _FQ_DEFAULT_FMPZ_NMOD z = R() - ccall((:fmpz_mod_poly_get_fmpz_poly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{FqPolyRingElem}, Ptr{Nothing}), - z, f, pointer_from_objref(F) + 2 * sizeof(Cint)) + @ccall libflint.fmpz_mod_poly_get_fmpz_poly(z::Ref{ZZPolyRingElem}, f::Ref{FqPolyRingElem}, (pointer_from_objref(F) + 2 * sizeof(Cint))::Ptr{Nothing})::Nothing return z end end diff --git a/src/flint/fq_default_rel_series.jl b/src/flint/fq_default_rel_series.jl index f5e850701..b0cf9e360 100644 --- a/src/flint/fq_default_rel_series.jl +++ b/src/flint/fq_default_rel_series.jl @@ -40,24 +40,19 @@ function normalise(a::FqRelPowerSeriesRingElem, len::Int) ctx = base_ring(a) if len > 0 c = base_ring(a)() - ccall((:fq_default_poly_get_coeff, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - c, a, len - 1, ctx) + @ccall libflint.fq_default_poly_get_coeff(c::Ref{FqFieldElem}, a::Ref{FqRelPowerSeriesRingElem}, (len - 1)::Int, ctx::Ref{FqField})::Nothing end while len > 0 && iszero(c) len -= 1 if len > 0 - ccall((:fq_default_poly_get_coeff, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - c, a, len - 1, ctx) + @ccall libflint.fq_default_poly_get_coeff(c::Ref{FqFieldElem}, a::Ref{FqRelPowerSeriesRingElem}, (len - 1)::Int, ctx::Ref{FqField})::Nothing end end return len end function pol_length(x::FqRelPowerSeriesRingElem) - return ccall((:fq_default_poly_length, libflint), Int, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqField}), x, base_ring(x)) + return @ccall libflint.fq_default_poly_length(x::Ref{FqRelPowerSeriesRingElem}, base_ring(x)::Ref{FqField})::Int end precision(x::FqRelPowerSeriesRingElem) = x.prec @@ -67,9 +62,7 @@ function polcoeff(x::FqRelPowerSeriesRingElem, n::Int) if n < 0 return z end - ccall((:fq_default_poly_get_coeff, libflint), Nothing, - (Ref{FqFieldElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, x, n, base_ring(x)) + @ccall libflint.fq_default_poly_get_coeff(z::Ref{FqFieldElem}, x::Ref{FqRelPowerSeriesRingElem}, n::Int, base_ring(x)::Ref{FqField})::Nothing return z end @@ -104,9 +97,7 @@ function renormalize!(z::FqRelPowerSeriesRingElem) z.val = zprec else z.val = zval + i - ccall((:fq_default_poly_shift_right, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, z, i, base_ring(z)) + @ccall libflint.fq_default_poly_shift_right(z::Ref{FqRelPowerSeriesRingElem}, z::Ref{FqRelPowerSeriesRingElem}, i::Int, base_ring(z)::Ref{FqField})::Nothing end return nothing end @@ -184,31 +175,18 @@ function +(a::FqRelPowerSeriesRingElem, b::FqRelPowerSeriesRingElem) ccall((:fq_default_poly_set_trunc, libflint), Nothing, (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), z, b, max(0, lenz - b.val + a.val), ctx) - ccall((:fq_default_poly_shift_left, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, z, b.val - a.val, ctx) - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, z, a, lenz, ctx) + @ccall libflint.fq_default_poly_shift_left(z::Ref{FqRelPowerSeriesRingElem}, z::Ref{FqRelPowerSeriesRingElem}, (b.val - a.val)::Int, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_add_series(z::Ref{FqRelPowerSeriesRingElem}, z::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, lenz::Int, ctx::Ref{FqField})::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:fq_default_poly_set_trunc, libflint), Nothing, (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), z, a, max(0, lenz - a.val + b.val), ctx) - ccall((:fq_default_poly_shift_left, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, z, a.val - b.val, ctx) - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, z, b, lenz, ctx) + @ccall libflint.fq_default_poly_shift_left(z::Ref{FqRelPowerSeriesRingElem}, z::Ref{FqRelPowerSeriesRingElem}, (a.val - b.val)::Int, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_add_series(z::Ref{FqRelPowerSeriesRingElem}, z::Ref{FqRelPowerSeriesRingElem}, b::Ref{FqRelPowerSeriesRingElem}, lenz::Int, ctx::Ref{FqField})::Nothing else lenz = max(lena, lenb) - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, a, b, lenz, ctx) + @ccall libflint.fq_default_poly_add_series(z::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, b::Ref{FqRelPowerSeriesRingElem}, lenz::Int, ctx::Ref{FqField})::Nothing end z.prec = prec z.val = val @@ -232,32 +210,19 @@ function -(a::FqRelPowerSeriesRingElem, b::FqRelPowerSeriesRingElem) ccall((:fq_default_poly_set_trunc, libflint), Nothing, (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), z, b, max(0, lenz - b.val + a.val), ctx) - ccall((:fq_default_poly_shift_left, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, z, b.val - a.val, ctx) + @ccall libflint.fq_default_poly_shift_left(z::Ref{FqRelPowerSeriesRingElem}, z::Ref{FqRelPowerSeriesRingElem}, (b.val - a.val)::Int, ctx::Ref{FqField})::Nothing z = neg!(z) - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, z, a, lenz, ctx) + @ccall libflint.fq_default_poly_add_series(z::Ref{FqRelPowerSeriesRingElem}, z::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, lenz::Int, ctx::Ref{FqField})::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:fq_default_poly_set_trunc, libflint), Nothing, (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), z, a, max(0, lenz - a.val + b.val), ctx) - ccall((:fq_default_poly_shift_left, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, z, a.val - b.val, ctx) - ccall((:fq_default_poly_sub_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, z, b, lenz, ctx) + @ccall libflint.fq_default_poly_shift_left(z::Ref{FqRelPowerSeriesRingElem}, z::Ref{FqRelPowerSeriesRingElem}, (a.val - b.val)::Int, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_sub_series(z::Ref{FqRelPowerSeriesRingElem}, z::Ref{FqRelPowerSeriesRingElem}, b::Ref{FqRelPowerSeriesRingElem}, lenz::Int, ctx::Ref{FqField})::Nothing else lenz = max(lena, lenb) - ccall((:fq_default_poly_sub_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, a, b, lenz, ctx) + @ccall libflint.fq_default_poly_sub_series(z::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, b::Ref{FqRelPowerSeriesRingElem}, lenz::Int, ctx::Ref{FqField})::Nothing end z.prec = prec z.val = val @@ -281,10 +246,7 @@ function *(a::FqRelPowerSeriesRingElem, b::FqRelPowerSeriesRingElem) return z end lenz = min(lena + lenb - 1, prec) - ccall((:fq_default_poly_mullow, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, a, b, lenz, base_ring(a)) + @ccall libflint.fq_default_poly_mullow(z::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, b::Ref{FqRelPowerSeriesRingElem}, lenz::Int, base_ring(a)::Ref{FqField})::Nothing return z end @@ -298,10 +260,7 @@ function *(x::FqFieldElem, y::FqRelPowerSeriesRingElem) z = parent(y)() z.prec = y.prec z.val = y.val - ccall((:fq_default_poly_scalar_mul_fq_default, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqFieldElem}, Ref{FqField}), - z, y, x, base_ring(y)) + @ccall libflint.fq_default_poly_scalar_mul_fq_default(z::Ref{FqRelPowerSeriesRingElem}, y::Ref{FqRelPowerSeriesRingElem}, x::Ref{FqFieldElem}, base_ring(y)::Ref{FqField})::Nothing return z end @@ -367,10 +326,7 @@ function shift_right(x::FqRelPowerSeriesRingElem, len::Int) z.prec = max(0, x.prec - len) z.val = max(0, xval - len) zlen = min(xlen + xval - len, xlen) - ccall((:fq_default_poly_shift_right, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Int, Ref{FqField}), - z, x, xlen - zlen, base_ring(x)) + @ccall libflint.fq_default_poly_shift_right(z::Ref{FqRelPowerSeriesRingElem}, x::Ref{FqRelPowerSeriesRingElem}, (xlen - zlen)::Int, base_ring(x)::Ref{FqField})::Nothing renormalize!(z) end return z @@ -395,9 +351,7 @@ function truncate!(x::FqRelPowerSeriesRingElem, k::Int) x = zero!(x) x.val = k else - ccall((:fq_default_poly_truncate, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - x, k - valuation(x), base_ring(x)) + @ccall libflint.fq_default_poly_truncate(x::Ref{FqRelPowerSeriesRingElem}, (k - valuation(x))::Int, base_ring(x)::Ref{FqField})::Nothing end x.prec = k return x @@ -463,10 +417,7 @@ function ==(x::FqRelPowerSeriesRingElem, y::FqRelPowerSeriesRingElem) if xlen != ylen return false end - return Bool(ccall((:fq_default_poly_equal_trunc, libflint), Cint, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Int, Ref{FqField}), - x, y, xlen, base_ring(x))) + return Bool(@ccall libflint.fq_default_poly_equal_trunc(x::Ref{FqRelPowerSeriesRingElem}, y::Ref{FqRelPowerSeriesRingElem}, xlen::Int, base_ring(x)::Ref{FqField})::Cint) end function isequal(x::FqRelPowerSeriesRingElem, y::FqRelPowerSeriesRingElem) @@ -476,10 +427,7 @@ function isequal(x::FqRelPowerSeriesRingElem, y::FqRelPowerSeriesRingElem) if x.prec != y.prec || x.val != y.val || pol_length(x) != pol_length(y) return false end - return Bool(ccall((:fq_default_poly_equal, libflint), Cint, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqField}), - x, y, base_ring(x))) + return Bool(@ccall libflint.fq_default_poly_equal(x::Ref{FqRelPowerSeriesRingElem}, y::Ref{FqRelPowerSeriesRingElem}, base_ring(x)::Ref{FqField})::Cint) end ############################################################################### @@ -505,10 +453,7 @@ function divexact(x::FqRelPowerSeriesRingElem, y::FqRelPowerSeriesRingElem; chec z.val = xval - yval z.prec = prec + z.val if prec != 0 - ccall((:fq_default_poly_div_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, x, y, prec, base_ring(x)) + @ccall libflint.fq_default_poly_div_series(z::Ref{FqRelPowerSeriesRingElem}, x::Ref{FqRelPowerSeriesRingElem}, y::Ref{FqRelPowerSeriesRingElem}, prec::Int, base_ring(x)::Ref{FqField})::Nothing end return z end @@ -525,10 +470,7 @@ function divexact(x::FqRelPowerSeriesRingElem, y::FqFieldElem; check::Bool=true) z.prec = x.prec z.prec = x.prec z.val = x.val - ccall((:fq_default_poly_scalar_div_fq_default, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqFieldElem}, Ref{FqField}), - z, x, y, base_ring(x)) + @ccall libflint.fq_default_poly_scalar_div_fq_default(z::Ref{FqRelPowerSeriesRingElem}, x::Ref{FqRelPowerSeriesRingElem}, y::Ref{FqFieldElem}, base_ring(x)::Ref{FqField})::Nothing return z end @@ -544,9 +486,7 @@ function inv(a::FqRelPowerSeriesRingElem) ainv = parent(a)() ainv.prec = a.prec ainv.val = 0 - ccall((:fq_default_poly_inv_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - ainv, a, a.prec, base_ring(a)) + @ccall libflint.fq_default_poly_inv_series(ainv::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, a.prec::Int, base_ring(a)::Ref{FqField})::Nothing return ainv end @@ -620,10 +560,7 @@ function sqrt_classical(a::FqRelPowerSeriesRingElem; check::Bool=true) s = sqrt(c; check=check) end a = divexact(a, c) - ccall((:fq_default_poly_sqrt_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Int, Ref{FqField}), - z, a, a.prec, base_ring(a)) + @ccall libflint.fq_default_poly_sqrt_series(z::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, a.prec::Int, base_ring(a)::Ref{FqField})::Nothing if !isone(s) z *= s end @@ -654,47 +591,38 @@ end ############################################################################### function zero!(x::FqRelPowerSeriesRingElem) - ccall((:fq_default_poly_zero, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqField}), x, base_ring(x)) + @ccall libflint.fq_default_poly_zero(x::Ref{FqRelPowerSeriesRingElem}, base_ring(x)::Ref{FqField})::Nothing x.prec = parent(x).prec_max x.val = parent(x).prec_max return x end function one!(x::FqRelPowerSeriesRingElem) - ccall((:fq_default_poly_one, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqField}), x, base_ring(x)) + @ccall libflint.fq_default_poly_one(x::Ref{FqRelPowerSeriesRingElem}, base_ring(x)::Ref{FqField})::Nothing x.prec = parent(x).prec_max x.val = 0 return x end function neg!(z::FqRelPowerSeriesRingElem, x::FqRelPowerSeriesRingElem) - ccall((:fq_default_poly_neg, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Ref{FqField}), z, x, base_ring(x)) + @ccall libflint.fq_default_poly_neg(z::Ref{FqRelPowerSeriesRingElem}, x::Ref{FqRelPowerSeriesRingElem}, base_ring(x)::Ref{FqField})::Nothing z.prec = x.prec z.val = x.val return z end function fit!(z::FqRelPowerSeriesRingElem, n::Int) - ccall((:fq_default_poly_fit_length, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, n, base_ring(z)) + @ccall libflint.fq_default_poly_fit_length(z::Ref{FqRelPowerSeriesRingElem}, n::Int, base_ring(z)::Ref{FqField})::Nothing return nothing end function setcoeff!(z::FqRelPowerSeriesRingElem, n::Int, x::ZZRingElem) - ccall((:fq_default_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Int, Ref{ZZRingElem}, Ref{FqField}), - z, n, x, base_ring(z)) + @ccall libflint.fq_default_poly_set_coeff_fmpz(z::Ref{FqRelPowerSeriesRingElem}, n::Int, x::Ref{ZZRingElem}, base_ring(z)::Ref{FqField})::Nothing return z end function setcoeff!(z::FqRelPowerSeriesRingElem, n::Int, x::FqFieldElem) - ccall((:fq_default_poly_set_coeff, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqFieldElem}, Ref{FqField}), - z, n, x, base_ring(z)) + @ccall libflint.fq_default_poly_set_coeff(z::Ref{FqRelPowerSeriesRingElem}, n::Int, x::Ref{FqFieldElem}, base_ring(z)::Ref{FqField})::Nothing return z end @@ -712,10 +640,7 @@ function mul!(z::FqRelPowerSeriesRingElem, a::FqRelPowerSeriesRingElem, b::FqRel if lena <= 0 || lenb <= 0 lenz = 0 end - ccall((:fq_default_poly_mullow, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, a, b, lenz, base_ring(z)) + @ccall libflint.fq_default_poly_mullow(z::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, b::Ref{FqRelPowerSeriesRingElem}, lenz::Int, base_ring(z)::Ref{FqField})::Nothing return z end @@ -734,31 +659,18 @@ function add!(a::FqRelPowerSeriesRingElem, b::FqRelPowerSeriesRingElem) ccall((:fq_default_poly_set_trunc, libflint), Nothing, (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), z, b, max(0, lenz - b.val + a.val), ctx) - ccall((:fq_default_poly_shift_left, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - z, z, b.val - a.val, ctx) - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - a, a, z, lenz, ctx) + @ccall libflint.fq_default_poly_shift_left(z::Ref{FqRelPowerSeriesRingElem}, z::Ref{FqRelPowerSeriesRingElem}, (b.val - a.val)::Int, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_add_series(a::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, z::Ref{FqRelPowerSeriesRingElem}, lenz::Int, ctx::Ref{FqField})::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:fq_default_poly_truncate, libflint), Nothing, (Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), a, max(0, lenz - a.val + b.val), ctx) - ccall((:fq_default_poly_shift_left, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - a, a, a.val - b.val, ctx) - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - a, a, b, lenz, ctx) + @ccall libflint.fq_default_poly_shift_left(a::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, (a.val - b.val)::Int, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_add_series(a::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, b::Ref{FqRelPowerSeriesRingElem}, lenz::Int, ctx::Ref{FqField})::Nothing else lenz = max(lena, lenb) - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - a, a, b, lenz, ctx) + @ccall libflint.fq_default_poly_add_series(a::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, b::Ref{FqRelPowerSeriesRingElem}, lenz::Int, ctx::Ref{FqField})::Nothing end a.prec = prec a.val = val @@ -784,31 +696,18 @@ function add!(c::FqRelPowerSeriesRingElem, a::FqRelPowerSeriesRingElem, b::FqRel ccall((:fq_default_poly_set_trunc, libflint), Nothing, (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), c, b, max(0, lenc - b.val + a.val), ctx) - ccall((:fq_default_poly_shift_left, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - c, c, b.val - a.val, ctx) - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - c, c, a, lenc, ctx) + @ccall libflint.fq_default_poly_shift_left(c::Ref{FqRelPowerSeriesRingElem}, c::Ref{FqRelPowerSeriesRingElem}, (b.val - a.val)::Int, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_add_series(c::Ref{FqRelPowerSeriesRingElem}, c::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, lenc::Int, ctx::Ref{FqField})::Nothing elseif b.val < a.val lenc = max(lena + a.val - b.val, lenb) ccall((:fq_default_poly_set_trunc, libflint), Nothing, (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), c, a, max(0, lenc - a.val + b.val), ctx) - ccall((:fq_default_poly_shift_left, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - c, c, a.val - b.val, ctx) - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - c, c, b, lenc, ctx) + @ccall libflint.fq_default_poly_shift_left(c::Ref{FqRelPowerSeriesRingElem}, c::Ref{FqRelPowerSeriesRingElem}, (a.val - b.val)::Int, ctx::Ref{FqField})::Nothing + @ccall libflint.fq_default_poly_add_series(c::Ref{FqRelPowerSeriesRingElem}, c::Ref{FqRelPowerSeriesRingElem}, b::Ref{FqRelPowerSeriesRingElem}, lenc::Int, ctx::Ref{FqField})::Nothing else lenc = max(lena, lenb) - ccall((:fq_default_poly_add_series, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Ref{FqRelPowerSeriesRingElem}, - Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - c, a, b, lenc, ctx) + @ccall libflint.fq_default_poly_add_series(c::Ref{FqRelPowerSeriesRingElem}, a::Ref{FqRelPowerSeriesRingElem}, b::Ref{FqRelPowerSeriesRingElem}, lenc::Int, ctx::Ref{FqField})::Nothing end c.prec = prec c.val = val @@ -817,9 +716,7 @@ function add!(c::FqRelPowerSeriesRingElem, a::FqRelPowerSeriesRingElem, b::FqRel end function set_length!(a::FqRelPowerSeriesRingElem, n::Int64) - ccall((:_fq_default_poly_set_length, libflint), Nothing, - (Ref{FqRelPowerSeriesRingElem}, Int, Ref{FqField}), - a, n, base_ring(a)) + @ccall libflint._fq_default_poly_set_length(a::Ref{FqRelPowerSeriesRingElem}, n::Int, base_ring(a)::Ref{FqField})::Nothing return a end diff --git a/src/flint/fq_embed.jl b/src/flint/fq_embed.jl index eee1d835d..5157c4ba7 100644 --- a/src/flint/fq_embed.jl +++ b/src/flint/fq_embed.jl @@ -12,9 +12,7 @@ function linear_factor(x::FqPolyRepPolyRingElem) y = parent(x)() - ccall((:fq_poly_factor_split_single, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - y, x, base_ring(x)) + @ccall libflint.fq_poly_factor_split_single(y::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, base_ring(x)::Ref{FqPolyRepField})::Nothing return y end @@ -32,10 +30,7 @@ function embed_gens(k::FqPolyRepField, K::FqPolyRepField) PR = polynomial_ring(R, "T")[1] P = PR() - ccall((:fq_embed_gens, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepFieldElem}, Ref{FpPolyRingElem}, Ref{FqPolyRepField}, - Ref{FqPolyRepField}), - a, b, P, k, K) + @ccall libflint.fq_embed_gens(a::Ref{FqPolyRepFieldElem}, b::Ref{FqPolyRepFieldElem}, P::Ref{FpPolyRingElem}, k::Ref{FqPolyRepField}, K::Ref{FqPolyRepField})::Nothing return a, b, P end @@ -57,10 +52,7 @@ function embed_matrices(k::FqPolyRepField, K::FqPolyRepField) s1 = zero_matrix(R, n, m) s2 = zero_matrix(R, m, n) - ccall((:fq_embed_matrices, libflint), Nothing, - (Ref{FpMatrix}, Ref{FpMatrix}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}, - Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}, Ref{FpPolyRingElem}), - s1, s2, a, k, b, K, P) + @ccall libflint.fq_embed_matrices(s1::Ref{FpMatrix}, s2::Ref{FpMatrix}, a::Ref{FqPolyRepFieldElem}, k::Ref{FqPolyRepField}, b::Ref{FqPolyRepFieldElem}, K::Ref{FqPolyRepField}, P::Ref{FpPolyRingElem})::Nothing return s1, s2 end @@ -72,17 +64,13 @@ function embed_matrices_pre(a::FqPolyRepFieldElem, b::FqPolyRepFieldElem, P::FpP s1 = zero_matrix(R, n, m) s2 = zero_matrix(R, m, n) - ccall((:fq_embed_matrices, libflint), Nothing, - (Ref{FpMatrix}, Ref{FpMatrix}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}, - Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}, Ref{FpPolyRingElem}), - s1, s2, a, k, b, K, P) + @ccall libflint.fq_embed_matrices(s1::Ref{FpMatrix}, s2::Ref{FpMatrix}, a::Ref{FqPolyRepFieldElem}, k::Ref{FqPolyRepField}, b::Ref{FqPolyRepFieldElem}, K::Ref{FqPolyRepField}, P::Ref{FpPolyRingElem})::Nothing return s1, s2 end # dirty: internally in flint an fq_struct is just an fmpz_poly_struct function setcoeff!(x::FqPolyRepFieldElem, j::Int, c::ZZRingElem) - ccall((:fmpz_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Int, Ref{ZZRingElem}), x, j, c) + @ccall libflint.fmpz_poly_set_coeff_fmpz(x::Ref{FqPolyRepFieldElem}, j::Int, c::Ref{ZZRingElem})::Nothing end function embed_pre_mat(x::FqPolyRepFieldElem, K::FqPolyRepField, M::FpMatrix) diff --git a/src/flint/fq_mat.jl b/src/flint/fq_mat.jl index 1ff8e7e85..85c5f93a3 100644 --- a/src/flint/fq_mat.jl +++ b/src/flint/fq_mat.jl @@ -31,8 +31,7 @@ function getindex!(v::FqPolyRepFieldElem, a::FqPolyRepMatrix, i::Int, j::Int) @boundscheck _checkbounds(a, i, j) GC.@preserve a begin z = mat_entry_ptr(a, i, j) - ccall((:fq_set, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ptr{FqPolyRepFieldElem}), v, z) + @ccall libflint.fq_set(v::Ref{FqPolyRepFieldElem}, z::Ptr{FqPolyRepFieldElem})::Nothing end return v end @@ -42,7 +41,7 @@ end GC.@preserve a begin el = mat_entry_ptr(a, i, j) z = base_ring(a)() - ccall((:fq_set, libflint), Nothing, (Ref{FqPolyRepFieldElem}, Ptr{FqPolyRepFieldElem}), z, el) + @ccall libflint.fq_set(z::Ref{FqPolyRepFieldElem}, el::Ptr{FqPolyRepFieldElem})::Nothing end return z end @@ -58,8 +57,7 @@ end @boundscheck _checkbounds(a, i, j) GC.@preserve a begin el = mat_entry_ptr(a, i, j) - ccall((:fq_set_fmpz, libflint), Nothing, - (Ptr{FqPolyRepFieldElem}, Ref{ZZRingElem}, Ref{FqPolyRepField}), el, u, base_ring(a)) + @ccall libflint.fq_set_fmpz(el::Ptr{FqPolyRepFieldElem}, u::Ref{ZZRingElem}, base_ring(a)::Ref{FqPolyRepField})::Nothing end end @@ -69,14 +67,12 @@ function setindex!(a::FqPolyRepMatrix, b::FqPolyRepMatrix, r::UnitRange{Int64}, _checkbounds(a, r, c) size(b) == (length(r), length(c)) || throw(DimensionMismatch("tried to assign a $(size(b, 1))x$(size(b, 2)) matrix to a $(length(r))x$(length(c)) destination")) A = view(a, r, c) - ccall((:fq_mat_set, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), A, b, base_ring(A)) + @ccall libflint.fq_mat_set(A::Ref{FqPolyRepMatrix}, b::Ref{FqPolyRepMatrix}, base_ring(A)::Ref{FqPolyRepField})::Nothing end function deepcopy_internal(a::FqPolyRepMatrix, dict::IdDict) z = FqPolyRepMatrix(nrows(a), ncols(a), base_ring(a)) - ccall((:fq_mat_set, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), z, a, base_ring(a)) + @ccall libflint.fq_mat_set(z::Ref{FqPolyRepMatrix}, a::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Nothing return z end @@ -92,8 +88,7 @@ function one(a::FqPolyRepMatrixSpace) end function iszero(a::FqPolyRepMatrix) - r = ccall((:fq_mat_is_zero, libflint), Cint, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), a, base_ring(a)) + r = @ccall libflint.fq_mat_is_zero(a::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Cint return Bool(r) end @@ -101,8 +96,7 @@ end @boundscheck _checkbounds(A, i, j) GC.@preserve A begin x = mat_entry_ptr(A, i, j) - return ccall((:fq_is_zero, libflint), Bool, - (Ptr{FqPolyRepFieldElem}, Ref{FqPolyRepField}), x, base_ring(A)) + return @ccall libflint.fq_is_zero(x::Ptr{FqPolyRepFieldElem}, base_ring(A)::Ref{FqPolyRepField})::Bool end end @@ -116,8 +110,7 @@ function ==(a::FqPolyRepMatrix, b::FqPolyRepMatrix) if !(a.base_ring == b.base_ring) return false end - r = ccall((:fq_mat_equal, libflint), Cint, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), a, b, base_ring(a)) + r = @ccall libflint.fq_mat_equal(a::Ref{FqPolyRepMatrix}, b::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Cint return Bool(r) end @@ -160,9 +153,7 @@ end ############################################################################### function swap_rows!(x::FqPolyRepMatrix, i::Int, j::Int) - ccall((:fq_mat_swap_rows, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ptr{Nothing}, Int, Int, Ref{FqPolyRepField}), - x, C_NULL, i - 1, j - 1, base_ring(x)) + @ccall libflint.fq_mat_swap_rows(x::Ref{FqPolyRepMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int, base_ring(x)::Ref{FqPolyRepField})::Nothing return x end @@ -173,9 +164,7 @@ function swap_rows(x::FqPolyRepMatrix, i::Int, j::Int) end function swap_cols!(x::FqPolyRepMatrix, i::Int, j::Int) - ccall((:fq_mat_swap_cols, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ptr{Nothing}, Int, Int, Ref{FqPolyRepField}), - x, C_NULL, i - 1, j - 1, base_ring(x)) + @ccall libflint.fq_mat_swap_cols(x::Ref{FqPolyRepMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int, base_ring(x)::Ref{FqPolyRepField})::Nothing return x end @@ -186,16 +175,14 @@ function swap_cols(x::FqPolyRepMatrix, i::Int, j::Int) end function reverse_rows!(x::FqPolyRepMatrix) - ccall((:fq_mat_invert_rows, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ptr{Nothing}, Ref{FqPolyRepField}), x, C_NULL, base_ring(x)) + @ccall libflint.fq_mat_invert_rows(x::Ref{FqPolyRepMatrix}, C_NULL::Ptr{Nothing}, base_ring(x)::Ref{FqPolyRepField})::Nothing return x end reverse_rows(x::FqPolyRepMatrix) = reverse_rows!(deepcopy(x)) function reverse_cols!(x::FqPolyRepMatrix) - ccall((:fq_mat_invert_cols, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ptr{Nothing}, Ref{FqPolyRepField}), x, C_NULL, base_ring(x)) + @ccall libflint.fq_mat_invert_cols(x::Ref{FqPolyRepMatrix}, C_NULL::Ptr{Nothing}, base_ring(x)::Ref{FqPolyRepField})::Nothing return x end @@ -244,55 +231,42 @@ end ################################################################################ function zero!(a::FqPolyRepMatrix) - ccall((:fq_mat_zero, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), a, base_ring(a)) + @ccall libflint.fq_mat_zero(a::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Nothing return a end function one!(a::FqPolyRepMatrix) - ccall((:fq_mat_one, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), a, base_ring(a)) + @ccall libflint.fq_mat_one(a::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Nothing return a end function neg!(z::FqPolyRepMatrix, a::FqPolyRepMatrix) - ccall((:fq_mat_neg, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), z, a, base_ring(a)) + @ccall libflint.fq_mat_neg(z::Ref{FqPolyRepMatrix}, a::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Nothing return z end function mul!(a::FqPolyRepMatrix, b::FqPolyRepMatrix, c::FqPolyRepMatrix) - ccall((:fq_mat_mul, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), - a, b, c, base_ring(a)) + @ccall libflint.fq_mat_mul(a::Ref{FqPolyRepMatrix}, b::Ref{FqPolyRepMatrix}, c::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Nothing return a end function add!(a::FqPolyRepMatrix, b::FqPolyRepMatrix, c::FqPolyRepMatrix) - ccall((:fq_mat_add, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), - a, b, c, base_ring(a)) + @ccall libflint.fq_mat_add(a::Ref{FqPolyRepMatrix}, b::Ref{FqPolyRepMatrix}, c::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Nothing return a end function sub!(a::FqPolyRepMatrix, b::FqPolyRepMatrix, c::FqPolyRepMatrix) - ccall((:fq_mat_sub, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), - a, b, c, base_ring(a)) + @ccall libflint.fq_mat_sub(a::Ref{FqPolyRepMatrix}, b::Ref{FqPolyRepMatrix}, c::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Nothing return a end function mul!(z::Vector{FqPolyRepFieldElem}, a::FqPolyRepMatrix, b::Vector{FqPolyRepFieldElem}) - ccall((:fq_mat_mul_vec_ptr, libflint), Nothing, - (Ptr{Ref{FqPolyRepFieldElem}}, Ref{FqPolyRepMatrix}, Ptr{Ref{FqPolyRepFieldElem}}, Int, Ref{FqPolyRepField}), - z, a, b, length(b), base_ring(a)) + @ccall libflint.fq_mat_mul_vec_ptr(z::Ptr{Ref{FqPolyRepFieldElem}}, a::Ref{FqPolyRepMatrix}, b::Ptr{Ref{FqPolyRepFieldElem}}, length(b)::Int, base_ring(a)::Ref{FqPolyRepField})::Nothing return z end function mul!(z::Vector{FqPolyRepFieldElem}, a::Vector{FqPolyRepFieldElem}, b::FqPolyRepMatrix) - ccall((:fq_mat_vec_mul_ptr, libflint), Nothing, - (Ptr{Ref{FqPolyRepFieldElem}}, Ptr{Ref{FqPolyRepFieldElem}}, Int, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), - z, a, length(a), b, base_ring(b)) + @ccall libflint.fq_mat_vec_mul_ptr(z::Ptr{Ref{FqPolyRepFieldElem}}, a::Ptr{Ref{FqPolyRepFieldElem}}, length(a)::Int, b::Ref{FqPolyRepMatrix}, base_ring(b)::Ref{FqPolyRepField})::Nothing return z end @@ -302,15 +276,9 @@ function Generic.add_one!(a::FqPolyRepMatrix, i::Int, j::Int) GC.@preserve a begin x = mat_entry_ptr(a, i, j) # There is no fq_add_one, but only ...sub_one - ccall((:fq_neg, libflint), Nothing, - (Ptr{FqPolyRepFieldElem}, Ptr{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - x, x, F) - ccall((:fq_sub_one, libflint), Nothing, - (Ptr{FqPolyRepFieldElem}, Ptr{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - x, x, F) - ccall((:fq_neg, libflint), Nothing, - (Ptr{FqPolyRepFieldElem}, Ptr{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - x, x, F) + @ccall libflint.fq_neg(x::Ptr{FqPolyRepFieldElem}, x::Ptr{FqPolyRepFieldElem}, F::Ref{FqPolyRepField})::Nothing + @ccall libflint.fq_sub_one(x::Ptr{FqPolyRepFieldElem}, x::Ptr{FqPolyRepFieldElem}, F::Ref{FqPolyRepField})::Nothing + @ccall libflint.fq_neg(x::Ptr{FqPolyRepFieldElem}, x::Ptr{FqPolyRepFieldElem}, F::Ref{FqPolyRepField})::Nothing end return a end @@ -361,16 +329,12 @@ end function rref(a::FqPolyRepMatrix) z = similar(a) - r = ccall((:fq_mat_rref, libflint), Int, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), - z, a, base_ring(a)) + r = @ccall libflint.fq_mat_rref(z::Ref{FqPolyRepMatrix}, a::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Int return r, z end function rref!(a::FqPolyRepMatrix) - r = ccall((:fq_mat_rref, libflint), Int, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), - a, a, base_ring(a)) + r = @ccall libflint.fq_mat_rref(a::Ref{FqPolyRepMatrix}, a::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Int return r end @@ -423,8 +387,7 @@ end function inv(a::FqPolyRepMatrix) !is_square(a) && error("Matrix must be a square matrix") z = similar(a) - r = ccall((:fq_mat_inv, libflint), Int, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), z, a, base_ring(a)) + r = @ccall libflint.fq_mat_inv(z::Ref{FqPolyRepMatrix}, a::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Int !Bool(r) && error("Matrix not invertible") return z end @@ -445,9 +408,7 @@ function Solve._can_solve_internal_no_check(::Solve.LUTrait, A::FqPolyRepMatrix, end x = similar(A, ncols(A), ncols(b)) - fl = ccall((:fq_mat_can_solve, libflint), Cint, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, - Ref{FqPolyRepField}), x, A, b, base_ring(A)) + fl = @ccall libflint.fq_mat_can_solve(x::Ref{FqPolyRepMatrix}, A::Ref{FqPolyRepMatrix}, b::Ref{FqPolyRepMatrix}, base_ring(A)::Ref{FqPolyRepField})::Cint if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end @@ -457,18 +418,12 @@ end # Direct interface to the C functions to be able to write 'generic' code for # different matrix types function _solve_tril_right_flint!(x::FqPolyRepMatrix, L::FqPolyRepMatrix, B::FqPolyRepMatrix, unit::Bool) - ccall((:fq_mat_solve_tril, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, - Cint, Ref{FqPolyRepField}), - x, L, B, Cint(unit), base_ring(L)) + @ccall libflint.fq_mat_solve_tril(x::Ref{FqPolyRepMatrix}, L::Ref{FqPolyRepMatrix}, B::Ref{FqPolyRepMatrix}, Cint(unit)::Cint, base_ring(L)::Ref{FqPolyRepField})::Nothing return nothing end function _solve_triu_right_flint!(x::FqPolyRepMatrix, U::FqPolyRepMatrix, B::FqPolyRepMatrix, unit::Bool) - ccall((:fq_mat_solve_triu, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, - Cint, Ref{FqPolyRepField}), - x, U, B, Cint(unit), base_ring(U)) + @ccall libflint.fq_mat_solve_triu(x::Ref{FqPolyRepMatrix}, U::Ref{FqPolyRepMatrix}, B::Ref{FqPolyRepMatrix}, Cint(unit)::Cint, base_ring(U)::Ref{FqPolyRepField})::Nothing return nothing end @@ -481,9 +436,7 @@ end function lu!(P::Perm, x::FqPolyRepMatrix) P.d .-= 1 - rank = Int(ccall((:fq_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{FqPolyRepMatrix}, Cint, Ref{FqPolyRepField}), - P.d, x, 0, base_ring(x))) + rank = Int(@ccall libflint.fq_mat_lu(P.d::Ptr{Int}, x::Ref{FqPolyRepMatrix}, 0::Cint, base_ring(x)::Ref{FqPolyRepField})::Cint) P.d .+= 1 @@ -546,9 +499,7 @@ function Base.view(x::FqPolyRepMatrix, r1::Int, c1::Int, r2::Int, c2::Int) z = FqPolyRepMatrix() z.base_ring = x.base_ring z.view_parent = x - ccall((:fq_mat_window_init, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Int, Int, Int, Int, Ref{FqPolyRepField}), - z, x, r1 - 1, c1 - 1, r2, c2, base_ring(x)) + @ccall libflint.fq_mat_window_init(z::Ref{FqPolyRepMatrix}, x::Ref{FqPolyRepMatrix}, (r1 - 1)::Int, (c1 - 1)::Int, r2::Int, c2::Int, base_ring(x)::Ref{FqPolyRepField})::Nothing finalizer(_fq_mat_window_clear_fn, z) return z end @@ -558,8 +509,7 @@ function Base.view(x::FqPolyRepMatrix, r::AbstractUnitRange{Int}, c::AbstractUni end function _fq_mat_window_clear_fn(a::FqPolyRepMatrix) - ccall((:fq_mat_window_clear, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), a, base_ring(a)) + @ccall libflint.fq_mat_window_clear(a::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Nothing end function sub(x::FqPolyRepMatrix, r1::Int, c1::Int, r2::Int, c2::Int) @@ -582,9 +532,7 @@ function hcat(x::FqPolyRepMatrix, y::FqPolyRepMatrix) (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") (x.r != y.r) && error("Matrices must have same number of rows") z = similar(x, nrows(x), ncols(x) + ncols(y)) - ccall((:fq_mat_concat_horizontal, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), - z, x, y, base_ring(x)) + @ccall libflint.fq_mat_concat_horizontal(z::Ref{FqPolyRepMatrix}, x::Ref{FqPolyRepMatrix}, y::Ref{FqPolyRepMatrix}, base_ring(x)::Ref{FqPolyRepField})::Nothing return z end @@ -592,9 +540,7 @@ function vcat(x::FqPolyRepMatrix, y::FqPolyRepMatrix) (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") (x.c != y.c) && error("Matrices must have same number of columns") z = similar(x, nrows(x) + nrows(y), ncols(x)) - ccall((:fq_mat_concat_vertical, libflint), Nothing, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), - z, x, y, base_ring(x)) + @ccall libflint.fq_mat_concat_vertical(z::Ref{FqPolyRepMatrix}, x::Ref{FqPolyRepMatrix}, y::Ref{FqPolyRepMatrix}, base_ring(x)::Ref{FqPolyRepField})::Nothing return z end @@ -608,8 +554,7 @@ function charpoly(R::FqPolyRepPolyRing, a::FqPolyRepMatrix) !is_square(a) && error("Matrix must be square") base_ring(R) != base_ring(a) && error("Must have common base ring") p = R() - ccall((:fq_mat_charpoly, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), p, a, base_ring(a)) + @ccall libflint.fq_mat_charpoly(p::Ref{FqPolyRepPolyRingElem}, a::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Nothing return p end @@ -617,8 +562,7 @@ function charpoly_danivlesky!(R::FqPolyRepPolyRing, a::FqPolyRepMatrix) !is_square(a) && error("Matrix must be square") base_ring(R) != base_ring(a) && error("Must have common base ring") p = R() - ccall((:fq_mat_charpoly_danilevsky, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), p, a, base_ring(a)) + @ccall libflint.fq_mat_charpoly_danilevsky(p::Ref{FqPolyRepPolyRingElem}, a::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Nothing return p end @@ -634,8 +578,7 @@ function minpoly(R::FqPolyRepPolyRing, a::FqPolyRepMatrix) base_ring(R) != base_ring(a) && error("Must have common base ring") m = deepcopy(a) p = R() - ccall((:fq_mat_minpoly, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), p, m, base_ring(a)) + @ccall libflint.fq_mat_minpoly(p::Ref{FqPolyRepPolyRingElem}, m::Ref{FqPolyRepMatrix}, base_ring(a)::Ref{FqPolyRepField})::Nothing return p end @@ -734,8 +677,7 @@ end function nullspace(M::FqPolyRepMatrix) N = similar(M, ncols(M), ncols(M)) - nullity = ccall((:fq_mat_nullspace, libflint), Int, - (Ref{FqPolyRepMatrix}, Ref{FqPolyRepMatrix}, Ref{FqPolyRepField}), N, M, base_ring(M)) + nullity = @ccall libflint.fq_mat_nullspace(N::Ref{FqPolyRepMatrix}, M::Ref{FqPolyRepMatrix}, base_ring(M)::Ref{FqPolyRepField})::Int return nullity, view(N, 1:nrows(N), 1:nullity) end diff --git a/src/flint/fq_nmod.jl b/src/flint/fq_nmod.jl index 11a0ef1a8..b0324be28 100644 --- a/src/flint/fq_nmod.jl +++ b/src/flint/fq_nmod.jl @@ -39,8 +39,7 @@ end function coeff(x::fqPolyRepFieldElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) - return ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{fqPolyRepFieldElem}, Int), x, n) + return @ccall libflint.nmod_poly_get_coeff_ui(x::Ref{fqPolyRepFieldElem}, n::Int)::UInt end function coeffs_raw(x::fqPolyRepFieldElem) @@ -62,8 +61,7 @@ end function setindex_raw!(x::fqPolyRepFieldElem, c::UInt, i::Int) len = degree(parent(x)) i > len - 1 && error("Index out of range") - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Int, UInt), x, i, c) + @ccall libflint.nmod_poly_set_coeff_ui(x::Ref{fqPolyRepFieldElem}, i::Int, c::UInt)::Nothing return x end @@ -73,21 +71,17 @@ one(a::fqPolyRepField) = one!(a()) function gen(a::fqPolyRepField) d = a() - ccall((:fq_nmod_gen, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), d, a) + @ccall libflint.fq_nmod_gen(d::Ref{fqPolyRepFieldElem}, a::Ref{fqPolyRepField})::Nothing return d end -iszero(a::fqPolyRepFieldElem) = ccall((:fq_nmod_is_zero, libflint), Bool, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), a, a.parent) +iszero(a::fqPolyRepFieldElem) = @ccall libflint.fq_nmod_is_zero(a::Ref{fqPolyRepFieldElem}, a.parent::Ref{fqPolyRepField})::Bool -isone(a::fqPolyRepFieldElem) = ccall((:fq_nmod_is_one, libflint), Bool, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), a, a.parent) +isone(a::fqPolyRepFieldElem) = @ccall libflint.fq_nmod_is_one(a::Ref{fqPolyRepFieldElem}, a.parent::Ref{fqPolyRepField})::Bool is_gen(a::fqPolyRepFieldElem) = a == gen(parent(a)) # there is no is_gen in flint -is_unit(a::fqPolyRepFieldElem) = ccall((:fq_nmod_is_invertible, libflint), Bool, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), a, a.parent) +is_unit(a::fqPolyRepFieldElem) = @ccall libflint.fq_nmod_is_invertible(a::Ref{fqPolyRepFieldElem}, a.parent::Ref{fqPolyRepField})::Bool function characteristic(a::fqPolyRepField) return ZZ(a.n) @@ -95,13 +89,12 @@ end function order(a::fqPolyRepField) d = ZZRingElem() - ccall((:fq_nmod_ctx_order, libflint), Nothing, - (Ref{ZZRingElem}, Ref{fqPolyRepField}), d, a) + @ccall libflint.fq_nmod_ctx_order(d::Ref{ZZRingElem}, a::Ref{fqPolyRepField})::Nothing return d end function degree(a::fqPolyRepField) - return ccall((:fq_nmod_ctx_degree, libflint), Int, (Ref{fqPolyRepField},), a) + return @ccall libflint.fq_nmod_ctx_degree(a::Ref{fqPolyRepField})::Int end function deepcopy_internal(d::fqPolyRepFieldElem, dict::IdDict) @@ -173,27 +166,21 @@ end function +(x::fqPolyRepFieldElem, y::fqPolyRepFieldElem) check_parent(x, y) z = parent(y)() - ccall((:fq_nmod_add, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, x, y, y.parent) + @ccall libflint.fq_nmod_add(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, y::Ref{fqPolyRepFieldElem}, y.parent::Ref{fqPolyRepField})::Nothing return z end function -(x::fqPolyRepFieldElem, y::fqPolyRepFieldElem) check_parent(x, y) z = parent(y)() - ccall((:fq_nmod_sub, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, x, y, y.parent) + @ccall libflint.fq_nmod_sub(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, y::Ref{fqPolyRepFieldElem}, y.parent::Ref{fqPolyRepField})::Nothing return z end function *(x::fqPolyRepFieldElem, y::fqPolyRepFieldElem) check_parent(x, y) z = parent(y)() - ccall((:fq_nmod_mul, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, x, y, y.parent) + @ccall libflint.fq_nmod_mul(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, y::Ref{fqPolyRepFieldElem}, y.parent::Ref{fqPolyRepField})::Nothing return z end @@ -205,9 +192,7 @@ end function *(x::Int, y::fqPolyRepFieldElem) z = parent(y)() - ccall((:fq_nmod_mul_si, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Int, Ref{fqPolyRepField}), - z, y, x, y.parent) + @ccall libflint.fq_nmod_mul_si(z::Ref{fqPolyRepFieldElem}, y::Ref{fqPolyRepFieldElem}, x::Int, y.parent::Ref{fqPolyRepField})::Nothing return z end @@ -219,9 +204,7 @@ end function *(x::ZZRingElem, y::fqPolyRepFieldElem) z = parent(y)() - ccall((:fq_nmod_mul_fmpz, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{ZZRingElem}, Ref{fqPolyRepField}), - z, y, x, y.parent) + @ccall libflint.fq_nmod_mul_fmpz(z::Ref{fqPolyRepFieldElem}, y::Ref{fqPolyRepFieldElem}, x::Ref{ZZRingElem}, y.parent::Ref{fqPolyRepField})::Nothing return z end @@ -255,9 +238,7 @@ function ^(x::fqPolyRepFieldElem, y::Int) y = -y end z = parent(x)() - ccall((:fq_nmod_pow_ui, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Int, Ref{fqPolyRepField}), - z, x, y, x.parent) + @ccall libflint.fq_nmod_pow_ui(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, y::Int, x.parent::Ref{fqPolyRepField})::Nothing return z end @@ -267,9 +248,7 @@ function ^(x::fqPolyRepFieldElem, y::ZZRingElem) y = -y end z = parent(x)() - ccall((:fq_nmod_pow, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{ZZRingElem}, Ref{fqPolyRepField}), - z, x, y, x.parent) + @ccall libflint.fq_nmod_pow(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, y::Ref{ZZRingElem}, x.parent::Ref{fqPolyRepField})::Nothing return z end @@ -281,8 +260,7 @@ end function ==(x::fqPolyRepFieldElem, y::fqPolyRepFieldElem) check_parent(x, y) - ccall((:fq_nmod_equal, libflint), Bool, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), x, y, y.parent) + @ccall libflint.fq_nmod_equal(x::Ref{fqPolyRepFieldElem}, y::Ref{fqPolyRepFieldElem}, y.parent::Ref{fqPolyRepField})::Bool end ############################################################################### @@ -308,8 +286,7 @@ end function inv(x::fqPolyRepFieldElem) iszero(x) && throw(DivideError()) z = parent(x)() - ccall((:fq_nmod_inv, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), z, x, x.parent) + @ccall libflint.fq_nmod_inv(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, x.parent::Ref{fqPolyRepField})::Nothing return z end @@ -323,9 +300,7 @@ function divexact(x::fqPolyRepFieldElem, y::fqPolyRepFieldElem; check::Bool=true check_parent(x, y) iszero(y) && throw(DivideError()) z = parent(y)() - ccall((:fq_nmod_div, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, x, y, y.parent) + @ccall libflint.fq_nmod_div(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, y::Ref{fqPolyRepFieldElem}, y.parent::Ref{fqPolyRepField})::Nothing return z end @@ -361,45 +336,36 @@ divexact(x::ZZRingElem, y::fqPolyRepFieldElem; check::Bool=true) = divexact(pare function sqrt(x::fqPolyRepFieldElem; check::Bool=true) z = parent(x)() - res = Bool(ccall((:fq_nmod_sqrt, libflint), Cint, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, x, x.parent)) + res = Bool(@ccall libflint.fq_nmod_sqrt(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, x.parent::Ref{fqPolyRepField})::Cint) check && !res && error("Not a square") return z end function is_square(x::fqPolyRepFieldElem) - return Bool(ccall((:fq_nmod_is_square, libflint), Cint, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - x, x.parent)) + return Bool(@ccall libflint.fq_nmod_is_square(x::Ref{fqPolyRepFieldElem}, x.parent::Ref{fqPolyRepField})::Cint) end function is_square_with_sqrt(x::fqPolyRepFieldElem) z = parent(x)() - flag = ccall((:fq_nmod_sqrt, libflint), Cint, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, x, x.parent) + flag = @ccall libflint.fq_nmod_sqrt(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, x.parent::Ref{fqPolyRepField})::Cint return (Bool(flag), z) end function pth_root(x::fqPolyRepFieldElem) z = parent(x)() - ccall((:fq_nmod_pth_root, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), z, x, x.parent) + @ccall libflint.fq_nmod_pth_root(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, x.parent::Ref{fqPolyRepField})::Nothing return z end function tr(x::fqPolyRepFieldElem) z = ZZRingElem() - ccall((:fq_nmod_trace, libflint), Nothing, - (Ref{ZZRingElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), z, x, x.parent) + @ccall libflint.fq_nmod_trace(z::Ref{ZZRingElem}, x::Ref{fqPolyRepFieldElem}, x.parent::Ref{fqPolyRepField})::Nothing return parent(x)(z) end function norm(x::fqPolyRepFieldElem) z = ZZRingElem() - ccall((:fq_nmod_norm, libflint), Nothing, - (Ref{ZZRingElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), z, x, x.parent) + @ccall libflint.fq_nmod_norm(z::Ref{ZZRingElem}, x::Ref{fqPolyRepFieldElem}, x.parent::Ref{fqPolyRepField})::Nothing return parent(x)(z) end @@ -409,9 +375,7 @@ function frobenius(x::fqPolyRepFieldElem, n = 1) end function frobenius!(a::fqPolyRepFieldElem, b::fqPolyRepFieldElem, i::Int = 1) - ccall((:fq_nmod_frobenius, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Int, Ref{fqPolyRepField}), - a, b, i, parent(a)) + @ccall libflint.fq_nmod_frobenius(a::Ref{fqPolyRepFieldElem}, b::Ref{fqPolyRepFieldElem}, i::Int, parent(a)::Ref{fqPolyRepField})::Nothing return a end @@ -419,8 +383,8 @@ function frobenius_matrix(F::fqPolyRepField, n::Int=1) a = frobenius(gen(F), n) k = Native.GF(Int(characteristic(F))) m = zero_matrix(k, degree(F), degree(F)) - ccall((:fq_nmod_embed_composition_matrix_sub, libflint), Nothing, (Ref{fpMatrix}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}, Int), m, a, F, degree(F)) - ccall((:nmod_mat_transpose, libflint), Nothing, (Ref{fpMatrix}, Ref{fpMatrix}), m, m) + @ccall libflint.fq_nmod_embed_composition_matrix_sub(m::Ref{fpMatrix}, a::Ref{fqPolyRepFieldElem}, F::Ref{fqPolyRepField}, degree(F)::Int)::Nothing + @ccall libflint.nmod_mat_transpose(m::Ref{fpMatrix}, m::Ref{fpMatrix})::Nothing return m end @@ -432,9 +396,7 @@ end function lift(R::fpPolyRing, x::fqPolyRepFieldElem) c = R() - ccall((:fq_nmod_get_nmod_poly, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - c, x, parent(x)) + @ccall libflint.fq_nmod_get_nmod_poly(c::Ref{fpPolyRingElem}, x::Ref{fqPolyRepFieldElem}, parent(x)::Ref{fqPolyRepField})::Nothing return c end @@ -445,64 +407,47 @@ end ############################################################################### function zero!(z::fqPolyRepFieldElem) - ccall((:fq_nmod_zero, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), z, z.parent) + @ccall libflint.fq_nmod_zero(z::Ref{fqPolyRepFieldElem}, z.parent::Ref{fqPolyRepField})::Nothing return z end function one!(z::fqPolyRepFieldElem) - ccall((:fq_nmod_one, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), z, z.parent) + @ccall libflint.fq_nmod_one(z::Ref{fqPolyRepFieldElem}, z.parent::Ref{fqPolyRepField})::Nothing return z end function neg!(z::fqPolyRepFieldElem, a::fqPolyRepFieldElem) - ccall((:fq_nmod_neg, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), z, a, a.parent) + @ccall libflint.fq_nmod_neg(z::Ref{fqPolyRepFieldElem}, a::Ref{fqPolyRepFieldElem}, a.parent::Ref{fqPolyRepField})::Nothing return z end function set!(z::fqPolyRepFieldElem, x::fqPolyRepFieldElemOrPtr) - ccall((:fq_nmod_set, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, x, parent(z)) + @ccall libflint.fq_nmod_set(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, parent(z)::Ref{fqPolyRepField})::Nothing end function set!(z::fqPolyRepFieldElem, x::ZZRingElemOrPtr) - ccall((:fq_nmod_set_fmpz, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{ZZRingElem}, Ref{fqPolyRepField}), - z, x, parent(z)) + @ccall libflint.fq_nmod_set_fmpz(z::Ref{fqPolyRepFieldElem}, x::Ref{ZZRingElem}, parent(z)::Ref{fqPolyRepField})::Nothing end function set!(z::fqPolyRepFieldElem, x::Int) - ccall((:fq_nmod_set_si, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Int, Ref{fqPolyRepField}), - z, x, parent(z)) + @ccall libflint.fq_nmod_set_si(z::Ref{fqPolyRepFieldElem}, x::Int, parent(z)::Ref{fqPolyRepField})::Nothing end function set!(z::fqPolyRepFieldElem, x::UInt) - ccall((:fq_nmod_set_ui, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, UInt, Ref{fqPolyRepField}), - z, x, parent(z)) + @ccall libflint.fq_nmod_set_ui(z::Ref{fqPolyRepFieldElem}, x::UInt, parent(z)::Ref{fqPolyRepField})::Nothing end function set!(z::fqPolyRepFieldElem, x::fpPolyRingElemOrPtr) - ccall((:fq_nmod_set_nmod_poly, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fpPolyRingElem}, Ref{fqPolyRepField}), - z, x, parent(z)) + @ccall libflint.fq_nmod_set_nmod_poly(z::Ref{fqPolyRepFieldElem}, x::Ref{fpPolyRingElem}, parent(z)::Ref{fqPolyRepField})::Nothing end function mul!(z::fqPolyRepFieldElem, x::fqPolyRepFieldElem, y::fqPolyRepFieldElem) - ccall((:fq_nmod_mul, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, x, y, y.parent) + @ccall libflint.fq_nmod_mul(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, y::Ref{fqPolyRepFieldElem}, y.parent::Ref{fqPolyRepField})::Nothing return z end function add!(z::fqPolyRepFieldElem, x::fqPolyRepFieldElem, y::fqPolyRepFieldElem) - ccall((:fq_nmod_add, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, x, y, x.parent) + @ccall libflint.fq_nmod_add(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepFieldElem}, y::Ref{fqPolyRepFieldElem}, x.parent::Ref{fqPolyRepField})::Nothing return z end @@ -578,11 +523,9 @@ function Base.iterate(F::Union{fqPolyRepField,FqPolyRepField}, coeffs::Vector) elt = F() for d = 1:deg if F isa fqPolyRepField - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Int, UInt), elt, d - 1, coeffs[d]) + @ccall libflint.nmod_poly_set_coeff_ui(elt::Ref{fqPolyRepFieldElem}, (d - 1)::Int, coeffs[d]::UInt)::Nothing else - ccall((:fmpz_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Int, Ref{ZZRingElem}), elt, d - 1, coeffs[d]) + @ccall libflint.fmpz_poly_set_coeff_fmpz(elt::Ref{FqPolyRepFieldElem}, (d - 1)::Int, coeffs[d]::Ref{ZZRingElem})::Nothing end end elt, coeffs @@ -605,11 +548,8 @@ function modulus(k::fqPolyRepField, var::VarName=:T) p::Int = characteristic(k) Q = polynomial(Native.GF(p), [], var) GC.@preserve k begin - P = ccall((:fq_nmod_ctx_modulus, libflint), Ptr{fpPolyRingElem}, - (Ref{fqPolyRepField},), k) - ccall((:nmod_poly_set, libflint), Nothing, - (Ref{fpPolyRingElem}, Ptr{fpPolyRingElem}), - Q, P) + P = @ccall libflint.fq_nmod_ctx_modulus(k::Ref{fqPolyRepField})::Ptr{fpPolyRingElem} + @ccall libflint.nmod_poly_set(Q::Ref{fpPolyRingElem}, P::Ptr{fpPolyRingElem})::Nothing end return Q end @@ -623,11 +563,8 @@ end function defining_polynomial(R::fpPolyRing, k::fqPolyRepField) Q = R() GC.@preserve k begin - P = ccall((:fq_nmod_ctx_modulus, libflint), Ptr{fpPolyRingElem}, - (Ref{fqPolyRepField},), k) - ccall((:nmod_poly_set, libflint), Nothing, - (Ref{fpPolyRingElem}, Ptr{fpPolyRingElem}), - Q, P) + P = @ccall libflint.fq_nmod_ctx_modulus(k::Ref{fqPolyRepField})::Ptr{fpPolyRingElem} + @ccall libflint.nmod_poly_set(Q::Ref{fpPolyRingElem}, P::Ptr{fpPolyRingElem})::Nothing end return Q end @@ -773,7 +710,7 @@ function representation_matrix(a::fqPolyRepFieldElem) F = parent(a) k = Native.GF(Int(characteristic(F))) m = zero_matrix(k, degree(F), degree(F)) - ccall((:fq_nmod_embed_mul_matrix, libflint), Nothing, (Ref{fpMatrix}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), m, a, F) - ccall((:nmod_mat_transpose, libflint), Nothing, (Ref{fpMatrix}, Ref{fpMatrix}), m, m) + @ccall libflint.fq_nmod_embed_mul_matrix(m::Ref{fpMatrix}, a::Ref{fqPolyRepFieldElem}, F::Ref{fqPolyRepField})::Nothing + @ccall libflint.nmod_mat_transpose(m::Ref{fpMatrix}, m::Ref{fpMatrix})::Nothing return m end diff --git a/src/flint/fq_nmod_embed.jl b/src/flint/fq_nmod_embed.jl index 7b0002d60..574308291 100644 --- a/src/flint/fq_nmod_embed.jl +++ b/src/flint/fq_nmod_embed.jl @@ -12,8 +12,7 @@ function linear_factor(x::fqPolyRepPolyRingElem) y = parent(x)() - ccall((:fq_nmod_poly_factor_split_single, libflint), Nothing, (Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), y, x, base_ring(x)) + @ccall libflint.fq_nmod_poly_factor_split_single(y::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, base_ring(x)::Ref{fqPolyRepField})::Nothing return y end @@ -55,9 +54,7 @@ function embed_matrices(k::fqPolyRepField, K::fqPolyRepField) s1 = zero_matrix(R, n, m) s2 = zero_matrix(R, m, n) - ccall((:fq_nmod_embed_matrices, libflint), Nothing, (Ref{fpMatrix}, - Ref{fpMatrix}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}, Ref{fqPolyRepFieldElem}, - Ref{fqPolyRepField}, Ref{fpPolyRingElem}), s1, s2, a, k, b, K, P) + @ccall libflint.fq_nmod_embed_matrices(s1::Ref{fpMatrix}, s2::Ref{fpMatrix}, a::Ref{fqPolyRepFieldElem}, k::Ref{fqPolyRepField}, b::Ref{fqPolyRepFieldElem}, K::Ref{fqPolyRepField}, P::Ref{fpPolyRingElem})::Nothing return s1, s2 end @@ -69,15 +66,12 @@ function embed_matrices_pre(a::fqPolyRepFieldElem, b::fqPolyRepFieldElem, P::fpP s1 = zero_matrix(R, n, m) s2 = zero_matrix(R, m, n) - ccall((:fq_nmod_embed_matrices, libflint), Nothing, (Ref{fpMatrix}, - Ref{fpMatrix}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}, Ref{fqPolyRepFieldElem}, - Ref{fqPolyRepField}, Ref{fpPolyRingElem}), s1, s2, a, k, b, K, P) + @ccall libflint.fq_nmod_embed_matrices(s1::Ref{fpMatrix}, s2::Ref{fpMatrix}, a::Ref{fqPolyRepFieldElem}, k::Ref{fqPolyRepField}, b::Ref{fqPolyRepFieldElem}, K::Ref{fqPolyRepField}, P::Ref{fpPolyRingElem})::Nothing return s1, s2 end function setcoeff!(x::fqPolyRepFieldElem, j::Int, c::Int) - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Int, UInt), x, j, c) + @ccall libflint.nmod_poly_set_coeff_ui(x::Ref{fqPolyRepFieldElem}, j::Int, c::UInt)::Nothing end function embed_pre_mat(x::fqPolyRepFieldElem, K::fqPolyRepField, M::fpMatrix) diff --git a/src/flint/fq_nmod_mat.jl b/src/flint/fq_nmod_mat.jl index 8f838b64a..1832448c0 100644 --- a/src/flint/fq_nmod_mat.jl +++ b/src/flint/fq_nmod_mat.jl @@ -31,8 +31,7 @@ function getindex!(v::fqPolyRepFieldElem, a::fqPolyRepMatrix, i::Int, j::Int) @boundscheck _checkbounds(a, i, j) GC.@preserve a begin z = mat_entry_ptr(a, i, j) - ccall((:fq_nmod_set, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ptr{fqPolyRepFieldElem}), v, z) + @ccall libflint.fq_nmod_set(v::Ref{fqPolyRepFieldElem}, z::Ptr{fqPolyRepFieldElem})::Nothing end return v end @@ -42,7 +41,7 @@ end GC.@preserve a begin el = mat_entry_ptr(a, i, j) z = base_ring(a)() - ccall((:fq_nmod_set, libflint), Nothing, (Ref{fqPolyRepFieldElem}, Ptr{fqPolyRepFieldElem}), z, el) + @ccall libflint.fq_nmod_set(z::Ref{fqPolyRepFieldElem}, el::Ptr{fqPolyRepFieldElem})::Nothing end return z end @@ -58,8 +57,7 @@ end @boundscheck _checkbounds(a, i, j) GC.@preserve a begin el = mat_entry_ptr(a, i, j) - ccall((:fq_nmod_set_fmpz, libflint), Nothing, - (Ptr{fqPolyRepFieldElem}, Ref{ZZRingElem}, Ref{fqPolyRepField}), el, u, base_ring(a)) + @ccall libflint.fq_nmod_set_fmpz(el::Ptr{fqPolyRepFieldElem}, u::Ref{ZZRingElem}, base_ring(a)::Ref{fqPolyRepField})::Nothing end end @@ -69,14 +67,12 @@ function setindex!(a::fqPolyRepMatrix, b::fqPolyRepMatrix, r::UnitRange{Int64}, _checkbounds(a, r, c) size(b) == (length(r), length(c)) || throw(DimensionMismatch("tried to assign a $(size(b, 1))x$(size(b, 2)) matrix to a $(length(r))x$(length(c)) destination")) A = view(a, r, c) - ccall((:fq_nmod_mat_set, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), A, b, base_ring(A)) + @ccall libflint.fq_nmod_mat_set(A::Ref{fqPolyRepMatrix}, b::Ref{fqPolyRepMatrix}, base_ring(A)::Ref{fqPolyRepField})::Nothing end function deepcopy_internal(a::fqPolyRepMatrix, dict::IdDict) z = fqPolyRepMatrix(nrows(a), ncols(a), base_ring(a)) - ccall((:fq_nmod_mat_set, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), z, a, base_ring(a)) + @ccall libflint.fq_nmod_mat_set(z::Ref{fqPolyRepMatrix}, a::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Nothing return z end @@ -92,8 +88,7 @@ function one(a::fqPolyRepMatrixSpace) end function iszero(a::fqPolyRepMatrix) - r = ccall((:fq_nmod_mat_is_zero, libflint), Cint, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), a, base_ring(a)) + r = @ccall libflint.fq_nmod_mat_is_zero(a::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Cint return Bool(r) end @@ -101,8 +96,7 @@ end @boundscheck _checkbounds(A, i, j) GC.@preserve A begin x = mat_entry_ptr(A, i, j) - return ccall((:fq_nmod_is_zero, libflint), Bool, - (Ptr{fqPolyRepFieldElem}, Ref{fqPolyRepField}), x, base_ring(A)) + return @ccall libflint.fq_nmod_is_zero(x::Ptr{fqPolyRepFieldElem}, base_ring(A)::Ref{fqPolyRepField})::Bool end end @@ -116,8 +110,7 @@ function ==(a::fqPolyRepMatrix, b::fqPolyRepMatrix) if !(a.base_ring == b.base_ring) return false end - r = ccall((:fq_nmod_mat_equal, libflint), Cint, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), a, b, base_ring(a)) + r = @ccall libflint.fq_nmod_mat_equal(a::Ref{fqPolyRepMatrix}, b::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Cint return Bool(r) end @@ -146,9 +139,7 @@ end ############################################################################### function swap_rows!(x::fqPolyRepMatrix, i::Int, j::Int) - ccall((:fq_nmod_mat_swap_rows, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ptr{Nothing}, Int, Int, Ref{fqPolyRepField}), - x, C_NULL, i - 1, j - 1, base_ring(x)) + @ccall libflint.fq_nmod_mat_swap_rows(x::Ref{fqPolyRepMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int, base_ring(x)::Ref{fqPolyRepField})::Nothing return x end @@ -159,9 +150,7 @@ function swap_rows(x::fqPolyRepMatrix, i::Int, j::Int) end function swap_cols!(x::fqPolyRepMatrix, i::Int, j::Int) - ccall((:fq_nmod_mat_swap_cols, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ptr{Nothing}, Int, Int, Ref{fqPolyRepField}), - x, C_NULL, i - 1, j - 1, base_ring(x)) + @ccall libflint.fq_nmod_mat_swap_cols(x::Ref{fqPolyRepMatrix}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int, base_ring(x)::Ref{fqPolyRepField})::Nothing return x end @@ -172,16 +161,14 @@ function swap_cols(x::fqPolyRepMatrix, i::Int, j::Int) end function reverse_rows!(x::fqPolyRepMatrix) - ccall((:fq_nmod_mat_invert_rows, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ptr{Nothing}, Ref{fqPolyRepField}), x, C_NULL, base_ring(x)) + @ccall libflint.fq_nmod_mat_invert_rows(x::Ref{fqPolyRepMatrix}, C_NULL::Ptr{Nothing}, base_ring(x)::Ref{fqPolyRepField})::Nothing return x end reverse_rows(x::fqPolyRepMatrix) = reverse_rows!(deepcopy(x)) function reverse_cols!(x::fqPolyRepMatrix) - ccall((:fq_nmod_mat_invert_cols, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ptr{Nothing}, Ref{fqPolyRepField}), x, C_NULL, base_ring(x)) + @ccall libflint.fq_nmod_mat_invert_cols(x::Ref{fqPolyRepMatrix}, C_NULL::Ptr{Nothing}, base_ring(x)::Ref{fqPolyRepField})::Nothing return x end @@ -231,57 +218,42 @@ end ################################################################################ function zero!(a::fqPolyRepMatrix) - ccall((:fq_nmod_mat_zero, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), a, base_ring(a)) + @ccall libflint.fq_nmod_mat_zero(a::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Nothing return a end function one!(a::fqPolyRepMatrix) - ccall((:fq_nmod_mat_one, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), a, base_ring(a)) + @ccall libflint.fq_nmod_mat_one(a::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Nothing return a end function neg!(z::fqPolyRepMatrix, a::fqPolyRepMatrix) - ccall((:fq_nmod_mat_neg, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), z, a, base_ring(a)) + @ccall libflint.fq_nmod_mat_neg(z::Ref{fqPolyRepMatrix}, a::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Nothing return z end function mul!(a::fqPolyRepMatrix, b::fqPolyRepMatrix, c::fqPolyRepMatrix) - ccall((:fq_nmod_mat_mul, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), - a, b, c, base_ring(a)) + @ccall libflint.fq_nmod_mat_mul(a::Ref{fqPolyRepMatrix}, b::Ref{fqPolyRepMatrix}, c::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Nothing return a end function add!(a::fqPolyRepMatrix, b::fqPolyRepMatrix, c::fqPolyRepMatrix) - ccall((:fq_nmod_mat_add, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), - a, b, c, base_ring(a)) + @ccall libflint.fq_nmod_mat_add(a::Ref{fqPolyRepMatrix}, b::Ref{fqPolyRepMatrix}, c::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Nothing return a end function sub!(a::fqPolyRepMatrix, b::fqPolyRepMatrix, c::fqPolyRepMatrix) - ccall((:fq_nmod_mat_sub, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), - a, b, c, base_ring(a)) + @ccall libflint.fq_nmod_mat_sub(a::Ref{fqPolyRepMatrix}, b::Ref{fqPolyRepMatrix}, c::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Nothing return a end function mul!(z::Vector{fqPolyRepFieldElem}, a::fqPolyRepMatrix, b::Vector{fqPolyRepFieldElem}) - ccall((:fq_nmod_mat_mul_vec_ptr, libflint), Nothing, - (Ptr{Ref{fqPolyRepFieldElem}}, Ref{fqPolyRepMatrix}, Ptr{Ref{fqPolyRepFieldElem}}, Int, - Ref{fqPolyRepField}), - z, a, b, length(b), base_ring(a)) + @ccall libflint.fq_nmod_mat_mul_vec_ptr(z::Ptr{Ref{fqPolyRepFieldElem}}, a::Ref{fqPolyRepMatrix}, b::Ptr{Ref{fqPolyRepFieldElem}}, length(b)::Int, base_ring(a)::Ref{fqPolyRepField})::Nothing return z end function mul!(z::Vector{fqPolyRepFieldElem}, a::Vector{fqPolyRepFieldElem}, b::fqPolyRepMatrix) - ccall((:fq_nmod_mat_vec_mul_ptr, libflint), Nothing, - (Ptr{Ref{fqPolyRepFieldElem}}, Ptr{Ref{fqPolyRepFieldElem}}, Int, Ref{fqPolyRepMatrix}, - Ref{fqPolyRepField}), - z, a, length(a), b, base_ring(b)) + @ccall libflint.fq_nmod_mat_vec_mul_ptr(z::Ptr{Ref{fqPolyRepFieldElem}}, a::Ptr{Ref{fqPolyRepFieldElem}}, length(a)::Int, b::Ref{fqPolyRepMatrix}, base_ring(b)::Ref{fqPolyRepField})::Nothing return z end @@ -291,15 +263,9 @@ function Generic.add_one!(a::fqPolyRepMatrix, i::Int, j::Int) GC.@preserve a begin x = mat_entry_ptr(a, i, j) # There is no fq_nmod_add_one, but only ...sub_one - ccall((:fq_nmod_neg, libflint), Nothing, - (Ptr{fqPolyRepFieldElem}, Ptr{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - x, x, F) - ccall((:fq_nmod_sub_one, libflint), Nothing, - (Ptr{fqPolyRepFieldElem}, Ptr{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - x, x, F) - ccall((:fq_nmod_neg, libflint), Nothing, - (Ptr{fqPolyRepFieldElem}, Ptr{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - x, x, F) + @ccall libflint.fq_nmod_neg(x::Ptr{fqPolyRepFieldElem}, x::Ptr{fqPolyRepFieldElem}, F::Ref{fqPolyRepField})::Nothing + @ccall libflint.fq_nmod_sub_one(x::Ptr{fqPolyRepFieldElem}, x::Ptr{fqPolyRepFieldElem}, F::Ref{fqPolyRepField})::Nothing + @ccall libflint.fq_nmod_neg(x::Ptr{fqPolyRepFieldElem}, x::Ptr{fqPolyRepFieldElem}, F::Ref{fqPolyRepField})::Nothing end return a end @@ -350,16 +316,12 @@ end function rref(a::fqPolyRepMatrix) z = similar(a) - r = ccall((:fq_nmod_mat_rref, libflint), Int, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), - z, a, base_ring(a)) + r = @ccall libflint.fq_nmod_mat_rref(z::Ref{fqPolyRepMatrix}, a::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Int return r, z end function rref!(a::fqPolyRepMatrix) - r = ccall((:fq_nmod_mat_rref, libflint), Int, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), - a, a, base_ring(a)) + r = @ccall libflint.fq_nmod_mat_rref(a::Ref{fqPolyRepMatrix}, a::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Int return r end @@ -412,8 +374,7 @@ end function inv(a::fqPolyRepMatrix) !is_square(a) && error("Matrix must be a square matrix") z = similar(a) - r = ccall((:fq_nmod_mat_inv, libflint), Int, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), z, a, base_ring(a)) + r = @ccall libflint.fq_nmod_mat_inv(z::Ref{fqPolyRepMatrix}, a::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Int !Bool(r) && error("Matrix not invertible") return z end @@ -434,9 +395,7 @@ function Solve._can_solve_internal_no_check(::Solve.LUTrait, A::fqPolyRepMatrix, end x = similar(A, ncols(A), ncols(b)) - fl = ccall((:fq_nmod_mat_can_solve, libflint), Cint, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, - Ref{fqPolyRepField}), x, A, b, base_ring(A)) + fl = @ccall libflint.fq_nmod_mat_can_solve(x::Ref{fqPolyRepMatrix}, A::Ref{fqPolyRepMatrix}, b::Ref{fqPolyRepMatrix}, base_ring(A)::Ref{fqPolyRepField})::Cint if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end @@ -446,18 +405,12 @@ end # Direct interface to the C functions to be able to write 'generic' code for # different matrix types function _solve_tril_right_flint!(x::fqPolyRepMatrix, L::fqPolyRepMatrix, B::fqPolyRepMatrix, unit::Bool) - ccall((:fq_nmod_mat_solve_tril, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, - Cint, Ref{fqPolyRepField}), - x, L, B, Cint(unit), base_ring(L)) + @ccall libflint.fq_nmod_mat_solve_tril(x::Ref{fqPolyRepMatrix}, L::Ref{fqPolyRepMatrix}, B::Ref{fqPolyRepMatrix}, Cint(unit)::Cint, base_ring(L)::Ref{fqPolyRepField})::Nothing return nothing end function _solve_triu_right_flint!(x::fqPolyRepMatrix, U::fqPolyRepMatrix, B::fqPolyRepMatrix, unit::Bool) - ccall((:fq_nmod_mat_solve_triu, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, - Cint, Ref{fqPolyRepField}), - x, U, B, Cint(unit), base_ring(U)) + @ccall libflint.fq_nmod_mat_solve_triu(x::Ref{fqPolyRepMatrix}, U::Ref{fqPolyRepMatrix}, B::Ref{fqPolyRepMatrix}, Cint(unit)::Cint, base_ring(U)::Ref{fqPolyRepField})::Nothing return nothing end @@ -470,9 +423,7 @@ end function lu!(P::Perm, x::fqPolyRepMatrix) P.d .-= 1 - rank = Int(ccall((:fq_nmod_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{fqPolyRepMatrix}, Cint, Ref{fqPolyRepField}), - P.d, x, 0, base_ring(x))) + rank = Int(@ccall libflint.fq_nmod_mat_lu(P.d::Ptr{Int}, x::Ref{fqPolyRepMatrix}, 0::Cint, base_ring(x)::Ref{fqPolyRepField})::Cint) P.d .+= 1 @@ -535,9 +486,7 @@ function Base.view(x::fqPolyRepMatrix, r1::Int, c1::Int, r2::Int, c2::Int) z = fqPolyRepMatrix() z.base_ring = x.base_ring z.view_parent = x - ccall((:fq_nmod_mat_window_init, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Int, Int, Int, Int, Ref{fqPolyRepField}), - z, x, r1 - 1, c1 - 1, r2, c2, base_ring(x)) + @ccall libflint.fq_nmod_mat_window_init(z::Ref{fqPolyRepMatrix}, x::Ref{fqPolyRepMatrix}, (r1 - 1)::Int, (c1 - 1)::Int, r2::Int, c2::Int, base_ring(x)::Ref{fqPolyRepField})::Nothing finalizer(_fq_nmod_mat_window_clear_fn, z) return z end @@ -547,8 +496,7 @@ function Base.view(x::fqPolyRepMatrix, r::AbstractUnitRange{Int}, c::AbstractUni end function _fq_nmod_mat_window_clear_fn(a::fqPolyRepMatrix) - ccall((:fq_nmod_mat_window_clear, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), a, base_ring(a)) + @ccall libflint.fq_nmod_mat_window_clear(a::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Nothing end function sub(x::fqPolyRepMatrix, r1::Int, c1::Int, r2::Int, c2::Int) @@ -571,9 +519,7 @@ function hcat(x::fqPolyRepMatrix, y::fqPolyRepMatrix) (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") (x.r != y.r) && error("Matrices must have same number of rows") z = similar(x, nrows(x), ncols(x) + ncols(y)) - ccall((:fq_nmod_mat_concat_horizontal, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), - z, x, y, base_ring(x)) + @ccall libflint.fq_nmod_mat_concat_horizontal(z::Ref{fqPolyRepMatrix}, x::Ref{fqPolyRepMatrix}, y::Ref{fqPolyRepMatrix}, base_ring(x)::Ref{fqPolyRepField})::Nothing return z end @@ -581,9 +527,7 @@ function vcat(x::fqPolyRepMatrix, y::fqPolyRepMatrix) (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") (x.c != y.c) && error("Matrices must have same number of columns") z = similar(x, nrows(x) + nrows(y), ncols(x)) - ccall((:fq_nmod_mat_concat_vertical, libflint), Nothing, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), - z, x, y, base_ring(x)) + @ccall libflint.fq_nmod_mat_concat_vertical(z::Ref{fqPolyRepMatrix}, x::Ref{fqPolyRepMatrix}, y::Ref{fqPolyRepMatrix}, base_ring(x)::Ref{fqPolyRepField})::Nothing return z end @@ -597,8 +541,7 @@ function charpoly(R::fqPolyRepPolyRing, a::fqPolyRepMatrix) !is_square(a) && error("Matrix must be square") base_ring(R) != base_ring(a) && error("Must have common base ring") p = R() - ccall((:fq_nmod_mat_charpoly, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), p, a, base_ring(a)) + @ccall libflint.fq_nmod_mat_charpoly(p::Ref{fqPolyRepPolyRingElem}, a::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Nothing return p end @@ -606,8 +549,7 @@ function charpoly_danivlesky!(R::fqPolyRepPolyRing, a::fqPolyRepMatrix) !is_square(a) && error("Matrix must be square") base_ring(R) != base_ring(a) && error("Must have common base ring") p = R() - ccall((:fq_nmod_mat_charpoly_danilevsky, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), p, a, base_ring(a)) + @ccall libflint.fq_nmod_mat_charpoly_danilevsky(p::Ref{fqPolyRepPolyRingElem}, a::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Nothing return p end @@ -623,8 +565,7 @@ function minpoly(R::fqPolyRepPolyRing, a::fqPolyRepMatrix) base_ring(R) != base_ring(a) && error("Must have common base ring") m = deepcopy(a) p = R() - ccall((:fq_nmod_mat_minpoly, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), p, m, base_ring(a)) + @ccall libflint.fq_nmod_mat_minpoly(p::Ref{fqPolyRepPolyRingElem}, m::Ref{fqPolyRepMatrix}, base_ring(a)::Ref{fqPolyRepField})::Nothing return p end @@ -723,8 +664,7 @@ end function nullspace(M::fqPolyRepMatrix) N = similar(M, ncols(M), ncols(M)) - nullity = ccall((:fq_nmod_mat_nullspace, libflint), Int, - (Ref{fqPolyRepMatrix}, Ref{fqPolyRepMatrix}, Ref{fqPolyRepField}), N, M, base_ring(M)) + nullity = @ccall libflint.fq_nmod_mat_nullspace(N::Ref{fqPolyRepMatrix}, M::Ref{fqPolyRepMatrix}, base_ring(M)::Ref{fqPolyRepField})::Int return nullity, view(N, 1:nrows(N), 1:nullity) end diff --git a/src/flint/fq_nmod_mpoly.jl b/src/flint/fq_nmod_mpoly.jl index 182c548a3..937b4609f 100644 --- a/src/flint/fq_nmod_mpoly.jl +++ b/src/flint/fq_nmod_mpoly.jl @@ -26,7 +26,7 @@ base_ring(a::fqPolyRepMPolyRing) = a.base_ring function internal_ordering(a::fqPolyRepMPolyRing) b = a.ord - # b = ccall((:fq_nmod_mpoly_ctx_ord, libflint), Cint, (Ref{fqPolyRepMPolyRing}, ), a) + # b = @ccall libflint.fq_nmod_mpoly_ctx_ord(a::Ref{fqPolyRepMPolyRing})::Cint return flint_orderings[b + 1] end @@ -34,9 +34,7 @@ function gens(R::fqPolyRepMPolyRing) A = Vector{fqPolyRepMPolyRingElem}(undef, R.nvars) for i = 1:R.nvars z = R() - ccall((:fq_nmod_mpoly_gen, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - z, i - 1, R) + @ccall libflint.fq_nmod_mpoly_gen(z::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, R::Ref{fqPolyRepMPolyRing})::Nothing A[i] = z end return A @@ -46,38 +44,28 @@ function gen(R::fqPolyRepMPolyRing, i::Int) n = nvars(R) !(1 <= i <= n) && error("Index must be between 1 and $n") z = R() - ccall((:fq_nmod_mpoly_gen, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - z, i - 1, R) + @ccall libflint.fq_nmod_mpoly_gen(z::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, R::Ref{fqPolyRepMPolyRing})::Nothing return z end function is_gen(a::fqPolyRepMPolyRingElem, i::Int) n = nvars(parent(a)) !(1 <= i <= n) && error("Index must be between 1 and $n") - return Bool(ccall((:fq_nmod_mpoly_is_gen, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - a, i - 1, a.parent)) + return Bool(@ccall libflint.fq_nmod_mpoly_is_gen(a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, a.parent::Ref{fqPolyRepMPolyRing})::Cint) end function is_gen(a::fqPolyRepMPolyRingElem) - return Bool(ccall((:fq_nmod_mpoly_is_gen, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - a, -1, a.parent)) + return Bool(@ccall libflint.fq_nmod_mpoly_is_gen(a::Ref{fqPolyRepMPolyRingElem}, (-1)::Int, a.parent::Ref{fqPolyRepMPolyRing})::Cint) end function deepcopy_internal(a::fqPolyRepMPolyRingElem, dict::IdDict) z = parent(a)() - ccall((:fq_nmod_mpoly_set, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - z, a, a.parent) + @ccall libflint.fq_nmod_mpoly_set(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return z end function length(a::fqPolyRepMPolyRingElem) - n = ccall((:fq_nmod_mpoly_length, libflint), Int, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, a.parent) + n = @ccall libflint.fq_nmod_mpoly_length(a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Int return n end @@ -86,16 +74,12 @@ one(R::fqPolyRepMPolyRing) = one!(R()) zero(R::fqPolyRepMPolyRing) = zero!(R()) function isone(a::fqPolyRepMPolyRingElem) - b = ccall((:fq_nmod_mpoly_is_one, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, a.parent) + b = @ccall libflint.fq_nmod_mpoly_is_one(a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Cint return Bool(b) end function iszero(a::fqPolyRepMPolyRingElem) - b = ccall((:fq_nmod_mpoly_is_zero, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, a.parent) + b = @ccall libflint.fq_nmod_mpoly_is_zero(a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Cint return Bool(b) end @@ -112,9 +96,7 @@ function is_unit(a::fqPolyRepMPolyRingElem) end function is_constant(a::fqPolyRepMPolyRingElem) - b = ccall((:fq_nmod_mpoly_is_fq_nmod, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, parent(a)) + b = @ccall libflint.fq_nmod_mpoly_is_fq_nmod(a::Ref{fqPolyRepMPolyRingElem}, parent(a)::Ref{fqPolyRepMPolyRing})::Cint return Bool(b) end @@ -133,9 +115,7 @@ function coeff(a::fqPolyRepMPolyRingElem, i::Int) n = length(a) !(1 <= i <= n) && error("Index must be between 1 and $(length(a))") z = base_ring(parent(a))() - ccall((:fq_nmod_mpoly_get_term_coeff_fq_nmod, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - z, a, i - 1, a.parent) + @ccall libflint.fq_nmod_mpoly_get_term_coeff_fq_nmod(z::Ref{fqPolyRepFieldElem}, a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return z end @@ -143,10 +123,7 @@ function coeff(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem) check_parent(a, b) !isone(length(b)) && error("Second argument must be a monomial") z = base_ring(parent(a))() - ccall((:fq_nmod_mpoly_get_coeff_fq_nmod_monomial, libflint), UInt, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepMPolyRingElem}, - Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - z, a, b, parent(a)) + @ccall libflint.fq_nmod_mpoly_get_coeff_fq_nmod_monomial(z::Ref{fqPolyRepFieldElem}, a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, parent(a)::Ref{fqPolyRepMPolyRing})::UInt return z end @@ -169,9 +146,7 @@ function degree(a::fqPolyRepMPolyRingElem, i::Int) n = nvars(parent(a)) !(1 <= i <= n) && error("Index must be between 1 and $n") if degrees_fit_int(a) - d = ccall((:fq_nmod_mpoly_degree_si, libflint), Int, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - a, i - 1, a.parent) + d = @ccall libflint.fq_nmod_mpoly_degree_si(a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, a.parent::Ref{fqPolyRepMPolyRing})::Int return d else return Int(degree_fmpz(a, i)) @@ -183,17 +158,13 @@ function degree_fmpz(a::fqPolyRepMPolyRingElem, i::Int) n = nvars(parent(a)) !(1 <= i <= n) && error("Index must be between 1 and $n") d = ZZRingElem() - ccall((:fq_nmod_mpoly_degree_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - d, a, i - 1, a.parent) + @ccall libflint.fq_nmod_mpoly_degree_fmpz(d::Ref{ZZRingElem}, a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return d end # Return true if degrees fit into an Int function degrees_fit_int(a::fqPolyRepMPolyRingElem) - b = ccall((:fq_nmod_mpoly_degrees_fit_si, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, a.parent) + b = @ccall libflint.fq_nmod_mpoly_degrees_fit_si(a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Cint return Bool(b) end @@ -203,9 +174,7 @@ function degrees(a::fqPolyRepMPolyRingElem) throw(OverflowError("degrees of polynomial do not fit into Int")) end degs = Vector{Int}(undef, nvars(parent(a))) - ccall((:fq_nmod_mpoly_degrees_si, libflint), Nothing, - (Ptr{Int}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - degs, a, a.parent) + @ccall libflint.fq_nmod_mpoly_degrees_si(degs::Ptr{Int}, a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return degs end @@ -216,17 +185,13 @@ function degrees_fmpz(a::fqPolyRepMPolyRingElem) for i in 1:n degs[i] = ZZRingElem() end - ccall((:fq_nmod_mpoly_degrees_fmpz, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - degs, a, a.parent) + @ccall libflint.fq_nmod_mpoly_degrees_fmpz(degs::Ptr{Ref{ZZRingElem}}, a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return degs end # Return true if degree fits into an Int function total_degree_fits_int(a::fqPolyRepMPolyRingElem) - b = ccall((:fq_nmod_mpoly_total_degree_fits_si, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, a.parent) + b = @ccall libflint.fq_nmod_mpoly_total_degree_fits_si(a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Cint return Bool(b) end @@ -235,18 +200,14 @@ function total_degree(a::fqPolyRepMPolyRingElem) if !total_degree_fits_int(a) throw(OverflowError("Total degree of polynomial does not fit into Int")) end - d = ccall((:fq_nmod_mpoly_total_degree_si, libflint), Int, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, a.parent) + d = @ccall libflint.fq_nmod_mpoly_total_degree_si(a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Int return d end # Total degree as an ZZRingElem function total_degree_fmpz(a::fqPolyRepMPolyRingElem) d = ZZRingElem() - ccall((:fq_nmod_mpoly_total_degree_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - d, a, a.parent) + @ccall libflint.fq_nmod_mpoly_total_degree_fmpz(d::Ref{ZZRingElem}, a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return d end @@ -270,10 +231,7 @@ function coeff(a::fqPolyRepMPolyRingElem, vars::Vector{Int}, exps::Vector{Int}) end end z = parent(a)() - ccall((:fq_nmod_mpoly_get_coeff_vars_ui, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Ptr{Int}, - Ptr{Int}, Int, Ref{fqPolyRepMPolyRing}), - z, a, vars, exps, length(vars), a.parent) + @ccall libflint.fq_nmod_mpoly_get_coeff_vars_ui(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, vars::Ptr{Int}, exps::Ptr{Int}, length(vars)::Int, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return z end @@ -288,30 +246,21 @@ end function +(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem) check_parent(a, b) z = parent(a)() - ccall((:fq_nmod_mpoly_add, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, - Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - z, a, b, a.parent) + @ccall libflint.fq_nmod_mpoly_add(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return z end function -(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem) check_parent(a, b) z = parent(a)() - ccall((:fq_nmod_mpoly_sub, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, - Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - z, a, b, a.parent) + @ccall libflint.fq_nmod_mpoly_sub(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return z end function *(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem) check_parent(a, b) z = parent(a)() - ccall((:fq_nmod_mpoly_mul, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, - Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - z, a, b, a.parent) + @ccall libflint.fq_nmod_mpoly_mul(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return z end @@ -344,9 +293,7 @@ divexact(a::fqPolyRepMPolyRingElem, b::Integer; check::Bool=true) = divexact(a, function ^(a::fqPolyRepMPolyRingElem, b::Int) b < 0 && throw(DomainError(b, "Exponent must be non-negative")) z = parent(a)() - r = ccall((:fq_nmod_mpoly_pow_ui, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, UInt, Ref{fqPolyRepMPolyRing}), - z, a, UInt(b), parent(a)) + r = @ccall libflint.fq_nmod_mpoly_pow_ui(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, UInt(b)::UInt, parent(a)::Ref{fqPolyRepMPolyRing})::Cint iszero(r) && error("Unable to compute power") return z end @@ -354,10 +301,7 @@ end function ^(a::fqPolyRepMPolyRingElem, b::ZZRingElem) b < 0 && throw(DomainError(b, "Exponent must be non-negative")) z = parent(a)() - r = ccall((:fq_nmod_mpoly_pow_fmpz, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, - Ref{ZZRingElem}, Ref{fqPolyRepMPolyRing}), - z, a, b, parent(a)) + r = @ccall libflint.fq_nmod_mpoly_pow_fmpz(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, b::Ref{ZZRingElem}, parent(a)::Ref{fqPolyRepMPolyRing})::Cint iszero(r) && error("Unable to compute power") return z end @@ -371,10 +315,7 @@ end function gcd(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem) check_parent(a, b) z = parent(a)() - r = ccall((:fq_nmod_mpoly_gcd, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, - Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - z, a, b, a.parent) + r = @ccall libflint.fq_nmod_mpoly_gcd(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Cint r == 0 && error("Unable to compute gcd") return z end @@ -384,10 +325,7 @@ function gcd_with_cofactors(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem z = parent(a)() abar = parent(a)() bbar = parent(a)() - r = ccall((:fq_nmod_mpoly_gcd_cofactors, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, - Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - z, abar, bbar, a, b, a.parent) + r = @ccall libflint.fq_nmod_mpoly_gcd_cofactors(z::Ref{fqPolyRepMPolyRingElem}, abar::Ref{fqPolyRepMPolyRingElem}, bbar::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Cint r == 0 && error("Unable to compute gcd") return z, abar, bbar end @@ -404,22 +342,14 @@ function (::Type{Fac{fqPolyRepMPolyRingElem}})(fac::fq_nmod_mpoly_factor, preser for i in 0:fac.num-1 f = R() if preserve_input - ccall((:fq_nmod_mpoly_factor_get_base, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fq_nmod_mpoly_factor}, Int, Ref{fqPolyRepMPolyRing}), - f, fac, i, R) + @ccall libflint.fq_nmod_mpoly_factor_get_base(f::Ref{fqPolyRepMPolyRingElem}, fac::Ref{fq_nmod_mpoly_factor}, i::Int, R::Ref{fqPolyRepMPolyRing})::Nothing else - ccall((:fq_nmod_mpoly_factor_swap_base, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fq_nmod_mpoly_factor}, Int, Ref{fqPolyRepMPolyRing}), - f, fac, i, R) + @ccall libflint.fq_nmod_mpoly_factor_swap_base(f::Ref{fqPolyRepMPolyRingElem}, fac::Ref{fq_nmod_mpoly_factor}, i::Int, R::Ref{fqPolyRepMPolyRing})::Nothing end - F.fac[f] = ccall((:fq_nmod_mpoly_factor_get_exp_si, libflint), Int, - (Ref{fq_nmod_mpoly_factor}, Int, Ref{fqPolyRepMPolyRing}), - fac, i, R) + F.fac[f] = @ccall libflint.fq_nmod_mpoly_factor_get_exp_si(fac::Ref{fq_nmod_mpoly_factor}, i::Int, R::Ref{fqPolyRepMPolyRing})::Int end c = base_ring(R)() - ccall((:fq_nmod_mpoly_factor_get_constant_fq_nmod, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fq_nmod_mpoly_factor}), - c, fac) + @ccall libflint.fq_nmod_mpoly_factor_get_constant_fq_nmod(c::Ref{fqPolyRepFieldElem}, fac::Ref{fq_nmod_mpoly_factor})::Nothing F.unit = R(c) return F end @@ -428,9 +358,7 @@ function factor(a::fqPolyRepMPolyRingElem) iszero(a) && throw(ArgumentError("Argument must be non-zero")) R = parent(a) fac = fq_nmod_mpoly_factor(R) - ok = ccall((:fq_nmod_mpoly_factor, libflint), Cint, - (Ref{fq_nmod_mpoly_factor}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - fac, a, R) + ok = @ccall libflint.fq_nmod_mpoly_factor(fac::Ref{fq_nmod_mpoly_factor}, a::Ref{fqPolyRepMPolyRingElem}, R::Ref{fqPolyRepMPolyRing})::Cint ok == 0 && error("unable to compute factorization") return Fac{fqPolyRepMPolyRingElem}(fac, false) end @@ -439,9 +367,7 @@ function factor_squarefree(a::fqPolyRepMPolyRingElem) iszero(a) && throw(ArgumentError("Argument must be non-zero")) R = parent(a) fac = fq_nmod_mpoly_factor(R) - ok = ccall((:fq_nmod_mpoly_factor_squarefree, libflint), Cint, - (Ref{fq_nmod_mpoly_factor}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - fac, a, R) + ok = @ccall libflint.fq_nmod_mpoly_factor_squarefree(fac::Ref{fq_nmod_mpoly_factor}, a::Ref{fqPolyRepMPolyRingElem}, R::Ref{fqPolyRepMPolyRing})::Cint ok == 0 && error("unable to compute factorization") return Fac{fqPolyRepMPolyRingElem}(fac, false) end @@ -454,16 +380,12 @@ function sqrt(a::fqPolyRepMPolyRingElem; check::Bool=true) end function is_square(a::fqPolyRepMPolyRingElem) - return Bool(ccall((:fq_nmod_mpoly_is_square, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, a.parent)) + return Bool(@ccall libflint.fq_nmod_mpoly_is_square(a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Cint) end function is_square_with_sqrt(a::fqPolyRepMPolyRingElem) q = parent(a)() - flag = ccall((:fq_nmod_mpoly_sqrt, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - q, a, a.parent) + flag = @ccall libflint.fq_nmod_mpoly_sqrt(q::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Cint return (Bool(flag), q) end @@ -475,16 +397,12 @@ end function ==(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem) check_parent(a, b) - return ccall((:fq_nmod_mpoly_equal, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, b, a.parent) != 0 + return @ccall libflint.fq_nmod_mpoly_equal(a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Cint != 0 end function Base.isless(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem) (!is_monomial(a) || !is_monomial(b)) && error("Not monomials in comparison") - return ccall((:fq_nmod_mpoly_cmp, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, b, a.parent) < 0 + return @ccall libflint.fq_nmod_mpoly_cmp(a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Cint < 0 end ############################################################################### @@ -494,9 +412,7 @@ end ############################################################################### function ==(a::fqPolyRepMPolyRingElem, b::fqPolyRepFieldElem) - return Bool(ccall((:fq_nmod_mpoly_equal_fq_nmod, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepMPolyRing}), - a, b, a.parent)) + return Bool(@ccall libflint.fq_nmod_mpoly_equal_fq_nmod(a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepFieldElem}, a.parent::Ref{fqPolyRepMPolyRing})::Cint) end ==(a::fqPolyRepFieldElem, b::fqPolyRepMPolyRingElem) = b == a @@ -524,10 +440,7 @@ function divides(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem) return false, zero(parent(a)) end z = parent(a)() - d = ccall((:fq_nmod_mpoly_divides, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, - Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - z, a, b, a.parent) + d = @ccall libflint.fq_nmod_mpoly_divides(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Cint return isone(d), z end @@ -540,10 +453,7 @@ end function Base.div(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem) check_parent(a, b) q = parent(a)() - ccall((:fq_nmod_mpoly_div, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, - Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - q, a, b, a.parent) + @ccall libflint.fq_nmod_mpoly_div(q::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return q end @@ -551,10 +461,7 @@ function Base.divrem(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem) check_parent(a, b) q = parent(a)() r = parent(a)() - ccall((:fq_nmod_mpoly_divrem, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, - Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - q, r, a, b, a.parent) + @ccall libflint.fq_nmod_mpoly_divrem(q::Ref{fqPolyRepMPolyRingElem}, r::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return q, r end @@ -568,10 +475,7 @@ function Base.divrem(a::fqPolyRepMPolyRingElem, b::Vector{fqPolyRepMPolyRingElem end q = [parent(a)() for i in 1:len] r = parent(a)() - ccall((:fq_nmod_mpoly_divrem_ideal, libflint), Nothing, - (Ptr{Ref{fqPolyRepMPolyRingElem}}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, - Ptr{Ref{fqPolyRepMPolyRingElem}}, Int, Ref{fqPolyRepMPolyRing}), - q, r, a, b, len, a.parent) + @ccall libflint.fq_nmod_mpoly_divrem_ideal(q::Ptr{Ref{fqPolyRepMPolyRingElem}}, r::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, b::Ptr{Ref{fqPolyRepMPolyRingElem}}, len::Int, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return q, r end @@ -598,9 +502,7 @@ function derivative(a::fqPolyRepMPolyRingElem, i::Int) n = nvars(parent(a)) !(1 <= i <= n) && error("Index must be between 1 and $n") z = parent(a)() - ccall((:fq_nmod_mpoly_derivative, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fq_nmod_mpoly_derivative(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{fqPolyRepMPolyRing})::Nothing return z end @@ -613,9 +515,7 @@ end function evaluate(a::fqPolyRepMPolyRingElem, b::Vector{fqPolyRepFieldElem}) length(b) != nvars(parent(a)) && error("Vector size incorrect in evaluate") z = base_ring(parent(a))() - ccall((:fq_nmod_mpoly_evaluate_all_fq_nmod, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepMPolyRingElem}, Ptr{Ref{fqPolyRepFieldElem}}, Ref{fqPolyRepMPolyRing}), - z, a, b, parent(a)) + @ccall libflint.fq_nmod_mpoly_evaluate_all_fq_nmod(z::Ref{fqPolyRepFieldElem}, a::Ref{fqPolyRepMPolyRingElem}, b::Ptr{Ref{fqPolyRepFieldElem}}, parent(a)::Ref{fqPolyRepMPolyRing})::Nothing return z end @@ -710,10 +610,7 @@ function evaluate(a::fqPolyRepMPolyRingElem, bs::Vector{fqPolyRepMPolyRingElem}) error("Number of variables does not match number of values") c = S() - fl = ccall((:fq_nmod_mpoly_compose_fq_nmod_mpoly, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Ptr{Ref{fqPolyRepMPolyRingElem}}, - Ref{fqPolyRepMPolyRing}, Ref{fqPolyRepMPolyRing}), - c, a, bs, R, S) + fl = @ccall libflint.fq_nmod_mpoly_compose_fq_nmod_mpoly(c::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, bs::Ptr{Ref{fqPolyRepMPolyRingElem}}, R::Ref{fqPolyRepMPolyRing}, S::Ref{fqPolyRepMPolyRing})::Cint fl == 0 && error("Something wrong in evaluation.") return c end @@ -727,9 +624,7 @@ function evaluate(a::fqPolyRepMPolyRingElem, bs::Vector{fqPolyRepPolyRingElem}) error("Number of variables does not match number of values") c = S() - fl = ccall((:fq_nmod_mpoly_compose_fq_nmod_poly, libflint), Cint, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Ptr{Ref{fqPolyRepPolyRingElem}}, - Ref{fqPolyRepMPolyRing}), c, a, bs, R) + fl = @ccall libflint.fq_nmod_mpoly_compose_fq_nmod_poly(c::Ref{fqPolyRepPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, bs::Ptr{Ref{fqPolyRepPolyRingElem}}, R::Ref{fqPolyRepMPolyRing})::Cint fl == 0 && error("Something wrong in evaluation.") return c end @@ -741,39 +636,27 @@ end ############################################################################### function zero!(a::fqPolyRepMPolyRingElem) - ccall((:fq_nmod_mpoly_zero, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, a.parent) + @ccall libflint.fq_nmod_mpoly_zero(a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return a end function one!(a::fqPolyRepMPolyRingElem) - ccall((:fq_nmod_mpoly_one, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, a.parent) + @ccall libflint.fq_nmod_mpoly_one(a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return a end function neg!(z::fqPolyRepMPolyRingElem, a::fqPolyRepMPolyRingElem) - ccall((:fq_nmod_mpoly_neg, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - z, a, a.parent) + @ccall libflint.fq_nmod_mpoly_neg(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return z end function add!(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem, c::fqPolyRepMPolyRingElem) - ccall((:fq_nmod_mpoly_add, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, - Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, b, c, a.parent) + @ccall libflint.fq_nmod_mpoly_add(a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, c::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return a end function mul!(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem, c::fqPolyRepMPolyRingElem) - ccall((:fq_nmod_mpoly_mul, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, - Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, b, c, a.parent) + @ccall libflint.fq_nmod_mpoly_mul(a::Ref{fqPolyRepMPolyRingElem}, b::Ref{fqPolyRepMPolyRingElem}, c::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return a end @@ -781,12 +664,9 @@ end # must be removed with combine_like_terms! function setcoeff!(a::fqPolyRepMPolyRingElem, n::Int, c::fqPolyRepFieldElem) if n > length(a) - ccall((:fq_nmod_mpoly_resize, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), a, n, a.parent) + @ccall libflint.fq_nmod_mpoly_resize(a::Ref{fqPolyRepMPolyRingElem}, n::Int, a.parent::Ref{fqPolyRepMPolyRing})::Nothing end - ccall((:fq_nmod_mpoly_set_term_coeff_fq_nmod, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepMPolyRing}), - a, n - 1, c, a.parent) + @ccall libflint.fq_nmod_mpoly_set_term_coeff_fq_nmod(a::Ref{fqPolyRepMPolyRingElem}, (n - 1)::Int, c::Ref{fqPolyRepFieldElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return a end @@ -801,9 +681,7 @@ setcoeff!(a::fqPolyRepMPolyRingElem, i::Int, c::ZZRingElem) = setcoeff!(a, i, ba # Remove zero terms and combine adjacent terms if they have the same monomial # no sorting is performed function combine_like_terms!(a::fqPolyRepMPolyRingElem) - ccall((:fq_nmod_mpoly_combine_like_terms, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), - a, a.parent) + @ccall libflint.fq_nmod_mpoly_combine_like_terms(a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return a end @@ -814,37 +692,27 @@ end ############################################################################### function exponent_vector_fits(::Type{Int}, a::fqPolyRepMPolyRingElem, i::Int) - b = ccall((:fq_nmod_mpoly_term_exp_fits_si, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - a, i - 1, a.parent) + b = @ccall libflint.fq_nmod_mpoly_term_exp_fits_si(a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, a.parent::Ref{fqPolyRepMPolyRing})::Cint return Bool(b) end function exponent_vector_fits(::Type{UInt}, a::fqPolyRepMPolyRingElem, i::Int) - b = ccall((:fq_nmod_mpoly_term_exp_fits_ui, libflint), Cint, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - a, i - 1, a.parent) + b = @ccall libflint.fq_nmod_mpoly_term_exp_fits_ui(a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, a.parent::Ref{fqPolyRepMPolyRing})::Cint return Bool(b) end function exponent_vector!(z::Vector{Int}, a::fqPolyRepMPolyRingElem, i::Int) - ccall((:fq_nmod_mpoly_get_term_exp_si, libflint), Nothing, - (Ptr{Int}, Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fq_nmod_mpoly_get_term_exp_si(z::Ptr{Int}, a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{fqPolyRepMPolyRing})::Nothing return z end function exponent_vector!(z::Vector{UInt}, a::fqPolyRepMPolyRingElem, i::Int) - ccall((:fq_nmod_mpoly_get_term_exp_ui, libflint), Nothing, - (Ptr{UInt}, Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fq_nmod_mpoly_get_term_exp_ui(z::Ptr{UInt}, a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{fqPolyRepMPolyRing})::Nothing return z end function exponent_vector!(z::Vector{ZZRingElem}, a::fqPolyRepMPolyRingElem, i::Int) - ccall((:fq_nmod_mpoly_get_term_exp_fmpz, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - z, a, i - 1, parent(a)) + @ccall libflint.fq_nmod_mpoly_get_term_exp_fmpz(z::Ptr{Ref{ZZRingElem}}, a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, parent(a)::Ref{fqPolyRepMPolyRing})::Nothing return z end @@ -857,12 +725,9 @@ end # No sort is performed, so this is unsafe. function set_exponent_vector!(a::fqPolyRepMPolyRingElem, n::Int, exps::Vector{UInt}) if n > length(a) - ccall((:fq_nmod_mpoly_resize, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), a, n, a.parent) + @ccall libflint.fq_nmod_mpoly_resize(a::Ref{fqPolyRepMPolyRingElem}, n::Int, a.parent::Ref{fqPolyRepMPolyRing})::Nothing end - ccall((:fq_nmod_mpoly_set_term_exp_ui, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ptr{UInt}, Ref{fqPolyRepMPolyRing}), - a, n - 1, exps, parent(a)) + @ccall libflint.fq_nmod_mpoly_set_term_exp_ui(a::Ref{fqPolyRepMPolyRingElem}, (n - 1)::Int, exps::Ptr{UInt}, parent(a)::Ref{fqPolyRepMPolyRing})::Nothing return a end @@ -871,12 +736,9 @@ end # no check is performed function set_exponent_vector!(a::fqPolyRepMPolyRingElem, n::Int, exps::Vector{Int}) if n > length(a) - ccall((:fq_nmod_mpoly_resize, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), a, n, a.parent) + @ccall libflint.fq_nmod_mpoly_resize(a::Ref{fqPolyRepMPolyRingElem}, n::Int, a.parent::Ref{fqPolyRepMPolyRing})::Nothing end - ccall((:fq_nmod_mpoly_set_term_exp_ui, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ptr{Int}, Ref{fqPolyRepMPolyRing}), - a, n - 1, exps, parent(a)) + @ccall libflint.fq_nmod_mpoly_set_term_exp_ui(a::Ref{fqPolyRepMPolyRingElem}, (n - 1)::Int, exps::Ptr{Int}, parent(a)::Ref{fqPolyRepMPolyRing})::Nothing return a end @@ -884,30 +746,23 @@ end # No sort is performed, so this is unsafe function set_exponent_vector!(a::fqPolyRepMPolyRingElem, n::Int, exps::Vector{ZZRingElem}) if n > length(a) - ccall((:fq_nmod_mpoly_resize, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), a, n, a.parent) + @ccall libflint.fq_nmod_mpoly_resize(a::Ref{fqPolyRepMPolyRingElem}, n::Int, a.parent::Ref{fqPolyRepMPolyRing})::Nothing end - ccall((:fq_nmod_mpoly_set_term_exp_fmpz, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Int, Ptr{ZZRingElem}, Ref{fqPolyRepMPolyRing}), - a, n - 1, exps, parent(a)) + @ccall libflint.fq_nmod_mpoly_set_term_exp_fmpz(a::Ref{fqPolyRepMPolyRingElem}, (n - 1)::Int, exps::Ptr{ZZRingElem}, parent(a)::Ref{fqPolyRepMPolyRing})::Nothing return a end # Return j-th coordinate of i-th exponent vector function exponent(a::fqPolyRepMPolyRingElem, i::Int, j::Int) (j < 1 || j > nvars(parent(a))) && error("Invalid variable index") - return ccall((:fq_nmod_mpoly_get_term_var_exp_ui, libflint), Int, - (Ref{fqPolyRepMPolyRingElem}, Int, Int, Ref{fqPolyRepMPolyRing}), - a, i - 1, j - 1, a.parent) + return @ccall libflint.fq_nmod_mpoly_get_term_var_exp_ui(a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, (j - 1)::Int, a.parent::Ref{fqPolyRepMPolyRing})::Int end # Return the coefficient of the term with the given exponent vector # Return zero if there is no such term function coeff(a::fqPolyRepMPolyRingElem, exps::Vector{UInt}) z = base_ring(parent(a))() - ccall((:fq_nmod_mpoly_get_coeff_fq_nmod_ui, libflint), UInt, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepMPolyRingElem}, Ptr{UInt}, Ref{fqPolyRepMPolyRing}), - z, a, exps, parent(a)) + @ccall libflint.fq_nmod_mpoly_get_coeff_fq_nmod_ui(z::Ref{fqPolyRepFieldElem}, a::Ref{fqPolyRepMPolyRingElem}, exps::Ptr{UInt}, parent(a)::Ref{fqPolyRepMPolyRing})::UInt return z end @@ -915,18 +770,14 @@ end # Return zero if there is no such term function coeff(a::fqPolyRepMPolyRingElem, exps::Vector{Int}) z = base_ring(parent(a))() - ccall((:fq_nmod_mpoly_get_coeff_fq_nmod_ui, libflint), UInt, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepMPolyRingElem}, Ptr{Int}, Ref{fqPolyRepMPolyRing}), - z, a, exps, parent(a)) + @ccall libflint.fq_nmod_mpoly_get_coeff_fq_nmod_ui(z::Ref{fqPolyRepFieldElem}, a::Ref{fqPolyRepMPolyRingElem}, exps::Ptr{Int}, parent(a)::Ref{fqPolyRepMPolyRing})::UInt return z end # Set the coefficient of the term with the given exponent vector to the # given ZZRingElem. Removal of a zero term is performed. function setcoeff!(a::fqPolyRepMPolyRingElem, exps::Vector{Int}, b::fqPolyRepFieldElem) - ccall((:fq_nmod_mpoly_set_coeff_fq_nmod_ui, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, UInt, Ptr{Int}, Ref{fqPolyRepMPolyRing}), - a, b, exps, parent(a)) + @ccall libflint.fq_nmod_mpoly_set_coeff_fq_nmod_ui(a::Ref{fqPolyRepMPolyRingElem}, b::UInt, exps::Ptr{Int}, parent(a)::Ref{fqPolyRepMPolyRing})::Nothing return a end @@ -940,34 +791,27 @@ setcoeff!(a, exps, base_ring(parent(a))(b)) # out of order. Note that like terms are not combined and zeros are not # removed. For that, call combine_like_terms! function sort_terms!(a::fqPolyRepMPolyRingElem) - ccall((:fq_nmod_mpoly_sort_terms, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRing}), a, a.parent) + @ccall libflint.fq_nmod_mpoly_sort_terms(a::Ref{fqPolyRepMPolyRingElem}, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return a end # Return the i-th term of the polynomial, as a polynomial function term(a::fqPolyRepMPolyRingElem, i::Int) z = parent(a)() - ccall((:fq_nmod_mpoly_get_term, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - z, a, i - 1, a.parent) + @ccall libflint.fq_nmod_mpoly_get_term(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return z end # Return the i-th monomial of the polynomial, as a polynomial function monomial(a::fqPolyRepMPolyRingElem, i::Int) z = parent(a)() - ccall((:fq_nmod_mpoly_get_term_monomial, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - z, a, i - 1, a.parent) + @ccall libflint.fq_nmod_mpoly_get_term_monomial(z::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return z end # Sets the given polynomial m to the i-th monomial of the polynomial function monomial!(m::fqPolyRepMPolyRingElem, a::fqPolyRepMPolyRingElem, i::Int) - ccall((:fq_nmod_mpoly_get_term_monomial, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepMPolyRingElem}, Int, Ref{fqPolyRepMPolyRing}), - m, a, i - 1, a.parent) + @ccall libflint.fq_nmod_mpoly_get_term_monomial(m::Ref{fqPolyRepMPolyRingElem}, a::Ref{fqPolyRepMPolyRingElem}, (i - 1)::Int, a.parent::Ref{fqPolyRepMPolyRing})::Nothing return m end @@ -990,9 +834,7 @@ promote_rule(::Type{fqPolyRepMPolyRingElem}, ::Type{fqPolyRepFieldElem}) = fqPol ############################################################################### function _push_term!(z::fqPolyRepMPolyRingElem, c::fqPolyRepFieldElem, exp::Vector{Int}) - ccall((:fq_nmod_mpoly_push_term_fq_nmod_ui, libflint), Nothing, - (Ref{fqPolyRepMPolyRingElem}, Ref{fqPolyRepFieldElem}, Ptr{UInt}, Ref{fqPolyRepMPolyRing}), - z, c, exp, parent(z)) + @ccall libflint.fq_nmod_mpoly_push_term_fq_nmod_ui(z::Ref{fqPolyRepMPolyRingElem}, c::Ref{fqPolyRepFieldElem}, exp::Ptr{UInt}, parent(z)::Ref{fqPolyRepMPolyRing})::Nothing return z end diff --git a/src/flint/fq_nmod_poly.jl b/src/flint/fq_nmod_poly.jl index 811ffa91a..4c765f870 100644 --- a/src/flint/fq_nmod_poly.jl +++ b/src/flint/fq_nmod_poly.jl @@ -28,12 +28,10 @@ var(a::fqPolyRepPolyRing) = a.S # ################################################################################ -length(x::fqPolyRepPolyRingElem) = ccall((:fq_nmod_poly_length, libflint), Int, - (Ref{fqPolyRepPolyRingElem},), x) +length(x::fqPolyRepPolyRingElem) = @ccall libflint.fq_nmod_poly_length(x::Ref{fqPolyRepPolyRingElem})::Int function set_length!(x::fqPolyRepPolyRingElem, n::Int) - ccall((:_fq_nmod_poly_set_length, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Int), x, n) + @ccall libflint._fq_nmod_poly_set_length(x::Ref{fqPolyRepPolyRingElem}, n::Int)::Nothing return x end @@ -41,9 +39,7 @@ function coeff(x::fqPolyRepPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) F = (x.parent).base_ring temp = F(1) - ccall((:fq_nmod_poly_get_coeff, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepField}), - temp, x, n, F) + @ccall libflint.fq_nmod_poly_get_coeff(temp::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepPolyRingElem}, n::Int, F::Ref{fqPolyRepField})::Nothing return temp end @@ -53,17 +49,11 @@ one(a::fqPolyRepPolyRing) = a(one(base_ring(a))) gen(a::fqPolyRepPolyRing) = a([zero(base_ring(a)), one(base_ring(a))]) -iszero(x::fqPolyRepPolyRingElem) = ccall((:fq_nmod_poly_is_zero, libflint), Bool, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - x, base_ring(x.parent)) +iszero(x::fqPolyRepPolyRingElem) = @ccall libflint.fq_nmod_poly_is_zero(x::Ref{fqPolyRepPolyRingElem}, base_ring(x.parent)::Ref{fqPolyRepField})::Bool -isone(x::fqPolyRepPolyRingElem) = ccall((:fq_nmod_poly_is_one, libflint), Bool, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - x, base_ring(x.parent)) +isone(x::fqPolyRepPolyRingElem) = @ccall libflint.fq_nmod_poly_is_one(x::Ref{fqPolyRepPolyRingElem}, base_ring(x.parent)::Ref{fqPolyRepField})::Bool -is_gen(x::fqPolyRepPolyRingElem) = ccall((:fq_nmod_poly_is_gen, libflint), Bool, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - x, base_ring(x.parent)) +is_gen(x::fqPolyRepPolyRingElem) = @ccall libflint.fq_nmod_poly_is_gen(x::Ref{fqPolyRepPolyRingElem}, base_ring(x.parent)::Ref{fqPolyRepField})::Bool degree(f::fqPolyRepPolyRingElem) = f.length - 1 @@ -128,30 +118,21 @@ canonical_unit(a::fqPolyRepPolyRingElem) = canonical_unit(leading_coefficient(a) function +(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_nmod_poly_add, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_add(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end function -(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_nmod_poly_sub, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_sub(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end function *(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_nmod_poly_mul, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_mul(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -165,10 +146,7 @@ function *(x::fqPolyRepFieldElem, y::fqPolyRepPolyRingElem) parent(x) != base_ring(parent(y)) && error("Coefficient rings must be equal") z = parent(y)() - ccall((:fq_nmod_poly_scalar_mul_fq_nmod, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, y, x, parent(x)) + @ccall libflint.fq_nmod_poly_scalar_mul_fq_nmod(z::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepFieldElem}, parent(x)::Ref{fqPolyRepField})::Nothing return z end @@ -215,9 +193,7 @@ end function ^(x::fqPolyRepPolyRingElem, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() - ccall((:fq_nmod_poly_pow, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_pow(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Int, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -229,9 +205,7 @@ end function ==(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) check_parent(x,y) - r = ccall((:fq_nmod_poly_equal, libflint), Cint, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - x, y, base_ring(parent(x))) + r = @ccall libflint.fq_nmod_poly_equal(x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Cint return Bool(r) end @@ -246,9 +220,7 @@ function ==(x::fqPolyRepPolyRingElem, y::fqPolyRepFieldElem) if length(x) > 1 return false elseif length(x) == 1 - r = ccall((:fq_nmod_poly_equal_fq_nmod, libflint), Cint, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - x, y, base_ring(parent(x))) + r = @ccall libflint.fq_nmod_poly_equal_fq_nmod(x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepFieldElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Cint return Bool(r) else return iszero(y) @@ -277,9 +249,7 @@ function truncate(x::fqPolyRepPolyRingElem, n::Int) return x end z = parent(x)() - ccall((:fq_nmod_poly_set_trunc, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepField}), - z, x, n, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_set_trunc(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, n::Int, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -287,10 +257,7 @@ function mullow(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem, n::Int) check_parent(x,y) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() - ccall((:fq_nmod_poly_mullow, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Int, Ref{fqPolyRepField}), - z, x, y, n, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_mullow(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, n::Int, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -303,9 +270,7 @@ end function reverse(x::fqPolyRepPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Index must be non-negative")) z = parent(x)() - ccall((:fq_nmod_poly_reverse, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepField}), - z, x, len, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_reverse(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, len::Int, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -318,18 +283,14 @@ end function shift_left(x::fqPolyRepPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:fq_nmod_poly_shift_left, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepField}), - z, x, len, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_shift_left(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, len::Int, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end function shift_right(x::fqPolyRepPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:fq_nmod_poly_shift_right, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepField}), - z, x, len, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_shift_right(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, len::Int, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -342,9 +303,7 @@ end function Base.div(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_nmod_poly_div_basecase, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_div_basecase(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -356,9 +315,7 @@ function rem(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) end function rem!(z::fqPolyRepPolyRingElem, x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) - ccall((:fq_nmod_poly_rem, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_rem(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -368,9 +325,7 @@ function Base.divrem(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() r = parent(x)() - ccall((:fq_nmod_poly_divrem, libflint), Nothing, (Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepField}), z, r, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_divrem(z::Ref{fqPolyRepPolyRingElem}, r::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z,r end @@ -383,9 +338,7 @@ end function sqrt(x::fqPolyRepPolyRingElem; check::Bool=true) R = parent(x) s = R() - flag = Bool(ccall((:fq_nmod_poly_sqrt, libflint), Cint, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - s, x, base_ring(parent(x)))) + flag = Bool(@ccall libflint.fq_nmod_poly_sqrt(s::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Cint) check && !flag && error("Not a square in sqrt") return s end @@ -399,9 +352,7 @@ function is_square(x::fqPolyRepPolyRingElem) end R = parent(x) s = R() - flag = Bool(ccall((:fq_nmod_poly_sqrt, libflint), Cint, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - s, x, base_ring(parent(x)))) + flag = Bool(@ccall libflint.fq_nmod_poly_sqrt(s::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Cint) return flag end @@ -414,9 +365,7 @@ function is_square_with_sqrt(x::fqPolyRepPolyRingElem) return false, zero(R) end s = R() - flag = Bool(ccall((:fq_nmod_poly_sqrt, libflint), Cint, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - s, x, base_ring(parent(x)))) + flag = Bool(@ccall libflint.fq_nmod_poly_sqrt(s::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Cint) return flag, s end @@ -430,9 +379,7 @@ function remove(z::fqPolyRepPolyRingElem, p::fqPolyRepPolyRingElem) ok, v = _remove_check_simple_cases(z, p) ok && return v, zero(parent(z)) z = deepcopy(z) - v = ccall((:fq_nmod_poly_remove, libflint), Int, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - z, p, base_ring(parent(z))) + v = @ccall libflint.fq_nmod_poly_remove(z::Ref{fqPolyRepPolyRingElem}, p::Ref{fqPolyRepPolyRingElem}, base_ring(parent(z))::Ref{fqPolyRepField})::Int return v, z end @@ -445,10 +392,7 @@ function divides(z::fqPolyRepPolyRingElem, x::fqPolyRepPolyRingElem) return false, zero(parent(z)) end q = parent(z)() - v = Bool(ccall((:fq_nmod_poly_divides, libflint), Cint, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - q, z, x, base_ring(parent(z)))) + v = Bool(@ccall libflint.fq_nmod_poly_divides(q::Ref{fqPolyRepPolyRingElem}, z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, base_ring(parent(z))::Ref{fqPolyRepField})::Cint) return v, q end @@ -470,9 +414,7 @@ function powermod(x::fqPolyRepPolyRingElem, n::Int, y::fqPolyRepPolyRingElem) n = -n end - ccall((:fq_nmod_poly_powmod_ui_binexp, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepField}), z, x, n, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_powmod_ui_binexp(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, n::Int, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -488,9 +430,7 @@ function powermod(x::fqPolyRepPolyRingElem, n::ZZRingElem, y::fqPolyRepPolyRingE n = -n end - ccall((:fq_nmod_poly_powmod_fmpz_binexp, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{ZZRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepField}), z, x, n, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_powmod_fmpz_binexp(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, n::Ref{ZZRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -503,9 +443,7 @@ end function gcd(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_nmod_poly_gcd, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_gcd(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -514,10 +452,7 @@ function gcdx(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) z = parent(x)() s = parent(x)() t = parent(x)() - ccall((:fq_nmod_poly_xgcd, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepField}), z, s, t, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_xgcd(z::Ref{fqPolyRepPolyRingElem}, s::Ref{fqPolyRepPolyRingElem}, t::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z, s, t end @@ -530,9 +465,7 @@ end function evaluate(x::fqPolyRepPolyRingElem, y::fqPolyRepFieldElem) base_ring(parent(x)) != parent(y) && error("Incompatible coefficient rings") z = parent(y)() - ccall((:fq_nmod_poly_evaluate_fq_nmod, libflint), Nothing, - (Ref{fqPolyRepFieldElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepFieldElem}, - Ref{fqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_evaluate_fq_nmod(z::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepFieldElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -545,9 +478,7 @@ end function AbstractAlgebra._compose_right(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_nmod_poly_compose, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_compose(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -559,9 +490,7 @@ end function derivative(x::fqPolyRepPolyRingElem) z = parent(x)() - ccall((:fq_nmod_poly_derivative, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - z, x, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_derivative(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -573,17 +502,13 @@ end function inflate(x::fqPolyRepPolyRingElem, n::Int) z = parent(x)() - ccall((:fq_nmod_poly_inflate, libflint), Nothing, (Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepPolyRingElem}, Culong, Ref{fqPolyRepField}), - z, x, UInt(n), base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_inflate(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, UInt(n)::Culong, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end function deflate(x::fqPolyRepPolyRingElem, n::Int) z = parent(x)() - ccall((:fq_nmod_poly_deflate, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Culong, Ref{fqPolyRepField}), - z, x, UInt(n), base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_deflate(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, UInt(n)::Culong, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end @@ -594,9 +519,7 @@ end ################################################################################ function is_irreducible(x::fqPolyRepPolyRingElem) - return Bool(ccall((:fq_nmod_poly_is_irreducible, libflint), Int32, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField} ), - x, base_ring(parent(x)))) + return Bool(@ccall libflint.fq_nmod_poly_is_irreducible(x::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Int32) end ################################################################################ @@ -606,8 +529,7 @@ end ################################################################################ function is_squarefree(x::fqPolyRepPolyRingElem) - return Bool(ccall((:fq_nmod_poly_is_squarefree, libflint), Int32, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), x, base_ring(parent(x)))) + return Bool(@ccall libflint.fq_nmod_poly_is_squarefree(x::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Int32) end ################################################################################ @@ -627,15 +549,11 @@ function _factor(x::fqPolyRepPolyRingElem) F = base_ring(R) a = F() fac = fq_nmod_poly_factor(F) - ccall((:fq_nmod_poly_factor, libflint), Nothing, (Ref{fq_nmod_poly_factor}, - Ref{fqPolyRepFieldElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - fac, a, x, F) + @ccall libflint.fq_nmod_poly_factor(fac::Ref{fq_nmod_poly_factor}, a::Ref{fqPolyRepFieldElem}, x::Ref{fqPolyRepPolyRingElem}, F::Ref{fqPolyRepField})::Nothing res = Dict{fqPolyRepPolyRingElem,Int}() for i in 1:fac.num f = R() - ccall((:fq_nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fq_nmod_poly_factor}, Int, - Ref{fqPolyRepField}), f, fac, i-1, F) + @ccall libflint.fq_nmod_poly_factor_get_poly(f::Ref{fqPolyRepPolyRingElem}, fac::Ref{fq_nmod_poly_factor}, (i-1)::Int, F::Ref{fqPolyRepField})::Nothing e = unsafe_load(fac.exp,i) res[f] = e end @@ -652,14 +570,11 @@ end function _factor_squarefree(x::fqPolyRepPolyRingElem) F = base_ring(parent(x)) fac = fq_nmod_poly_factor(F) - ccall((:fq_nmod_poly_factor_squarefree, libflint), UInt, - (Ref{fq_nmod_poly_factor}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), fac, x, F) + @ccall libflint.fq_nmod_poly_factor_squarefree(fac::Ref{fq_nmod_poly_factor}, x::Ref{fqPolyRepPolyRingElem}, F::Ref{fqPolyRepField})::UInt res = Dict{fqPolyRepPolyRingElem,Int}() for i in 1:fac.num f = parent(x)() - ccall((:fq_nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fq_nmod_poly_factor}, Int, - Ref{fqPolyRepField}), f, fac, i-1, F) + @ccall libflint.fq_nmod_poly_factor_get_poly(f::Ref{fqPolyRepPolyRingElem}, fac::Ref{fq_nmod_poly_factor}, (i-1)::Int, F::Ref{fqPolyRepField})::Nothing e = unsafe_load(fac.exp, i) res[f] = e end @@ -676,15 +591,11 @@ function factor_distinct_deg(x::fqPolyRepPolyRingElem) F = base_ring(R) fac = fq_nmod_poly_factor(F) degrees = Vector{Int}(undef, degree(x)) - ccall((:fq_nmod_poly_factor_distinct_deg, libflint), Nothing, - (Ref{fq_nmod_poly_factor}, Ref{fqPolyRepPolyRingElem}, Ref{Vector{Int}}, - Ref{fqPolyRepField}), fac, x, degrees, F) + @ccall libflint.fq_nmod_poly_factor_distinct_deg(fac::Ref{fq_nmod_poly_factor}, x::Ref{fqPolyRepPolyRingElem}, degrees::Ref{Vector{Int}}, F::Ref{fqPolyRepField})::Nothing res = Dict{Int, fqPolyRepPolyRingElem}() for i in 1:fac.num f = R() - ccall((:fq_nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fq_nmod_poly_factor}, Int, - Ref{fqPolyRepField}), f, fac, i-1, F) + @ccall libflint.fq_nmod_poly_factor_get_poly(f::Ref{fqPolyRepPolyRingElem}, fac::Ref{fq_nmod_poly_factor}, (i-1)::Int, F::Ref{fqPolyRepField})::Nothing res[degrees[i]] = f end return res @@ -694,15 +605,11 @@ function roots(x::fqPolyRepPolyRingElem) R = parent(x) F = base_ring(R) fac = fq_nmod_poly_factor(F) - ccall((:fq_nmod_poly_roots, libflint), Nothing, - (Ref{fq_nmod_poly_factor}, Ref{fqPolyRepPolyRingElem}, Cint, - Ref{fqPolyRepField}), fac, x, 0, F) + @ccall libflint.fq_nmod_poly_roots(fac::Ref{fq_nmod_poly_factor}, x::Ref{fqPolyRepPolyRingElem}, 0::Cint, F::Ref{fqPolyRepField})::Nothing res = fqPolyRepFieldElem[] for i in 1:fac.num f = R() - ccall((:fq_nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fq_nmod_poly_factor}, Int, - Ref{fqPolyRepField}), f, fac, i-1, F) + @ccall libflint.fq_nmod_poly_factor_get_poly(f::Ref{fqPolyRepPolyRingElem}, fac::Ref{fq_nmod_poly_factor}, (i-1)::Int, F::Ref{fqPolyRepField})::Nothing @assert isone(coeff(f, 1)) push!(res, -coeff(f, 0)) end @@ -716,65 +623,47 @@ end ################################################################################ function zero!(z::fqPolyRepPolyRingElem) - ccall((:fq_nmod_poly_zero, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - z, base_ring(parent(z))) + @ccall libflint.fq_nmod_poly_zero(z::Ref{fqPolyRepPolyRingElem}, base_ring(parent(z))::Ref{fqPolyRepField})::Nothing return z end function one!(z::fqPolyRepPolyRingElem) - ccall((:fq_nmod_poly_one, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - z, base_ring(parent(z))) + @ccall libflint.fq_nmod_poly_one(z::Ref{fqPolyRepPolyRingElem}, base_ring(parent(z))::Ref{fqPolyRepField})::Nothing return z end function neg!(z::fqPolyRepPolyRingElem, a::fqPolyRepPolyRingElem) - ccall((:fq_nmod_poly_neg, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepField}), - z, a, base_ring(parent(a))) + @ccall libflint.fq_nmod_poly_neg(z::Ref{fqPolyRepPolyRingElem}, a::Ref{fqPolyRepPolyRingElem}, base_ring(parent(a))::Ref{fqPolyRepField})::Nothing return z end function fit!(z::fqPolyRepPolyRingElem, n::Int) - ccall((:fq_nmod_poly_fit_length, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepField}), - z, n, base_ring(parent(z))) + @ccall libflint.fq_nmod_poly_fit_length(z::Ref{fqPolyRepPolyRingElem}, n::Int, base_ring(parent(z))::Ref{fqPolyRepField})::Nothing return nothing end function setcoeff!(z::fqPolyRepPolyRingElem, n::Int, x::fqPolyRepFieldElem) - ccall((:fq_nmod_poly_set_coeff, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Int, Ref{fqPolyRepFieldElem}, Ref{fqPolyRepField}), - z, n, x, base_ring(parent(z))) + @ccall libflint.fq_nmod_poly_set_coeff(z::Ref{fqPolyRepPolyRingElem}, n::Int, x::Ref{fqPolyRepFieldElem}, base_ring(parent(z))::Ref{fqPolyRepField})::Nothing return z end function setcoeff!(z::fqPolyRepPolyRingElem, n::Int, x::ZZRingElem) - ccall((:fq_nmod_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Int, Ref{ZZRingElem}, Ref{fqPolyRepField}), - z, n, x, base_ring(parent(z))) + @ccall libflint.fq_nmod_poly_set_coeff_fmpz(z::Ref{fqPolyRepPolyRingElem}, n::Int, x::Ref{ZZRingElem}, base_ring(parent(z))::Ref{fqPolyRepField})::Nothing return z end function mul!(z::fqPolyRepPolyRingElem, x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) - ccall((:fq_nmod_poly_mul, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_mul(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end function add!(z::fqPolyRepPolyRingElem, x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) - ccall((:fq_nmod_poly_add, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_add(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end function sub!(z::fqPolyRepPolyRingElem, x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem) - ccall((:fq_nmod_poly_sub, libflint), Nothing, - (Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, - Ref{fqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_nmod_poly_sub(z::Ref{fqPolyRepPolyRingElem}, x::Ref{fqPolyRepPolyRingElem}, y::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Nothing return z end diff --git a/src/flint/fq_poly.jl b/src/flint/fq_poly.jl index a91b3d8f2..99cec63af 100644 --- a/src/flint/fq_poly.jl +++ b/src/flint/fq_poly.jl @@ -28,22 +28,18 @@ var(a::FqPolyRepPolyRing) = a.S # ################################################################################ -length(x::FqPolyRepPolyRingElem) = ccall((:fq_poly_length, libflint), Int, - (Ref{FqPolyRepPolyRingElem},), x) +length(x::FqPolyRepPolyRingElem) = @ccall libflint.fq_poly_length(x::Ref{FqPolyRepPolyRingElem})::Int function coeff(x::FqPolyRepPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) F = (x.parent).base_ring temp = F(1) - ccall((:fq_poly_get_coeff, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepField}), - temp, x, n, F) + @ccall libflint.fq_poly_get_coeff(temp::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepPolyRingElem}, n::Int, F::Ref{FqPolyRepField})::Nothing return temp end function set_length!(x::FqPolyRepPolyRingElem, n::Int) - ccall((:_fq_poly_set_length, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Int), x, n) + @ccall libflint._fq_poly_set_length(x::Ref{FqPolyRepPolyRingElem}, n::Int)::Nothing return x end @@ -53,17 +49,11 @@ one(a::FqPolyRepPolyRing) = a(one(base_ring(a))) gen(a::FqPolyRepPolyRing) = a([zero(base_ring(a)), one(base_ring(a))]) -is_gen(x::FqPolyRepPolyRingElem) = ccall((:fq_poly_is_gen, libflint), Bool, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - x, base_ring(x.parent)) +is_gen(x::FqPolyRepPolyRingElem) = @ccall libflint.fq_poly_is_gen(x::Ref{FqPolyRepPolyRingElem}, base_ring(x.parent)::Ref{FqPolyRepField})::Bool -iszero(x::FqPolyRepPolyRingElem) = ccall((:fq_poly_is_zero, libflint), Bool, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - x, base_ring(x.parent)) +iszero(x::FqPolyRepPolyRingElem) = @ccall libflint.fq_poly_is_zero(x::Ref{FqPolyRepPolyRingElem}, base_ring(x.parent)::Ref{FqPolyRepField})::Bool -isone(x::FqPolyRepPolyRingElem) = ccall((:fq_poly_is_one, libflint), Bool, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - x, base_ring(x.parent)) +isone(x::FqPolyRepPolyRingElem) = @ccall libflint.fq_poly_is_one(x::Ref{FqPolyRepPolyRingElem}, base_ring(x.parent)::Ref{FqPolyRepField})::Bool degree(f::FqPolyRepPolyRingElem) = f.length - 1 @@ -128,30 +118,21 @@ canonical_unit(a::FqPolyRepPolyRingElem) = canonical_unit(leading_coefficient(a) function +(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_poly_add, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_add(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end function -(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_poly_sub, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_sub(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end function *(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_poly_mul, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_mul(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -165,10 +146,7 @@ function *(x::FqPolyRepFieldElem, y::FqPolyRepPolyRingElem) parent(x) != base_ring(parent(y)) && error("Coefficient rings must be equal") z = parent(y)() - ccall((:fq_poly_scalar_mul_fq, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - z, y, x, parent(x)) + @ccall libflint.fq_poly_scalar_mul_fq(z::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepFieldElem}, parent(x)::Ref{FqPolyRepField})::Nothing return z end @@ -215,9 +193,7 @@ end function ^(x::FqPolyRepPolyRingElem, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() - ccall((:fq_poly_pow, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_pow(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Int, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -229,9 +205,7 @@ end function ==(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) check_parent(x,y) - r = ccall((:fq_poly_equal, libflint), Cint, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - x, y, base_ring(parent(x))) + r = @ccall libflint.fq_poly_equal(x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Cint return Bool(r) end @@ -246,9 +220,7 @@ function ==(x::FqPolyRepPolyRingElem, y::FqPolyRepFieldElem) if length(x) > 1 return false elseif length(x) == 1 - r = ccall((:fq_poly_equal_fq, libflint), Cint, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - x, y, base_ring(parent(x))) + r = @ccall libflint.fq_poly_equal_fq(x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepFieldElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Cint return Bool(r) else return iszero(y) @@ -277,9 +249,7 @@ function truncate(x::FqPolyRepPolyRingElem, n::Int) return x end z = parent(x)() - ccall((:fq_poly_set_trunc, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepField}), - z, x, n, base_ring(parent(x))) + @ccall libflint.fq_poly_set_trunc(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, n::Int, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -287,10 +257,7 @@ function mullow(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem, n::Int) check_parent(x,y) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() - ccall((:fq_poly_mullow, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Int, Ref{FqPolyRepField}), - z, x, y, n, base_ring(parent(x))) + @ccall libflint.fq_poly_mullow(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, n::Int, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -303,9 +270,7 @@ end function reverse(x::FqPolyRepPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Index must be non-negative")) z = parent(x)() - ccall((:fq_poly_reverse, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepField}), - z, x, len, base_ring(parent(x))) + @ccall libflint.fq_poly_reverse(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, len::Int, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -318,18 +283,14 @@ end function shift_left(x::FqPolyRepPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:fq_poly_shift_left, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepField}), - z, x, len, base_ring(parent(x))) + @ccall libflint.fq_poly_shift_left(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, len::Int, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end function shift_right(x::FqPolyRepPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:fq_poly_shift_right, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepField}), - z, x, len, base_ring(parent(x))) + @ccall libflint.fq_poly_shift_right(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, len::Int, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -342,9 +303,7 @@ end function Base.div(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_poly_div_basecase, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_div_basecase(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -356,9 +315,7 @@ function rem(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) end function rem!(z::FqPolyRepPolyRingElem, x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) - ccall((:fq_poly_rem, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - z, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_rem(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -368,9 +325,7 @@ function Base.divrem(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() r = parent(x)() - ccall((:fq_poly_divrem, libflint), Nothing, (Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepField}), z, r, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_divrem(z::Ref{FqPolyRepPolyRingElem}, r::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z, r end @@ -383,9 +338,7 @@ end function sqrt(x::FqPolyRepPolyRingElem; check::Bool=true) R = parent(x) s = R() - flag = Bool(ccall((:fq_poly_sqrt, libflint), Cint, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - s, x, base_ring(parent(x)))) + flag = Bool(@ccall libflint.fq_poly_sqrt(s::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Cint) check && !flag && error("Not a square in sqrt") return s end @@ -399,9 +352,7 @@ function is_square(x::FqPolyRepPolyRingElem) end R = parent(x) s = R() - flag = Bool(ccall((:fq_poly_sqrt, libflint), Cint, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - s, x, base_ring(parent(x)))) + flag = Bool(@ccall libflint.fq_poly_sqrt(s::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Cint) return flag end @@ -414,9 +365,7 @@ function is_square_with_sqrt(x::FqPolyRepPolyRingElem) return false, zero(R) end s = R() - flag = Bool(ccall((:fq_poly_sqrt, libflint), Cint, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - s, x, base_ring(parent(x)))) + flag = Bool(@ccall libflint.fq_poly_sqrt(s::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Cint) return flag, s end @@ -430,9 +379,7 @@ function remove(z::FqPolyRepPolyRingElem, p::FqPolyRepPolyRingElem) ok, v = _remove_check_simple_cases(z, p) ok && return v, zero(parent(z)) z = deepcopy(z) - v = ccall((:fq_poly_remove, libflint), Int, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - z, p, base_ring(parent(z))) + v = @ccall libflint.fq_poly_remove(z::Ref{FqPolyRepPolyRingElem}, p::Ref{FqPolyRepPolyRingElem}, base_ring(parent(z))::Ref{FqPolyRepField})::Int return v, z end @@ -445,10 +392,7 @@ function divides(z::FqPolyRepPolyRingElem, x::FqPolyRepPolyRingElem) end check_parent(z, x) q = parent(z)() - v = Bool(ccall((:fq_poly_divides, libflint), Cint, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - q, z, x, base_ring(parent(z)))) + v = Bool(@ccall libflint.fq_poly_divides(q::Ref{FqPolyRepPolyRingElem}, z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, base_ring(parent(z))::Ref{FqPolyRepField})::Cint) return v, q end @@ -470,9 +414,7 @@ function powermod(x::FqPolyRepPolyRingElem, n::Int, y::FqPolyRepPolyRingElem) n = -n end - ccall((:fq_poly_powmod_ui_binexp, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepField}), z, x, n, y, base_ring(parent(x))) + @ccall libflint.fq_poly_powmod_ui_binexp(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, n::Int, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -488,9 +430,7 @@ function powermod(x::FqPolyRepPolyRingElem, n::ZZRingElem, y::FqPolyRepPolyRingE n = -n end - ccall((:fq_poly_powmod_fmpz_binexp, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{ZZRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepField}), z, x, n, y, base_ring(parent(x))) + @ccall libflint.fq_poly_powmod_fmpz_binexp(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, n::Ref{ZZRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -503,9 +443,7 @@ end function gcd(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_poly_gcd, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_gcd(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -514,9 +452,7 @@ function gcdx(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) z = parent(x)() s = parent(x)() t = parent(x)() - ccall((:fq_poly_xgcd, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepField}), z, s, t, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_xgcd(z::Ref{FqPolyRepPolyRingElem}, s::Ref{FqPolyRepPolyRingElem}, t::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z, s, t end @@ -529,9 +465,7 @@ end function evaluate(x::FqPolyRepPolyRingElem, y::FqPolyRepFieldElem) base_ring(parent(x)) != parent(y) && error("Incompatible coefficient rings") z = parent(y)() - ccall((:fq_poly_evaluate_fq, libflint), Nothing, - (Ref{FqPolyRepFieldElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepFieldElem}, - Ref{FqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_evaluate_fq(z::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepFieldElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -544,9 +478,7 @@ end function AbstractAlgebra._compose_right(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:fq_poly_compose, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_compose(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -558,9 +490,7 @@ end function derivative(x::FqPolyRepPolyRingElem) z = parent(x)() - ccall((:fq_poly_derivative, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - z, x, base_ring(parent(x))) + @ccall libflint.fq_poly_derivative(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -572,17 +502,13 @@ end function inflate(x::FqPolyRepPolyRingElem, n::Int) z = parent(x)() - ccall((:fq_poly_inflate, libflint), Nothing, (Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepPolyRingElem}, Culong, Ref{FqPolyRepField}), - z, x, UInt(n), base_ring(parent(x))) + @ccall libflint.fq_poly_inflate(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, UInt(n)::Culong, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end function deflate(x::FqPolyRepPolyRingElem, n::Int) z = parent(x)() - ccall((:fq_poly_deflate, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Culong, Ref{FqPolyRepField}), - z, x, UInt(n), base_ring(parent(x))) + @ccall libflint.fq_poly_deflate(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, UInt(n)::Culong, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end @@ -593,9 +519,7 @@ end ################################################################################ function is_irreducible(x::FqPolyRepPolyRingElem) - return Bool(ccall((:fq_poly_is_irreducible, libflint), Int32, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField} ), - x, base_ring(parent(x)))) + return Bool(@ccall libflint.fq_poly_is_irreducible(x::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Int32) end ################################################################################ @@ -605,8 +529,7 @@ end ################################################################################ function is_squarefree(x::FqPolyRepPolyRingElem) - return Bool(ccall((:fq_poly_is_squarefree, libflint), Int32, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), x, base_ring(parent(x)))) + return Bool(@ccall libflint.fq_poly_is_squarefree(x::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Int32) end ################################################################################ @@ -626,15 +549,11 @@ function _factor(x::FqPolyRepPolyRingElem) F = base_ring(R) a = F() fac = fq_poly_factor(F) - ccall((:fq_poly_factor, libflint), Nothing, (Ref{fq_poly_factor}, - Ref{FqPolyRepFieldElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - fac, a, x, F) + @ccall libflint.fq_poly_factor(fac::Ref{fq_poly_factor}, a::Ref{FqPolyRepFieldElem}, x::Ref{FqPolyRepPolyRingElem}, F::Ref{FqPolyRepField})::Nothing res = Dict{FqPolyRepPolyRingElem,Int}() for i in 1:fac.num f = R() - ccall((:fq_poly_factor_get_poly, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{fq_poly_factor}, Int, - Ref{FqPolyRepField}), f, fac, i-1, F) + @ccall libflint.fq_poly_factor_get_poly(f::Ref{FqPolyRepPolyRingElem}, fac::Ref{fq_poly_factor}, (i-1)::Int, F::Ref{FqPolyRepField})::Nothing e = unsafe_load(fac.exp,i) res[f] = e end @@ -651,14 +570,11 @@ end function _factor_squarefree(x::FqPolyRepPolyRingElem) F = base_ring(parent(x)) fac = fq_poly_factor(F) - ccall((:fq_poly_factor_squarefree, libflint), UInt, - (Ref{fq_poly_factor}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), fac, x, F) + @ccall libflint.fq_poly_factor_squarefree(fac::Ref{fq_poly_factor}, x::Ref{FqPolyRepPolyRingElem}, F::Ref{FqPolyRepField})::UInt res = Dict{FqPolyRepPolyRingElem,Int}() for i in 1:fac.num f = parent(x)() - ccall((:fq_poly_factor_get_poly, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{fq_poly_factor}, Int, - Ref{FqPolyRepField}), f, fac, i-1, F) + @ccall libflint.fq_poly_factor_get_poly(f::Ref{FqPolyRepPolyRingElem}, fac::Ref{fq_poly_factor}, (i-1)::Int, F::Ref{FqPolyRepField})::Nothing e = unsafe_load(fac.exp, i) res[f] = e end @@ -675,15 +591,11 @@ function factor_distinct_deg(x::FqPolyRepPolyRingElem) F = base_ring(R) fac = fq_poly_factor(F) degrees = Vector{Int}(undef, degree(x)) - ccall((:fq_poly_factor_distinct_deg, libflint), Nothing, - (Ref{fq_poly_factor}, Ref{FqPolyRepPolyRingElem}, Ref{Vector{Int}}, - Ref{FqPolyRepField}), fac, x, degrees, F) + @ccall libflint.fq_poly_factor_distinct_deg(fac::Ref{fq_poly_factor}, x::Ref{FqPolyRepPolyRingElem}, degrees::Ref{Vector{Int}}, F::Ref{FqPolyRepField})::Nothing res = Dict{Int, FqPolyRepPolyRingElem}() for i in 1:fac.num f = R() - ccall((:fq_poly_factor_get_poly, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{fq_poly_factor}, Int, - Ref{FqPolyRepField}), f, fac, i-1, F) + @ccall libflint.fq_poly_factor_get_poly(f::Ref{FqPolyRepPolyRingElem}, fac::Ref{fq_poly_factor}, (i-1)::Int, F::Ref{FqPolyRepField})::Nothing res[degrees[i]] = f end return res @@ -693,15 +605,11 @@ function roots(x::FqPolyRepPolyRingElem) R = parent(x) F = base_ring(R) fac = fq_poly_factor(F) - ccall((:fq_poly_roots, libflint), Nothing, - (Ref{fq_poly_factor}, Ref{FqPolyRepPolyRingElem}, Cint, - Ref{FqPolyRepField}), fac, x, 0, F) + @ccall libflint.fq_poly_roots(fac::Ref{fq_poly_factor}, x::Ref{FqPolyRepPolyRingElem}, 0::Cint, F::Ref{FqPolyRepField})::Nothing res = FqPolyRepFieldElem[] for i in 1:fac.num f = R() - ccall((:fq_poly_factor_get_poly, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{fq_poly_factor}, Int, - Ref{FqPolyRepField}), f, fac, i-1, F) + @ccall libflint.fq_poly_factor_get_poly(f::Ref{FqPolyRepPolyRingElem}, fac::Ref{fq_poly_factor}, (i-1)::Int, F::Ref{FqPolyRepField})::Nothing @assert isone(coeff(f, 1)) push!(res, -coeff(f, 0)) end @@ -715,58 +623,42 @@ end ################################################################################ function zero!(z::FqPolyRepPolyRingElem) - ccall((:fq_poly_zero, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - z, base_ring(parent(z))) + @ccall libflint.fq_poly_zero(z::Ref{FqPolyRepPolyRingElem}, base_ring(parent(z))::Ref{FqPolyRepField})::Nothing return z end function one!(z::FqPolyRepPolyRingElem) - ccall((:fq_poly_one, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - z, base_ring(parent(z))) + @ccall libflint.fq_poly_one(z::Ref{FqPolyRepPolyRingElem}, base_ring(parent(z))::Ref{FqPolyRepField})::Nothing return z end function neg!(z::FqPolyRepPolyRingElem, a::FqPolyRepPolyRingElem) - ccall((:fq_poly_neg, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepField}), - z, a, base_ring(parent(a))) + @ccall libflint.fq_poly_neg(z::Ref{FqPolyRepPolyRingElem}, a::Ref{FqPolyRepPolyRingElem}, base_ring(parent(a))::Ref{FqPolyRepField})::Nothing return z end function fit!(z::FqPolyRepPolyRingElem, n::Int) - ccall((:fq_poly_fit_length, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepField}), - z, n, base_ring(parent(z))) + @ccall libflint.fq_poly_fit_length(z::Ref{FqPolyRepPolyRingElem}, n::Int, base_ring(parent(z))::Ref{FqPolyRepField})::Nothing return nothing end function setcoeff!(z::FqPolyRepPolyRingElem, n::Int, x::FqPolyRepFieldElem) - ccall((:fq_poly_set_coeff, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Int, Ref{FqPolyRepFieldElem}, Ref{FqPolyRepField}), - z, n, x, base_ring(parent(z))) + @ccall libflint.fq_poly_set_coeff(z::Ref{FqPolyRepPolyRingElem}, n::Int, x::Ref{FqPolyRepFieldElem}, base_ring(parent(z))::Ref{FqPolyRepField})::Nothing return z end function mul!(z::FqPolyRepPolyRingElem, x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) - ccall((:fq_poly_mul, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_mul(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end function add!(z::FqPolyRepPolyRingElem, x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) - ccall((:fq_poly_add, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_add(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end function sub!(z::FqPolyRepPolyRingElem, x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem) - ccall((:fq_poly_sub, libflint), Nothing, - (Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, - Ref{FqPolyRepField}), z, x, y, base_ring(parent(x))) + @ccall libflint.fq_poly_sub(z::Ref{FqPolyRepPolyRingElem}, x::Ref{FqPolyRepPolyRingElem}, y::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Nothing return z end diff --git a/src/flint/gfp_elem.jl b/src/flint/gfp_elem.jl index 7083356bd..17f00f2ba 100644 --- a/src/flint/gfp_elem.jl +++ b/src/flint/gfp_elem.jl @@ -225,8 +225,7 @@ function ^(x::fpFieldElem, y::Int) x = inv(x) y = -y end - d = ccall((:n_powmod2_preinv, libflint), UInt, (UInt, Int, UInt, UInt), - UInt(x.data), y, R.n, R.ninv) + d = @ccall libflint.n_powmod2_preinv(UInt(x.data)::UInt, y::Int, R.n::UInt, R.ninv::UInt)::UInt return fpFieldElem(d, R) end @@ -264,8 +263,7 @@ end function inv(x::fpFieldElem) R = parent(x) iszero(x) && throw(DivideError()) - xinv = ccall((:n_invmod, libflint), UInt, (UInt, UInt), - x.data, R.n) + xinv = @ccall libflint.n_invmod(x.data::UInt, R.n::UInt)::UInt return fpFieldElem(xinv, R) end @@ -279,8 +277,7 @@ function divexact(x::fpFieldElem, y::fpFieldElem; check::Bool=true) check_parent(x, y) y == 0 && throw(DivideError()) R = parent(x) - yinv = ccall((:n_invmod, libflint), UInt, (UInt, UInt), - y.data, R.n) + yinv = @ccall libflint.n_invmod(y.data::UInt, R.n::UInt)::UInt d = mulmod(x.data, yinv, R.n, R.ninv) return fpFieldElem(d, R) end @@ -307,7 +304,7 @@ function Base.sqrt(a::fpFieldElem; check::Bool=true) if iszero(a) return zero(R) end - r = ccall((:n_sqrtmod, libflint), UInt, (UInt, UInt), a.data, R.n) + r = @ccall libflint.n_sqrtmod(a.data::UInt, R.n::UInt)::UInt check && iszero(r) && error("Not a square in sqrt") return fpFieldElem(r, R) end @@ -317,7 +314,7 @@ function is_square(a::fpFieldElem) if iszero(a) || R.n == 2 return true end - r = ccall((:n_jacobi, libflint), Cint, (UInt, UInt), a.data, R.n) + r = @ccall libflint.n_jacobi(a.data::UInt, R.n::UInt)::Cint return isone(r) end @@ -326,7 +323,7 @@ function is_square_with_sqrt(a::fpFieldElem) if iszero(a) || R.n == 2 return true, a end - r = ccall((:n_sqrtmod, libflint), UInt, (UInt, UInt), a.data, R.n) + r = @ccall libflint.n_sqrtmod(a.data::UInt, R.n::UInt)::UInt if iszero(r) return false, zero(R) end @@ -409,8 +406,7 @@ function (R::fpField)(a::Int) d += n end if d >= n - d = ccall((:n_mod2_preinv, libflint), UInt, (UInt, UInt, UInt), - d, n, ninv) + d = @ccall libflint.n_mod2_preinv(d::UInt, n::UInt, ninv::UInt)::UInt end return fpFieldElem(d, R) end @@ -418,26 +414,22 @@ end function (R::fpField)(a::UInt) n = R.n ninv = R.ninv - a = ccall((:n_mod2_preinv, libflint), UInt, (UInt, UInt, UInt), - a, n, ninv) + a = @ccall libflint.n_mod2_preinv(a::UInt, n::UInt, ninv::UInt)::UInt return fpFieldElem(a, R) end function (R::fpField)(a::ZZRingElem) - d = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), - a, R.n) + d = @ccall libflint.fmpz_fdiv_ui(a::Ref{ZZRingElem}, R.n::UInt)::UInt return fpFieldElem(d, R) end function (R::fpField)(a::QQFieldElem) num = numerator(a, false) den = denominator(a, false) - n = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), - num, R.n) - d = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), - den, R.n) + n = @ccall libflint.fmpz_fdiv_ui(num::Ref{ZZRingElem}, R.n::UInt)::UInt + d = @ccall libflint.fmpz_fdiv_ui(den::Ref{ZZRingElem}, R.n::UInt)::UInt V = [UInt(0)] - g = ccall((:n_gcdinv, libflint), UInt, (Ptr{UInt}, UInt, UInt), V, d, R.n) + g = @ccall libflint.n_gcdinv(V::Ptr{UInt}, d::UInt, R.n::UInt)::UInt g != 1 && error("Unable to coerce") return R(n)*R(V[1]) end diff --git a/src/flint/gfp_fmpz_elem.jl b/src/flint/gfp_fmpz_elem.jl index dd01fffa7..2063e4e46 100644 --- a/src/flint/gfp_fmpz_elem.jl +++ b/src/flint/gfp_fmpz_elem.jl @@ -157,9 +157,7 @@ function *(x::FpFieldElem, y::FpFieldElem) check_parent(x, y) R = parent(x) d = ZZRingElem() - ccall((:fmpz_mod_mul, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - d, x.data, y.data, R.ninv) + @ccall libflint.fmpz_mod_mul(d::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, y.data::Ref{ZZRingElem}, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return FpFieldElem(d, R) end @@ -209,18 +207,14 @@ function ^(x::FpFieldElem, y::Int) y = -y end d = ZZRingElem() - ccall((:fmpz_mod_pow_ui, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt, Ref{fmpz_mod_ctx_struct}), - d, x.data, y, R.ninv) + @ccall libflint.fmpz_mod_pow_ui(d::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, y::UInt, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return FpFieldElem(d, R) end function ^(x::FpFieldElem, y::ZZRingElem) R = parent(x) z = R() - if 0 == ccall((:fmpz_mod_pow_fmpz, libflint), Cint, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z.data, x.data, y, R.ninv) + if 0 == @ccall libflint.fmpz_mod_pow_fmpz(z.data::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, y::Ref{ZZRingElem}, R.ninv::Ref{fmpz_mod_ctx_struct})::Cint if iszero(x) throw(DivideError()) else @@ -270,9 +264,7 @@ function inv(x::FpFieldElem) iszero(x) && throw(DivideError()) s = ZZRingElem() g = ZZRingElem() - ccall((:fmpz_gcdinv, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - g, s, x.data, R.n) + @ccall libflint.fmpz_gcdinv(g::Ref{ZZRingElem}, s::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, R.n::Ref{ZZRingElem})::Nothing return FpFieldElem(s, R) end @@ -311,9 +303,7 @@ function Base.sqrt(a::FpFieldElem; check::Bool=true) return zero(R) end z = ZZRingElem() - flag = ccall((:fmpz_sqrtmod, libflint), Bool, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - z, a.data, R.n) + flag = @ccall libflint.fmpz_sqrtmod(z::Ref{ZZRingElem}, a.data::Ref{ZZRingElem}, R.n::Ref{ZZRingElem})::Bool check && !flag && error("Not a square in sqrt") return FpFieldElem(z, R) end @@ -323,8 +313,7 @@ function is_square(a::FpFieldElem) if iszero(a) || R.n == 2 return true end - r = ccall((:fmpz_jacobi, libflint), Cint, (Ref{ZZRingElem}, Ref{ZZRingElem}), - a.data, R.n) + r = @ccall libflint.fmpz_jacobi(a.data::Ref{ZZRingElem}, R.n::Ref{ZZRingElem})::Cint return isone(r) end @@ -334,9 +323,7 @@ function is_square_with_sqrt(a::FpFieldElem) return true, a end z = ZZRingElem() - r = ccall((:fmpz_sqrtmod, libflint), Cint, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - z, a.data, R.n) + r = @ccall libflint.fmpz_sqrtmod(z::Ref{ZZRingElem}, a.data::Ref{ZZRingElem}, R.n::Ref{ZZRingElem})::Cint if iszero(r) return false, zero(R) end @@ -371,28 +358,21 @@ end function mul!(z::FpFieldElem, x::FpFieldElem, y::FpFieldElem) R = parent(z) - ccall((:fmpz_mod_mul, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z.data, x.data, y.data, R.ninv) + @ccall libflint.fmpz_mod_mul(z.data::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, y.data::Ref{ZZRingElem}, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function mul!(z::FpFieldElem, x::FpFieldElem, y::ZZRingElem) R = parent(x) - ccall((:fmpz_mod, libflint), Nothing, (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - z.data, y, R.n) + @ccall libflint.fmpz_mod(z.data::Ref{ZZRingElem}, y::Ref{ZZRingElem}, R.n::Ref{ZZRingElem})::Nothing - ccall((:fmpz_mod_mul, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z.data, x.data, z.data, R.ninv) + @ccall libflint.fmpz_mod_mul(z.data::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, z.data::Ref{ZZRingElem}, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function add!(z::FpFieldElem, x::FpFieldElem, y::FpFieldElem) R = parent(z) - ccall((:fmpz_mod_add, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{fmpz_mod_ctx_struct}), - z.data, x.data, y.data, R.ninv) + @ccall libflint.fmpz_mod_add(z.data::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, y.data::Ref{ZZRingElem}, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -459,8 +439,7 @@ end function (R::FpField)(a::ZZRingElem) d = ZZRingElem() - ccall((:fmpz_mod, libflint), Nothing, (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - d, a, R.n) + @ccall libflint.fmpz_mod(d::Ref{ZZRingElem}, a::Ref{ZZRingElem}, R.n::Ref{ZZRingElem})::Nothing return FpFieldElem(d, R) end diff --git a/src/flint/gfp_fmpz_mat.jl b/src/flint/gfp_fmpz_mat.jl index 0188a1d1f..4b8744199 100644 --- a/src/flint/gfp_fmpz_mat.jl +++ b/src/flint/gfp_fmpz_mat.jl @@ -34,8 +34,7 @@ function getindex!(v::FpFieldElem, a::FpMatrix, i::Int, j::Int) @boundscheck _checkbounds(a, i, j) GC.@preserve a begin z = mat_entry_ptr(a, i, j) - ccall((:fmpz_mod_set_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ptr{ZZRingElem}, Ref{FpField}), v.data, z, base_ring(a)) + @ccall libflint.fmpz_mod_set_fmpz(v.data::Ref{ZZRingElem}, z::Ptr{ZZRingElem}, base_ring(a)::Ref{FpField})::Nothing end return v end @@ -43,9 +42,7 @@ end # return plain ZZRingElem, no bounds checking @inline function getindex_raw(a::FpMatrix, i::Int, j::Int) u = ZZRingElem() - ccall((:fmpz_mod_mat_get_entry, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FpMatrix}, Int, Int, Ref{fmpz_mod_ctx_struct}), - u, a, i - 1, j - 1, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_get_entry(u::Ref{ZZRingElem}, a::Ref{FpMatrix}, (i - 1)::Int, (j - 1)::Int, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return u end @@ -72,17 +69,14 @@ end # as per setindex! but no reduction mod n and no bounds checking @inline function setindex_raw!(a::FpMatrix, u::ZZRingElem, i::Int, j::Int) - ccall((:fmpz_mod_mat_set_entry, libflint), Nothing, - (Ref{FpMatrix}, Int, Int, Ref{ZZRingElem}, Ref{Nothing}), - a, i - 1, j - 1, u, C_NULL) # ctx is not needed here + @ccall libflint.fmpz_mod_mat_set_entry(a::Ref{FpMatrix}, (i - 1)::Int, (j - 1)::Int, u::Ref{ZZRingElem}, C_NULL::Ref{Nothing})::Nothing # ctx is not needed here end function setindex!(a::FpMatrix, b::FpMatrix, r::UnitRange{Int64}, c::UnitRange{Int64}) _checkbounds(a, r, c) size(b) == (length(r), length(c)) || throw(DimensionMismatch("tried to assign a $(size(b, 1))x$(size(b, 2)) matrix to a $(length(r))x$(length(c)) destination")) A = view(a, r, c) - ccall((:fmpz_mod_mat_set, libflint), Nothing, - (Ref{FpMatrix}, Ref{FpMatrix}, Ref{Nothing}), A, b, C_NULL) + @ccall libflint.fmpz_mod_mat_set(A::Ref{FpMatrix}, b::Ref{FpMatrix}, C_NULL::Ref{Nothing})::Nothing end function deepcopy_internal(a::FpMatrix, dict::IdDict) @@ -90,9 +84,7 @@ function deepcopy_internal(a::FpMatrix, dict::IdDict) if isdefined(a, :base_ring) z.base_ring = a.base_ring end - ccall((:fmpz_mod_mat_set, libflint), Nothing, - (Ref{FpMatrix}, Ref{FpMatrix}, Ref{fmpz_mod_ctx_struct}), - z, a, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_set(z::Ref{FpMatrix}, a::Ref{FpMatrix}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -105,14 +97,12 @@ base_ring(a::FpMatrix) = a.base_ring function one(a::FpMatrixSpace) (nrows(a) != ncols(a)) && error("Matrices must be square") z = a() - ccall((:fmpz_mod_mat_one, libflint), Nothing, - (Ref{FpMatrix}, Ref{fmpz_mod_ctx_struct}), z, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_one(z::Ref{FpMatrix}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function iszero(a::FpMatrix) - r = ccall((:fmpz_mod_mat_is_zero, libflint), Cint, - (Ref{FpMatrix}, Ref{fmpz_mod_ctx_struct}), a, base_ring(a).ninv) + r = @ccall libflint.fmpz_mod_mat_is_zero(a::Ref{FpMatrix}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Cint return Bool(r) end @@ -147,9 +137,7 @@ function Generic.add_one!(a::FpMatrix, i::Int, j::Int) @boundscheck _checkbounds(a, i, j) GC.@preserve a begin x = mat_entry_ptr(a, i, j) - ccall((:fmpz_mod_add_si, libflint), Nothing, - (Ptr{ZZRingElem}, Ptr{ZZRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - x, x, 1, base_ring(a).ninv) + @ccall libflint.fmpz_mod_add_si(x::Ptr{ZZRingElem}, x::Ptr{ZZRingElem}, 1::Int, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end return a end @@ -180,16 +168,13 @@ function Base.view(x::FpMatrix, r1::Int, c1::Int, r2::Int, c2::Int) z = FpMatrix() z.base_ring = x.base_ring z.view_parent = x - ccall((:fmpz_mod_mat_window_init, libflint), Nothing, - (Ref{FpMatrix}, Ref{FpMatrix}, Int, Int, Int, Int, Ref{fmpz_mod_ctx_struct}), - z, x, r1 - 1, c1 - 1, r2, c2, base_ring(x).ninv) + @ccall libflint.fmpz_mod_mat_window_init(z::Ref{FpMatrix}, x::Ref{FpMatrix}, (r1 - 1)::Int, (c1 - 1)::Int, r2::Int, c2::Int, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Nothing finalizer(_gfp_fmpz_mat_window_clear_fn, z) return z end function _gfp_fmpz_mat_window_clear_fn(a::FpMatrix) - ccall((:fmpz_mod_mat_window_clear, libflint), Nothing, - (Ref{FpMatrix}, Ref{fmpz_mod_ctx_struct}), a, base_ring(a).ninv) + @ccall libflint.fmpz_mod_mat_window_clear(a::Ref{FpMatrix}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Nothing end ############################################################################### @@ -213,9 +198,7 @@ promote_rule(::Type{FpMatrix}, ::Type{ZZRingElem}) = FpMatrix function inv(a::FpMatrix) !is_square(a) && error("Matrix must be a square matrix") z = similar(a) - r = ccall((:fmpz_mod_mat_inv, libflint), Int, - (Ref{FpMatrix}, Ref{FpMatrix}, Ref{fmpz_mod_ctx_struct}), - z, a, base_ring(a).ninv) + r = @ccall libflint.fmpz_mod_mat_inv(z::Ref{FpMatrix}, a::Ref{FpMatrix}, base_ring(a).ninv::Ref{fmpz_mod_ctx_struct})::Int !Bool(r) && error("Matrix not invertible") return z end @@ -341,8 +324,7 @@ end function nullspace(M::FpMatrix) N = similar(M, ncols(M), ncols(M)) - nullity = ccall((:fmpz_mod_mat_nullspace, libflint), Int, - (Ref{FpMatrix}, Ref{FpMatrix}, Ref{fmpz_mod_ctx_struct}), N, M, base_ring(M).ninv) + nullity = @ccall libflint.fmpz_mod_mat_nullspace(N::Ref{FpMatrix}, M::Ref{FpMatrix}, base_ring(M).ninv::Ref{fmpz_mod_ctx_struct})::Int return nullity, view(N, 1:nrows(N), 1:nullity) end @@ -362,8 +344,7 @@ function Solve._can_solve_internal_no_check(::Solve.LUTrait, A::FpMatrix, b::FpM end x = similar(A, ncols(A), ncols(b)) - fl = ccall((:fmpz_mod_mat_can_solve, libflint), Cint, - (Ref{FpMatrix}, Ref{FpMatrix}, Ref{FpMatrix}, Ref{fmpz_mod_ctx_struct}), x, A, b, base_ring(x).ninv) + fl = @ccall libflint.fmpz_mod_mat_can_solve(x::Ref{FpMatrix}, A::Ref{FpMatrix}, b::Ref{FpMatrix}, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Cint if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end @@ -373,16 +354,12 @@ end # Direct interface to the C functions to be able to write 'generic' code for # different matrix types function _solve_tril_right_flint!(x::FpMatrix, L::FpMatrix, B::FpMatrix, unit::Bool) - ccall((:fmpz_mod_mat_solve_tril, libflint), Nothing, - (Ref{FpMatrix}, Ref{FpMatrix}, Ref{FpMatrix}, Cint, Ref{fmpz_mod_ctx_struct}), - x, L, B, Cint(unit), base_ring(x).ninv) + @ccall libflint.fmpz_mod_mat_solve_tril(x::Ref{FpMatrix}, L::Ref{FpMatrix}, B::Ref{FpMatrix}, Cint(unit)::Cint, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return nothing end function _solve_triu_right_flint!(x::FpMatrix, U::FpMatrix, B::FpMatrix, unit::Bool) - ccall((:fmpz_mod_mat_solve_triu, libflint), Nothing, - (Ref{FpMatrix}, Ref{FpMatrix}, Ref{FpMatrix}, Cint, Ref{fmpz_mod_ctx_struct}), - x, U, B, Cint(unit), base_ring(x).ninv) + @ccall libflint.fmpz_mod_mat_solve_triu(x::Ref{FpMatrix}, U::Ref{FpMatrix}, B::Ref{FpMatrix}, Cint(unit)::Cint, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Nothing return nothing end @@ -395,9 +372,7 @@ end function lu!(P::Perm, x::FpMatrix) P.d .-= 1 - rank = ccall((:fmpz_mod_mat_lu, libflint), Int, - (Ptr{Int}, Ref{FpMatrix}, Cint, Ref{fmpz_mod_ctx_struct}), - P.d, x, Cint(false), base_ring(x).ninv) + rank = @ccall libflint.fmpz_mod_mat_lu(P.d::Ptr{Int}, x::Ref{FpMatrix}, Cint(false)::Cint, base_ring(x).ninv::Ref{fmpz_mod_ctx_struct})::Int P.d .+= 1 diff --git a/src/flint/gfp_fmpz_poly.jl b/src/flint/gfp_fmpz_poly.jl index b3584a669..0b4f8ba47 100644 --- a/src/flint/gfp_fmpz_poly.jl +++ b/src/flint/gfp_fmpz_poly.jl @@ -59,10 +59,7 @@ end function *(x::FpPolyRingElem, y::ZZRingElem) z = parent(x)() - ccall((:fmpz_mod_poly_scalar_mul_fmpz, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_mul_fmpz(z::Ref{FpPolyRingElem}, x::Ref{FpPolyRingElem}, y::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -81,9 +78,7 @@ end function +(x::FpPolyRingElem, y::Int) z = parent(x)() - ccall((:fmpz_mod_poly_add_si, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_add_si(z::Ref{FpPolyRingElem}, x::Ref{FpPolyRingElem}, y::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -91,10 +86,7 @@ end function +(x::FpPolyRingElem, y::ZZRingElem) z = parent(x)() - ccall((:fmpz_mod_poly_add_fmpz, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_add_fmpz(z::Ref{FpPolyRingElem}, x::Ref{FpPolyRingElem}, y::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -113,35 +105,25 @@ end function -(x::FpPolyRingElem, y::Int) z = parent(x)() - ccall((:fmpz_mod_poly_sub_si, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_sub_si(z::Ref{FpPolyRingElem}, x::Ref{FpPolyRingElem}, y::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function -(x::Int, y::FpPolyRingElem) z = parent(y)() - ccall((:fmpz_mod_poly_si_sub, libflint), Nothing, - (Ref{FpPolyRingElem}, Int, Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - z, x, y, y.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_si_sub(z::Ref{FpPolyRingElem}, x::Int, y::Ref{FpPolyRingElem}, y.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function -(x::FpPolyRingElem, y::ZZRingElem) z = parent(x)() - ccall((:fmpz_mod_poly_sub_fmpz, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_sub_fmpz(z::Ref{FpPolyRingElem}, x::Ref{FpPolyRingElem}, y::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end function -(x::ZZRingElem, y::FpPolyRingElem) z = parent(y)() - ccall((:fmpz_mod_poly_fmpz_sub, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{ZZRingElem}, Ref{FpPolyRingElem}, - Ref{fmpz_mod_ctx_struct}), - z, x, y, y.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_fmpz_sub(z::Ref{FpPolyRingElem}, x::Ref{ZZRingElem}, y::Ref{FpPolyRingElem}, y.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -171,9 +153,7 @@ function ==(x::FpPolyRingElem, y::FpFieldElem) return false elseif length(x) == 1 u = ZZRingElem() - ccall((:fmpz_mod_poly_get_coeff_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{FpPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - u, x, 0, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_get_coeff_fmpz(u::Ref{ZZRingElem}, x::Ref{FpPolyRingElem}, 0::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return u == y else return iszero(y) @@ -192,10 +172,7 @@ function divexact(x::FpPolyRingElem, y::FpFieldElem; check::Bool=true) base_ring(x) != parent(y) && error("Elements must have same parent") iszero(y) && throw(DivideError()) q = parent(x)() - ccall((:fmpz_mod_poly_scalar_div_fmpz, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{ZZRingElem}, - Ref{fmpz_mod_ctx_struct}), - q, x, y.data, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_scalar_div_fmpz(q::Ref{FpPolyRingElem}, x::Ref{FpPolyRingElem}, y.data::Ref{ZZRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return q end @@ -230,9 +207,7 @@ specifies the ring to lift into. """ function lift(R::ZZPolyRing, y::FpPolyRingElem) z = ZZPolyRingElem() - ccall((:fmpz_mod_poly_get_fmpz_poly, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - z, y, y.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_get_fmpz_poly(z::Ref{ZZPolyRingElem}, y::Ref{FpPolyRingElem}, y.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing z.parent = R return z end @@ -247,10 +222,7 @@ function gcd(x::FpPolyRingElem, y::FpPolyRingElem) check_parent(x, y) z = parent(x)() f = ZZRingElem() - ccall((:fmpz_mod_poly_gcd, libflint), Nothing, - (Ref{FpPolyRingElem}, - Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - z, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_gcd(z::Ref{FpPolyRingElem}, x::Ref{FpPolyRingElem}, y::Ref{FpPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return z end @@ -259,10 +231,7 @@ function gcdx(x::FpPolyRingElem, y::FpPolyRingElem) g = parent(x)() s = parent(x)() t = parent(x)() - ccall((:fmpz_mod_poly_xgcd, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, - Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - g, s, t, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_xgcd(g::Ref{FpPolyRingElem}, s::Ref{FpPolyRingElem}, t::Ref{FpPolyRingElem}, x::Ref{FpPolyRingElem}, y::Ref{FpPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return g, s, t end @@ -271,10 +240,7 @@ function gcdinv(x::FpPolyRingElem, y::FpPolyRingElem) length(y) >= 2 || error("Length of second argument must be >= 2") g = parent(x)() s = parent(x)() - ccall((:fmpz_mod_poly_gcdinv, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, - Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - g, s, x, y, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_gcdinv(g::Ref{FpPolyRingElem}, s::Ref{FpPolyRingElem}, x::Ref{FpPolyRingElem}, y::Ref{FpPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing return g, s end @@ -285,9 +251,7 @@ end ################################################################################ function is_irreducible(x::FpPolyRingElem) - return Bool(ccall((:fmpz_mod_poly_is_irreducible, libflint), Cint, - (Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - x, x.parent.base_ring.ninv)) + return Bool(@ccall libflint.fmpz_mod_poly_is_irreducible(x::Ref{FpPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Cint) end ################################################################################ @@ -297,9 +261,7 @@ end ################################################################################ function is_squarefree(x::FpPolyRingElem) - return Bool(ccall((:fmpz_mod_poly_is_squarefree, libflint), Cint, - (Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - x, x.parent.base_ring.ninv)) + return Bool(@ccall libflint.fmpz_mod_poly_is_squarefree(x::Ref{FpPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Cint) end ################################################################################ @@ -310,26 +272,20 @@ end function Base.sqrt(x::FpPolyRingElem; check::Bool=true) s = parent(x)() - flag = Bool(ccall((:fmpz_mod_poly_sqrt, libflint), Cint, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - s, x, x.parent.base_ring.ninv)) + flag = Bool(@ccall libflint.fmpz_mod_poly_sqrt(s::Ref{FpPolyRingElem}, x::Ref{FpPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Cint) check && !flag && error("Not a square in sqrt") return s end function is_square(x::FpPolyRingElem) s = parent(x)() - flag = Bool(ccall((:fmpz_mod_poly_sqrt, libflint), Cint, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - s, x, x.parent.base_ring.ninv)) + flag = Bool(@ccall libflint.fmpz_mod_poly_sqrt(s::Ref{FpPolyRingElem}, x::Ref{FpPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Cint) return flag end function is_square_with_sqrt(x::FpPolyRingElem) s = parent(x)() - flag = Bool(ccall((:fmpz_mod_poly_sqrt, libflint), Cint, - (Ref{FpPolyRingElem}, Ref{FpPolyRingElem}, Ref{fmpz_mod_ctx_struct}), - s, x, x.parent.base_ring.ninv)) + flag = Bool(@ccall libflint.fmpz_mod_poly_sqrt(s::Ref{FpPolyRingElem}, x::Ref{FpPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Cint) return flag, s end @@ -348,17 +304,11 @@ end function _factor(x::FpPolyRingElem) n = x.parent.base_ring.ninv fac = gfp_fmpz_poly_factor(n) - ccall((:fmpz_mod_poly_factor, libflint), Nothing, - (Ref{gfp_fmpz_poly_factor}, Ref{FpPolyRingElem}, - Ref{fmpz_mod_ctx_struct}), - fac, x, n) + @ccall libflint.fmpz_mod_poly_factor(fac::Ref{gfp_fmpz_poly_factor}, x::Ref{FpPolyRingElem}, n::Ref{fmpz_mod_ctx_struct})::Nothing res = Dict{FpPolyRingElem, Int}() for i in 1:fac.num f = parent(x)() - ccall((:fmpz_mod_poly_factor_get_fmpz_mod_poly, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{gfp_fmpz_poly_factor}, Int, - Ref{fmpz_mod_ctx_struct}), - f, fac, i - 1, n) + @ccall libflint.fmpz_mod_poly_factor_get_fmpz_mod_poly(f::Ref{FpPolyRingElem}, fac::Ref{gfp_fmpz_poly_factor}, (i - 1)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing e = unsafe_load(fac.exp, i) res[f] = e end @@ -374,17 +324,11 @@ end function _factor_squarefree(x::FpPolyRingElem) n = x.parent.base_ring.ninv fac = gfp_fmpz_poly_factor(n) - ccall((:fmpz_mod_poly_factor_squarefree, libflint), UInt, - (Ref{gfp_fmpz_poly_factor}, Ref{FpPolyRingElem}, - Ref{fmpz_mod_ctx_struct}), - fac, x, n) + @ccall libflint.fmpz_mod_poly_factor_squarefree(fac::Ref{gfp_fmpz_poly_factor}, x::Ref{FpPolyRingElem}, n::Ref{fmpz_mod_ctx_struct})::UInt res = Dict{FpPolyRingElem, Int}() for i in 1:fac.num f = parent(x)() - ccall((:fmpz_mod_poly_factor_get_fmpz_mod_poly, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{gfp_fmpz_poly_factor}, Int, - Ref{fmpz_mod_ctx_struct}), - f, fac, i - 1, n) + @ccall libflint.fmpz_mod_poly_factor_get_fmpz_mod_poly(f::Ref{FpPolyRingElem}, fac::Ref{gfp_fmpz_poly_factor}, (i - 1)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing e = unsafe_load(fac.exp, i) res[f] = e end @@ -402,17 +346,11 @@ function factor_distinct_deg(x::FpPolyRingElem) degss = [ pointer(degs) ] n = x.parent.base_ring.ninv fac = gfp_fmpz_poly_factor(n) - ccall((:fmpz_mod_poly_factor_distinct_deg, libflint), UInt, - (Ref{gfp_fmpz_poly_factor}, Ref{FpPolyRingElem}, Ptr{Ptr{Int}}, - Ref{fmpz_mod_ctx_struct}), - fac, x, degss, n) + @ccall libflint.fmpz_mod_poly_factor_distinct_deg(fac::Ref{gfp_fmpz_poly_factor}, x::Ref{FpPolyRingElem}, degss::Ptr{Ptr{Int}}, n::Ref{fmpz_mod_ctx_struct})::UInt res = Dict{Int, FpPolyRingElem}() for i in 1:fac.num f = parent(x)() - ccall((:fmpz_mod_poly_factor_get_fmpz_mod_poly, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{gfp_fmpz_poly_factor}, Int, - Ref{fmpz_mod_ctx_struct}), - f, fac, i - 1, n) + @ccall libflint.fmpz_mod_poly_factor_get_fmpz_mod_poly(f::Ref{FpPolyRingElem}, fac::Ref{gfp_fmpz_poly_factor}, (i - 1)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing res[degs[i]] = f end return res @@ -424,14 +362,11 @@ function factor_equal_deg(x::FpPolyRingElem, d::Int) return FpPolyRingElem[x] end fac = gfp_fmpz_poly_factor(base_ring(x)) - ccall((:fmpz_mod_poly_factor_equal_deg, libflint), UInt, - (Ref{gfp_fmpz_poly_factor}, Ref{FpPolyRingElem}, Int, Ref{fmpz_mod_ctx_struct}), - fac, x, d, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_factor_equal_deg(fac::Ref{gfp_fmpz_poly_factor}, x::Ref{FpPolyRingElem}, d::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::UInt res = Vector{FpPolyRingElem}(undef, fac.num) for i in 1:fac.num f = parent(x)() - ccall((:fmpz_mod_poly_factor_get_fmpz_mod_poly, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{gfp_fmpz_poly_factor}, Int, Ref{fmpz_mod_ctx_struct}), f, fac, i - 1, x.parent.base_ring.ninv) + @ccall libflint.fmpz_mod_poly_factor_get_fmpz_mod_poly(f::Ref{FpPolyRingElem}, fac::Ref{gfp_fmpz_poly_factor}, (i - 1)::Int, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Nothing res[i] = f end return res @@ -441,15 +376,11 @@ function roots(a::FpPolyRingElem) R = parent(a) n = R.base_ring.ninv fac = fmpz_mod_poly_factor(n) - ccall((:fmpz_mod_poly_roots, libflint), UInt, - (Ref{fmpz_mod_poly_factor}, Ref{FpPolyRingElem}, Cint, Ref{fmpz_mod_ctx_struct}), - fac, a, 0, n) + @ccall libflint.fmpz_mod_poly_roots(fac::Ref{fmpz_mod_poly_factor}, a::Ref{FpPolyRingElem}, 0::Cint, n::Ref{fmpz_mod_ctx_struct})::UInt f = R() res = FpFieldElem[] for i in 1:fac.num - ccall((:fmpz_mod_poly_factor_get_fmpz_mod_poly, libflint), Nothing, - (Ref{FpPolyRingElem}, Ref{fmpz_mod_poly_factor}, Int, Ref{fmpz_mod_ctx_struct}), - f, fac, i - 1, n) + @ccall libflint.fmpz_mod_poly_factor_get_fmpz_mod_poly(f::Ref{FpPolyRingElem}, fac::Ref{fmpz_mod_poly_factor}, (i - 1)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing @assert isone(coeff(f, 1)) push!(res, -coeff(f, 0)) end diff --git a/src/flint/gfp_mat.jl b/src/flint/gfp_mat.jl index 75fcc5140..0ae4b3789 100644 --- a/src/flint/gfp_mat.jl +++ b/src/flint/gfp_mat.jl @@ -51,8 +51,7 @@ function setindex!(a::fpMatrix, b::fpMatrix, r::UnitRange{Int64}, c::UnitRange{I _checkbounds(a, r, c) size(b) == (length(r), length(c)) || throw(DimensionMismatch("tried to assign a $(size(b, 1))x$(size(b, 2)) matrix to a $(length(r))x$(length(c)) destination")) A = view(a, r, c) - ccall((:nmod_mat_set, libflint), Nothing, - (Ref{fpMatrix}, Ref{fpMatrix}), A, b) + @ccall libflint.nmod_mat_set(A::Ref{fpMatrix}, b::Ref{fpMatrix})::Nothing end function deepcopy_internal(a::fpMatrix, dict::IdDict) @@ -60,15 +59,14 @@ function deepcopy_internal(a::fpMatrix, dict::IdDict) if isdefined(a, :base_ring) z.base_ring = a.base_ring end - ccall((:nmod_mat_set, libflint), Nothing, - (Ref{fpMatrix}, Ref{fpMatrix}), z, a) + @ccall libflint.nmod_mat_set(z::Ref{fpMatrix}, a::Ref{fpMatrix})::Nothing return z end function one(a::fpMatrixSpace) (nrows(a) != ncols(a)) && error("Matrices must be square") z = a() - ccall((:nmod_mat_one, libflint), Nothing, (Ref{fpMatrix}, ), z) + @ccall libflint.nmod_mat_one(z::Ref{fpMatrix})::Nothing return z end @@ -93,12 +91,12 @@ end function rref(a::fpMatrix) z = deepcopy(a) - r = ccall((:nmod_mat_rref, libflint), Int, (Ref{fpMatrix}, ), z) + r = @ccall libflint.nmod_mat_rref(z::Ref{fpMatrix})::Int return r, z end function rref!(a::fpMatrix) - r = ccall((:nmod_mat_rref, libflint), Int, (Ref{fpMatrix}, ), a) + r = @ccall libflint.nmod_mat_rref(a::Ref{fpMatrix})::Int return r end @@ -152,7 +150,7 @@ end function det(a::fpMatrix) !is_square(a) && error("Matrix must be a square matrix") - r = ccall((:nmod_mat_det, libflint), UInt, (Ref{fpMatrix}, ), a) + r = @ccall libflint.nmod_mat_det(a::Ref{fpMatrix})::UInt return base_ring(a)(r) end @@ -182,15 +180,13 @@ function Base.view(x::fpMatrix, r1::Int, c1::Int, r2::Int, c2::Int) z = fpMatrix() z.base_ring = x.base_ring z.view_parent = x - ccall((:nmod_mat_window_init, libflint), Nothing, - (Ref{fpMatrix}, Ref{fpMatrix}, Int, Int, Int, Int), - z, x, r1 - 1, c1 - 1, r2, c2) + @ccall libflint.nmod_mat_window_init(z::Ref{fpMatrix}, x::Ref{fpMatrix}, (r1 - 1)::Int, (c1 - 1)::Int, r2::Int, c2::Int)::Nothing finalizer(_gfp_mat_window_clear_fn, z) return z end function _gfp_mat_window_clear_fn(a::fpMatrix) - ccall((:nmod_mat_window_clear, libflint), Nothing, (Ref{fpMatrix}, ), a) + @ccall libflint.nmod_mat_window_clear(a::Ref{fpMatrix})::Nothing end ################################################################################ @@ -202,8 +198,7 @@ end function charpoly(R::fpPolyRing, a::fpMatrix) m = deepcopy(a) p = R() - ccall((:nmod_mat_charpoly, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{fpMatrix}), p, m) + @ccall libflint.nmod_mat_charpoly(p::Ref{fpPolyRingElem}, m::Ref{fpMatrix})::Nothing return p end @@ -215,8 +210,7 @@ end function minpoly(R::fpPolyRing, a::fpMatrix) p = R() - ccall((:nmod_mat_minpoly, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{fpMatrix}), p, a) + @ccall libflint.nmod_mat_minpoly(p::Ref{fpPolyRingElem}, a::Ref{fpMatrix})::Nothing return p end @@ -241,8 +235,7 @@ promote_rule(::Type{fpMatrix}, ::Type{ZZRingElem}) = fpMatrix function inv(a::fpMatrix) !is_square(a) && error("Matrix must be a square matrix") z = similar(a) - r = ccall((:nmod_mat_inv, libflint), Int, - (Ref{fpMatrix}, Ref{fpMatrix}), z, a) + r = @ccall libflint.nmod_mat_inv(z::Ref{fpMatrix}, a::Ref{fpMatrix})::Int !Bool(r) && error("Matrix not invertible") return z end @@ -263,9 +256,7 @@ function Solve._can_solve_internal_no_check(::Solve.LUTrait, A::fpMatrix, b::fpM end x = similar(A, ncols(A), ncols(b)) - fl = ccall((:nmod_mat_can_solve, libflint), Cint, - (Ref{fpMatrix}, Ref{fpMatrix}, Ref{fpMatrix}), - x, A, b) + fl = @ccall libflint.nmod_mat_can_solve(x::Ref{fpMatrix}, A::Ref{fpMatrix}, b::Ref{fpMatrix})::Cint if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end @@ -275,16 +266,12 @@ end # Direct interface to the C functions to be able to write 'generic' code for # different matrix types function _solve_tril_right_flint!(x::fpMatrix, L::fpMatrix, B::fpMatrix, unit::Bool) - ccall((:nmod_mat_solve_tril, libflint), Nothing, - (Ref{fpMatrix}, Ref{fpMatrix}, Ref{fpMatrix}, Cint), - x, L, B, Cint(unit)) + @ccall libflint.nmod_mat_solve_tril(x::Ref{fpMatrix}, L::Ref{fpMatrix}, B::Ref{fpMatrix}, Cint(unit)::Cint)::Nothing return nothing end function _solve_triu_right_flint!(x::fpMatrix, U::fpMatrix, B::fpMatrix, unit::Bool) - ccall((:nmod_mat_solve_triu, libflint), Nothing, - (Ref{fpMatrix}, Ref{fpMatrix}, Ref{fpMatrix}, Cint), - x, U, B, Cint(unit)) + @ccall libflint.nmod_mat_solve_triu(x::Ref{fpMatrix}, U::Ref{fpMatrix}, B::Ref{fpMatrix}, Cint(unit)::Cint)::Nothing return nothing end @@ -407,8 +394,7 @@ end function nullspace(M::fpMatrix) N = similar(M, ncols(M), ncols(M)) - nullity = ccall((:nmod_mat_nullspace, libflint), Int, - (Ref{fpMatrix}, Ref{fpMatrix}), N, M) + nullity = @ccall libflint.nmod_mat_nullspace(N::Ref{fpMatrix}, M::Ref{fpMatrix})::Int return nullity, view(N, 1:nrows(N), 1:nullity) end @@ -421,9 +407,7 @@ end function lu!(P::Perm, x::fpMatrix) P.d .-= 1 - rank = ccall((:nmod_mat_lu, libflint), Int, - (Ptr{Int}, Ref{fpMatrix}, Cint), - P.d, x, Cint(false)) + rank = @ccall libflint.nmod_mat_lu(P.d::Ptr{Int}, x::Ref{fpMatrix}, Cint(false)::Cint)::Int P.d .+= 1 diff --git a/src/flint/gfp_poly.jl b/src/flint/gfp_poly.jl index 6e97e5bca..682fa427c 100644 --- a/src/flint/gfp_poly.jl +++ b/src/flint/gfp_poly.jl @@ -31,7 +31,7 @@ lead_isunit(a::fpPolyRingElem) = !iszero(a) function Base.hash(a::fpPolyRingElem, h::UInt) b = 0x74cec61d2911ace3%UInt for i in 0:length(a) - 1 - u = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, (Ref{fpPolyRingElem}, Int), a, i) + u = @ccall libflint.nmod_poly_get_coeff_ui(a::Ref{fpPolyRingElem}, i::Int)::UInt b = xor(b, xor(hash(u, h), h)) b = (b << 1) | (b >> (sizeof(Int)*8 - 1)) end @@ -129,8 +129,7 @@ function ==(x::fpPolyRingElem, y::fpFieldElem) if length(x) > 1 return false elseif length(x) == 1 - u = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{fpPolyRingElem}, Int), x, 0) + u = @ccall libflint.nmod_poly_get_coeff_ui(x::Ref{fpPolyRingElem}, 0::Int)::UInt return u == y else return iszero(y) @@ -149,8 +148,7 @@ function divexact(x::fpPolyRingElem, y::fpPolyRingElem; check::Bool=true) check_parent(x, y) iszero(y) && throw(DivideError()) z = parent(x)() - ccall((:nmod_poly_div, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), z, x, y) + @ccall libflint.nmod_poly_div(z::Ref{fpPolyRingElem}, x::Ref{fpPolyRingElem}, y::Ref{fpPolyRingElem})::Nothing return z end @@ -177,9 +175,7 @@ function Base.divrem(x::fpPolyRingElem, y::fpPolyRingElem) iszero(y) && throw(DivideError()) q = parent(x)() r = parent(x)() - ccall((:nmod_poly_divrem, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), - q, r, x, y) + @ccall libflint.nmod_poly_divrem(q::Ref{fpPolyRingElem}, r::Ref{fpPolyRingElem}, x::Ref{fpPolyRingElem}, y::Ref{fpPolyRingElem})::Nothing return q, r end @@ -187,9 +183,7 @@ function Base.div(x::fpPolyRingElem, y::fpPolyRingElem) check_parent(x,y) iszero(y) && throw(DivideError()) q = parent(x)() - ccall((:nmod_poly_div, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), - q, x, y) + @ccall libflint.nmod_poly_div(q::Ref{fpPolyRingElem}, x::Ref{fpPolyRingElem}, y::Ref{fpPolyRingElem})::Nothing return q end @@ -203,8 +197,7 @@ function rem(x::fpPolyRingElem, y::fpPolyRingElem) check_parent(x,y) iszero(y) && throw(DivideError()) z = parent(x)() - ccall((:nmod_poly_rem, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), z, x, y) + @ccall libflint.nmod_poly_rem(z::Ref{fpPolyRingElem}, x::Ref{fpPolyRingElem}, y::Ref{fpPolyRingElem})::Nothing return z end @@ -217,8 +210,7 @@ end function gcd(x::fpPolyRingElem, y::fpPolyRingElem) check_parent(x,y) z = parent(x)() - ccall((:nmod_poly_gcd, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), z, x, y) + @ccall libflint.nmod_poly_gcd(z::Ref{fpPolyRingElem}, x::Ref{fpPolyRingElem}, y::Ref{fpPolyRingElem})::Nothing return z end @@ -227,9 +219,7 @@ function gcdx(x::fpPolyRingElem, y::fpPolyRingElem) g = parent(x)() s = parent(x)() t = parent(x)() - ccall((:nmod_poly_xgcd, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, - Ref{fpPolyRingElem}), g, s, t, x, y) + @ccall libflint.nmod_poly_xgcd(g::Ref{fpPolyRingElem}, s::Ref{fpPolyRingElem}, t::Ref{fpPolyRingElem}, x::Ref{fpPolyRingElem}, y::Ref{fpPolyRingElem})::Nothing return g,s,t end @@ -238,9 +228,7 @@ function gcdinv(x::fpPolyRingElem, y::fpPolyRingElem) length(y) <= 1 && error("Length of second argument must be >= 2") g = parent(x)() s = parent(x)() - ccall((:nmod_poly_gcdinv, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), - g, s, x, y) + @ccall libflint.nmod_poly_gcdinv(g::Ref{fpPolyRingElem}, s::Ref{fpPolyRingElem}, x::Ref{fpPolyRingElem}, y::Ref{fpPolyRingElem})::Nothing return g,s end @@ -254,8 +242,7 @@ function resultant(x::fpPolyRingElem, y::fpPolyRingElem, check::Bool = true) if check check_parent(x,y) end - r = ccall((:nmod_poly_resultant, libflint), UInt, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), x, y) + r = @ccall libflint.nmod_poly_resultant(x::Ref{fpPolyRingElem}, y::Ref{fpPolyRingElem})::UInt return base_ring(x)(r) end @@ -267,8 +254,7 @@ end function evaluate(x::fpPolyRingElem, y::fpFieldElem) base_ring(x) != parent(y) && error("Elements must have same parent") - z = ccall((:nmod_poly_evaluate_nmod, libflint), UInt, - (Ref{fpPolyRingElem}, UInt), x, y.data) + z = @ccall libflint.nmod_poly_evaluate_nmod(x::Ref{fpPolyRingElem}, y.data::UInt)::UInt return parent(y)(z) end @@ -290,9 +276,7 @@ function interpolate(R::fpPolyRing, x::Vector{fpFieldElem}, ay[i] = y[i].data end - ccall((:nmod_poly_interpolate_nmod_vec, libflint), Nothing, - (Ref{fpPolyRingElem}, Ptr{UInt}, Ptr{UInt}, Int), - z, ax, ay, length(x)) + @ccall libflint.nmod_poly_interpolate_nmod_vec(z::Ref{fpPolyRingElem}, ax::Ptr{UInt}, ay::Ptr{UInt}, length(x)::Int)::Nothing return z end @@ -311,8 +295,7 @@ specifies the ring to lift into. """ function lift(R::ZZPolyRing, y::fpPolyRingElem) z = ZZPolyRingElem() - ccall((:fmpz_poly_set_nmod_poly_unsigned, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{fpPolyRingElem}), z, y) + @ccall libflint.fmpz_poly_set_nmod_poly_unsigned(z::Ref{ZZPolyRingElem}, y::Ref{fpPolyRingElem})::Nothing z.parent = R return z end @@ -324,8 +307,7 @@ end ################################################################################ function is_irreducible(x::fpPolyRingElem) - return Bool(ccall((:nmod_poly_is_irreducible, libflint), Int32, - (Ref{fpPolyRingElem}, ), x)) + return Bool(@ccall libflint.nmod_poly_is_irreducible(x::Ref{fpPolyRingElem})::Int32) end ################################################################################ @@ -335,8 +317,7 @@ end ################################################################################ function is_squarefree(x::fpPolyRingElem) - return Bool(ccall((:nmod_poly_is_squarefree, libflint), Int32, - (Ref{fpPolyRingElem}, ), x)) + return Bool(@ccall libflint.nmod_poly_is_squarefree(x::Ref{fpPolyRingElem})::Int32) end ################################################################################ @@ -348,8 +329,7 @@ end function sqrt(x::fpPolyRingElem; check::Bool=true) R = parent(x) s = R() - flag = Bool(ccall((:nmod_poly_sqrt, libflint), Cint, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), s, x)) + flag = Bool(@ccall libflint.nmod_poly_sqrt(s::Ref{fpPolyRingElem}, x::Ref{fpPolyRingElem})::Cint) check && !flag && error("Not a square in sqrt") return s end @@ -363,8 +343,7 @@ function is_square(x::fpPolyRingElem) end R = parent(x) s = R() - flag = Bool(ccall((:nmod_poly_sqrt, libflint), Cint, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), s, x)) + flag = Bool(@ccall libflint.nmod_poly_sqrt(s::Ref{fpPolyRingElem}, x::Ref{fpPolyRingElem})::Cint) return flag end @@ -377,8 +356,7 @@ function is_square_with_sqrt(x::fpPolyRingElem) return false, zero(R) end s = R() - flag = Bool(ccall((:nmod_poly_sqrt, libflint), Cint, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), s, x)) + flag = Bool(@ccall libflint.nmod_poly_sqrt(s::Ref{fpPolyRingElem}, x::Ref{fpPolyRingElem})::Cint) return flag, s end @@ -396,13 +374,11 @@ end function _factor(x::fpPolyRingElem) fac = gfp_poly_factor(x.mod_n) - z = ccall((:nmod_poly_factor, libflint), UInt, - (Ref{gfp_poly_factor}, Ref{fpPolyRingElem}), fac, x) + z = @ccall libflint.nmod_poly_factor(fac::Ref{gfp_poly_factor}, x::Ref{fpPolyRingElem})::UInt res = Dict{fpPolyRingElem, Int}() for i in 1:fac.num f = parent(x)() - ccall((:nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{gfp_poly_factor}, Int), f, fac, i-1) + @ccall libflint.nmod_poly_factor_get_poly(f::Ref{fpPolyRingElem}, fac::Ref{gfp_poly_factor}, (i-1)::Int)::Nothing e = unsafe_load(fac.exp,i) res[f] = e end @@ -416,13 +392,11 @@ end function _factor_squarefree(x::fpPolyRingElem) fac = gfp_poly_factor(x.mod_n) - ccall((:nmod_poly_factor_squarefree, libflint), UInt, - (Ref{gfp_poly_factor}, Ref{fpPolyRingElem}), fac, x) + @ccall libflint.nmod_poly_factor_squarefree(fac::Ref{gfp_poly_factor}, x::Ref{fpPolyRingElem})::UInt res = Dict{fpPolyRingElem, Int}() for i in 1:fac.num f = parent(x)() - ccall((:nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{gfp_poly_factor}, Int), f, fac, i-1) + @ccall libflint.nmod_poly_factor_get_poly(f::Ref{fpPolyRingElem}, fac::Ref{gfp_poly_factor}, (i-1)::Int)::Nothing e = unsafe_load(fac.exp,i) res[f] = e end @@ -439,14 +413,11 @@ function factor_distinct_deg(x::fpPolyRingElem) degs = Vector{Int}(undef, degree(x)) degss = [ pointer(degs) ] fac = gfp_poly_factor(x.mod_n) - ccall((:nmod_poly_factor_distinct_deg, libflint), UInt, - (Ref{gfp_poly_factor}, Ref{fpPolyRingElem}, Ptr{Ptr{Int}}), - fac, x, degss) + @ccall libflint.nmod_poly_factor_distinct_deg(fac::Ref{gfp_poly_factor}, x::Ref{fpPolyRingElem}, degss::Ptr{Ptr{Int}})::UInt res = Dict{Int, fpPolyRingElem}() for i in 1:fac.num f = parent(x)() - ccall((:nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{gfp_poly_factor}, Int), f, fac, i-1) + @ccall libflint.nmod_poly_factor_get_poly(f::Ref{fpPolyRingElem}, fac::Ref{gfp_poly_factor}, (i-1)::Int)::Nothing res[degs[i]] = f end return res @@ -458,14 +429,11 @@ function factor_equal_deg(x::fpPolyRingElem, d::Int) return fpPolyRingElem[x] end fac = gfp_poly_factor(x.mod_n) - ccall((:nmod_poly_factor_equal_deg, libflint), UInt, - (Ref{gfp_poly_factor}, Ref{fpPolyRingElem}, Int), - fac, x, d) + @ccall libflint.nmod_poly_factor_equal_deg(fac::Ref{gfp_poly_factor}, x::Ref{fpPolyRingElem}, d::Int)::UInt res = Vector{fpPolyRingElem}(undef, fac.num) for i in 1:fac.num f = parent(x)() - ccall((:nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{gfp_poly_factor}, Int), f, fac, i - 1) + @ccall libflint.nmod_poly_factor_get_poly(f::Ref{fpPolyRingElem}, fac::Ref{gfp_poly_factor}, (i - 1)::Int)::Nothing res[i] = f end return res @@ -475,15 +443,11 @@ function roots(a::fpPolyRingElem) R = parent(a) n = R.n fac = nmod_poly_factor(n) - ccall((:nmod_poly_roots, libflint), UInt, - (Ref{nmod_poly_factor}, Ref{fpPolyRingElem}, Cint), - fac, a, 0) + @ccall libflint.nmod_poly_roots(fac::Ref{nmod_poly_factor}, a::Ref{fpPolyRingElem}, 0::Cint)::UInt f = R() res = fpFieldElem[] for i in 1:fac.num - ccall((:nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{fpPolyRingElem}, Ref{nmod_poly_factor}, Int), - f, fac, i - 1) + @ccall libflint.nmod_poly_factor_get_poly(f::Ref{fpPolyRingElem}, fac::Ref{nmod_poly_factor}, (i - 1)::Int)::Nothing @assert isone(coeff(f, 1)) push!(res, -coeff(f, 0)) end @@ -500,8 +464,7 @@ function remove(z::fpPolyRingElem, p::fpPolyRingElem) ok, v = _remove_check_simple_cases(z, p) ok && return v, zero(parent(z)) z = deepcopy(z) - v = ccall((:nmod_poly_remove, libflint), Int, - (Ref{fpPolyRingElem}, Ref{fpPolyRingElem}), z, p) + v = @ccall libflint.nmod_poly_remove(z::Ref{fpPolyRingElem}, p::Ref{fpPolyRingElem})::Int return v, z end @@ -551,7 +514,7 @@ function (R::fpPolyRing)() end function (R::fpPolyRing)(x::ZZRingElem) - r = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), x, R.n) + r = @ccall libflint.fmpz_fdiv_ui(x::Ref{ZZRingElem}, R.n::UInt)::UInt z = fpPolyRingElem(R.n, r) z.parent = R return z diff --git a/src/flint/nmod.jl b/src/flint/nmod.jl index 5e8d51d08..e62605288 100644 --- a/src/flint/nmod.jl +++ b/src/flint/nmod.jl @@ -161,8 +161,7 @@ end # ni needs to be an 'inverse' of n computing using :n_preinvert_limb in flint function mulmod(a::UInt, b::UInt, n::UInt, ni::UInt) - return ccall((:n_mulmod2_preinv, libflint), UInt, - (UInt, UInt, UInt, UInt), a, b, n, ni) + return @ccall libflint.n_mulmod2_preinv(a::UInt, b::UInt, n::UInt, ni::UInt)::UInt end function *(x::zzModRingElem, y::zzModRingElem) @@ -226,8 +225,7 @@ function ^(x::zzModRingElem, y::Int) x = inv(x) y = -y end - d = ccall((:n_powmod2_preinv, libflint), UInt, (UInt, Int, UInt, UInt), - UInt(x.data), y, R.n, R.ninv) + d = @ccall libflint.n_powmod2_preinv(UInt(x.data)::UInt, y::Int, R.n::UInt, R.ninv::UInt)::UInt return zzModRingElem(d, R) end @@ -270,8 +268,7 @@ function inv(x::zzModRingElem) end #s = [UInt(0)] s = Ref{UInt}() - g = ccall((:n_gcdinv, libflint), UInt, (Ptr{UInt}, UInt, UInt), - s, x.data, R.n) + g = @ccall libflint.n_gcdinv(s::Ptr{UInt}, x.data::UInt, R.n::UInt)::UInt g != 1 && error("Impossible inverse in ", R) return zzModRingElem(s[], R) end @@ -421,8 +418,7 @@ function (R::zzModRing)(a::Int) d += n end if d >= n - d = ccall((:n_mod2_preinv, libflint), UInt, (UInt, UInt, UInt), - d, n, ninv) + d = @ccall libflint.n_mod2_preinv(d::UInt, n::UInt, ninv::UInt)::UInt end return zzModRingElem(d, R) end @@ -430,14 +426,12 @@ end function (R::zzModRing)(a::UInt) n = R.n ninv = R.ninv - a = ccall((:n_mod2_preinv, libflint), UInt, (UInt, UInt, UInt), - a, n, ninv) + a = @ccall libflint.n_mod2_preinv(a::UInt, n::UInt, ninv::UInt)::UInt return zzModRingElem(a, R) end function (R::zzModRing)(a::ZZRingElem) - d = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), - a, R.n) + d = @ccall libflint.fmpz_fdiv_ui(a::Ref{ZZRingElem}, R.n::UInt)::UInt return zzModRingElem(d, R) end diff --git a/src/flint/nmod_abs_series.jl b/src/flint/nmod_abs_series.jl index ecb8735e6..9313f9d82 100644 --- a/src/flint/nmod_abs_series.jl +++ b/src/flint/nmod_abs_series.jl @@ -48,8 +48,7 @@ for (etype, rtype, mtype, brtype) in ( function normalise(a::($etype), len::Int) while len > 0 - c = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{($etype)}, Int), a, len - 1) + c = @ccall libflint.nmod_poly_get_coeff_ui(a::Ref{($etype)}, (len - 1)::Int)::UInt if !iszero(c) break end @@ -69,8 +68,7 @@ for (etype, rtype, mtype, brtype) in ( if n < 0 return zero(UInt) end - return ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{($etype)}, Int), x, n) + return @ccall libflint.nmod_poly_get_coeff_ui(x::Ref{($etype)}, n::Int)::UInt end function coeff(x::($etype), n::Int) @@ -106,8 +104,7 @@ for (etype, rtype, mtype, brtype) in ( function isone(a::($etype)) return precision(a) == 0 || - Bool(ccall((:nmod_poly_is_one, libflint), Cint, - (Ref{($etype)},), a)) + Bool(@ccall libflint.nmod_poly_is_one(a::Ref{($etype)})::Cint) end # todo: write an nmod_poly_valuation @@ -188,9 +185,7 @@ for (etype, rtype, mtype, brtype) in ( lenz = max(lena, lenb) z = parent(a)() z.prec = prec - ccall((:nmod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, a, b, lenz) + @ccall libflint.nmod_poly_add_series(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int)::Nothing return z end @@ -207,9 +202,7 @@ for (etype, rtype, mtype, brtype) in ( lenz = max(lena, lenb) z = parent(a)() z.prec = prec - ccall((:nmod_poly_sub_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, a, b, lenz) + @ccall libflint.nmod_poly_sub_series(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int)::Nothing return z end @@ -236,9 +229,7 @@ for (etype, rtype, mtype, brtype) in ( lenz = min(lena + lenb - 1, prec) - ccall((:nmod_poly_mullow, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, a, b, lenz) + @ccall libflint.nmod_poly_mullow(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int)::Nothing return z end @@ -251,9 +242,7 @@ for (etype, rtype, mtype, brtype) in ( function *(x::$(mtype), y::($etype)) z = parent(y)() z.prec = y.prec - ccall((:nmod_poly_scalar_mul_nmod, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt), - z, y, x.data) + @ccall libflint.nmod_poly_scalar_mul_nmod(z::Ref{($etype)}, y::Ref{($etype)}, x.data::UInt)::Nothing return z end @@ -261,9 +250,7 @@ for (etype, rtype, mtype, brtype) in ( function *(x::ZZRingElem, y::($etype)) R = base_ring(y) - xmod = ccall((:fmpz_fdiv_ui, libflint), UInt, - (Ref{ZZRingElem}, UInt), - x, R.n) + xmod = @ccall libflint.fmpz_fdiv_ui(x::Ref{ZZRingElem}, R.n::UInt)::UInt return R(xmod)*y end @@ -286,12 +273,8 @@ for (etype, rtype, mtype, brtype) in ( z.prec = x.prec + len z.prec = min(z.prec, max_precision(parent(x))) zlen = min(z.prec, xlen + len) - ccall((:nmod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - z, x, len) - ccall((:nmod_poly_set_trunc, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - z, z, zlen) + @ccall libflint.nmod_poly_shift_left(z::Ref{($etype)}, x::Ref{($etype)}, len::Int)::Nothing + @ccall libflint.nmod_poly_set_trunc(z::Ref{($etype)}, z::Ref{($etype)}, zlen::Int)::Nothing return z end @@ -303,9 +286,7 @@ for (etype, rtype, mtype, brtype) in ( z.prec = max(0, x.prec - len) else z.prec = x.prec - len - ccall((:nmod_poly_shift_right, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - z, x, len) + @ccall libflint.nmod_poly_shift_right(z::Ref{($etype)}, x::Ref{($etype)}, len::Int)::Nothing end return z end @@ -325,9 +306,7 @@ for (etype, rtype, mtype, brtype) in ( if precision(x) <= k return x end - ccall((:nmod_poly_truncate, libflint), Nothing, - (Ref{($etype)}, Int), - x, k) + @ccall libflint.nmod_poly_truncate(x::Ref{($etype)}, k::Int)::Nothing x.prec = k return x end @@ -352,9 +331,7 @@ for (etype, rtype, mtype, brtype) in ( z = parent(a)() z.prec = a.prec + (b - 1)*valuation(a) z.prec = min(z.prec, max_precision(parent(a))) - ccall((:nmod_poly_pow_trunc, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt, Int), - z, a, b, z.prec) + @ccall libflint.nmod_poly_pow_trunc(z::Ref{($etype)}, a::Ref{($etype)}, b::UInt, z.prec::Int)::Nothing end return z end @@ -372,9 +349,7 @@ for (etype, rtype, mtype, brtype) in ( n = max(length(x), length(y)) n = min(n, prec) - return Bool(ccall((:nmod_poly_equal_trunc, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Int), - x, y, n)) + return Bool(@ccall libflint.nmod_poly_equal_trunc(x::Ref{($etype)}, y::Ref{($etype)}, n::Int)::Cint) end function isequal(x::($etype), y::($etype)) @@ -384,9 +359,7 @@ for (etype, rtype, mtype, brtype) in ( if x.prec != y.prec || length(x) != length(y) return false end - return Bool(ccall((:nmod_poly_equal, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Int), - x, y, length(x))) + return Bool(@ccall libflint.nmod_poly_equal(x::Ref{($etype)}, y::Ref{($etype)}, length(x)::Int)::Cint) end ############################################################################### @@ -399,8 +372,7 @@ for (etype, rtype, mtype, brtype) in ( if length(x) > 1 return false elseif length(x) == 1 - z = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{($etype)}, Int), x, 0) + z = @ccall libflint.nmod_poly_get_coeff_ui(x::Ref{($etype)}, 0::Int)::UInt return z == y.data else return precision(x) == 0 || iszero(y) @@ -411,9 +383,7 @@ for (etype, rtype, mtype, brtype) in ( function ==(x::($etype), y::ZZRingElem) R = base_ring(x) - ymod = ccall((:fmpz_fdiv_ui, libflint), UInt, - (Ref{ZZRingElem}, UInt), - y, modulus(x)) + ymod = @ccall libflint.fmpz_fdiv_ui(y::Ref{ZZRingElem}, modulus(x)::UInt)::UInt return x == R(ymod) end @@ -444,9 +414,7 @@ for (etype, rtype, mtype, brtype) in ( prec = min(x.prec, y.prec - v2 + v1) z = parent(x)() z.prec = prec - ccall((:nmod_poly_div_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, x, y, prec) + @ccall libflint.nmod_poly_div_series(z::Ref{($etype)}, x::Ref{($etype)}, y::Ref{($etype)}, prec::Int)::Nothing return z end @@ -461,9 +429,7 @@ for (etype, rtype, mtype, brtype) in ( z = parent(x)() z.prec = x.prec yinv = inv(y) - ccall((:nmod_poly_scalar_mul_nmod, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt), - z, x, yinv.data) + @ccall libflint.nmod_poly_scalar_mul_nmod(z::Ref{($etype)}, x::Ref{($etype)}, yinv.data::UInt)::Nothing return z end @@ -485,9 +451,7 @@ for (etype, rtype, mtype, brtype) in ( !is_unit(a) && error("Unable to invert power series") ainv = parent(a)() ainv.prec = a.prec - ccall((:nmod_poly_inv_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - ainv, a, a.prec) + @ccall libflint.nmod_poly_inv_series(ainv::Ref{($etype)}, a::Ref{($etype)}, a.prec::Int)::Nothing return ainv end @@ -498,35 +462,30 @@ for (etype, rtype, mtype, brtype) in ( ############################################################################### function zero!(z::($etype)) - ccall((:nmod_poly_zero, libflint), Nothing, - (Ref{($etype)},), z) + @ccall libflint.nmod_poly_zero(z::Ref{($etype)})::Nothing z.prec = parent(z).prec_max return z end function one!(z::($etype)) - ccall((:nmod_poly_one, libflint), Nothing, - (Ref{($etype)},), z) + @ccall libflint.nmod_poly_one(z::Ref{($etype)})::Nothing z.prec = parent(z).prec_max return z end function neg!(z::($etype), x::($etype)) - ccall((:nmod_poly_neg, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}), z, x) + @ccall libflint.nmod_poly_neg(z::Ref{($etype)}, x::Ref{($etype)})::Nothing z.prec = x.prec return z end function fit!(z::($etype), n::Int) - ccall((:nmod_poly_fit_length, libflint), Nothing, - (Ref{($etype)}, Int), z, n) + @ccall libflint.nmod_poly_fit_length(z::Ref{($etype)}, n::Int)::Nothing return nothing end function setcoeff!(z::($etype), n::Int, x::($mtype)) - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{($etype)}, Int, UInt), z, n, x.data) + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{($etype)}, n::Int, x.data::UInt)::Nothing return z end @@ -554,9 +513,7 @@ for (etype, rtype, mtype, brtype) in ( end z.prec = prec - ccall((:nmod_poly_mullow, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Int), z, a, b, lenz) + @ccall libflint.nmod_poly_mullow(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int)::Nothing return z end @@ -571,9 +528,7 @@ for (etype, rtype, mtype, brtype) in ( lenc = max(lena, lenb) c.prec = prec - ccall((:nmod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - c, a, b, lenc) + @ccall libflint.nmod_poly_add_series(c::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenc::Int)::Nothing return c end @@ -703,9 +658,7 @@ function sqrt_classical(a::fpAbsPowerSeriesRingElem; check::Bool=true) end a = divexact(a, c) z.prec = a.prec - div(v, 2) - ccall((:nmod_poly_sqrt_series, libflint), Nothing, - (Ref{fpAbsPowerSeriesRingElem}, Ref{fpAbsPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.nmod_poly_sqrt_series(z::Ref{fpAbsPowerSeriesRingElem}, a::Ref{fpAbsPowerSeriesRingElem}, a.prec::Int)::Nothing if !isone(s) z *= s end diff --git a/src/flint/nmod_mat.jl b/src/flint/nmod_mat.jl index a35e5ed3b..865addd52 100644 --- a/src/flint/nmod_mat.jl +++ b/src/flint/nmod_mat.jl @@ -40,8 +40,7 @@ end #as above, but as a plain UInt, no bounds checking function getindex_raw(a::T, i::Int, j::Int) where T <: Zmodn_mat - return ccall((:nmod_mat_get_entry, libflint), UInt, - (Ref{T}, Int, Int), a, i - 1, j - 1) + return @ccall libflint.nmod_mat_get_entry(a::Ref{T}, (i - 1)::Int, (j - 1)::Int)::UInt end @inline function setindex!(a::T, u::UInt, i::Int, j::Int) where T <: Zmodn_mat @@ -65,16 +64,14 @@ setindex!(a::Zmodn_mat, u::Integer, i::Int, j::Int) = setindex!(a, ZZRingElem(u) # as per setindex! but no reduction mod n and no bounds checking function setindex_raw!(a::T, u::UInt, i::Int, j::Int) where T <: Zmodn_mat - ccall((:nmod_mat_set_entry, libflint), Nothing, - (Ref{T}, Int, Int, UInt), a, i - 1, j - 1, u) + @ccall libflint.nmod_mat_set_entry(a::Ref{T}, (i - 1)::Int, (j - 1)::Int, u::UInt)::Nothing end # as per setindex! but no reduction mod n and no bounds checking function setindex_raw!(a::T, u::ZZRingElem, i::Int, j::Int) where T <: Zmodn_mat t = ZZRingElem() - ccall((:fmpz_mod_ui, libflint), UInt, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), t, u, a.n) - tt = ccall((:fmpz_get_ui, libflint), UInt, (Ref{ZZRingElem}, ), t) + @ccall libflint.fmpz_mod_ui(t::Ref{ZZRingElem}, u::Ref{ZZRingElem}, a.n::UInt)::UInt + tt = @ccall libflint.fmpz_get_ui(t::Ref{ZZRingElem})::UInt setindex_raw!(a, tt, i, j) end @@ -82,8 +79,7 @@ function setindex!(a::zzModMatrix, b::zzModMatrix, r::UnitRange{Int64}, c::UnitR _checkbounds(a, r, c) size(b) == (length(r), length(c)) || throw(DimensionMismatch("tried to assign a $(size(b, 1))x$(size(b, 2)) matrix to a $(length(r))x$(length(c)) destination")) A = view(a, r, c) - ccall((:nmod_mat_set, libflint), Nothing, - (Ref{zzModMatrix}, Ref{zzModMatrix}), A, b) + @ccall libflint.nmod_mat_set(A::Ref{zzModMatrix}, b::Ref{zzModMatrix})::Nothing end function deepcopy_internal(a::zzModMatrix, dict::IdDict) @@ -91,8 +87,7 @@ function deepcopy_internal(a::zzModMatrix, dict::IdDict) if isdefined(a, :base_ring) z.base_ring = a.base_ring end - ccall((:nmod_mat_set, libflint), Nothing, - (Ref{zzModMatrix}, Ref{zzModMatrix}), z, a) + @ccall libflint.nmod_mat_set(z::Ref{zzModMatrix}, a::Ref{zzModMatrix})::Nothing return z end @@ -108,7 +103,7 @@ function one(a::zzModMatrixSpace) end function iszero(a::T) where T <: Zmodn_mat - r = ccall((:nmod_mat_is_zero, libflint), Cint, (Ref{T}, ), a) + r = @ccall libflint.nmod_mat_is_zero(a::Ref{T})::Cint return Bool(r) end @@ -124,8 +119,7 @@ end ################################################################################ ==(a::T, b::T) where T <: Zmodn_mat = (a.base_ring == b.base_ring) && -Bool(ccall((:nmod_mat_equal, libflint), Cint, - (Ref{T}, Ref{T}), a, b)) +Bool(@ccall libflint.nmod_mat_equal(a::Ref{T}, b::Ref{T})::Cint) isequal(a::T, b::T) where T <: Zmodn_mat = ==(a, b) @@ -137,15 +131,13 @@ isequal(a::T, b::T) where T <: Zmodn_mat = ==(a, b) function transpose(a::T) where T <: Zmodn_mat z = similar(a, ncols(a), nrows(a)) - ccall((:nmod_mat_transpose, libflint), Nothing, - (Ref{T}, Ref{T}), z, a) + @ccall libflint.nmod_mat_transpose(z::Ref{T}, a::Ref{T})::Nothing return z end function transpose!(a::T) where T <: Zmodn_mat !is_square(a) && error("Matrix must be a square matrix") - ccall((:nmod_mat_transpose, libflint), Nothing, - (Ref{T}, Ref{T}), a, a) + @ccall libflint.nmod_mat_transpose(a::Ref{T}, a::Ref{T})::Nothing end ############################################################################### @@ -155,8 +147,7 @@ end ############################################################################### function swap_rows!(x::T, i::Int, j::Int) where T <: Zmodn_mat - ccall((:nmod_mat_swap_rows, libflint), Nothing, - (Ref{T}, Ptr{Nothing}, Int, Int), x, C_NULL, i - 1, j - 1) + @ccall libflint.nmod_mat_swap_rows(x::Ref{T}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int)::Nothing return x end @@ -167,8 +158,7 @@ function swap_rows(x::T, i::Int, j::Int) where T <: Zmodn_mat end function swap_cols!(x::T, i::Int, j::Int) where T <: Zmodn_mat - ccall((:nmod_mat_swap_cols, libflint), Nothing, - (Ref{T}, Ptr{Nothing}, Int, Int), x, C_NULL, i - 1, j - 1) + @ccall libflint.nmod_mat_swap_cols(x::Ref{T}, C_NULL::Ptr{Nothing}, (i - 1)::Int, (j - 1)::Int)::Nothing return x end @@ -179,16 +169,14 @@ function swap_cols(x::T, i::Int, j::Int) where T <: Zmodn_mat end function reverse_rows!(x::T) where T <: Zmodn_mat - ccall((:nmod_mat_invert_rows, libflint), Nothing, - (Ref{T}, Ptr{Nothing}), x, C_NULL) + @ccall libflint.nmod_mat_invert_rows(x::Ref{T}, C_NULL::Ptr{Nothing})::Nothing return x end reverse_rows(x::T) where T <: Zmodn_mat = reverse_rows!(deepcopy(x)) function reverse_cols!(x::T) where T <: Zmodn_mat - ccall((:nmod_mat_invert_cols, libflint), Nothing, - (Ref{T}, Ptr{Nothing}), x, C_NULL) + @ccall libflint.nmod_mat_invert_cols(x::Ref{T}, C_NULL::Ptr{Nothing})::Nothing return x end @@ -211,16 +199,14 @@ reverse_cols(x::T) where T <: Zmodn_mat = reverse_cols!(deepcopy(x)) function +(x::T, y::T) where T <: Zmodn_mat check_parent(x,y) z = similar(x) - ccall((:nmod_mat_add, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + @ccall libflint.nmod_mat_add(z::Ref{T}, x::Ref{T}, y::Ref{T})::Nothing return z end function -(x::T, y::T) where T <: Zmodn_mat check_parent(x,y) z = similar(x) - ccall((:nmod_mat_sub, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + @ccall libflint.nmod_mat_sub(z::Ref{T}, x::Ref{T}, y::Ref{T})::Nothing return z end @@ -228,8 +214,7 @@ function *(x::T, y::T) where T <: Zmodn_mat (base_ring(x) != base_ring(y)) && error("Base ring must be equal") (ncols(x) != nrows(y)) && error("Dimensions are wrong") z = similar(x, nrows(x), ncols(y)) - ccall((:nmod_mat_mul, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + @ccall libflint.nmod_mat_mul(z::Ref{T}, x::Ref{T}, y::Ref{T})::Nothing return z end @@ -241,54 +226,49 @@ end ################################################################################ function zero!(a::T) where T <: Zmodn_mat - ccall((:nmod_mat_zero, libflint), Nothing, (Ref{T}, ), a) + @ccall libflint.nmod_mat_zero(a::Ref{T})::Nothing return a end function one!(a::T) where T <: Zmodn_mat - ccall((:nmod_mat_one, libflint), Nothing, (Ref{T}, ), a) + @ccall libflint.nmod_mat_one(a::Ref{T})::Nothing return a end function neg!(z::T, a::T) where T <: Zmodn_mat - ccall((:nmod_mat_neg, libflint), Nothing, (Ref{T}, Ref{T}), z, a) + @ccall libflint.nmod_mat_neg(z::Ref{T}, a::Ref{T})::Nothing return z end function mul!(a::T, b::T, c::T) where T <: Zmodn_mat - ccall((:nmod_mat_mul, libflint), Nothing, (Ref{T}, Ref{T}, Ref{T}), a, b, c) + @ccall libflint.nmod_mat_mul(a::Ref{T}, b::Ref{T}, c::Ref{T})::Nothing return a end function add!(a::T, b::T, c::T) where T <: Zmodn_mat - ccall((:nmod_mat_add, libflint), Nothing, (Ref{T}, Ref{T}, Ref{T}), a, b, c) + @ccall libflint.nmod_mat_add(a::Ref{T}, b::Ref{T}, c::Ref{T})::Nothing return a end function sub!(a::T, b::T, c::T) where T <: Zmodn_mat - ccall((:nmod_mat_sub, libflint), Nothing, (Ref{T}, Ref{T}, Ref{T}), a, b, c) + @ccall libflint.nmod_mat_sub(a::Ref{T}, b::Ref{T}, c::Ref{T})::Nothing return a end # entries of b required to be in [0,n) function mul!(z::Vector{UInt}, a::T, b::Vector{UInt}) where T <: Zmodn_mat - ccall((:nmod_mat_mul_nmod_vec, libflint), Nothing, - (Ptr{UInt}, Ref{T}, Ptr{UInt}, Int), - z, a, b, length(b)) + @ccall libflint.nmod_mat_mul_nmod_vec(z::Ptr{UInt}, a::Ref{T}, b::Ptr{UInt}, length(b)::Int)::Nothing return z end # entries of a required to be in [0,n) function mul!(z::Vector{UInt}, a::Vector{UInt}, b::T) where T <: Zmodn_mat - ccall((:nmod_mat_nmod_vec_mul, libflint), Nothing, - (Ptr{UInt}, Ptr{UInt}, Int, Ref{T}), - z, a, length(a), b) + @ccall libflint.nmod_mat_nmod_vec_mul(z::Ptr{UInt}, a::Ptr{UInt}, length(a)::Int, b::Ref{T})::Nothing return z end function mul!(a::zzModMatrix, b::zzModMatrix, c::zzModRingElem) - ccall((:nmod_mat_scalar_mul, libflint), Nothing, - (Ref{zzModMatrix}, Ref{zzModMatrix}, UInt), a, b, c.data) + @ccall libflint.nmod_mat_scalar_mul(a::Ref{zzModMatrix}, b::Ref{zzModMatrix}, c.data::UInt)::Nothing return a end @@ -297,12 +277,12 @@ function mul!(a::zzModMatrix, b::zzModRingElem, c::zzModMatrix) end function mul!(A::fpMatrix, B::fpFieldElem, D::fpMatrix) - ccall((:nmod_mat_scalar_mul, libflint), Nothing, (Ref{fpMatrix}, Ref{fpMatrix}, UInt), A, D, B.data) + @ccall libflint.nmod_mat_scalar_mul(A::Ref{fpMatrix}, D::Ref{fpMatrix}, B.data::UInt)::Nothing return A end function addmul!(A::fpMatrix, B::fpMatrix, C::fpFieldElem, D::fpMatrix) - ccall((:nmod_mat_scalar_addmul_ui, libflint), Nothing, (Ref{fpMatrix}, Ref{fpMatrix}, Ref{fpMatrix}, UInt), A, B, D, C.data) + @ccall libflint.nmod_mat_scalar_addmul_ui(A::Ref{fpMatrix}, B::Ref{fpMatrix}, D::Ref{fpMatrix}, C.data::UInt)::Nothing return A end @@ -329,8 +309,7 @@ end function *(x::T, y::UInt) where T <: Zmodn_mat z = similar(x) - ccall((:nmod_mat_scalar_mul, libflint), Nothing, - (Ref{T}, Ref{T}, UInt), z, x, y) + @ccall libflint.nmod_mat_scalar_mul(z::Ref{T}, x::Ref{T}, y::UInt)::Nothing return z end @@ -338,9 +317,8 @@ end function *(x::T, y::ZZRingElem) where T <: Zmodn_mat t = ZZRingElem() - ccall((:fmpz_mod_ui, libflint), UInt, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), t, y, x.n) - tt = ccall((:fmpz_get_ui, libflint), UInt, (Ref{ZZRingElem}, ), t) + @ccall libflint.fmpz_mod_ui(t::Ref{ZZRingElem}, y::Ref{ZZRingElem}, x.n::UInt)::UInt + tt = @ccall libflint.fmpz_get_ui(t::Ref{ZZRingElem})::UInt return x*tt end @@ -367,8 +345,7 @@ end function ^(x::T, y::UInt) where T <: Zmodn_mat z = similar(x) - ccall((:nmod_mat_pow, libflint), Nothing, - (Ref{T}, Ref{T}, UInt), z, x, y) + @ccall libflint.nmod_mat_pow(z::Ref{T}, x::Ref{T}, y::UInt)::Nothing return z end @@ -391,7 +368,7 @@ end ################################################################################ function strong_echelon_form!(a::T) where T <: Zmodn_mat - ccall((:nmod_mat_strong_echelon_form, libflint), Nothing, (Ref{T}, ), a) + @ccall libflint.nmod_mat_strong_echelon_form(a::Ref{T})::Nothing end @doc raw""" @@ -409,7 +386,7 @@ function strong_echelon_form(a::zzModMatrix) end function howell_form!(a::T) where T <: Zmodn_mat - ccall((:nmod_mat_howell_form, libflint), Nothing, (Ref{T}, ), a) + @ccall libflint.nmod_mat_howell_form(a::Ref{T})::Nothing end @doc raw""" @@ -435,7 +412,7 @@ end function tr(a::T) where T <: Zmodn_mat !is_square(a) && error("Matrix must be a square matrix") - r = ccall((:nmod_mat_trace, libflint), UInt, (Ref{T}, ), a) + r = @ccall libflint.nmod_mat_trace(a::Ref{T})::UInt return base_ring(a)(r) end @@ -448,7 +425,7 @@ end function det(a::zzModMatrix) !is_square(a) && error("Matrix must be a square matrix") if is_prime(a.n) - r = ccall((:nmod_mat_det, libflint), UInt, (Ref{zzModMatrix}, ), a) + r = @ccall libflint.nmod_mat_det(a::Ref{zzModMatrix})::UInt return base_ring(a)(r) else try @@ -466,7 +443,7 @@ end ################################################################################ function rank(a::T) where T <: Zmodn_mat - r = ccall((:nmod_mat_rank, libflint), Int, (Ref{T}, ), a) + r = @ccall libflint.nmod_mat_rank(a::Ref{T})::Int return r end @@ -480,8 +457,7 @@ function inv(a::zzModMatrix) !is_square(a) && error("Matrix must be a square matrix") if is_prime(a.n) z = similar(a) - r = ccall((:nmod_mat_inv, libflint), Int, - (Ref{zzModMatrix}, Ref{zzModMatrix}), z, a) + r = @ccall libflint.nmod_mat_inv(z::Ref{zzModMatrix}, a::Ref{zzModMatrix})::Int !Bool(r) && error("Matrix not invertible") return z else @@ -518,14 +494,14 @@ end # is done inplace, so the lower part wil be "l", the upper "u", # both are implicit only. function _solve_triu!(A::T, B::T, C::T, unit::Int = 0) where T <: Zmodn_mat - ccall((:nmod_mat_solve_triu, libflint), Cvoid, (Ref{T}, Ref{T}, Ref{T}, Cint), A, B, C, unit) + @ccall libflint.nmod_mat_solve_triu(A::Ref{T}, B::Ref{T}, C::Ref{T}, unit::Cint)::Cvoid end #solves lower_triangular_part(B)A = C, #if unit == 1, then only the strictly lower triangular part is used #and the diagonal is assumed to be 1 function AbstractAlgebra._solve_tril!(A::T, B::T, C::T, unit::Int = 0) where T <: Zmodn_mat - ccall((:nmod_mat_solve_tril, libflint), Cvoid, (Ref{T}, Ref{T}, Ref{T}, Cint), A, B, C, unit) + @ccall libflint.nmod_mat_solve_tril(A::Ref{T}, B::Ref{T}, C::Ref{T}, unit::Cint)::Cvoid end function Solve._can_solve_internal_no_check(::Solve.LUTrait, A::zzModMatrix, b::zzModMatrix, task::Symbol; side::Symbol = :left) @@ -536,9 +512,7 @@ function Solve._can_solve_internal_no_check(::Solve.LUTrait, A::zzModMatrix, b:: x = similar(A, ncols(A), ncols(b)) # This is probably only correct if the characteristic is prime - fl = ccall((:nmod_mat_can_solve, libflint), Cint, - (Ref{zzModMatrix}, Ref{zzModMatrix}, Ref{zzModMatrix}), - x, A, b) + fl = @ccall libflint.nmod_mat_can_solve(x::Ref{zzModMatrix}, A::Ref{zzModMatrix}, b::Ref{zzModMatrix})::Cint if task === :only_check || task === :with_solution return Bool(fl), x, zero(A, 0, 0) end @@ -557,8 +531,7 @@ end function lu!(P::Perm, x::T) where T <: Zmodn_mat P.d .-= 1 - rank = Int(ccall((:nmod_mat_lu, libflint), Cint, (Ptr{Int}, Ref{T}, Cint), - P.d, x, 0)) + rank = Int(@ccall libflint.nmod_mat_lu(P.d::Ptr{Int}, x::Ref{T}, 0::Cint)::Cint) P.d .+= 1 @@ -633,9 +606,7 @@ function Base.view(x::zzModMatrix, r1::Int, c1::Int, r2::Int, c2::Int) z = zzModMatrix() z.base_ring = x.base_ring z.view_parent = x - ccall((:nmod_mat_window_init, libflint), Nothing, - (Ref{zzModMatrix}, Ref{zzModMatrix}, Int, Int, Int, Int), - z, x, r1 - 1, c1 - 1, r2, c2) + @ccall libflint.nmod_mat_window_init(z::Ref{zzModMatrix}, x::Ref{zzModMatrix}, (r1 - 1)::Int, (c1 - 1)::Int, r2::Int, c2::Int)::Nothing finalizer(_nmod_mat_window_clear_fn, z) return z end @@ -645,7 +616,7 @@ function Base.view(x::T, r::AbstractUnitRange{Int}, c::AbstractUnitRange{Int}) w end function _nmod_mat_window_clear_fn(a::zzModMatrix) - ccall((:nmod_mat_window_clear, libflint), Nothing, (Ref{zzModMatrix}, ), a) + @ccall libflint.nmod_mat_window_clear(a::Ref{zzModMatrix})::Nothing end function sub(x::T, r1::Int, c1::Int, r2::Int, c2::Int) where T <: Zmodn_mat @@ -670,8 +641,7 @@ function hcat(x::T, y::T) where T <: Zmodn_mat (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") (x.r != y.r) && error("Matrices must have same number of rows") z = similar(x, nrows(x), ncols(x) + ncols(y)) - ccall((:nmod_mat_concat_horizontal, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + @ccall libflint.nmod_mat_concat_horizontal(z::Ref{T}, x::Ref{T}, y::Ref{T})::Nothing return z end @@ -679,8 +649,7 @@ function vcat(x::T, y::T) where T <: Zmodn_mat (base_ring(x) != base_ring(y)) && error("Matrices must have same base ring") (x.c != y.c) && error("Matrices must have same number of columns") z = similar(x, nrows(x) + nrows(y), ncols(x)) - ccall((:nmod_mat_concat_vertical, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + @ccall libflint.nmod_mat_concat_vertical(z::Ref{T}, x::Ref{T}, y::Ref{T})::Nothing return z end @@ -698,14 +667,12 @@ entries of the returned matrix are those of $a$ lifted to $\mathbb{Z}$. """ function lift(a::T) where {T <: Zmodn_mat} z = ZZMatrix(nrows(a), ncols(a)) - ccall((:fmpz_mat_set_nmod_mat, libflint), Nothing, - (Ref{ZZMatrix}, Ref{T}), z, a) + @ccall libflint.fmpz_mat_set_nmod_mat(z::Ref{ZZMatrix}, a::Ref{T})::Nothing return z end function lift!(z::ZZMatrix, a::T) where T <: Zmodn_mat - ccall((:fmpz_mat_set_nmod_mat, libflint), Nothing, - (Ref{ZZMatrix}, Ref{T}), z, a) + @ccall libflint.fmpz_mat_set_nmod_mat(z::Ref{ZZMatrix}, a::Ref{T})::Nothing return z end @@ -718,8 +685,7 @@ end function charpoly(R::zzModPolyRing, a::zzModMatrix) m = deepcopy(a) p = R() - ccall((:nmod_mat_charpoly, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{zzModMatrix}), p, m) + @ccall libflint.nmod_mat_charpoly(p::Ref{zzModPolyRingElem}, m::Ref{zzModMatrix})::Nothing return p end @@ -731,8 +697,7 @@ end function minpoly(R::zzModPolyRing, a::zzModMatrix) p = R() - ccall((:nmod_mat_minpoly, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{zzModMatrix}), p, a) + @ccall libflint.nmod_mat_minpoly(p::Ref{zzModPolyRingElem}, a::Ref{zzModMatrix})::Nothing return p end @@ -868,8 +833,7 @@ end function nullspace(M::zzModMatrix) # Apparently this only works correctly if base_ring(M) is a field N = similar(M, ncols(M), ncols(M)) - nullity = ccall((:nmod_mat_nullspace, libflint), Int, - (Ref{zzModMatrix}, Ref{zzModMatrix}), N, M) + nullity = @ccall libflint.nmod_mat_nullspace(N::Ref{zzModMatrix}, M::Ref{zzModMatrix})::Int return nullity, view(N, 1:nrows(N), 1:nullity) end diff --git a/src/flint/nmod_mpoly.jl b/src/flint/nmod_mpoly.jl index dda924467..6926a4712 100644 --- a/src/flint/nmod_mpoly.jl +++ b/src/flint/nmod_mpoly.jl @@ -38,7 +38,7 @@ for (etype, rtype, ftype, ctype, utype) in ( function internal_ordering(a::($rtype)) b = a.ord - # b = ccall((:nmod_mpoly_ctx_ord, libflint), Cint, (Ref{zzModMPolyRing}, ), a) + # b = @ccall libflint.nmod_mpoly_ctx_ord(a::Ref{zzModMPolyRing})::Cint return flint_orderings[b + 1] end @@ -46,9 +46,7 @@ for (etype, rtype, ftype, ctype, utype) in ( A = Vector{($etype)}(undef, R.nvars) for i = 1:R.nvars z = R() - ccall((:nmod_mpoly_gen, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($rtype)}), - z, i - 1, R) + @ccall libflint.nmod_mpoly_gen(z::Ref{($etype)}, (i - 1)::Int, R::Ref{($rtype)})::Nothing A[i] = z end return A @@ -58,31 +56,23 @@ for (etype, rtype, ftype, ctype, utype) in ( n = nvars(R) (i <= 0 || i > n) && error("Index must be between 1 and $n") z = R() - ccall((:nmod_mpoly_gen, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($rtype)}), - z, i - 1, R) + @ccall libflint.nmod_mpoly_gen(z::Ref{($etype)}, (i - 1)::Int, R::Ref{($rtype)})::Nothing return z end function is_gen(a::($etype), i::Int) n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") - return Bool(ccall((:nmod_mpoly_is_gen, libflint), Cint, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, i - 1, parent(a))) + return Bool(@ccall libflint.nmod_mpoly_is_gen(a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Cint) end function is_gen(a::($etype)) - return Bool(ccall((:nmod_mpoly_is_gen, libflint), Cint, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, -1, parent(a))) + return Bool(@ccall libflint.nmod_mpoly_is_gen(a::Ref{($etype)}, (-1)::Int, parent(a)::Ref{($rtype)})::Cint) end function deepcopy_internal(a::($etype), dict::IdDict) z = parent(a)() - ccall((:nmod_mpoly_set, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, parent(a)) + @ccall libflint.nmod_mpoly_set(z::Ref{($etype)}, a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return z end @@ -98,15 +88,11 @@ for (etype, rtype, ftype, ctype, utype) in ( zero(R::($rtype)) = zero!(R()) function isone(a::($etype)) - return Bool(ccall((:nmod_mpoly_is_one, libflint), Cint, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a))) + return Bool(@ccall libflint.nmod_mpoly_is_one(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Cint) end function iszero(a::($etype)) - return Bool(ccall((:nmod_mpoly_is_zero, libflint), Cint, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a))) + return Bool(@ccall libflint.nmod_mpoly_is_zero(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Cint) end function is_monomial(a::($etype)) @@ -122,9 +108,7 @@ for (etype, rtype, ftype, ctype, utype) in ( end function is_constant(a::($etype)) - return Bool(ccall((:nmod_mpoly_is_ui, libflint), Cint, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a))) + return Bool(@ccall libflint.nmod_mpoly_is_ui(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Cint) end function fit!(a::($etype), n::Int) @@ -141,18 +125,14 @@ for (etype, rtype, ftype, ctype, utype) in ( function coeff(a::($etype), i::Int) n = length(a) (i < 1 || i > n) && error("Index must be between 1 and $(length(a))") - z = ccall((:nmod_mpoly_get_term_coeff_ui, libflint), UInt, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, i - 1, parent(a)) + z = @ccall libflint.nmod_mpoly_get_term_coeff_ui(a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::UInt return base_ring(parent(a))(z) end function coeff(a::($etype), b::($etype)) check_parent(a, b) !isone(length(b)) && error("Second argument must be a monomial") - z = ccall((:nmod_mpoly_get_coeff_ui_monomial, libflint), UInt, - (Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - a, b, parent(a)) + z = @ccall libflint.nmod_mpoly_get_coeff_ui_monomial(a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::UInt return base_ring(parent(a))(z) end @@ -175,9 +155,7 @@ for (etype, rtype, ftype, ctype, utype) in ( n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") if degrees_fit_int(a) - d = ccall((:nmod_mpoly_degree_si, libflint), Int, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, i - 1, parent(a)) + d = @ccall libflint.nmod_mpoly_degree_si(a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Int else return Int(degree_fmpz(a, i)) end @@ -188,17 +166,13 @@ for (etype, rtype, ftype, ctype, utype) in ( n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") d = ZZRingElem() - ccall((:nmod_mpoly_degree_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Int, Ref{($rtype)}), - d, a, i - 1, parent(a)) + @ccall libflint.nmod_mpoly_degree_fmpz(d::Ref{ZZRingElem}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Nothing return d end # Return true if degrees fit into an Int function degrees_fit_int(a::($etype)) - return Bool(ccall((:nmod_mpoly_degrees_fit_si, libflint), Cint, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a))) + return Bool(@ccall libflint.nmod_mpoly_degrees_fit_si(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Cint) end # Return an array of the max degrees in each variable @@ -207,9 +181,7 @@ for (etype, rtype, ftype, ctype, utype) in ( throw(OverflowError("degrees of polynomial do not fit into Int")) end degs = Vector{Int}(undef, nvars(parent(a))) - ccall((:nmod_mpoly_degrees_si, libflint), Nothing, - (Ptr{Int}, Ref{($etype)}, Ref{($rtype)}), - degs, a, parent(a)) + @ccall libflint.nmod_mpoly_degrees_si(degs::Ptr{Int}, a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return degs end @@ -220,17 +192,13 @@ for (etype, rtype, ftype, ctype, utype) in ( for i in 1:n degs[i] = ZZRingElem() end - ccall((:nmod_mpoly_degrees_fmpz, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ref{($etype)}, Ref{($rtype)}), - degs, a, parent(a)) + @ccall libflint.nmod_mpoly_degrees_fmpz(degs::Ptr{Ref{ZZRingElem}}, a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return degs end # Return true if degree fits into an Int function total_degree_fits_int(a::($etype)) - return Bool(ccall((:nmod_mpoly_total_degree_fits_si, libflint), Cint, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a))) + return Bool(@ccall libflint.nmod_mpoly_total_degree_fits_si(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Cint) end # Total degree as an Int @@ -238,18 +206,14 @@ for (etype, rtype, ftype, ctype, utype) in ( if !total_degree_fits_int(a) throw(OverflowError("Total degree of polynomial does not fit into Int")) end - d = ccall((:nmod_mpoly_total_degree_si, libflint), Int, - (Ref{($etype)}, Ref{($rtype)}), - a, a.parent) + d = @ccall libflint.nmod_mpoly_total_degree_si(a::Ref{($etype)}, a.parent::Ref{($rtype)})::Int return d end # Total degree as an ZZRingElem function total_degree_fmpz(a::($etype)) d = ZZRingElem() - ccall((:nmod_mpoly_total_degree_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{($etype)}, Ref{($rtype)}), - d, a, parent(a)) + @ccall libflint.nmod_mpoly_total_degree_fmpz(d::Ref{ZZRingElem}, a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return d end @@ -273,9 +237,7 @@ for (etype, rtype, ftype, ctype, utype) in ( error("Exponent cannot be negative") end end - ccall((:nmod_mpoly_get_coeff_vars_ui, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ptr{Int}, Ptr{Int}, Int, Ref{($rtype)}), - z, a, vars, exps, length(vars), parent(a)) + @ccall libflint.nmod_mpoly_get_coeff_vars_ui(z::Ref{($etype)}, a::Ref{($etype)}, vars::Ptr{Int}, exps::Ptr{Int}, length(vars)::Int, parent(a)::Ref{($rtype)})::Nothing return z end @@ -290,27 +252,21 @@ for (etype, rtype, ftype, ctype, utype) in ( function +(a::($etype), b::($etype)) check_parent(a, b) z = parent(a)() - ccall((:nmod_mpoly_add, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.nmod_mpoly_add(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return z end function -(a::($etype), b::($etype)) check_parent(a, b) z = parent(a)() - ccall((:nmod_mpoly_sub, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.nmod_mpoly_sub(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return z end function *(a::($etype), b::($etype)) check_parent(a, b) z = parent(a)() - ccall((:nmod_mpoly_mul, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.nmod_mpoly_mul(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return z end @@ -322,9 +278,7 @@ for (etype, rtype, ftype, ctype, utype) in ( function +(a::($etype), b::UInt) z = parent(a)() - ccall((:nmod_mpoly_add_ui, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.nmod_mpoly_add_ui(z::Ref{($etype)}, a::Ref{($etype)}, b::UInt, parent(a)::Ref{($rtype)})::Nothing return z end @@ -340,20 +294,14 @@ for (etype, rtype, ftype, ctype, utype) in ( function -(a::($etype), b::UInt) z = parent(a)() - ccall((:nmod_mpoly_sub_ui, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.nmod_mpoly_sub_ui(z::Ref{($etype)}, a::Ref{($etype)}, b::UInt, parent(a)::Ref{($rtype)})::Nothing return z end function -(b::UInt, a::($etype)) z = parent(a)() - ccall((:nmod_mpoly_sub_ui, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt, Ref{($rtype)}), - z, a, b, parent(a)) - ccall((:nmod_mpoly_neg, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, z, parent(a)) + @ccall libflint.nmod_mpoly_sub_ui(z::Ref{($etype)}, a::Ref{($etype)}, b::UInt, parent(a)::Ref{($rtype)})::Nothing + @ccall libflint.nmod_mpoly_neg(z::Ref{($etype)}, z::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return z end @@ -367,9 +315,7 @@ for (etype, rtype, ftype, ctype, utype) in ( function *(a::($etype), b::UInt) z = parent(a)() - ccall((:nmod_mpoly_scalar_mul_ui, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt, Ref{($rtype)}), - z, a, b, parent(a)) + @ccall libflint.nmod_mpoly_scalar_mul_ui(z::Ref{($etype)}, a::Ref{($etype)}, b::UInt, parent(a)::Ref{($rtype)})::Nothing return z end @@ -390,18 +336,14 @@ for (etype, rtype, ftype, ctype, utype) in ( function ^(a::($etype), b::Int) b < 0 && throw(DomainError(b, "Exponent must be non-negative")) z = parent(a)() - ccall((:nmod_mpoly_pow_ui, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt, Ref{($rtype)}), - z, a, UInt(b), parent(a)) + @ccall libflint.nmod_mpoly_pow_ui(z::Ref{($etype)}, a::Ref{($etype)}, UInt(b)::UInt, parent(a)::Ref{($rtype)})::Nothing return z end function ^(a::($etype), b::ZZRingElem) b < 0 && throw(DomainError(b, "Exponent must be non-negative")) z = parent(a)() - ok = ccall((:nmod_mpoly_pow_fmpz, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{ZZRingElem}, Ref{($rtype)}), - z, a, b, parent(a)) + ok = @ccall libflint.nmod_mpoly_pow_fmpz(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{ZZRingElem}, parent(a)::Ref{($rtype)})::Cint !isone(ok) && error("Unable to compute power") return z end @@ -415,9 +357,7 @@ for (etype, rtype, ftype, ctype, utype) in ( function gcd(a::($etype), b::($etype)) check_parent(a, b) z = parent(a)() - r = ccall((:nmod_mpoly_gcd, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, b, a.parent) + r = @ccall libflint.nmod_mpoly_gcd(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, a.parent::Ref{($rtype)})::Cint r == 0 && error("Unable to compute gcd") return z end @@ -427,10 +367,7 @@ for (etype, rtype, ftype, ctype, utype) in ( z = parent(a)() abar = parent(a)() bbar = parent(a)() - r = ccall((:nmod_mpoly_gcd_cofactors, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, abar, bbar, a, b, a.parent) + r = @ccall libflint.nmod_mpoly_gcd_cofactors(z::Ref{($etype)}, abar::Ref{($etype)}, bbar::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, a.parent::Ref{($rtype)})::Cint r == 0 && error("Unable to compute gcd") return z, abar, bbar end @@ -447,21 +384,13 @@ for (etype, rtype, ftype, ctype, utype) in ( for i in 0:fac.num-1 f = R() if preserve_input - ccall((:nmod_mpoly_factor_get_base, libflint), Nothing, - (Ref{($etype)}, Ref{($ftype)}, Int, Ref{($rtype)}), - f, fac, i, R) + @ccall libflint.nmod_mpoly_factor_get_base(f::Ref{($etype)}, fac::Ref{($ftype)}, i::Int, R::Ref{($rtype)})::Nothing else - ccall((:nmod_mpoly_factor_swap_base, libflint), Nothing, - (Ref{($etype)}, Ref{($ftype)}, Int, Ref{($rtype)}), - f, fac, i, R) + @ccall libflint.nmod_mpoly_factor_swap_base(f::Ref{($etype)}, fac::Ref{($ftype)}, i::Int, R::Ref{($rtype)})::Nothing end - F.fac[f] = ccall((:nmod_mpoly_factor_get_exp_si, libflint), Int, - (Ref{($ftype)}, Int, Ref{($rtype)}), - fac, i, R) + F.fac[f] = @ccall libflint.nmod_mpoly_factor_get_exp_si(fac::Ref{($ftype)}, i::Int, R::Ref{($rtype)})::Int end - c = ccall((:nmod_mpoly_factor_get_constant_ui, libflint), UInt, - (Ref{($ftype)}, ), - fac) + c = @ccall libflint.nmod_mpoly_factor_get_constant_ui(fac::Ref{($ftype)})::UInt F.unit = R(c) return F end @@ -470,9 +399,7 @@ for (etype, rtype, ftype, ctype, utype) in ( iszero(a) && throw(ArgumentError("Argument must be non-zero")) R = parent(a) fac = ($ftype)(R) - ok = ccall((:nmod_mpoly_factor, libflint), Cint, - (Ref{($ftype)}, Ref{($etype)}, Ref{($rtype)}), - fac, a, R) + ok = @ccall libflint.nmod_mpoly_factor(fac::Ref{($ftype)}, a::Ref{($etype)}, R::Ref{($rtype)})::Cint !isone(ok) && error("unable to compute factorization") return Fac{($etype)}(fac, false) end @@ -481,9 +408,7 @@ for (etype, rtype, ftype, ctype, utype) in ( iszero(a) && throw(ArgumentError("Argument must be non-zero")) R = parent(a) fac = ($ftype)(R) - ok = ccall((:nmod_mpoly_factor_squarefree, libflint), Cint, - (Ref{($ftype)}, Ref{($etype)}, Ref{($rtype)}), - fac, a, R) + ok = @ccall libflint.nmod_mpoly_factor_squarefree(fac::Ref{($ftype)}, a::Ref{($etype)}, R::Ref{($rtype)})::Cint !isone(ok) && error("unable to compute factorization") return Fac{($etype)}(fac, false) end @@ -496,16 +421,12 @@ for (etype, rtype, ftype, ctype, utype) in ( end function is_square(a::($etype)) - return Bool(ccall((:nmod_mpoly_is_square, libflint), Cint, - (Ref{($etype)}, Ref{($rtype)}), - a, a.parent)) + return Bool(@ccall libflint.nmod_mpoly_is_square(a::Ref{($etype)}, a.parent::Ref{($rtype)})::Cint) end function is_square_with_sqrt(a::($etype)) q = parent(a)() - flag = ccall((:nmod_mpoly_sqrt, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - q, a, a.parent) + flag = @ccall libflint.nmod_mpoly_sqrt(q::Ref{($etype)}, a::Ref{($etype)}, a.parent::Ref{($rtype)})::Cint return (Bool(flag), q) end @@ -517,16 +438,12 @@ for (etype, rtype, ftype, ctype, utype) in ( function ==(a::($etype), b::($etype)) check_parent(a, b) - return Bool(ccall((:nmod_mpoly_equal, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - a, b, a.parent)) + return Bool(@ccall libflint.nmod_mpoly_equal(a::Ref{($etype)}, b::Ref{($etype)}, a.parent::Ref{($rtype)})::Cint) end function Base.isless(a::($etype), b::($etype)) (!is_monomial(a) || !is_monomial(b)) && error("Not monomials in comparison") - return ccall((:nmod_mpoly_cmp, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - a, b, a.parent) < 0 + return @ccall libflint.nmod_mpoly_cmp(a::Ref{($etype)}, b::Ref{($etype)}, a.parent::Ref{($rtype)})::Cint < 0 end ############################################################################### @@ -536,17 +453,13 @@ for (etype, rtype, ftype, ctype, utype) in ( ############################################################################### function ==(a::($etype), b::($ctype)) - return Bool(ccall((:nmod_mpoly_equal_ui, libflint), Cint, - (Ref{($etype)}, UInt, Ref{($rtype)}), - a, b.data, a.parent)) + return Bool(@ccall libflint.nmod_mpoly_equal_ui(a::Ref{($etype)}, b.data::UInt, a.parent::Ref{($rtype)})::Cint) end ==(a::($ctype), b::($etype)) = b == a function ==(a::($etype), b::UInt) - return Bool(ccall((:nmod_mpoly_equal_ui, libflint), Cint, - (Ref{($etype)}, UInt, Ref{($rtype)}), - a, b, parent(a))) + return Bool(@ccall libflint.nmod_mpoly_equal_ui(a::Ref{($etype)}, b::UInt, parent(a)::Ref{($rtype)})::Cint) end ==(a::UInt, b::($etype)) = b == a @@ -574,9 +487,7 @@ for (etype, rtype, ftype, ctype, utype) in ( return false, zero(parent(a)) end z = parent(a)() - d = ccall((:nmod_mpoly_divides, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, b, parent(a)) + d = @ccall libflint.nmod_mpoly_divides(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::Cint return isone(d), z end @@ -589,9 +500,7 @@ for (etype, rtype, ftype, ctype, utype) in ( function Base.div(a::($etype), b::($etype)) check_parent(a, b) q = parent(a)() - ccall((:nmod_mpoly_div, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - q, a, b, parent(a)) + @ccall libflint.nmod_mpoly_div(q::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return q end @@ -599,10 +508,7 @@ for (etype, rtype, ftype, ctype, utype) in ( check_parent(a, b) q = parent(a)() r = parent(a)() - ccall((:nmod_mpoly_divrem, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, - Ref{($etype)}, Ref{($rtype)}), - q, r, a, b, parent(a)) + @ccall libflint.nmod_mpoly_divrem(q::Ref{($etype)}, r::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return q, r end @@ -610,10 +516,7 @@ for (etype, rtype, ftype, ctype, utype) in ( len = length(b) q = [parent(a)() for i in 1:len] r = parent(a)() - ccall((:nmod_mpoly_divrem_ideal, libflint), Nothing, - (Ptr{Ref{($etype)}}, Ref{($etype)}, Ref{($etype)}, - Ptr{Ref{($etype)}}, Int, Ref{($rtype)}), - q, r, a, b, len, parent(a)) + @ccall libflint.nmod_mpoly_divrem_ideal(q::Ptr{Ref{($etype)}}, r::Ref{($etype)}, a::Ref{($etype)}, b::Ptr{Ref{($etype)}}, len::Int, parent(a)::Ref{($rtype)})::Nothing return q, r end @@ -640,9 +543,7 @@ for (etype, rtype, ftype, ctype, utype) in ( n = nvars(parent(a)) (i <= 0 || i > n) && error("Index must be between 1 and $n") z = parent(a)() - ccall((:nmod_mpoly_derivative, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, i - 1, parent(a)) + @ccall libflint.nmod_mpoly_derivative(z::Ref{($etype)}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Nothing return z end @@ -655,9 +556,7 @@ for (etype, rtype, ftype, ctype, utype) in ( function evaluate(a::($etype), b::Vector{$ctype}) length(b) != nvars(parent(a)) && error("Vector size incorrect in evaluate") b2 = [d.data for d in b] - z = ccall((:nmod_mpoly_evaluate_all_ui, libflint), UInt, - (Ref{($etype)}, Ptr{UInt}, Ref{($rtype)}), - a, b2, parent(a)) + z = @ccall libflint.nmod_mpoly_evaluate_all_ui(a::Ref{($etype)}, b2::Ptr{UInt}, parent(a)::Ref{($rtype)})::UInt return base_ring(parent(a))(z) end @@ -752,10 +651,7 @@ for (etype, rtype, ftype, ctype, utype) in ( error("Number of variables does not match number of values") c = S() - fl = ccall((:nmod_mpoly_compose_nmod_mpoly, libflint), Cint, - (Ref{$etype}, Ref{$etype}, Ptr{Ref{$etype}}, - Ref{$rtype}, Ref{$rtype}), - c, a, bs, R, S) + fl = @ccall libflint.nmod_mpoly_compose_nmod_mpoly(c::Ref{$etype}, a::Ref{$etype}, bs::Ptr{Ref{$etype}}, R::Ref{$rtype}, S::Ref{$rtype})::Cint fl == 0 && error("Something wrong in evaluation.") return c end @@ -770,9 +666,7 @@ for (etype, rtype, ftype, ctype, utype) in ( error("Number of variables does not match number of values") c = S() - fl = ccall((:nmod_mpoly_compose_nmod_poly, libflint), Cint, - (Ref{$utype}, Ref{$etype}, Ptr{Ref{$utype}}, - Ref{$rtype}), c, a, bs, R) + fl = @ccall libflint.nmod_mpoly_compose_nmod_poly(c::Ref{$utype}, a::Ref{$etype}, bs::Ptr{Ref{$utype}}, R::Ref{$rtype})::Cint fl == 0 && error("Something wrong in evaluation.") return c end @@ -784,37 +678,27 @@ for (etype, rtype, ftype, ctype, utype) in ( ############################################################################### function zero!(a::($etype)) - ccall((:nmod_mpoly_zero, libflint), Nothing, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a)) + @ccall libflint.nmod_mpoly_zero(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return a end function one!(a::($etype)) - ccall((:nmod_mpoly_one, libflint), Nothing, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a)) + @ccall libflint.nmod_mpoly_one(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return a end function neg!(z::($etype), a::($etype)) - ccall((:nmod_mpoly_neg, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - z, a, parent(a)) + @ccall libflint.nmod_mpoly_neg(z::Ref{($etype)}, a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return z end function add!(a::($etype), b::($etype), c::($etype)) - ccall((:nmod_mpoly_add, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - a, b, c, parent(a)) + @ccall libflint.nmod_mpoly_add(a::Ref{($etype)}, b::Ref{($etype)}, c::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return a end function mul!(a::($etype), b::($etype), c::($etype)) - ccall((:nmod_mpoly_mul, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Ref{($rtype)}), - a, b, c, parent(a)) + @ccall libflint.nmod_mpoly_mul(a::Ref{($etype)}, b::Ref{($etype)}, c::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return a end @@ -822,13 +706,9 @@ for (etype, rtype, ftype, ctype, utype) in ( # must be removed with combine_like_terms! function setcoeff!(a::($etype), n::Int, c::($ctype)) if n > length(a) - ccall((:nmod_mpoly_resize, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, n, a.parent) + @ccall libflint.nmod_mpoly_resize(a::Ref{($etype)}, n::Int, a.parent::Ref{($rtype)})::Nothing end - ccall((:nmod_mpoly_set_term_coeff_ui, libflint), Nothing, - (Ref{($etype)}, Int, UInt, Ref{($rtype)}), - a, n - 1, c.data, a.parent) + @ccall libflint.nmod_mpoly_set_term_coeff_ui(a::Ref{($etype)}, (n - 1)::Int, c.data::UInt, a.parent::Ref{($rtype)})::Nothing return a end @@ -843,9 +723,7 @@ for (etype, rtype, ftype, ctype, utype) in ( # Remove zero terms and combine adjacent terms if they have the same monomial # no sorting is performed function combine_like_terms!(a::($etype)) - ccall((:nmod_mpoly_combine_like_terms, libflint), Nothing, - (Ref{($etype)}, Ref{($rtype)}), - a, a.parent) + @ccall libflint.nmod_mpoly_combine_like_terms(a::Ref{($etype)}, a.parent::Ref{($rtype)})::Nothing return a end @@ -856,37 +734,27 @@ for (etype, rtype, ftype, ctype, utype) in ( ############################################################################### function exponent_vector_fits(::Type{Int}, a::($etype), i::Int) - b = ccall((:nmod_mpoly_term_exp_fits_si, libflint), Cint, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, i - 1, parent(a)) + b = @ccall libflint.nmod_mpoly_term_exp_fits_si(a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Cint return Bool(b) end function exponent_vector_fits(::Type{UInt}, a::($etype), i::Int) - b = ccall((:nmod_mpoly_term_exp_fits_ui, libflint), Cint, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, i - 1, parent(a)) + b = @ccall libflint.nmod_mpoly_term_exp_fits_ui(a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Cint return Bool(b) end function exponent_vector!(z::Vector{Int}, a::($etype), i::Int) - ccall((:nmod_mpoly_get_term_exp_si, libflint), Nothing, - (Ptr{Int}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, i - 1, parent(a)) + @ccall libflint.nmod_mpoly_get_term_exp_si(z::Ptr{Int}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Nothing return z end function exponent_vector!(z::Vector{UInt}, a::($etype), i::Int) - ccall((:nmod_mpoly_get_term_exp_ui, libflint), Nothing, - (Ptr{UInt}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, i - 1, parent(a)) + @ccall libflint.nmod_mpoly_get_term_exp_ui(z::Ptr{UInt}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Nothing return z end function exponent_vector!(z::Vector{ZZRingElem}, a::($etype), i::Int) - ccall((:nmod_mpoly_get_term_exp_fmpz, libflint), Nothing, - (Ptr{Ref{ZZRingElem}}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, i - 1, parent(a)) + @ccall libflint.nmod_mpoly_get_term_exp_fmpz(z::Ptr{Ref{ZZRingElem}}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Nothing return z end @@ -900,12 +768,9 @@ for (etype, rtype, ftype, ctype, utype) in ( # they don't fit into 31/63 bits function set_exponent_vector!(a::($etype), n::Int, exps::Vector{UInt}) if n > length(a) - ccall((:nmod_mpoly_resize, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($rtype)}), a, n, a.parent) + @ccall libflint.nmod_mpoly_resize(a::Ref{($etype)}, n::Int, a.parent::Ref{($rtype)})::Nothing end - ccall((:nmod_mpoly_set_term_exp_ui, libflint), Nothing, - (Ref{($etype)}, Int, Ptr{UInt}, Ref{($rtype)}), - a, n - 1, exps, parent(a)) + @ccall libflint.nmod_mpoly_set_term_exp_ui(a::Ref{($etype)}, (n - 1)::Int, exps::Ptr{UInt}, parent(a)::Ref{($rtype)})::Nothing return a end @@ -914,13 +779,9 @@ for (etype, rtype, ftype, ctype, utype) in ( # no check is performed function set_exponent_vector!(a::($etype), n::Int, exps::Vector{Int}) if n > length(a) - ccall((:nmod_mpoly_resize, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, n, parent(a)) + @ccall libflint.nmod_mpoly_resize(a::Ref{($etype)}, n::Int, parent(a)::Ref{($rtype)})::Nothing end - ccall((:nmod_mpoly_set_term_exp_ui, libflint), Nothing, - (Ref{($etype)}, Int, Ptr{Int}, Ref{($rtype)}), - a, n - 1, exps, parent(a)) + @ccall libflint.nmod_mpoly_set_term_exp_ui(a::Ref{($etype)}, (n - 1)::Int, exps::Ptr{Int}, parent(a)::Ref{($rtype)})::Nothing return a end @@ -928,57 +789,43 @@ for (etype, rtype, ftype, ctype, utype) in ( # No sort is performed, so this is unsafe function set_exponent_vector!(a::($etype), n::Int, exps::Vector{ZZRingElem}) if n > length(a) - ccall((:nmod_mpoly_resize, libflint), Nothing, - (Ref{($etype)}, Int, Ref{($rtype)}), - a, n, parent(a)) + @ccall libflint.nmod_mpoly_resize(a::Ref{($etype)}, n::Int, parent(a)::Ref{($rtype)})::Nothing end - ccall((:nmod_mpoly_set_term_exp_fmpz, libflint), Nothing, - (Ref{($etype)}, Int, Ptr{ZZRingElem}, Ref{($rtype)}), - a, n - 1, exps, parent(a)) + @ccall libflint.nmod_mpoly_set_term_exp_fmpz(a::Ref{($etype)}, (n - 1)::Int, exps::Ptr{ZZRingElem}, parent(a)::Ref{($rtype)})::Nothing return a end # Return j-th coordinate of i-th exponent vector function exponent(a::($etype), i::Int, j::Int) (j < 1 || j > nvars(parent(a))) && error("Invalid variable index") - return ccall((:nmod_mpoly_get_term_var_exp_ui, libflint), Int, - (Ref{($etype)}, Int, Int, Ref{($rtype)}), - a, i - 1, j - 1, parent(a)) + return @ccall libflint.nmod_mpoly_get_term_var_exp_ui(a::Ref{($etype)}, (i - 1)::Int, (j - 1)::Int, parent(a)::Ref{($rtype)})::Int end # Return the coefficient of the term with the given exponent vector # Return zero if there is no such term function coeff(a::($etype), exps::Vector{UInt}) - z = ccall((:nmod_mpoly_get_coeff_ui_ui, libflint), UInt, - (Ref{($etype)}, Ptr{UInt}, Ref{($rtype)}), - a, exps, parent(a)) + z = @ccall libflint.nmod_mpoly_get_coeff_ui_ui(a::Ref{($etype)}, exps::Ptr{UInt}, parent(a)::Ref{($rtype)})::UInt return base_ring(parent(a))(z) end # Return the coefficient of the term with the given exponent vector # Return zero if there is no such term function coeff(a::($etype), exps::Vector{Int}) - z = ccall((:nmod_mpoly_get_coeff_ui_ui, libflint), UInt, - (Ref{($etype)}, Ptr{Int}, Ref{($rtype)}), - a, exps, parent(a)) + z = @ccall libflint.nmod_mpoly_get_coeff_ui_ui(a::Ref{($etype)}, exps::Ptr{Int}, parent(a)::Ref{($rtype)})::UInt return base_ring(parent(a))(z) end # Set the coefficient of the term with the given exponent vector to the # given ZZRingElem. Removal of a zero term is performed. function setcoeff!(a::($etype), exps::Vector{UInt}, b::($ctype)) - ccall((:nmod_mpoly_set_coeff_ui_ui, libflint), Nothing, - (Ref{($etype)}, UInt, Ptr{UInt}, Ref{($rtype)}), - a, b.data, exps, parent(a)) + @ccall libflint.nmod_mpoly_set_coeff_ui_ui(a::Ref{($etype)}, b.data::UInt, exps::Ptr{UInt}, parent(a)::Ref{($rtype)})::Nothing return a end # Set the coefficient of the term with the given exponent vector to the # given ZZRingElem. Removal of a zero term is performed. function setcoeff!(a::($etype), exps::Vector{Int}, b::($ctype)) - ccall((:nmod_mpoly_set_coeff_ui_ui, libflint), Nothing, - (Ref{($etype)}, UInt, Ptr{Int}, Ref{($rtype)}), - a, b.data, exps, parent(a)) + @ccall libflint.nmod_mpoly_set_coeff_ui_ui(a::Ref{($etype)}, b.data::UInt, exps::Ptr{Int}, parent(a)::Ref{($rtype)})::Nothing return a end @@ -992,35 +839,27 @@ for (etype, rtype, ftype, ctype, utype) in ( # out of order. Note that like terms are not combined and zeros are not # removed. For that, call combine_like_terms! function sort_terms!(a::($etype)) - ccall((:nmod_mpoly_sort_terms, libflint), Nothing, - (Ref{($etype)}, Ref{($rtype)}), - a, parent(a)) + @ccall libflint.nmod_mpoly_sort_terms(a::Ref{($etype)}, parent(a)::Ref{($rtype)})::Nothing return a end # Return the i-th term of the polynomial, as a polynomial function term(a::($etype), i::Int) z = parent(a)() - ccall((:nmod_mpoly_get_term, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, i - 1, parent(a)) + @ccall libflint.nmod_mpoly_get_term(z::Ref{($etype)}, a::Ref{($etype)}, (i - 1)::Int, parent(a)::Ref{($rtype)})::Nothing return z end # Return the i-th monomial of the polynomial, as a polynomial function monomial(a::($etype), i::Int) z = parent(a)() - ccall((:nmod_mpoly_get_term_monomial, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, Ref{($rtype)}), - z, a, i - 1, a.parent) + @ccall libflint.nmod_mpoly_get_term_monomial(z::Ref{($etype)}, a::Ref{($etype)}, (i - 1)::Int, a.parent::Ref{($rtype)})::Nothing return z end # Sets the given polynomial m to the i-th monomial of the polynomial function monomial!(m::($etype), a::($etype), i::Int) - ccall((:nmod_mpoly_get_term_monomial, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, Ref{($rtype)}), - m, a, i - 1, a.parent) + @ccall libflint.nmod_mpoly_get_term_monomial(m::Ref{($etype)}, a::Ref{($etype)}, (i - 1)::Int, a.parent::Ref{($rtype)})::Nothing return m end @@ -1043,9 +882,7 @@ for (etype, rtype, ftype, ctype, utype) in ( ############################################################################### function _push_term!(z::($etype), c::($ctype), exp::Vector{Int}) - ccall((:nmod_mpoly_push_term_ui_ui, libflint), Nothing, - (Ref{$etype}, UInt, Ptr{UInt}, Ref{$rtype}), - z, c.data, exp, parent(z)) + @ccall libflint.nmod_mpoly_push_term_ui_ui(z::Ref{$etype}, c.data::UInt, exp::Ptr{UInt}, parent(z)::Ref{$rtype})::Nothing return z end diff --git a/src/flint/nmod_poly.jl b/src/flint/nmod_poly.jl index f076f5117..beef0b990 100644 --- a/src/flint/nmod_poly.jl +++ b/src/flint/nmod_poly.jl @@ -28,8 +28,8 @@ dense_poly_type(::Type{zzModRingElem}) = zzModPolyRingElem function lead_is_unit_or_throw(a::zzModPolyRingElem) d = degree(a) - u = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, (Ref{zzModPolyRingElem}, Int), a, d) - n = ccall((:n_gcd, libflint), UInt, (UInt, UInt), u, modulus(a)) + u = @ccall libflint.nmod_poly_get_coeff_ui(a::Ref{zzModPolyRingElem}, d::Int)::UInt + n = @ccall libflint.n_gcd(u::UInt, modulus(a)::UInt)::UInt if n != 1 R = base_ring(a) throw(NotInvertibleError(R(n), R)) @@ -39,7 +39,7 @@ end function Base.hash(a::zzModPolyRingElem, h::UInt) b = 0x53dd43cd511044d1%UInt for i in 0:length(a) - 1 - u = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, (Ref{zzModPolyRingElem}, Int), a, i) + u = @ccall libflint.nmod_poly_get_coeff_ui(a::Ref{zzModPolyRingElem}, i::Int)::UInt b = xor(b, xor(hash(u, h), h)) b = (b << 1) | (b >> (sizeof(Int)*8 - 1)) end @@ -52,21 +52,17 @@ end # ################################################################################ -length(x::T) where T <: Zmodn_poly = ccall((:nmod_poly_length, libflint), Int, - (Ref{T}, ), x) +length(x::T) where T <: Zmodn_poly = @ccall libflint.nmod_poly_length(x::Ref{T})::Int -degree(x::T) where T <: Zmodn_poly = ccall((:nmod_poly_degree, libflint), Int, - (Ref{T}, ), x) +degree(x::T) where T <: Zmodn_poly = @ccall libflint.nmod_poly_degree(x::Ref{T})::Int function coeff(x::T, n::Int) where T <: Zmodn_poly n < 0 && throw(DomainError(n, "Index must be non-negative")) - return base_ring(x)(ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{T}, Int), x, n)) + return base_ring(x)(@ccall libflint.nmod_poly_get_coeff_ui(x::Ref{T}, n::Int)::UInt) end function coeff_raw(x::T, n::Int) where T <: Zmodn_poly - return ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{T}, Int), x, n) + return @ccall libflint.nmod_poly_get_coeff_ui(x::Ref{T}, n::Int)::UInt end zero(R::zzModPolyRing) = R(UInt(0)) @@ -78,8 +74,7 @@ gen(R::zzModPolyRing) = R([zero(base_ring(R)), one(base_ring(R))]) is_gen(a::T) where T <: Zmodn_poly = (degree(a) == 1 && iszero(coeff(a,0)) && isone(coeff(a,1))) -iszero(a::T) where T <: Zmodn_poly = Bool(ccall((:nmod_poly_is_zero, libflint), Int32, - (Ref{T}, ), a)) +iszero(a::T) where T <: Zmodn_poly = Bool(@ccall libflint.nmod_poly_is_zero(a::Ref{T})::Int32) modulus(a::T) where T <: Zmodn_poly = a.parent.n @@ -151,24 +146,21 @@ end function +(x::T, y::T) where T <: Zmodn_poly check_parent(x,y) z = parent(x)() - ccall((:nmod_poly_add, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + @ccall libflint.nmod_poly_add(z::Ref{T}, x::Ref{T}, y::Ref{T})::Nothing return z end function -(x::T, y::T) where T <: Zmodn_poly check_parent(x,y) z = parent(x)() - ccall((:nmod_poly_sub, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + @ccall libflint.nmod_poly_sub(z::Ref{T}, x::Ref{T}, y::Ref{T})::Nothing return z end function *(x::T, y::T) where T <: Zmodn_poly check_parent(x,y) z = parent(x)() - ccall((:nmod_poly_mul, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + @ccall libflint.nmod_poly_mul(z::Ref{T}, x::Ref{T}, y::Ref{T})::Nothing return z end @@ -180,8 +172,7 @@ end function *(x::T, y::UInt) where T <: Zmodn_poly z = parent(x)() - ccall((:nmod_poly_scalar_mul_nmod, libflint), Nothing, - (Ref{T}, Ref{T}, UInt), z, x, y) + @ccall libflint.nmod_poly_scalar_mul_nmod(z::Ref{T}, x::Ref{T}, y::UInt)::Nothing return z end @@ -191,9 +182,8 @@ function *(x::T, y::ZZRingElem) where T <: Zmodn_poly z = parent(x)() t = ZZRingElem() tt = UInt(0) - ccall((:fmpz_mod_ui, libflint), UInt, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), t, y, parent(x).n) - tt = ccall((:fmpz_get_ui, libflint), UInt, (Ref{ZZRingElem}, ), t) + @ccall libflint.fmpz_mod_ui(t::Ref{ZZRingElem}, y::Ref{ZZRingElem}, parent(x).n::UInt)::UInt + tt = @ccall libflint.fmpz_get_ui(t::Ref{ZZRingElem})::UInt return x*tt end @@ -212,8 +202,7 @@ end function +(x::T, y::UInt) where T <: Zmodn_poly z = parent(x)() - ccall((:nmod_poly_add_ui, libflint), Nothing, - (Ref{T}, Ref{T}, UInt), z, x, y) + @ccall libflint.nmod_poly_add_ui(z::Ref{T}, x::Ref{T}, y::UInt)::Nothing return z end @@ -223,9 +212,8 @@ function +(x::T, y::ZZRingElem) where T <: Zmodn_poly z = parent(x)() t = ZZRingElem() tt = UInt(0) - ccall((:fmpz_mod_ui, libflint), UInt, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), t, y, parent(x).n) - tt = ccall((:fmpz_get_ui, libflint), UInt, (Ref{ZZRingElem}, ), t) + @ccall libflint.fmpz_mod_ui(t::Ref{ZZRingElem}, y::Ref{ZZRingElem}, parent(x).n::UInt)::UInt + tt = @ccall libflint.fmpz_get_ui(t::Ref{ZZRingElem})::UInt return +(x,tt) end @@ -244,8 +232,7 @@ end function -(x::T, y::UInt) where T <: Zmodn_poly z = parent(x)() - ccall((:nmod_poly_sub_ui, libflint), Nothing, - (Ref{T}, Ref{T}, UInt), z, x, y) + @ccall libflint.nmod_poly_sub_ui(z::Ref{T}, x::Ref{T}, y::UInt)::Nothing return z end @@ -255,9 +242,8 @@ function -(x::T, y::ZZRingElem) where T <: Zmodn_poly z = parent(x)() t = ZZRingElem() tt = UInt(0) - ccall((:fmpz_mod_ui, libflint), UInt, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), t, y, parent(x).n) - tt = ccall((:fmpz_get_ui, libflint), UInt, (Ref{ZZRingElem}, ), t) + @ccall libflint.fmpz_mod_ui(t::Ref{ZZRingElem}, y::Ref{ZZRingElem}, parent(x).n::UInt)::UInt + tt = @ccall libflint.fmpz_get_ui(t::Ref{ZZRingElem})::UInt return -(x,tt) end @@ -283,8 +269,7 @@ end function ^(x::T, y::Int) where T <: Zmodn_poly y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() - ccall((:nmod_poly_pow, libflint), Nothing, - (Ref{T}, Ref{T}, Int), z, x, y) + @ccall libflint.nmod_poly_pow(z::Ref{T}, x::Ref{T}, y::Int)::Nothing return z end @@ -296,8 +281,7 @@ end function ==(x::T, y::T) where T <: Zmodn_poly check_parent(x, y) - return Bool(ccall((:nmod_poly_equal, libflint), Int32, - (Ref{T}, Ref{T}), x, y)) + return Bool(@ccall libflint.nmod_poly_equal(x::Ref{T}, y::Ref{T})::Int32) end isequal(x::T, y::T) where T <: Zmodn_poly = x == y @@ -313,8 +297,7 @@ function ==(x::zzModPolyRingElem, y::zzModRingElem) if length(x) > 1 return false elseif length(x) == 1 - u = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{zzModPolyRingElem}, Int), x, 0) + u = @ccall libflint.nmod_poly_get_coeff_ui(x::Ref{zzModPolyRingElem}, 0::Int)::UInt return u == y else return iszero(y) @@ -335,8 +318,7 @@ function truncate(a::T, n::Int) where T <: Zmodn_poly if length(z) <= n return z end - ccall((:nmod_poly_truncate, libflint), Nothing, - (Ref{T}, Int), z, n) + @ccall libflint.nmod_poly_truncate(z::Ref{T}, n::Int)::Nothing return z end @@ -344,8 +326,7 @@ function mullow(x::T, y::T, n::Int) where T <: Zmodn_poly check_parent(x, y) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() - ccall((:nmod_poly_mullow, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Int), z, x, y, n) + @ccall libflint.nmod_poly_mullow(z::Ref{T}, x::Ref{T}, y::Ref{T}, n::Int)::Nothing return z end @@ -358,8 +339,7 @@ end function reverse(x::T, len::Int) where T <: Zmodn_poly len < 0 && throw(DomainError(len, "Index must be non-negative")) z = parent(x)() - ccall((:nmod_poly_reverse, libflint), Nothing, - (Ref{T}, Ref{T}, Int), z, x, len) + @ccall libflint.nmod_poly_reverse(z::Ref{T}, x::Ref{T}, len::Int)::Nothing return z end @@ -372,16 +352,14 @@ end function shift_left(x::T, len::Int) where T <: Zmodn_poly len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:nmod_poly_shift_left, libflint), Nothing, - (Ref{T}, Ref{T}, Int), z, x, len) + @ccall libflint.nmod_poly_shift_left(z::Ref{T}, x::Ref{T}, len::Int)::Nothing return z end function shift_right(x::T, len::Int) where T <: Zmodn_poly len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() - ccall((:nmod_poly_shift_right, libflint), Nothing, - (Ref{T}, Ref{T}, Int), z, x, len) + @ccall libflint.nmod_poly_shift_right(z::Ref{T}, x::Ref{T}, len::Int)::Nothing return z end @@ -396,8 +374,7 @@ function divexact(x::zzModPolyRingElem, y::zzModPolyRingElem; check::Bool=true) iszero(y) && throw(DivideError()) lead_is_unit_or_throw(y) z = parent(x)() - ccall((:nmod_poly_div, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}), z, x, y) + @ccall libflint.nmod_poly_div(z::Ref{zzModPolyRingElem}, x::Ref{zzModPolyRingElem}, y::Ref{zzModPolyRingElem})::Nothing return z end @@ -435,9 +412,7 @@ function Base.divrem(x::zzModPolyRingElem, y::zzModPolyRingElem) lead_is_unit_or_throw(y) q = parent(x)() r = parent(x)() - ccall((:nmod_poly_divrem, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}), - q, r, x, y) + @ccall libflint.nmod_poly_divrem(q::Ref{zzModPolyRingElem}, r::Ref{zzModPolyRingElem}, x::Ref{zzModPolyRingElem}, y::Ref{zzModPolyRingElem})::Nothing return q, r end @@ -446,9 +421,7 @@ function Base.div(x::zzModPolyRingElem, y::zzModPolyRingElem) iszero(y) && throw(DivideError()) lead_is_unit_or_throw(y) q = parent(x)() - ccall((:nmod_poly_div, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}), - q, x, y) + @ccall libflint.nmod_poly_div(q::Ref{zzModPolyRingElem}, x::Ref{zzModPolyRingElem}, y::Ref{zzModPolyRingElem})::Nothing return q end @@ -463,8 +436,7 @@ function rem(x::zzModPolyRingElem, y::zzModPolyRingElem) iszero(y) && throw(DivideError()) lead_is_unit_or_throw(y) z = parent(x)() - ccall((:nmod_poly_rem, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}), z, x, y) + @ccall libflint.nmod_poly_rem(z::Ref{zzModPolyRingElem}, x::Ref{zzModPolyRingElem}, y::Ref{zzModPolyRingElem})::Nothing return z end @@ -501,8 +473,7 @@ function invmod(x::T, y::T) where T <: Zmodn_poly return parent(x)(inv(evaluate(x, coeff(y, 0)))) end z = parent(x)() - r = ccall((:nmod_poly_invmod, libflint), Int32, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + r = @ccall libflint.nmod_poly_invmod(z::Ref{T}, x::Ref{T}, y::Ref{T})::Int32 r == 0 ? error("Impossible inverse in invmod") : return z end @@ -510,9 +481,7 @@ function mulmod(x::T, y::T, z::T) where T <: Zmodn_poly check_parent(x,y) check_parent(y,z) w = parent(x)() - ccall((:nmod_poly_mulmod, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}, Ref{T}), - w, x, y, z) + @ccall libflint.nmod_poly_mulmod(w::Ref{T}, x::Ref{T}, y::Ref{T}, z::Ref{T})::Nothing return w end @@ -528,8 +497,7 @@ function powermod(x::T, e::Int, y::T) where T <: Zmodn_poly e = -e end - ccall((:nmod_poly_powmod_ui_binexp, libflint), Nothing, - (Ref{T}, Ref{T}, Int, Ref{T}), z, x, e, y) + @ccall libflint.nmod_poly_powmod_ui_binexp(z::Ref{T}, x::Ref{T}, e::Int, y::Ref{T})::Nothing return z end @@ -545,8 +513,7 @@ function resultant(x::zzModPolyRingElem, y::zzModPolyRingElem, check::Bool = tr check_parent(x,y) !is_prime(modulus(x)) && error("Modulus not prime in resultant") end - r = ccall((:nmod_poly_resultant, libflint), UInt, - (Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}), x, y) + r = @ccall libflint.nmod_poly_resultant(x::Ref{zzModPolyRingElem}, y::Ref{zzModPolyRingElem})::UInt return base_ring(x)(r) end @@ -558,8 +525,7 @@ end function evaluate(x::zzModPolyRingElem, y::zzModRingElem) base_ring(x) != parent(y) && error("Elements must have same parent") - z = ccall((:nmod_poly_evaluate_nmod, libflint), UInt, - (Ref{zzModPolyRingElem}, UInt), x, y.data) + z = @ccall libflint.nmod_poly_evaluate_nmod(x::Ref{zzModPolyRingElem}, y.data::UInt)::UInt return parent(y)(z) end @@ -571,8 +537,7 @@ end function derivative(x::T) where T <: Zmodn_poly z = parent(x)() - ccall((:nmod_poly_derivative, libflint), Nothing, - (Ref{T}, Ref{T}), z, x) + @ccall libflint.nmod_poly_derivative(z::Ref{T}, x::Ref{T})::Nothing return z end @@ -584,8 +549,7 @@ end function integral(x::T) where T <: Zmodn_poly z = parent(x)() - ccall((:nmod_poly_integral, libflint), Nothing, - (Ref{T}, Ref{T}), z, x) + @ccall libflint.nmod_poly_integral(z::Ref{T}, x::Ref{T})::Nothing return z end @@ -598,8 +562,7 @@ end function AbstractAlgebra._compose_right(x::T, y::T) where T <: Zmodn_poly check_parent(x,y) z = parent(x)() - ccall((:nmod_poly_compose, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + @ccall libflint.nmod_poly_compose(z::Ref{T}, x::Ref{T}, y::Ref{T})::Nothing return z end @@ -621,9 +584,7 @@ function interpolate(R::zzModPolyRing, x::Vector{zzModRingElem}, ay[i] = y[i].data end - ccall((:nmod_poly_interpolate_nmod_vec, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ptr{UInt}, Ptr{UInt}, Int), - z, ax, ay, length(x)) + @ccall libflint.nmod_poly_interpolate_nmod_vec(z::Ref{zzModPolyRingElem}, ax::Ptr{UInt}, ay::Ptr{UInt}, length(x)::Int)::Nothing return z end @@ -636,16 +597,14 @@ end function inflate(x::T, n::Int) where T <: Zmodn_poly n < 0 && throw(DomainError(n, "Cannot inflate by a negative number.")) z = parent(x)() - ccall((:nmod_poly_inflate, libflint), Nothing, - (Ref{T}, Ref{T}, UInt), z, x, UInt(n)) + @ccall libflint.nmod_poly_inflate(z::Ref{T}, x::Ref{T}, UInt(n)::UInt)::Nothing return z end function deflate(x::T, n::Int) where T <: Zmodn_poly n < 0 && throw(DomainError(n, "Cannot deflate by a negative number.")) z = parent(x)() - ccall((:nmod_poly_deflate, libflint), Nothing, - (Ref{T}, Ref{T}, UInt), z, x, UInt(n)) + @ccall libflint.nmod_poly_deflate(z::Ref{T}, x::Ref{T}, UInt(n)::UInt)::Nothing return z end @@ -664,8 +623,7 @@ specifies the ring to lift into. """ function lift(R::ZZPolyRing, y::zzModPolyRingElem) z = ZZPolyRingElem() - ccall((:fmpz_poly_set_nmod_poly_unsigned, libflint), Nothing, - (Ref{ZZPolyRingElem}, Ref{zzModPolyRingElem}), z, y) + @ccall libflint.fmpz_poly_set_nmod_poly_unsigned(z::Ref{ZZPolyRingElem}, y::Ref{zzModPolyRingElem})::Nothing z.parent = R return z end @@ -678,8 +636,7 @@ end function is_irreducible(x::zzModPolyRingElem) !is_prime(modulus(x)) && error("Modulus not prime in is_irreducible") - return Bool(ccall((:nmod_poly_is_irreducible, libflint), Int32, - (Ref{zzModPolyRingElem}, ), x)) + return Bool(@ccall libflint.nmod_poly_is_irreducible(x::Ref{zzModPolyRingElem})::Int32) end ################################################################################ @@ -690,8 +647,7 @@ end function is_squarefree(x::zzModPolyRingElem) !is_prime(modulus(x)) && error("Modulus not prime in is_squarefree") - return Bool(ccall((:nmod_poly_is_squarefree, libflint), Int32, - (Ref{zzModPolyRingElem}, ), x)) + return Bool(@ccall libflint.nmod_poly_is_squarefree(x::Ref{zzModPolyRingElem})::Int32) end ################################################################################ @@ -709,13 +665,11 @@ end function _factor(x::zzModPolyRingElem) !is_prime(modulus(x)) && error("Modulus not prime in factor") fac = nmod_poly_factor(x.mod_n) - z = ccall((:nmod_poly_factor, libflint), UInt, - (Ref{nmod_poly_factor}, Ref{zzModPolyRingElem}), fac, x) + z = @ccall libflint.nmod_poly_factor(fac::Ref{nmod_poly_factor}, x::Ref{zzModPolyRingElem})::UInt res = Dict{zzModPolyRingElem,Int}() for i in 1:fac.num f = parent(x)() - ccall((:nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{nmod_poly_factor}, Int), f, fac, i-1) + @ccall libflint.nmod_poly_factor_get_poly(f::Ref{zzModPolyRingElem}, fac::Ref{nmod_poly_factor}, (i-1)::Int)::Nothing e = unsafe_load(fac.exp,i) res[f] = e end @@ -730,13 +684,11 @@ end function _factor_squarefree(x::zzModPolyRingElem) fac = nmod_poly_factor(x.mod_n) - ccall((:nmod_poly_factor_squarefree, libflint), UInt, - (Ref{nmod_poly_factor}, Ref{zzModPolyRingElem}), fac, x) + @ccall libflint.nmod_poly_factor_squarefree(fac::Ref{nmod_poly_factor}, x::Ref{zzModPolyRingElem})::UInt res = Dict{zzModPolyRingElem,Int}() for i in 1:fac.num f = parent(x)() - ccall((:nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{nmod_poly_factor}, Int), f, fac, i-1) + @ccall libflint.nmod_poly_factor_get_poly(f::Ref{zzModPolyRingElem}, fac::Ref{nmod_poly_factor}, (i-1)::Int)::Nothing e = unsafe_load(fac.exp,i) res[f] = e end @@ -754,14 +706,11 @@ function factor_distinct_deg(x::zzModPolyRingElem) degs = Vector{Int}(undef, degree(x)) degss = [ pointer(degs) ] fac = nmod_poly_factor(x.mod_n) - ccall((:nmod_poly_factor_distinct_deg, libflint), UInt, - (Ref{nmod_poly_factor}, Ref{zzModPolyRingElem}, Ptr{Ptr{Int}}), - fac, x, degss) + @ccall libflint.nmod_poly_factor_distinct_deg(fac::Ref{nmod_poly_factor}, x::Ref{zzModPolyRingElem}, degss::Ptr{Ptr{Int}})::UInt res = Dict{Int,zzModPolyRingElem}() for i in 1:fac.num f = parent(x)() - ccall((:nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{nmod_poly_factor}, Int), f, fac, i-1) + @ccall libflint.nmod_poly_factor_get_poly(f::Ref{zzModPolyRingElem}, fac::Ref{nmod_poly_factor}, (i-1)::Int)::Nothing res[degs[i]] = f end return res @@ -789,24 +738,16 @@ function roots(a::zzModPolyRingElem) n = R.n fac = nmod_poly_factor(n) if is_prime(n) - ccall((:nmod_poly_roots, libflint), UInt, - (Ref{nmod_poly_factor}, Ref{zzModPolyRingElem}, Cint), - fac, a, 0) + @ccall libflint.nmod_poly_roots(fac::Ref{nmod_poly_factor}, a::Ref{zzModPolyRingElem}, 0::Cint)::UInt else nfac = n_factor() - ccall((:n_factor, libflint), Nothing, - (Ref{n_factor}, UInt), - nfac, n) - ccall((:nmod_poly_roots_factored, libflint), UInt, - (Ref{nmod_poly_factor}, Ref{zzModPolyRingElem}, Cint, Ref{n_factor}), - fac, a, 0, nfac) + @ccall libflint.n_factor(nfac::Ref{n_factor}, n::UInt)::Nothing + @ccall libflint.nmod_poly_roots_factored(fac::Ref{nmod_poly_factor}, a::Ref{zzModPolyRingElem}, 0::Cint, nfac::Ref{n_factor})::UInt end f = R() res = zzModRingElem[] for i in 1:fac.num - ccall((:nmod_poly_factor_get_poly, libflint), Nothing, - (Ref{zzModPolyRingElem}, Ref{nmod_poly_factor}, Int), - f, fac, i - 1) + @ccall libflint.nmod_poly_factor_get_poly(f::Ref{zzModPolyRingElem}, fac::Ref{nmod_poly_factor}, (i - 1)::Int)::Nothing @assert isone(coeff(f, 1)) push!(res, -coeff(f, 0)) end @@ -837,8 +778,7 @@ function remove(z::zzModPolyRingElem, p::zzModPolyRingElem) ok, v = _remove_check_simple_cases(z, p) ok && return v, zero(parent(z)) z = deepcopy(z) - v = ccall((:nmod_poly_remove, libflint), Int, - (Ref{zzModPolyRingElem}, Ref{zzModPolyRingElem}), z, p) + v = @ccall libflint.nmod_poly_remove(z::Ref{zzModPolyRingElem}, p::Ref{zzModPolyRingElem})::Int return v, z end @@ -880,30 +820,27 @@ end ################################################################################ function zero!(x::T) where T <: Zmodn_poly - ccall((:nmod_poly_zero, libflint), Nothing, - (Ref{T},), x) + @ccall libflint.nmod_poly_zero(x::Ref{T})::Nothing return x end function one!(a::T) where T <: Zmodn_poly - ccall((:nmod_poly_one, libflint), Nothing, (Ref{T}, ), a) + @ccall libflint.nmod_poly_one(a::Ref{T})::Nothing return a end function neg!(z::T, a::T) where T <: Zmodn_poly - ccall((:nmod_poly_neg, libflint), Nothing, (Ref{T}, Ref{T}), z, a) + @ccall libflint.nmod_poly_neg(z::Ref{T}, a::Ref{T})::Nothing return z end function fit!(x::T, n::Int) where T <: Zmodn_poly - ccall((:nmod_poly_fit_length, libflint), Nothing, - (Ref{T}, Int), x, n) + @ccall libflint.nmod_poly_fit_length(x::Ref{T}, n::Int)::Nothing return nothing end function setcoeff!(x::T, n::Int, y::UInt) where T <: Zmodn_poly - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{T}, Int, UInt), x, n, y) + @ccall libflint.nmod_poly_set_coeff_ui(x::Ref{T}, n::Int, y::UInt)::Nothing return x end @@ -914,7 +851,7 @@ function setcoeff!(x::T, n::Int, y::Int) where T <: Zmodn_poly end function setcoeff!(x::T, n::Int, y::ZZRingElem) where T <: Zmodn_poly - r = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), y, x.mod_n) + r = @ccall libflint.fmpz_fdiv_ui(y::Ref{ZZRingElem}, x.mod_n::UInt)::UInt setcoeff!(x, n, r) return x end @@ -924,26 +861,22 @@ setcoeff!(x::T, n::Int, y::Integer) where T <: Zmodn_poly = setcoeff!(x, n, ZZRi setcoeff!(x::zzModPolyRingElem, n::Int, y::zzModRingElem) = setcoeff!(x, n, y.data) function add!(z::T, x::T, y::T) where T <: Zmodn_poly - ccall((:nmod_poly_add, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + @ccall libflint.nmod_poly_add(z::Ref{T}, x::Ref{T}, y::Ref{T})::Nothing return z end function sub!(z::T, x::T, y::T) where T <: Zmodn_poly - ccall((:nmod_poly_sub, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + @ccall libflint.nmod_poly_sub(z::Ref{T}, x::Ref{T}, y::Ref{T})::Nothing return z end function mul!(z::T, x::T, y::T) where T <: Zmodn_poly - ccall((:nmod_poly_mul, libflint), Nothing, - (Ref{T}, Ref{T}, Ref{T}), z, x, y) + @ccall libflint.nmod_poly_mul(z::Ref{T}, x::Ref{T}, y::Ref{T})::Nothing return z end function mul!(z::T, x::T, y::UInt) where T <: Zmodn_poly - ccall((:nmod_poly_scalar_mul_nmod, libflint), Nothing, - (Ref{T}, Ref{T}, UInt), z, x, y) + @ccall libflint.nmod_poly_scalar_mul_nmod(z::Ref{T}, x::Ref{T}, y::UInt)::Nothing return z end @@ -985,7 +918,7 @@ function (R::zzModPolyRing)() end function (R::zzModPolyRing)(x::ZZRingElem) - r = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), x, R.n) + r = @ccall libflint.fmpz_fdiv_ui(x::Ref{ZZRingElem}, R.n::UInt)::UInt z = zzModPolyRingElem(R.n, r) z.parent = R return z diff --git a/src/flint/nmod_rel_series.jl b/src/flint/nmod_rel_series.jl index efcd3dd6b..e7be19f4a 100644 --- a/src/flint/nmod_rel_series.jl +++ b/src/flint/nmod_rel_series.jl @@ -45,21 +45,19 @@ for (etype, rtype, mtype, brtype) in ( function normalise(a::($etype), len::Int) if len > 0 - c = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{($etype)}, Int), a, len - 1) + c = @ccall libflint.nmod_poly_get_coeff_ui(a::Ref{($etype)}, (len - 1)::Int)::UInt end while len > 0 && iszero(c) len -= 1 if len > 0 - c = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{($etype)}, Int), a, len - 1) + c = @ccall libflint.nmod_poly_get_coeff_ui(a::Ref{($etype)}, (len - 1)::Int)::UInt end end return len end function pol_length(x::($etype)) - return ccall((:nmod_poly_length, libflint), Int, (Ref{($etype)},), x) + return @ccall libflint.nmod_poly_length(x::Ref{($etype)})::Int end precision(x::($etype)) = x.prec @@ -69,8 +67,7 @@ for (etype, rtype, mtype, brtype) in ( if n < 0 return R(0) end - z = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{($etype)}, Int), x, n) + z = @ccall libflint.nmod_poly_get_coeff_ui(x::Ref{($etype)}, n::Int)::UInt return R(z) end @@ -107,8 +104,7 @@ for (etype, rtype, mtype, brtype) in ( z.val = zprec else z.val = zval + i - ccall((:nmod_poly_shift_right, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), z, z, i) + @ccall libflint.nmod_poly_shift_right(z::Ref{($etype)}, z::Ref{($etype)}, i::Int)::Nothing end return nothing end @@ -183,28 +179,18 @@ for (etype, rtype, mtype, brtype) in ( ccall((:nmod_poly_set_trunc, libflint), Nothing, (Ref{($etype)}, Ref{($etype)}, Int), z, b, max(0, lenz - b.val + a.val)) - ccall((:nmod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - z, z, b.val - a.val) - ccall((:nmod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, z, a, lenz) + @ccall libflint.nmod_poly_shift_left(z::Ref{($etype)}, z::Ref{($etype)}, (b.val - a.val)::Int)::Nothing + @ccall libflint.nmod_poly_add_series(z::Ref{($etype)}, z::Ref{($etype)}, a::Ref{($etype)}, lenz::Int)::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:nmod_poly_set_trunc, libflint), Nothing, (Ref{($etype)}, Ref{($etype)}, Int), z, a, max(0, lenz - a.val + b.val)) - ccall((:nmod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - z, z, a.val - b.val) - ccall((:nmod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, z, b, lenz) + @ccall libflint.nmod_poly_shift_left(z::Ref{($etype)}, z::Ref{($etype)}, (a.val - b.val)::Int)::Nothing + @ccall libflint.nmod_poly_add_series(z::Ref{($etype)}, z::Ref{($etype)}, b::Ref{($etype)}, lenz::Int)::Nothing else lenz = max(lena, lenb) - ccall((:nmod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, a, b, lenz) + @ccall libflint.nmod_poly_add_series(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int)::Nothing end z.prec = prec z.val = val @@ -227,30 +213,19 @@ for (etype, rtype, mtype, brtype) in ( ccall((:nmod_poly_set_trunc, libflint), Nothing, (Ref{($etype)}, Ref{($etype)}, Int), z, b, max(0, lenz - b.val + a.val)) - ccall((:nmod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - z, z, b.val - a.val) - ccall((:nmod_poly_neg, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}), z, z) - ccall((:nmod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, z, a, lenz) + @ccall libflint.nmod_poly_shift_left(z::Ref{($etype)}, z::Ref{($etype)}, (b.val - a.val)::Int)::Nothing + @ccall libflint.nmod_poly_neg(z::Ref{($etype)}, z::Ref{($etype)})::Nothing + @ccall libflint.nmod_poly_add_series(z::Ref{($etype)}, z::Ref{($etype)}, a::Ref{($etype)}, lenz::Int)::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:nmod_poly_set_trunc, libflint), Nothing, (Ref{($etype)}, Ref{($etype)}, Int), z, a, max(0, lenz - a.val + b.val)) - ccall((:nmod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - z, z, a.val - b.val) - ccall((:nmod_poly_sub_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, z, b, lenz) + @ccall libflint.nmod_poly_shift_left(z::Ref{($etype)}, z::Ref{($etype)}, (a.val - b.val)::Int)::Nothing + @ccall libflint.nmod_poly_sub_series(z::Ref{($etype)}, z::Ref{($etype)}, b::Ref{($etype)}, lenz::Int)::Nothing else lenz = max(lena, lenb) - ccall((:nmod_poly_sub_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, a, b, lenz) + @ccall libflint.nmod_poly_sub_series(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int)::Nothing end z.prec = prec z.val = val @@ -274,9 +249,7 @@ for (etype, rtype, mtype, brtype) in ( return z end lenz = min(lena + lenb - 1, prec) - ccall((:nmod_poly_mullow, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, a, b, lenz) + @ccall libflint.nmod_poly_mullow(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int)::Nothing renormalize!(z) return z end @@ -291,9 +264,7 @@ for (etype, rtype, mtype, brtype) in ( z = parent(y)() z.prec = y.prec z.val = y.val - ccall((:nmod_poly_scalar_mul_nmod, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt), - z, y, data(x)) + @ccall libflint.nmod_poly_scalar_mul_nmod(z::Ref{($etype)}, y::Ref{($etype)}, data(x)::UInt)::Nothing renormalize!(z) return z end @@ -304,10 +275,8 @@ for (etype, rtype, mtype, brtype) in ( z = parent(y)() z.prec = y.prec z.val = y.val - r = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), x, modulus(y)) - ccall((:nmod_poly_scalar_mul_nmod, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt), - z, y, r) + r = @ccall libflint.fmpz_fdiv_ui(x::Ref{ZZRingElem}, modulus(y)::UInt)::UInt + @ccall libflint.nmod_poly_scalar_mul_nmod(z::Ref{($etype)}, y::Ref{($etype)}, r::UInt)::Nothing renormalize!(z) return z end @@ -359,9 +328,7 @@ for (etype, rtype, mtype, brtype) in ( z.prec = max(0, x.prec - len) z.val = max(0, xval - len) zlen = min(xlen + xval - len, xlen) - ccall((:nmod_poly_shift_right, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - z, x, xlen - zlen) + @ccall libflint.nmod_poly_shift_right(z::Ref{($etype)}, x::Ref{($etype)}, (xlen - zlen)::Int)::Nothing renormalize!(z) end return z @@ -386,9 +353,7 @@ for (etype, rtype, mtype, brtype) in ( x = zero!(x) x.val = k else - ccall((:nmod_poly_truncate, libflint), Nothing, - (Ref{($etype)}, Int), - x, k - valuation(x)) + @ccall libflint.nmod_poly_truncate(x::Ref{($etype)}, (k - valuation(x))::Int)::Nothing end x.prec = k return x @@ -422,9 +387,7 @@ for (etype, rtype, mtype, brtype) in ( z = parent(a)() z.prec = a.prec + (b - 1)*valuation(a) z.val = b*valuation(a) - ccall((:nmod_poly_pow_trunc, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int, Int), - z, a, b, z.prec - z.val) + @ccall libflint.nmod_poly_pow_trunc(z::Ref{($etype)}, a::Ref{($etype)}, b::Int, (z.prec - z.val)::Int)::Nothing end renormalize!(z) return z @@ -450,9 +413,7 @@ for (etype, rtype, mtype, brtype) in ( if xlen != ylen return false end - return Bool(ccall((:nmod_poly_equal_trunc, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}, Int), - x, y, xlen)) + return Bool(@ccall libflint.nmod_poly_equal_trunc(x::Ref{($etype)}, y::Ref{($etype)}, xlen::Int)::Cint) end function isequal(x::($etype), y::($etype)) @@ -462,8 +423,7 @@ for (etype, rtype, mtype, brtype) in ( if x.prec != y.prec || x.val != y.val || pol_length(x) != pol_length(y) return false end - return Bool(ccall((:nmod_poly_equal, libflint), Cint, - (Ref{($etype)}, Ref{($etype)}), x, y)) + return Bool(@ccall libflint.nmod_poly_equal(x::Ref{($etype)}, y::Ref{($etype)})::Cint) end ############################################################################### @@ -479,8 +439,7 @@ for (etype, rtype, mtype, brtype) in ( return false elseif pol_length(x) == 1 if x.val == 0 - z = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{($etype)}, Int), x, 0) + z = @ccall libflint.nmod_poly_get_coeff_ui(x::Ref{($etype)}, 0::Int)::UInt return data(y) == z else return false @@ -499,15 +458,14 @@ for (etype, rtype, mtype, brtype) in ( return false elseif pol_length(x) == 1 if x.val == 0 - r = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), y, modulus(x)) - z = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{($etype)}, Int), x, 0) + r = @ccall libflint.fmpz_fdiv_ui(y::Ref{ZZRingElem}, modulus(x)::UInt)::UInt + z = @ccall libflint.nmod_poly_get_coeff_ui(x::Ref{($etype)}, 0::Int)::UInt return r == z else return false end else - r = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), y, modulus(x)) + r = @ccall libflint.fmpz_fdiv_ui(y::Ref{ZZRingElem}, modulus(x)::UInt)::UInt return r == UInt(0) end end @@ -522,8 +480,7 @@ for (etype, rtype, mtype, brtype) in ( elseif pol_length(x) == 1 if x.val == 0 r = mod(y, modulus(x)) - z = ccall((:nmod_poly_get_coeff_ui, libflint), UInt, - (Ref{($etype)}, Int), x, 0) + z = @ccall libflint.nmod_poly_get_coeff_ui(x::Ref{($etype)}, 0::Int)::UInt return r == z else return false @@ -563,9 +520,7 @@ for (etype, rtype, mtype, brtype) in ( z.val = xval - yval z.prec = prec + z.val if prec != 0 - ccall((:nmod_poly_div_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, x, y, prec) + @ccall libflint.nmod_poly_div_series(z::Ref{($etype)}, x::Ref{($etype)}, y::Ref{($etype)}, prec::Int)::Nothing end return z end @@ -582,9 +537,7 @@ for (etype, rtype, mtype, brtype) in ( z.prec = x.prec z.val = x.val r = inv(y) - ccall((:nmod_poly_scalar_mul_nmod, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt), - z, x, data(r)) + @ccall libflint.nmod_poly_scalar_mul_nmod(z::Ref{($etype)}, x::Ref{($etype)}, data(r)::UInt)::Nothing return z end @@ -594,11 +547,9 @@ for (etype, rtype, mtype, brtype) in ( z.prec = x.prec z.prec = x.prec z.val = x.val - r = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), y, modulus(x)) + r = @ccall libflint.fmpz_fdiv_ui(y::Ref{ZZRingElem}, modulus(x)::UInt)::UInt rinv = inv(base_ring(x)(r)) - ccall((:nmod_poly_scalar_mul_nmod, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt), - z, x, data(rinv)) + @ccall libflint.nmod_poly_scalar_mul_nmod(z::Ref{($etype)}, x::Ref{($etype)}, data(rinv)::UInt)::Nothing return z end @@ -610,9 +561,7 @@ for (etype, rtype, mtype, brtype) in ( z.val = x.val r = mod(y, modulus(x)) rinv = inv(base_ring(x)(r)) - ccall((:nmod_poly_scalar_mul_nmod, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, UInt), - z, x, data(rinv)) + @ccall libflint.nmod_poly_scalar_mul_nmod(z::Ref{($etype)}, x::Ref{($etype)}, data(rinv)::UInt)::Nothing return z end @@ -630,9 +579,7 @@ for (etype, rtype, mtype, brtype) in ( ainv = parent(a)() ainv.prec = a.prec ainv.val = 0 - ccall((:nmod_poly_inv_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - ainv, a, a.prec) + @ccall libflint.nmod_poly_inv_series(ainv::Ref{($etype)}, a::Ref{($etype)}, a.prec::Int)::Nothing return ainv end @@ -680,56 +627,45 @@ for (etype, rtype, mtype, brtype) in ( ############################################################################### function zero!(x::($etype)) - ccall((:nmod_poly_zero, libflint), Nothing, - (Ref{($etype)},), x) + @ccall libflint.nmod_poly_zero(x::Ref{($etype)})::Nothing x.prec = parent(x).prec_max x.val = parent(x).prec_max return x end function one!(x::($etype)) - ccall((:nmod_poly_one, libflint), Nothing, - (Ref{($etype)},), x) + @ccall libflint.nmod_poly_one(x::Ref{($etype)})::Nothing x.prec = parent(x).prec_max x.val = 0 return x end function neg!(z::($etype), x::($etype)) - ccall((:nmod_poly_neg, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}), - z, x) + @ccall libflint.nmod_poly_neg(z::Ref{($etype)}, x::Ref{($etype)})::Nothing z.prec = x.prec z.val = x.val return z end function fit!(x::($etype), n::Int) - ccall((:nmod_poly_fit_length, libflint), Nothing, - (Ref{($etype)}, Int), x, n) + @ccall libflint.nmod_poly_fit_length(x::Ref{($etype)}, n::Int)::Nothing return nothing end function setcoeff!(z::($etype), n::Int, x::ZZRingElem) - r = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), x, modulus(z)) - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{($etype)}, Int, UInt), - z, n, r) + r = @ccall libflint.fmpz_fdiv_ui(x::Ref{ZZRingElem}, modulus(z)::UInt)::UInt + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{($etype)}, n::Int, r::UInt)::Nothing return z end function setcoeff!(z::($etype), n::Int, x::UInt) r = mod(x, modulus(z)) - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{($etype)}, Int, UInt), - z, n, r) + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{($etype)}, n::Int, r::UInt)::Nothing return z end function setcoeff!(z::($etype), n::Int, x::($mtype)) - ccall((:nmod_poly_set_coeff_ui, libflint), Nothing, - (Ref{($etype)}, Int, UInt), - z, n, data(x)) + @ccall libflint.nmod_poly_set_coeff_ui(z::Ref{($etype)}, n::Int, data(x)::UInt)::Nothing return z end @@ -747,9 +683,7 @@ for (etype, rtype, mtype, brtype) in ( if lena <= 0 || lenb <= 0 lenz = 0 end - ccall((:nmod_poly_mullow, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - z, a, b, lenz) + @ccall libflint.nmod_poly_mullow(z::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int)::Nothing renormalize!(z) return z end @@ -769,28 +703,18 @@ for (etype, rtype, mtype, brtype) in ( ccall((:nmod_poly_set_trunc, libflint), Nothing, (Ref{($etype)}, Ref{($etype)}, Int), z, b, max(0, lenz - b.val + a.val)) - ccall((:nmod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - z, z, b.val - a.val) - ccall((:nmod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - a, a, z, lenz) + @ccall libflint.nmod_poly_shift_left(z::Ref{($etype)}, z::Ref{($etype)}, (b.val - a.val)::Int)::Nothing + @ccall libflint.nmod_poly_add_series(a::Ref{($etype)}, a::Ref{($etype)}, z::Ref{($etype)}, lenz::Int)::Nothing elseif b.val < a.val lenz = max(lena + a.val - b.val, lenb) ccall((:nmod_poly_truncate, libflint), Nothing, (Ref{($etype)}, Int), a, max(0, lenz - a.val + b.val)) - ccall((:nmod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - a, a, a.val - b.val) - ccall((:nmod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - a, a, b, lenz) + @ccall libflint.nmod_poly_shift_left(a::Ref{($etype)}, a::Ref{($etype)}, (a.val - b.val)::Int)::Nothing + @ccall libflint.nmod_poly_add_series(a::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int)::Nothing else lenz = max(lena, lenb) - ccall((:nmod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - a, a, b, lenz) + @ccall libflint.nmod_poly_add_series(a::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenz::Int)::Nothing end a.prec = prec a.val = val @@ -815,28 +739,18 @@ for (etype, rtype, mtype, brtype) in ( ccall((:nmod_poly_set_trunc, libflint), Nothing, (Ref{($etype)}, Ref{($etype)}, Int), c, b, max(0, lenc - b.val + a.val)) - ccall((:nmod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - c, c, b.val - a.val) - ccall((:nmod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - c, c, a, lenc) + @ccall libflint.nmod_poly_shift_left(c::Ref{($etype)}, c::Ref{($etype)}, (b.val - a.val)::Int)::Nothing + @ccall libflint.nmod_poly_add_series(c::Ref{($etype)}, c::Ref{($etype)}, a::Ref{($etype)}, lenc::Int)::Nothing elseif b.val < a.val lenc = max(lena + a.val - b.val, lenb) ccall((:nmod_poly_set_trunc, libflint), Nothing, (Ref{($etype)}, Ref{($etype)}, Int), c, a, max(0, lenc - a.val + b.val)) - ccall((:nmod_poly_shift_left, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Int), - c, c, a.val - b.val) - ccall((:nmod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - c, c, b, lenc) + @ccall libflint.nmod_poly_shift_left(c::Ref{($etype)}, c::Ref{($etype)}, (a.val - b.val)::Int)::Nothing + @ccall libflint.nmod_poly_add_series(c::Ref{($etype)}, c::Ref{($etype)}, b::Ref{($etype)}, lenc::Int)::Nothing else lenc = max(lena, lenb) - ccall((:nmod_poly_add_series, libflint), Nothing, - (Ref{($etype)}, Ref{($etype)}, Ref{($etype)}, Int), - c, a, b, lenc) + @ccall libflint.nmod_poly_add_series(c::Ref{($etype)}, a::Ref{($etype)}, b::Ref{($etype)}, lenc::Int)::Nothing end c.prec = prec c.val = val @@ -988,9 +902,7 @@ function sqrt_classical(a::fpRelPowerSeriesRingElem; check::Bool=true) s = sqrt(c; check=check) end a = divexact(a, c) - ccall((:nmod_poly_sqrt_series, libflint), Nothing, - (Ref{fpRelPowerSeriesRingElem}, Ref{fpRelPowerSeriesRingElem}, Int), - z, a, a.prec) + @ccall libflint.nmod_poly_sqrt_series(z::Ref{fpRelPowerSeriesRingElem}, a::Ref{fpRelPowerSeriesRingElem}, a.prec::Int)::Nothing if !isone(s) z *= s end diff --git a/src/flint/padic.jl b/src/flint/padic.jl index 88916bccb..28a4d9b94 100644 --- a/src/flint/padic.jl +++ b/src/flint/padic.jl @@ -104,8 +104,7 @@ end function Base.deepcopy_internal(a::PadicFieldElem, dict::IdDict) z = parent(a)() z.N = a.N # set does not transfer N - neither should it. - ccall((:padic_set, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), z, a, parent(a)) + @ccall libflint.padic_set(z::Ref{PadicFieldElem}, a::Ref{PadicFieldElem}, parent(a)::Ref{PadicField})::Nothing return z end @@ -120,8 +119,7 @@ Return the prime $p$ for the given $p$-adic field. """ function prime(R::PadicField, i::Int = 1) z = ZZRingElem() - ccall((:padic_ctx_pow_ui, libflint), Nothing, - (Ref{ZZRingElem}, Int, Ref{PadicField}), z, i, R) + @ccall libflint.padic_ctx_pow_ui(z::Ref{ZZRingElem}, i::Int, R::Ref{PadicField})::Nothing return z end @@ -150,8 +148,7 @@ Return a lift of the given $p$-adic field element to $\mathbb{Q}$. function lift(R::QQField, a::PadicFieldElem) ctx = parent(a) r = QQFieldElem() - ccall((:padic_get_fmpq, libflint), Nothing, - (Ref{QQFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), r, a, ctx) + @ccall libflint.padic_get_fmpq(r::Ref{QQFieldElem}, a::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Nothing return r end @@ -166,33 +163,29 @@ function lift(R::ZZRing, a::PadicFieldElem) if iszero(a) return r end - ccall((:padic_get_fmpz, libflint), Nothing, - (Ref{ZZRingElem}, Ref{PadicFieldElem}, Ref{PadicField}), r, a, ctx) + @ccall libflint.padic_get_fmpz(r::Ref{ZZRingElem}, a::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Nothing return r end function zero(R::PadicField; precision::Int=precision(R)) z = PadicFieldElem(precision) - ccall((:padic_zero, libflint), Nothing, (Ref{PadicFieldElem},), z) + @ccall libflint.padic_zero(z::Ref{PadicFieldElem})::Nothing z.parent = R return z end function one(R::PadicField; precision::Int=precision(R)) z = PadicFieldElem(precision) - ccall((:padic_one, libflint), Nothing, (Ref{PadicFieldElem},), z) + @ccall libflint.padic_one(z::Ref{PadicFieldElem})::Nothing z.parent = R return z end -iszero(a::PadicFieldElem) = Bool(ccall((:padic_is_zero, libflint), Cint, - (Ref{PadicFieldElem},), a)) +iszero(a::PadicFieldElem) = Bool(@ccall libflint.padic_is_zero(a::Ref{PadicFieldElem})::Cint) -isone(a::PadicFieldElem) = Bool(ccall((:padic_is_one, libflint), Cint, - (Ref{PadicFieldElem},), a)) +isone(a::PadicFieldElem) = Bool(@ccall libflint.padic_is_one(a::Ref{PadicFieldElem})::Cint) -is_unit(a::PadicFieldElem) = !Bool(ccall((:padic_is_zero, libflint), Cint, - (Ref{PadicFieldElem},), a)) +is_unit(a::PadicFieldElem) = !Bool(@ccall libflint.padic_is_zero(a::Ref{PadicFieldElem})::Cint) characteristic(R::PadicField) = 0 @@ -302,9 +295,7 @@ function -(x::PadicFieldElem) end ctx = parent(x) z = PadicFieldElem(x.N) - ccall((:padic_neg, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), - z, x, ctx) + @ccall libflint.padic_neg(z::Ref{PadicFieldElem}, x::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Nothing z.parent = ctx return z end @@ -320,9 +311,7 @@ function +(x::PadicFieldElem, y::PadicFieldElem) ctx = parent(x) z = PadicFieldElem(min(x.N, y.N)) z.parent = ctx - ccall((:padic_add, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), - z, x, y, ctx) + @ccall libflint.padic_add(z::Ref{PadicFieldElem}, x::Ref{PadicFieldElem}, y::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Nothing return z end @@ -331,9 +320,7 @@ function -(x::PadicFieldElem, y::PadicFieldElem) ctx = parent(x) z = PadicFieldElem(min(x.N, y.N)) z.parent = ctx - ccall((:padic_sub, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), - z, x, y, ctx) + @ccall libflint.padic_sub(z::Ref{PadicFieldElem}, x::Ref{PadicFieldElem}, y::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Nothing return z end @@ -342,9 +329,7 @@ function *(x::PadicFieldElem, y::PadicFieldElem) ctx = parent(x) z = PadicFieldElem(min(x.N + y.v, y.N + x.v)) z.parent = ctx - ccall((:padic_mul, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), - z, x, y, ctx) + @ccall libflint.padic_mul(z::Ref{PadicFieldElem}, x::Ref{PadicFieldElem}, y::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Nothing return z end @@ -402,11 +387,8 @@ function ==(a::PadicFieldElem, b::PadicFieldElem) check_parent(a, b) ctx = parent(a) z = PadicFieldElem(min(a.N, b.N)) - ccall((:padic_sub, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), - z, a, b, ctx) - return Bool(ccall((:padic_is_zero, libflint), Cint, - (Ref{PadicFieldElem},), z)) + @ccall libflint.padic_sub(z::Ref{PadicFieldElem}, a::Ref{PadicFieldElem}, b::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Nothing + return Bool(@ccall libflint.padic_is_zero(z::Ref{PadicFieldElem})::Cint) end function isequal(a::PadicFieldElem, b::PadicFieldElem) @@ -444,9 +426,7 @@ function ^(a::PadicFieldElem, n::Int) ctx = parent(a) z = PadicFieldElem(a.N + (n - 1)*a.v) z.parent = ctx - ccall((:padic_pow_si, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Int, Ref{PadicField}), - z, a, n, ctx) + @ccall libflint.padic_pow_si(z::Ref{PadicFieldElem}, a::Ref{PadicFieldElem}, n::Int, ctx::Ref{PadicField})::Nothing return z end @@ -462,9 +442,7 @@ function divexact(a::PadicFieldElem, b::PadicFieldElem; check::Bool=true) ctx = parent(a) z = PadicFieldElem(min(a.N - b.v, b.N - 2*b.v + a.v)) z.parent = ctx - ccall((:padic_div, libflint), Cint, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), - z, a, b, ctx) + @ccall libflint.padic_div(z::Ref{PadicFieldElem}, a::Ref{PadicFieldElem}, b::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Cint return z end @@ -497,8 +475,7 @@ function inv(a::PadicFieldElem) ctx = parent(a) z = PadicFieldElem(a.N - 2*a.v) z.parent = ctx - ccall((:padic_inv, libflint), Cint, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), z, a, ctx) + @ccall libflint.padic_inv(z::Ref{PadicFieldElem}, a::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Cint return z end @@ -545,8 +522,7 @@ function Base.sqrt(a::PadicFieldElem; check::Bool=true) ctx = parent(a) z = PadicFieldElem(a.N - div(a.v, 2)) z.parent = ctx - res = Bool(ccall((:padic_sqrt, libflint), Cint, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), z, a, ctx)) + res = Bool(@ccall libflint.padic_sqrt(z::Ref{PadicFieldElem}, a::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Cint) check && !res && error("Square root of p-adic does not exist") return z end @@ -560,15 +536,14 @@ function is_square(a::PadicFieldElem) end R = parent(a) u = ZZRingElem() - ccall((:padic_get_unit, libflint), Nothing, - (Ref{ZZRingElem}, Ref{PadicFieldElem}), u, a) + @ccall libflint.padic_get_unit(u::Ref{ZZRingElem}, a::Ref{PadicFieldElem})::Nothing p = prime(R) if p == 2 umod = mod(u, 8) return umod == 1 else umod = mod(u, p) - r = ccall((:n_jacobi, libflint), Cint, (UInt, UInt), umod, p) + r = @ccall libflint.n_jacobi(umod::UInt, p::UInt)::Cint return isone(r) end end @@ -581,8 +556,7 @@ function is_square_with_sqrt(a::PadicFieldElem) ctx = parent(a) z = PadicFieldElem(a.N - div(a.v, 2)) z.parent = ctx - res = Bool(ccall((:padic_sqrt, libflint), Cint, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), z, a, ctx)) + res = Bool(@ccall libflint.padic_sqrt(z::Ref{PadicFieldElem}, a::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Cint) if !res return false, zero(R) end @@ -606,8 +580,7 @@ function Base.exp(a::PadicFieldElem) ctx = parent(a) z = PadicFieldElem(a.N) z.parent = ctx - res = Bool(ccall((:padic_exp, libflint), Cint, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), z, a, ctx)) + res = Bool(@ccall libflint.padic_exp(z::Ref{PadicFieldElem}, a::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Cint) !res && error("Unable to compute exponential") return z end @@ -628,8 +601,7 @@ function log(a::PadicFieldElem) if v == 0 a = a^(prime(ctx)-1) end - res = Bool(ccall((:padic_log, libflint), Cint, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), z, a, ctx)) + res = Bool(@ccall libflint.padic_log(z::Ref{PadicFieldElem}, a::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Cint) !res && error("Unable to compute logarithm") if v == 0 z = z//(prime(ctx)-1) @@ -651,8 +623,7 @@ function teichmuller(a::PadicFieldElem) ctx = parent(a) z = PadicFieldElem(a.N) z.parent = ctx - ccall((:padic_teichmuller, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), z, a, ctx) + @ccall libflint.padic_teichmuller(z::Ref{PadicFieldElem}, a::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Nothing return z end @@ -665,26 +636,21 @@ end function zero!(z::PadicFieldElem; precision::Int=precision(parent(z))) z.N = precision ctx = parent(z) - ccall((:padic_zero, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{PadicField}), z, ctx) + @ccall libflint.padic_zero(z::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Nothing return z end function mul!(z::PadicFieldElem, x::PadicFieldElem, y::PadicFieldElem) z.N = min(x.N + y.v, y.N + x.v) ctx = parent(x) - ccall((:padic_mul, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), - z, x, y, ctx) + @ccall libflint.padic_mul(z::Ref{PadicFieldElem}, x::Ref{PadicFieldElem}, y::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Nothing return z end function add!(z::PadicFieldElem, x::PadicFieldElem, y::PadicFieldElem) z.N = min(x.N, y.N) ctx = parent(x) - ccall((:padic_add, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), - z, x, y, ctx) + @ccall libflint.padic_add(z::Ref{PadicFieldElem}, x::Ref{PadicFieldElem}, y::Ref{PadicFieldElem}, ctx::Ref{PadicField})::Nothing return z end @@ -720,8 +686,7 @@ function (R::PadicField)(n::ZZRingElem; precision::Int=precision(R)) N, = remove(n, p) end z = PadicFieldElem(N + precision) - ccall((:padic_set_fmpz, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{ZZRingElem}, Ref{PadicField}), z, n, R) + @ccall libflint.padic_set_fmpz(z::Ref{PadicFieldElem}, n::Ref{ZZRingElem}, R::Ref{PadicField})::Nothing z.parent = R return z end @@ -738,8 +703,7 @@ function (R::PadicField)(n::QQFieldElem; precision::Int=precision(R)) N = -remove(m, p)[1] end z = PadicFieldElem(N + precision) - ccall((:padic_set_fmpq, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{QQFieldElem}, Ref{PadicField}), z, n, R) + @ccall libflint.padic_set_fmpq(z::Ref{PadicFieldElem}, n::Ref{QQFieldElem}, R::Ref{PadicField})::Nothing z.parent = R return z end @@ -790,13 +754,13 @@ Base.precision(Q::PadicField) = Q.prec_max function Base.setprecision(q::PadicFieldElem, N::Int) r = parent(q)() r.N = N - ccall((:padic_set, libflint), Nothing, (Ref{PadicFieldElem}, Ref{PadicFieldElem}, Ref{PadicField}), r, q, parent(q)) + @ccall libflint.padic_set(r::Ref{PadicFieldElem}, q::Ref{PadicFieldElem}, parent(q)::Ref{PadicField})::Nothing return r end function setprecision!(a::PadicFieldElem, n::Int) a.N = n - ccall((:padic_reduce, libflint), Nothing, (Ref{PadicFieldElem}, Ref{PadicField}), a, parent(a)) + @ccall libflint.padic_reduce(a::Ref{PadicFieldElem}, parent(a)::Ref{PadicField})::Nothing return a end diff --git a/src/flint/qadic.jl b/src/flint/qadic.jl index 090d9b5d8..3e728b54e 100644 --- a/src/flint/qadic.jl +++ b/src/flint/qadic.jl @@ -81,8 +81,7 @@ parent_type(::Type{QadicFieldElem}) = QadicField function _prime(R::QadicField, n::Int = 1) z = ZZRingElem() - ccall((:padic_ctx_pow_ui, libflint), Nothing, - (Ref{ZZRingElem}, UInt, Ref{QadicField}), z, n, R) + @ccall libflint.padic_ctx_pow_ui(z::Ref{ZZRingElem}, n::UInt, R::Ref{QadicField})::Nothing return z end @@ -104,8 +103,7 @@ end function Base.deepcopy_internal(a::QadicFieldElem, dict::IdDict{Any, Any}) z = parent(a)() z.N = a.N - ccall((:qadic_set, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), z, a, parent(a)) + @ccall libflint.qadic_set(z::Ref{QadicFieldElem}, a::Ref{QadicFieldElem}, parent(a)::Ref{QadicField})::Nothing return z end @@ -115,7 +113,7 @@ function Base.hash(a::QadicFieldElem, h::UInt) end function degree(R::QadicField) - return ccall((:qadic_ctx_degree, libflint), Int, (Ref{QadicField}, ), R) + return @ccall libflint.qadic_ctx_degree(R::Ref{QadicField})::Int end @doc raw""" @@ -125,8 +123,7 @@ Return the prime $p$ for the given $q$-adic field. """ function prime(R::QadicField) z = ZZRingElem() - ccall((:padic_ctx_pow_ui, libflint), Nothing, - (Ref{ZZRingElem}, UInt, Ref{QadicField}), z, 1, R) + @ccall libflint.padic_ctx_pow_ui(z::Ref{ZZRingElem}, 1::UInt, R::Ref{QadicField})::Nothing return z end @@ -146,7 +143,7 @@ element is divisible by $p^n$ but not a higher power of $q$ then the function will return $n$. """ function valuation(a::QadicFieldElem) - iszero(a) ? precision(a) : ccall((:qadic_val, libflint), Int, (Ref{QadicFieldElem}, ), a) + iszero(a) ? precision(a) : @ccall libflint.qadic_val(a::Ref{QadicFieldElem})::Int end @doc raw""" @@ -157,8 +154,7 @@ Return a lift of the given $q$-adic field element to $\mathbb{Q}[x]$. function lift(R::QQPolyRing, a::QadicFieldElem) ctx = parent(a) r = R() - ccall((:padic_poly_get_fmpq_poly, libflint), Nothing, - (Ref{QQPolyRingElem}, Ref{QadicFieldElem}, Ref{QadicField}), r, a, ctx) + @ccall libflint.padic_poly_get_fmpq_poly(r::Ref{QQPolyRingElem}, a::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Nothing return r end @@ -170,34 +166,30 @@ Return a lift of the given $q$-adic field element to $\mathbb{Z}[x]$ if possible function lift(R::ZZPolyRing, a::QadicFieldElem) ctx = parent(a) r = R() - res = Bool(ccall((:padic_poly_get_fmpz_poly, libflint), Cint, - (Ref{ZZPolyRingElem}, Ref{QadicFieldElem}, Ref{QadicField}), r, a, ctx)) + res = Bool(@ccall libflint.padic_poly_get_fmpz_poly(r::Ref{ZZPolyRingElem}, a::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Cint) !res && error("Unable to lift") return r end function zero(R::QadicField; precision::Int=precision(R)) z = QadicFieldElem(precision) - ccall((:qadic_zero, libflint), Nothing, (Ref{QadicFieldElem},), z) + @ccall libflint.qadic_zero(z::Ref{QadicFieldElem})::Nothing z.parent = R return z end function one(R::QadicField; precision::Int=precision(R)) z = QadicFieldElem(precision) - ccall((:qadic_one, libflint), Nothing, (Ref{QadicFieldElem},), z) + @ccall libflint.qadic_one(z::Ref{QadicFieldElem})::Nothing z.parent = R return z end -iszero(a::QadicFieldElem) = Bool(ccall((:qadic_is_zero, libflint), Cint, - (Ref{QadicFieldElem},), a)) +iszero(a::QadicFieldElem) = Bool(@ccall libflint.qadic_is_zero(a::Ref{QadicFieldElem})::Cint) -isone(a::QadicFieldElem) = Bool(ccall((:qadic_is_one, libflint), Cint, - (Ref{QadicFieldElem},), a)) +isone(a::QadicFieldElem) = Bool(@ccall libflint.qadic_is_one(a::Ref{QadicFieldElem})::Cint) -is_unit(a::QadicFieldElem) = !Bool(ccall((:qadic_is_zero, libflint), Cint, - (Ref{QadicFieldElem},), a)) +is_unit(a::QadicFieldElem) = !Bool(@ccall libflint.qadic_is_zero(a::Ref{QadicFieldElem})::Cint) characteristic(R::QadicField) = 0 @@ -231,9 +223,7 @@ function expressify(b::QadicFieldElem, x = var(parent(b)); context = nothing) sum = Expr(:call, :+) c = R(precision = precision(parent(b))) for i in degree(parent(b)):-1:0 - ccall((:padic_poly_get_coeff_padic, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{QadicFieldElem}, Int, Ref{QadicField}), - c, b, i, parent(b)) + @ccall libflint.padic_poly_get_coeff_padic(c::Ref{PadicFieldElem}, b::Ref{QadicFieldElem}, i::Int, parent(b)::Ref{QadicField})::Nothing ec = expressify(c, context = context) if !iszero(c) if iszero(i) @@ -283,9 +273,7 @@ function -(x::QadicFieldElem) end ctx = parent(x) z = QadicFieldElem(x.N) - ccall((:qadic_neg, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), - z, x, ctx) + @ccall libflint.qadic_neg(z::Ref{QadicFieldElem}, x::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Nothing z.parent = ctx return z end @@ -301,9 +289,7 @@ function +(x::QadicFieldElem, y::QadicFieldElem) ctx = parent(x) z = QadicFieldElem(min(x.N, y.N)) z.parent = ctx - ccall((:qadic_add, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), - z, x, y, ctx) + @ccall libflint.qadic_add(z::Ref{QadicFieldElem}, x::Ref{QadicFieldElem}, y::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Nothing return z end @@ -312,9 +298,7 @@ function -(x::QadicFieldElem, y::QadicFieldElem) ctx = parent(x) z = QadicFieldElem(min(x.N, y.N)) z.parent = ctx - ccall((:qadic_sub, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), - z, x, y, ctx) + @ccall libflint.qadic_sub(z::Ref{QadicFieldElem}, x::Ref{QadicFieldElem}, y::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Nothing return z end @@ -323,9 +307,7 @@ function *(x::QadicFieldElem, y::QadicFieldElem) ctx = parent(x) z = QadicFieldElem(min(x.N + valuation(y), y.N + valuation(x))) z.parent = ctx - ccall((:qadic_mul, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), - z, x, y, ctx) + @ccall libflint.qadic_mul(z::Ref{QadicFieldElem}, x::Ref{QadicFieldElem}, y::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Nothing return z end @@ -391,11 +373,8 @@ function ==(a::QadicFieldElem, b::QadicFieldElem) check_parent(a, b) ctx = parent(a) z = QadicFieldElem(min(a.N, b.N)) - ccall((:qadic_sub, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), - z, a, b, ctx) - return Bool(ccall((:qadic_is_zero, libflint), Cint, - (Ref{QadicFieldElem},), z)) + @ccall libflint.qadic_sub(z::Ref{QadicFieldElem}, a::Ref{QadicFieldElem}, b::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Nothing + return Bool(@ccall libflint.qadic_is_zero(z::Ref{QadicFieldElem})::Cint) end function isequal(a::QadicFieldElem, b::QadicFieldElem) @@ -442,9 +421,7 @@ function ^(a::QadicFieldElem, n::ZZRingElem) z = QadicFieldElem(a.N + (Int(n) - 1)*valuation(a)) end z.parent = ctx - ccall((:qadic_pow, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{ZZRingElem}, Ref{QadicField}), - z, a, n, ctx) + @ccall libflint.qadic_pow(z::Ref{QadicFieldElem}, a::Ref{QadicFieldElem}, n::Ref{ZZRingElem}, ctx::Ref{QadicField})::Nothing return z end @@ -488,8 +465,7 @@ function inv(a::QadicFieldElem) ctx = parent(a) z = QadicFieldElem(a.N - 2*valuation(a)) z.parent = ctx - ccall((:qadic_inv, libflint), Cint, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), z, a, ctx) + @ccall libflint.qadic_inv(z::Ref{QadicFieldElem}, a::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Cint return z end @@ -537,8 +513,7 @@ function Base.sqrt(a::QadicFieldElem; check::Bool=true) ctx = parent(a) z = QadicFieldElem(a.N - div(av, 2)) z.parent = ctx - res = Bool(ccall((:qadic_sqrt, libflint), Cint, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), z, a, ctx)) + res = Bool(@ccall libflint.qadic_sqrt(z::Ref{QadicFieldElem}, a::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Cint) check && !res && error("Square root of p-adic does not exist") return z end @@ -560,8 +535,7 @@ function Base.exp(a::QadicFieldElem) ctx = parent(a) z = QadicFieldElem(a.N) z.parent = ctx - res = Bool(ccall((:qadic_exp, libflint), Cint, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), z, a, ctx)) + res = Bool(@ccall libflint.qadic_exp(z::Ref{QadicFieldElem}, a::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Cint) !res && error("Unable to compute exponential") return z end @@ -585,8 +559,7 @@ function log(a::QadicFieldElem) ctx = parent(a) z = QadicFieldElem(a.N) z.parent = ctx - res = Bool(ccall((:qadic_log, libflint), Cint, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), z, a, ctx)) + res = Bool(@ccall libflint.qadic_log(z::Ref{QadicFieldElem}, a::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Cint) !res && error("Unable to compute logarithm") if av == 0 z = divexact(z, qm1) @@ -608,8 +581,7 @@ function teichmuller(a::QadicFieldElem) ctx = parent(a) z = QadicFieldElem(a.N) z.parent = ctx - ccall((:qadic_teichmuller, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), z, a, ctx) + @ccall libflint.qadic_teichmuller(z::Ref{QadicFieldElem}, a::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Nothing return z end @@ -623,8 +595,7 @@ function frobenius(a::QadicFieldElem, e::Int = 1) ctx = parent(a) z = QadicFieldElem(a.N) z.parent = ctx - ccall((:qadic_frobenius, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Int, Ref{QadicField}), z, a, e, ctx) + @ccall libflint.qadic_frobenius(z::Ref{QadicFieldElem}, a::Ref{QadicFieldElem}, e::Int, ctx::Ref{QadicField})::Nothing return z end @@ -637,26 +608,21 @@ end function zero!(z::QadicFieldElem; precision::Int=precision(parent(z))) z.N = precision ctx = parent(z) - ccall((:qadic_zero, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicField}), z, ctx) + @ccall libflint.qadic_zero(z::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Nothing return z end function mul!(z::QadicFieldElem, x::QadicFieldElem, y::QadicFieldElem) z.N = min(x.N + valuation(y), y.N + valuation(x)) ctx = parent(x) - ccall((:qadic_mul, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), - z, x, y, ctx) + @ccall libflint.qadic_mul(z::Ref{QadicFieldElem}, x::Ref{QadicFieldElem}, y::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Nothing return z end function add!(z::QadicFieldElem, x::QadicFieldElem, y::QadicFieldElem) z.N = min(x.N, y.N) ctx = parent(x) - ccall((:qadic_add, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), - z, x, y, ctx) + @ccall libflint.qadic_add(z::Ref{QadicFieldElem}, x::Ref{QadicFieldElem}, y::Ref{QadicFieldElem}, ctx::Ref{QadicField})::Nothing return z end @@ -668,13 +634,13 @@ end function tr(r::QadicFieldElem) t = base_field(parent(r))() - ccall((:qadic_trace, libflint), Nothing, (Ref{PadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), t, r, parent(r)) + @ccall libflint.qadic_trace(t::Ref{PadicFieldElem}, r::Ref{QadicFieldElem}, parent(r)::Ref{QadicField})::Nothing return t end function norm(r::QadicFieldElem) t = base_field(parent(r))() - ccall((:qadic_norm, libflint), Nothing, (Ref{PadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), t, r, parent(r)) + @ccall libflint.qadic_norm(t::Ref{PadicFieldElem}, r::Ref{QadicFieldElem}, parent(r)::Ref{QadicField})::Nothing return t end @@ -708,8 +674,7 @@ end function gen(R::QadicField; precision::Int=precision(R)) z = QadicFieldElem(precision) - ccall((:qadic_gen, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QadicField}), z, R) + @ccall libflint.qadic_gen(z::Ref{QadicFieldElem}, R::Ref{QadicField})::Nothing z.parent = R return z end @@ -722,8 +687,7 @@ function (R::QadicField)(a::UInt; precision::Int=precision(R)) end v = valuation(a, prime(R)) z = QadicFieldElem(precision + v) - ccall((:qadic_set_ui, libflint), Nothing, - (Ref{QadicFieldElem}, UInt, Ref{QadicField}), z, a, R) + @ccall libflint.qadic_set_ui(z::Ref{QadicFieldElem}, a::UInt, R::Ref{QadicField})::Nothing z.parent = R return z end @@ -736,8 +700,7 @@ function (R::QadicField)(a::Int; precision::Int=precision(R)) end v = valuation(a, prime(R)) z = QadicFieldElem(precision + v) - ccall((:padic_poly_set_si, libflint), Nothing, - (Ref{QadicFieldElem}, Int, Ref{QadicField}), z,a, R) + @ccall libflint.padic_poly_set_si(z::Ref{QadicFieldElem}, a::Int, R::Ref{QadicField})::Nothing z.parent = R return z end @@ -750,8 +713,7 @@ function (R::QadicField)(n::ZZRingElem; precision::Int=precision(R)) N = valuation(n, p) end z = QadicFieldElem(N + precision) - ccall((:padic_poly_set_fmpz, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{ZZRingElem}, Ref{QadicField}), z, n, R) + @ccall libflint.padic_poly_set_fmpz(z::Ref{QadicFieldElem}, n::Ref{ZZRingElem}, R::Ref{QadicField})::Nothing z.parent = R return z end @@ -768,16 +730,14 @@ function (R::QadicField)(n::QQFieldElem; precision::Int=precision(R)) N = -remove(m, p)[1] end z = QadicFieldElem(N + precision) - ccall((:padic_poly_set_fmpq, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QQFieldElem}, Ref{QadicField}), z, n, R) + @ccall libflint.padic_poly_set_fmpq(z::Ref{QadicFieldElem}, n::Ref{QQFieldElem}, R::Ref{QadicField})::Nothing z.parent = R return z end function (R::QadicField)(n::ZZPolyRingElem; precision::Int=precision(R)) z = QadicFieldElem(precision) - ccall((:qadic_set_fmpz_poly, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{ZZPolyRingElem}, Ref{QadicField}), z, n, R) + @ccall libflint.qadic_set_fmpz_poly(z::Ref{QadicFieldElem}, n::Ref{ZZPolyRingElem}, R::Ref{QadicField})::Nothing z.parent = R return z end @@ -795,8 +755,7 @@ function (R::QadicField)(n::QQPolyRingElem; precision::Int=precision(R)) N = -remove(m, p)[1] end z = QadicFieldElem(N + precision) - ccall((:padic_poly_set_fmpq_poly, libflint), Nothing, - (Ref{QadicFieldElem}, Ref{QQPolyRingElem}, Ref{QadicField}), z, n, R) + @ccall libflint.padic_poly_set_fmpq_poly(z::Ref{QadicFieldElem}, n::Ref{QQPolyRingElem}, R::Ref{QadicField})::Nothing z.parent = R return z end @@ -825,8 +784,7 @@ function (Rx::Generic.PolyRing{PadicFieldElem})(a::QadicFieldElem) coeffs = Vector{PadicFieldElem}(undef, degree(Qq)) for i = 1:length(coeffs) c = R() - ccall((:padic_poly_get_coeff_padic, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{QadicFieldElem}, Int, Ref{QadicField}), c, a, i - 1, parent(a)) + @ccall libflint.padic_poly_get_coeff_padic(c::Ref{PadicFieldElem}, a::Ref{QadicFieldElem}, (i - 1)::Int, parent(a)::Ref{QadicField})::Nothing coeffs[i] = c end return Rx(coeffs) @@ -835,14 +793,12 @@ end function coeff(x::QadicFieldElem, i::Int) R = base_field(parent(x)) c = R() - ccall((:padic_poly_get_coeff_padic, libflint), Nothing, - (Ref{PadicFieldElem}, Ref{QadicFieldElem}, Int, Ref{QadicField}), c, x, i, parent(x)) + @ccall libflint.padic_poly_get_coeff_padic(c::Ref{PadicFieldElem}, x::Ref{QadicFieldElem}, i::Int, parent(x)::Ref{QadicField})::Nothing return c end function setcoeff!(x::QadicFieldElem, i::Int, y::PadicFieldElem) - ccall((:padic_poly_set_coeff_padic, libflint), Nothing, - (Ref{QadicFieldElem}, Int, Ref{PadicFieldElem}, Ref{QadicField}), x, i, y, parent(x)) + @ccall libflint.padic_poly_set_coeff_padic(x::Ref{QadicFieldElem}, i::Int, y::Ref{PadicFieldElem}, parent(x)::Ref{QadicField})::Nothing end function setcoeff!(x::QadicFieldElem, i::Int, y::UInt) @@ -852,8 +808,7 @@ end function setcoeff!(x::QadicFieldElem, i::Int, y::ZZRingElem) R = base_field(parent(x)) Y = R(ZZRingElem(y)) - ccall((:padic_poly_set_coeff_padic, libflint), Nothing, - (Ref{QadicFieldElem}, Int, Ref{PadicFieldElem}, Ref{QadicField}), x, i, Y, parent(x)) + @ccall libflint.padic_poly_set_coeff_padic(x::Ref{QadicFieldElem}, i::Int, Y::Ref{PadicFieldElem}, parent(x)::Ref{QadicField})::Nothing end Base.length(a::QadicFieldElem) = a.length @@ -915,13 +870,13 @@ precision(Q::QadicField) = Q.prec_max function Base.setprecision(q::QadicFieldElem, N::Int) r = parent(q)() r.N = N - ccall((:padic_poly_set, libflint), Nothing, (Ref{QadicFieldElem}, Ref{QadicFieldElem}, Ref{QadicField}), r, q, parent(q)) + @ccall libflint.padic_poly_set(r::Ref{QadicFieldElem}, q::Ref{QadicFieldElem}, parent(q)::Ref{QadicField})::Nothing return r end function setprecision!(q::QadicFieldElem, N::Int) q.N = N - ccall((:qadic_reduce, libflint), Nothing, (Ref{QadicFieldElem}, Ref{QadicField}), q, parent(q)) + @ccall libflint.qadic_reduce(q::Ref{QadicFieldElem}, parent(q)::Ref{QadicField})::Nothing return q end diff --git a/src/gaussiannumbers/QQi.jl b/src/gaussiannumbers/QQi.jl index 7db55cafe..5406ae2bc 100644 --- a/src/gaussiannumbers/QQi.jl +++ b/src/gaussiannumbers/QQi.jl @@ -236,9 +236,7 @@ end function reduce!(z::QQiFieldElem) g = ZZRingElem() - ccall((:fmpz_gcd3, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), - g, z.num.x, z.den, z.num.y) + @ccall libflint.fmpz_gcd3(g::Ref{ZZRingElem}, z.num.x::Ref{ZZRingElem}, z.den::Ref{ZZRingElem}, z.num.y::Ref{ZZRingElem})::Nothing if is_negative(z.den) neg!(g, g) end diff --git a/src/gaussiannumbers/ZZi.jl b/src/gaussiannumbers/ZZi.jl index e3a707efc..7486d2c7f 100644 --- a/src/gaussiannumbers/ZZi.jl +++ b/src/gaussiannumbers/ZZi.jl @@ -558,9 +558,7 @@ function sqr!(z::ZZiRingElem, a::ZZiRingElem, t::ZZiRingElem) else mul!(z.y, a.x, a.y) sub!(z.x, t.x, t.y) - ccall((:fmpz_mul_2exp, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), - z.y, z.y, 1) + @ccall libflint.fmpz_mul_2exp(z.y::Ref{ZZRingElem}, z.y::Ref{ZZRingElem}, 1::UInt)::Nothing end return z end @@ -664,8 +662,7 @@ end function smod(a::ZZRingElem, b::ZZRingElem) z = ZZRingElem() - ccall((:fmpz_smod, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}), z, a, b) + @ccall libflint.fmpz_smod(z::Ref{ZZRingElem}, a::Ref{ZZRingElem}, b::Ref{ZZRingElem})::Nothing return z end diff --git a/src/gaussiannumbers/continued_fraction.jl b/src/gaussiannumbers/continued_fraction.jl index 1c5c5d101..b43ad91c0 100644 --- a/src/gaussiannumbers/continued_fraction.jl +++ b/src/gaussiannumbers/continued_fraction.jl @@ -37,16 +37,12 @@ end function copy_data(a::ZZRingElem) z = Ref(0) - ccall((:fmpz_init_set, libflint), Nothing, - (Ref{Int}, Ref{ZZRingElem}), - z, a) + @ccall libflint.fmpz_init_set(z::Ref{Int}, a::Ref{ZZRingElem})::Nothing return z[] end function shift_right!(z::ZZRingElem, a::ZZRingElem, b::Union{Int, UInt}) - ccall((:fmpz_fdiv_q_2exp, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, UInt), - z, a, UInt(b)) + @ccall libflint.fmpz_fdiv_q_2exp(z::Ref{ZZRingElem}, a::Ref{ZZRingElem}, UInt(b)::UInt)::Nothing return z end @@ -78,9 +74,7 @@ function _shortest_l_infinity(c::ZZRingElem, b::ZZRingElem, a::ZZRingElem) # will cleanup x while stealing its enties later x = _fmpq_ball(copy_data(a), steal_data!(b_plus_c), copy_data(a), steal_data!(b_minus_c), 0) - ccall((:_fmpq_ball_get_cfrac, libflint), Nothing, - (Ref{_fmpq_cfrac_list}, Ref{_fmpz_mat22}, Cint, Ref{_fmpq_ball}), - s, m, 1, x) + @ccall libflint._fmpq_ball_get_cfrac(s::Ref{_fmpq_cfrac_list}, m::Ref{_fmpz_mat22}, 1::Cint, x::Ref{_fmpq_ball})::Nothing m11 = steal_fmpz_data(m._11) m12 = steal_fmpz_data(m._12) @@ -176,9 +170,9 @@ function _push_and_clear!(v::Vector{ZZRingElem}, s::_fmpq_cfrac_list) push!(v, steal_fmpz_data(unsafe_load(s.array, i))) end for i in s.length:s.alloc-1 - ccall((:fmpz_clear, libflint), Nothing, (Ptr{Int},), s.array + sizeof(Int)*i) + @ccall libflint.fmpz_clear((s.array + sizeof(Int)*i)::Ptr{Int})::Nothing end - ccall((:flint_free, libflint), Nothing, (Ptr{Int},), s.array) + @ccall libflint.flint_free(s.array::Ptr{Int})::Nothing end function _doit_exact!(xn::ZZRingElem, xd::ZZRingElem, v::Vector{ZZRingElem}, lim::Int, wantM::Bool) @@ -187,9 +181,7 @@ function _doit_exact!(xn::ZZRingElem, xd::ZZRingElem, v::Vector{ZZRingElem}, lim m = _fmpz_mat22(1,0,0,1,1) if ok s = _fmpq_cfrac_list(C_NULL, 0, 0, lim, 0, 0) - ccall((:_fmpq_ball_get_cfrac, libflint), Nothing, - (Ref{_fmpq_cfrac_list}, Ref{_fmpz_mat22}, Cint, Ref{_fmpq_ball}), - s, m, wantM, x) + @ccall libflint._fmpq_ball_get_cfrac(s::Ref{_fmpq_cfrac_list}, m::Ref{_fmpz_mat22}, wantM::Cint, x::Ref{_fmpq_ball})::Nothing _push_and_clear!(v, s) end xn.d = x.left_num; x.left_num = 0 @@ -242,9 +234,7 @@ function _doit_ball!( steal_data!(xrn), steal_data!(xrd), 0) m = _fmpz_mat22(1,0,0,1,1) s = _fmpq_cfrac_list(C_NULL, 0, 0, lim, 0, 0) - ccall((:_fmpq_ball_get_cfrac, libflint), Nothing, - (Ref{_fmpq_cfrac_list}, Ref{_fmpz_mat22}, Cint, Ref{_fmpq_ball}), - s, m, wantM, x) + @ccall libflint._fmpq_ball_get_cfrac(s::Ref{_fmpq_cfrac_list}, m::Ref{_fmpz_mat22}, wantM::Cint, x::Ref{_fmpq_ball})::Nothing _push_and_clear!(v, s) xln.d = x.left_num; x.left_num = 0 xld.d = x.left_den; x.left_den = 0 @@ -301,9 +291,7 @@ function _left_and_right(x::ArbFieldElem) a = ZZRingElem() b = ZZRingElem() f = ZZRingElem() - ccall((:arb_get_interval_fmpz_2exp, libflint), Nothing, - (Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ZZRingElem}, Ref{ArbFieldElem}), - a, b, f, x) + @ccall libflint.arb_get_interval_fmpz_2exp(a::Ref{ZZRingElem}, b::Ref{ZZRingElem}, f::Ref{ZZRingElem}, x::Ref{ArbFieldElem})::Nothing fits(Int, f) || error("Ball endpoints do not fit into QQFieldElem") e = Int(f) if f >= 0 diff --git a/src/julia/Integer.jl b/src/julia/Integer.jl index 99c9912a3..ee2204fa7 100644 --- a/src/julia/Integer.jl +++ b/src/julia/Integer.jl @@ -11,7 +11,7 @@ function next_prime(x::T, proved::Bool=true) where {T<:Integer} end function valuation(a::UInt, b::UInt) - return ccall((:n_remove, libflint), Int, (Ref{UInt}, UInt), a, b) + return @ccall libflint.n_remove(a::Ref{UInt}, b::UInt)::Int end fits(::Type{Int}, a::Int) = true