Skip to content

Commit add89bd

Browse files
committed
Fix stack overflow error
1 parent 8b9f4fd commit add89bd

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/IntervalArithmetic.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import Base:
2323
<, >, ==, !=, , ^, <=, >=,
2424
in, zero, one, eps, typemin, typemax, abs, abs2, min, max,
2525
sqrt, exp, log, exp2, exp10, log2, log10, inv, cbrt, hypot,
26-
sin, cos, tan, cot, csc, sec, asin, acos, atan, acot, sinpi, cospi,
26+
rad2deg, deg2rad,
27+
sin, cos, tan, cot, csc, sec, asin, acos, atan, acot, sinpi, cospi, sincospi,
2728
sinh, cosh, tanh, coth, csch, sech, asinh, acosh, atanh, acoth,
2829
union, intersect, isempty,
2930
convert, eltype, size,

src/intervals/arithmetic/trigonometric.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
# Section 9.1 of the IEEE Standard 1788-2015 and required for set-based flavor
33
# in Section 10.5.3
44

5+
# needed to prevent stack overflow
6+
7+
rad2deg(x::Interval) = (x / π) * 180
8+
9+
deg2rad(x::Interval) = (x * π) / 180
10+
11+
sincospi(x::Interval) = (sinpi(x), cospi(x))
12+
13+
#
14+
515
const halfpi = π / 2
616

717
half_pi(::Type{T}) where {T<:NumTypes} = unsafe_scale(convert(T, 0.5), interval(T, π))
@@ -132,10 +142,7 @@ function sin(a::Interval{Float64})
132142
end
133143
end
134144

135-
function sinpi(a::Interval{T}) where {T<:NumTypes}
136-
isempty(a) && return a
137-
return sin(a * interval(T, π))
138-
end
145+
sinpi(a::Interval) = sin(a * π)
139146

140147
"""
141148
cos(a::Interval)
@@ -225,10 +232,7 @@ function cos(a::Interval{Float64})
225232
end
226233
end
227234

228-
function cospi(a::Interval{T}) where {T<:NumTypes}
229-
isempty(a) && return a
230-
return cos(a * interval(T, π))
231-
end
235+
cospi(a::Interval) = cos(a * π)
232236

233237
"""
234238
tan(a::Interval)

0 commit comments

Comments
 (0)