help-octave
[Top][All Lists]
Advanced

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

Re: RREF (row reduce echelon form)


From: Kevin Straight
Subject: Re: RREF (row reduce echelon form)
Date: Sun, 21 Jan 2001 11:49:14 -0800 (PST)

Hello, here is the rref which comes with goctave, it works pretty well
generally.  See the documentation on the goctave web site
at: http://12.32.54.90/goctave/manual/index.html


=================
## usage: rref (m)
##
## Return the reduced-row-eschelon-form of matrix m.

## Author: Kevin Straight, address@hidden

function retval = rref (m, dummy)

     if (nargin < 1)
        usage ("rref (x)");
     endif

# Bring the pivot to the top row

     for i=1:rows(m)
       if(m(i,1)==max(m(:,1)))
         scratch=m(i,:);
         m(i,:)=m(1,:);
         m(1,:)=scratch;

       endif     
     endfor

     if(m(1,1)!=0)
       m(1,:)=m(1,:)/m(1,1);

       for i=2:rows(m)

         if(m(i,1)!=0)

           m(i,:)=(m(i,:)/m(i,1))-m(1,:);

         endif
       endfor
     else
         if(any(m(1,:)))
           q=2;
           while(m(1,q)==0)
             q++;
           endwhile
           m(1,:)=m(1,:)/m(1,q);
         endif
     endif

     if(columns(m)>1 && rows(m)>1)
        m(2:rows(m),2:columns(m)) = rref( m(2:rows(m),2:columns(m)),1 );        
        
     endif


# Swell, now we're row reduced.  Lets get to rref

     if((rows(m)>=2) && (columns(m) >=2) && (nargin ==1))

     for i=0:rows(m)-1
       if( any( m(rows(m)-i,:) ) )

         q=1;
         while(m(rows(m)-i,q)==0)
           q++;
         endwhile
         for j=1:rows(m)-i-1
           m(j,:)=m(j,:)-(m(rows(m)-i,:)*m(j,q));
         endfor

       endif
     endfor

     endif

     retval = m;

endfunction
=================

On Sat, 20 Jan 2001, 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
> -------------------------------------------------------------
> 

==========================
Kevin Straight
University of Idaho
www.uidaho.edu/~stra9456
==========================



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

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