JuliaMath / SpecialFunctions.jl

Special mathematical functions in Julia
https://specialfunctions.juliamath.org/stable/
Other
359 stars 100 forks source link

besselk with a BigFloat argument fails #116

Open omalled opened 6 years ago

omalled commented 6 years ago

I'm trying to update some code that currently uses my own implementation of the inverse Laplace transform to use InverseLaplace.jl instead. My code makes a call like SpecialFunctions.besselk(0, x). My implementation of the inverse Laplace transform results in x having type Float64, but InverseLaplace.jl wants x to be a BigFloat. This creates a problem

julia> SpecialFunctions.besselk(0, 1.0)
0.42102443824070834

julia> SpecialFunctions.besselk(0, BigFloat(1.0))
ERROR: MethodError: no method matching besselk(::BigFloat, ::Complex{BigFloat})
Closest candidates are:
  besselk(::T<:AbstractFloat, ::Complex{T<:AbstractFloat}) where T<:AbstractFloat at /homedir/.julia/v0.6/SpecialFunctions/src/bessel.jl:502
  besselk(::Real, ::Complex) at /homedir/.julia/v0.6/SpecialFunctions/src/bessel.jl:499
  besselk(::Any...; kwargs...) at deprecated.jl:1303
  ...
Stacktrace:
 [1] besselk(::Float64, ::Complex{BigFloat}) at /homedir/.julia/v0.6/SpecialFunctions/src/bessel.jl:500
 [2] besselk(::Int64, ::BigFloat) at /homedir/.julia/v0.6/SpecialFunctions/src/bessel.jl:450

It seems like that first candidate fits the bill, but julia disagrees.

simonbyrne commented 6 years ago

There is currently no Bessel k function for BigFloats (the MPFR library we use only provides Bessel j and y functions, see https://www.mpfr.org/mpfr-current/mpfr.html#Special-Functions).