Skip to content

Commit ecf16f5

Browse files
dpsanderslbenet
authored andcommitted
Multiplication of IntervalBox by a matrix (#253)
* Add multiplication of an IntervalBox by a matrix * Missing end * Fix testset
1 parent cd85294 commit ecf16f5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/multidim/arithmetic.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Base.size(X::IntervalBox{2,Float64}) = (2,)
2929
@inline broadcasted(f, x, Y::IntervalBox) = wrap(f.(x, Y.v))
3030
# for literal_pow:
3131
@inline broadcasted(f, x, y, Z::IntervalBox) = wrap(f.(x, y, Z.v))
32-
@inline broadcasted(f, x, Y::IntervalBox, z) = wrap(f.(x, Y.v, z))
32+
@inline broadcasted(f, x, Y::IntervalBox, z) = wrap(f.(x, Y.v, z))
3333

3434
for op in (:+, :-, :, :, :, :isinterior, :dot, :setdiff, :×)
3535
@eval $(op)(a::SVector, b::IntervalBox) = $(op)(IntervalBox(a), b)
@@ -38,3 +38,8 @@ end
3838
for op in (:+, :-, :, :, :, :isinterior, :dot, :setdiff, :×)
3939
@eval $(op)(a::IntervalBox, b::SVector) = $(op)(a, IntervalBox(b))
4040
end
41+
42+
43+
# multiplication by a matrix
44+
45+
*(A::AbstractMatrix, X::IntervalBox) = IntervalBox(A * X.v)

test/multidim_tests/multidim.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,16 @@ end
236236

237237
end
238238

239+
@testset "Multiplication by a matrix" begin
240+
A = [1 2; 3 4]
241+
X = IntervalBox(1..2, 3..4)
242+
243+
@test A * X == IntervalBox(7..10, 15..22)
244+
245+
B = SMatrix{2,2}(A)
246+
247+
@test B * X == IntervalBox(7..10, 15..22)
248+
249+
end
250+
239251
end

0 commit comments

Comments
 (0)