Skip to content

Commit 9bc6f6b

Browse files
committed
Minor update for fast matrix multiplication
1 parent f47d487 commit 9bc6f6b

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

src/matmul.jl

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,8 @@ Base.similar(::Array, S::Type{Interval{T}}, dims::Dims) where {T<:NumTy
171171
Base.similar(::Array, S::Type{Complex{Interval{T}}}, dims::Dims) where {T<:NumTypes} = zeros(S, dims)
172172
#
173173

174-
function LinearAlgebra.mul!(C::AbstractVecOrMat{<:RealOrComplexI}, A::AbstractMatrix{<:RealOrComplexI}, B::AbstractVecOrMat{<:RealOrComplexI})
175-
return LinearAlgebra.mul!(C, A, B, interval(true), interval(false))
176-
end
174+
LinearAlgebra.mul!(C::AbstractVecOrMat{<:RealOrComplexI}, A::AbstractMatrix{<:RealOrComplexI}, B::AbstractVecOrMat{<:RealOrComplexI}) =
175+
LinearAlgebra.mul!(C, A, B, interval(true), interval(false))
177176

178177
for T (:AbstractVector, :AbstractMatrix) # needed to resolve method ambiguities
179178
@eval begin
@@ -251,20 +250,6 @@ end
251250
# fast matrix multiplication
252251
# Note: Rump's algorithm
253252

254-
_mul!(::MatMulMode{:fast}, C, A::AbstractMatrix{<:Interval{<:Rational}}, B::AbstractVecOrMat{<:Interval{<:Rational}}, α, β) =
255-
LinearAlgebra._mul!(C, A, B, α, β)
256-
_mul!(::MatMulMode{:fast}, C, A::AbstractMatrix{<:Interval{<:Rational}}, B::AbstractVecOrMat, α, β) =
257-
LinearAlgebra._mul!(C, A, B, α, β)
258-
_mul!(::MatMulMode{:fast}, C, A::AbstractMatrix, B::AbstractVecOrMat{<:Interval{<:Rational}}, α, β) =
259-
LinearAlgebra._mul!(C, A, B, α, β)
260-
261-
_mul!(::MatMulMode{:fast}, C, A::AbstractMatrix{<:Complex{<:Interval{<:Rational}}}, B::AbstractVecOrMat{<:Complex{<:Interval{<:Rational}}}, α, β) =
262-
LinearAlgebra._mul!(C, A, B, α, β)
263-
_mul!(::MatMulMode{:fast}, C, A::AbstractMatrix{<:Complex{<:Interval{<:Rational}}}, B::AbstractVecOrMat{<:Interval{<:Rational}}, α, β) =
264-
LinearAlgebra._mul!(C, A, B, α, β)
265-
_mul!(::MatMulMode{:fast}, C, A::AbstractMatrix{<:Interval{<:Rational}}, B::AbstractVecOrMat{<:Complex{<:Interval{<:Rational}}}, α, β) =
266-
LinearAlgebra._mul!(C, A, B, α, β)
267-
268253
function _mul!(::MatMulMode{:fast}, C, A, B, α, β)
269254
Int != Int32 && return _fastmul!(C, A, B, α, β)
270255
@info "Fast multiplication is not supported on 32-bit systems, using the slow version"
@@ -432,7 +417,7 @@ for (T, S) ∈ ((:(Complex{<:Interval}), :Interval), (:(Complex{<:Interval}), :A
432417
end
433418

434419
function __mul(A::AbstractMatrix{T}, B::AbstractVecOrMat{S}) where {T,S}
435-
NewType = promote_numtype(T, S)
420+
NewType = float(promote_numtype(T, S))
436421
return __mul(interval.(NewType, A), interval.(NewType, B))
437422
end
438423

@@ -507,13 +492,13 @@ else
507492
_getrounding() = ccall(:fegetround, Cint, ())
508493
end
509494

510-
_2mat(A::LinearAlgebra.Diagonal) = Matrix(A)
511-
512-
_2mat(A) = A
495+
_2stride(A::StridedArray) = A
496+
_2stride(A::AbstractVector) = Vector(A)
497+
_2stride(A::AbstractMatrix) = Matrix(A)
513498

514499
function _call_gem_openblas_upward!(C, A_::AbstractMatrix{Float64}, B_::AbstractMatrix{Float64})
515-
A = _2mat(A_)
516-
B = _2mat(B_)
500+
A = _2stride(A_)
501+
B = _2stride(B_)
517502

518503
m, k = size(A)
519504
n = size(B, 2)
@@ -544,8 +529,8 @@ function _call_gem_openblas_upward!(C, A_::AbstractMatrix{Float64}, B_::Abstract
544529
end
545530

546531
function _call_gem_openblas_upward!(C, A_::AbstractMatrix{Float64}, B_::AbstractVector{Float64})
547-
A = _2mat(A_)
548-
B = _2mat(B_)
532+
A = _2stride(A_)
533+
B = _2stride(B_)
549534

550535
m, k = size(A)
551536

0 commit comments

Comments
 (0)