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

SparseMeshArray #60

Open
kunyuan opened this issue Sep 26, 2022 · 1 comment
Open

SparseMeshArray #60

kunyuan opened this issue Sep 26, 2022 · 1 comment
Labels
enhancement New feature or request priority:high

Comments

@kunyuan
Copy link
Member

kunyuan commented Sep 26, 2022

Implement SparseMeshArray, which generalizes BlockGf in Triqs.
Example from https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-array

julia> struct SparseArray{T,N} <: AbstractArray{T,N}
           data::Dict{NTuple{N,Int}, T}
           dims::NTuple{N,Int}
       end

julia> SparseArray(::Type{T}, dims::Int...) where {T} = SparseArray(T, dims);

julia> SparseArray(::Type{T}, dims::NTuple{N,Int}) where {T,N} = SparseArray{T,N}(Dict{NTuple{N,Int}, T}(), dims);

julia> Base.size(A::SparseArray) = A.dims

julia> Base.similar(A::SparseArray, ::Type{T}, dims::Dims) where {T} = SparseArray(T, dims)

julia> Base.getindex(A::SparseArray{T,N}, I::Vararg{Int,N}) where {T,N} = get(A.data, I, zero(T))

julia> Base.setindex!(A::SparseArray{T,N}, v, I::Vararg{Int,N}) where {T,N} = (A.data[I] = v)
@kunyuan kunyuan added enhancement New feature or request priority:high labels Sep 26, 2022
@kunyuan
Copy link
Member Author

kunyuan commented Oct 2, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority:high
Projects
None yet
Development

No branches or pull requests

1 participant