procedure TMatriks.Button5Click(Sender: TObject);
var
mat1: array[0..2,0..2] of real;
mat2: array[0..2,0..2] of real;
i,j:integer;
begin
with stringgrid1 do
for i:= 0 to 2 do
for j:= 0 to 2 do
mat1 [j,i]:=strtofloat(cells[i,j]);
for i:= 0 to 2 do
for j:= 0 to 2 do
mat2 [j,i]:=mat1 [i,j];
with stringgrid3 do
for i:= 0 to 2 do
for j:= 0 to 2 do
cells [i,j]:= floattostr (mat2[j,i]);
end;
procedure TMatriks.Button3Click(Sender: TObject);
var
mat1: array[0..2,0..2] of real;
mat3: array[0..2,0..2] of real;
i,j:integer;
k: real;
begin
k:=strtofloat(edit1.Text);
with stringgrid1 do
for i:= 0 to 2 do
for j:= 0 to 2 do
mat1 [j,i]:=strtofloat(cells[i,j]);
with stringgrid3 do
for i:= 0 to 2 do
for j:= 0 to 2 do
mat3 [j,i]:=k*mat1[j,i];
with stringgrid3 do
for i:= 0 to 2 do
for j:= 0 to 2 do
cells [i,j]:= floattostr (mat3[j,i]);
end;
procedure TMatriks.Button1Click(Sender: TObject);
var
mat1: array[0..2,0..2] of real;
mat2: array[0..2,0..2] of real;
mat3: array[0..2,0..2] of real;
i,j:integer;
begin
with stringgrid1 do
for i:= 0 to 2 do
for j:= 0 to 2 do
mat1 [j,i]:=strtofloat(cells[i,j]);
with stringgrid2 do
for i:= 0 to 2 do
for j:= 0 to 2 do
mat2 [j,i]:=strtofloat(cells[i,j]);
for i:= 0 to 2 do
for j:= 0 to 2 do
mat3[j,i]:=mat1[j,i]+mat2[j,i];
with stringgrid3 do
for i:= 0 to 2 do
for j:= 0 to 2 do
cells [i,j]:= floattostr (mat3[j,i]);
end;
procedure TMatriks.Button2Click(Sender: TObject);
var
mat1: array[0..2,0..2] of real;
mat2: array[0..2,0..2] of real;
mat3: array[0..2,0..2] of real;
i,j:integer;
begin
with stringgrid1 do
for i:= 0 to 2 do
for j:= 0 to 2 do
mat1 [j,i]:=strtofloat(cells[i,j]);
with stringgrid2 do
for i:= 0 to 2 do
for j:= 0 to 2 do
mat2 [j,i]:=strtofloat(cells[i,j]);
for i:= 0 to 2 do
for j:= 0 to 2 do
mat3[j,i]:=mat1[j,i]-mat2[j,i];
with stringgrid3 do
for i:= 0 to 2 do
for j:= 0 to 2 do
cells [i,j]:= floattostr (mat3[j,i]);
end;
procedure TMatriks.Button6Click(Sender: TObject);
var
mat1: array[0..2,0..2] of real;
mat3: array[0..2,0..2] of real;
mat4: array[0..2,0..2] of real;
i,j:integer;
d:real;
begin
with stringgrid1 do
for i:= 0 to 2 do
for j:= 0 to 2 do
mat1 [j,i]:=strtofloat(cells[i,j]);
for i:= 0 to 2 do
for j:= 0 to 2 do
//determinan
d:= 1 /(((mat1[0,0]*mat1[1,1]*mat1[2,2])+(mat1[0,1]*mat1[1,2]*mat1[2,0])+(mat1[0,2]*mat1[1,0]*mat1[2,1]))-((mat1[0,2]*mat1[1,1]*mat1[2,0])+(mat1[0,0]*mat1[1,2]*mat1[2,1])+(mat1[0,1]*mat1[1,0]*mat1[2,2])));
//minor kofaktor
mat3 [0,0]:=(mat1[1,1]*mat1[2,2])-(mat1[1,2]*mat1[2,1]);
mat3 [1,0]:=(-1) *((mat1[1,0]*mat1[2,2])-(mat1[1,2]*mat1[2,0]));
mat3 [2,0]:=(mat1[1,0]*mat1[2,1])-(mat1[1,1]*mat1[2,0]);
mat3 [0,1]:=(-1)*((mat1[0,1]*mat1[2,2])-(mat1[0,2]*mat1[2,1]));
mat3 [1,1]:=(mat1[0,0]*mat1[2,2])-(mat1[0,2]*mat1[2,0]);
mat3 [2,1]:=(-1)*((mat1[0,0]*mat1[2,1])-(mat1[0,1]*mat1[2,0]));
mat3 [0,2]:=(mat1[0,1]*mat1[1,2])-(mat1[0,2]*mat1[1,1]);
mat3 [1,2]:=(-1)*((mat1[0,0]*mat1[1,2])-(mat1[0,2]*mat1[1,0]));
mat3 [2,2]:=(mat1[0,0]*mat1[1,1])-(mat1[0,1]*mat1[1,0]);
for i:= 0 to 2 do
for j:= 0 to 2 do
mat4 [j,i]:=d*mat3[j,i];
with stringgrid3 do
for i:= 0 to 2 do
for j:= 0 to 2 do
cells [i,j]:= floattostr(mat4[j,i]);
end;
procedure TMatriks.Button7Click(Sender: TObject);
var
i:integer;
begin
edit1.Text:=' ';
for i:= 0 to stringgrid1.ColCount-1 do
stringgrid1.cols[i].clear;
for i:= 0 to stringgrid2.ColCount-1 do
stringgrid2.cols[i].clear;
for i:= 0 to stringgrid3.ColCount-1 do
stringgrid3.cols[i].clear;
end;
procedure TMatriks.Button4Click(Sender: TObject);
Var
mat1: array[0..2,0..2] of real;
mat2: array[0..2,0..2] of real;
mat3: array[0..2,0..2] of real;
mat4: array[0..2,0..2] of real;
i,j:integer;
begin
with stringgrid1 do
for i:= 0 to 2 do
for j:= 0 to 2 do
mat1 [j,i]:=strtofloat(cells[i,j]);
with stringgrid2 do
for i:= 0 to 2 do
for j:= 0 to 2 do
mat2 [j,i]:=strtofloat(cells[i,j]);
with stringgrid3 do
for i:= 0 to 2 do
for j:= 0 to 2 do
mat3 [0,0]:=(mat1[0,0]*mat2[0,0])+(mat1[0,1]*mat2[1,0])+(mat1[0,2]*mat2[2,0]);
mat3 [0,1]:=(mat1[0,0]*mat2[0,1])+(mat1[0,1]*mat2[1,1])+(mat1[0,2]*mat2[2,1]);
mat3 [0,2]:=(mat1[0,0]*mat2[0,2])+(mat1[0,1]*mat2[1,2])+(mat1[0,2]*mat2[2,2]);
mat3 [1,0]:=(mat1[1,0]*mat2[0,0])+(mat1[1,1]*mat2[1,0])+(mat1[1,2]*mat2[2,0]);
mat3 [1,1]:=(mat1[1,0]*mat2[0,1])+(mat1[1,1]*mat2[1,1])+(mat1[1,2]*mat2[2,1]);
mat3 [1,2]:=(mat1[1,0]*mat2[0,2])+(mat1[1,1]*mat2[1,2])+(mat1[1,2]*mat2[2,2]);
mat3 [2,0]:=(mat1[2,0]*mat2[0,0])+(mat1[2,1]*mat2[1,0])+(mat1[2,2]*mat2[2,0]);
mat3 [2,1]:=(mat1[2,0]*mat2[0,1])+(mat1[2,1]*mat2[1,1])+(mat1[2,2]*mat2[2,1]);
mat3 [2,2]:=(mat1[2,0]*mat2[0,2])+(mat1[2,1]*mat2[1,2])+(mat1[2,2]*mat2[2,2]);
for i:= 0 to 2 do
for j:= 0 to 2 do
mat4 [j,i]:=mat3[j,i];
with stringgrid3 do
for i:= 0 to 2 do
for j:= 0 to 2 do
cells [i,j]:= floattostr(mat4[j,i]);
end;
procedure TMatriks.Button8Click(Sender: TObject);
begin
MainMenu.Show;
Matriks.Hide;
end;
procedure TMatriks.Timer1Timer(Sender: TObject);
begin
label1.Left:=label1.Left-30;
if label1.Left<=-150 then
label1.Left := 600;
end;
end.
Sabtu, 19 November 2016
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar