How to resolve the algorithm Reduced row echelon form step by step in the Icon and Unicon programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Reduced row echelon form step by step in the Icon and Unicon programming language
Table of Contents
Problem Statement
Show how to compute the reduced row echelon form (a.k.a. row canonical form) of a matrix. The matrix can be stored in any datatype that is convenient (for most languages, this will probably be a two-dimensional array). Built-in functions or this pseudocode (from Wikipedia) may be used: For testing purposes, the RREF of this matrix: is:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Reduced row echelon form step by step in the Icon and Unicon programming language
Source code in the icon programming language
procedure main(A)
tM := [[ 1, 2, -1, -4],
[ 2, 3, -1,-11],
[ -2, 0, -3, 22]]
showMat(rref(tM))
end
procedure rref(M)
lead := 1
rCount := *\M | stop("no Matrix?")
cCount := *(M[1]) | 0
every r := !rCount do {
i := r
while M[i,lead] = 0 do {
if (i+:=1) > rCount then {
i := r
if cCount < (lead +:= 1) then stop("can't reduce")
}
}
M[i] :=: M[r]
if 0 ~= (m0 := M[r,lead]) then every !M[r] /:= real(m0)
every r ~= (i := !rCount) do {
every !(mr := copy(M[r])) *:= M[i,lead]
every M[i,j := !cCount] -:= mr[j]
}
lead +:= 1
}
return M
end
procedure showMat(M)
every r := !M do every writes(right(!r,5)||" " | "\n")
end
You may also check:How to resolve the algorithm Loops/For step by step in the Perl programming language
You may also check:How to resolve the algorithm Ordered words step by step in the Befunge programming language
You may also check:How to resolve the algorithm Sum of squares step by step in the Sather programming language
You may also check:How to resolve the algorithm Perfect numbers step by step in the Lasso programming language
You may also check:How to resolve the algorithm Teacup rim text step by step in the AWK programming language