-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
An important part of the logic for map/broadcast is first determining if the function preserves zero values (or more generally, stored values, though for now we are focusing on the case where unstored values are zero). If it doesn't, all elements of the destination need to be instantiated, while if it does, we only need to loop over the values that are stored in the arrays being mapped/broadcasted.
The logic as of #21 is based on a function:
function preserves_unstored(f, a_dest::AbstractArray, as::AbstractArray...)
I = first(eachindex(as...))
return iszero(f(map(a -> getunstoredindex(a, I), as)...))
end
which has the disadvantage that calling getunstoredindex
could be expensive, say if the sparse array is an array of large arrays it could allocate a large array, and additionally checking if it is zero could be expensive as well. It would be good to try to come up with a better system for that.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request