-
Notifications
You must be signed in to change notification settings - Fork 62
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
Allow coercion and conversion from AcbFieldElem
and ComplexFieldElem
to Float64
and ComplexF64
#2018
Conversation
function convert(::Type{ComplexF64}, x::AcbFieldElem) | ||
return ComplexF64(x) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thofma so we have this convert
method here because it existed before... We can remove it, but technically this is breaking. Thoughts? (I am fine with breaking ; or leaving it in; as long as we agree)
function convert(::Type{Float64}, x::AcbFieldElem) | ||
return Float64(x) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thofma This convert
method was added "for symmetry". But of course we can also remove it and only keep the convert
to ComplexF64
(to retain compatibility), or drop both...
I guess we can keep the |
re = _real_ptr(x) | ||
t = _mid_ptr(re) | ||
# 4 == round to nearest | ||
v = @ccall libflint.arf_get_d(t::Ptr{arf_struct}, 4::Int)::Float64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really should have constants for this. This is the declaration in C:
typedef enum
{
ARF_RND_DOWN = 0,
ARF_RND_UP = 1,
ARF_RND_FLOOR = 2,
ARF_RND_CEIL = 3,
ARF_RND_NEAR = 4
}
arf_rnd_t;
We should have something similar, say
const ARF_RND_DOWN = 0
const ARF_RND_UP = 1
const ARF_RND_FLOOR = 2
const ARF_RND_CEIL = 3
const ARF_RND_NEAR = 4
somewhere in the code (for now we could create this manually, on the long run this could be created/updated from the FLINT code by a script @lgoettgens is working on).
@jamesnohilly please make a follow-up PR to add these constants somewhere (perhaps in src/arb/ArbTypes.jl
for now), and use them at least in the code you are adding here (and possibly other places calling arf_get_d
)
AcbFieldElem
and ComplexFieldElem
to Float64
and ComplexF64
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2018 +/- ##
==========================================
+ Coverage 88.31% 88.33% +0.02%
==========================================
Files 98 98
Lines 36181 36203 +22
==========================================
+ Hits 31953 31981 +28
+ Misses 4228 4222 -6 ☔ View full report in Codecov by Sentry. |
This PR adds conversion functionality for
Float64
and type-based conversion forComplexF64
forAcbFieldElem
andComplexFieldElem
. It follows the same structure asArbFieldElem
by splitting the conversion code into their types and using this in the appropriateconvert
.This PR references oscar-system/Oscar.jl#4531.