After
do this in Python, now it's time to bring it back to Delphi, where all of this is started, :)
The heart of code lay on this one
procedure tform1.gauss;
var i,j,k:integer; temp:real;
begin
for i:=1 to 9 do begin
for j:= 1 to i do begin
if t[i,j]<>0 then begin
temp:=t[i,j];
for k:= 1 to 10 do begin
if i=j then
t[j,k]:=t[j,k]/temp
else t[i,k]:=t[i,k]/temp - t[j,k];
end;
end;
end;
end;
//back subtitution
for i:=9 downto 1 do begin
x[i]:=t[i,10];
for j:=9 downto i do begin
if i<>j then
x[i]:=x[i]-x[j]*t[i,j];
end;
end;
You could say that it consists of zeroing lower tringle and normalizing the diagonal and then subtituting the value.
There's little failsafe code here, that is if we already have zero cell, don't proceed, or it will gave divided by zero error.