OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxg/] [cxg1002.a] - Blame information for rev 720

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- CXG1002.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
-- OBJECTIVE:
27
--      Check that the subprograms defined in the package
28
--      Ada.Numerics.Generic_Complex_Types provide the prescribed results.
29
--      Specifically, check the various versions of functions "+" and "-".
30
--
31
-- TEST DESCRIPTION:
32
--      This test checks that the subprograms "+" and "-" defined in the
33
--      Generic_Complex_Types package provide the results prescribed for the
34
--      evaluation of these complex arithmetic operations.  The functions
35
--      Re and Im are used to extract the appropriate component of the
36
--      complex result, in order that the prescribed result component can be
37
--      verified.
38
--      The generic package is instantiated with a real type (new Float),
39
--      and the results produced by the specified subprograms are verified.
40
--
41
-- SPECIAL REQUIREMENTS:
42
--      This test can be run in either "relaxed" or "strict" mode.
43
--
44
--
45
-- CHANGE HISTORY:
46
--      06 Dec 94   SAIC    ACVC 2.0
47
--
48
--!
49
 
50
with Ada.Numerics.Generic_Complex_Types;
51
with Report;
52
 
53
procedure CXG1002 is
54
 
55
begin
56
 
57
   Report.Test ("CXG1002", "Check that the subprograms defined in " &
58
                           "the package Ada.Numerics.Generic_Complex_Types " &
59
                           "provide the prescribed results");
60
 
61
   Test_Block:
62
   declare
63
 
64
      type Real_Type is new Float;
65
 
66
      package Complex_Pack is new
67
        Ada.Numerics.Generic_Complex_Types(Real_Type);
68
      use Complex_Pack;
69
 
70
      -- Declare a zero valued complex number using the record
71
      -- aggregate approach.
72
 
73
      Complex_Zero : constant Complex_Pack.Complex := (0.0, 0.0);
74
 
75
      TC_Complex,
76
      TC_Complex_Right,
77
      TC_Complex_Left   : Complex_Pack.Complex := Complex_Zero;
78
 
79
      TC_Real           : Real_Type := 0.0;
80
 
81
      TC_Imaginary      : Complex_Pack.Imaginary;
82
 
83
   begin
84
 
85
 
86
      -- Check that the imaginary component of the result of a binary addition
87
      -- operator that yields a result of complex type is exact when either
88
      -- of its operands is of pure-real type.
89
 
90
      TC_Complex := Compose_From_Cartesian(2.0, 3.0);
91
      TC_Real    := 3.0;
92
 
93
      if Im("+"(Left => TC_Complex, Right => TC_Real))  /=  3.0 or
94
         Im("+"(TC_Complex, 6.0))                       /=  3.0 or
95
         Im(TC_Complex + TC_Real)                       /=  3.0 or
96
         Im(TC_Complex + 5.0)                           /=  3.0 or
97
         Im((7.0, 2.0) + 1.0)                           /=  2.0 or
98
         Im((7.0, 5.0) + (-2.0))                        /=  5.0 or
99
         Im((-7.0, -2.0) + 1.0)                         /= -2.0 or
100
         Im((-7.0, -3.0) + (-3.0))                      /= -3.0
101
      then
102
         Report.Failed("Incorrect results from Function ""+"" with " &
103
                       "one Complex and one Real argument - 1");
104
      end if;
105
 
106
      if Im("+"(Left => TC_Real, Right => TC_Complex))  /=   3.0  or
107
         Im("+"(4.0, TC_Complex))                       /=   3.0  or
108
         Im(TC_Real + TC_Complex)                       /=   3.0  or
109
         Im(9.0 + TC_Complex)                           /=   3.0  or
110
         Im(1.0 + (7.0, -9.0))                          /=  -9.0  or
111
         Im((-2.0) + (7.0, 2.0))                        /=   2.0  or
112
         Im(1.0 + (-7.0, -5.0))                         /=  -5.0  or
113
         Im((-3.0) + (-7.0, 16.0))                      /=  16.0
