Skip to content

Commit 0a06275

Browse files
ararslanKristofferC
authored andcommitted
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. (cherry picked from commit 587cb82)
1 parent 6b4cb65 commit 0a06275

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

stdlib/LinearAlgebra/src/matmul.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ function *(transx::Transpose{<:Any,<:StridedVector{T}}, y::StridedVector{T}) whe
4141
end
4242

4343
# Matrix-vector multiplication
44-
function (*)(A::StridedMatrix{T}, x::StridedVector{S}) where {T<:BlasFloat,S}
44+
function (*)(A::StridedMatrix{T}, x::StridedVector{S}) where {T<:BlasFloat,S<:Real}
4545
TS = promote_op(matprod, T, S)
46-
mul!(similar(x, TS, size(A,1)), A, convert(AbstractVector{TS}, x))
46+
y = isconcretetype(TS) ? convert(AbstractVector{TS}, x) : x
47+
mul!(similar(x, TS, size(A,1)), A, y)
4748
end
4849
function (*)(A::AbstractMatrix{T}, x::AbstractVector{S}) where {T,S}
4950
TS = promote_op(matprod, T, S)

0 commit comments

Comments
 (0)