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 --
9 -- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
11 -- This specification is derived from the Ada Reference Manual for use with --
12 -- GNAT. The copyright notice above, and the license provisions that follow --
13 -- apply solely to the contents of the part following the private keyword. --
15 -- GNAT is free software; you can redistribute it and/or modify it under --
16 -- terms of the GNU General Public License as published by the Free Soft- --
17 -- ware Foundation; either version 2, or (at your option) any later ver- --
18 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
19 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
20 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
21 -- for more details. You should have received a copy of the GNU General --
22 -- Public License distributed with GNAT; see file COPYING. If not, write --
23 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
24 -- Boston, MA 02110-1301, USA. --
26 -- As a special exception, if other files instantiate generics from this --
27 -- unit, or you link this unit with other files to produce an executable, --
28 -- this unit does not by itself cause the resulting executable to be --
29 -- covered by the GNU General Public License. This exception does not --
30 -- however invalidate any other reasons why the executable file might be --
31 -- covered by the GNU Public License. --
33 -- GNAT was originally developed by the GNAT team at New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc. --
36 ------------------------------------------------------------------------------
39 type Real
is digits <>;
41 package Ada
.Numerics
.Generic_Complex_Types
is
44 type Complex
is record
48 pragma Complex_Representation
(Complex
);
50 type Imaginary
is private;
52 i
: constant Imaginary
;
53 j
: constant Imaginary
;
55 function Re
(X
: Complex
) return Real
'Base;
56 function Im
(X
: Complex
) return Real
'Base;
57 function Im
(X
: Imaginary
) return Real
'Base;
59 procedure Set_Re
(X
: in out Complex
; Re
: in Real
'Base);
60 procedure Set_Im
(X
: in out Complex
; Im
: in Real
'Base);
61 procedure Set_Im
(X
: out Imaginary
; Im
: in Real
'Base);
63 function Compose_From_Cartesian
(Re
, Im
: Real
'Base) return Complex
;
64 function Compose_From_Cartesian
(Re
: Real
'Base) return Complex
;
65 function Compose_From_Cartesian
(Im
: Imaginary
) return Complex
;
67 function Modulus
(X
: Complex
) return Real
'Base;
68 function "abs" (Right
: Complex
) return Real
'Base renames Modulus
;
70 function Argument
(X
: Complex
) return Real
'Base;
71 function Argument
(X
: Complex
; Cycle
: Real
'Base) return Real
'Base;
73 function Compose_From_Polar
(
74 Modulus
, Argument
: Real
'Base)
77 function Compose_From_Polar
(
78 Modulus
, Argument
, Cycle
: Real
'Base)
81 function "+" (Right
: Complex
) return Complex
;
82 function "-" (Right
: Complex
) return Complex
;
83 function Conjugate
(X
: Complex
) return Complex
;
85 function "+" (Left
, Right
: Complex
) return Complex
;
86 function "-" (Left
, Right
: Complex
) return Complex
;
87 function "*" (Left
, Right
: Complex
) return Complex
;
88 function "/" (Left
, Right
: Complex
) return Complex
;
90 function "**" (Left
: Complex
; Right
: Integer) return Complex
;
92 function "+" (Right
: Imaginary
) return Imaginary
;
93 function "-" (Right
: Imaginary
) return Imaginary
;
94 function Conjugate
(X
: Imaginary
) return Imaginary
renames "-";
95 function "abs" (Right
: Imaginary
) return Real
'Base;
97 function "+" (Left
, Right
: Imaginary
) return Imaginary
;
98 function "-" (Left
, Right
: Imaginary
) return Imaginary
;
99 function "*" (Left
, Right
: Imaginary
) return Real
'Base;
100 function "/" (Left
, Right
: Imaginary
) return Real
'Base;
102 function "**" (Left
: Imaginary
; Right
: Integer) return Complex
;
104 function "<" (Left
, Right
: Imaginary
) return Boolean;
105 function "<=" (Left
, Right
: Imaginary
) return Boolean;
106 function ">" (Left
, Right
: Imaginary
) return Boolean;
107 function ">=" (Left
, Right
: Imaginary
) return Boolean;
109 function "+" (Left
: Complex
; Right
: Real
'Base) return Complex
;
110 function "+" (Left
: Real
'Base; Right
: Complex
) return Complex
;
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
;
118 function "+" (Left
: Complex
; Right
: Imaginary
) return Complex
;
119 function "+" (Left
: Imaginary
; 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
;
127 function "+" (Left
: Imaginary
; Right
: Real
'Base) return Complex
;
128 function "+" (Left
: Real
'Base; Right
: Imaginary
) return Complex
;
129 function "-" (Left
: Imaginary
; Right
: Real
'Base) return Complex
;
130 function "-" (Left
: Real
'Base; Right
: Imaginary
) return Complex
;
132 function "*" (Left
: Imaginary
; Right
: Real
'Base) return Imaginary
;
133 function "*" (Left
: Real
'Base; Right
: Imaginary
) return Imaginary
;
134 function "/" (Left
: Imaginary
; Right
: Real
'Base) return Imaginary
;
135 function "/" (Left
: Real
'Base; Right
: Imaginary
) return Imaginary
;
138 type Imaginary
is new Real
'Base;
140 i
: constant Imaginary
:= 1.0;
141 j
: constant Imaginary
:= 1.0;
147 pragma Inline
("<=");
149 pragma Inline
(">=");
150 pragma Inline
("abs");
151 pragma Inline
(Compose_From_Cartesian
);
152 pragma Inline
(Conjugate
);
155 pragma Inline
(Set_Im
);
156 pragma Inline
(Set_Re
);
158 end Ada
.Numerics
.Generic_Complex_Types
;