Skip to content

Commit 19465ec

Browse files
committed
Exclude unintended complex symmetric sparse matrices from 3-arg dot (#642)
1 parent ee589b1 commit 19465ec

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/linalg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ function nzrangelo(A, i, excl=false)
913913
@inbounds r2 < r1 || rv[r1] >= i + excl ? r : searchsortedfirst(rv, i + excl, r1, r2, Forward):r2
914914
end
915915

916-
dot(x::AbstractVector, A::RealHermSymComplexHerm{<:Any,<:AbstractSparseMatrixCSC}, y::AbstractVector) =
916+
dot(x::AbstractVector, A::RealHermSymComplexHerm{<:Real,<:AbstractSparseMatrixCSC}, y::AbstractVector) =
917917
_dot(x, parent(A), y, A.uplo == 'U' ? nzrangeup : nzrangelo, A isa Symmetric ? identity : real, A isa Symmetric ? transpose : adjoint)
918918
function _dot(x::AbstractVector, A::AbstractSparseMatrixCSC, y::AbstractVector, rangefun::Function, diagop::Function, odiagop::Function)
919919
require_one_based_indexing(x, y)
@@ -944,7 +944,7 @@ function _dot(x::AbstractVector, A::AbstractSparseMatrixCSC, y::AbstractVector,
944944
end
945945
return r
946946
end
947-
dot(x::SparseVector, A::RealHermSymComplexHerm{<:Any,<:AbstractSparseMatrixCSC}, y::SparseVector) =
947+
dot(x::SparseVector, A::RealHermSymComplexHerm{<:Real,<:AbstractSparseMatrixCSC}, y::SparseVector) =
948948
_dot(x, parent(A), y, A.uplo == 'U' ? nzrangeup : nzrangelo, A isa Symmetric ? identity : real)
949949
function _dot(x::SparseVector, A::AbstractSparseMatrixCSC, y::SparseVector, rangefun::Function, diagop::Function)
950950
m, n = size(A)

test/linalg.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,11 +845,12 @@ end
845845
@test dot(x, A, y) dot(x, Av, y)
846846
end
847847

848-
for (T, trans) in ((Float64, Symmetric), (ComplexF64, Hermitian)), uplo in (:U, :L)
848+
for (T, trans) in ((Float64, Symmetric), (ComplexF64, Symmetric), (ComplexF64, Hermitian)), uplo in (:U, :L)
849849
B = sprandn(T, 10, 10, 0.2)
850850
x = sprandn(T, 10, 0.4)
851851
S = trans(B'B, uplo)
852-
@test dot(x, S, x) dot(Vector(x), S, Vector(x)) dot(Vector(x), Matrix(S), Vector(x))
852+
Sd = trans(Matrix(B'B), uplo)
853+
@test dot(x, S, x) dot(x, Sd, x) dot(Vector(x), S, Vector(x)) dot(Vector(x), Sd, Vector(x))
853854
end
854855
end
855856

0 commit comments

Comments
 (0)