Skip to content

Commit df8e419

Browse files
committed
Rename boundtype to numtype
1 parent b84de91 commit df8e419

25 files changed

+291
-291
lines changed

ext/IntervalArithmeticForwardDiffExt.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ ForwardDiff.Dual{T,V}(x::ExactReal) where {T,V} = convert(Dual{T,V}, x)
1515
Base.convert(::Type{Dual{T,V,N}}, x::ExactReal) where {T,V,N} = Dual{T}(V(x), zero(Partials{N,V}))
1616

1717
Base.promote_rule(::Type{Dual{T, V, N}}, ::Type{Interval{S}}) where {T, V, N, S<:Union{AbstractFloat, Rational}} =
18-
Dual{T,Interval{IntervalArithmetic.promote_boundtype(V, S)},N}
18+
Dual{T,Interval{IntervalArithmetic.promote_numtype(V, S)},N}
1919
Base.promote_rule(::Type{Interval{S}}, ::Type{Dual{T, V, N}}) where {S<:Union{AbstractFloat, Rational}, T, V, N} =
20-
Dual{T,Interval{IntervalArithmetic.promote_boundtype(V, S)},N}
20+
Dual{T,Interval{IntervalArithmetic.promote_numtype(V, S)},N}
2121
Base.promote_rule(::Type{ExactReal{S}}, ::Type{Dual{T, V, N}}) where {S<:Real, T, V, N} =
22-
Dual{T,ExactReal{IntervalArithmetic.promote_boundtype(V, S)},N}
22+
Dual{T,ExactReal{IntervalArithmetic.promote_numtype(V, S)},N}
2323
Base.promote_rule(::Type{Dual{T, V, N}}, ::Type{ExactReal{S}}) where {S<:Real, T, V, N} =
24-
Dual{T,ExactReal{IntervalArithmetic.promote_boundtype(V, S)},N}
24+
Dual{T,ExactReal{IntervalArithmetic.promote_numtype(V, S)},N}
2525

2626
Base.:(==)(x::Union{BareInterval,Interval}, y::Dual) = x == value(y)
2727
Base.:(==)(x::Dual, y::Union{BareInterval,Interval}) = value(x) == y

ext/IntervalArithmeticIntervalSetsExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module IntervalArithmeticIntervalSetsExt
33
import IntervalSets as IS
44
import IntervalArithmetic as IA
55

6-
IA.interval(i::IS.Interval{L,R,T}) where {L,R,T} = IA.interval(IA.promote_boundtype(T, T), i)
7-
function IA.interval(::Type{T}, i::IS.Interval{L,R}) where {T<:IA.BoundTypes,L,R}
6+
IA.interval(i::IS.Interval{L,R,T}) where {L,R,T} = IA.interval(IA.promote_numtype(T, T), i)
7+
function IA.interval(::Type{T}, i::IS.Interval{L,R}) where {T<:IA.NumTypes,L,R}
88
# infinite endpoints are always open in IA, finite always closed:
99
isinf(IS.leftendpoint(i)) != IS.isleftopen(i) && return IA.nai(T)
1010
isinf(IS.rightendpoint(i)) != IS.isrightopen(i) && return IA.nai(T)

src/IntervalArithmetic.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Key features:
1111
1212
- **Bound Type**: The default numerical type used to represent the bounds of the
1313
intervals. The default is `Float64`, but other subtypes of
14-
[`IntervalArithmetic.BoundTypes`](@ref) can be used to adjust precision.
14+
[`IntervalArithmetic.NumTypes`](@ref) can be used to adjust precision.
1515
1616
- **Flavor**: The interval representation that adhere to the IEEE Standard
1717
1788-2015. By default, it uses the set-based flavor, which excludes infinity
@@ -97,21 +97,21 @@ include("matmul.jl")
9797

9898
#
9999

