Open kunyuan opened 1 year ago
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)
Some example: https://github.com/KristofferC/BlockSparseMatrices.jl
Implement SparseMeshArray, which generalizes BlockGf in Triqs. Example from https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-array