[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Row Reduced Eschelon Form?
From: |
Dirk Laurie |
Subject: |
Re: Row Reduced Eschelon Form? |
Date: |
Tue, 19 Jan 1999 16:16:13 +0200 (SAT) |
Bryan May wrote:
>
> Is there a version of matlab's rref() for octave. I looked throught the
> linear algebra documentation and couldn't find anything on it. Any ideas?
>
The equivalent is quite easy to write as an m-file.
function R=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);
k=find(abs(diag(U))>tol);
R=U(k,k)\U(k,:);
% 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
Dirk