SparseArrays.jl icon indicating copy to clipboard operation
SparseArrays.jl copied to clipboard

isequal very slow for SparseVectors

Open dpinol opened this issue 1 year ago • 0 comments

It looks like isequal(SparseVector) loops along all dimensions instead of only the non zero ones. Comparing 2 instances which just contain 1 value take 1.5s

julia> using SparseArrays

julia> const v=spzeros(1000_000_000)
1000000000-element SparseVector{Float64, Int64} with 0 stored entries

julia> const v2=spzeros(1000_000_000)
1000000000-element SparseVector{Float64, Int64} with 0 stored entries

julia> v[1]=1
1

julia> v2[1]=1
1

julia> @time isequal(v,v2);
  1.510852 seconds

julia> @time isequal(v,v2);
  1.503675 seconds
julia> versioninfo()
Julia Version 1.11.0-rc4
Commit b4b9add84db (2024-09-25 11:03 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × 13th Gen Intel(R) Core(TM) i9-13950HX
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 32 virtual cores)

dpinol avatar Sep 30 '24 15:09 dpinol