|
1 | 1 | @testset "chainrules" begin
|
2 | 2 | Random.seed!(1)
|
3 | 3 |
|
4 |
| - @testset "general" begin |
| 4 | + @testset "general: single input" begin |
5 | 5 | for x in (1.0, -1.0, 0.0, 0.5, 10.0, -17.1, 1.5 + 0.7im)
|
6 | 6 | test_scalar(erf, x)
|
7 | 7 | test_scalar(erfc, x)
|
|
12 | 12 | test_scalar(airybi, x)
|
13 | 13 | test_scalar(airybiprime, x)
|
14 | 14 |
|
15 |
| - test_scalar(besselj0, x) |
16 |
| - test_scalar(besselj1, x) |
17 |
| - |
18 | 15 | test_scalar(erfcx, x)
|
19 | 16 | test_scalar(dawson, x)
|
20 | 17 |
|
|
28 | 25 | end
|
29 | 26 |
|
30 | 27 | if x isa Real && x > 0 || x isa Complex
|
31 |
| - test_scalar(bessely0, x) |
32 |
| - test_scalar(bessely1, x) |
33 | 28 | test_scalar(gamma, x)
|
34 | 29 | test_scalar(digamma, x)
|
35 | 30 | test_scalar(trigamma, x)
|
36 | 31 | end
|
37 | 32 | end
|
| 33 | + end |
| 34 | + |
| 35 | + @testset "Bessel functions" begin |
| 36 | + for x in (1.5, 2.5, 10.5, -0.6, -2.6, -3.3, 1.6 + 1.6im, 1.6 - 1.6im, -4.6 + 1.6im) |
| 37 | + test_scalar(besselj0, x) |
| 38 | + test_scalar(besselj1, x) |
| 39 | + |
| 40 | + isreal(x) && x < 0 && continue |
| 41 | + |
| 42 | + test_scalar(bessely0, x) |
| 43 | + test_scalar(bessely1, x) |
| 44 | + |
| 45 | + for nu in (-1.5, 2.2, 4.0) |
| 46 | + test_frule(besseli, nu, x) |
| 47 | + test_rrule(besseli, nu, x) |
38 | 48 |
|
39 |
| - @testset "beta and logbeta" begin |
40 |
| - test_points = (1.5, 2.5, 10.5, 1.6 + 1.6im, 1.6 - 1.6im, 4.6 + 1.6im) |
41 |
| - for _x in test_points, _y in test_points |
42 |
| - # ensure all complex if any complex for FiniteDifferences |
43 |
| - x, y = promote(_x, _y) |
44 |
| - test_frule(beta, x, y) |
45 |
| - test_rrule(beta, x, y) |
| 49 | + test_frule(besselj, nu, x) |
| 50 | + test_rrule(besselj, nu, x) |
46 | 51 |
|
47 |
| - test_frule(logbeta, x, y) |
48 |
| - test_rrule(logbeta, x, y) |
| 52 | + test_frule(besselk, nu, x) |
| 53 | + test_rrule(besselk, nu, x) |
| 54 | + |
| 55 | + test_frule(bessely, nu, x) |
| 56 | + test_rrule(bessely, nu, x) |
| 57 | + |
| 58 | + # use complex numbers in `rrule` for FiniteDifferences |
| 59 | + test_frule(hankelh1, nu, x) |
| 60 | + test_rrule(hankelh1, nu, complex(x)) |
| 61 | + |
| 62 | + # use complex numbers in `rrule` for FiniteDifferences |
| 63 | + test_frule(hankelh2, nu, x) |
| 64 | + test_rrule(hankelh2, nu, complex(x)) |
49 | 65 | end
|
50 | 66 | end
|
| 67 | + end |
51 | 68 |
|
52 |
| - @testset "log gamma and co" begin |
53 |
| - # It is important that we have negative numbers with both odd and even integer parts |
54 |
| - for x in (1.5, 2.5, 10.5, -0.6, -2.6, -3.3, 1.6 + 1.6im, 1.6 - 1.6im, -4.6 + 1.6im) |
55 |
| - isreal(x) && x < 0 && continue |
56 |
| - test_scalar(loggamma, x) |
| 69 | + @testset "beta and logbeta" begin |
| 70 | + test_points = (1.5, 2.5, 10.5, 1.6 + 1.6im, 1.6 - 1.6im, 4.6 + 1.6im) |
| 71 | + for _x in test_points, _y in test_points |
| 72 | + # ensure all complex if any complex for FiniteDifferences |
| 73 | + x, y = promote(_x, _y) |
| 74 | + test_frule(beta, x, y) |
| 75 | + test_rrule(beta, x, y) |
57 | 76 |
|
58 |
| - isreal(x) || continue |
59 |
| - test_frule(logabsgamma, x) |
60 |
| - test_rrule(logabsgamma, x; output_tangent=(randn(), randn())) |
| 77 | + test_frule(logbeta, x, y) |
| 78 | + test_rrule(logbeta, x, y) |
| 79 | + end |
| 80 | + end |
| 81 | + |
| 82 | + @testset "log gamma and co" begin |
| 83 | + # It is important that we have negative numbers with both odd and even integer parts |
| 84 | + for x in (1.5, 2.5, 10.5, -0.6, -2.6, -3.3, 1.6 + 1.6im, 1.6 - 1.6im, -4.6 + 1.6im) |
| 85 | + for m in (0, 1, 2, 3) |
| 86 | + test_frule(polygamma, m, x) |
| 87 | + test_rrule(polygamma, m, x) |
61 | 88 | end
|
| 89 | + |
| 90 | + isreal(x) && x < 0 && continue |
| 91 | + test_scalar(loggamma, x) |
| 92 | + |
| 93 | + isreal(x) || continue |
| 94 | + test_frule(logabsgamma, x) |
| 95 | + test_rrule(logabsgamma, x; output_tangent=(randn(), randn())) |
62 | 96 | end
|
63 | 97 | end
|
64 | 98 | end
|
0 commit comments