make float32 bessels type stable#120
Merged
oscardssmith merged 3 commits intomasterfrom Jun 21, 2025
Merged
Conversation
Member
|
Ya... the Float32 implementations on some of these functions is definitely lacking. Would like to see some more pure implementations but these changes look good to me! |
Member
Author
|
shall we merge as is and wait for further improvements? |
Member
Author
|
Merging soonish unless there's objections |
inkydragon
reviewed
Dec 15, 2025
|
|
||
| _, Uk_Yn = Uk_poly_Hankel(p*im, v, -p2, T(x)) | ||
| return coef_Yn * Uk_Yn | ||
| return T(coef_Yn * Uk_Yn) |
Member
There was a problem hiding this comment.
This change break CI.
https://github.com/JuliaMath/Bessels.jl/actions/runs/20239790685/job/58104358142?pr=124#step:6:164
besselj: Error During Test at /home/runner/work/Bessels.jl/Bessels.jl/test/besselj_test.jl:118
Test threw exception
Expression: isapprox((Bessels.BesselFunctions.besseljy_positive_args(v, xx))[1], sf, rtol = 1.0e-12)
InexactError: Float64(-0.06838365257880721 - 0.1665302180645065im)
Stacktrace:
[1] Real
@ ./complex.jl:44 [inlined]
[2] hankel_debye(v::Float64, x::Float64)
@ Bessels.BesselFunctions ~/work/Bessels.jl/Bessels.jl/src/BesselFunctions/U_polynomials.jl:105
[3] besseljy_positive_args(nu::Float64, x::Float64)
@ Bessels.BesselFunctions ~/work/Bessels.jl/Bessels.jl/src/BesselFunctions/hankel.jl:139
[4] macro expansion
@ /opt/hostedtoolcache/julia/1.9.4/x64/share/julia/stdlib/v1.9/Test/src/Test.jl:478 [inlined]
[5] top-level scope
@ ~/work/Bessels.jl/Bessels.jl/test/besselj_test.jl:118
Return the Hankel function H(nu, x) = J(nu, x) + Y(nu, x)*im
(coef_Yn * Uk_Yn) isa Complex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These are not good implementations of these functions for Float32 (since they do all the math in Float64 to Float64 tolerances before converting back), but they are at least type stable (and as a bonus, now work with CUDA.jl)