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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- CXA5A07.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 function Arctan provides correct results.
28
--
29
-- TEST DESCRIPTION:
30
--      This test examines both the version of Arctan resulting from the
31
--      instantiation of the Ada.Numerics.Generic_Elementary_Functions with
32
--      a type derived from type Float, as well as the preinstantiated
33
--      version of this package for type Float.
34
--      Prescribed results, including instances prescribed to raise
35
--      exceptions, are examined in the test cases.  In addition,
36
--      certain evaluations are performed where the actual function result
37
--      is compared with the expected result (within an epsilon range of
38
--      accuracy).
39
--
40
-- TEST FILES:
41
--      The following files comprise this test:
42
--
43
--         FXA5A00.A   (foundation code)
44
--         CXA5A07.A
45
--
46
--
47
-- CHANGE HISTORY:
48
--      04 Apr 95   SAIC    Initial prerelease version.
49
--      13 Jun 95   SAIC    Incorporated use of Dont_Optimize procedure, and
50
--                          use of Result_Within_Range function overloaded for
51
--                          FXA5A00.New_Float_Type.
52
--      28 Feb 97   PWB.CTA Removed checks with explicit Cycle => 2.0*Pi
53
--
54
-- CHANGE NOTE:
55
--      According to Ken Dritz, author of the Numerics Annex of the RM,
56
--      one should never specify the cycle 2.0*Pi for the trigonometric
57
--      functions.  In particular, if the machine number for the first
58
--      argument is not an exact multiple of the machine number for the
59
--      explicit cycle, then the specified exact results cannot be
60
--      reasonably expected.  The affected checks in this test have been
61
--      marked as comments, with the additional notation "pwb-math".
62
--      Phil Brashear
63
--!
64
 
65
with Ada.Numerics.Elementary_Functions;
66
with Ada.Numerics.Generic_Elementary_Functions;
67
with FXA5A00;
68
with Report;
69
 
70
procedure CXA5A07 is
71
begin
72
 
73
   Report.Test ("CXA5A07", "Check that the Arctan function provides " &
74
                           "correct results");
75
 
76
   Test_Block:
77
   declare
78
 
79
      use Ada.Numerics;
80
      use FXA5A00;
81
 
82
      package GEF is new Ada.Numerics.Generic_Elementary_Functions(New_Float);
83
      package  EF renames Ada.Numerics.Elementary_Functions;
84
 
85
      Float_Result     : Float;
86
      New_Float_Result : New_Float;
87
 
88
      procedure Dont_Optimize_Float     is new Dont_Optimize(Float);
89
      procedure Dont_Optimize_New_Float is new Dont_Optimize(New_Float);
90
 
91
   begin
92
 
93
      -- Testing of Arctan Function, both instantiated and pre-instantiated
94
      -- version.
95
 
96
      -- Check that Argument_Error is raised by the Arctan function when
97
      -- provided parameter values of 0.0, 0.0.
98
 
99
      begin
100
         New_Float_Result := GEF.Arctan(Y => 0.0, X => 0.0);
101
         Report.Failed("Argument_Error not raised when the Arctan " &
102
                       "function is provided input of 0.0, 0.0");
103
         Dont_Optimize_New_Float(New_Float_Result, 1);
104
      exception
105
         when Argument_Error => null;  -- OK, expected exception.
106
         when others         =>
107
            Report.Failed("Incorrect exception raised by the Arctan " &
108
                          "function when provided 0.0, 0.0 input parameters");
109
      end;
110
 
111
 
112
      -- Check that no exception is raised by the Arctan function when
113
      -- provided a large positive or negative Y parameter value, when
114
      -- using the default value for parameter X.
115
 
116
      begin
117
         Float_Result := EF.Arctan(Y => FXA5A00.Large);
118
         Dont_Optimize_Float(Float_Result, 2);
119
      exception
120
         when others =>
121
            Report.Failed("Exception raised when the Arctan function is " &
122
                          "provided a large positive Y parameter value");
123
      end;
124
 
125
      begin
126
         New_Float_Result := GEF.Arctan(Y => New_Float(-FXA5A00.Large));
127
         Dont_Optimize_New_Float(New_Float_Result, 3);
128
      exception
129
         when others =>
130
            Report.Failed("Exception raised when the Arctan function is " &
131
                          "provided a large negative Y parameter value");
