@@ -64,52 +64,23 @@ function NDSparseArray(A::AbstractArray{T, N}; atol::Real = 0) where {T, N}
6464    return  sparse_array
6565end 
6666
67- #  Required AbstractArray interface
6867Base. size (A:: NDSparseArray ) =  A. dims
69- Base. IndexStyle (:: Type{<:NDSparseArray} ) =  IndexCartesian ()
7068
71- #  Linear indexing support
72- @inline  function  Base. getindex (A:: NDSparseArray , i:: Int )
73-     @boundscheck  checkbounds (A, i)
74-     idx =  CartesianIndices (A)[i]
75-     haskey (A. data, idx) ||  throw (BoundsError (A, i))
76-     return  A. data[idx]
77- end 
78- 
79- @inline  function  Base. setindex! (A:: NDSparseArray , val, i:: Int )
80-     @boundscheck  checkbounds (A, i)
81-     idx =  CartesianIndices (A)[i]
82-     A. data[idx] =  val
83-     return  val
84- end 
85- 
86- #  Indexing
69+ #  Indexing methods
8770@inline  function  Base. getindex (A:: NDSparseArray{T, N} , I:: Vararg{Int, N} ) where  {T, N}
8871    @boundscheck  checkbounds (A, I... )
8972    idx =  CartesianIndex (I)
9073    haskey (A. data, idx) ||  throw (BoundsError (A, I))
9174    return  A. data[idx]
9275end 
9376
94- @inline  function  Base. getindex (A:: NDSparseArray , I:: CartesianIndex )
95-     @boundscheck  checkbounds (A, I)
96-     haskey (A. data, I) ||  throw (BoundsError (A, I))
97-     return  A. data[I]
98- end 
99- 
10077@inline  function  Base. setindex! (A:: NDSparseArray{T, N} , val, I:: Vararg{Int, N} ) where  {T, N}
10178    @boundscheck  checkbounds (A, I... )
10279    idx =  CartesianIndex (I)
10380    A. data[idx] =  val
10481    return  val
10582end 
10683
107- @inline  function  Base. setindex! (A:: NDSparseArray , val, I:: CartesianIndex )
108-     @boundscheck  checkbounds (A, I)
109-     A. data[I] =  val
110-     return  val
111- end 
112- 
11384#  Delete methods
11485""" 
11586    delete!(A::NDSparseArray, I...) 
0 commit comments