1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . N U M E R I C S . G E N E R I C _ C O M P L E X _ T Y P E S --
10 -- Copyright (C) 1992-1997 Free Software Foundation, Inc. --
12 -- This specification is derived from the Ada Reference Manual for use with --
13 -- GNAT. The copyright notice above, and the license provisions that follow --
14 -- apply solely to the contents of the part following the private keyword. --
16 -- GNAT is free software; you can redistribute it and/or modify it under --
17 -- terms of the GNU General Public License as published by the Free Soft- --
18 -- ware Foundation; either version 2, or (at your option) any later ver- --
19 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
20 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
21 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
22 -- for more details. You should have received a copy of the GNU General --
23 -- Public License distributed with GNAT; see file COPYING. If not, write --
24 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
25 -- MA 02111-1307, USA. --
27 -- As a special exception, if other files instantiate generics from this --
28 -- unit, or you link this unit with other files to produce an executable, --
29 -- this unit does not by itself cause the resulting executable to be --
30 -- covered by the GNU General Public License. This exception does not --
31 -- however invalidate any other reasons why the executable file might be --
32 -- covered by the GNU Public License. --
34 -- GNAT was originally developed by the GNAT team at New York University. --
35 -- Extensive contributions were provided by Ada Core Technologies Inc. --
37 ------------------------------------------------------------------------------
40 type Real
is digits <>;
42 package Ada
.Numerics
.Generic_Complex_Types
is
44 pragma Pure
(Generic_Complex_Types
);
46 type Complex
is record
50 pragma Complex_Representation
(Complex
);
52 type Imaginary
is private;
54 i
: constant Imaginary
;
55 j
: constant Imaginary
;
57 function Re
(X
: Complex
) return Real
'Base;
58 function Im
(X
: Complex
) return Real
'Base;
59 function Im
(X
: Imaginary
) return Real
'Base;
61 procedure Set_Re
(X
: in out Complex
; Re
: in Real
'Base);
62 procedure Set_Im
(X
: in out Complex
; Im
: in Real
'Base);
63 procedure Set_Im
(X
: out Imaginary
; Im
: in Real
'Base);
65 function Compose_From_Cartesian
(Re
, Im
: Real
'Base) return Complex
;
66 function Compose_From_Cartesian
(Re
: Real
'Base) return Complex
;
67 function Compose_From_Cartesian
(Im
: Imaginary
) return Complex
;
69 function Modulus
(X
: Complex
) return Real
'Base;
70 function "abs" (Right
: Complex
) return Real
'Base renames Modulus
;
72 function Argument
(X
: Complex
) return Real
'Base;
73 function Argument
(X
: Complex
; Cycle
: Real
'Base) return Real
'Base;
75 function Compose_From_Polar
(
76 Modulus
, Argument
: Real
'Base)
79 function Compose_From_Polar
(
80 Modulus
, Argument
, Cycle
: Real
'Base)
83 function "+" (Right
: Complex
) return Complex
;
84 function "-" (Right
: Complex
) return Complex
;
85 function Conjugate
(X
: Complex
) return Complex
;
87 function "+" (Left
, Right
: Complex
) return Complex
;
88 function "-" (Left
, Right
: Complex
) return Complex
;
89 function "*" (Left
, Right
: Complex
) return Complex
;
90 function "/" (Left
, Right
: Complex
) return Complex
;
92 function "**" (Left
: Complex
; Right
: Integer) return Complex
;
94 function "+" (Right
: Imaginary
) return Imaginary
;
95 function "-" (Right
: Imaginary
) return Imaginary
;
96 function Conjugate
(X
: Imaginary
) return Imaginary
renames "-";
97 function "abs" (Right
: Imaginary
) return Real
'Base;
99 function "+" (Left
, Right
: Imaginary
) return Imaginary
;
100 function "-" (Left
, Right
: Imaginary
) return Imaginary
;
101 function "*" (Left
, Right
: Imaginary
) return Real
'Base;
102 function "/" (Left
, Right
: Imaginary
) return Real
'Base;
104 function "**" (Left
: Imaginary
; Right
: Integer) return Complex
;
106 function "<" (Left
, Right
: Imaginary
) return Boolean;
107 function "<=" (Left
, Right
: Imaginary
) return Boolean;
108 function ">" (Left
, Right
: Imaginary
) return Boolean;
109 function ">=" (Left
, Right
: Imaginary
) return Boolean;
111 function "+" (Left
: Complex
; Right
: Real
'Base) return Complex
;
112 function "+" (Left
: Real
'Base; Right
: Complex
) return Complex
;
113 function "-" (Left
: Complex
; Right
: Real
'Base) return Complex
;
114 function "-" (Left
: Real
'Base; Right
: Complex
) return Complex
;
115 function "*" (Left
: Complex
; Right
: Real
'Base) return Complex
;
116 function "*" (Left
: Real
'Base; Right
: Complex
) return Complex
;
117 function "/" (Left
: Complex
; Right
: Real
'Base) return Complex
;
118 function "/" (Left
: Real
'Base; Right
: Complex
) return Complex
;
120 function "+" (Left
: Complex
; Right
: Imaginary
) return Complex
;
121 function "+" (Left
: Imaginary
; Right
: Complex
) return Complex
;
122 function "-" (Left
: Complex
; Right
: Imaginary
) return Complex
;
123 function "-" (Left
: Imaginary
; Right
: Complex
) return Complex
;
124 function "*" (Left
: Complex
; Right
: Imaginary
) return Complex
;
125 function "*" (Left
: Imaginary
; Right
: Complex
) return Complex
;
126 function "/" (Left
: Complex
; Right
: Imaginary
) return Complex
;
127 function "/" (Left
: Imaginary
; Right
: Complex
) return Complex
;
129 function "+" (Left
: Imaginary
; Right
: Real
'Base) return Complex
;
130 function "+" (Left
: Real
'Base; Right
: Imaginary
) return Complex
;
131 function "-" (Left
: Imaginary
; Right
: Real
'Base) return Complex
;
132 function "-" (Left
: Real
'Base; Right
: Imaginary
) return Complex
;
134 function "*" (Left
: Imaginary
; Right
: Real
'Base) return Imaginary
;
135 function "*" (Left
: Real
'Base; Right
: Imaginary
) return Imaginary
;
136 function "/" (Left
: Imaginary
; Right
: Real
'Base) return Imaginary
;
137 function "/" (Left
: Real
'Base; Right
: Imaginary
) return Imaginary
;
140 type Imaginary
is new Real
'Base;
142 i
: constant Imaginary
:= 1.0;
143 j
: constant Imaginary
:= 1.0;
149 pragma Inline
("<=");
151 pragma Inline
(">=");
152 pragma Inline
("abs");
153 pragma Inline
(Compose_From_Cartesian
);
154 pragma Inline
(Conjugate
);
157 pragma Inline
(Set_Im
);
158 pragma Inline
(Set_Re
);
160 end Ada
.Numerics
.Generic_Complex_Types
;