Skip to content

Commit

Permalink
bug: fix padic regulator computation (#1360)
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma authored Jan 21, 2024
1 parent 63f0f7a commit 0526c55
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Hecke"
uuid = "3e1990a7-5d81-5526-99ce-9ba3ff248f21"
version = "0.24.2"
version = "0.24.3"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
Expand Down
38 changes: 32 additions & 6 deletions examples/NFDB.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1177,32 +1177,51 @@ function _p_adic_regulator(K, p, fast::Bool = false)
if fast
try
C, mC = completion_easy(K, P, prec)
catch
catch e
if !(e isa ErrorException && e.msg == "cannot deal with difficult primes yet")
rethrow()
end
C, mC = completion(K, P, prec)
end
else
C, mC = completion(K, P, prec)
end
Rmat = zero_matrix(C, r, r)
D = Dict{nf_elem, elem_type(C)}()
good = true
for i in 1:r
for j in 1:r
Rmat[i, j] = _evaluate_log_of_fac_elem(mC, P, mA(A[i])(mU(U[j + 1])), D) # j + 1, because the fundamental units correspond to U[2],..,U[r + 1]
try
Rmat[i, j] = _evaluate_log_of_fac_elem(mC, P, mA(A[i])(mU(U[j + 1])), D) # j + 1, because the fundamental units correspond to U[2],..,U[r + 1]
catch e
if !(e isa ErrorException && e.msg == "precision too low")
rethrow()
end
good = false
break
end
end
if !good
break
end
end
if !good
prec = 2*prec
continue
end
z = _det(Rmat)
if !is_zero(z)
return valuation(z)
else
prec = 2*prec
end
if prec > 4048
if prec > 2^15
error("Something wrong")
end
end
end

function _evaluate_log_of_fac_elem(mC, P, e::FacElem{nf_elem, AnticNumberField}, D = Dict{nf_elem, LocalFieldElem{qadic, EisensteinLocalField}}())
function _evaluate_log_of_fac_elem(mC, P, e::FacElem{nf_elem, AnticNumberField}, D = Dict{nf_elem, elem_type(codomain(mC))}())
C = codomain(mC)
K = base_ring(e)
pi = K(uniformizer(P))
Expand All @@ -1217,7 +1236,14 @@ function _evaluate_log_of_fac_elem(mC, P, e::FacElem{nf_elem, AnticNumberField},
for (b, n) in e
l = get!(D, b) do
bb = mC(pi^(-valuation(b, P)) * b)
return log(bb)
if is_zero(bb)
error("precision too low")
end
if bb isa qadic
return _log(bb)
else
return log(bb)
end
end
res = res + n * l
end
Expand All @@ -1233,7 +1259,7 @@ function _padic_regulator_non_normal(K, p)
# first identify the distinct p-adic completions of K
A, mA = automorphism_group(N)
d = degree(N)
prec = 32
prec = 32
auts = Int[]
while true
empty!(auts)
Expand Down

2 comments on commit 0526c55

@thofma
Copy link
Owner Author

@thofma thofma commented on 0526c55 Jan 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/99260

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.24.3 -m "<description of version>" 0526c55a46adb963290c2d537f145a328770eb8d
git push origin v0.24.3

Please sign in to comment.