help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reduced row echelon form


From: Dirk Laurie
Subject: Re: reduced row echelon form
Date: Mon, 16 Oct 2000 08:55:36 +0200

ben partan skryf:
> Is there a built-in command for get a reduced row echelon form of a
> matrix? Or is there an easy way to get one?

function [R,k]=rref(A,tol)
% reduced row echelon form
[m,n]=size(A); p=max(m,n);
if nargin<2, tol=p*eps*norm(A,inf); end
  % pad matrix with zeros to make it square
if mŠþ=n, A(p,p)=0; end
[L,U,P]=lu(A); r=sum(max(abs(U'))>tol);
for i=1:r, k=find(U(i,:)); j(i)=k(1); end
R=U(1:r,j)ŠÜU(1:r,:);
  % remove added columns if any, add correct number of zero rows
if n<p, R(:,n+1:p)=[]; end
if length(k)<m, R(m,n)=0; end
endfunction

Consider the above code as alpha tested only.

Dirk



-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]