Skip to content

Proposal: sparse overlay #13

@putianyi889

Description

@putianyi889

Motivation: JuliaSparse/SparseArrays.jl#512

Solution (just a brief sketch):

struct SparseOverlay{T,N,D<:AbstractArray{T,N}} <: AbstractArray{T,N}
    data::Dict{CartesianIndex{N},T}
    base::D
end
const SparseArray{T,N} = SparseOverlay{T,N,FillArrays.Zeros{T,N}}

@inline function Base.getindex(a::SparseOverlay{T,N}, I::CartesianIndex{N}) where {T,N}
    @boundscheck checkbounds(a, I)
    return get(a.data, I, a.base[I])
end

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