Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fingolfin opened this issue Jan 31, 2024 · 3 comments

Comments

@fingolfin
Copy link
Member

fingolfin commented Jan 31, 2024

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
Copy link
Member Author

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
Copy link
Member Author

fingolfin commented Jan 31, 2024

Also these should work (but don't)

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

@fingolfin
Copy link
Member Author

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

@fingolfin fingolfin changed the title Add conversion QQFieldElem -> Float64 / ComplexF64, and perhaps more generally all Real / Complex subtypes Add conversion QQBarFieldElem -> Float64 / ComplexF64, and perhaps more generally all Real / Complex subtypes Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant