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.
  • Loading branch information
ararslan authored and JeffBezanson committed May 23, 2019
1 parent 4247a48 commit 587cb82
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 587cb82

Please sign in to comment.