Skip to content

Commit

Permalink
#2453 - Vertices list of IntervalArithmetic types (#2457)
Browse files Browse the repository at this point in the history
* vertices list of IA types

* typo

* Update unit_Interval.jl
  • Loading branch information
mforets authored Dec 22, 2020
1 parent 7a12227 commit 3910423
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Sets/Interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -699,3 +699,19 @@ end
return result
end
end

function vertices_list(x::IntervalArithmetic.Interval{N}) where {N}
a = IntervalArithmetic.inf(x)
b = IntervalArithmetic.sup(x)
ST = IntervalArithmetic.SVector{1, N}
if _isapprox(a, b)
vlist = [ST(a)]
else
vlist = [ST(a), ST(b)]
end
return vlist
end

function vertices_list(H::IntervalArithmetic.IntervalBox)
return vertices_list(convert(Hyperrectangle, H))
end
8 changes: 8 additions & 0 deletions test/unit_Interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,12 @@ for N in Ns
@test rectify(x) == Interval(N(0), N(2))
x = Interval(N(1), N(2))
@test rectify(x) == x

# list of vertices of IA types
b = IA.IntervalBox(IA.Interval(0 , 1), IA.Interval(0, 1))
vlistIB = vertices_list(b)
@test is_cyclic_permutation(vlistIB, [SA[N(1), N(1)], SA[N(0), N(1)], SA[N(1), N(0)], SA[N(0), N(0)]])

vlistI = vertices_list(b[1])
@test is_cyclic_permutation(vlistI, [SA[N(0)], SA[N(1)]])
end

0 comments on commit 3910423

Please sign in to comment.