From 587cb8242f9e564b66ad5851abea2537ba4fb1de Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Thu, 23 May 2019 11:38:35 -0700 Subject: [PATCH] Amend matrix * vector specialization for strided arrays (#32097) This restricts the element type of the input vector to be `<:Real` and only converts in case the promoted type is concrete. Fixes #32092. --- stdlib/LinearAlgebra/src/matmul.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/LinearAlgebra/src/matmul.jl b/stdlib/LinearAlgebra/src/matmul.jl index c9cf328eeb294..d3a3a6a5bdaa9 100644 --- a/stdlib/LinearAlgebra/src/matmul.jl +++ b/stdlib/LinearAlgebra/src/matmul.jl @@ -41,9 +41,10 @@ function *(transx::Transpose{<:Any,<:StridedVector{T}}, y::StridedVector{T}) whe end # Matrix-vector multiplication -function (*)(A::StridedMatrix{T}, x::StridedVector{S}) where {T<:BlasFloat,S} +function (*)(A::StridedMatrix{T}, x::StridedVector{S}) where {T<:BlasFloat,S<:Real} TS = promote_op(matprod, T, S) - mul!(similar(x, TS, size(A,1)), A, convert(AbstractVector{TS}, x)) + y = isconcretetype(TS) ? convert(AbstractVector{TS}, x) : x + mul!(similar(x, TS, size(A,1)), A, y) end function (*)(A::AbstractMatrix{T}, x::AbstractVector{S}) where {T,S} TS = promote_op(matprod, T, S)