-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Julia ports of hyperbolic (including inverse) functions from openlibm. #24159
Changes from 1 commit
fd37f3d
0bead47
53886c5
9cba2fa
423d46a
dd8c892
4daaa8b
6bd838c
5f8f975
ecbc401
2aec485
7bf4cdf
90b5c45
ea5c860
79d7477
ee9b458
1fbca61
0424b85
cc7e1f7
248dcbb
2b396ad
c15347b
79ae7d1
eb1390a
c3bedbd
d92b7bc
b751c37
5c22157
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -844,6 +844,8 @@ end | |
end | ||
#prev, current, next float | ||
pcnfloat(x) = prevfloat(x), x, nextfloat(x) | ||
import Base.Math: COSH_SMALL_X, H_SMALL_X, H_MEDIUM_X, H_LARGE_X | ||
|
||
@testset "sinh" begin | ||
for T in (Float32, Float64) | ||
@test sinh(zero(T)) === zero(T) | ||
|
@@ -853,14 +855,10 @@ pcnfloat(x) = prevfloat(x), x, nextfloat(x) | |
@test sinh(T(1000)) === T(Inf) | ||
@test sinh(-T(1000)) === -T(Inf) | ||
@test isnan_type(T, sinh(T(NaN))) | ||
end | ||
for x in (pcnfloat(2.0^-28)..., pcnfloat(22.0)..., pcnfloat(709.7822265633563)...) | ||
@test sinh(x) ≈ sinh(big(x)) rtol=eps(Float64) | ||
@test sinh(-x) ≈ sinh(big(-x)) rtol=eps(Float64) | ||
end | ||
for x in (pcnfloat(2f-12)..., pcnfloat(9f0)..., pcnfloat(88.72283f0)...) | ||
@test sinh(x) ≈ sinh(big(x)) rtol=eps(Float32) | ||
@test sinh(-x) ≈ sinh(big(-x)) rtol=eps(Float32) | ||
for x in Iterators.flatten(pcnfloat.([H_SMALL_X(T), H_MEDIUM_X(T), H_LARGE_X(T)])) | ||
@test sinh(x) ≈ sinh(big(x)) rtol=eps(T) | ||
@test sinh(-x) ≈ sinh(big(-x)) rtol=eps(T) | ||
end | ||
end | ||
end | ||
|
||
|
@@ -873,14 +871,10 @@ end | |
@test cosh(T(1000)) === T(Inf) | ||
@test cosh(-T(1000)) === T(Inf) | ||
@test isnan_type(T, cosh(T(NaN))) | ||
end | ||
for x in (pcnfloat(2.7755602085408512e-17)..., pcnfloat(22.0)..., pcnfloat(709.7822265633563)...) | ||
@test cosh(x) ≈ cosh(big(x)) rtol=eps(Float64) | ||
@test cosh(-x) ≈ cosh(big(-x)) rtol=eps(Float64) | ||
end | ||
for x in (pcnfloat(0.00024414062f0)..., pcnfloat(9f0)..., pcnfloat(88.72283f0)...) | ||
@test cosh(x) ≈ cosh(big(x)) rtol=eps(Float32) | ||
@test cosh(-x) ≈ cosh(big(-x)) rtol=eps(Float32) | ||
for x in Iterators.flatten(pcnfloat.([COSH_SMALL_X(T), H_MEDIUM_X(T), H_LARGE_X(T)])) | ||
@test cosh(x) ≈ cosh(big(x)) rtol=eps(T) | ||
@test cosh(-x) ≈ cosh(big(-x)) rtol=eps(T) | ||
end | ||
end | ||
end | ||
|
||
|
@@ -893,7 +887,7 @@ end | |
@test tanh(T(1000)) === one(T) | ||
@test tanh(-T(1000)) === -one(T) | ||
@test isnan_type(T, tanh(T(NaN))) | ||
for x in Iterators.flatten(pcnfloat.(T == Float64 ? [2.0^-28,1.0,22.0] : [2f0^-12,1f0,9f0])) | ||
for x in Iterators.flatten(pcnfloat.([H_SMALL_X(T), T(1.0), H_MEDIUM_X(T)])) | ||
@test tanh(x) ≈ tanh(big(x)) rtol=eps(T) | ||
@test tanh(-x) ≈ tanh(big(-x)) rtol=eps(T) | ||
end | ||
|
@@ -907,7 +901,7 @@ end | |
@test asinh(nextfloat(zero(T))) === nextfloat(zero(T)) | ||
@test asinh(prevfloat(zero(T))) === prevfloat(zero(T)) | ||
@test isnan_type(T, asinh(T(NaN))) | ||
for x in Iterators.flatten(pcnfloat.(T == Float64 ? [2.0^-28,2.0,2.0^28] : [2f0^-12,2f0,22f28])) | ||
for x in Iterators.flatten(pcnfloat.([T(2)^-28,T(2),T(2)])) | ||
@test asinh(x) ≈ asinh(big(x)) rtol=eps(T) | ||
@test asinh(-x) ≈ asinh(big(-x)) rtol=eps(T) | ||
end | ||
|
@@ -919,7 +913,7 @@ end | |
@test_throws DomainError acosh(T(0.1)) | ||
@test acosh(one(T)) === zero(T) | ||
@test isnan_type(T, acosh(T(NaN))) | ||
for x in (nextfloat(T(1)), pcnfloat(T(2))..., pcnfloat(T(2^28))...) | ||
for x in Iterators.flatten(pcnfloat.([T(1) T(2), T(2^28)])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I seem to have pushed without this fix. |
||
@test acosh(x) ≈ acosh(big(x) rtol=eps(T) | ||
end | ||
end | ||
|
@@ -935,7 +929,7 @@ end | |
@test atanh(nextfloat(zero(T))) === nextfloat(zero(T)) | ||
@test atanh(prevfloat(zero(T))) === prevfloat(zero(T)) | ||
@test isnan_type(T, atanh(T(NaN))) | ||
for x in Iterators.flatten(pcnfloat.(T == Float64 ? [2.0^-28,0.5] : [2f-28,0.5f0])) | ||
for x in Iterators.flatten(pcnfloat.([T(2.0)^-28, T(0.5)])) | ||
@test atanh(x) ≈ atanh(big(x)) rtol=eps(T) | ||
@test atanh(-x) ≈ atanh(big(-x)) rtol=eps(T) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second
T(2)
doesn't look right. I assume you meanT(2)^28
?