100-
function configure_boundtype(boundtype::Type{<:BoundTypes})
101-
@eval promote_boundtype(::Type{T}, ::Type{S}) where {T,S} = promote_type($boundtype, boundtype(T), boundtype(S))
100+
function configure_numtype(numtype::Type{<:NumTypes})
101+
@eval promote_numtype(::Type{T}, ::Type{S}) where {T,S} = promote_type($numtype, numtype(T), numtype(S))
102102
@eval macro interval(expr)
103-
return _wrap_interval($boundtype, expr)
103+
return _wrap_interval($numtype, expr)
104104
end
105-
@eval _parse(str::AbstractString) = parse(Interval{$boundtype}, str)
106-
@eval emptyinterval() = emptyinterval(Interval{$boundtype})
107-
@eval entireinterval() = entireinterval(Interval{$boundtype})
108-
@eval nai() = nai(Interval{$boundtype})
109-
return boundtype
105+
@eval _parse(str::AbstractString) = parse(Interval{$numtype}, str)
106+
@eval emptyinterval() = emptyinterval(Interval{$numtype})
107+
@eval entireinterval() = entireinterval(Interval{$numtype})
108+
@eval nai() = nai(Interval{$numtype})
109+
return numtype
110110
end
111111

112112
function configure_flavor(flavor::Symbol)
113113
flavor == :set_based || return throw(ArgumentError("only the interval flavor `:set_based` is supported and implemented"))
114-
@eval zero_times_infinity(::Type{T}) where {T<:BoundTypes} = zero_times_infinity(Flavor{$(QuoteNode(flavor))}(), T)
114+
@eval zero_times_infinity(::Type{T}) where {T<:NumTypes} = zero_times_infinity(Flavor{$(QuoteNode(flavor))}(), T)
115115
@eval div_by_thin_zero(x::BareInterval) = div_by_thin_zero(Flavor{$(QuoteNode(flavor))}(), x)
116116
@eval contains_infinity(x::BareInterval) = contains_infinity(Flavor{$(QuoteNode(flavor))}(), x)
117117
@eval is_valid_interval(a::Real, b::Real) = is_valid_interval(Flavor{$(QuoteNode(flavor))}(), a, b)
@@ -183,13 +183,13 @@ function configure_matmul(matmul::Symbol)
183183
end
184184

185185
"""
186-
configure(; boundtype=Float64, flavor=:set_based, rounding=:correct, power=:fast, matmul=:fast)
186+
configure(; numtype=Float64, flavor=:set_based, rounding=:correct, power=:fast, matmul=:fast)
187187
188188
Configure the default behavior for:
189189
190190
- **Bound Type**: The default numerical type used to represent the bounds of the
191191
intervals. The default is `Float64`, but other subtypes of
192-
[`IntervalArithmetic.BoundTypes`](@ref) can be used to adjust precision.
192+
[`IntervalArithmetic.NumTypes`](@ref) can be used to adjust precision.
193193
194194
- **Flavor**: The interval representation that adhere to the IEEE Standard
195195
1788-2015. By default, it uses the set-based flavor, which excludes infinity
@@ -211,13 +211,13 @@ Configure the default behavior for:
211211
definition of matrix multiplication. Learn more:
212212
[`IntervalArithmetic.MatMulMode`](@ref).
213213
"""
214-
function configure(; boundtype::Type{<:BoundTypes}=Float64, flavor::Symbol=:set_based, rounding::Symbol=:correct, power::Symbol=:fast, matmul::Symbol=:fast)
215-
configure_boundtype(boundtype)
214+
function configure(; numtype::Type{<:NumTypes}=Float64, flavor::Symbol=:set_based, rounding::Symbol=:correct, power::Symbol=:fast, matmul::Symbol=:fast)
215+
configure_numtype(numtype)
216216
configure_flavor(flavor)
217217
configure_rounding(rounding)
218218
configure_power(power)
219219
configure_matmul(matmul)
220-
return boundtype, flavor, rounding, power, matmul
220+
return numtype, flavor, rounding, power, matmul
221221
end
222222

