Skip to content

sum of a Bool sparse array is slow #237

@eschnett

Description

@eschnett

Evaluating the sum of a sparse array is slow. It appears to use an O(n^2) algorithm:

julia> @time sum(sparse(I(10000)))
  0.401920 seconds (6 allocations: 176.281 KiB)
10000

julia> @time sum(sparse(I(20000)))
  1.616018 seconds (8 allocations: 351.875 KiB)
20000

julia> @time sum(sparse(I(40000)))
  6.819114 seconds (8 allocations: 703.500 KiB)
40000

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions