[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RREF (row reduce echelon form)
From: |
Paul Kienzle |
Subject: |
Re: RREF (row reduce echelon form) |
Date: |
Sun, 21 Jan 2001 16:49:58 +0000 |
User-agent: |
Mutt/1.2.5i |
And here is the version which comes with matcompat:
http://users.powernet.co.uk/kienzle/octave/matcompat
Also, a number of different versions have been submitted to octave-sources
and help-octave over the years. Perhaps you grabbed one of the them and
that's why you thought it was part of Octave?
Paul Kienzle
address@hidden
## rref Reduced row echelon form
## R = rref (A, tol) returns the reduced row echelon form of a.
## tol defaults to eps * max (size (A)) * norm (A, inf)
##
## [R, k] = rref (...) returns the vector of "bound variables",
## which are those columns on which elimination has been performed.
## Author: Paul Kienzle (based on a anonymous source from the public domain)
function [A, k] = rref (A, tolerance)
## Supress empty list warnings
eleo = empty_list_elements_ok;
unwind_protect
empty_list_elements_ok = 1;
[rows,cols] = size (A);
if (nargin < 2)
tolerance = eps * max (rows, cols) * norm (A, inf);
endif
used = zeros(1,cols);
r = 1;
for c=1:cols
## Find the pivot row
[m, pivot] = max (abs (A (r:rows, c)));
pivot = r + pivot - 1;
if (m <= tolerance)
## Skip column c, making sure the approximately zero terms are
## actually zero.
A (r:rows, c) = zeros (rows-r+1, 1);
else
## keep track of bound variables
used (1, c) = 1;
## Swap current row and pivot row
A ([pivot, r], c:cols) = A ([r, pivot], c:cols);
## Normalize pivot row
A (r, c:cols) = A (r, c:cols) / A (r, c);
## Eliminate the current column
ridx = [1:r-1, r+1:rows];
A (ridx, c:cols) = A (ridx, c:cols) - A (ridx, c) * A(r, c:cols);
## Check if done
if (r++ == rows) break; endif
endif
endfor
k = find(used);
unwind_protect_cleanup
## Restore state
empty_list_elements_ok = eleo;
end_unwind_protect
endfunction
On Sat, Jan 20, 2001 at 09:46:43PM -0800, J. R. Miller wrote:
> Hi,
>
> I seem to recall several years ago there was an octave command or function
> "RREF" (row reduce echelon form), for whatever version of Octave
> corresponded to Debian 1.2 or 1.3. Returning, I can't find "RREF". If
> I'm just not seeing it, please tell me where to look, or how to setup.
>
> If it's not part of Octave, is there somewhere fellow users share this
> kind of code, so I don't have to reinvent the wheel?
>
> Otherwise, please tell me where I can find pseudocode for the algorithm
> and whatever language reference is recommended for writing this code.
> /This is not an area of strength for me, so please be specific./
>
> Thanks,
>
> JR
> address@hidden
>
>
>
>
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web: http://www.octave.org
> How to fund new projects: http://www.octave.org/funding.html
> Subscription information: http://www.octave.org/archive.html
> -------------------------------------------------------------
>
>
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------