| 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. |
| 15 |
-- |
| 16 |
-- DISCLAIMER |
| 17 |
-- |
| 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 |
--* |
| 25 |
-- |
| 26 |
-- FOUNDATION DESCRIPTION: |
| 27 |
-- This file simulates a generic complex integer support package, to be |
| 28 |
-- used for tests covering generic formal packages. |
| 29 |
-- |
| 30 |
-- CHANGE HISTORY: |
| 31 |
-- 06 Dec 94 SAIC ACVC 2.0 |
| 32 |
-- |
| 33 |
--! |
| 34 |
|
| 35 |
generic -- Complex integer abstraction. |
| 36 |
type Int_Type is range <>; |
| 37 |
package FC70A00 is |
| 38 |
|
| 39 |
-- Simulate a generic complex integer support package. Complex integers |
| 40 |
-- are treated as coordinates in the Cartesian plane. |
| 41 |
|
| 42 |
|
| 43 |
type Complex_Type is private; |
| 44 |
|
| 45 |
Zero : constant Complex_Type; -- (0,0). |
| 46 |
One : constant Complex_Type; -- (1,0). |
| 47 |
|
| 48 |
|
| 49 |
function "-" (Right : Complex_Type) -- Invert a complex |
| 50 |
return Complex_Type; -- integer. |
| 51 |
|
| 52 |
function "+" (Left, Right : Complex_Type) -- Add two complex |
| 53 |
return Complex_Type; -- integers. |
| 54 |
|
| 55 |
function "*" (Left, Right : Complex_Type) -- Multiply two complex |
| 56 |
return Complex_Type; -- integers. |
| 57 |
|
| 58 |
function Reciprocal (Right : Complex_Type) -- Return the reciprocal |
| 59 |
return Complex_Type; -- of a complex integer. |
| 60 |
|
| 61 |
function Complex (Real, Imag : Int_Type) -- Create a complex |
| 62 |
return Complex_Type; -- integer. |
| 63 |
|
| 64 |
private |
| 65 |
|
| 66 |
type Complex_Type is record |
| 67 |
Real : Int_Type; |
| 68 |
Imag : Int_Type; |
| 69 |
end record; |
| 70 |
|
| 71 |
Zero : constant Complex_Type := (Real => 0, Imag => 0); |
| 72 |
One : constant Complex_Type := (Real => 1, Imag => 0); |
| 73 |
|
| 74 |
end FC70A00; |
| 75 |
|
| 76 |
|
| 77 |
--==================================================================-- |
| 78 |
|
| 79 |
|
| 80 |
package body FC70A00 is -- Complex integer abstraction. |
| 81 |
|
| 82 |
function Complex (Real, Imag : Int_Type) return Complex_Type is |
| 83 |
begin |
| 84 |
return ( (Real, Imag) ); |
| 85 |
end Complex; |
| 86 |
|
| 87 |
--==============================================-- |
| 88 |
|
| 89 |
function "-" (Right : Complex_Type) return Complex_Type is |
| 90 |
begin |
| 91 |
return ( (-Right.Real, -Right.Imag) ); |
| 92 |
end "-"; |
| 93 |
|
| 94 |
--==============================================-- |
| 95 |
|
| 96 |
function "+" (Left, Right : Complex_Type) return Complex_Type is |
| 97 |
begin |
| 98 |
return ( (Left.Real + Right.Real, Left.Imag + Right.Imag) ); |
| 99 |
end "+"; |
| 100 |
|
| 101 |
--==============================================-- |
| 102 |
|
| 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 "*"; |
| 108 |
|
| 109 |
--==============================================-- |
| 110 |
|
| 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; |
| 116 |
|
| 117 |
end FC70A00; |