2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / ada / acats / support / fc70a00.a
blobe903a13ade37cbeaa96817393134d1f314e3eaa4
1 -- FC70A00.A
2 --
3 -- Grant of Unlimited Rights
4 --
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
14 -- to do so.
16 -- DISCLAIMER
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
24 --*
26 -- FOUNDATION DESCRIPTION:
27 -- This file simulates a generic complex integer support package, to be
28 -- used for tests covering generic formal packages.
30 -- CHANGE HISTORY:
31 -- 06 Dec 94 SAIC ACVC 2.0
33 --!
35 generic -- Complex integer abstraction.
36 type Int_Type is range <>;
37 package FC70A00 is
39 -- Simulate a generic complex integer support package. Complex integers
40 -- are treated as coordinates in the Cartesian plane.
43 type Complex_Type is private;
45 Zero : constant Complex_Type; -- (0,0).
46 One : constant Complex_Type; -- (1,0).
49 function "-" (Right : Complex_Type) -- Invert a complex
50 return Complex_Type; -- integer.
52 function "+" (Left, Right : Complex_Type) -- Add two complex
53 return Complex_Type; -- integers.
55 function "*" (Left, Right : Complex_Type) -- Multiply two complex
56 return Complex_Type; -- integers.
58 function Reciprocal (Right : Complex_Type) -- Return the reciprocal
59 return Complex_Type; -- of a complex integer.
61 function Complex (Real, Imag : Int_Type) -- Create a complex
62 return Complex_Type; -- integer.
64 private
66 type Complex_Type is record
67 Real : Int_Type;
68 Imag : Int_Type;
69 end record;
71 Zero : constant Complex_Type := (Real => 0, Imag => 0);
72 One : constant Complex_Type := (Real => 1, Imag => 0);
74 end FC70A00;
77 --==================================================================--
80 package body FC70A00 is -- Complex integer abstraction.
82 function Complex (Real, Imag : Int_Type) return Complex_Type is
83 begin
84 return ( (Real, Imag) );
85 end Complex;
87 --==============================================--
89 function "-" (Right : Complex_Type) return Complex_Type is
90 begin
91 return ( (-Right.Real, -Right.Imag) );
92 end "-";
94 --==============================================--
96 function "+" (Left, Right : Complex_Type) return Complex_Type is
97 begin
98 return ( (Left.Real + Right.Real, Left.Imag + Right.Imag) );
99 end "+";
101 --==============================================--
103 function "*" (Left, Right : Complex_Type) return Complex_Type is
104 begin
105 return ( (Real => (Left.Real * Right.Real) - (Left.Imag * Right.Imag),
106 Imag => (Left.Imag * Right.Real) + (Left.Real * Right.Imag)) );
107 end "*";
109 --==============================================--
111 function Reciprocal (Right : Complex_Type) return Complex_Type is
112 Denominator : Int_Type := Right.Real**2 + Right.Imag**2;
113 begin -- NOTE: Results are truncated.
114 return ( (Right.Real/Denominator, -Right.Imag/Denominator) );
115 end Reciprocal;
117 end FC70A00;