unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,unit1, Forms, Dialogs;
procedure CHOBSB(A:MATRX2; N:integer; D:array of real;var B:array of real);
procedure CHODCM(A:matrx2; N:integer;var D:array of real; T:array of real);
implementation
procedure CHOBSB(A:MATRX2; N:integer; D:array of real;var B:array of real);
var
I,J:integer; SUM:real;
begin
For I:=1 To N do
begin
Sum:=B[I];
For J:=1 To I - 1 do
Sum:=Sum - A[I, J] * B[J];
B[I]:=Sum;
end;
For I:=N DownTo 1 do
begin
If D[I] = 0 Then
begin
ShowMessage('Singular Matrix');
Exit;
end
Else
Sum:=B[I] / D[I];
For J:=I + 1 To N do
Sum:=Sum - A[J, I] * B[J];
B[I]:=Sum;
end;
end;
procedure CHODCM(A:matrx2; N:integer;var D:array of real; T:array of real);
var
I,J,K:integer; SUM:real;
begin
For I:=1 To N do
begin
Sum:=A[I, I];
For J:=1 To I - 1 do
begin
T[J]:=A[J, I];
For K:=1 To J - 1 do
T[J]:=T[J] - T[K] * A[J, K];
If D[J] = 0 Then
begin
If T[J] 0 Then
ShowMessage('No Cholesky decomposition')
Else
A[I, J]:=1;
end
Else
A[I, J]:=T[J] / D[J];
Sum:=Sum - T[J] * A[I, J];
end;
D[I]:=Sum;
end;
end;
end.