Skip to content

Commit

Permalink
Amend matrix * vector specialization for strided arrays (#32097)
Browse files Browse the repository at this point in the history
This restricts the element type of the input vector to be `<:Real` and
only converts in case the promoted type is concrete.

Fixes #32092.

(cherry picked from commit 587cb82)
  • Loading branch information
ararslan authored and KristofferC committed May 23, 2019
1 parent ad5e60a commit e5dfde8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions stdlib/LinearAlgebra/src/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e5dfde8

Please sign in to comment.