132
      end;
133
 
134
 
135
      -- Check that no exception is raised by the Arctan function when
136
      -- provided a small positive or negative Y parameter value, when
137
      -- using the default value for parameter X.
138
 
139
      begin
140
         Float_Result := EF.Arctan(Y => FXA5A00.Small);
141
         Dont_Optimize_Float(Float_Result, 4);
142
      exception
143
         when others =>
144
            Report.Failed("Exception raised when the Arctan function is " &
145
                          "provided a small positive Y parameter value");
146
      end;
147
 
148
      begin
149
         New_Float_Result := GEF.Arctan(Y => New_Float(-FXA5A00.Small));
150
         Dont_Optimize_New_Float(New_Float_Result, 5);
151
      exception
152
         when others =>
153
            Report.Failed("Exception raised when the Arctan function is " &
154
                          "provided a small negative Y parameter value");
155
      end;
156
 
157
 
158
      -- Check that no exception is raised by the Arctan function when
159
      -- provided combinations of large and small positive or negative
160
      -- parameter values for both Y and X input parameters.
161
 
162
      begin
163
         Float_Result := EF.Arctan(Y => FXA5A00.Large, X => FXA5A00.Large);
164
         Dont_Optimize_Float(Float_Result, 6);
165
      exception
166
         when others =>
167
            Report.Failed("Exception raised when the Arctan function is " &
168
                          "provided large positive X and Y parameter values");
169
      end;
170
 
171
      begin
172
         New_Float_Result := GEF.Arctan(New_Float(-FXA5A00.Large),
173
                                        X => New_Float(FXA5A00.Small));
174
         Dont_Optimize_New_Float(New_Float_Result, 7);
175
      exception
176
         when others =>
177
            Report.Failed("Exception raised when the Arctan function is " &
178
                          "provided a large negative Y parameter value "  &
179
                          "and a small positive X parameter value");
180
      end;
181
 
182
 
183
      begin
184
         Float_Result := EF.Arctan(Y => FXA5A00.Small, X => FXA5A00.Large);
185
         Dont_Optimize_Float(Float_Result, 8);
186
      exception
187
         when others =>
188
            Report.Failed("Exception raised when the Arctan function is " &
189
                          "provided a small positive Y parameter value "  &
190
                          "and a large positive X parameter value");
191
      end;
192
 
193
      begin
194
         New_Float_Result := GEF.Arctan(New_Float(-FXA5A00.Small),
195
                                        New_Float(-FXA5A00.Large));
196
         Dont_Optimize_New_Float(New_Float_Result, 9);
197
      exception
198
         when others =>
199
            Report.Failed("Exception raised when the Arctan function is " &
200
                          "provided a small negative Y parameter value "  &
201
                          "and a large negative parameter value");
202
      end;
203
 
204
 
205
      -- Check that when the Arctan function is provided a Y parameter value
206
      -- of 0.0 and a positive X parameter input value, the prescribed result
207
      -- of zero is returned.
208
 
209
      if GEF.Arctan(Y => 0.0)                     /= 0.0 or -- Default X value
210
          EF.Arctan(Y => 0.0, X => FXA5A00.Large) /= 0.0 or
211
--pwb-math: Next line: changed 2.0*Pi to 360.0
212
         GEF.Arctan(0.0, 360.0)                  /= 0.0 or
213
          EF.Arctan(0.0, FXA5A00.Small)           /= 0.0
214
      then
215
         Report.Failed("Incorrect results from the Arctan function when " &
216
                       "provided a Y parameter value of 0.0 and various " &
217
                       "positive X parameter values");
218
      end if;
219
 
220
 
221
      -- Check that the Arctan function provides correct results when provided
222
      -- a variety of Y parameter values.
223
 
224
      if not FXA5A00.Result_Within_Range(EF.Arctan(Pi),    1.26,  0.01)  or
225
         not FXA5A00.Result_Within_Range(EF.Arctan(-Pi),  -1.26,  0.01)  or
226
         not FXA5A00.Result_Within_Range(GEF.Arctan(1.0),  0.785, 0.001) or
227
         not FXA5A00.Result_Within_Range(EF.Arctan(-1.0), -0.785, 0.001) or
228
         not FXA5A00.Result_Within_Range(GEF.Arctan(0.25), 0.245, 0.001) or
