9292 # TODO : Define `default_similartype` or something like that?
9393 return SparseArrayDOK {T} (undef, size)
9494end
95-
96- # map over a specified subset of indices of the inputs.
97- function map_indices! end
98-
99- @interface interface:: AbstractArrayInterface function map_indices! (
100- indices, f, a_dest:: AbstractArray , as:: AbstractArray...
101- )
102- for I in indices
103- a_dest[I] = f (map (a -> a[I], as)... )
104- end
105- return a_dest
106- end
107-
108- # Only map the stored values of the inputs.
109- function map_stored! end
110-
111- @interface interface:: AbstractArrayInterface function map_stored! (
112- f, a_dest:: AbstractArray , as:: AbstractArray...
113- )
114- @interface interface map_indices! (eachstoredindex (as... ), f, a_dest, as... )
115- return a_dest
116- end
117-
118- # Only map all values, not just the stored ones.
119- function map_all! end
120-
121- @interface interface:: AbstractArrayInterface function map_all! (
122- f, a_dest:: AbstractArray , as:: AbstractArray...
123- )
124- @interface interface map_indices! (eachindex (as... ), f, a_dest, as... )
125- return a_dest
126- end
127-
12895using DerivableInterfaces: DerivableInterfaces, zero!
12996
13097# `zero!` isn't defined in `Base`, but it is defined in `ArrayLayouts`
@@ -140,36 +107,6 @@ using DerivableInterfaces: DerivableInterfaces, zero!
140107 return @interface interface map_stored! (f, a, a)
141108end
142109
143- # Determines if a function preserves the stored values
144- # of the destination sparse array.
145- # The current code may be inefficient since it actually
146- # accesses an unstored element, which in the case of a
147- # sparse array of arrays can allocate an array.
148- # Sparse arrays could be expected to define a cheap
149- # unstored element allocator, for example
150- # `get_prototypical_unstored(a::AbstractArray)`.
151- function preserves_unstored (f, a_dest:: AbstractArray , as:: AbstractArray... )
152- I = first (eachindex (as... ))
153- return iszero (f (map (a -> getunstoredindex (a, I), as)... ))
154- end
155-
156- # @interface interface::AbstractSparseArrayInterface function Base.map!(
157- # f, a_dest::AbstractArray, as::AbstractArray...
158- # )
159- # isempty(a_dest) && return a_dest # special case to avoid trying to access empty array
160- # indices = if !preserves_unstored(f, a_dest, as...)
161- # eachindex(a_dest)
162- # elseif any(a -> a_dest !== a, as)
163- # as = map(a -> Base.unalias(a_dest, a), as)
164- # @interface interface zero!(a_dest)
165- # eachstoredindex(as...)
166- # else
167- # eachstoredindex(a_dest)
168- # end
169- # @interface interface map_indices!(indices, f, a_dest, as...)
170- # return a_dest
171- # end
172-
173110# `f::typeof(norm)`, `op::typeof(max)` used by `norm`.
174111function reduce_init (f, op, as... )
175112 # TODO : Generalize this.
0 commit comments