Im trying to write Gaussian elimination method.
I have array (column 0 and row 0 are empty always):
11 | 12 | 13 | 14
21 | 22 | 23 | 24
31 | 32 | 33 | 34
In Stage 1 first array ($A) is modyfied by function 'calc' and saved in second array and it looks like these ( * - updated):
11 | 12 | 13 | 14
21* | 22* | 23* | 24*
31* | 32* | 33* | 34*
In Stage 2 second array ($A2) is modyfied and saved in to $A3, should look like these:
11 | 12 | 13 | 14
21 | 22 | 23 | 24
31 | 32* | 33* | 34*
But it dosent. Function 'calc' is called 3 times like it should be, but array is changed like these:
11 | 12 | 13 | 14
21(+1)* | 22(+1)* | 23(+1)* | 24(+1)*
31(+2)* | 32* | 33* | 34*
Heres my code:
#Include <Array.au3>
$gi=3
$gj=$gi+1
Dim $A[$gi+1][$gj+1]
Dim $A2[$gi+1][$gj+1]
Dim $A3[$gi+1][$gj+1]
$A[1][1] = 2
$A[1][2] = 2
$A[1][3] = 2
$A[1][4] = 2
$A[2][1] = 1
$A[2][2] = 2
$A[2][3] = 4
$A[2][4] = 0
$A[3][1] = 2
$A[3][2] = 2
$A[3][3] = 1
$A[3][4] = -2
$A2=$A
$A3=$A
; Stage 1 <=====================
For $ti=2 To $gi Step +1
For $tj=1 To $gj Step +1
$A2[$ti][$tj] = Call("calc", $A, $ti, $tj, 1)
Next
Next
_ArrayDisplay($A2, "Window")
;Stage 2 <=====================
For $ti=3 To $gi Step +1
For $tj=2 To $gj Step +1
$A3[$ti][$tj] = Call("calc", $A2, $ti, $tj, 2)
Next
Next
_ArrayDisplay($A3, "Window")
Func calc($T, $i, $j, $c)
$temp = $T[$i][$j] - ($T[$i][$c]/$T[$c][$c]) * $T[$c][$j]
MsgBox(0,"","$T["&$i&"]["&$j&"] - ($T["&$i&"]["&$c&"]/$T["&$c&"]["&$c&"]) * $T["&$c&"]["&$j&"] = "&$temp);FOR DEBUG ONLY
Return $temp
EndFunc
Whats wrong in Step 2?