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

Likely bug in issymmetric(A::AbstractSparseMatrixCSC) #605

Open
sztal opened this issue Mar 5, 2025 · 2 comments · May be fixed by #606
Open

Likely bug in issymmetric(A::AbstractSparseMatrixCSC) #605

sztal opened this issue Mar 5, 2025 · 2 comments · May be fixed by #606

Comments

@sztal
Copy link

sztal commented Mar 5, 2025

I found a likely bug in issymmetric(A::AbstractSparseMatrixCSC), which considers symmetric a matrix which is clearly non-symmetric. Here is an example.

using LinearAlgebra, SparseArrays
S = sparse([2, 3, 1], [1, 1, 3], [1, 1, 1], 3, 3)

S looks like this:

3×3 SparseMatrixCSC{Int64, Int64} with 3 stored entries:
 ⋅  ⋅  1
 1  ⋅  ⋅
 1  ⋅  ⋅

And this is what issymmetric does:

M = Matrix(S)
issymmetric(S)  # true
issymmetric(M)  # false

The bug most likely applies also to ishermitian.

Version info

Julia Version 1.11.3
Commit d63adeda50d (2025-01-21 19:42 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 9 5900HX with Radeon Graphics
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
Environment:
  JULIA_PROJECT = @.
  JULIA_PKG_PRESERVE_TIERED_INSTALLED = true
  JULIA_REVISE = manual
  JULIA_EDITOR = vim

Pkg status

⌃ [4c555306] ArrayLayouts v1.11.0
  [6e4b80f9] BenchmarkTools v1.6.0
  [31a5f54b] Debugger v0.7.10
  [31c24e10] Distributions v0.25.117
  [1a297f60] FillArrays v1.13.0
  [86223c79] Graphs v1.12.0
⌃ [aa1ae85d] JuliaInterpreter v0.9.41
⌃ [0b1a1467] KrylovKit v0.9.3
⌃ [5078a376] LazyArrays v2.4.0
  [295af30f] Revise v3.7.2
  [2913bbd2] StatsBase v0.34.4
Info Packages marked with ⌃ have new versions available and may be upgradable.
@jishnub
Copy link
Collaborator

jishnub commented Mar 5, 2025

Could you look into which method is used for the check?

@sztal
Copy link
Author

sztal commented Mar 5, 2025

Sure!

@which issymetric(S)
# @ SparseArrays ~/.julia/juliaup/julia-1.11.3+0.x64.linux.gnu/share/julia/stdlib/v1.11/SparseArrays/src/sparsematrix.jl:4034

More specifically, @edit issymmetric(S) takes me to:

## Structure query functions
issymmetric(A::AbstractSparseMatrixCSC) = is_hermsym(A, identity)

@jishnub jishnub linked a pull request Mar 6, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants