-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #560 from OlivierHnt/1.0-constructors
1.0-dev: rework constructors
- Loading branch information
Showing
53 changed files
with
1,740 additions
and
1,925 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
include("intervals.jl") | ||
include("functions.jl") | ||
|
||
isnan(x::Interval) = false # NaI is always decorated | ||
isnan(::Interval) = false # NaI is always decorated | ||
|
||
"""`NaI` not-an-interval: [NaN, NaN].""" | ||
nai(::Type{T}) where T = DecoratedInterval(convert(T, NaN), convert(T, NaN), ill) | ||
nai(::Type{F}) where {T, F<:Interval{T}} = nai(T) | ||
nai(::Interval{T}) where T<:Real = nai(T) | ||
nai(::DecoratedInterval{T}) where T<:Real = nai(T) | ||
nai() = nai(Interval{default_bound()}) | ||
nai(::Type{Interval{T}}) where {T<:NumTypes} = nai(T) | ||
nai(::Type{T}) where {T<:NumTypes} = DecoratedInterval(convert(T, NaN), convert(T, NaN), ill) | ||
nai(::Type{<:Real}) = nai(default_numtype()) | ||
nai() = nai(default_numtype()) | ||
nai(::T) where {T} = nai(T) | ||
|
||
isnai(x::Interval) = isnan(inf(x)) || isnan(sup(x)) #|| inf(x) > sup(x) || (isinf(inf(x)) && inf(x) == sup(x)) | ||
isnai(x::Interval) = isnan(inf(x)) || isnan(sup(x)) # || inf(x) > sup(x) || (isinf(inf(x)) && inf(x) == sup(x)) | ||
isnai(x::DecoratedInterval) = isnai(interval(x)) || x.decoration == ill |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,41 @@ | ||
# This file is part of the IntervalArithmetic.jl package; MIT licensed | ||
# This file contains the functions described as "Absmax functions" in Section | ||
# 9.1 of the IEEE Standard 1788-2015 and required for set-based flavor in | ||
# Section 10.5.3 | ||
|
||
#= This file contains the functions described as "Absmax functions" | ||
in the IEEE Std 1788-2015 (sections 9.1) and required for set-based flavor | ||
in section 10.5.3. | ||
=# | ||
""" | ||
abs(a::Interval) | ||
Implement the `abs` function of the IEEE Std 1788-2015 (Table 9.1). | ||
Implement the `abs` function of the IEEE Standard 1788-2015 (Table 9.1). | ||
""" | ||
function abs(a::F) where {F<:Interval} | ||
isempty(a) && return emptyinterval(F) | ||
return F(mig(a), mag(a)) | ||
function abs(a::Interval{T}) where {T<:NumTypes} | ||
isempty(a) && return a | ||
return unsafe_interval(T, mig(a), mag(a)) | ||
end | ||
|
||
abs2(a::Interval) = sqr(a) | ||
|
||
""" | ||
min(a::Interval) | ||
min(a::Interval, b::Interval) | ||
Implement the `min` function of the IEEE Std 1788-2015 (Table 9.1). | ||
Implement the `min` function of the IEEE Standard 1788-2015 (Table 9.1). | ||
""" | ||
function min(a::F, b::F) where {F<:Interval} | ||
(isempty(a) || isempty(b)) && return emptyinterval(F) | ||
return F(min(inf(a), inf(b)), min(sup(a), sup(b))) | ||
function min(a::Interval{T}, b::Interval{T}) where {T<:NumTypes} | ||
isempty(a) && return a | ||
isempty(b) && return b | ||
return unsafe_interval(T, min(inf(a), inf(b)), min(sup(a), sup(b))) | ||
end | ||
|
||
min(a::Interval, b::Interval) = min(promote(a, b)...) | ||
|
||
""" | ||
max(a::Interval) | ||
max(a::Interval, b::Interval) | ||
Implement the `max` function of the IEEE Std 1788-2015 (Table 9.1). | ||
Implement the `max` function of the IEEE Standard 1788-2015 (Table 9.1). | ||
""" | ||
function max(a::F, b::F) where {F<:Interval} | ||
(isempty(a) || isempty(b)) && return emptyinterval(F) | ||
return F(max(inf(a), inf(b)), max(sup(a), sup(b))) | ||
function max(a::Interval{T}, b::Interval{T}) where {T<:NumTypes} | ||
isempty(a) && return a | ||
isempty(b) && return b | ||
return unsafe_interval(T, max(inf(a), inf(b)), max(sup(a), sup(b))) | ||
end | ||
|
||
max(a::Interval, b::Interval) = max(promote(a, b)...) |
Oops, something went wrong.