Skip to content

Commit

Permalink
Update FLINT_jll (#1568)
Browse files Browse the repository at this point in the history
* Change FLINT dependency from 2.9 to 3.1

This includes:

* Reduce size of fq_default_ctx_struct to match the synonymous
  gr_ctx_struct.
* Adjust for FLINT 3.1 fq_nmod where ulongs are now encouraged within
  this module.
* Adjust for FLINT 3.1 fmpz_mod_mat changes where context objects should
  be part of the argument.
* Replace libantic, libarb, libcalcium by libflint
* Return fq_nmod prime as fmpz
* remove some old hack
  • Loading branch information
albinahlback committed May 4, 2024
1 parent c70d9a2 commit e76cdb3
Show file tree
Hide file tree
Showing 40 changed files with 1,963 additions and 1,979 deletions.
8 changes: 1 addition & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ version = "0.44.0"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
Antic_jll = "e21ec000-9f72-519e-ba6d-10061e575a27"
Arb_jll = "d9960996-1013-53c9-9ba4-74a4155039c3"
Calcium_jll = "fcfa6d1b-d8ce-59d5-8c0a-c0d7f69e4f40"
FLINT_jll = "e134572f-a0d5-539d-bddf-3cad8db41a82"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -17,10 +14,7 @@ SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[compat]
AbstractAlgebra = "0.41.0"
Antic_jll = "~0.201.500"
Arb_jll = "~200.2300.000"
Calcium_jll = "~0.401.100"
FLINT_jll = "^200.900.006"
FLINT_jll = "^300.100.100"
Libdl = "1.6"
LinearAlgebra = "1.6"
Pkg = "1.6"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ The official Nemo repository is at:

Nemo currently provides:

* Wrappers of MPIR, Flint, Arb and Antic
* Wrappers of [FLINT](https://flintlib.org/) (now also containing the previous projects Arb and Antic)
* Generic polynomial rings, matrix spaces, fraction fields, residue rings, power series
* finite fields, p-adics, integers, rationals, permutations and characters, number fields
12 changes: 3 additions & 9 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,13 @@ julia> @time divexact((u*exp(x*u)), (exp(u)-1));

## Building dependencies from source

Nemo depends on various C libraries which are installed using binaries by default.
With julia version >= 1.3, the use of these binaries can be overridden by putting the following into the file `~/.julia/artifacts/Overrides.toml`:
Nemo depends on the FLINT C library which is installed using binaries by
default. With Julia version >= 1.3, the use of this binary can be overridden by
putting the following into the file `~/.julia/artifacts/Overrides.toml`:
```toml
[e134572f-a0d5-539d-bddf-3cad8db41a82]
FLINT = "/prefix/for/libflint"

[d9960996-1013-53c9-9ba4-74a4155039c3]
Arb = "/prefix/for/libarb"

[e21ec000-9f72-519e-ba6d-10061e575a27]
Antic = "/prefix/for/libantic"
```
(If only a specific library should be overridden, only the specific entry should be added.)

## Experimental threading support for flint

Expand Down
36 changes: 18 additions & 18 deletions src/HeckeMoreStuff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function _acb_mat(A::ArbMatrix)
end

function mul!(z::AcbFieldElem, x::AcbFieldElem, y::ArbFieldElem)
ccall((:acb_mul_arb, libarb), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{ArbFieldElem}, Int),
ccall((:acb_mul_arb, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{ArbFieldElem}, Int),
z, x, y, parent(z).prec)
return z
end
Expand Down Expand Up @@ -350,7 +350,7 @@ end

function Base.:(^)(a::AbsSimpleNumFieldElem, e::UInt)
b = parent(a)()
ccall((:nf_elem_pow, libantic), Nothing,
ccall((:nf_elem_pow, libflint), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, UInt, Ref{AbsSimpleNumField}),
b, a, e, parent(a))
return b
Expand Down Expand Up @@ -416,7 +416,7 @@ function (R::FqPolyRing)(g::QQPolyRingElem)
end

function bits(x::ArbFieldElem)
return ccall((:arb_bits, libarb), Int, (Ref{ArbFieldElem},), x)
return ccall((:arb_bits, libflint), Int, (Ref{ArbFieldElem},), x)
end

function *(a::ZZMatrix, b::Matrix{BigFloat})
Expand Down Expand Up @@ -498,7 +498,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, libantic), Nothing,
ccall((:nf_elem_mod_fmpz, libflint), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}),
a, a, b, parent(a))
return a
Expand All @@ -514,15 +514,15 @@ This function returns $b$.
function numerator(a::AbsSimpleNumFieldElem)
_one = one(ZZ)
z = deepcopy(a)
ccall((:nf_elem_set_den, libantic), Nothing,
ccall((:nf_elem_set_den, libflint), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}),
z, _one, a.parent)
return z
end

function one!(r::AbsSimpleNumFieldElem)
a = parent(r)
ccall((:nf_elem_one, libantic), Nothing,
ccall((:nf_elem_one, libflint), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), r, a)
return r
end
Expand All @@ -537,14 +537,14 @@ function zero(r::AbsSimpleNumFieldElem)
end

function divexact!(z::AbsSimpleNumFieldElem, x::AbsSimpleNumFieldElem, y::ZZRingElem)
ccall((:nf_elem_scalar_div_fmpz, libantic), Nothing,
ccall((:nf_elem_scalar_div_fmpz, libflint), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}),
z, x, y, parent(x))
return z
end

