Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/IntervalMatrices.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
module IntervalMatrices

using LinearAlgebra
using LinearAlgebra: checksquare

using Random: AbstractRNG, GLOBAL_RNG, seed!
import Random: rand

import Base: copy,
import Base: copy, rand,
+, -, *, /, \,
size, IndexStyle, getindex, setindex!,
similar, ∈, ⊆, ∩, ∪, real, imag

using Reexport
import LinearAlgebra
using LinearAlgebra: Diagonal, I, UniformScaling, checksquare, opnorm
using Random: AbstractRNG, GLOBAL_RNG
using Reexport: @reexport

# =================================
# Interface with IntervalArithmetic
Expand Down
2 changes: 1 addition & 1 deletion src/exponential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ end
function _exp_remainder(A::IntervalMatrix{T}, t, p; n=checksquare(A)) where {T}
C = max.(abs.(inf(A)), abs.(sup(A)))
# compute Q = I + Ct + (Ct)^2/2! + ... + (Ct)^p/p!
Q = Matrix(LinearAlgebra.Diagonal(ones(T, n)))
Q = Matrix(Diagonal(ones(T, n)))

tⁱ = 1
i! = 1
Expand Down
13 changes: 7 additions & 6 deletions src/matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,20 @@ julia> [1 2; 3 4] ± [1 2; 4 5]
"""
function ±(C::MT, S::MT) where {T,MT<:AbstractMatrix{T}}
size(C) == size(S) || throw(ArgumentError("the sizes of the center matrix and the " *
"radii matrix should match, but they are $(size(C)) " *
"and $(size(S)) respectively"))
"radii matrix should match, but they are " *
"$(size(C)) and $(size(S)) respectively"))

return IntervalMatrix(map((x, y) -> interval(x - y, x + y), C, S))
end

for op in (:Adjoint, :Bidiagonal, :Diagonal, :Hermitian,
:SymTridiagonal, :Symmetric, :Transpose, :Tridiagonal)
@eval LinearAlgebra.$op(A::IntervalMatrix) = IntervalMatrix($op(A.mat))
for op in (:Adjoint, :Bidiagonal, :Diagonal, :Hermitian, :SymTridiagonal, :Symmetric, :Transpose,
:Tridiagonal)
@eval LinearAlgebra.$op(A::IntervalMatrix) = IntervalMatrix(LinearAlgebra.$op(A.mat))
end

if VERSION >= v"1.3"
LinearAlgebra.UpperHessenberg(A::IntervalMatrix) = IntervalMatrix(UpperHessenberg(A.mat))
LinearAlgebra.UpperHessenberg(A::IntervalMatrix) =
IntervalMatrix(LinearAlgebra.UpperHessenberg(A.mat))
end

@static if vIA >= v"0.22"
Expand Down
26 changes: 14 additions & 12 deletions src/operations/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,26 @@
# (there exist more precise approaches but are currently not implemented here)
\(M1::IntervalMatrix, M2::IntervalMatrix) = IntervalMatrix(M1.mat \ M2.mat)
# COV_EXCL_START
for T in (:AbstractMatrix, :Diagonal, :(Union{UpperTriangular,LowerTriangular}),
:(Union{UnitUpperTriangular,UnitLowerTriangular}), :SymTridiagonal, :Bidiagonal,
:(LinearAlgebra.HermOrSym), :(LinearAlgebra.AdjOrTrans{<:Any,<:Bidiagonal}))
for T in (:AbstractMatrix, :(LinearAlgebra.Diagonal),
:(Union{LinearAlgebra.UpperTriangular,LinearAlgebra.LowerTriangular}),
:(Union{LinearAlgebra.UnitUpperTriangular,LinearAlgebra.UnitLowerTriangular}),
:(LinearAlgebra.SymTridiagonal), :(LinearAlgebra.Bidiagonal), :(LinearAlgebra.HermOrSym),
:(LinearAlgebra.AdjOrTrans{<:Any,<:LinearAlgebra.Bidiagonal})) # NOTE: these are internal functions
@eval begin
\(M1::IntervalMatrix, M2::$T) = IntervalMatrix(M1.mat \ M2)
\(M1::$T, M2::IntervalMatrix) = IntervalMatrix(M1 \ M2.mat)
end
end
@static if VERSION >= v"1.3"
for T in [:(Union{LinearAlgebra.Adjoint{T,
S} where {T,
S<:(LinearAlgebra.UpperHessenberg{T,
S} where {S<:AbstractMatrix{T}})},
LinearAlgebra.Transpose{T,
S} where {T,
S<:(LinearAlgebra.UpperHessenberg{T,
S} where {S<:AbstractMatrix{T}})},
LinearAlgebra.UpperHessenberg})]
for T in [:(LinearAlgebra.Adjoint{T,
S} where {T,
S<:(LinearAlgebra.UpperHessenberg{T,
S} where {S<:AbstractMatrix{T}})}),
:(LinearAlgebra.Transpose{T,
S} where {T,
S<:(LinearAlgebra.UpperHessenberg{T,
S} where {S<:AbstractMatrix{T}})}),
:(LinearAlgebra.UpperHessenberg)]
@eval begin
\(M1::IntervalMatrix, M2::$T) = IntervalMatrix(M1.mat \ M2)
\(M1::$T, M2::IntervalMatrix) = IntervalMatrix(M1 \ M2.mat)
Expand Down
2 changes: 1 addition & 1 deletion src/operations/mult.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function set_multiplication_mode(multype)

# AbstractMatrix, incl. disambiguations
for T in (:AbstractMatrix, :(LinearAlgebra.AbstractTriangular), # COV_EXCL_LINE
:(Transpose{T,<:AbstractVector} where {T}), :Diagonal,
:(LinearAlgebra.Transpose{T,<:AbstractVector} where {T}), :Diagonal,
:(LinearAlgebra.Adjoint{T,<:AbstractVector} where {T}))
@eval begin # COV_EXCL_LINE
*(A::IntervalMatrix, B::$T) = *($type, A, B)
Expand Down
28 changes: 0 additions & 28 deletions test/Aqua.jl

This file was deleted.

6 changes: 6 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PkgVersion = "eebad327-c553-4316-9ea0-9fa01ccd7688"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Aqua = "0.8.9"
ExplicitImports = "1"
Pkg = "<0.0.1, 1.2"
PkgVersion = "0.3.3"

[extras]
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
8 changes: 4 additions & 4 deletions test/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ end
A = rand(IntervalMatrix)
@test A isa IntervalMatrix

Aₛ = Symmetric(A)
Aₛ = LinearAlgebra.Symmetric(A)
@test Aₛ isa IntervalMatrix
@test Aₛ.mat isa Symmetric
@test Aₛ.mat isa LinearAlgebra.Symmetric
@test Matrix(Aₛ) isa Matrix

@static if VERSION >= v"1.3"
Aₕ = UpperHessenberg(A)
Aₕ = LinearAlgebra.UpperHessenberg(A)
@test Aₕ isa IntervalMatrix
@test Aₕ.mat isa UpperHessenberg
@test Aₕ.mat isa LinearAlgebra.UpperHessenberg
@test Matrix(Aₕ) isa Matrix
end
end
50 changes: 50 additions & 0 deletions test/quality_assurance.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using IntervalMatrices, Test
import PkgVersion, Aqua

import Pkg
@static if VERSION >= v"1.6" # TODO make explicit test requirement
Pkg.add("ExplicitImports")
import ExplicitImports

@testset "ExplicitImports tests" begin
ignores = (:GLOBAL_RNG,)
@test isnothing(ExplicitImports.check_all_explicit_imports_are_public(IntervalMatrices;
ignore=ignores))
@test isnothing(ExplicitImports.check_all_explicit_imports_via_owners(IntervalMatrices))
ignores = (:HermOrSym, :AdjOrTrans)
@test isnothing(ExplicitImports.check_all_qualified_accesses_are_public(IntervalMatrices;
ignore=ignores))
@test isnothing(ExplicitImports.check_all_qualified_accesses_via_owners(IntervalMatrices))
ignores = (:IntervalArithmetic, :Interval, :in_interval, :intersect_interval, :interval,
:isequal_interval, :issubset_interval, :setdisplay) # due to reexporting IntervalArithmetic
@test isnothing(ExplicitImports.check_no_implicit_imports(IntervalMatrices; ignore=ignores))
@test isnothing(ExplicitImports.check_no_self_qualified_accesses(IntervalMatrices))
@test isnothing(ExplicitImports.check_no_stale_explicit_imports(IntervalMatrices))
end
end

@testset "Aqua tests" begin
# PkgVersion is only used in old versions
@static if VERSION >= v"1.9"
stale_deps = (ignore=[:PkgVersion],)
else
stale_deps = true
end

# old versions of IntervalArithmetic had an undefined export
@static if PkgVersion.Version(IntervalMatrices.IntervalArithmetic) >= v"0.17.6"
undefined_exports = true
else
undefined_exports = false
end

# old versions of IntervalArithmetic did not define `interval` for `Complex` inputs
@static if PkgVersion.Version(IntervalMatrices.IntervalArithmetic) >= v"0.21"
piracies = true
else
piracies = (broken=true,)
end

Aqua.test_all(IntervalMatrices; stale_deps=stale_deps, undefined_exports=undefined_exports,
piracies=piracies)
end
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ include("setops.jl")
include("exponential.jl")
include("affine.jl")

include("Aqua.jl")
include("quality_assurance.jl")
Loading