Professional Documents
Culture Documents
para
los
elementos
de
la
superior
diagonal
):
principal,
y:
son los
elementos de la matriz U.
3.- APLICACIN.La descomposicin de Cholesky se usa principalmente para hallar la solucin
numrica de ecuaciones lineales Ax = b. Si A es simtrica y positiva definida,
entonces se puede solucionar Ax = b calculando primero la descomposicin de
Cholesky A = LLT, luego resolviendo Ly = b para y, y finalmente resolviendo LTx =
y pa.
5.- JUSTIFICACIN.-
2).- EJEMPLO.
es decir,
Calculemos
matriz L.
la
DESARROLLO
A.- DIAGRAMACIN.-
end;
a:=2;
b:=2;
While b<=k do
begin
i:=a;
j:=b;
While i<=l do
begin
MB[i,j]:=(MA[i,j]);
m:=1;
While m<j do
begin
MB[i,j]:=MB[i,j]-((MB[i,m])*(MC[m,j]));
m:=m+1;
end;
i:=i+1;
end;
i:=j;
j:=j+1;
While j<=k do
begin
m:=1;
MC[i,j]:=MA[i,j];
While m<i do
begin
MC[i,j]:=MC[i,j]-((MB[i,m])*(MC[m,j]));
m:=m+1;
end;
MC[i,j]:=((1/(MB[i,i]))*((MC[i,j])));
j:=j+1;
end;
b:=b+1;
end;
b:=(b-1);
i:=(b-1);
While i>0 do
begin
V[i]:=MC[i,b];
m:=(i+1);
While m<b do
begin
V[i]:=V[i]-(MC[i,m]*V[m]);
m:=m+1;
end;
i:=i-1;
end;
p:=500; y:=100;
for o:=1 to l do
begin
Canvas.TextOut(p,y,'x'+ inttostr(o)+' es igual a:'+ floattostr( V[o]));
y:=y+20;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
X.Dibujar(100,100,canvas);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Close;
end;
end.
unit UCMatriz;
interface
uses
SysUtils, Dialogs, Graphics;
Const
max=100;
type
CEMMatriz=Class(Exception);
CMatriz=Class
private
M:Array [1..max, 1..max] of integer;
nf:integer;
nc:integer;
public
Constructor Crear(Df,dc:integer);
Function Elemento(f,c:integer):integer;
Function DimensionFila:integer;
Function DimensionColumna:integer;
Procedure Redimensionar(df,dc:integer);
Procedure Poner(f,c, que:integer);
Procedure Mostrar;
Procedure Dibujar(x,y:integer; C:TCanvas);
end;
CEMMatrizC = Class (Exception);
CMatrizC =Class
private
M:Array [1..max, 1..max] of String;
nf:integer;
nc:integer;
public
Constructor Crear(Df,dc:integer);
Function Elemento(f,c:integer):String;
Function DimensionFila:integer;
Function DimensionColumna:integer;
Procedure Redimensionar(df,dc:integer);
Procedure Poner(f,c:integer; que:String);
Procedure Mostrar;
Procedure Dibujar(x,y:integer; C:TCanvas);
end;
implementation
{ CMatriz }
constructor CMatriz.Crear(df,dc: integer);
begin
if (df>0) and (df<=max) then
nf:=df
else
Raise CEMMatriz.Create('CMatriz.Crear: Error fuera de RANGO...');
if (dc>0) and (dc<=max) then
nc:=dc
else
Raise CEMMatriz.Create('CMatriz.Crear: Error fuera de RANGO...');
end;
function CMatriz.DimensionFila: integer;
begin
Result:=nf;
end;
function CMatriz.DimensionColumna: integer;
begin
Result:=nc;
end;
writeln (M[i,j]);
writeln;
end;
j:=j+1;
end;
i:=i+1;
end;
end;
procedure CMatriz.Dibujar(x,y:integer; C:TCanvas);
var
aux,i,j:integer;
begin
aux:=x;
for i:=1 to nf do
begin
for j:=1 to nc do
begin
C.MoveTo(x,y);
C.Rectangle(x,y,x+35,y+35);
C.TextOut(x+5,y+5,inttostr(M[i,j]));
X:=x+34;
end;
x:=aux;
y:=y+34;
end;
end;
{ CMatrizC }
constructor CMatrizC.Crear(Df, dc: integer);
begin
if (df>0) and (df<=max) then
nf:=df
else
Raise CEMMatrizC.Create('CMatrizC.Crear: Error fuera de RANGO...');
if (dc>0) and (dc<=max) then
nc:=dc
else
Raise CEMMatrizC.Create('CMatrizC.Crear: Error fuera de RANGO...');
end;
procedure CMatrizC.Dibujar(x, y: integer; C: TCanvas);
var
aux,i,j:integer;
begin
aux:=x;
for i:=1 to nf do
begin
for j:=1 to nc do
begin
C.MoveTo(x,y);
C.Rectangle(x,y,x+35,y+35);
C.TextOut(x+5,y+5,M[i,j]);
X:=x+34;
end;
x:=aux;
y:=y+34;
end;
end;
function CMatrizC.DimensionColumna: integer;
begin
Result:=nc;
end;
function CMatrizC.DimensionFila: integer;
begin
Result:=nf;
end;
function CMatrizC.Elemento(f, c: integer): String;
begin
if (f>0) and (f<=nf) and (c>0) and (c<=nc) then
Result:=M[f,c]
else
Raise CEMMatrizC.Create('CMatrizC.Elemento: Error fuera de RANGO...');
end;
procedure CMatrizC.Mostrar;
var i,j:integer;
begin
i:=1;
while i<= nc do
begin
j:=1;
while j<= nf do
begin
if j< nf then
begin
write (M[i,j],'
');
end
else
begin
writeln (M[i,j]);
writeln;
end;
j:=j+1;
end;
i:=i+1;
end;
end;
procedure CMatrizC.Poner(f, c: integer; que: String);
begin
if (f>0) and (f<=nf) and (c>0) and (c<=nc) then
M[f,c]:=que
else
Raise CEMMatrizC.Create('CMatrizC.Poner: Error fuera de RANGO...');
end;
procedure CMatrizC.Redimensionar(df, dc: integer);
begin
if (df>0) and (df<=max) then
nf:=df
else
Raise CEMMatrizC.Create('CMatrizC.Redimensionar: Error fuera de RANGO...');
if (dc>0) and (dc<=max) then
nc:=dc
else
Raise CEMMatrizC.Create('CMatrizC.Redimensionar: Error fuera de RANGO...');
end;
end.
4.- Ahora llenamos la matriz con los nmeros que queramos adicionar.
6.- Y por ltimo le damos un clic en el botn resolver por el Mtodo de Cholesky y no va a
mostrar los
resultados de la matriz
CONCLUSIN.