229
         not FXA5A00.Result_Within_Range(EF.Arctan(0.92),  0.744, 0.001)
230
      then
231
         Report.Failed("Incorrect results from the Arctan function when " &
232
                       "provided a variety of Y parameter values");
233
      end if;
234
 
235
 
236
 
237
      -- Check the results of the Arctan function with specified cycle
238
      -- parameter.
239
 
240
      -- Check that the Arctan function with specified Cycle parameter
241
      -- raises Argument_Error when the value of the Cycle parameter is zero
242
      -- or negative.
243
 
244
      begin
245
         Float_Result := EF.Arctan(Y => Pi, Cycle => 0.0);  -- Default X value
246
         Report.Failed("Argument_Error not raised by the Arctan function " &
247
                       "with default X parameter value, when the Cycle "   &
248
                       "parameter is 0.0");
249
         Dont_Optimize_Float(Float_Result, 10);
250
      exception
251
         when Argument_Error => null;  -- OK, expected exception.
252
         when others         =>
253
            Report.Failed("Incorrect exception raised by the Arctan "      &
254
                          "function with default X parameter value, when " &
255
                          "provided a 0.0 cycle parameter value");
256
      end;
257
 
258
      begin
259
         New_Float_Result := GEF.Arctan(Y => Pi, X => 1.0, Cycle => 0.0);
260
         Report.Failed("Argument_Error not raised by the Arctan function " &
261
                       "when the Cycle parameter is 0.0");
262
         Dont_Optimize_New_Float(New_Float_Result, 11);
263
      exception
264
         when Argument_Error => null;  -- OK, expected exception.
265
         when others         =>
266
            Report.Failed("Incorrect exception raised by the Arctan "     &
267
                          "function when provided a 0.0 cycle parameter " &
268
                          "value");
269
      end;
270
 
271
      begin
272
         Float_Result := EF.Arctan(Y => Pi, Cycle => -360.0);
273
         Report.Failed("Argument_Error not raised by the Arctan function " &
274
                       "with a default X parameter value, when the Cycle " &
275
                       "parameter is -360.0");
276
         Dont_Optimize_Float(Float_Result, 12);
277
      exception
278
         when Argument_Error => null;  -- OK, expected exception.
279
         when others         =>
280
            Report.Failed("Incorrect exception raised by the Arctan "        &
281
                          "function with a default X parameter value, when " &
282
                          "provided a -360.0 cycle parameter value");
283
      end;
284
 
285
      begin
286
         New_Float_Result := GEF.Arctan(Y => Pi, X => 1.0, Cycle => -Pi);
287
         Report.Failed("Argument_Error not raised by the Arctan function " &
288
                       "when the Cycle parameter is -Pi");
289
         Dont_Optimize_New_Float(New_Float_Result, 13);
290
      exception
291
         when Argument_Error => null;  -- OK, expected exception.
292
         when others         =>
293
            Report.Failed("Incorrect exception raised by the Arctan "     &
294
                          "function when provided a -Pi cycle parameter " &
295
                          "value");
296
      end;
297
 
298
 
299
      -- Check that no exception is raised by the Arctan function with
300
      -- specified Cycle parameter, when provided large and small positive
301
      -- or negative parameter values for both Y and X input parameters.
302
 
303
      begin
304
         Float_Result := EF.Arctan(Y     => -FXA5A00.Large,
305
                                   X     => -FXA5A00.Large,
306
--pwb-math: Next line: changed 2.0*Pi to 360.0
307
                                   Cycle => 360.0);
308
         Dont_Optimize_Float(Float_Result, 14);
309
      exception
310
         when others =>
311
            Report.Failed("Exception raised when the Arctan function with " &
312
                          "specified Cycle parameter, when provided large " &
313
                          "negative X and Y parameter values");
314
      end;
315
 
316
 
317
      begin
318
         New_Float_Result := GEF.Arctan(New_Float(FXA5A00.Large),
319
                                        X     => New_Float(-FXA5A00.Small),
320
--pwb-math: Next line: changed 2.0*Pi to 360.0
321
                                        Cycle => 360.0);
322
         Dont_Optimize_New_Float(New_Float_Result, 15);
323
      exception
324
         when others =>
