1package body Complex_P is
2
3 function "+"(A : in Complex) return Complex is
4 begin
5 return A;
6 end "+";
7
8 function "+"(A,
9 B : in Complex) return Complex is
10 begin
11 return(A.R + B.R, A.I + B.I);
12 end "+";
13
14 function "-"(A : in Complex) return Complex is
15 begin
16 return(-A.R, -A.I);
17 end "-";
18
19 function "-"(A,
20 B : in Complex) return Complex is
21 begin
22 return(A.R - B.R, A.I - B.I);
23 end "-";
24
25 function "*"(A,
26 B : in Complex) return Complex is
27 begin
28 return(A.R*B.R - A.I*B.I, A.R*B.I + A.I*B.R);
29 end "*";
30
31 function "/"(A,
32 B : in Complex) return Complex is
33 D : Float := B.R**2 + B.I**2;
34 begin
35 return((A.R*B.R + A.I*B.I)/D, (A.I*B.R - A.R*B.I)/D);
36 end "/";
37
38 function Construct(R,
39 I : Float) return Complex is
40 begin
41 return(R, I);
42 end Construct;
43
44 function Real_Part(A : in Complex) return Float is
45 begin
46 return A.R;
47 end Real_Part;
48
49 function Imaginary_Part(A : in Complex) return Float is
50 begin
51 return A.I;
52 end Imaginary_Part;
53
54end Complex_P;