OSDN Git Service

New Language: Ada
[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 --                            $Revision: 1.7 $                              --
10 --                                                                          --
11 --          Copyright (C) 1992-1997 Free Software Foundation, Inc.          --
12 --                                                                          --
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. --
16 --                                                                          --
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.                                                      --
27 --                                                                          --
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.                                      --
34 --                                                                          --
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). --
37 --                                                                          --
38 ------------------------------------------------------------------------------
39
40 generic
41    type Real is digits <>;
42
43 package Ada.Numerics.Generic_Complex_Types is
44
45 pragma Pure (Generic_Complex_Types);
46
47    type Complex is record
48       Re, Im : Real'Base;
49    end record;
50
51    pragma Complex_Representation (Complex);
52
53    type Imaginary is private;
54
55    i : constant Imaginary;
56    j : constant Imaginary;
57
58    function Re (X : Complex)   return Real'Base;
59    function Im (X : Complex)   return Real'Base;
60    function Im (X : Imaginary) return Real'Base;
61
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);
65
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;
69
70    function Modulus (X     : Complex) return Real'Base;
71    function "abs"   (Right : Complex) return Real'Base renames Modulus;
72
73    function Argument (X : Complex)                    return Real'Base;
74    function Argument (X : Complex; Cycle : Real'Base) return Real'Base;
75
76    function Compose_From_Polar (
77      Modulus, Argument : Real'Base)
78      return Complex;
79
80    function Compose_From_Polar (
81      Modulus, Argument, Cycle : Real'Base)
82      return Complex;
83
84    function "+"       (Right : Complex) return Complex;
85    function "-"       (Right : Complex) return Complex;
86    function Conjugate (X     : Complex) return Complex;
87
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;
92
93    function "**"      (Left : Complex; Right : Integer) return Complex;
94
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;
99
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;
104
105    function "**"      (Left : Imaginary; Right : Integer) return Complex;
106
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;
111
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;
120
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;
129
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;
134
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;
139
140 private
141    type Imaginary is new Real'Base;
142
143    i : constant Imaginary := 1.0;
144    j : constant Imaginary := 1.0;
145
146    pragma Inline ("+");
147    pragma Inline ("-");
148    pragma Inline ("*");
149    pragma Inline ("<");
150    pragma Inline ("<=");
151    pragma Inline (">");
152    pragma Inline (">=");
153    pragma Inline ("abs");
154    pragma Inline (Compose_From_Cartesian);
155    pragma Inline (Conjugate);
156    pragma Inline (Im);
157    pragma Inline (Re);
158    pragma Inline (Set_Im);
159    pragma Inline (Set_Re);
160
161 end Ada.Numerics.Generic_Complex_Types;