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 --
11 -- Copyright (C) 1992-1997 Free Software Foundation, Inc. --
13 -- This specification is derived from the Ada Reference Manual for use with --
14 -- GNAT. The copyright notice above, and the license provisions that follow --
15 -- apply solely to the contents of the part following the private keyword. --
17 -- GNAT is free software; you can redistribute it and/or modify it under --
18 -- terms of the GNU General Public License as published by the Free Soft- --
19 -- ware Foundation; either version 2, or (at your option) any later ver- --
20 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
21 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
22 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
23 -- for more details. You should have received a copy of the GNU General --
24 -- Public License distributed with GNAT; see file COPYING. If not, write --
25 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
26 -- MA 02111-1307, USA. --
28 -- As a special exception, if other files instantiate generics from this --
29 -- unit, or you link this unit with other files to produce an executable, --
30 -- this unit does not by itself cause the resulting executable to be --
31 -- covered by the GNU General Public License. This exception does not --
32 -- however invalidate any other reasons why the executable file might be --
33 -- covered by the GNU Public License. --
35 -- GNAT was originally developed by the GNAT team at New York University. --
36 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
38 ------------------------------------------------------------------------------
41 type Real
is digits <>;
43 package Ada
.Numerics
.Generic_Complex_Types
is
45 pragma Pure
(Generic_Complex_Types
);
47 type Complex
is record
51 pragma Complex_Representation
(Complex
);
53 type Imaginary
is private;
55 i
: constant Imaginary
;
56 j
: constant Imaginary
;
58 function Re
(X
: Complex
) return Real
'Base;
59 function Im
(X
: Complex
) return Real
'Base;
60 function Im
(X
: Imaginary
) return Real
'Base;
62 procedure Set_Re
(X
: in out Complex
; Re
: in Real
'Base);
63 procedure Set_Im
(X
: in out Complex
; Im
: in Real
'Base);
64 procedure Set_Im
(X
: out Imaginary
; Im
: in Real
'Base);
66 function Compose_From_Cartesian
(Re
, Im
: Real
'Base) return Complex
;
67 function Compose_From_Cartesian
(Re
: Real
'Base) return Complex
;
68 function Compose_From_Cartesian
(Im
: Imaginary
) return Complex
;
70 function Modulus
(X
: Complex
) return Real
'Base;
71 function "abs" (Right
: Complex
) return Real
'Base renames Modulus
;
73 function Argument
(X
: Complex
) return Real
'Base;
74 function Argument
(X
: Complex
; Cycle
: Real
'Base) return Real
'Base;
76 function Compose_From_Polar
(
77 Modulus
, Argument
: Real
'Base)
80 function Compose_From_Polar
(
81 Modulus
, Argument
, Cycle
: Real
'Base)
84 function "+" (Right
: Complex
) return Complex
;
85 function "-" (Right
: Complex
) return Complex
;
86 function Conjugate
(X
: Complex
) return Complex
;
88 function "+" (Left
, Right
: Complex
) return Complex
;
89 function "-" (Left
, Right
: Complex
) return Complex
;
90 function "*" (Left
, Right
: Complex
) return Complex
;
91 function "/" (Left
, Right
: Complex
) return Complex
;
93 function "**" (Left
: Complex
; Right
: Integer) return Complex
;
95 function "+" (Right
: Imaginary
) return Imaginary
;
96 function "-" (Right
: Imaginary
) return Imaginary
;
97 function Conjugate
(X
: Imaginary
) return Imaginary
renames "-";
98 function "abs" (Right
: Imaginary
) return Real
'Base;
100 function "+" (Left
, Right
: Imaginary
) return Imaginary
;
101 function "-" (Left
, Right
: Imaginary
) return Imaginary
;
102 function "*" (Left
, Right
: Imaginary
) return Real
'Base;
103 function "/" (Left
, Right
: Imaginary
) return Real
'Base;
105 function "**" (Left
: Imaginary
; Right
: Integer) return Complex
;
107 function "<" (Left
, Right
: Imaginary
) return Boolean;
108 function "<=" (Left
, Right
: Imaginary
) return Boolean;
109 function ">" (Left
, Right
: Imaginary
) return Boolean;
110 function ">=" (Left
, Right
: Imaginary
) return Boolean;
112 function "+" (Left
: Complex
; Right
: Real
'Base) return Complex
;
113 function "+" (Left
: Real
'Base; Right
: Complex
) return Complex
;
114 function "-" (Left
: Complex
; Right
: Real
'Base) return Complex
;
115 function "-" (Left
: Real
'Base; Right
: Complex
) return Complex
;
116 function "*" (Left
: Complex
; Right
: Real
'Base) return Complex
;
117 function "*" (Left
: Real
'Base; Right
: Complex
) return Complex
;
118 function "/" (Left
: Complex
; Right
: Real
'Base) return Complex
;
119 function "/" (Left
: Real
'Base; Right
: Complex
) return Complex
;
121 function "+" (Left
: Complex
; Right
: Imaginary
) return Complex
;
122 function "+" (Left
: Imaginary
; Right
: Complex
) return Complex
;
123 function "-" (Left
: Complex
; Right
: Imaginary
) return Complex
;
124 function "-" (Left
: Imaginary
; Right
: Complex
) return Complex
;
125 function "*" (Left
: Complex
; Right
: Imaginary
) return Complex
;
126 function "*" (Left
: Imaginary
; Right
: Complex
) return Complex
;
127 function "/" (Left
: Complex
; Right
: Imaginary
) return Complex
;
128 function "/" (Left
: Imaginary
; Right
: Complex
) return Complex
;
130 function "+" (Left
: Imaginary
; Right
: Real
'Base) return Complex
;
131 function "+" (Left
: Real
'Base; Right
: Imaginary
) return Complex
;
132 function "-" (Left
: Imaginary
; Right
: Real
'Base) return Complex
;
133 function "-" (Left
: Real
'Base; Right
: Imaginary
) return Complex
;
135 function "*" (Left
: Imaginary
; Right
: Real
'Base) return Imaginary
;
136 function "*" (Left
: Real
'Base; Right
: Imaginary
) return Imaginary
;
137 function "/" (Left
: Imaginary
; Right
: Real
'Base) return Imaginary
;
138 function "/" (Left
: Real
'Base; Right
: Imaginary
) return Imaginary
;
141 type Imaginary
is new Real
'Base;
143 i
: constant Imaginary
:= 1.0;
144 j
: constant Imaginary
:= 1.0;
150 pragma Inline
("<=");
152 pragma Inline
(">=");
153 pragma Inline
("abs");
154 pragma Inline
(Compose_From_Cartesian
);
155 pragma Inline
(Conjugate
);
158 pragma Inline
(Set_Im
);
159 pragma Inline
(Set_Re
);
161 end Ada
.Numerics
.Generic_Complex_Types
;