Skip to content

Commit

Permalink
Completes libieeep1788_bool.jl (#400)
Browse files Browse the repository at this point in the history
* Add nai case to decorations binary functions

* Add libieeep1788_bool.jl
  • Loading branch information
krish8484 committed Sep 27, 2020
1 parent b18e2ab commit 930ef28
Show file tree
Hide file tree
Showing 3 changed files with 626 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/decorations/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bool_functions = (
)

bool_binary_functions = (
:<, :>, :!=, :, :<=,
:<, :>, :!=, :, :<=, :(==),
:isinterior, :isdisjoint, :precedes, :strictprecedes
)

Expand All @@ -36,18 +36,15 @@ for f in bool_functions
end

for f in bool_binary_functions
@eval $(f)(xx::DecoratedInterval, yy::DecoratedInterval) =
@eval function $(f)(xx::DecoratedInterval, yy::DecoratedInterval)
(isnai(xx) || isnai(yy)) && return false
$(f)(interval(xx), interval(yy))
end
end

in(x::T, a::DecoratedInterval) where T<:Real = in(x, interval(a))


function ==(x::DecoratedInterval, y::DecoratedInterval)
isnai(x) && isnai(y) && return true
return (==(interval(x), interval(y)))
end

## scalar functions: mig, mag and friends
scalar_functions = (
:mig, :mag, :inf, :sup, :mid, :diam, :radius, :dist, :eps, :midpoint_radius
Expand Down
4 changes: 2 additions & 2 deletions test/ITF1788_tests/ieee1788-constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ end

# Example from Section 11.3
@testset "IEEE1788.e" begin
@test DecoratedInterval(2, 1) == nai()
@test isnai(DecoratedInterval(2, 1))
end

# Examples from Table 12.1
Expand Down Expand Up @@ -99,7 +99,7 @@ end
@test decoration(@decorated("-10??u")) == decoration(DecoratedInterval(Interval(-10.0, Inf), dac))
@test @decorated("-10??") == DecoratedInterval(Interval(-Inf, Inf), dac)
@test decoration(@decorated("-10??")) == decoration(DecoratedInterval(Interval(-Inf, Inf), dac))
@test @decorated("[nai]") == nai()
@test isnai(@decorated("[nai]"))
@test @decorated("3.56?1_def") == DecoratedInterval(Interval(0x3.8ccccccccccccp+0, 0x3.91eb851eb8520p+0), def)
@test decoration(@decorated("3.56?1_def")) == decoration(DecoratedInterval(Interval(0x3.8ccccccccccccp+0, 0x3.91eb851eb8520p+0), def))
end
Expand Down

0 comments on commit 930ef28

Please sign in to comment.