i'm running the following code, where M
is a ~200,000 by ~200,000 sparse matrix and points
is ~200,000 by 2 matrix
inds=sub2ind(size(M),points(:,1),points(:,2));
M(inds)=M(inds)+1;
the problem is that the second line takes very long to run (15-90 seconds).
the operation takes longer depending on how many of the indices in inds
are 'new' (i.e. that don't already have a value in the sparse matrix)
is there a more efficient way to do this?