Skip to content

Commit 0ecfa6f

Browse files
authored
Backports to release-1.13 (#717)
- [x] #715
2 parents 9d08bb3 + 7a78eb0 commit 0ecfa6f

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/linalg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ function _dot(x::AbstractVector, A::AbstractSparseMatrixCSC, y::AbstractVector,
13871387
@inbounds for col in axes(A,2)
13881388
ycol = y[col]
13891389
xcol = x[col]
1390-
if _isnotzero(ycol) && _isnotzero(xcol)
1390+
if _isnotzero(ycol) || _isnotzero(xcol)
13911391
for k in rangefun(A, col)
13921392
i = rvals[k]
13931393
Aij = nzvals[k]

test/linalg.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -967,18 +967,20 @@ end
967967
end
968968

969969
@testset "generalized dot product" begin
970-
for i = 1:5
971-
A = sprand(ComplexF64, 10, 15, 0.4)
972-
Av = view(A, :, :)
973-
x = sprand(ComplexF64, 10, 0.5)
974-
y = sprand(ComplexF64, 15, 0.5)
970+
A = sprand(ComplexF64, 10, 15, 1.0)
971+
A15 = sprand(ComplexF64, 15, 15, 1.0)
972+
Av = view(A, :, :)
973+
vx = sprand(ComplexF64, 10, 0.5)
974+
vy = sprand(ComplexF64, 15, 0.5)
975+
vy2 = sprand(ComplexF64, 15, 0.5)
976+
for (x, y, y2) in ((vx, vy, vy2), (Vector(vx), Vector(vy), Vector(vy2)))
975977
@test dot(x, A, y) dot(Vector(x), A, Vector(y)) (Vector(x)' * Matrix(A)) * Vector(y)
976978
@test dot(x, A, y) dot(x, Av, y)
977979
@test dot(x, collect(A), y) dot(x, A, y)
978980
@test dot(y, collect(A)', x) dot(y, A', x)
979981
@test dot(y, transpose(collect(A)), x) dot(y, transpose(A), x)
980-
@test dot(y, Hermitian(collect(A)' * collect(A)), y) dot(y, Hermitian(A' * A), y)
981-
@test dot(y, Symmetric(collect(A)' * collect(A)), y) dot(y, Symmetric(A' * A), y)
982+
@test dot(y, Hermitian(collect(A15)), y2) dot(y, Hermitian(A15), y2)
983+
@test dot(y, Symmetric(collect(A15)), y2) dot(y, Symmetric(A15), y2)
982984
B = BitMatrix(rand(Bool, 10, 15))
983985
@test dot(x, A, y) dot(x, Matrix(A), y)
984986
@test_throws DimensionMismatch dot([x, x], A, y)
@@ -990,8 +992,8 @@ end
990992
B = sprandn(T, 10, 10, 0.2)
991993
x = sprandn(T, 10, 0.4)
992994
xd = Vector(x)
993-
S = trans(B'B, uplo)
994-
Sd = trans(Matrix(B'B), uplo)
995+
S = trans(B, uplo)
996+
Sd = trans(Matrix(B), uplo)
995997
@test dot(x, S, x) dot(x, Sd, x) dot(xd, S, xd) dot(xd, Sd, xd)
996998
end
997999
end

0 commit comments

Comments
 (0)