From 753fa25ee22a327bffcf65981c797d2c8f4169d1 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 17 Oct 2024 15:17:23 +0200 Subject: [PATCH] Implement isreal(elm::QQAbFieldElem) (#4207) Also turn QQAbAutomorphism into immutable struct --- src/Rings/AbelianClosure.jl | 4 +++- test/Rings/AbelianClosure.jl | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Rings/AbelianClosure.jl b/src/Rings/AbelianClosure.jl index 662cb496601f..dd60211a93b8 100644 --- a/src/Rings/AbelianClosure.jl +++ b/src/Rings/AbelianClosure.jl @@ -1044,7 +1044,7 @@ end # Then $l = k a n_0 + b n_1$ is coprime to $n$ and has the properties # $l \equiv 1 \pmod{n_0}$ and $l \equiv k \pmod{n_1}$. -mutable struct QQAbAutomorphism +struct QQAbAutomorphism exp::Int end @@ -1084,6 +1084,8 @@ end Base.conj(elm::QQAbFieldElem) = elm^QQAbAutomorphism(-1) +Base.isreal(elm::QQAbFieldElem) = conj(elm) == elm + ############################################################################### # # Elements in quadratic subfields of cyclotomic fields diff --git a/test/Rings/AbelianClosure.jl b/test/Rings/AbelianClosure.jl index cb47f6b42fd8..9fb875fada9f 100644 --- a/test/Rings/AbelianClosure.jl +++ b/test/Rings/AbelianClosure.jl @@ -276,6 +276,10 @@ end f = hom(K, K, 3) @test f(a) == a^3 @test f(z(9)) == z(9) + + @test isone(conj(a)*a) + @test !isreal(a) + @test isreal(a+conj(a)) end @testset "Square roots" begin