325
            Report.Failed("Exception raised when the Arctan function with "  &
326
                          "specified Cycle parameter, when provided large "  &
327
                          "positive Y parameter value and a small negative " &
328
                          "X parameter value");
329
      end;
330
 
331
 
332
      begin
333
         Float_Result := EF.Arctan(Y     => -FXA5A00.Small,
334
                                   X     => -FXA5A00.Large,
335
--pwb-math: Next line: changed 2.0*Pi to 360.0
336
                                   Cycle => 360.0);
337
         Dont_Optimize_Float(Float_Result, 16);
338
      exception
339
         when others =>
340
            Report.Failed("Exception raised when the Arctan function with "  &
341
                          "specified Cycle parameter, when provided large "  &
342
                          "negative Y parameter value and a large negative " &
343
                          "X parameter value");
344
      end;
345
 
346
      begin
347
         New_Float_Result := GEF.Arctan(New_Float(FXA5A00.Small),
348
                                        New_Float(FXA5A00.Large),
349
--pwb-math: Next line: changed 2.0*Pi to 360.0
350
                                        360.0);
351
         Dont_Optimize_New_Float(New_Float_Result, 17);
352
      exception
353
         when others =>
354
            Report.Failed("Exception raised when the Arctan function with " &
355
                          "specified Cycle parameter, when provided a "     &
356
                          "small negative Y parameter value and a large "   &
357
                          "positive X parameter value");
358
      end;
359
 
360
 
361
      -- Check that the Arctan function with specified Cycle parameter
362
      -- provides correct results when provided a variety of Y parameter
363
      -- input values.
364
 
365
--pwb-math      if not FXA5A00.Result_Within_Range(EF.Arctan(Pi,    Cycle => 2.0*Pi),
366
--pwb-math                                         1.26,
367
--pwb-math                                         0.01)                            or
368
--pwb-math         not FXA5A00.Result_Within_Range(EF.Arctan(-Pi,   Cycle => 2.0*Pi),
369
--pwb-math                                         -1.26,
370
--pwb-math                                         0.01)                            or
371
--pwb-math         not FXA5A00.Result_Within_Range(GEF.Arctan(1.0,  Cycle => 2.0*Pi),
372
--pwb-math                                         0.785,
373
--pwb-math                                         0.001)                           or
374
--pwb-math         not FXA5A00.Result_Within_Range(EF.Arctan(-1.0,  Cycle => 2.0*Pi),
375
--pwb-math                                         -0.785,
376
--pwb-math                                         0.001)                           or
377
--pwb-math         not FXA5A00.Result_Within_Range(GEF.Arctan(0.16, Cycle => 2.0*Pi),
378
--pwb-math                                         0.159,
379
--pwb-math                                         0.001)                           or
380
--pwb-math         not FXA5A00.Result_Within_Range(EF.Arctan(1.0,   Cycle => 360.0),
381
--pwb-math                                         45.0,
382
--pwb-math                                         0.1)                             or
383
--pwb-math         not FXA5A00.Result_Within_Range(GEF.Arctan(1.0,  Cycle => 100.0),
384
--pwb-math                                         12.5,
385
--pwb-math                                         0.1)
386
 
387
--pwb-math  Next 12 lines are replacements for 21 commented lines above
388
      if not FXA5A00.Result_Within_Range(GEF.Arctan(1.0,  Cycle => 2.0*180.0),
389
                                         45.0,
390
                                         0.001)                           or
391
         not FXA5A00.Result_Within_Range(EF.Arctan(-1.0,  Cycle => 2.0*180.0),
392
                                         -45.0,
393
                                         0.001)                           or
394
         not FXA5A00.Result_Within_Range(EF.Arctan(1.0,   Cycle => 360.0),
395
                                         45.0,
396
                                         0.1)                             or
397
         not FXA5A00.Result_Within_Range(GEF.Arctan(1.0,  Cycle => 100.0),
398
                                         12.5,
399
                                         0.1)
400
      then
401
         Report.Failed("Incorrect results from the Arctan function with "   &
402
                       "specified Cycle parameter when provided a variety " &
403
                       "of Y parameter values");
404
      end if;
405
 
406
 
407
   exception
408
      when others => Report.Failed ("Exception raised in Test_Block");
409
   end Test_Block;
410
 
411
   Report.Result;
412
 
413
end CXA5A07;

powered by: WebSVN 2.1.0

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