114
      then
115
         Report.Failed("Incorrect results from Function ""+"" with " &
116
                       "one Complex and one Real argument - 2");
117
      end if;
118
 
119
 
120
      -- Check that the imaginary component of the result of a binary
121
      -- subtraction operator that yields a result of complex type is exact
122
      -- when its right operand is of pure-real type.
123
 
124
      TC_Complex := (8.0, -4.0);
125
      TC_Real    := 2.0;
126
 
127
      if Im("-"(Left => TC_Complex, Right => TC_Real))  /=  -4.0  or
128
         Im("-"(TC_Complex, 5.0))                       /=  -4.0  or
129
         Im(TC_Complex - TC_Real)                       /=  -4.0  or
130
         Im(TC_Complex - 4.0)                           /=  -4.0  or
131
         Im((6.0, 5.0) - 1.0)                           /=   5.0  or
132
         Im((6.0, 13.0) - 7.0)                          /=  13.0  or
133
         Im((-5.0, 3.0) - (2.0))                        /=   3.0  or
134
         Im((-5.0, -6.0) - (-3.0))                      /=  -6.0
135
      then
136
         Report.Failed("Incorrect results from Function ""-"" with " &
137
                       "one Complex and one Real argument");
138
      end if;
139
 
140
 
141
      -- Check that the real component of the result of a binary addition
142
      -- operator that yields a result of complex type is exact when either
143
      -- of its operands is of pure-imaginary type.
144
 
145
      TC_Complex := (5.0, 0.0);
146
 
147
      if Re("+"(Left => TC_Complex, Right => i))  /=   5.0 or
148
         Re("+"(Complex_Pack.j, TC_Complex))      /=   5.0 or
149
         Re((-8.0,  5.0) + ( 2.0*i))              /=  -8.0 or
150
         Re((2.0,  5.0) + (-2.0*i))               /=   2.0 or
151
         Re((-20.0, -5.0) + ( 3.0*i))             /= -20.0 or
152
         Re((6.0, -5.0) + (-3.0*i))               /=   6.0
153
      then
154
         Report.Failed("Incorrect results from Function ""+"" with " &
155
                       "one Complex and one Imaginary argument");
156
      end if;
157
 
158
 
159
      -- Check that the real component of the result of a binary
160
      -- subtraction operator that yields a result of complex type is exact
161
      -- when its right operand is of pure-imaginary type.
162
 
163
      TC_Complex := TC_Complex + i;    -- Should produce (5.0, 1.0)
164
 
165
      if Re("-"(TC_Complex, i))                   /=  5.0 or
166
         Re((-4.0,  4.0) - ( 2.0*i))              /= -4.0 or
167
         Re((9.0,  4.0) - ( 5.0*i))               /=  9.0 or
168
         Re((16.0, -5.0) - ( 3.0*i))              /= 16.0 or
169
         Re((-3.0, -5.0) - (-4.0*i))              /= -3.0
170
      then
171
         Report.Failed("Incorrect results from Function ""-"" with " &
172
                       "one Complex and one Imaginary argument");
173
      end if;
174
 
175
 
176
      -- Check that the result of a binary addition operation is exact when
177
      -- one of its operands is of real type and the other is of
178
      -- pure-imaginary type; the operator is analogous to the
179
      -- Compose_From_Cartesian function; it performs no arithmetic.
180
 
181
      TC_Complex := Complex_Pack."+"(5.0, Complex_Pack.i);
182
 
183
      if TC_Complex                   /= (5.0, 1.0) or
184
         (4.0 + i)                    /= (4.0, 1.0) or
185
         "+"(Left => j, Right => 3.0) /= (3.0, 1.0)
186
      then
187
         Report.Failed("Incorrect results from Function ""+"" with " &
188
                       "one Real and one Imaginary argument");
189
      end if;
190
 
191
 
192
   exception
193
      when others => Report.Failed ("Exception raised in Test_Block");
194
   end Test_Block;
195
 
196
   Report.Result;
197
 
198
end CXG1002;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.