Thanks, James. Is this worthy of a github issue?

On Tuesday, September 8, 2015 at 5:00:53 PM UTC-7, James Fairbanks wrote:
>
> #= This is the function from Base that is being used when you call & on 
>>> two sparse matrices 
>>> function ($f){S,T}(A::AbstractArray{S}, B::AbstractArray{T})
>>>     F = similar(A, promote_op($F,S,T), promote_shape(size(A),size(B)))
>>>     for i in eachindex(A,B)
>>>         @inbounds F[i] = ($f)(A[i], B[i])
>>>     end
>>>     return F
>>> end
>>>
>>> # look at what eachindex does for SparseMatrixCSC
>>> a = sprand(10,10,0.3)
>>> @show collect(eachindex(a))
>>> 100-element Array{CartesianIndex{2},1}:
>>>  CartesianIndex{2}((1,1))  
>>>  CartesianIndex{2}((2,1))  
>>>  CartesianIndex{2}((3,1))  
>>>  CartesianIndex{2}((4,1))  
>>>  CartesianIndex{2}((5,1))  
>>>  CartesianIndex{2}((6,1))  
>>>  CartesianIndex{2}((7,1))  
>>>  CartesianIndex{2}((8,1))  
>>>  CartesianIndex{2}((9,1))  
>>>  CartesianIndex{2}((10,1)) 
>>>  CartesianIndex{2}((1,2))  
>>>  CartesianIndex{2}((2,2))  
>>>  CartesianIndex{2}((3,2))  
>>>  CartesianIndex{2}((4,2))   
>>>  ⋮                         
>>>  CartesianIndex{2}((6,8))  
>>>  CartesianIndex{2}((7,8))  
>>>  CartesianIndex{2}((8,8))  
>>>  CartesianIndex{2}((9,8))  
>>>  CartesianIndex{2}((10,8)) 
>>>  CartesianIndex{2}((1,9))  
>>>  CartesianIndex{2}((2,9))  
>>>  CartesianIndex{2}((3,9))  
>>>  CartesianIndex{2}((4,9))  
>>>  CartesianIndex{2}((5,9))  
>>>  CartesianIndex{2}((6,9))  
>>>  CartesianIndex{2}((7,9))  
>>>  CartesianIndex{2}((8,9))  
>>>  CartesianIndex{2}((9,9))  
>>>  CartesianIndex{2}((10,9)) 
>>>  CartesianIndex{2}((1,10)) 
>>>  CartesianIndex{2}((2,10)) 
>>>  CartesianIndex{2}((3,10)) 
>>>  CartesianIndex{2}((4,10)) 
>>>  CartesianIndex{2}((5,10)) 
>>>  CartesianIndex{2}((6,10)) 
>>>  CartesianIndex{2}((7,10)) 
>>>  CartesianIndex{2}((8,10)) 
>>>  CartesianIndex{2}((9,10)) 
>>>  CartesianIndex{2}((10,10))
>>>
>>>  The problem is that the generic AbstractArray implementation of & and 
> some other operators is iterating over all the n x m entries of A. 
>

Reply via email to