|
3 | 3 | # here we will test just a few cases of the overall hankel function |
4 | 4 | # focusing on negative arguments and reflection |
5 | 5 |
|
6 | | -v, x = 1.5, 1.3 |
7 | | -@test isapprox(hankelh1(v, x), SpecialFunctions.hankelh1(v, x), rtol=2e-13) |
8 | | -@test isapprox(hankelh2(v, x), SpecialFunctions.hankelh2(v, x), rtol=2e-13) |
9 | | -@test isapprox(besselh(v, 1, x), SpecialFunctions.besselh(v, 1, x), rtol=2e-13) |
10 | | -@test isapprox(besselh(v, 2, x), SpecialFunctions.besselh(v, 2, x), rtol=2e-13) |
| 6 | +@testset "$T" for T in (Float32, Float64) |
| 7 | + rtol = T == Float64 ? 2e-13 : 2e-6 |
| 8 | + v, x = T(1.5), T(1.3) |
| 9 | + @test isapprox(hankelh1(v, x), SpecialFunctions.hankelh1(v, x); rtol) |
| 10 | + @test isapprox(hankelh2(v, x), SpecialFunctions.hankelh2(v, x); rtol) |
| 11 | + @test isapprox(besselh(v, 1, x), SpecialFunctions.besselh(v, 1, x); rtol) |
| 12 | + @test isapprox(besselh(v, 2, x), SpecialFunctions.besselh(v, 2, x); rtol) |
| 13 | + @inferred besselh(v, 2, x) |
| 14 | + |
| 15 | + v, x = T(-2.6), T(9.2) |
| 16 | + @test isapprox(hankelh1(v, x), SpecialFunctions.hankelh1(v, x); rtol) |
| 17 | + @test isapprox(hankelh2(v, x), SpecialFunctions.hankelh2(v, x); rtol) |
| 18 | + @test isapprox(besselh(v, 1, x), SpecialFunctions.besselh(v, 1, x); rtol) |
| 19 | + @test isapprox(besselh(v, 2, x), SpecialFunctions.besselh(v, 2, x); rtol) |
| 20 | + @inferred besselh(v, 2, x) |
11 | 21 |
|
12 | | -v, x = -2.6, 9.2 |
13 | | -@test isapprox(hankelh1(v, x), SpecialFunctions.hankelh1(v, x), rtol=2e-13) |
14 | | -@test isapprox(hankelh2(v, x), SpecialFunctions.hankelh2(v, x), rtol=2e-13) |
15 | | -@test isapprox(besselh(v, 1, x), SpecialFunctions.besselh(v, 1, x), rtol=2e-13) |
16 | | -@test isapprox(besselh(v, 2, x), SpecialFunctions.besselh(v, 2, x), rtol=2e-13) |
| 22 | + v, x = T(-4.0), T(11.4) |
| 23 | + @test isapprox(hankelh1(v, x), SpecialFunctions.hankelh1(v, x); rtol) |
| 24 | + @test isapprox(hankelh2(v, x), SpecialFunctions.hankelh2(v, x); rtol) |
| 25 | + @test isapprox(besselh(v, 1, x), SpecialFunctions.besselh(v, 1, x); rtol) |
| 26 | + @test isapprox(besselh(v, 2, x), SpecialFunctions.besselh(v, 2, x); rtol) |
| 27 | + @inferred besselh(v, 2, x) |
17 | 28 |
|
18 | | -v, x = -4.0, 11.4 |
19 | | -@test isapprox(hankelh1(v, x), SpecialFunctions.hankelh1(v, x), rtol=2e-13) |
20 | | -@test isapprox(hankelh2(v, x), SpecialFunctions.hankelh2(v, x), rtol=2e-13) |
21 | | -@test isapprox(besselh(v, 1, x), SpecialFunctions.besselh(v, 1, x), rtol=2e-13) |
22 | | -@test isapprox(besselh(v, 2, x), SpecialFunctions.besselh(v, 2, x), rtol=2e-13) |
| 29 | + v, x = T(14.3), T(29.4) |
| 30 | + @test isapprox(hankelh1(v, x), SpecialFunctions.hankelh1(v, x); rtol) |
| 31 | + @test isapprox(hankelh2(v, x), SpecialFunctions.hankelh2(v, x); rtol) |
| 32 | + @test isapprox(besselh(v, 1, x), SpecialFunctions.besselh(v, 1, x); rtol) |
| 33 | + @test isapprox(besselh(v, 2, x), SpecialFunctions.besselh(v, 2, x); rtol) |
| 34 | + @inferred besselh(v, 2, x) |
23 | 35 |
|
24 | | -v, x = 14.3, 29.4 |
25 | | -@test isapprox(hankelh1(v, x), SpecialFunctions.hankelh1(v, x), rtol=2e-13) |
26 | | -@test isapprox(hankelh2(v, x), SpecialFunctions.hankelh2(v, x), rtol=2e-13) |
27 | | -@test isapprox(besselh(v, 1, x), SpecialFunctions.besselh(v, 1, x), rtol=2e-13) |
28 | | -@test isapprox(besselh(v, 2, x), SpecialFunctions.besselh(v, 2, x), rtol=2e-13) |
| 36 | + @test isapprox(hankelh1(1:50, T(10)), SpecialFunctions.hankelh1.(1:50, 10.0); rtol) |
| 37 | + @test isapprox(hankelh1(T(0.5):T(25.5), T(15)), SpecialFunctions.hankelh1.(0.5:1:25.5, 15.0); rtol) |
| 38 | + @test isapprox(hankelh1(1:50, T(100)), SpecialFunctions.hankelh1.(1:50, 100.0); 2*rtol) |
| 39 | + @test isapprox(hankelh2(1:50, T(10)), SpecialFunctions.hankelh2.(1:50, 10.0); rtol) |
| 40 | + @inferred hankelh2(1:50, T(10)) |
29 | 41 |
|
30 | | -@test isapprox(hankelh1(1:50, 10.0), SpecialFunctions.hankelh1.(1:50, 10.0), rtol=2e-13) |
31 | | -@test isapprox(hankelh1(0.5:1:25.5, 15.0), SpecialFunctions.hankelh1.(0.5:1:25.5, 15.0), rtol=2e-13) |
32 | | -@test isapprox(hankelh1(1:50, 100.0), SpecialFunctions.hankelh1.(1:50, 100.0), rtol=2e-13) |
33 | | -@test isapprox(hankelh2(1:50, 10.0), SpecialFunctions.hankelh2.(1:50, 10.0), rtol=2e-13) |
34 | | - |
35 | | -#test 2 arg version |
36 | | -@test besselh(v, 1, x) == besselh(v, x) |
37 | | -@test besselh(1:50, 1, 10.0) == besselh(1:50, 10.0) |
| 42 | + #test 2 arg version |
| 43 | + @test besselh(v, 1, x) == besselh(v, x) |
| 44 | + @test besselh(1:50, 1, T(10.0)) == besselh(1:50, T(10.0)) |
| 45 | +end |
0 commit comments