From f74bbd4d4849dbf5dd144b304f4283e6227b3c44 Mon Sep 17 00:00:00 2001 From: OlivierHnt <38465572+OlivierHnt@users.noreply.github.com> Date: Mon, 9 Dec 2024 18:50:39 +0100 Subject: [PATCH] Minor cleanup --- src/IntervalArithmetic.jl | 2 ++ src/matmul.jl | 24 +++++++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/IntervalArithmetic.jl b/src/IntervalArithmetic.jl index a9755f38..19e1b445 100644 --- a/src/IntervalArithmetic.jl +++ b/src/IntervalArithmetic.jl @@ -32,6 +32,8 @@ include("symbols.jl") # +import LinearAlgebra + include("matmul.jl") end diff --git a/src/matmul.jl b/src/matmul.jl index 89a5818c..04eb7d53 100644 --- a/src/matmul.jl +++ b/src/matmul.jl @@ -1,9 +1,3 @@ -import LinearAlgebra - - - -# - interval(::Type{T}, J::LinearAlgebra.UniformScaling, d::Decoration = com; format::Symbol = :infsup) where {T} = LinearAlgebra.UniformScaling(interval(T, J.λ, d; format = format)) interval(J::LinearAlgebra.UniformScaling, d::Decoration = com; format::Symbol = :infsup) = @@ -52,7 +46,7 @@ end # matrix inversion -# Note: use the contraction mapping theorem, only works when the entries of A have small radii +# note: use the contraction mapping theorem, only works when the entries of A have small radii function Base.inv(A::Matrix{<:RealOrComplexI}) mid_A = mid.(A) @@ -86,12 +80,16 @@ struct MatMulMode{T} end matmul_mode() = MatMulMode{:slow}() -Base.similar(a::Array{T}) where {T <: RealOrComplexI} = zeros(T, size(a)) -Base.similar(a::Array{T}, S::Type) where {T <: RealOrComplexI} = zeros(S, size(a)) -Base.similar(::Array{T}, m::Int) where {T <: RealOrComplexI} = zeros(T, m) -Base.similar(::Array{T}, S::Type, dims::Dims{N}) where {N, T <: RealOrComplexI} = zeros(S, dims) -Base.similar(::Array{T}, dims::Dims{N}) where {T <: RealOrComplexI, N} = zeros(T, dims) - +# by-pass `similar` methods defined in array.jl +Base.similar(a::Array{T,1}) where {T<:RealOrComplexI} = zeros(T, size(a, 1)) +Base.similar(a::Array{T,2}) where {T<:RealOrComplexI} = zeros(T, size(a, 1), size(a, 2)) +Base.similar(a::Array{T,1}, S::Type) where {T<:RealOrComplexI} = zeros(S, size(a, 1)) +Base.similar(a::Array{T,2}, S::Type) where {T<:RealOrComplexI} = zeros(S, size(a, 1), size(a, 2)) +Base.similar(a::Array{T}, m::Int) where {T<:RealOrComplexI} = zeros(T, m) +Base.similar(a::Array{T}, S::Type, dims::Dims) where {T<:RealOrComplexI} = zeros(S, dims) +Base.similar(a::Array{T}, dims::Dims) where {T<:RealOrComplexI} = zeros(T, dims) +# + function LinearAlgebra.mul!(C::AbstractVecOrMat{<:RealOrComplexI}, A::AbstractMatrix{<:RealOrComplexI}, B::AbstractVecOrMat{<:RealOrComplexI}) return LinearAlgebra.mul!(C, A, B, interval(true), interval(false)) end