Nemo.jl
Nemo.jl copied to clipboard
Add conversion QQFieldElem -> Float64 / ComplexF64, and perhaps more generally all Real / Complex subtypes
Right now I have to do this:
julia> x = sqrt(QQBar(2))
Root 1.41421 of x^2 - 2
julia> RR = ArbField(64);
julia> Float64(RR(x))
1.4142135623730951
It would be nice if I could just do Float64(x), alas:
julia> Float64(x)
ERROR: MethodError: no method matching Float64(::QQBarFieldElem)
While add it, maybe also add convert methods to/from QQBar?
convert(::Type{T}, x::QQBarFieldElem) where T <: Number = T(x)
convert(::Type{QQBarFieldElem}, x::Number) = QQBarFieldElem(x)
Also these should work (but don't)
QQBar(1//2)
QQBarFieldElem(1//2)
QQBarFieldElem(big(1)) # note that QQBar(big(1)) works
Conversion from ZZRingElem should also work (this just came up again while teaching with OSCAR)