-
Notifications
You must be signed in to change notification settings - Fork 1
/
CplxMtrxI.pas
114 lines (105 loc) · 3.58 KB
/
CplxMtrxI.pas
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
unit CplxMtrxI;
interface
uses
IntervalArithmetic32and64;
type
complexI = record
re, im : interval
end;
cplxvectorI = array of complexI;
cplxmatrixI = array of array of complexI;
procedure complexmatrixI (n : Integer;
var a : cplxmatrixI;
var x : cplxvectorI;
var st : Integer);
implementation
procedure complexmatrixI (n : Integer;
var a : cplxmatrixI;
var x : cplxvectorI;
var st : Integer);
var i,ih,j,k,n1 : Integer;
d, m : interval;
aa,b,c : complexI;
alb : Boolean;
begin
if n<1
then st:=1
else begin
st:=0;
k:=0;
repeat
k:=k+1;
d:=int_read('0');
for i:=k to n do
begin
b.re:=iabs(a[i,k].re)+iabs(a[i,k].im);
if b.re>d
then begin
d:=b.re;
ih:=i
end
end;
if d=int_read('0')
then st:=2
else begin
aa:=a[ih,k];
alb:=iabs(aa.re)<iabs(aa.im);
if alb
then begin
b.re:=aa.re;
aa.re:=aa.im;
aa.im:=b.re
end;
b.re:=aa.im/aa.re;
aa.im:=int_read('1')/(b.re*aa.im+aa.re);
aa.re:=aa.im*b.re;
if not alb
then begin
b.re:=aa.re;
aa.re:=aa.im;
aa.im:=b.re
end;
a[ih,k]:=a[k,k];
n1:=n+1;
for j:=k+1 to n1 do
begin
c:=a[ih,j];
if d<(iabs(c.re)+iabs(c.im))*int_read('1e-16')
then st:=2
else begin
a[ih,j]:=a[k,j];
b.re:=c.im*aa.im+c.re*aa.re;
b.im:=c.im*aa.re-c.re*aa.im;
a[k,j]:=b;
for i:=k+1 to n do
begin
c:=a[i,k];
a[i,j].re:=a[i,j].re-c.re*b.re
+c.im*b.im;
a[i,j].im:=a[i,j].im-c.re*b.im
-c.im*b.re
end
end
end
end
until (k=n) or (st=2);
if st=0
then begin
x[n]:=a[n,n1];
for i:=n-1 downto 1 do
begin
aa:=a[i,n1];
for j:=i+1 to n do
begin
b:=a[j,n1];
c:=a[i,j];
aa.re:=aa.re-c.re*b.re+c.im*b.im;
aa.im:=aa.im-c.re*b.im-c.im*b.re
end;
a[i,n1]:=aa;
x[i]:=aa
end
end
end
end;
end.