Nemo.jl icon indicating copy to clipboard operation
Nemo.jl copied to clipboard

Add conversion QQFieldElem -> Float64 / ComplexF64, and perhaps more generally all Real / Complex subtypes

Open fingolfin opened this issue 2 years ago • 3 comments

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)

fingolfin avatar Jan 31 '24 14:01 fingolfin

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)

fingolfin avatar Jan 31 '24 14:01 fingolfin

Also these should work (but don't)

QQBar(1//2)
QQBarFieldElem(1//2)
QQBarFieldElem(big(1))  # note that QQBar(big(1)) works

fingolfin avatar Jan 31 '24 14:01 fingolfin

Conversion from ZZRingElem should also work (this just came up again while teaching with OSCAR)

fingolfin avatar Jun 20 '24 22:06 fingolfin