Skip to content

Commit

Permalink
feat: enable disabling of caching in completion_easy (#1696)
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma authored Nov 29, 2024
1 parent a9f1690 commit fb22ad4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
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

0 comments on commit fb22ad4

Please sign in to comment.