Reduced row echelon form: Difference between revisions
m
→{{header|EasyLang}}
No edit summary |
|||
(6 intermediate revisions by 4 users not shown) | |||
Line 1:
x + 10z = 5▼
4x + y + 6z = 1▼
1 0 10 5▼
4 1 6 1▼
1 0 01 5▼
4 1 6 1▼
1 0 10 5▼
1 0 10 5▼
0 0 0 −3▼
x + 10z = 5▼
{{wikipedia|Rref#Pseudocode}}
Line 2,157 ⟶ 2,110:
0 1 0 1
0 0 1 -2</pre>
=={{header|EasyLang}}==
{{trans|Go}}
<syntaxhighlight>
proc rref . m[][] .
nrow = len m[][]
ncol = len m[1][]
lead = 1
for r to nrow
if lead > ncol
while m[i][lead] = 0
if i > nrow
i = r
lead += 1
if lead > ncol
return
swap m[i][] m[r][]
m = m[r][lead]
for k to ncol
m[r][k] /= m
.
for i to nrow
if i <> r
m = m[i][lead]
for k to ncol
m[i][k] -= m * m[r][k]
.
.
.
test[][] = [ [ 1 2 -1 -4 ] [ 2 3 -1 -11 ] [ -2 0 -3 22 ] ]
rref test[][]
print test[][]
</syntaxhighlight>
=={{header|Euphoria}}==
Line 5,371 ⟶ 5,367:
{{libheader|Wren-matrix}}
The above module has a method for this built in as it's needed to implement matrix inversion using the Gauss-Jordan method. However, as in the example here, it's not just restricted to square matrices.
<syntaxhighlight lang="
import "./fmt" for Fmt
var m = Matrix.new([
|