Skip to content

Commit e6375b0

Browse files
dpsanderslbenet
authored andcommitted
Use broadcasting consistently for multidim operations (#106)
* Use broadcasting consistently for multidim operations * Fix typo
1 parent d5ab93b commit e6375b0

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/multidim/intervalbox.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ mid(X::IntervalBox) = mid.(X)
2424

2525
# TODO: Update to use generator
2626
(X::IntervalBox{N,T}, Y::IntervalBox{N,T}) where {N,T} =
27-
all(i->(X[i] Y[i]), 1:N)
28-
# all(X[i] ⊆ Y[i] for i in 1:N) # on Julia 0.6
27+
all(X .⊆ Y)
2928

3029
(X::IntervalBox{N,T}, Y::IntervalBox{N,T}) where {N,T} =
31-
IntervalBox(ntuple(i -> X[i] Y[i], Val{N}))
30+
IntervalBox(X . Y)
3231
(X::IntervalBox{N,T}, Y::IntervalBox{N,T}) where {N,T} =
33-
IntervalBox(ntuple(i -> X[i] Y[i], Val{N}))
32+
IntervalBox(X . Y)
3433

3534
#=
3635
On Julia 0.6 can now write
@@ -40,11 +39,9 @@ On Julia 0.6 can now write
4039

4140
isempty(X::IntervalBox) = any(isempty, X)
4241

43-
# TODO: Replace with generator in 0.5:
44-
diam(X::IntervalBox) = maximum([diam(x) for x in X])
42+
diam(X::IntervalBox) = maximum(diam.(X))
4543

46-
emptyinterval(X::IntervalBox{N,T}) where {N,T} =
47-
IntervalBox(ntuple(i->emptyinterval(T), Val{N}))
44+
emptyinterval(X::IntervalBox{N,T}) where {N,T} = IntervalBox(emptyinterval.(X))
4845

4946

5047
import Base

0 commit comments

Comments
 (0)