Skip to content

Commit 9889d2a

Browse files
committed
add float16 test and update news.md
1 parent dab6277 commit 9889d2a

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ For bug fixes, performance enhancements, or fixes to unexported functions we wil
1313
### Added
1414
- add an unexport method (`Bessels.besseljy(nu, x)`) for faster computation of `besselj` and `bessely` (#33)
1515
- add exported methods for Hankel functions `besselh(nu, k, x)`, `hankelh1(nu, x)`, `hankelh2(nu, x)` (#33)
16+
- add exported methods for spherical bessel function `sphericalbesselj(nu, x)`, `sphericalbesselj(nu, x)`, (#38)
1617

1718
### Fixed
1819
- fix cutoff in `bessely` to not return error for integer orders and small arguments (#33)

src/math_constants.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ const PIO4(::Type{Float32}) = 0.78539816339744830962f0
2121
const TWOOPI(::Type{Float32}) = 0.636619772367581343075535f0
2222
const THPIO4(::Type{Float32}) = 2.35619449019234492885f0
2323
const SQ2O2(::Type{Float32}) = 0.7071067811865476f0
24+
const SQPIO2(::Type{Float32}) = 1.25331413731550025f0

test/sphericalbessel_test.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ x = 1e-15
3232
@test isnan(Bessels.sphericalbessely(1.4, NaN))
3333
@test isnan(Bessels.sphericalbessely(4.0, NaN))
3434

35+
# test Float16 types
36+
@test Bessels.sphericalbesselj(1.4, Float16(1.2)) isa Float16
37+
@test Bessels.sphericalbessely(1.4, Float16(1.2)) isa Float16
3538

3639
for x in 0.5:1.0:100.0, v in [0, 1, 5.5, 8.2, 10]
3740
@test isapprox(Bessels.sphericalbesselj(v, x), SpecialFunctions.sphericalbesselj(v, x), rtol=1e-12)
@@ -43,6 +46,8 @@ for x in 5.5:4.0:160.0, v in [20, 25.0, 32.4, 40.0, 45.12, 50.0, 55.2, 60.124, 7
4346
@test isapprox(Bessels.sphericalbessely(v, x), SpecialFunctions.sphericalbessely(v, x), rtol=3e-12)
4447
end
4548

49+
@test isapprox(Bessels.sphericalbessely(270, 240.0), SpecialFunctions.sphericalbessely(270, 240.0), rtol=3e-12)
50+
4651
v, x = -4.0, 5.6
4752
@test isapprox(Bessels.sphericalbesselj(v, x), 0.07774965105230025584537, rtol=3e-12)
4853
@test isapprox(Bessels.sphericalbessely(v, x), -0.1833997131521190346258, rtol=3e-12)

0 commit comments

Comments
 (0)