Skip to content

Commit

Permalink
Don't use Flint* globals (#1674)
Browse files Browse the repository at this point in the history
* `FlintQQ` -> `QQ`

* `FlintZZ` -> `ZZ`
  • Loading branch information
lgoettgens authored Nov 8, 2024
1 parent 39fc9cb commit e526417
Show file tree
Hide file tree
Showing 277 changed files with 1,853 additions and 1,853 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ julia> using Hecke
| | | | __/ (__| < __/ | Manual: https://thofma.github.io/Hecke.jl
|_| |_|\___|\___|_|\_\___| | Version 0.34.6
julia> Qx, x = polynomial_ring(FlintQQ, "x");
julia> Qx, x = polynomial_ring(QQ, "x");
julia> f = x^3 + 2;
Expand Down
4 changes: 2 additions & 2 deletions docs/src/manual/number_fields/class_fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ring_class_field(::AbsNumFieldOrder)

```@repl
using Hecke # hide
Qx, x = polynomial_ring(FlintQQ, "x");
Qx, x = polynomial_ring(QQ, "x");
K, a = number_field(x^2 - 10, "a");
c, mc = class_group(K)
A = ray_class_field(mc)
Expand All @@ -82,7 +82,7 @@ number_field(C::ClassField)

```@repl
using Hecke; # hide
Qx, x = polynomial_ring(FlintQQ, "x");
Qx, x = polynomial_ring(QQ, "x");
k, a = number_field(x^2 - 10, "a");
c, mc = class_group(k);
A = ray_class_field(mc)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/manual/orders/orders.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ any_order(K::AbsSimpleNumField)

```@repl
using Hecke; # hide
Qx, x = polynomial_ring(FlintQQ, "x");
Qx, x = polynomial_ring(QQ, "x");
K, a = number_field(x^2 - 2, "a");
O = EquationOrder(K)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/manual/quad_forms/genusherm.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ mass(::HermLat)

```@repl 2
using Hecke # hide
Qx, x = polynomial_ring(FlintQQ, "x");
Qx, x = polynomial_ring(QQ, "x");
f = x^2 - 2;
K, a = number_field(f, "a", cached = false);
Kt, t = polynomial_ring(K, "t");
Expand Down
2 changes: 1 addition & 1 deletion examples/Clgp.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Hard class group of Carlo
# Qx, x = polynomial_ring(FlintQQ, "x");
# Qx, x = polynomial_ring(QQ, "x");
# f = x^4-x^3-378*x^2+2081*x-67;
# K, a = number_field(f);
# C = cyclotomic_extension(K, 7)
Expand Down
4 changes: 2 additions & 2 deletions examples/FieldEnumeration/FieldEnumeration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function __to_univariate(Qx, f)
z = zero(Qx)
x = gen(Qx)
for (c, m) in zip(coefficients(f), monomials(f))
z = z + FlintQQ(c) * x^total_degree(m)
z = z + QQ(c) * x^total_degree(m)
end
return z
end
Expand All @@ -30,7 +30,7 @@ end

function _read_fields(filename::String)
f=open(filename, "r")
Qx,x=polynomial_ring(FlintQQ,"x")
Qx,x=polynomial_ring(QQ,"x")
pols = []
for s in eachline(f)
a=Main.eval(Meta.parse(s))
Expand Down
2 changes: 1 addition & 1 deletion examples/FieldEnumeration/absolute_abelian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function _get_simple_extension_and_maximal_order(K)
pol = K.pol
k = length(pol)
gensK = gens(K)
Qx, x = polynomial_ring(FlintQQ, "x", cached = false)
Qx, x = polynomial_ring(QQ, "x", cached = false)
basesofmaximalorders = Vector{elem_type(K)}[]
discs = ZZRingElem[]
for i in 1:k
Expand Down
2 changes: 1 addition & 1 deletion examples/FieldEnumeration/cubic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ end


function Gunter_Qi(r::Range, pref="Qi.new")
Qt, t = FlintQQ["t"]
Qt, t = QQ["t"]
k, a = number_field(t^2+1, "k.1")
s = Hecke.NumFieldHom{AbsSimpleNumField, AbsSimpleNumField}(k, k, -a)
M = maximal_order(k)
Expand Down
2 changes: 1 addition & 1 deletion examples/FieldEnumeration/smallest_field.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ end

function _read_fields(filename::String)
f=open(filename, "r")
Qx,x=polynomial_ring(FlintQQ,"x")
Qx,x=polynomial_ring(QQ,"x")
pols=Tuple{QQPolyRingElem, ZZRingElem}[]
for s in eachline(f)
a=eval(parse(s))
Expand Down
4 changes: 2 additions & 2 deletions examples/IsPower.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function ispower_mod_p(a::AbsSimpleNumFieldElem, i::Int)
con_pr_j = [[one(parent(x)) for x = y] for y = con_pr]
no_fac = sum(map(length, con_pr))
j = 0
trafo = identity_matrix(FlintZZ, no_fac)
trafo = identity_matrix(ZZ, no_fac)
no_rt = no_fac
while true
j += 1
Expand All @@ -128,7 +128,7 @@ function ispower_mod_p(a::AbsSimpleNumFieldElem, i::Int)
continue
end
trafo = hcat(trafo, data)
data = zero_matrix(FlintZZ, 1, ncols(trafo))
data = zero_matrix(ZZ, 1, ncols(trafo))
data[1, end] = pk
trafo = vcat(trafo, data)
#= roots: products of the local roots that ar small
Expand Down
24 changes: 12 additions & 12 deletions examples/MultDep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function multiplicative_group_mod_units_fac_elem(A::Vector{AbsSimpleNumFieldElem
cp = coprime_base(A)
end
sort!(cp, lt = (a,b) -> norm(a) > norm(b))
M = sparse_matrix(FlintZZ)
M = sparse_matrix(ZZ)
for a = A
T = Tuple{Int, ZZRingElem}[]
for i = 1:length(cp)
Expand All @@ -24,7 +24,7 @@ function multiplicative_group_mod_units_fac_elem(A::Vector{AbsSimpleNumFieldElem
end
# isone(I) && break
end
push!(M, sparse_row(FlintZZ, T))
push!(M, sparse_row(ZZ, T))
end
h, t = Hecke.hnf_kannan_bachem(M, Val(true), truncate = true)
return h, t, cp
Expand Down Expand Up @@ -92,7 +92,7 @@ function *(O1::AbsNumFieldOrder, O2::AbsNumFieldOrder)
b2 = basis(O2, k)
p = [x*y for (x,y) in Base.Iterators.ProductIterator((b1, b2))]
d = reduce(lcm, [denominator(x) for x = p])
M = zero_matrix(FlintZZ, n*n, n)
M = zero_matrix(ZZ, n*n, n)
z = ZZRingElem()
for i = 1:n*n
a = p[i]*d
Expand Down Expand Up @@ -244,7 +244,7 @@ function mult_syzygies_units(A::Vector{FacElem{AbsSimpleNumFieldElem, AbsSimpleN
else # length == 1 extend the module
s = QQFieldElem[]
for x in k[1, :]
@vtime :qAdic 1 y = lift_reco(FlintQQ, x, reco = true)
@vtime :qAdic 1 y = lift_reco(QQ, x, reco = true)
if y === nothing
prec *= 2
@vprint :qAdic 1 "increase prec to ", prec
Expand All @@ -257,7 +257,7 @@ function mult_syzygies_units(A::Vector{FacElem{AbsSimpleNumFieldElem, AbsSimpleN
continue
end
d = reduce(lcm, map(denominator, s))
gamma = ZZRingElem[FlintZZ(x*d)::ZZRingElem for x = s]
gamma = ZZRingElem[ZZ(x*d)::ZZRingElem for x = s]
@assert reduce(gcd, gamma) == 1 # should be a primitive relation
@time if !verify_gamma(push!(copy(u), a), gamma, ZZRingElem(p)^prec)
prec *= 2
Expand Down Expand Up @@ -295,21 +295,21 @@ function mult_syzygies_units(A::Vector{FacElem{AbsSimpleNumFieldElem, AbsSimpleN
=#

for i=1:length(uu)-1
append!(uu[i][2], zeros(FlintZZ, length(uu[end][2])-length(uu[i][2])))
append!(uu[i][2], zeros(ZZ, length(uu[end][2])-length(uu[i][2])))
end
if length(uu) == 0
U = matrix(FlintZZ, length(uu), length(uu[end][2]), reduce(vcat, [x[2] for x = uu]))
U = matrix(ZZ, length(uu), length(uu[end][2]), reduce(vcat, [x[2] for x = uu]))
else
U = matrix(FlintZZ, length(uu), length(uu[end][2]), reduce(vcat, [x[2] for x = uu]))
U = matrix(ZZ, length(uu), length(uu[end][2]), reduce(vcat, [x[2] for x = uu]))
end
_, U = hnf_with_transform(U')
if false
U = inv(U)
V = sub(U, 1:rows(U), 1:cols(U)-length(u))
U = sub(U, 1:rows(U), cols(U)-length(u)+1:cols(U))
#U can be reduced modulo V...
Z = zero_matrix(FlintZZ, cols(V), cols(U))
I = identity_matrix(FlintZZ, cols(U)) * p^(2*prec)
Z = zero_matrix(ZZ, cols(V), cols(U))
I = identity_matrix(ZZ, cols(U)) * p^(2*prec)
k = base_ring(A[1])
A = [ Z V'; I U']
l = lll(A)
Expand Down Expand Up @@ -353,14 +353,14 @@ function lift_reco(::QQField, a::PadicFieldElem; reco::Bool = false)
fl, c, d = rational_reconstruction(u, prime(R, N-v))
!fl && return nothing

x = FlintQQ(c, d)
x = QQ(c, d)
if v < 0
return x//prime(R, -v)
else
return x*prime(R, v)
end
else
return lift(FlintQQ, a)
return lift(QQ, a)
end
end

Expand Down
34 changes: 17 additions & 17 deletions examples/MultiQuad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function _combine(f::QQPolyRingElem, g::QQPolyRingElem, Qxy)
end

function multi_quad_with_aut(d::Vector{ZZRingElem})
Qx, x = polynomial_ring(FlintQQ, "x", cached = false)
Qx, x = polynomial_ring(QQ, "x", cached = false)
Qxy, y = polynomial_ring(Qx, "y", cached = false)
lp = [ number_field(x^2-a)[1] for a = d]
aut = [ [gen(x), -gen(x)] for x = lp]
Expand All @@ -48,7 +48,7 @@ function multi_quad_with_aut(d::Vector{ZZRingElem})
end

function multi_quad_with_emb(d::Vector{ZZRingElem})
Qx, x = polynomial_ring(FlintQQ, "x", cached = false)
Qx, x = polynomial_ring(QQ, "x", cached = false)
Qxy, y = polynomial_ring(Qx, "y", cached = false)
lp = [ number_field(x^2-a)[1] for a = d]
aut = [ [gen(x)] for x = lp]
Expand Down Expand Up @@ -102,7 +102,7 @@ function multi_quad(d::Vector{ZZRingElem}, B::Int)
t_ord = 0
local t_u

Zx, x = FlintZZ["x"]
Zx, x = ZZ["x"]

for i = 2:length(all_d)
k, a = number_field(x^2-all_d[i], cached = false)
Expand Down Expand Up @@ -222,7 +222,7 @@ function _nullspace(A::zzModMatrix)
if valuation(p, i) > 1
continue
end
b = matrix(residue_ring(FlintZZ, Int(i))[1], A_orig)
b = matrix(residue_ring(ZZ, Int(i))[1], A_orig)
b = nullspace(b)
b = rref(b[1]')
c = matrix(base_ring(b[2]), A)'
Expand Down Expand Up @@ -261,7 +261,7 @@ function mod_p(R, Q::AbsNumFieldOrderIdeal{AbsSimpleNumField, AbsSimpleNumFieldE
end
end
# =#
return matrix(residue_ring(FlintZZ, p)[1], 1, length(R), [dlog(dl, mF(x)^e, pp) % p for x = R])
return matrix(residue_ring(ZZ, p)[1], 1, length(R), [dlog(dl, mF(x)^e, pp) % p for x = R])
end

Hecke.lift(A::ZZMatrix) = A
Expand All @@ -283,7 +283,7 @@ function saturate_exp(c::Hecke.ClassGrpCtx, p::Int, stable = 1.5)
else
#println("NOT doint zeta")
end
T = residue_ring(FlintZZ, p)[1]
T = residue_ring(ZZ, p)[1]
A = identity_matrix(T, length(R))
i = 1
for (up, k) = factor(p).fac
Expand All @@ -293,10 +293,10 @@ function saturate_exp(c::Hecke.ClassGrpCtx, p::Int, stable = 1.5)
all_p = [up^k]
end
#@show all_p
AA = identity_matrix(FlintZZ, ncols(A))
AA = identity_matrix(ZZ, ncols(A))
for pp = all_p
#println("doin' $pp")
AA = matrix(residue_ring(FlintZZ, Int(pp))[1], lift(AA))
AA = matrix(residue_ring(ZZ, Int(pp))[1], lift(AA))
Ap = matrix(base_ring(AA), A)
i = 1
S = Hecke.PrimesSet(Hecke.p_start, -1, Int(pp), 1)
Expand Down Expand Up @@ -397,15 +397,15 @@ function elems_from_sat(c::Hecke.ClassGrpCtx, z)
res = []
fac = []
for i=1:ncols(z)
a = fe(c.R_gen[1])^FlintZZ(z[1, i])
b = FlintZZ(z[1, i]) * c.M.bas_gens[1]
a = fe(c.R_gen[1])^ZZ(z[1, i])
b = ZZ(z[1, i]) * c.M.bas_gens[1]
for j=2:length(c.R_gen)
a *= fe(c.R_gen[j])^FlintZZ(z[j, i])
b += FlintZZ(z[j, i]) * c.M.bas_gens[j]
a *= fe(c.R_gen[j])^ZZ(z[j, i])
b += ZZ(z[j, i]) * c.M.bas_gens[j]
end
for j=1:length(c.R_rel)
a *= fe(c.R_rel[j])^FlintZZ(z[j + length(c.R_gen), i])
b += FlintZZ(z[j + length(c.R_gen), i]) * c.M.rel_gens[j]
a *= fe(c.R_rel[j])^ZZ(z[j + length(c.R_gen), i])
b += ZZ(z[j + length(c.R_gen), i]) * c.M.rel_gens[j]
end

push!(res, (a, b))
Expand All @@ -414,10 +414,10 @@ function elems_from_sat(c::Hecke.ClassGrpCtx, z)
end

function saturate(c::Hecke.ClassGrpCtx, n::Int, stable = 3.5)
e = matrix(FlintZZ, saturate_exp(c, n%8 == 0 ? 2*n : n, stable))
e = matrix(ZZ, saturate_exp(c, n%8 == 0 ? 2*n : n, stable))
se = sparse_matrix(e)'

A = sparse_matrix(FlintZZ)
A = sparse_matrix(ZZ)
K = nf(c)
_, zeta = get_attribute(K, :torsion_units)

Expand Down Expand Up @@ -551,7 +551,7 @@ function simplify(c::Hecke.ClassGrpCtx)
end
end
for i=1:length(U.units)
Hecke.class_group_add_relation(d, U.units[i], sparse_row(FlintZZ))
Hecke.class_group_add_relation(d, U.units[i], sparse_row(ZZ))
end
return d
end
Expand Down
6 changes: 3 additions & 3 deletions examples/NFDB.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function _class_group(c::Vector{BigInt})
Qx, x = polynomial_ring(FlintQQ, "x", cached = false)
Qx, x = polynomial_ring(QQ, "x", cached = false)
f = Qx(c)
K, a = number_field(f, cached = false)
OK = lll(maximal_order(K))
Expand All @@ -11,7 +11,7 @@ function _class_group_batch(polys::Vector{QQPolyRingElem})
res = Dict()
for i in 1:length(polys)
f = polys[i]
c = BigInt[FlintZZ(coeff(f, j)) for j in 0:degree(f)]
c = BigInt[ZZ(coeff(f, j)) for j in 0:degree(f)]
res[i] = @spawn _class_group(c)
end

Expand Down Expand Up @@ -1454,7 +1454,7 @@ mutable struct NFDBGeneric{T, S}
return z
end
end

function NFDBGeneric(L::Vector{RelSimpleNumField{AbsSimpleNumFieldElem}})
res = NFDBGeneric{1, eltype(L)}()
for K in L
Expand Down
12 changes: 6 additions & 6 deletions examples/Plesken.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

function steinitz(a::zzModPolyRingElem)
p = characteristic(base_ring(a))
ZZx = polynomial_ring(FlintZZ)[1]
ZZx = polynomial_ring(ZZ)[1]
# f = lift(ZZx, a) ## bloody stupid lift for poly uses symmetric residue
f = [lift(coeff(a, i))::ZZRingElem for i=0:degree(a)]
return Nemo.evaluate(ZZx(f), p)
Expand All @@ -38,7 +38,7 @@ end

function steinitz(a::ResElem{T}) where T <: Union{zzModPolyRingElem, fqPolyRepPolyRingElem, PolyRingElem}
f = [steinitz(coeff(a.data, i))::ZZRingElem for i=0:degree(a.data)]
ZZx = polynomial_ring(FlintZZ)[1]
ZZx = polynomial_ring(ZZ)[1]
S = base_ring(base_ring(parent(a)))
return evaluate(ZZx(f), size(S))
end
Expand Down Expand Up @@ -217,8 +217,8 @@ function plesken_kummer(p::ZZRingElem, r::Int, s::Int)
R = finite_field(p)
descent = false
else
f = cyclotomic(r, polynomial_ring(FlintZZ)[2])
f = polynomial_ring(residue_ring(FlintZZ, p)[1])[1](f)
f = cyclotomic(r, polynomial_ring(ZZ)[2])
f = polynomial_ring(residue_ring(ZZ, p)[1])[1](f)
f = factor(f)
k = keys(f.fac)
st = start(k)
Expand All @@ -235,7 +235,7 @@ function plesken_kummer(p::ZZRingElem, r::Int, s::Int)
descent = true
ord = degree(opt)
R = Native.finite_field(opt, "a")[1]
T = residue_ring(FlintZZ, p)[1]
T = residue_ring(ZZ, p)[1]
J = CoerceMap(T, R)
end
zeta = primitive_root_r_div_qm1(R, r)
Expand Down Expand Up @@ -355,7 +355,7 @@ function h_minus(p::Int, nb::Int)
# is the asymptotic size, so that's what nb should be


Zx, x = polynomial_ring(FlintZZ)
Zx, x = polynomial_ring(ZZ)
F = Vector{ZZRingElem}(p-1)

g = rand(1:p-1)
Expand Down
Loading

0 comments on commit e526417

Please sign in to comment.