Consider the following:

julia> @time e = sprandn(50000,50000,0.3);
elapsed time: 95.837541848 seconds (17178 MB allocated, 0.08% gc time in 4 
pauses with 1 full sweep)

then:

julia> function doinf!(e::SparseMatrixCSC)
           for i = 1:size(e)[1]
               e[i,i] = Inf
           end
       end
doinf! (generic function with 1 method)

julia> @time z = doinf!(e);


...still going after about 20 minutes. I know sparse matrix insertion is 
expensive, but is there a better way of doing this? (I don't have the 
storage to make this a dense matrix.) I'm thinking it might be faster to 
write my own function to assign random number or Inf within two loops, but 
I'm surprised that the doinf! is taking so long.

Reply via email to