|
1 | 1 | parentvalue_to_value(a::AbstractArray, value) = value |
2 | 2 | value_to_parentvalue(a::AbstractArray, value) = value |
3 | | -eachstoredparentindex(a::AbstractArray) = eachstoredindex(parent(a)) |
| 3 | +eachstoredparentindex(a::AbstractArray) = eachstoredparentindex(IndexStyle(a), a) |
| 4 | +function eachstoredparentindex(style::IndexStyle, a::AbstractArray) |
| 5 | + return eachstoredindex(style, parent(a)) |
| 6 | +end |
4 | 7 | storedparentvalues(a::AbstractArray) = storedvalues(parent(a)) |
5 | 8 |
|
6 | 9 | function parentindex_to_index(a::AbstractArray{<:Any,N}, I::CartesianIndex{N}) where {N} |
@@ -71,8 +74,8 @@ function index_to_parentindex(a::ReshapedArray, I::CartesianIndex) |
71 | 74 | return CartesianIndices(parent(a))[LinearIndices(size(a))[I]] |
72 | 75 | end |
73 | 76 |
|
74 | | -function eachstoredparentindex(a::SubArray) |
75 | | - return filter(eachstoredindex(parent(a))) do I |
| 77 | +function eachstoredparentindex(style::IndexStyle, a::SubArray) |
| 78 | + return filter(eachstoredindex(style, parent(a))) do I |
76 | 79 | return all(d -> I[d] ∈ parentindices(a)[d], 1:ndims(parent(a))) |
77 | 80 | end |
78 | 81 | end |
|
144 | 147 | for type in (:Adjoint, :PermutedDimsArray, :ReshapedArray, :SubArray, :Transpose) |
145 | 148 | @eval begin |
146 | 149 | @interface ::AbstractSparseArrayInterface storedvalues(a::$type) = storedparentvalues(a) |
147 | | - @interface ::AbstractSparseArrayInterface function eachstoredindex(a::$type) |
| 150 | + @interface ::AbstractSparseArrayInterface function eachstoredindex( |
| 151 | + style::IndexStyle, a::$type |
| 152 | + ) |
148 | 153 | # TODO: Make lazy with `Iterators.map`. |
149 | | - return map(collect(eachstoredparentindex(a))) do I |
| 154 | + return map(eachstoredparentindex(style, a)) do I |
150 | 155 | return parentindex_to_index(a, I) |
151 | 156 | end |
152 | 157 | end |
|
193 | 198 | @interface ::AbstractArrayInterface eachstoredindex(D::Diagonal) = |
194 | 199 | _diagind(D, IndexCartesian()) |
195 | 200 |
|
196 | | -function isstored(D::Diagonal, i::Int, j::Int) |
| 201 | +@interface ::AbstractArrayInterface function isstored(D::Diagonal, i::Int, j::Int) |
197 | 202 | return i == j && checkbounds(Bool, D, i, j) |
198 | 203 | end |
199 | 204 | @interface ::AbstractArrayInterface function getstoredindex(D::Diagonal, i::Int, j::Int) |
|
0 commit comments