-
Notifications
You must be signed in to change notification settings - Fork 102
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
Internals of BigFloat getting changed in 1.12 #485
Comments
Simple MWE: julia> using SpecialFunctions
Precompiling SpecialFunctions finished.
1 dependency successfully precompiled in 2 seconds. 17 already precompiled.
julia> gamma(big(1.), 0)
1.0
julia> gamma(big(1), 0)
ERROR: not compatible with mpfr
Stacktrace: |
The current implmentation is: using Base.MPFR: MPFRRoundingMode, ROUNDING_MODE
function _gamma(x::BigFloat)
isnan(x) && return x
z = BigFloat()
ccall((:mpfr_gamma, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Int32), z, x, ROUNDING_MODE[])
isnan(z) && throw(DomainError(x, "NaN result for non-NaN input."))
return z
end The current ccall((:mpfr_gamma, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, MPFRRoundingMode), z, x, Base.Rounding.rounding_raw(BigFloat)) but this shouldn't change anything. We should also change What else should change? |
I think you're looking at the wrong method? The failing one is SpecialFunctions.jl/src/gamma_inc.jl Lines 1149 to 1161 in f8fd782
|
I believe the issue is that
julia nightly:
|
Shouldn't |
Based on the stacktrace we're hitting this |
Basically, 1.11:
master:
|
Why can't |
Since this was specifically introduced in the PR which reworked BigFloat this looks completely deliberate. |
In particular, couldn't we just have: Base.cconvert(::Type{Ref{BigFloat}}, x::Number) = convert(BigFloat, x).d ? This mirrors the behavior in earlier versions, where |
It still does. |
The problem is that Doing this right is the whole job of |
Fixed in JuliaLang/julia#57367 |
#55906 changed `cconvert(Ref{BigFloat}, x::BigFloat)` to return `x.d`, but neglected to do so for other types of `x`, where it still returns a `Ref{BigFloat}` and hence is now returning the wrong type for `ccall`. Not only does this break backwards compatibility (JuliaMath/SpecialFunctions.jl#485), but it also seems simply wrong: the *whole* job of `cconvert` is to convert objects to the correct type for use with `ccall`. This PR does so (at least for `Number` and `Ref{BigFloat}`).
#55906 changed `cconvert(Ref{BigFloat}, x::BigFloat)` to return `x.d`, but neglected to do so for other types of `x`, where it still returns a `Ref{BigFloat}` and hence is now returning the wrong type for `ccall`. Not only does this break backwards compatibility (JuliaMath/SpecialFunctions.jl#485), but it also seems simply wrong: the *whole* job of `cconvert` is to convert objects to the correct type for use with `ccall`. This PR does so (at least for `Number` and `Ref{BigFloat}`). (cherry picked from commit 6dca4f4)
See JuliaLang/julia#55906.
Now causes
The text was updated successfully, but these errors were encountered: