Skip to content

Full array minus spares vector gives sparse array as output #27

@pmcvay

Description

@pmcvay

A full array minus a sparse vector gives a sparse array with every position filled as an output. This seems inefficient. An example is below

julia> a = sparsevec([1,3,10], [.1, .3, .4])
10-element SparseVector{Float64,Int64} with 3 stored entries:
  [1 ]  =  0.1
  [3 ]  =  0.3
  [10]  =  0.4

julia> b = collect(1:10)
10-element Array{Int64,1}:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10

julia> b - a
10-element SparseVector{Float64,Int64} with 10 stored entries:
  [1 ]  =  0.9
  [2 ]  =  2.0
  [3 ]  =  2.7
  [4 ]  =  4.0
  [5 ]  =  5.0
  [6 ]  =  6.0
  [7 ]  =  7.0
  [8 ]  =  8.0
  [9 ]  =  9.0
  [10]  =  9.6

Metadata

Metadata

Assignees

No one assigned

    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