Skip to content

Commit

Permalink
cache Galois results (in AbsSimpleField) (#4056)
Browse files Browse the repository at this point in the history
  • Loading branch information
fieker committed Aug 29, 2024
1 parent fd7e9b8 commit 70de637
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/NumberTheory/GaloisGrp/GaloisGrp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1952,10 +1952,18 @@ function galois_group(K::AbsSimpleNumField, extra::Int = 5;
pStart::Int = 2*degree(K),
prime::Int = 0,
do_shape::Bool = true,
redo::Bool = false,
algorithm::Symbol=:pAdic,
field::Union{Nothing, AbsSimpleNumField} = nothing)

@assert algorithm in [:pAdic, :Complex, :Symbolic]

X = get_attribute(K, :GaloisCtx)
if X !== nothing && !redo && algorithm == :pAdic
if prime == 0 || X.prime == prime
return X.G, X
end
end

if do_shape
p, ct = find_prime(K.pol, pStart)
Expand Down Expand Up @@ -2007,6 +2015,9 @@ function galois_group(K::AbsSimpleNumField, extra::Int = 5;
G = symmetric_group(degree(K))
end
GC.G = G
if algorithm == :pAdic
set_attribute!(K, :GaloisCtx => GC)
end
return G, GC
end

Expand All @@ -2028,6 +2039,9 @@ function galois_group(K::AbsSimpleNumField, extra::Int = 5;
# some subgroups of the wreath products
if degree(K) == 1
GC.G = G
if algorithm == :pAdic
set_attribute!(K, :GaloisCtx => GC)
end
return G, GC
end

Expand All @@ -2040,6 +2054,9 @@ function galois_group(K::AbsSimpleNumField, extra::Int = 5;

# TODO: here we know if we are primitive; can we detect 2-transitive (inside starting_group)?

if algorithm == :pAdic
set_attribute!(K, :GaloisCtx => GC)
end
return descent(GC, G, F, si, extra = extra)
end
end
Expand All @@ -2053,7 +2070,7 @@ supergroup of the Galois group, operating on the roots in `GC`, the context obje
The groups are filtered by `F` and the result needs to contain the permutation `si`.
For verbose output, the groups are printed through `grp_id`.
"""
function descent(GC::GaloisCtx, G::PermGroup, F::GroupFilter, si::PermGroupElem; grp_id = transitive_group_identification, extra::Int = 5)
function descent(GC::GaloisCtx, G::PermGroup, F::GroupFilter, si::PermGroupElem; grp_id = x -> degree(x) >= 32 ? (degree(x), -1) : transitive_group_identification(x), extra::Int = 5)
@vprint :GaloisGroup 2 "Have starting group with id $(grp_id(G))\n"

n = degree(GC.f)
Expand Down
5 changes: 5 additions & 0 deletions test/NumberTheory/galthy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
Gs, Cs = galois_group(K, algorithm = :Symbolic)
@test is_isomorphic(G, Gc)
@test is_isomorphic(G, Gs)
_G, _C = galois_group(K)
# test caching
@test C === _C
_G, _C = galois_group(K; redo = true)
@test C !== _C

# from the book
K, a = number_field(x^9 - 3*x^8 + x^6 + 15*x^5 - 13*x^4 -
Expand Down

0 comments on commit 70de637

Please sign in to comment.