OSDN Git Service

PR c++/27714
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-ngcoty.ads
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-2006, 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 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.                                              --
25 --                                                                          --
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.                                      --
32 --                                                                          --
33 -- GNAT was originally developed  by the GNAT team at  New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
35 --                                                                          --
36 ------------------------------------------------------------------------------
37
38 generic
39    type Real is digits <>;
40
41 package Ada.Numerics.Generic_Complex_Types is
42    pragma Pure;
43
44    type Complex is record
45       Re, Im : Real'Base;
46    end record;
47
48    pragma Complex_Representation (Complex);
49
50    type Imaginary is private;
51
52    i : constant Imaginary;
53    j : constant Imaginary;
54
55    function Re (X : Complex)   return Real'Base;
56    function Im (X : Complex)   return Real'Base;
57    function Im (X : Imaginary) return Real'Base;
58
59    procedure Set_Re (X : in out Complex; Re : Real'Base);
60    procedure Set_Im (X : in out Complex; Im : Real'Base);
61    procedure Set_Im (X : out Imaginary;  Im : Real'Base);
62
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;
66
67    function Modulus (X     : Complex) return Real'Base;
68    function "abs"   (Right : Complex) return Real'Base renames Modulus;
69
70    function Argument (X : Complex)                    return Real'Base;
71    function Argument (X : Complex; Cycle : Real'Base) return Real'Base;
72
73    function Compose_From_Polar (
74      Modulus, Argument : Real'Base)
75      return Complex;
76
77    function Compose_From_Polar (
78      Modulus, Argument, Cycle : Real'Base)
79      return Complex;
80
81    function "+"       (Right : Complex) return Complex;
82    function "-"       (Right : Complex) return Complex;
83    function Conjugate (X     : Complex) return Complex;
84
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;
89
90    function "**"      (Left : Complex; Right : Integer) return Complex;
91
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;
96
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;
101
102    function "**"      (Left : Imaginary; Right : Integer) return Complex;
103
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;
108
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;
117
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;
126
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;
131
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;
136
137 private
138    type Imaginary is new Real'Base;
139
140    i : constant Imaginary := 1.0;
141    j : constant Imaginary := 1.0;
142
143    pragma Inline ("+");
144    pragma Inline ("-");
145    pragma Inline ("*");
146    pragma Inline ("<");
147    pragma Inline ("<=");
148    pragma Inline (">");
149    pragma Inline (">=");
150    pragma Inline ("abs");
151    pragma Inline (Compose_From_Cartesian);
152    pragma Inline (Conjugate);
153    pragma Inline (Im);
154    pragma Inline (Re);
155    pragma Inline (Set_Im);
156    pragma Inline (Set_Re);
157
158 end Ada.Numerics.Generic_Complex_Types;