|
| 1 | +using SpecialFunctions, Reactant |
| 2 | + |
| 3 | +macro ≈(a, b) |
| 4 | + return quote |
| 5 | + isapprox($a, $b; atol=1e-14) |
| 6 | + end |
| 7 | +end |
| 8 | + |
| 9 | +@testset "gamma" begin |
| 10 | + @test SpecialFunctions.gamma(0.5) ≈ @jit(SpecialFunctions.gamma(ConcreteRNumber(0.5))) |
| 11 | + @test SpecialFunctions.gamma(2) ≈ @jit(SpecialFunctions.gamma(ConcreteRNumber(2))) |
| 12 | +end |
| 13 | + |
| 14 | +@testset "loggamma" begin |
| 15 | + @test SpecialFunctions.loggamma(0.5) ≈ |
| 16 | + @jit(SpecialFunctions.loggamma(ConcreteRNumber(0.5))) |
| 17 | + @test SpecialFunctions.loggamma(2) ≈ @jit(SpecialFunctions.loggamma(ConcreteRNumber(2))) |
| 18 | +end |
| 19 | + |
| 20 | +@testset "digamma" begin |
| 21 | + @test SpecialFunctions.digamma(0.5) ≈ |
| 22 | + @jit(SpecialFunctions.digamma(ConcreteRNumber(0.5))) |
| 23 | + @test SpecialFunctions.digamma(2) ≈ @jit(SpecialFunctions.digamma(ConcreteRNumber(2))) |
| 24 | +end |
| 25 | + |
| 26 | +@testset "trigamma" begin |
| 27 | + @test SpecialFunctions.trigamma(0.5) ≈ |
| 28 | + @jit(SpecialFunctions.trigamma(ConcreteRNumber(0.5))) |
| 29 | + @test SpecialFunctions.trigamma(2) ≈ @jit(SpecialFunctions.trigamma(ConcreteRNumber(2))) |
| 30 | +end |
| 31 | + |
| 32 | +@testset "beta" begin |
| 33 | + @test SpecialFunctions.beta(0.5, 0.6) ≈ |
| 34 | + @jit(SpecialFunctions.beta(ConcreteRNumber(0.5), ConcreteRNumber(0.6))) |
| 35 | + @test SpecialFunctions.beta(2, 4) ≈ |
| 36 | + @jit(SpecialFunctions.beta(ConcreteRNumber(2), ConcreteRNumber(4))) |
| 37 | +end |
| 38 | + |
| 39 | +@testset "logbeta" begin |
| 40 | + @test SpecialFunctions.logbeta(0.5, 0.6) ≈ |
| 41 | + @jit(SpecialFunctions.logbeta(ConcreteRNumber(0.5), ConcreteRNumber(0.6))) |
| 42 | + @test SpecialFunctions.logbeta(2, 4) ≈ |
| 43 | + @jit(SpecialFunctions.logbeta(ConcreteRNumber(2), ConcreteRNumber(4))) |
| 44 | +end |
| 45 | + |
| 46 | +@testset "erf" begin |
| 47 | + @test SpecialFunctions.erf(0.5) ≈ @jit(SpecialFunctions.erf(ConcreteRNumber(0.5))) |
| 48 | + @test SpecialFunctions.erf(2) ≈ @jit(SpecialFunctions.erf(ConcreteRNumber(2))) |
| 49 | +end |
| 50 | + |
| 51 | +@testset "erf with 2 arguments" begin |
| 52 | + @test SpecialFunctions.erf(0.5, 0.6) ≈ |
| 53 | + @jit(SpecialFunctions.erf(ConcreteRNumber(0.5), ConcreteRNumber(0.6))) |
| 54 | + @test SpecialFunctions.erf(2, 4) ≈ |
| 55 | + @jit(SpecialFunctions.erf(ConcreteRNumber(2), ConcreteRNumber(4))) |
| 56 | +end |
| 57 | + |
| 58 | +@testset "erfc" begin |
| 59 | + @test SpecialFunctions.erfc(0.5) ≈ @jit(SpecialFunctions.erfc(ConcreteRNumber(0.5))) |
| 60 | + @test SpecialFunctions.erfc(2) ≈ @jit(SpecialFunctions.erfc(ConcreteRNumber(2))) |
| 61 | +end |
| 62 | + |
| 63 | +@testset "logerf" begin |
| 64 | + @test SpecialFunctions.logerf(0.5, 0.6) ≈ |
| 65 | + @jit(SpecialFunctions.logerf(ConcreteRNumber(0.5), ConcreteRNumber(0.6))) |
| 66 | + @test SpecialFunctions.logerf(2, 4) ≈ |
| 67 | + @jit(SpecialFunctions.logerf(ConcreteRNumber(2), ConcreteRNumber(4))) |
| 68 | +end |
| 69 | + |
| 70 | +@testset "erfcx" begin |
| 71 | + @test SpecialFunctions.erfcx(0.5) ≈ @jit(SpecialFunctions.erfcx(ConcreteRNumber(0.5))) |
| 72 | + @test SpecialFunctions.erfcx(2) ≈ @jit(SpecialFunctions.erfcx(ConcreteRNumber(2))) |
| 73 | +end |
| 74 | + |
| 75 | +@testset "logerfc" begin |
| 76 | + @test SpecialFunctions.logerfc(0.5) ≈ |
| 77 | + @jit(SpecialFunctions.logerfc(ConcreteRNumber(0.5))) |
| 78 | + @test SpecialFunctions.logerfc(2) ≈ @jit(SpecialFunctions.logerfc(ConcreteRNumber(2))) |
| 79 | +end |
| 80 | + |
| 81 | +@testset "logerfcx" begin |
| 82 | + @test SpecialFunctions.logerfcx(0.5) ≈ |
| 83 | + @jit(SpecialFunctions.logerfcx(ConcreteRNumber(0.5))) |
| 84 | + @test SpecialFunctions.logerfcx(2) ≈ @jit(SpecialFunctions.logerfcx(ConcreteRNumber(2))) |
| 85 | +end |
| 86 | + |
| 87 | +@testset "loggamma1p" begin |
| 88 | + @test SpecialFunctions.loggamma1p(0.5) ≈ |
| 89 | + @jit SpecialFunctions.loggamma1p(ConcreteRNumber(0.5)) |
| 90 | +end |
| 91 | + |
| 92 | +@testset "loggammadiv" begin |
| 93 | + @test SpecialFunctions.loggammadiv(150, 20) ≈ |
| 94 | + @jit SpecialFunctions.loggammadiv(ConcreteRNumber(150), ConcreteRNumber(20)) |
| 95 | +end |
| 96 | + |
| 97 | +@testset "zeta" begin |
| 98 | + s = ConcreteRArray([1.0, 2.0, 50.0]) |
| 99 | + z = ConcreteRArray([1e-8, 0.001, 2.0]) |
| 100 | + @test SpecialFunctions.zeta.(Array(s), Array(z)) ≈ @jit SpecialFunctions.zeta.(s, z) |
| 101 | +end |
0 commit comments