function sub!(a::AbsSimpleNumFieldElem, b::AbsSimpleNumFieldElem, c::AbsSimpleNumFieldElem)
ccall((:nf_elem_sub, libantic), Nothing,
ccall((:nf_elem_sub, libflint), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}),
a, b, c, a.parent)
end
Expand Down Expand Up @@ -684,31 +684,31 @@ function divexact!(a::ZZRingElem, b::ZZRingElem)
end

function round!(z::ArbFieldElem, x::ArbFieldElem, p::Int)
ccall((:arb_set_round, libarb), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, p)
ccall((:arb_set_round, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, p)
z.parent = ArbField(p, cached=false)
return z
end

function round!(z::AcbFieldElem, x::AcbFieldElem, p::Int)
ccall((:acb_set_round, libarb), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, p)
ccall((:acb_set_round, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, p)
z.parent = AcbField(p, cached=false)
return z
end

function round(x::ArbFieldElem, p::Int)
z = ArbField(p, cached=false)()
ccall((:arb_set_round, libarb), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, p)
ccall((:arb_set_round, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), z, x, p)
return z
end

function round(x::AcbFieldElem, p::Int)
z = AcbField(p, cached=false)()
ccall((:acb_set_round, libarb), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, p)
ccall((:acb_set_round, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), z, x, p)
return z
end

function bits(x::AcbFieldElem)
return ccall((:acb_bits, libarb), Int, (Ref{AcbFieldElem},), x)
return ccall((:acb_bits, libflint), Int, (Ref{AcbFieldElem},), x)
end

function Base.Int128(x::ZZRingElem)
Expand Down Expand Up @@ -1455,7 +1455,7 @@ Base.:(*)(x::QQFieldElem, y::AbstractAlgebra.Generic.MatSpaceElem{AbsSimpleNumFi


function mod_sym!(a::AbsSimpleNumFieldElem, b::ZZRingElem)
ccall((:nf_elem_smod_fmpz, libantic), Nothing,
ccall((:nf_elem_smod_fmpz, libflint), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}),
a, a, b, parent(a))
return a
Expand Down Expand Up @@ -1544,7 +1544,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, libantic), Nothing,
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)
return nothing
Expand All @@ -1557,7 +1557,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, libantic), Nothing,
ccall((:nf_elem_get_nmod_poly_den, libflint), Nothing,
(Ref{fpPolyRingElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}, Cint),
r, a, a.parent, Cint(useden))
return nothing
Expand All @@ -1570,7 +1570,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, libantic), Nothing,
ccall((:nf_elem_get_nmod_poly_den, libflint), Nothing,
(Ref{zzModPolyRingElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}, Cint),
r, a, a.parent, Cint(useden))
return nothing
Expand All @@ -1583,7 +1583,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, libantic), Nothing,
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)
return nothing
Expand Down
16 changes: 0 additions & 16 deletions src/Nemo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,6 @@ function flint_abort()
error("Problem in the Flint-Subsystem")
end

# check whether we are using flint version >= 3.0 (or some recent enough dev version),
# which changed the layout of some structs
_ptr = Libdl.dlopen(libflint)
if Libdl.dlsym(_ptr, :_fmpz_mod_vec_set_fmpz_vec_threaded; throw_error = false) !== nothing
const NEW_FLINT = true
const libantic = libflint
const libarb = libflint
const libcalcium = libflint
else
const NEW_FLINT = false
using Arb_jll: libarb
using Antic_jll: libantic
using Calcium_jll: libcalcium
end
Libdl.dlclose(_ptr)

################################################################################
#
# Debugging tools for allocation tracking
Expand Down
12 changes: 6 additions & 6 deletions src/antic/AnticTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +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, libantic), Nothing,
ccall((:nf_init, libflint), Nothing,
(Ref{AbsSimpleNumField}, Ref{QQPolyRingElem}), nf, pol)
finalizer(_AnticNumberField_clear_fn, nf)
nf.S = s
Expand All @@ -56,7 +56,7 @@ const AnticNumberFieldID = CacheDictType{Tuple{QQPolyRing, QQPolyRingElem, Symbo


function _AnticNumberField_clear_fn(a::AbsSimpleNumField)
ccall((:nf_clear, libantic), Nothing, (Ref{AbsSimpleNumField},), a)
ccall((:nf_clear, libflint), Nothing, (Ref{AbsSimpleNumField},), a)
end

"""
Expand All @@ -81,7 +81,7 @@ mutable struct AbsSimpleNumFieldElem <: SimpleNumFieldElem{QQFieldElem}

function AbsSimpleNumFieldElem(p::AbsSimpleNumField)
r = new()
ccall((:nf_elem_init, libantic), Nothing,
ccall((:nf_elem_init, libflint), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), r, p)
r.parent = p
finalizer(_nf_elem_clear_fn, r)
Expand All @@ -90,9 +90,9 @@ mutable struct AbsSimpleNumFieldElem <: SimpleNumFieldElem{QQFieldElem}

function AbsSimpleNumFieldElem(p::AbsSimpleNumField, a::AbsSimpleNumFieldElem)
r = new()
ccall((:nf_elem_init, libantic), Nothing,
ccall((:nf_elem_init, libflint), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), r, p)
ccall((:nf_elem_set, libantic), Nothing,
ccall((:nf_elem_set, libflint), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), r, a, p)
r.parent = p
finalizer(_nf_elem_clear_fn, r)
Expand All @@ -101,6 +101,6 @@ mutable struct AbsSimpleNumFieldElem <: SimpleNumFieldElem{QQFieldElem}
end

function _nf_elem_clear_fn(a::AbsSimpleNumFieldElem)
ccall((:nf_elem_clear, libantic), Nothing,
ccall((:nf_elem_clear, libflint), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}), a, a.parent)
end
Loading

0 comments on commit e76cdb3

Please sign in to comment.