Cholesky decomposition: Difference between revisions
Added compatibility for Delphi
m (Enable syntax highlighting for C#) |
MaiconSoft (talk | contribs) (Added compatibility for Delphi) |
||
Line 2,450:
=={{header|Pascal}}==
<lang pascal>
type
D2Array = array of array of double;
function cholesky(const A: D2Array): D2Array;
procedure printM(const A: D2Array);
begin
for
▲ begin
▲ for j := low(A) to high(A) do
▲ write(A[i,j]:8:5);
▲ writeln;
end;▼
end;
end;
const
m1: array[0..2, 0..2] of double = ((25, 15, -5), (15, 18, 0), (-5, 0, 11));
▲ m2: array[0..3,0..3] of double = ((18, 22, 54, 42),
var
index, i: integer;
cIn, cOut: D2Array;
Line 2,501 ⟶ 2,498:
setlength(cIn, length(m1), length(m1));
for index := low(m1) to high(m1) do
begin
cIn[index] := m1[index];▼
SetLength(cIn[index], length(m1[index]));
for i := 0 to High(m1[Index]) do
▲ cIn[index][i] := m1[index][i];
cOut := cholesky(cIn);
printM(cOut);
writeln;
setlength(cIn, length(m2), length(m2));
for index := low(m2) to high(m2) do
begin
cIn[index] := m2[index];▼
SetLength(cIn[index], length(m2[Index]));
for i := 0 to High(m2[Index]) do
▲ cIn[index][i] := m2[index][i];
end;
cOut := cholesky(cIn);
printM(cOut);
end.</lang>
{{out}}
|