Skip to content

Commit

Permalink
Update all uses of roots
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Jul 6, 2023
1 parent 43fb22c commit 4c301d8
Show file tree
Hide file tree
Showing 21 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/EllCrv/RationalPointSearch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ mutable struct NegativityCertificate
end


rr = roots(f, AcbField(64, cached = false))
rr = roots(AcbField(64, cached = false), f)
r = sort!(map(real, filter!(isreal, rr)))

# Let's first consider what happens between two roots
Expand Down
4 changes: 2 additions & 2 deletions src/LocalField/Conjugates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The roots of $f$ in $Q$, $f$ has to be square-free (at least the roots have to b
"""
function roots(Q::FlintQadicField, f::ZZPolyRingElem; max_roots::Int = degree(f))
k, mk = residue_field(Q)
rt = roots(f, k)
rt = roots(k, f)
RT = qadic[]
for r = rt
push!(RT, newton_lift(f, preimage(mk, r)))
Expand All @@ -98,7 +98,7 @@ function roots(C::qAdicRootCtx, n::Int = 10)
Q.prec_max = n
for x = lf
if is_splitting(C) || degree(x[1]) == degree(Q)
append!(rt, roots(x[1], Q, max_roots = 1))
append!(rt, roots(Q, x[1], max_roots = 1))
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/LocalField/automorphisms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function absolute_automorphism_list(K::LocalField{qadic, S}) where S
auts = morphism_type(K)[]
for f in autsk
fnew = map_coefficients(f, defining_polynomial(K))
rt = roots(fnew, K)
rt = roots(K, fnew)
for x in rt
push!(auts, hom(K, K, f, x))
end
Expand Down
2 changes: 1 addition & 1 deletion src/Map/FiniteField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ end
#Function that finds an embedding of k into K
function Nemo.embed_any(k::FinField, K::FinField)
f = defining_polynomial(k)
rt = roots(f, K)[1]
rt = roots(K, f)[1]
return hom(k, K, rt)
end

Expand Down
4 changes: 2 additions & 2 deletions src/Map/automorphisms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function _automorphisms(K::NfAbsNS; is_abelian::Bool = false)
pols = QQPolyRingElem[is_univariate(x)[2] for x in K.pol]
rt = Vector{Vector{NfAbsNSElem}}(undef, length(pols))
for i = 1:length(pols)
rt[i] = roots(pols[i], K)
rt[i] = roots(K, pols[i])
end
auts = Vector{NfAbsNSToNfAbsNS}(undef, prod(length(x) for x in rt))
ind = 1
Expand Down Expand Up @@ -677,7 +677,7 @@ function absolute_automorphism_list(K::NumField)
end

function _automorphisms(K::NumField{QQFieldElem}, F::NumField, L::QQField)
rt = roots(defining_polynomial(K), F)
rt = roots(F, defining_polynomial(K))
auts = morphism_type(K, F)[hom(K, F, x) for x in rt]
return auts
end
Expand Down
4 changes: 2 additions & 2 deletions src/Misc/FiniteField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function splitting_field(f::PolyElem{<:FinFieldElem}; do_roots::Bool = false)
embed(k, K)
end
if do_roots
return K, roots(f, K)
return K, roots(K, f)
end
return K
end
end
14 changes: 7 additions & 7 deletions src/Misc/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -711,14 +711,14 @@ function roots(f::ZZPolyRingElem, ::QQField; max_roots::Int=degree(f))
end

function roots(f::ZZPolyRingElem; max_roots::Int=degree(f))
r = roots(f, FlintQQ, max_roots=max_roots)
r = roots(FlintQQ, f, max_roots=max_roots)
return ZZRingElem[FlintZZ(x) for x = r if denominator(x) == 1]
end

function roots(f::QQPolyRingElem; max_roots::Int=degree(f))
Zx, x = polynomial_ring(FlintZZ, cached=false)
g = Zx(denominator(f) * f)
return roots(g, FlintQQ)
Zx, x = polynomial_ring(FlintZZ, cached = false)
g = Zx(denominator(f)*f)
return roots(FlintQQ, g)
end

function roots(R::AcbField, f::Union{ZZPolyRingElem, QQPolyRingElem}, abs_tol::Int=R.prec, initial_prec::Int...)
Expand All @@ -740,7 +740,7 @@ function factor(R::AcbField, f::Union{ZZPolyRingElem, QQPolyRingElem}, abs_tol::
d = Dict{acb_poly, Int}()
Rt, t = polynomial_ring(R, String(var(parent(f))), cached = false)
for (k,v) = g.fac
for r = roots(k, R)
for r = roots(R, k)
d[t-r] = v
end
end
Expand All @@ -753,7 +753,7 @@ function roots(R::ArbField, f::Union{ZZPolyRingElem, QQPolyRingElem}, abs_tol::I
C = AcbField(precision(R))
for k = keys(g.fac)
s, _ = signature(k)
rt = roots(k, C)
rt = roots(C, k)
append!(r, map(real, rt[1:s]))
end
return r
Expand All @@ -766,7 +766,7 @@ function factor(R::ArbField, f::Union{ZZPolyRingElem, QQPolyRingElem}, abs_tol::
C = AcbField(precision(R))
for (k,v) = g.fac
s, t = signature(k)
r = roots(k, C)
r = roots(C, k)
for i=1:s
d[x-real(r[i])] = v
end
Expand Down
2 changes: 1 addition & 1 deletion src/Misc/RelFiniteField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ function absolute_field(F::RelFinField{T}; cached::Bool = true) where T <: FinFi
K, gK = Native.FiniteField(p, d, "a", cached = cached)
k, mk = absolute_field(base_field(F))
def_pol_new = map_coefficients(pseudo_inv(mk), defining_polynomial(F))
img_gen_k = roots(defining_polynomial(k), K)[1]
img_gen_k = roots(K, defining_polynomial(k))[1]
mp = hom(k, K, img_gen_k)
g = map_coefficients(mp, def_pol_new)
img_gen_F = roots(g)[1]
Expand Down
2 changes: 1 addition & 1 deletion src/Misc/nmod_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ function FlintFiniteField(f::fqPolyRepPolyRingElem, s::AbstractString = "o"; cac
k = base_ring(f)
p = characteristic(k)
K, o = FlintFiniteField(p, degree(k)*degree(f), s, cached = cached)
r = roots(f, K)[1] # not working, embeddings are missing
r = roots(K, f)[1] # not working, embeddings are missing
fl || error("s.th. went wrong")
return K, r
end
Expand Down
4 changes: 2 additions & 2 deletions src/NumField/NfAbs/MPolyAbsFact.jl
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ function analytic_roots(f::ZZMPolyRingElem, r::ZZRingElem, pr::Int = 10; prec::I
g = evaluate(f, [Hecke.Globals.Zx(r), gen(Hecke.Globals.Zx)])
@assert is_squarefree(g)
C = AcbField(prec)
rt = Hecke.roots(g, C)[1:max_roots]
rt = Hecke.roots(C, g)[1:max_roots]
@assert all(x->parent(x) == C, rt)
Cs, s = power_series_ring(C, pr+2, "s", cached = false)
Cst, t = polynomial_ring(Cs, cached = false)
Expand Down Expand Up @@ -476,7 +476,7 @@ function symbolic_roots(f::ZZMPolyRingElem, r::ZZRingElem, pr::Int = 10; max_roo
g = evaluate(f, [Hecke.Globals.Zx(r), gen(Hecke.Globals.Zx)])
@assert is_squarefree(g)
lg = factor(g)
rt = vcat([Hecke.roots(x, number_field(x)[1]) for x = keys(lg.fac)]...)
rt = vcat([Hecke.roots(number_field(x)[1], x) for x = keys(lg.fac)]...)
rt = rt[1:min(length(rt), max_roots)]
RT = []
for i = 1:length(rt)
Expand Down
4 changes: 2 additions & 2 deletions src/NumField/NfAbs/NfAbs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ end

function _issubfield(K::AnticNumberField, L::AnticNumberField)
f = K.pol
R = roots(f, L, max_roots = 1)
R = roots(L, f, max_roots = 1)
if isempty(R)
return false, L()
else
Expand Down Expand Up @@ -875,7 +875,7 @@ The normal closure of $K$ together with the embedding map.
"""
function normal_closure(K::AnticNumberField)
s = splitting_field(K.pol)
r = roots(K.pol, s)[1]
r = roots(s, K.pol)[1]
return s, hom(K, s, r, check = false)
end

Expand Down
6 changes: 3 additions & 3 deletions src/NumField/NfAbs/Simplify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function _sieve_primitive_elements(B::Vector{NfAbsNSElem})
Ft = polynomial_ring(F, "t", cached = false)[1]
rt = Vector{Vector{fqPolyRepFieldElem}}(undef, ngens(K))
for i = 1:length(pols)
rt[i] = roots(pols[i], F)
rt[i] = roots(F, pols[i])
end
rt_all = Vector{Vector{fqPolyRepFieldElem}}(undef, degree(K))
ind = 1
Expand Down Expand Up @@ -219,7 +219,7 @@ function _sieve_primitive_elements(B::Vector{nf_elem})
Ft = polynomial_ring(F, "t", cached = false)[1]
ap = zero(Ft)
fit!(ap, degree(K)+1)
rt = roots(f, F)
rt = roots(F, f)

n = degree(K)
indices = Int[]
Expand Down Expand Up @@ -358,7 +358,7 @@ function polredabs(K::AnticNumberField)
Ft = polynomial_ring(F, "t", cached = false)[1]
ap = zero(Ft)
fit!(ap, degree(K)+1)
rt = roots(f, F)
rt = roots(F, f)

n = degree(K)

Expand Down
2 changes: 1 addition & 1 deletion src/NumField/NfRel/NfRelNSMor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ end

function _automorphisms(L::NfRelNS{T}) where T
Kx, _ = polynomial_ring(base_field(L), "x", cached = false)
rts = Vector{elem_type(L)}[roots(to_univariate(Kx, x), L) for x in L.pol]
rts = Vector{elem_type(L)}[roots(L, to_univariate(Kx, x)) for x in L.pol]
auts = Vector{morphism_type(L)}(undef, prod(length(x) for x in rts))
ind = 1
it = cartesian_product_iterator([1:length(rts[i]) for i in 1:length(rts)], inplace = true)
Expand Down
4 changes: 2 additions & 2 deletions src/NumField/NfRel/Simplify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function _setup_block_system(Lrel::NfRel{nf_elem})
Fpx = polynomial_ring(Fp, cached = false)[1]
F = FlintFiniteField(p, abs_deg, "w", cached = false)[1]
Fx = polynomial_ring(F, cached = false)[1]
rt_base_field = roots(Zx(K.pol), F)
rt_base_field = roots(F, Zx(K.pol))
tmp = Fpx()
g = Lrel.pol
rt = Dict{FqPolyRepFieldElem, Vector{FqPolyRepFieldElem}}()
Expand Down Expand Up @@ -276,7 +276,7 @@ function _setup_block_system(Lrel::NfRelNS{nf_elem})
Fpx = polynomial_ring(Fp, cached = false)[1]
F = FlintFiniteField(p, abs_deg, "w", cached = false)[1]
Fx = polynomial_ring(F, cached = false)[1]
rt_base_field = roots(Zx(K.pol), F)
rt_base_field = roots(F, Zx(K.pol))
rt = Dict{FqPolyRepFieldElem, Vector{Vector{FqPolyRepFieldElem}}}()
Rxy = polynomial_ring(F, ngens(Lrel), cached = false)[1]
tmp = Fpx()
Expand Down
2 changes: 1 addition & 1 deletion src/NumField/SimpleNumField/Subfields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function _principal_subfields_basis(K::SimpleNumField)
#f in Kx
#fk = Kx([coeff(f,i) for i in 0:n])
#determine roots
rts = roots(f, K)
rts = roots(K, f)
ar_lin_fac = elem_type(Kx)[x - root for root in rts]
fK = change_base_ring(K, f, parent = Kx)
##divide by roots
Expand Down
2 changes: 1 addition & 1 deletion src/NumField/Subfields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function _subfield_primitive_element_from_basis(K::AnticNumberField, as::Vector{
Ft = polynomial_ring(F, "t", cached = false)[1]
ap = zero(Ft)
fit!(ap, degree(K)+1)
rt = roots(f, F)
rt = roots(F, f)
indices = Int[]
for i = 1:length(as)
b = _block(as[i], rt, ap)
Expand Down
2 changes: 1 addition & 1 deletion src/NumFieldOrd/NfOrd/Ideal/Prime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ function prime_dec_nonindex(O::NfAbsOrd{NfAbsNS,NfAbsNSElem}, p::IntegerUnion, d
t = x[ti]
g = gcd(d, degree(t[1]))
d = lcm(d, degree(t[1]))
r = roots(t[1], Fq)
r = roots(Fq, t[1])
if g == 1
push!(rt, [r[1]])
else
Expand Down
2 changes: 1 addition & 1 deletion src/NumFieldOrd/NfOrd/TorsionUnits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ function _torsion_units_gen(K::NumField)
end
for i = v:-1:1
f = cyclotomic(Int(p)^i, x)
r = roots(f, K)
r = roots(K, f)
if length(r) > 0
mul!(gen, gen, r[1])
ord *= Int(p)^(i)
Expand Down
4 changes: 2 additions & 2 deletions src/RCF/autos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ end

function rel_auto_generic(A::ClassField_pp)
K = A.A
imgs = roots(K.pol, K)
imgs = roots(K, K.pol)
homs = morphism_type(K)[hom(K, K, x, check = false) for x in imgs]
return small_generating_set(homs, *)[1]
end
Expand Down Expand Up @@ -594,7 +594,7 @@ function extend_generic(A::ClassField, autos::Vector{NfToNfMor}, p::ZZRingElem)
imgs = Vector{NfRelNSElem{nf_elem}}(undef, length(Cp))
for j = 1:length(gA)
pol = map_coefficients(autos[i], Cp[j].A.pol)
imgs[j] = roots(pol, A)[1]
imgs[j] = roots(A, pol)[1]
end
rts[i] = imgs
end
Expand Down
2 changes: 1 addition & 1 deletion test/Misc/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
local l

while p < 4096
l = roots(f, ArbField(p, cached = false))
l = roots(ArbField(p, cached = false), f)
sgtpos = count(ispositive, l)
sgtneg = count(isnegative, l)
sgtz = count(iszero, l)
Expand Down
2 changes: 1 addition & 1 deletion test/NfAbs/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ end
Qx, x = QQ["x"]
f = x^3-39*x-65
K, a = number_field(f, "a")
r = @inferred roots(f, K)
r = @inferred roots(K, f)
@test length(r) == 3
@test all(iszero, (f(b) for b in r))
end
Expand Down

0 comments on commit 4c301d8

Please sign in to comment.