Back to Forum  View unanswered posts  View active topics

Page 1 of 1

[ 6 posts ] 

Author 
Message 
rambiz

Post subject: Reduced Row Echelon Form Posted: Tue Jun 07, 2016 3:27 pm 

Joined: Sun Nov 15, 2015 12:13 am Posts: 20

Hi all, how can one get the "Reduced Row Echelon Form" of a matrix in Singular, please?
example: (input is a 4x3 matrix)
input= [1 2 3 4 5 6 7 8 9 10 11 12]
desired output= [1 0 1 0 1 2 0 0 0 0 0 0]


Top 


rambiz

Post subject: My code for the Reduced Row Echelon Form Posted: Wed Jun 08, 2016 12:09 am 

Joined: Sun Nov 15, 2015 12:13 am Posts: 20

Hi all, I have written a code to implement conversion to the reduced row echelon form. I used the Groebner Basis approach, which is most probably not the smartest way. One needs to set the correct number of ring variables manually in the code, and of course, enter the matrix. In case the number of rows of output is smaller than the number of rows of the matrix, those rows are all zero. Code: ring r=0,(x(1..4)),dp; //number of variables must be the same as the number of columns of the matrix for which we want the reduced row echelon form
matrix m[4][4]=16,2,3,13,5,11,10,8,9,7,6,12,4,14,15,1; //enter an arbitrary matrix here
print("m=");print(m);
int nr=nrows(m); int nc=ncols(m); int j; int k; for(j=1;j<=nr;j=j+1){for(k=1;k<=nc;k=k+1){m[j,k]=m[j,k]*x(k);}}; kill j; kill k;
matrix ONES[nc][1]; for(int j=1;j<=nc;j=j+1){ONES[j,1]=1;}; kill j;
ideal i=m*ONES; option(redSB); ideal g=std(i); int L=size(g); for(int j=1;j<=L;j=j+1) {g[j]=g[j]/leadcoef(g[j]);} // set the coefficients of the leading terms to unity kill j;
matrix RREF[L][nc]; int k; int j; for (j=L;j>0;j=j1){for (k=1;k<=nc;k=k+1){RREF[j,k]=jet(g[L+1j]/x(k),0);}};
print("RREF=");print(RREF);print("RREF is the Reduced Row Echelon Form of the matrix m")
A) Do you think this code is correct? I have doublechecked a few matrices with MATLAB and it seems to be OK. B)Any suggestion how to improve my code?
Last edited by rambiz on Sat Jun 11, 2016 4:29 pm, edited 2 times in total.


Top 


hannes

Post subject: Re: Reduced Row Echelon Form Posted: Thu Jun 09, 2016 10:27 am 

Joined: Wed May 25, 2005 4:16 pm Posts: 190


Top 


rambiz

Post subject: ludecomp Posted: Thu Jun 09, 2016 4:29 pm 

Joined: Sun Nov 15, 2015 12:13 am Posts: 20

Hi Hannes, I had actually had a look at the function you suggested before I posted my original message. However, I don't know how that decomposition can be used to get the reduced row echelon form. Can you please elaborate? Thanks.


Top 


hannes

Post subject: Re: Reduced Row Echelon Form Posted: Fri Jun 10, 2016 11:05 am 

Joined: Wed May 25, 2005 4:16 pm Posts: 190

Code: ring R=0,x,dp; matrix m[4][3]=1,2,3,4,5,6,7,8,9,10,11,12; list L=ludecomp (m); print(L[3]); 1,2, 3, 0,3,6, 0,0, 0, 0,0, 0


Top 


rambiz

Post subject: Re: Reduced Row Echelon Form Posted: Sat Jun 11, 2016 4:42 pm 

Joined: Sun Nov 15, 2015 12:13 am Posts: 20

According to my definition in a reduced row echelon form the leading terms should all be one, and the remaining entries in the same column should be zero. In the case of your example:
matrix m[4][3]=1,2,3,4,5,6,7,8,9,10,11,12;
Desired output is:
1 0 1 0 1 2 0 0 0 0 0 0


Top 



Page 1 of 1

[ 6 posts ] 


You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum


It is currently Tue Jul 17, 2018 12:05 am