223223
configure()
@@ -227,7 +227,7 @@ configure()
227227
bareinterval(::Type{BigFloat}, a::AbstractIrrational) = _unsafe_bareinterval(BigFloat, a, a)
228228

229229
# Note: generated functions must be defined after all the methods they use
230-
@generated function bareinterval(::Type{T}, a::AbstractIrrational) where {T<:BoundTypes}
230+
@generated function bareinterval(::Type{T}, a::AbstractIrrational) where {T<:NumTypes}
231231
x = _unsafe_bareinterval(T, a(), a()) # precompute the interval
232232
return :($x) # set body of the function to return the precomputed result
233233
end

src/display.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ Base.show(io::IO, ::MIME"text/plain", a::Union{BareInterval,Interval,Complex{<:I
108108

109109
# `String` representation
110110

111-
function _str_repr(a::BareInterval{T}, format::Symbol) where {T<:BoundTypes}
111+
function _str_repr(a::BareInterval{T}, format::Symbol) where {T<:NumTypes}
112112
# `format` is either `:infsup`, `:midpoint` or `:full`
113113
str_interval = _str_basic_repr(a, format)
114114
((format === :full) & (str_interval != "")) && return string("BareInterval{", T, "}(", str_interval, ')')
115115
return _str_precision(str_interval, a, format)
116116
end
117117

118-
function _str_repr(a::Interval{T}, format::Symbol) where {T<:BoundTypes}
118+
function _str_repr(a::Interval{T}, format::Symbol) where {T<:NumTypes}
119119
# `format` is either `:infsup`, `:midpoint` or `:full`
120120
str_interval = _str_basic_repr(a.bareinterval, format) # use `a.bareinterval` to not print a warning if `a` is an NaI
121121
if format === :full && str_interval != ""
@@ -130,7 +130,7 @@ function _str_repr(a::Interval{T}, format::Symbol) where {T<:BoundTypes}
130130
return ifelse(display_options.ng_flag & !isguaranteed(a), string(str_interval, "_NG"), str_interval)
131131
end
132132

133-
function _str_repr(x::Complex{Interval{T}}, format::Symbol) where {T<:BoundTypes}
133+
function _str_repr(x::Complex{Interval{T}}, format::Symbol) where {T<:NumTypes}
134134
# `format` is either `:infsup`, `:midpoint` or `:full`
135135
str_imag = _str_repr(imag(x), format)
136136
if format === :full

src/intervals/arithmetic/absmax.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
Implement the `abs` function of the IEEE Standard 1788-2015 (Table 9.1).
1010
"""
11-
function Base.abs(x::BareInterval{T}) where {T<:BoundTypes}
11+
function Base.abs(x::BareInterval{T}) where {T<:NumTypes}
1212
isempty_interval(x) && return x
1313
return _unsafe_bareinterval(T, mig(x), mag(x))
1414
end
@@ -45,7 +45,7 @@ for f ∈ (:min, :max)
4545
4646
Implement the `$($f)` function of the IEEE Standard 1788-2015 (Table 9.1).
4747
"""
48-
function Base.$f(x::BareInterval{T}, y::BareInterval{T}) where {T<:BoundTypes}
48+
function Base.$f(x::BareInterval{T}, y::BareInterval{T}) where {T<:NumTypes}
4949
isempty_interval(x) && return x
5050
isempty_interval(y) && return y
5151
return _unsafe_bareinterval(T, $f(inf(x), inf(y)), $f(sup(x), sup(y)))

src/intervals/arithmetic/basic.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Base.:+(x::Interval) = x
1212
1313
Implement the `add` function of the IEEE Standard 1788-2015 (Table 9.1).
1414
"""
15-
function Base.:+(x::BareInterval{T}, y::BareInterval{T}) where {T<:BoundTypes}
15+
function Base.:+(x::BareInterval{T}, y::BareInterval{T}) where {T<:NumTypes}
1616
isempty_interval(x) && return x
1717
isempty_interval(y) && return y
1818
return @round(T, inf(x) + inf(y), sup(x) + sup(y))
@@ -32,7 +32,7 @@ end
3232
3333
Implement the `neg` function of the IEEE Standard 1788-2015 (Table 9.1).
3434
"""
35-
function Base.:-(x::BareInterval{T}) where {T<:BoundTypes}
35+
function Base.:-(x::BareInterval{T}) where {T<:NumTypes}
3636
isempty_interval(x) && return x
3737
return _unsafe_bareinterval(T, -sup(x), -inf(x))
3838
end
@@ -45,7 +45,7 @@ Base.:-(x::Interval) = _unsafe_interval(-bareinterval(x), decoration(x), isguara
4545
4646
Implement the `sub` function of the IEEE Standard 1788-2015 (Table 9.1).
4747
"""
48-
function Base.:-(x::BareInterval{T}, y::BareInterval{T}) where {T<:BoundTypes}
48+
function Base.:-(x::BareInterval{T}, y::BareInterval{T}) where {T<:NumTypes}
4949
isempty_interval(x) && return x
5050
isempty_interval(y) && return y
5151
return @round(T, inf(x) - sup(y), sup(x) - inf(y))
@@ -68,7 +68,7 @@ Implement the `mul` function of the IEEE Standard 1788-2015 (Table 9.1).
6868
!!! note
6969
The behavior of `*` is flavor dependent for some edge cases.
7070
"""
71-
function Base.:*(x::BareInterval{T}, y::BareInterval{T}) where {T<:BoundTypes}
71+
function Base.:*(x::BareInterval{T}, y::BareInterval{T}) where {T<:NumTypes}
7272
isempty_interval(x) && return x
7373
isempty_interval(y) && return y
7474
isthinzero(x) && return x
@@ -87,14 +87,14 @@ end
8787

8888
# helper functions for multiplication
8989

90-
function _unbounded_mul(x::T, y::T, r::RoundingMode) where {T<:BoundTypes}
90+
function _unbounded_mul(x::T, y::T, r::RoundingMode) where {T<:NumTypes}
9191
iszero(x) && return sign(y) * zero_times_infinity(T)
9292
iszero(y) && return sign(x) * zero_times_infinity(T)
9393
return _mul_round(x, y, r)
9494
end
9595

9696
for f (:_unbounded_mul, :*)
97-
@eval function _mult(::typeof($f), x::BareInterval{T}, y::BareInterval{T}) where {T<:BoundTypes}
97+
@eval function _mult(::typeof($f), x::BareInterval{T}, y::BareInterval{T}) where {T<:NumTypes}
9898
if inf(y) 0
9999
inf(x) 0 && return @round(T, $f(inf(x), inf(y)), $f(sup(x), sup(y)))
100100
sup(x) 0 && return @round(T, $f(inf(x), sup(y)), $f(sup(x), inf(y)))
@@ -121,7 +121,7 @@ Implement the `recip` function of the IEEE Standard 1788-2015 (Table 9.1).
121121
!!! note
122122
The behavior of `inv` is flavor dependent for some edge cases.
123123
"""
124-
function Base.inv(x::BareInterval{T}) where {T<:BoundTypes}
124+
function Base.inv(x::BareInterval{T}) where {T<:NumTypes}
125125
isempty_interval(x) && return x
126126
if in_interval(0, x)
127127
inf(x) < 0 == sup(x) && return @round(T, typemin(T), inv(inf(x)))
@@ -155,7 +155,7 @@ Implement the `div` function of the IEEE Standard 1788-2015 (Table 9.1).
155155
!!! note
156156
The behavior of `/` is flavor dependent for some edge cases.
157157
"""
158-
function Base.:/(x::BareInterval{T}, y::BareInterval{T}) where {T<:BoundTypes}
158+
function Base.:/(x::BareInterval{T}, y::BareInterval{T}) where {T<:NumTypes}
159159
isempty_interval(x) && return x
160160
isempty_interval(y) && return y
161161
isthinzero(y) && return div_by_thin_zero(x)
@@ -205,7 +205,7 @@ Base.:\(x::BareInterval, y::BareInterval) = /(y, x)
205205
206206
Implement the combined multiply-add; this is semantically equivalent to `x * y + z`.
207207
"""
208-
Base.muladd(x::BareInterval{T}, y::BareInterval{T}, z::BareInterval{T}) where {T<:BoundTypes} = x * y + z # not in the IEEE Standard 1788-2015
208+
Base.muladd(x::BareInterval{T}, y::BareInterval{T}, z::BareInterval{T}) where {T<:NumTypes} = x * y + z # not in the IEEE Standard 1788-2015
209209
Base.muladd(x::BareInterval, y::BareInterval, z::BareInterval) = muladd(promote(x, y, z)...)
210210

211211
function Base.muladd(x::Interval, y::Interval, z::Interval)
@@ -221,7 +221,7 @@ end
221221
222222
Implement the `fma` function of the IEEE Standard 1788-2015 (Table 9.1).
223223
"""
224-
Base.fma(x::BareInterval{T}, y::BareInterval{T}, z::BareInterval{T}) where {T<:BoundTypes} = x * y + z
224+
Base.fma(x::BareInterval{T}, y::BareInterval{T}, z::BareInterval{T}) where {T<:NumTypes} = x * y + z
225225
Base.fma(x::BareInterval, y::BareInterval, z::BareInterval) = fma(promote(x, y, z)...)
226226

227227
function Base.fma(x::Interval, y::Interval, z::Interval)
@@ -246,7 +246,7 @@ end
246246

247247
Base.sqrt(x::BareInterval{<:Rational}) = sqrt(float(x))
248248

249-
function Base.sqrt(x::Interval{T}) where {T<:BoundTypes}
249+
function Base.sqrt(x::Interval{T}) where {T<:NumTypes}
250250
domain = _unsafe_bareinterval(T, zero(T), typemax(T))
251251
bx = bareinterval(x)
252252
r = sqrt(bx)
@@ -255,4 +255,4 @@ function Base.sqrt(x::Interval{T}) where {T<:BoundTypes}
255255
return _unsafe_interval(r, d, isguaranteed(x))
256256
end
257257

258-
Base.sqrt(x::Complex{Interval{T}}) where {T<:BoundTypes} = x ^ interval(1//2)
258+
Base.sqrt(x::Complex{Interval{T}}) where {T<:NumTypes} = x ^ interval(1//2)

src/intervals/arithmetic/hyperbolic.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ for f ∈ (:sinh, :tanh, :asinh)
2525
end
2626
end
2727

28-
Base.sinh(x::Complex{Interval{T}}) where {T<:BoundTypes} = (exp(x) - exp(-x)) / interval(T, 2)
28+
Base.sinh(x::Complex{Interval{T}}) where {T<:NumTypes} = (exp(x) - exp(-x)) / interval(T, 2)
2929

3030
Base.tanh(x::Complex{<:Interval}) = sinh(x) / cosh(x)
3131

@@ -48,7 +48,7 @@ function Base.cosh(x::Interval)
4848
return _unsafe_interval(r, d, isguaranteed(x))
4949
end
5050

51-
Base.cosh(x::Complex{Interval{T}}) where {T<:BoundTypes} = (exp(x) + exp(-x)) / interval(T, 2)
51+
Base.cosh(x::Complex{Interval{T}}) where {T<:NumTypes} = (exp(x) + exp(-x)) / interval(T, 2)
5252

5353
"""
5454
coth(::BareInterval)
@@ -153,7 +153,7 @@ end
153153

154154
Base.acosh(x::BareInterval{<:Rational}) = acosh(float(x))
155155

156-
function Base.acosh(x::Interval{T}) where {T<:BoundTypes}
156+
function Base.acosh(x::Interval{T}) where {T<:NumTypes}
157157
domain = _unsafe_bareinterval(T, one(T), typemax(T))
158158
bx = bareinterval(x)
159159
r = acosh(bx)
@@ -179,7 +179,7 @@ end
179179

180180
Base.atanh(x::BareInterval{<:Rational}) = atanh(float(x))
181181

182-
function Base.atanh(x::Interval{T}) where {T<:BoundTypes}
182+
function Base.atanh(x::Interval{T}) where {T<:NumTypes}
183183
domain = _unsafe_bareinterval(T, -one(T), one(T))
184184
bx = bareinterval(x)
185185
r = atanh(bx)
@@ -214,7 +214,7 @@ end
214214

215215
Base.acoth(x::BareInterval{<:Rational}) = acoth(float(x))
216216

217-
function Base.acoth(x::Interval{T}) where {T<:BoundTypes}
217+
function Base.acoth(x::Interval{T}) where {T<:NumTypes}
218218
singular_domain = _unsafe_bareinterval(T, -one(T), one(T))
219219
bx = bareinterval(x)
220220
r = acoth(bx)

src/intervals/arithmetic/integer.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
Implement the `sign` function of the IEEE Standard 1788-2015 (Table 9.1).
1010
"""
11-
function Base.sign(x::BareInterval{T}) where {T<:BoundTypes}
11+
function Base.sign(x::BareInterval{T}) where {T<:NumTypes}
1212
isempty_interval(x) && return x
1313
lo, hi = bounds(x)
1414
return _unsafe_bareinterval(T, sign(lo), sign(hi))
@@ -27,7 +27,7 @@ end
2727
2828
Implement the `ceil` function of the IEEE Standard 1788-2015 (Table 9.1).
2929
"""
30-
function Base.ceil(x::BareInterval{T}) where {T<:BoundTypes}
30+
function Base.ceil(x::BareInterval{T}) where {T<:NumTypes}
3131
isempty_interval(x) && return x
3232
lo, hi = bounds(x)
3333
return _unsafe_bareinterval(T, ceil(lo), ceil(hi))
@@ -47,7 +47,7 @@ end
4747
4848
Implement the `floor` function of the IEEE Standard 1788-2015 (Table 9.1).
4949
"""
50-
function Base.floor(x::BareInterval{T}) where {T<:BoundTypes}
50+
function Base.floor(x::BareInterval{T}) where {T<:NumTypes}
5151
isempty_interval(x) && return x
5252
lo, hi = bounds(x)
5353
return _unsafe_bareinterval(T, floor(lo), floor(hi))
@@ -67,7 +67,7 @@ end
6767
6868
Implement the `trunc` function of the IEEE Standard 1788-2015 (Table 9.1).
6969
"""
70-
function Base.trunc(x::BareInterval{T}) where {T<:BoundTypes}
70+
function Base.trunc(x::BareInterval{T}) where {T<:NumTypes}
7171
isempty_interval(x) && return x
7272
lo, hi = bounds(x)
7373
return _unsafe_bareinterval(T, trunc(lo), trunc(hi))
@@ -96,7 +96,7 @@ Base.round(x::Union{BareInterval,Interval}, ::RoundingMode{:Down}) = floor(x)
9696

9797
for (S, R) ((:(:Nearest), :RoundNearest), (:(:NearestTiesAway), :RoundNearestTiesAway))
9898
@eval begin
99-
function Base.round(x::BareInterval{T}, ::RoundingMode{$S}) where {T<:BoundTypes}
99+
function Base.round(x::BareInterval{T}, ::RoundingMode{$S}) where {T<:NumTypes}
100100
isempty_interval(x) && return x
101101
lo, hi = bounds(x)
102102
return _unsafe_bareinterval(T, round(lo, $R), round(hi, $R))

0 commit comments

Comments
 (0)