const
n = 4;
begin
var a := new real[n, n](
(1.17, 0.53, -0.84, -0.34),
(0.64, -0.72, -0.43, 0.17),
(0.32, 0.43, -0.93, 0.23),
(1.35, -0.72, 1.38, 0.35));
var b := new real[n](1.15, 0.15, -0.48, 0.88);
var t := ArrFill(n, True);
for var j := 0 to n - 1 do begin
(var amin, var imin) := (real.MaxValue, -1);
for var i := 0 to n - 1 do
if (abs(a[i, j]) < amin) and t[i] then
(imin, amin) := (i, a[i, j]);
if amin = 0 then begin
t[imin] := False;
break
end;
for var k := 0 to n - 1 do
a[imin, k] /= amin; b[imin] /= amin;
for var i := 0 to n - 1 do begin
var coef := -a[i, j] / a[imin, j];
if i <> imin then begin
a[i, k] := a[imin, k] * coef + a[i, k];
b[i] := b[imin] * coef + b[i]
end
b.PrintLines
end.
const
n = 4;
begin
var a := new real[n, n](
(1.17, 0.53, -0.84, -0.34),
(0.64, -0.72, -0.43, 0.17),
(0.32, 0.43, -0.93, 0.23),
(1.35, -0.72, 1.38, 0.35));
var b := new real[n](1.15, 0.15, -0.48, 0.88);
var t := ArrFill(n, True);
for var j := 0 to n - 1 do begin
(var amin, var imin) := (real.MaxValue, -1);
for var i := 0 to n - 1 do
if (abs(a[i, j]) < amin) and t[i] then
(imin, amin) := (i, a[i, j]);
if amin = 0 then begin
t[imin] := False;
break
end;
for var k := 0 to n - 1 do
a[imin, k] /= amin; b[imin] /= amin;
t[imin] := False;
for var i := 0 to n - 1 do begin
var coef := -a[i, j] / a[imin, j];
if i <> imin then begin
for var k := 0 to n - 1 do
a[i, k] := a[imin, k] * coef + a[i, k];
b[i] := b[imin] * coef + b[i]
end
end
end;
b.PrintLines
end.