Skip to content

Commit 6b86270

Browse files
committed
Introduce getunstoredindex_function
1 parent 00cac74 commit 6b86270

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseArraysBase"
22
uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.5.11"
4+
version = "0.6.1"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"

src/abstractsparsearrayinterface.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ using DerivableInterfaces:
44

55
function eachstoredindex end
66
function getstoredindex end
7-
function getunstoredindex end
7+
function getunstoredindex_function end
88
function isstored end
99
function setstoredindex! end
1010
function setunstoredindex! end
1111
function storedlength end
1212
function storedpairs end
1313
function storedvalues end
1414

15+
@inline function getunstoredindex(a::AbstractArray{<:Any,N}, I::Vararg{Int,N}) where {N}
16+
@boundscheck checkbounds(a, I...)
17+
return getunstoredindex_function(a)(a, I...)
18+
end
19+
1520
# Replace the function for accessing
1621
# unstored values.
1722
function set_getunstoredindex end
@@ -90,7 +95,7 @@ end
9095
a::AbstractArray, T::Type, size::Tuple{Vararg{Int}}
9196
)
9297
# TODO: Define `default_similartype` or something like that?
93-
return SparseArrayDOK{T}(undef, size)
98+
return SparseArrayDOK{T}(undef, size; getunstored=getunstoredindex_function(a))
9499
end
95100

96101
# map over a specified subset of indices of the inputs.

src/sparsearraydok.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ end
8787
@boundscheck checkbounds(a, I...)
8888
return storage(a)[CartesianIndex(I)]
8989
end
90+
@inline getunstoredindex_function(a::SparseArrayDOK) = a.getunstored
9091
@inline function getunstoredindex(a::SparseArrayDOK{<:Any,N}, I::Vararg{Int,N}) where {N}
9192
@boundscheck checkbounds(a, I...)
92-
return a.getunstored(a, I...)
93+
return getunstoredindex_function(a)(a, I...)
9394
end
9495
@inline function setstoredindex!(
9596
a::SparseArrayDOK{<:Any,N}, value, I::Vararg{Int,N}

0 commit comments

Comments
 (0)