diff --git a/Project.toml b/Project.toml index f188ed8fca..df0d41e460 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Hecke" uuid = "3e1990a7-5d81-5526-99ce-9ba3ff248f21" -version = "0.30.1" +version = "0.30.2" [deps] AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d" diff --git a/src/NumField/ComplexEmbeddings/Generic.jl b/src/NumField/ComplexEmbeddings/Generic.jl index 5c046bb330..0a149e9825 100644 --- a/src/NumField/ComplexEmbeddings/Generic.jl +++ b/src/NumField/ComplexEmbeddings/Generic.jl @@ -488,3 +488,16 @@ function _log_evaluate_fac_elem(e, x, prec) end return z end + +################################################################################ +# +# Complex conjugation +# +################################################################################ + +function complex_conjugation(K::NumField) + L, f = absolute_simple_field(K) + g = inv(f) + conj = complex_conjugation(L) + return compose(compose(g, conj), f) +end diff --git a/src/NumField/ComplexEmbeddings/QQ.jl b/src/NumField/ComplexEmbeddings/QQ.jl index 6849502d99..beb8e8804a 100644 --- a/src/NumField/ComplexEmbeddings/QQ.jl +++ b/src/NumField/ComplexEmbeddings/QQ.jl @@ -52,3 +52,5 @@ sign(x::Union{ZZRingElem, FacElem{QQFieldElem}}, ::QQEmb) = sign(Int, x) signs(x::Union{ZZRingElem, QQFieldElem, FacElem{QQFieldElem}}, ::Vector{QQEmb}) = Dict(QQEmb() => sign(x, QQEmb())) signs(x::Union{ZZRingElem, QQFieldElem, FacElem{QQFieldElem}}) = Dict(QQEmb() => sign(x, QQEmb())) + +complex_conjugation(K::QQField) = identity_map(K) diff --git a/src/NumField/NfAbs/Conjugates.jl b/src/NumField/NfAbs/Conjugates.jl index db4f75331e..633084db8d 100644 --- a/src/NumField/NfAbs/Conjugates.jl +++ b/src/NumField/NfAbs/Conjugates.jl @@ -491,6 +491,9 @@ Given a totally complex normal number field, this function returns an automorphism which is the restriction of complex conjugation at one embedding. """ function complex_conjugation(K::AbsSimpleNumField; auts::Vector{<:NumFieldHom{AbsSimpleNumField, AbsSimpleNumField}} = morphism_type(AbsSimpleNumField, AbsSimpleNumField)[]) + if is_totally_real(K) + return id_hom(K) + end if !isempty(auts) A = auts else diff --git a/test/NfAbs/Conjugates.jl b/test/NfAbs/Conjugates.jl index 9117c437e0..1eb65614c2 100644 --- a/test/NfAbs/Conjugates.jl +++ b/test/NfAbs/Conjugates.jl @@ -110,6 +110,9 @@ end K, a = cyclotomic_field(13) aut = @inferred complex_conjugation(K) @test aut(a) == a^-1 + K, a = quadratic_field(5) + aut = @inferred complex_conjugation(K) + @test aut(a) == a end @testset "Bad example" begin diff --git a/test/NumField/ComplexEmbeddings/Generic.jl b/test/NumField/ComplexEmbeddings/Generic.jl index 44760b7e5b..f1f0c1c432 100644 --- a/test/NumField/ComplexEmbeddings/Generic.jl +++ b/test/NumField/ComplexEmbeddings/Generic.jl @@ -61,6 +61,11 @@ c = FacElem(K(2))^1000 * FacElem(K(3))^-1000 * FacElem(K(5))^1000 @test (@inferred e(c)) isa AcbFieldElem + + c = complex_conjugation(K) + if !(K isa QQField) + @test c == id_hom(K) + end end K, a = quadratic_field(-1) @@ -73,4 +78,23 @@ e = complex_embeddings(k)[1] eext = extend(e, ktoK) @test all(overlaps(c(ktoK(b)), e(b)) for c in eext) + + Qx, x = QQ["x"] + K, _ = rationals_as_number_field() + Kt, t = K["t"] + K1, = number_field(t^2 - 2) + K2, = number_field([t^2 - 2, t^2 - 3]) + K3, = number_field([x^2 - 2, x^2 - 3]) + for K in Any[K1, K2, K3] + c = complex_conjugation(K) + @test c == id_hom(K) + end + + K1, = number_field(t^2 + 2) + K2, = number_field([t^2 + 2]) + K3, = number_field([x^2 + 2]) + for K in Any[K1, K2, K3] + c = complex_conjugation(K) + @test c != id_hom(K) + end end diff --git a/test/NumField/ComplexEmbeddings/QQ.jl b/test/NumField/ComplexEmbeddings/QQ.jl index b648e985b9..fcd5f2d151 100644 --- a/test/NumField/ComplexEmbeddings/QQ.jl +++ b/test/NumField/ComplexEmbeddings/QQ.jl @@ -1,2 +1,4 @@ @testset "QQ" begin + c = complex_conjugation(QQ) + @test c(QQ(1)) == QQ(1) end