diff --git a/src/calcium/qqbar.jl b/src/calcium/qqbar.jl index 8f16dfc388..7c918a0c9b 100644 --- a/src/calcium/qqbar.jl +++ b/src/calcium/qqbar.jl @@ -1484,6 +1484,17 @@ function ZZRingElem(a::QQBarFieldElem) return z end +function (::Type{ComplexF64})(x::QQBarFieldElem) + z = AcbField(53, cached = false)(x) + x = ArbFieldElem() + ccall((:acb_get_real, libflint), Nothing, (Ref{ArbFieldElem}, Ref{AcbFieldElem}), x, z) + xx = Float64(x) + y = ArbFieldElem() + ccall((:acb_get_imag, libflint), Nothing, (Ref{ArbFieldElem}, Ref{AcbFieldElem}), y, z) + yy = Float64(y) + return ComplexF64(xx, yy) +end + ############################################################################### # # Unsafe functions diff --git a/test/calcium/qqbar-test.jl b/test/calcium/qqbar-test.jl index 5432691608..e094b624d4 100644 --- a/test/calcium/qqbar-test.jl +++ b/test/calcium/qqbar-test.jl @@ -389,6 +389,19 @@ end end +@testset "QQBarFieldElem.conversions" begin + R = algebraic_closure(QQ) + + # precision must be < 53, otherwise the test is wrong + set_precision!(Balls, 50) do + for i in 1:10 + a = rand(R, degree=5, bits=5) + b = ComplexF64(a) + @test contains(ComplexField()(a), ComplexField()(b)) + end + end +end + function test_elem(R::QQBarField) return rand(R, degree=5, bits=5) end