Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug in issymmetric/ishermitian when zeros are stored #15504

Merged
merged 1 commit into from
Mar 16, 2016

Conversation

KristofferC
Copy link
Member

Fixes #13645

I introduced a small bug in #11371 that made issymmetric give the wrong answer in some cases when the matrix had stored zeros.

In short, the problem was that when I skipped storedzeros I have take into account that the tracker that keeps track of the next element needs to be incremented as well.
I took the opportunity to add some comments to the code as well.

With:

m = n = 5
colptr = [1, 5, 9, 13, 13, 17]
rowval = [1, 2, 3, 5, 1, 2, 3, 5, 1, 2, 3, 5, 1, 2, 3, 5]
nzval = [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0]
A = SparseMatrixCSC(m, n, colptr, rowval, nzval)

We have:

julia> A-A'
5x5 sparse matrix with 0 Float64 entries:

On master:

julia> issymmetric(A) 
false

On PR:

julia> issymmetric(A) 
true

@@ -1110,6 +1110,15 @@ A.nzval[2] = 0.0
@test ishermitian(A) == true
@test issymmetric(A) == true

m = n = 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a let here?

@KristofferC
Copy link
Member Author

Thank you @tkelman. Updated.

@tkelman tkelman added the sparse Sparse arrays label Mar 16, 2016
tkelman added a commit that referenced this pull request Mar 16, 2016
fix bug in issymmetric/ishermitian when zeros are stored
@tkelman tkelman merged commit 2a3aada into JuliaLang:master Mar 16, 2016
@KristofferC KristofferC deleted the kc/sparse_sym branch March 16, 2016 13:18
tkelman pushed a commit that referenced this pull request Jun 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sparse Sparse arrays
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants