111
|
1 ------------------------------------------------------------------------------
|
|
2 -- --
|
|
3 -- GNAT RUN-TIME COMPONENTS --
|
|
4 -- --
|
|
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 --
|
|
6 -- --
|
|
7 -- S p e c --
|
|
8 -- --
|
|
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
|
|
10 -- --
|
|
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. --
|
|
14 -- --
|
|
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 3, 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. --
|
|
21 -- --
|
|
22 -- As a special exception under Section 7 of GPL version 3, you are granted --
|
|
23 -- additional permissions described in the GCC Runtime Library Exception, --
|
|
24 -- version 3.1, as published by the Free Software Foundation. --
|
|
25 -- --
|
|
26 -- You should have received a copy of the GNU General Public License and --
|
|
27 -- a copy of the GCC Runtime Library Exception along with this program; --
|
|
28 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
|
|
29 -- <http://www.gnu.org/licenses/>. --
|
|
30 -- --
|
|
31 -- GNAT was originally developed by the GNAT team at New York University. --
|
|
32 -- Extensive contributions were provided by Ada Core Technologies Inc. --
|
|
33 -- --
|
|
34 ------------------------------------------------------------------------------
|
|
35
|
|
36 generic
|
|
37 type Real is digits <>;
|
|
38
|
|
39 package Ada.Numerics.Generic_Complex_Types is
|
|
40 pragma Pure;
|
|
41
|
|
42 type Complex is record
|
|
43 Re, Im : Real'Base;
|
|
44 end record;
|
|
45
|
|
46 pragma Complex_Representation (Complex);
|
|
47
|
|
48 type Imaginary is private;
|
|
49 pragma Preelaborable_Initialization (Imaginary);
|
|
50
|
|
51 i : constant Imaginary;
|
|
52 j : constant Imaginary;
|
|
53
|
|
54 function Re (X : Complex) return Real'Base;
|
|
55 function Im (X : Complex) return Real'Base;
|
|
56 function Im (X : Imaginary) return Real'Base;
|
|
57
|
|
58 procedure Set_Re (X : in out Complex; Re : Real'Base);
|
|
59 procedure Set_Im (X : in out Complex; Im : Real'Base);
|
|
60 procedure Set_Im (X : out Imaginary; Im : Real'Base);
|
|
61
|
|
62 function Compose_From_Cartesian (Re, Im : Real'Base) return Complex;
|
|
63 function Compose_From_Cartesian (Re : Real'Base) return Complex;
|
|
64 function Compose_From_Cartesian (Im : Imaginary) return Complex;
|
|
65
|
|
66 function Modulus (X : Complex) return Real'Base;
|
|
67 function "abs" (Right : Complex) return Real'Base renames Modulus;
|
|
68
|
|
69 function Argument (X : Complex) return Real'Base;
|
|
70 function Argument (X : Complex; Cycle : Real'Base) return Real'Base;
|
|
71
|
|
72 function Compose_From_Polar (
|
|
73 Modulus, Argument : Real'Base)
|
|
74 return Complex;
|
|
75
|
|
76 function Compose_From_Polar (
|
|
77 Modulus, Argument, Cycle : Real'Base)
|
|
78 return Complex;
|
|
79
|
|
80 function "+" (Right : Complex) return Complex;
|
|
81 function "-" (Right : Complex) return Complex;
|
|
82 function Conjugate (X : Complex) return Complex;
|
|
83
|
|
84 function "+" (Left, Right : 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
|
|
89 function "**" (Left : Complex; Right : Integer) return Complex;
|
|
90
|
|
91 function "+" (Right : Imaginary) return Imaginary;
|
|
92 function "-" (Right : Imaginary) return Imaginary;
|
|
93 function Conjugate (X : Imaginary) return Imaginary renames "-";
|
|
94 function "abs" (Right : Imaginary) return Real'Base;
|
|
95
|
|
96 function "+" (Left, Right : Imaginary) return Imaginary;
|
|
97 function "-" (Left, Right : Imaginary) return Imaginary;
|
|
98 function "*" (Left, Right : Imaginary) return Real'Base;
|
|
99 function "/" (Left, Right : Imaginary) return Real'Base;
|
|
100
|
|
101 function "**" (Left : Imaginary; Right : Integer) return Complex;
|
|
102
|
|
103 function "<" (Left, Right : Imaginary) return Boolean;
|
|
104 function "<=" (Left, Right : Imaginary) return Boolean;
|
|
105 function ">" (Left, Right : Imaginary) return Boolean;
|
|
106 function ">=" (Left, Right : Imaginary) return Boolean;
|
|
107
|
|
108 function "+" (Left : Complex; Right : Real'Base) return Complex;
|
|
109 function "+" (Left : Real'Base; Right : Complex) return Complex;
|
|
110 function "-" (Left : Complex; Right : Real'Base) return Complex;
|
|
111 function "-" (Left : Real'Base; Right : Complex) return Complex;
|
|
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
|
|
117 function "+" (Left : Complex; Right : Imaginary) return Complex;
|
|
118 function "+" (Left : Imaginary; Right : Complex) return Complex;
|
|
119 function "-" (Left : Complex; Right : Imaginary) return Complex;
|
|
120 function "-" (Left : Imaginary; 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
|
|
126 function "+" (Left : Imaginary; Right : Real'Base) return Complex;
|
|
127 function "+" (Left : Real'Base; Right : Imaginary) return Complex;
|
|
128 function "-" (Left : Imaginary; Right : Real'Base) return Complex;
|
|
129 function "-" (Left : Real'Base; Right : Imaginary) return Complex;
|
|
130
|
|
131 function "*" (Left : Imaginary; Right : Real'Base) return Imaginary;
|
|
132 function "*" (Left : Real'Base; Right : Imaginary) return Imaginary;
|
|
133 function "/" (Left : Imaginary; Right : Real'Base) return Imaginary;
|
|
134 function "/" (Left : Real'Base; Right : Imaginary) return Imaginary;
|
|
135
|
|
136 private
|
|
137 type Imaginary is new Real'Base;
|
|
138
|
|
139 i : constant Imaginary := 1.0;
|
|
140 j : constant Imaginary := 1.0;
|
|
141
|
|
142 pragma Inline ("+");
|
|
143 pragma Inline ("-");
|
|
144 pragma Inline ("*");
|
|
145 pragma Inline ("<");
|
|
146 pragma Inline ("<=");
|
|
147 pragma Inline (">");
|
|
148 pragma Inline (">=");
|
|
149 pragma Inline ("abs");
|
|
150 pragma Inline (Compose_From_Cartesian);
|
|
151 pragma Inline (Conjugate);
|
|
152 pragma Inline (Im);
|
|
153 pragma Inline (Re);
|
|
154 pragma Inline (Set_Im);
|
|
155 pragma Inline (Set_Re);
|
|
156
|
|
157 end Ada.Numerics.Generic_Complex_Types;
|