From: Andrei Baskakov on
Interesting thing. I tested thee approaches.
Assuming that all entries in A are ones!
T = sparse(IT, JT, 1, n, n);
1) setsparse(A, I1, J1, 0);
A1 = setsparse(A, IT, JT, 0);

2) Using setdiff([I J], [I1 J2]);
[I J] = find(A);
[IJ] = setdiff([I J], [IT JT], 'rows');
A2 = sparse(IJ(:,1), IJ(:,2), 1, n, n);

3) Using matrix difference
A3 = A - (A & T);

And the 3) is the fastest for random matrices.
A was a 1000x1000 matrix created with sprand.
nnz(A) = 181493
nnz(T) = 33453

Timings of approaches in seconds
1: 0.055329,
2: 0.800266,
3: 0.023299

"Bruno Luong" <b.luong(a)fogale.findmycountry> wrote
> Remove non-zero elements is costly operation for sparse matrix, because the internal data have to be squeezed. My guess is this is a biggest time consuming part.