Reduced Echelon Form...

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Reduced Echelon Form...

Ryan Kirkpatrick-2

        I have a quick question for all of you Octave people... Is there
a function / way to get the reduced echelon form of a matrix using Octave?
The MatLab function is rref(), but I can't find any reference to it or
reduced echelon from any where in the octave manuals, info pages, or
mailing list archives. This is also sometime called the Gauss-Jordan
reduction method.
        I know how to do it by hand, and my HP48GX can do it, and it would
nice to be able to quickly do it with Octave as well. Thanks!

----------------------------------------------------------------------------
|   "For to me to live is Christ, and to die is gain."                     |
|                                            --- Philippians 1:21 (KJV)    |
----------------------------------------------------------------------------
|  Ryan Kirkpatrick  |  Boulder, Colorado  | [hidden email]  |
----------------------------------------------------------------------------
|               http://www-ugrad.cs.colorado.edu/~rkirkpat/                |
----------------------------------------------------------------------------



Reply | Threaded
Open this post in threaded view
|

Reduced Echelon Form...

John W. Eaton-6
On 12-Nov-1997, Ryan Kirkpatrick <[hidden email]> wrote:

| I have a quick question for all of you Octave people... Is there
| a function / way to get the reduced echelon form of a matrix using Octave?
| The MatLab function is rref(), but I can't find any reference to it or
| reduced echelon from any where in the octave manuals, info pages, or
| mailing list archives.

Octave doesn't have a function for this.  Would someone like to write
it and contribute it for a future release?

Thanks,

jwe


Reply | Threaded
Open this post in threaded view
|

Re: Reduced Echelon Form...

Dirk Laurie
> On 12-Nov-1997, Ryan Kirkpatrick <[hidden email]> wrote:
>
> | I have a quick question for all of you Octave people... Is there
> | a function / way to get the reduced echelon form of a matrix using Octave?

What do you mean by "the" reduced echelon form?

In general you get from a matrix to echelon form by a sequence of
  A(i,:) -= e(i,j)*A(j,:)
and
  A([i,j],:) = A([j,i],:)
operations.  In infinite precision you could in principle make this
unique by swapping only when necessary, and using the smallest available
index, but in floating point it is customary to swap so abs(A(i,i))
becomes as large as possible.  Then what about ties, etc.?

If all you need is _some_ echelon form, it can easily be done with existing
functions.

>> % Take as example a 5x4 matrix of rank 3
>> A=rand(5,3)*rand(3,4)
A =

  0.57946  0.47497  0.28647  0.69047
  1.14007  0.58709  0.55125  1.29656
  1.04450  0.68101  0.59835  1.35022
  0.50407  0.24968  0.39805  0.81140
  0.91741  0.42059  0.46076  1.06360
>> % Make it square by adding zeros and call lu
>> [L,U,P]=lu([A zeros(5,1)]);
>> U
U =

   1.14007   0.58709   0.55125   1.29656   0.00000
   0.00000   0.17657   0.00629   0.03147   0.00000
   0.00000   0.00000   0.15467   0.23990   0.00000
   0.00000   0.00000   0.00000  -0.00000   0.00000
   0.00000   0.00000   0.00000   0.00000   0.00000
>> % Diagnose which rows of U are zero
>> sum(abs(U'))
ans =

  3.57497  0.21433  0.39457  0.00000  0.00000
>> echelon=U(ans>eps,1:4)
echelon =

  1.14007  0.58709  0.55125  1.29656
  0.00000  0.17657  0.00629  0.03147
  0.00000  0.00000  0.15467  0.23990

You can see from this that the final echelon form depends on tricy
decisions whether a floating point number is zero.

Dirk




Reply | Threaded
Open this post in threaded view
|

Re: Reduced Echelon Form...

Ryan Kirkpatrick-2
        Sorry about the delay, I got busy and forgot about this email.

On Thu, 13 Nov 1997, Dirk Laurie wrote:

> > On 12-Nov-1997, Ryan Kirkpatrick <[hidden email]> wrote:
> >
> > | I have a quick question for all of you Octave people... Is there
> > | a function / way to get the reduced echelon form of a matrix using Octave?
>
> What do you mean by "the" reduced echelon form?

        What I mean is:

        rref([4 5  2 0;
              2 7  9 0;
              8 10 4 0])

        results in

        [ 1 0 -1.7222 0;
          0 1 1.7777  0;
          0 0 0       0]

        This is an example, where each row starts with a one, that the
colunm that contains a starting one is all zeros save that one, and the
matrix is an upper triangular matrix.

        Your method is close to what I am looking for but not quite.
Hopefully this will make clearer what I am looking for.

----------------------------------------------------------------------------
|   "For to me to live is Christ, and to die is gain."                     |
|                                            --- Philippians 1:21 (KJV)    |
----------------------------------------------------------------------------
|  Ryan Kirkpatrick  |  Boulder, Colorado  | [hidden email]  |
----------------------------------------------------------------------------
|               http://www-ugrad.cs.colorado.edu/~rkirkpat/                |
----------------------------------------------------------------------------