# procedure Ref, Maple 6, packable # Copyright: Erich Kaltofen RefPkg['Ref'] := proc(A::Matrix) # returns the row echelon form of the matrix A local m,n, i,j,k, AA; option `Copyright (c) 1997;2002 by Erich Kaltofen`; description `optional second arg column nr m at which to stop`; AA := copy(A); # so that argument remains unchanged m := LinearAlgebra[RowDimension](AA); if nargs > 1 # optional second argument then n := args[2]; else n := LinearAlgebra[ColumnDimension](AA); fi; i := 1; # current row j := 1; # current column while i 0 then break; # out of for loop fi; od; # end pivot search if k <= m then # found a pivot element # place pivot element in i-th row if i<>k then LinearAlgebra[RowOperation](AA, [i, k], inplace=true); userinfo(3, {'RefPkg', 'Ref'}, `NoName`, print(cat(`Exchanged row ` , i , ` and ` , k))); fi; # now AA[i,j] <> 0, so eliminate rest of column for k from i+1 to m do # set AA[k,j] to 0 userinfo(3, {'RefPkg', 'Ref'}, `NoName`, print(cat(`Added row ` , i , ` times `), -AA[k,j]/AA[i,j], cat(` to row ` , k))); LinearAlgebra[RowOperation](AA, [k, i], -AA[k,j]/AA[i,j], inplace=true); userinfo(3, {'RefPkg', 'Ref'}, `NoName`, print(AA)); od; i := i+1; j := j+1; else # all elements in j-th col below i-1-st row are 0 j := j+1; # skip to next col, but stay in row fi; od; RETURN(AA); end: