How to resolve the algorithm Reduced row echelon form step by step in the Ring programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Reduced row echelon form step by step in the Ring 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 Ring programming language
Source code in the ring programming language
# Project : Reduced row echelon form
matrix = [[1, 2, -1, -4],
[2, 3, -1, -11],
[ -2, 0, -3, 22]]
ref(matrix)
for row = 1 to 3
for col = 1 to 4
if matrix[row][col] = -0
see "0 "
else
see "" + matrix[row][col] + " "
ok
next
see nl
next
func ref(m)
nrows = 3
ncols = 4
lead = 1
for r = 1 to nrows
if lead >= ncols
exit
ok
i = r
while m[i][lead] = 0
i = i + 1
if i = nrows
i = r
lead = lead + 1
if lead = ncols
exit 2
ok
ok
end
for j = 1 to ncols
temp = m[i][j]
m[i][j] = m[r][j]
m[r][j] = temp
next
n = m[r][lead]
if n != 0
for j = 1 to ncols
m[r][j] = m[r][j] / n
next
ok
for i = 1 to nrows
if i != r
n = m[i][lead]
for j = 1 to ncols
m[i][j] = m[i][j] - m[r][j] * n
next
ok
next
lead = lead + 1
next
You may also check:How to resolve the algorithm Hash join step by step in the D programming language
You may also check:How to resolve the algorithm Collections step by step in the AWK programming language
You may also check:How to resolve the algorithm Sieve of Eratosthenes step by step in the Modula-3 programming language
You may also check:How to resolve the algorithm Map range step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Sequence of primes by trial division step by step in the Batch File programming language