function S = speye(m,n)
%SPEYE  Sparse identity matrix.
%   SPEYE(M,N) forms an M-by-N sparse matrix with 1's on
%   the main diagonal.  SPEYE(N) abbreviates SPEYE(N,N).
%
%   SPEYE(SIZE(A)) is a space-saving SPARSE(EYE(SIZE(A))).
%
%   See also SPONES, SPDIAGS, SPALLOC, SPRAND, SPRANDN.

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 5.4 $  $Date: 1997/11/21 23:44:43 $

if nargin < 2
   if length(m) == 1
      n = m;
   elseif length(m) == 2
      n = m(2);
      m = m(1);
   else 
      error('Please use SPEYE(N), SPEYE(M,N) or SPEYE([M,N]).')
   end
end
k = 1:round(min(m,n));
S = sparse(k,k,1,m,n);
