diff --git a/src/init_IntervalArithmetic.jl b/src/init_IntervalArithmetic.jl index 8c4e3de..b1a7f1b 100644 --- a/src/init_IntervalArithmetic.jl +++ b/src/init_IntervalArithmetic.jl @@ -21,6 +21,8 @@ else # vIA < v"0.22" intersect_interval(a::Interval, b::Interval) = intersect(a, b) + pown(x, y) = x^y + if vIA >= v"0.21" # `convert` was temporarily removed in IntervalArithmetic v0.21 until v0.22 Base.convert(::Type{Interval{T}}, x::Number) where {T} = interval(T(x)) diff --git a/src/operations/arithmetic.jl b/src/operations/arithmetic.jl index de6a389..c50f89d 100644 --- a/src/operations/arithmetic.jl +++ b/src/operations/arithmetic.jl @@ -83,7 +83,7 @@ function square(A::IntervalMatrix) # case i == j @inbounds for j in 1:n - B[j, j] = pow(A[j, j], 2) + B[j, j] = pown(A[j, j], 2) for k in 1:n k == j && continue B[j, j] += A[j, k] * A[k, j] diff --git a/test/exponential.jl b/test/exponential.jl index b7dff0b..dfd7df3 100644 --- a/test/exponential.jl +++ b/test/exponential.jl @@ -60,6 +60,10 @@ end a = m * m b = square(m) @test b ⊆ a + + # correct use of `pown` (#283) + m = IntervalMatrix(hcat(interval(-4.0, -2.0))) + @test square(m) ⩵ IntervalMatrix(hcat(interval(4.0, 16.0))) end @testset "Interval matrix power" begin