Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ uuid = "0e736298-9ec6-45e8-9647-e4fc86a2fe38"
version = "0.3.0-DEV"

[deps]
Gamma = "a0844989-3bd2-4988-8bea-c9407ab0941b"
SIMDMath = "5443be0b-e40a-4f70-a07e-dcd652efc383"

[weakdeps]
Expand All @@ -13,6 +14,7 @@ BesselsEnzymeCoreExt = "EnzymeCore"

[compat]
EnzymeCore = "0.7, 0.8"
Gamma = "1.0.0"
SIMDMath = "0.2.5"
julia = "1.9"

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Numerical routines for computing Bessel, Airy, and Hankel functions for real arg

The goal of the library is to provide high quality numerical implementations of Bessel functions with high accuracy without comprimising on computational time. In general, we try to match (and often exceed) the accuracy of other open source routines such as those provided by [SpecialFunctions.jl](https://github.com/JuliaMath/SpecialFunctions.jl). There are instances where we don't quite match that desired accuracy (within a digit or two) but in general will provide implementations that are 5-10x faster (see [benchmarks](https://github.com/JuliaMath/Bessels.jl#benchmarks)).

The library currently supports Bessel functions, modified Bessel functions, Hankel functions, spherical Bessel functions, and Airy functions of the first and second kind for positive real arguments and integer and noninteger orders. Negative arguments are also supported only if the return value is real. [Limited support](https://github.com/JuliaMath/Bessels.jl#complex-numbers) is provided for complex arguments. An unexported gamma function is also provided.
The library currently supports Bessel functions, modified Bessel functions, Hankel functions, spherical Bessel functions, and Airy functions of the first and second kind for positive real arguments and integer and noninteger orders. Negative arguments are also supported only if the return value is real. [Limited support](https://github.com/JuliaMath/Bessels.jl#complex-numbers) is provided for complex arguments.

# Quick start

Expand Down Expand Up @@ -184,7 +184,7 @@ Stacktrace:
@ REPL[62]:1
```
#### Gamma
We also provide an unexported gamma function for real arguments that can be called with `Bessels.gamma(x)`.
We also provide an unexported gamma function for real arguments that can be called with `Bessels.gamma(x)`, but this is just a re-export from `Gamma.jl` so if you only want a Gamma function, you should use `Gamma.jl` rather than `Bessels.jl`.

# Accuracy

Expand Down
5 changes: 0 additions & 5 deletions docs/src/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,3 @@ airyaiprime
airybi
airybiprime
```

# Gamma functions
```@docs
Bessels.gamma
```
6 changes: 3 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

Bessels.jl is a collection of mathematical algorithms to compute special functions written entirely in the Julia programming language. It is focused on providing high quality implementations of mathematical functions that are accurate and highly performant. Since it contains only Julia code and has no external dependencies, it is a lightweight package that can be used in any high performance application while taking advatnage of the dynamism of the Julia language.

Bessels.jl contains numerous definitions of special functions important in many fields of mathematical physics. Available functions include Bessel, Modified Bessel, Spherical Bessel, Airy, Hankel, and Gamma functions. A full list of available functions can be found in the API section of this documentation. Initial development has focused on providing implementations for real arguments, however, some functions (e.g., Airy) also accept complex numbers as input.
Bessels.jl contains numerous definitions of special functions important in many fields of mathematical physics. Available functions include Bessel, Modified Bessel, Spherical Bessel, Airy, and Hankel functions. A full list of available functions can be found in the API section of this documentation. Initial development has focused on providing implementations for real arguments, however, some functions (e.g., Airy) also accept complex numbers as input.

## Scope

Bessels.jl started simply as a package to compute just the Bessel function of the first kind and zero order, but it has quickly grown to include several Bessel type functions. As mentioned earlier, Bessels.jl contains algorithms for computing Bessel, Modified Bessel, Spherical Bessel, Airy, and Hankel functions. These functions are contained in Chapters 9 and 10 of the [NIST Digital Library of Mathematical Functions](https://dlmf.nist.gov/). However, there exists other types of related functions such as the Struve and Weber type functions contained in Chapters 11 and 12. In general, these are special cases of the confuent hypergeometric functions $_0F_1, _1F_1$, and $_1F_2$. Additionally, several other special functions such as the gamma functions are also needed to compute these types of functions.
Bessels.jl started simply as a package to compute just the Bessel function of the first kind and zero order, but it has quickly grown to include several Bessel type functions. As mentioned earlier, Bessels.jl contains algorithms for computing Bessel, Modified Bessel, Spherical Bessel, Airy, and Hankel functions. These functions are contained in Chapters 9 and 10 of the [NIST Digital Library of Mathematical Functions](https://dlmf.nist.gov/). However, there exists other types of related functions such as the Struve and Weber type functions contained in Chapters 11 and 12. In general, these are special cases of the confuent hypergeometric functions $_0F_1, _1F_1$, and $_1F_2$.

Therefore, Bessels.jl seeks to be home to any Bessel or related functions (see the section provided by [mpmath](https://mpmath.org/doc/current/functions/bessel.html)) which are typically contained in Chapters 9-12 of the NIST Digital library or to any other related function required to compute Bessel type functions.

Expand Down Expand Up @@ -64,4 +64,4 @@ If you are using Bessels.jl, please feel free to add yours to the list!
- [Cephes](https://netlib.org/cephes/)
- [fortran-bessels](https://github.com/perazz/fortran-bessels)

This is by no means exhaustive so please add yours or any others that should be listed.
This is by no means exhaustive so please add yours or any others that should be listed.
4 changes: 2 additions & 2 deletions src/BesselFunctions/BesselFunctions.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module BesselFunctions

using ..GammaFunctions
using Gamma: gamma, loggamma
using ..Math

export besselj0
Expand Down Expand Up @@ -57,4 +57,4 @@ include("Float128/constants.jl")
include("Float128/besselj.jl")
include("Float128/bessely.jl")

end
end
2 changes: 1 addition & 1 deletion src/BesselFunctions/besselj.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ besselj_series_cutoff(v, x::Float64) = (x < 7.0) || v > (2 + x*(0.109 + 0.062*x)
# cutoff for Float128 for ~1e-35 relative error
#besselj_series_cutoff(v, x::AbstractFloat) = (x < 4.0) || v > (x*(0.08 + 0.12*x))


#=
# this needs a better way to sum these as it produces large errors
# use when v is large and x is small
# though when v is large we should use the debye expansion instead
# also do not have a julia implementation of loggamma so will not use for now
function log_besselj_small_arguments_orders(v, x::T) where T
MaxIter = 3000
out = zero(T)
Expand Down
2 changes: 1 addition & 1 deletion src/BesselFunctions/bessely.jl
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ end
# this also works well for nu > 1.35x - 4.5
# for nu > 25 more cancellation occurs near integer values
# There could be premature underflow when (x/2)^v == 0.
# It might be better to use logarithms (when we get loggamma julia implementation)
# It might be better to use logarithms, now that we have loggamma julia implementation
"""
bessely_power_series(nu, x::T) where T <: Float64

Expand Down
5 changes: 3 additions & 2 deletions src/Bessels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ export airybix
export airybiprime
export airybiprimex


using Gamma

include("Math/Math.jl")
include("GammaFunctions/GammaFunctions.jl")
include("AiryFunctions/AiryFunctions.jl")
include("BesselFunctions/BesselFunctions.jl")

using .GammaFunctions
using .AiryFunctions
using .BesselFunctions

Expand Down
9 changes: 0 additions & 9 deletions src/GammaFunctions/GammaFunctions.jl

This file was deleted.

117 changes: 0 additions & 117 deletions src/GammaFunctions/gamma.jl

This file was deleted.

16 changes: 0 additions & 16 deletions test/gamma_test.jl

This file was deleted.

4 changes: 1 addition & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import SpecialFunctions
@time @testset "besselj" begin include("besselj_test.jl") end
@time @testset "bessely" begin include("bessely_test.jl") end
@time @testset "hankel" begin include("hankel_test.jl") end
@time @testset "gamma" begin include("gamma_test.jl") end
@time @testset "airy" begin include("airy_test.jl") end
@time @testset "sphericalbessel" begin include("sphericalbessel_test.jl") end

# https://github.com/EnzymeAD/Enzyme.jl/issues/2699
if VERSION > v"1.12"
if VERSION > v"1.12-"
@warn "Skipping enzyme autodiff tests on Julia > 1.12 due to Enzyme.jl compatibility issues."
else
@time @testset "besselk enzyme autodiff" begin include("besselk_enzyme_test.jl") end
Expand Down
Loading