Skip to content

Commit 095b685

Browse files
authored
Exclude unintended complex symmetric sparse matrices from 3-arg dot (#642)
1 parent 8049287 commit 095b685

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/linalg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ function nzrangelo(A, i, excl=false)
12101210
@inbounds r2 < r1 || rv[r1] >= i + excl ? r : (searchsortedfirst(view(rv, r1:r2), i + excl) + r1-1):r2
12111211
end
12121212

1213-
dot(x::AbstractVector, A::RealHermSymComplexHerm{<:Any,<:AbstractSparseMatrixCSC}, y::AbstractVector) =
1213+
dot(x::AbstractVector, A::RealHermSymComplexHerm{<:Real,<:AbstractSparseMatrixCSC}, y::AbstractVector) =
12141214
_dot(x, parent(A), y, A.uplo == 'U' ? nzrangeup : nzrangelo, A isa Symmetric ? identity : real, A isa Symmetric ? transpose : adjoint)
12151215
function _dot(x::AbstractVector, A::AbstractSparseMatrixCSC, y::AbstractVector, rangefun::Function, diagop::Function, odiagop::Function)
12161216
require_one_based_indexing(x, y)
@@ -1242,7 +1242,7 @@ function _dot(x::AbstractVector, A::AbstractSparseMatrixCSC, y::AbstractVector,
12421242
end
12431243
return r
12441244
end
1245-
dot(x::SparseVector, A::RealHermSymComplexHerm{<:Any,<:AbstractSparseMatrixCSC}, y::SparseVector) =
1245+
dot(x::SparseVector, A::RealHermSymComplexHerm{<:Real,<:AbstractSparseMatrixCSC}, y::SparseVector) =
12461246
_dot(x, parent(A), y, A.uplo == 'U' ? nzrangeup : nzrangelo, A isa Symmetric ? identity : real)
12471247
function _dot(x::SparseVector, A::AbstractSparseMatrixCSC, y::SparseVector, rangefun::Function, diagop::Function)
12481248
m, n = size(A)

test/linalg.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,11 +954,12 @@ end
954954
@test dot(x, A, y) dot(x, Av, y)
955955
end
956956

957-
for (T, trans) in ((Float64, Symmetric), (ComplexF64, Hermitian)), uplo in (:U, :L)
957+
for (T, trans) in ((Float64, Symmetric), (ComplexF64, Symmetric), (ComplexF64, Hermitian)), uplo in (:U, :L)
958958
B = sprandn(T, 10, 10, 0.2)
959959
x = sprandn(T, 10, 0.4)
960960
S = trans(B'B, uplo)
961-
@test dot(x, S, x) dot(Vector(x), S, Vector(x)) dot(Vector(x), Matrix(S), Vector(x))
961+
Sd = trans(Matrix(B'B), uplo)
962+
@test dot(x, S, x) dot(x, Sd, x) dot(Vector(x), S, Vector(x)) dot(Vector(x), Sd, Vector(x))
962963
end
963964
end
964965

0 commit comments

Comments
 (0)