From: Matt J on
"Ross Anderson" <rpa5nospam(a)cornell.edu> wrote in message <i180dd$sid$1(a)fred.mathworks.com>...
> Hi all,
>
> I have Ax=B where A and B are sparse. I want to reduce this so any row ax=b is unique, but I don't have the resources to make A and B full first. If I could, I could say
>
> Afull = [full(A) full(B)];
> [newmat,index] = unique(Afull,'rows','first');
> repeatedIndex = setdiff(1:size(Afull,1),index);
> Af = full(A);
> Bf = full(B);
> Af(repeatedIndex,:) = [];
> Bf(repeatedIndex)=[];
> A = sparse(Af);
> B = sparse(Bf);
>
> but is there a way to do this without un-sparsifying A and B?
============

I don't see why you think you needed to unsparsify. UNIQUE seems to accept sparse input just fine, at least in R2009b. So I'm wondering why the solution isn't as simple as the following:

n=size(A,2);
Aug=unique( [A,B], 'rows', 'first');

A=Aug(:,1:n);
B=Aug(:,n+1:end);