Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable disabling of caching in completion_easy #1696

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/LocalField/Conjugates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function roots(C::qAdicRootCtx, n::Int = 10)
end

@doc raw"""
qAdicConj(K::AbsSimpleNumField, p::Int)
qAdicConj(K::AbsSimpleNumField, p::Int; cached::Bool = true)

Creates a data structure to compute the conjugates in an unramified splitting field
over $Q_p$.
Expand All @@ -123,7 +123,7 @@ mutable struct qAdicConj
C::qAdicRootCtx
cache::Dict{AbsSimpleNumFieldElem, Any}

function qAdicConj(K::AbsSimpleNumField, p::Int; splitting_field::Bool = false)
function qAdicConj(K::AbsSimpleNumField, p::Int; splitting_field::Bool = false, cached::Bool = true)
if discriminant(map_coefficients(Native.GF(p), K.pol)) == 0
error("cannot deal with difficult primes yet")
end
Expand All @@ -143,7 +143,8 @@ mutable struct qAdicConj
D = get_attribute!(K, :nf_conjugate_data_qAdic) do
return Dict{Int, Tuple{qAdicRootCtx, Dict{AbsSimpleNumFieldElem, Any}}}()
end::Dict{Int, Tuple{qAdicRootCtx, Dict{AbsSimpleNumFieldElem, Any}}}
Dp = get!(D, p) do

Dp = get_cached!(D, p, cached) do
Zx = polynomial_ring(ZZ, cached = false)[1]
d = lcm(map(denominator, coefficients(K.pol)))
C = qAdicRootCtx(Zx(K.pol*d), p)
Expand Down Expand Up @@ -499,7 +500,7 @@ function lift_root(f::ZZPolyRingElem, a::AbsSimpleNumFieldElem, o::AbsSimpleNumF
end

@doc raw"""
completion_easy(K::AbsSimpleNumField, P::AbsNumFieldOrderIdeal{AbsSimpleNumField, AbsSimpleNumFieldElem})
completion_easy(K::AbsSimpleNumField, P::AbsNumFieldOrderIdeal; cached::Bool = true)
-> QadicField, CompletionMap

The completion of $K$ wrt to the topology induced by the valuation at the
Expand All @@ -509,35 +510,35 @@ The map giving the embedding of $K$ into the completion, admits a pointwise
preimage to obtain a lift. Note, that the map is not well defined by this
data: $K$ will have $\deg P$ many embeddings.
"""
function completion_easy(K::AbsSimpleNumField, P::AbsNumFieldOrderIdeal{AbsSimpleNumField, AbsSimpleNumFieldElem}, precision::Int = 10)
function completion_easy(K::AbsSimpleNumField, P::AbsNumFieldOrderIdeal{AbsSimpleNumField, AbsSimpleNumFieldElem}, precision::Int = 10; cached::Bool = true)
#non-unique!! will have deg(P) many
p = minimum(P)
C = qAdicConj(K, Int(p))
C = qAdicConj(K, Int(p); cached)
g = conjugates(P.gen_two.elem_in_nf, C)
# @show map(x->valuation(x), g)
i = findfirst(x->valuation(x) > 0, g)
return completion(K, p, i, precision)
return completion(K, p, i, precision; cached)
end

completion(K::AbsSimpleNumField, p::Integer, i::Int, precision::Int = 64) = completion(K, ZZRingElem(p), i, precision)
completion(K::AbsSimpleNumField, p::Integer, i::Int, precision::Int = 64; cached::Bool = true) = completion(K, ZZRingElem(p), i, precision; cached)

@doc raw"""
completion(K::AbsSimpleNumField, p::ZZRingElem, i::Int) -> QadicField, Map

The completion corresponding to the $i$-th conjugate in the non-canonical ordering of
`conjugates`.
"""
function completion(K::AbsSimpleNumField, p::ZZRingElem, i::Int, n = 64)
C = qAdicConj(K, Int(p))
function completion(K::AbsSimpleNumField, p::ZZRingElem, i::Int, n = 64; cached::Bool = true)
C = qAdicConj(K, Int(p); cached)
@assert 0<i<= degree(K)

ca = conjugates(gen(K), C, n, all = true, flat = false)[i]
return completion(K, ca)
return completion(K, ca; cached)
end

function completion(K::AbsSimpleNumField, ca::QadicFieldElem)
function completion(K::AbsSimpleNumField, ca::QadicFieldElem; cached::Bool = true)
p = prime(parent(ca))
C = qAdicConj(K, Int(p))
C = qAdicConj(K, Int(p); cached)
r = roots(C.C, precision(ca))
i = findfirst(x->parent(r[x]) == parent(ca) && r[x] == ca, 1:length(r))
Zx = polynomial_ring(ZZ, cached = false)[1]
Expand Down
2 changes: 2 additions & 0 deletions test/LocalField/Conjugates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

@test valuation(a - preimage(mL1, mL1(a)), lp[2][1]) >= 10
@test valuation(a - preimage(mL2, mL2(a)), lp[1][1]) >= 10

@test degree(codomain(completion(k, 37, 2; cached = false)[2])) == 2
end
end

Expand Down
Loading