Skip to content

Commit

Permalink
Generalise contractors to bareinterval (#6)
Browse files Browse the repository at this point in the history
* Generalize contractors to bare intervals

* Add test

* New line
  • Loading branch information
dpsanders authored Aug 25, 2024
1 parent efaa4a4 commit b239a83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/intervalbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ isinterior(X::IntervalBox{N,T}, Y::IntervalBox{N,T}) where {N,T} = all(isinterio
# Cartesian product:
×(a::IntervalType...) = IntervalBox(a...)
×(a::IntervalType, b::IntervalBox) = IntervalBox(a, b.v...)
×(a::IntervalBox, b::Interval) = IntervalBox(a.v..., b)
×(a::IntervalBox, b::IntervalType) = IntervalBox(a.v..., b)
×(a::IntervalBox, b::IntervalBox) = IntervalBox(a.v..., b.v...)

IntervalBox(x::Interval, ::Val{n}) where {n} = IntervalBox(SVector(ntuple( _ -> x, Val(n) )))
IntervalBox(x::IntervalType, ::Val{n}) where {n} = IntervalBox(SVector(ntuple( _ -> x, Val(n) )))

IntervalBox(x::Interval, n::Int) = IntervalBox(x, Val(n))
IntervalBox(x::IntervalType, n::Int) = IntervalBox(x, Val(n))

dot(x::IntervalBox, y::IntervalBox) = dot(x.v, y.v)

Expand Down
6 changes: 6 additions & 0 deletions test/multidim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,9 @@ end
# end

# end


@testset "Bare interval boxes" begin
x = bareinterval(-1..1)
@test IntervalBox(x, 2) == IntervalBox(x, x)
end

0 comments on commit b239a83

Please sign in to comment.