|
44 | 44 | @test iszero(xlog1py(0 + im * 0, -1 + im * Inf))
|
45 | 45 | end
|
46 | 46 |
|
| 47 | +@testset "xexpx" begin |
| 48 | + for x in (false, 0, 0.0, 0f0, -Inf, -Inf32) |
| 49 | + @test (@inferred xexpx(x)) === zero(exp(x)) |
| 50 | + end |
| 51 | + for x in (NaN16, NaN32, NaN64, Inf16, Inf32, Inf64) |
| 52 | + @test (@inferred xexpx(x)) === x |
| 53 | + end |
| 54 | + for x in (1, true, 1.0, 1f0) |
| 55 | + @test (@inferred xexpx(x)) === exp(x) |
| 56 | + end |
| 57 | + for a in (2, 2f0, 2.0), x in -a:a |
| 58 | + @test (@inferred xexpx(x)) === x * exp(x) |
| 59 | + end |
| 60 | +end |
| 61 | + |
| 62 | +@testset "xexpy" begin |
| 63 | + for x in (0, 1, 1.0, 1f0, Inf, Inf32), y in (-Inf, -Inf32) |
| 64 | + @test (@inferred xexpy(x, y)) === zero(x * exp(y)) |
| 65 | + end |
| 66 | + for x in (0, 1, 1.0, 1f0, Inf, Inf32, -Inf, -Inf32, NaN, NaN32), nan in (NaN, NaN32) |
| 67 | + @test (@inferred xexpy(x, nan)) === oftype(x * exp(nan), NaN) |
| 68 | + @test (@inferred xexpy(nan, x)) === oftype(nan * exp(x), NaN) |
| 69 | + end |
| 70 | + for x in (2, -2f0, 2.0), y in (1, -1f0, 1.0) |
| 71 | + @test (@inferred xexpy(x, y)) ≈ x * exp(y) |
| 72 | + end |
| 73 | + for x in (randn(), randn(Float32)) |
| 74 | + @test xexpy(x, x) ≈ xexpx(x) |
| 75 | + end |
| 76 | +end |
| 77 | + |
47 | 78 | @testset "logistic & logit" begin
|
48 | 79 | @test logistic(2) ≈ 1.0 / (1.0 + exp(-2.0))
|
49 | 80 | @test logistic(-750.0) === 0.0
|
|
0 commit comments