function p = colperm(S)
%COLPERM Order columns based on nonzero count.
%	p = COLPERM(S) generate a permutation that reorders the
%	columns of the sparse (or full) matrix S in nondecreasing
%	order of nonzero count.  Useful as a preordering for LU 
%	factorization: lu(S(:,p)).
%	Not the best ordering in the world, but it's fast to 
%	compute, and it does a pretty good job.
%
%	See also COLMMD, SYMMMD, SYMRCM.

%	Copyright (c) 1984-94 by The MathWorks, Inc.

[ignore,p] = sort(full(sum(spones(S))));
