[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: reduced row echelon form
From: |
Paul Kienzle |
Subject: |
Re: reduced row echelon form |
Date: |
Mon, 16 Oct 2000 09:51:55 +0100 |
User-agent: |
Mutt/1.2.5i |
Here is one that I found. I don't know if it is correct.
Paul Kienzle
address@hidden
##rref Reduced row echelon form
## rref (a, tol) returns the reduced row echelon form of a.
## tol defaults to eps * max (size (a)) * norm (A, inf)
## This code is in the public domain
## Adapted-by: Paul Kienzle
function A = rref (A, tolerance)
## Supress empty list warnings
ele_save = empty_list_elements_ok;
unwind_protect
empty_list_elements_ok = 1;
[rows,cols] = size (A);
r = 1;
c = 1;
if (nargin < 2)
tolerance = eps * max (r, c) * norm (A, inf);
endif
while ((r<=rows) & (c<=cols))
## Find the pivot row
[m, pivot] = max (abs (A (r:rows, c)));
pivot = r + pivot - 1;
if (m <= tolerance)
## Zero out the column
A (r:rows, c++) = zeros (rows-r+1, 1);
else
## Swap row p and row r
A ([pivot, r], c:cols) = A ([r, pivot], c:cols);
## Divide by leading term
A (r, c:cols) = A (r, c:cols) / A (r, c);
## Clear column c
for i = [1:r-1, r+1:rows]
A (i, c:cols) = A (i, c:cols) - A (i, c) * A (r, c:cols);
endfor;
c++;
r++;
endif
endwhile
unwind_protect_cleanup
## Restore state
empty_list_elements_ok = ele_save;
end_unwind_protect
endfunction
On Sun, Oct 15, 2000 at 11:43:37PM -0400, ben partan wrote:
> 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?
> Thanks.
> ________________________________________________________________
> YOU'RE PAYING TOO MUCH FOR THE INTERNET!
> Juno now offers FREE Internet Access!
> Try it today - there's no risk! For your FREE software, visit:
> http://dl.www.juno.com/get/tagj.
>
>
>
> -----------------------------------------------------------------------
> 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
> -----------------------------------------------------------------------
>
>
-----------------------------------------------------------------------
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
-----------------------------------------------------------------------