Skip to content

Commit

Permalink
Fix -, conj, and conj! for sparse matrices with invalid entries…
Browse files Browse the repository at this point in the history
… in `nzval` (#31187)

(cherry picked from commit ca92c7b)
  • Loading branch information
martinholters authored and KristofferC committed Apr 15, 2019
1 parent 8a84ba5 commit 442a1c2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions stdlib/SparseArrays/test/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2586,4 +2586,16 @@ end
@test sum(x1, dims=2) == sum(x2, dims=2)
end

@testset "unary operations on matrices where length(nzval)>nnz" begin
# this should create a sparse matrix with length(nzval)>nnz
A = SparseMatrixCSC(Complex{BigInt}[1+im 2+2im]')'[1:1, 2:2]
# ...ensure it does! If necessary, the test needs to be updated to use
# another mechanism to create a suitable A.
@assert length(A.nzval) > nnz(A)
@test -A == fill(-2-2im, 1, 1)
@test conj(A) == fill(2-2im, 1, 1)
conj!(A)
@test A == fill(2-2im, 1, 1)
end

end # module

0 comments on commit 442a1c2

Please sign in to comment.