Skip to content

Commit

Permalink
Change argument order in factor and roots (#2433)
Browse files Browse the repository at this point in the history
* Update all uses of `factor`

* Update all uses of `roots`
  • Loading branch information
lgoettgens authored and thofma committed Jul 6, 2023
1 parent bd95ec2 commit 2c1b6f6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions experimental/GModule/AlgClosureFp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function Oscar.roots(a::AlgClosureElem, b::Int)
d = mapreduce(degree, lcm, keys(lf.fac), init = 1)
d = lcm(d, degree(parent(ad)))
K = ext_of_degree(parent(a), d)
r = roots(f, K)
r = roots(K, f)
return [AlgClosureElem(x, parent(a)) for x = r]
end

Expand All @@ -126,7 +126,7 @@ function Oscar.roots(a::Generic.Poly{AlgClosureElem{T}}) where T
d = mapreduce(degree, lcm, keys(lf.fac), init = 1)
d = lcm(d, degree(parent(b[1])))
K = ext_of_degree(A, d)
r = roots(f, K)
r = roots(K, f)
return [AlgClosureElem(x, A) for x = r]
end

Expand Down
2 changes: 1 addition & 1 deletion experimental/GModule/Misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Hecke.number_field(::QQField, a::qqbar; cached::Bool = false)
return b
end
f = minpoly(x)
r = roots(f, k)
r = roots(k, f)
pr = 10
while true
C = AcbField(pr)
Expand Down
2 changes: 1 addition & 1 deletion src/AlgebraicGeometry/Surfaces/K3Auto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1928,7 +1928,7 @@ function ample_class(S::ZZLat)
else
rv = (r*gram_matrix(S)*transpose(v))[1,1]
p = x^2*vsq + 2*x*rv + rsq
rp = roots(p, CalciumQQBar)
rp = roots(CalciumQQBar, p)
a = rp[1]
b = rp[2]
if a > b
Expand Down
16 changes: 8 additions & 8 deletions src/NumberTheory/GaloisGrp/GaloisGrp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ mutable struct ComplexRootCtx
rt::Vector{acb}
function ComplexRootCtx(f::ZZPolyRingElem)
@assert ismonic(f)
rt = roots(f, AcbField(20))
rt = roots(AcbField(20), f)
return new(f, 20, rt)
end
function ComplexRootCtx(f::QQPolyRingElem)
Expand All @@ -492,7 +492,7 @@ function Hecke.roots(C::GaloisCtx{ComplexRootCtx}, pr::Int = 10; raw::Bool = fal
if C.C.pr >= pr
return C.C.rt
end
rt = roots(C.C.f, AcbField(pr))
rt = roots(AcbField(pr), C.C.f)
C.C.pr = pr
n = length(rt)
for i=1:n
Expand Down Expand Up @@ -580,7 +580,7 @@ function Nemo.roots_upper_bound(f::ZZMPolyRingElem, t::Int = 0)
F = evaluate(f, [x, Qsx(s)])
dis = numerator(discriminant(F))
@assert !iszero(dis(t))
rt = roots(dis, AcbField(20))
rt = roots(AcbField(20), dis)
r = Hecke.lower_bound(minimum([abs(x-t) for x = rt]), ZZRingElem)
@assert r > 0
ff = map_coefficients(abs, f)
Expand Down Expand Up @@ -1664,13 +1664,13 @@ If `prime` is given, no search is performed.
function find_prime(f::QQPolyRingElem, extra::Int = 5; prime::Int = 0, pStart::Int = 2*degree(f), filter_prime = x->true, filter_pattern = x->true)
if prime != 0
p = prime
lf = factor(f, GF(p))
lf = factor(GF(p), f)
return p, Set([CycleType(map(degree, collect(keys(lf.fac))))])
end
if pStart < 0
error("should no longer happen")
p = -pStart
lf = factor(f, GF(p))
lf = factor(GF(p), f)
return p, Set([CycleType(map(degree, collect(keys(lf.fac))))])
end

Expand All @@ -1693,7 +1693,7 @@ function find_prime(f::QQPolyRingElem, extra::Int = 5; prime::Int = 0, pStart::I
if k(leading_coefficient(f)) == 0
continue
end
lf = factor(f, GF(p))
lf = factor(GF(p), f)
if any(x->x>1, values(lf.fac))
continue
end
Expand Down Expand Up @@ -2466,7 +2466,7 @@ ideal(x4^4 - 2, x3^3 + x3^2*x4 + x3*x4^2 + x4^3, x2^2 + x2*x3 + x2*x4 + x3^2 + x
julia> k, _ = number_field(i);
julia> length(roots(x^4-2, k))
julia> length(roots(k, x^4-2))
4
```
Expand Down Expand Up @@ -2532,7 +2532,7 @@ function galois_ideal(C::GaloisCtx, extra::Int = 5)
push!(id, sum(evaluate(I^length(h), x) for I = PE) - v)
end
h = Hecke.power_sums_to_polynomial(h)
q = roots(h, number_field(C.f)[1])
q = roots(number_field(C.f)[1], h)
@assert length(q) > 0
q = parent(defining_polynomial(parent(q[1])))(q[1])
#TODO: think h(q(y)) is probably boring, while q(y) == pe might be
Expand Down
4 changes: 2 additions & 2 deletions src/NumberTheory/GaloisGrp/Qt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function _subfields(FF::Generic.FunctionField, f::ZZMPolyRingElem; tStart::Int =
@vprint :Subfields 2 "for $f\n"

d = numerator(discriminant(FF))
rt = roots(d, AcbField(20))
rt = roots(AcbField(20), d)
t = tStart
local g::ZZPolyRingElem
while true
Expand All @@ -140,7 +140,7 @@ function _subfields(FF::Generic.FunctionField, f::ZZMPolyRingElem; tStart::Int =
@vprint :Subfields 2 "now looking for a nice prime...\n"
p, _ = find_prime(defining_polynomial(K), pStart = 200)

d = lcm(map(degree, collect(keys(factor(g, GF(p)).fac))))
d = lcm(map(degree, collect(keys(factor(GF(p), g).fac))))

@assert evaluate(evaluate(f, [X, T+t]), [gen(Zx), zero(Zx)]) == g

Expand Down
2 changes: 1 addition & 1 deletion test/NumberTheory/galthy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
U = trivial_subgroup(G)[1]
L = fixed_field(C, U)
@test degree(L) == order(G)
@test length(roots(k.pol, L)) == 5
@test length(roots(L, k.pol)) == 5

R, x = polynomial_ring(QQ, "x")
pol = x^6 - 366*x^4 - 878*x^3 + 4329*x^2 + 14874*x + 10471
Expand Down

0 comments on commit 2c1b6f6

Please sign in to comment.