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

moved QQAb related stuff from experimental to src #2610

Merged
merged 1 commit into from
Jul 31, 2023
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
25 changes: 0 additions & 25 deletions experimental/GModule/Misc.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
function Hecke.minpoly(a::QQAbElem)
return minpoly(data(a))
end

function Hecke.number_field(::QQField, a::QQAbElem; cached::Bool = false)
f = minpoly(a)
k, b = number_field(f, check = false, cached = cached)
return k, b
end

Hecke.minpoly(a::qqbar) = minpoly(Hecke.Globals.Qx, a)

function Hecke.number_field(::QQField, a::qqbar; cached::Bool = false)
Expand Down Expand Up @@ -158,18 +148,3 @@ function cyclo_fixed_group_gens(A::AbstractArray{nf_elem})
end
return [(mR(sR(ms(x))), F) for x = gens(s)]
end

function Hecke.number_field(::QQField, a::AbstractVector{<: QQAbElem}; cached::Bool = false)
if length(a) == 0
return Hecke.rationals_as_number_field()[1]
end
f = lcm([Hecke.is_cyclotomic_type(parent(data(x)))[2] for x = a])
K = cyclotomic_field(f)[1]
k, mkK = Hecke.subfield(K, [K(data(x)) for x = a])
return k, gen(k)
end

Base.getindex(::QQField, a::QQAbElem) = number_field(QQ, a)
Base.getindex(::QQField, a::Vector{QQAbElem}) = number_field(QQ, a)
Base.getindex(::QQField, a::QQAbElem...) = number_field(QQ, [x for x =a])

42 changes: 37 additions & 5 deletions src/Rings/AbelianClosure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,10 @@
function _variable(K::QQAbField)
if isdefined(K, :s)
return K.s
elseif Oscar.is_unicode_allowed()
return "ζ"
else
if Oscar.is_unicode_allowed()
return "ζ"
else
return "zeta"
end
return "zeta"
end
end

Expand Down Expand Up @@ -488,6 +486,40 @@

canonical_unit(a::QQAbElem) = a

################################################################################
#
# Minimal polynomial
#
################################################################################

Hecke.minpoly(a::QQAbElem) = minpoly(data(a))

################################################################################
#
# Syntactic sugar
#
################################################################################

function Hecke.number_field(::QQField, a::QQAbElem; cached::Bool = false)
f = minpoly(a)
k, b = number_field(f, check = false, cached = cached)
return k, b
end

function Hecke.number_field(::QQField, a::AbstractVector{<: QQAbElem}; cached::Bool = false)
if length(a) == 0
return Hecke.rationals_as_number_field()[1]

Check warning on line 511 in src/Rings/AbelianClosure.jl

View check run for this annotation

Codecov / codecov/patch

src/Rings/AbelianClosure.jl#L511

Added line #L511 was not covered by tests
end
f = lcm([Hecke.is_cyclotomic_type(parent(data(x)))[2] for x = a])
K = cyclotomic_field(f)[1]
k, mkK = Hecke.subfield(K, [K(data(x)) for x = a])
return k, gen(k)
end

Base.getindex(::QQField, a::QQAbElem) = number_field(QQ, a)
Base.getindex(::QQField, a::Vector{QQAbElem{T}}) where T = number_field(QQ, a)
Base.getindex(::QQField, a::QQAbElem...) = number_field(QQ, [x for x in a])

################################################################################
#
# Arithmetic
Expand Down
21 changes: 19 additions & 2 deletions test/Rings/AbelianClosure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@ end
K, z = abelian_closure(QQ)
@test sprint(show, "text/plain", K) == "Abelian closure of Q"

@test get_variable(K) == "zeta"
orig = get_variable(K)
@test orig == "zeta"
s = sprint(show, "text/plain", z)

a = z(1)
sprint(show, "text/plain", a) == "1"
a = z(4)
sprint(show, "text/plain", a) == "z(4)"
Oscar.with_unicode() do
# The following holds only if `set_variable!`
# has not been called before for `K`.
@test get_variable(K) == "ζ"
s = sprint(show, "text/plain", z)

Expand All @@ -91,7 +94,7 @@ end
@test isone(a^4) && !isone(a) && !isone(a^2)

# reset variable for any subsequent (doc-)tests
@test set_variable!(K, "z") == "ω"
@test set_variable!(K, orig) == "ω"
end

@testset "Coercion" begin
Expand All @@ -104,6 +107,7 @@ end
fb = minpoly(Oscar.AbelianClosure.data(b))
fc = minpoly(Oscar.AbelianClosure.data(c))
fd = minpoly(Oscar.AbelianClosure.data(d))
@test fa == minpoly(a)
@test iszero(fa(c)) && iszero(fc(a))
@test iszero(fb(d)) && iszero(fd(b))
@test_throws Hecke.NotImplemented Oscar.AbelianClosure.coerce_down(Hecke.rationals_as_number_field()[1], 1, z(2))
Expand Down Expand Up @@ -324,4 +328,17 @@ end
K, z = abelian_closure(QQ)
S = [z(3)]
@test degree(number_field(QQ, S)[1]) == 2

@testset "Syntax to create number fields from QabElem" begin
K, z = abelian_closure(QQ)
F, a = QQ[z(5)]
@test F isa AnticNumberField
@test dim(F) == 4
F, a = QQ[[z(5), z(3)]]
@test F isa AnticNumberField
@test dim(F) == 8
F, a = QQ[z(5), z(3)]
@test F isa AnticNumberField
@test dim(F) == 8
end
end
Loading