rev_matr function matr_rev matr matr const var integer t1 t2 real ext

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// rev_matr
function matr_rev(a:matr):matr;
const n=3;
var
i,j,k,l :integer;
t1, t2 :real;
ext :array[1..n, 1..n*2] of real;
a1, a2, a3 :matr;
begin
for i:=1 to n do begin
for j:=1 to 2*n do
if j<= n then
ext[i,j]:=a[i,j]
else
ext[i,j]:=0;
ext[i,n+i]:=1;
end;
for i:=1 to n-1 do begin
for j:=i+1 to n do begin
t1:=ext[i,i];t2:=ext[j,i];
for k:=1 to 2*n do begin
ext[j,k]:=ext[j,k]*t1+(-1)*ext[i,k]*t2;
end;
end;
end;
for i:=0 to n-2 do begin
for j:=1 to n-1 do begin
if j<n-i then
begin
t1:=ext[j,j+i+1];t2:=ext[j+i+1,j+i+1];
for k:=1 to 2*n do begin
ext[j,k]:=(-1)*ext[j,k]*t2+ext[j+1+i,k]*t1;
end;
end;
end;
end;
for i:=1 to n do
for j:=1 to n do
matr_rev[i,j]:=ext[i,j+n]/ext[i,i];
end;
// end_ rev_matr