The creation of the new sparse matrix (via spdiagm) doubles the amount of memory, unfortunately. I had to kill it past 26 GB.
On Thursday, April 2, 2015 at 1:36:48 PM UTC-7, Patrick O'Leary wrote: > > Perhaps try: > > z = e + spdiagm(fill(Inf, 50000), 0, 50000, 50000) > > I can't try a matrix that large, I don't have the memory on this system--I > tested with 5000, though, and it is massively faster. > > On Thursday, April 2, 2015 at 3:21:37 PM UTC-5, Seth wrote: >> >> >> >> 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. >> >
