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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxa/] [cxa5a08.a] - Blame information for rev 294

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- CXA5A08.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 Arccot provides correct results.
28
--
29
-- TEST DESCRIPTION:
30
--      This test examines both the version of Arccot resulting from the
31
--      instantiation of the Ada.Numerics.Generic_Elementary_Functions
32
--      with 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
--         CXA5A08.A
45
--
46
--
47
-- CHANGE HISTORY:
48
--      06 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
--      18 Apr 96   SAIC    Incorporated reviewer comments for ACVC 2.1.
53
--      28 Feb 97   CTA.PWB Removed checks with explicit Cycle => 2.0*Pi
54
--
55
-- CHANGE NOTE:
56
--      According to Ken Dritz, author of the Numerics Annex of the RM,
57
--      one should never specify the cycle 2.0*Pi for the trigonometric
58
--      functions.  In particular, if the machine number for the first
59
--      argument is not an exact multiple of the machine number for the
60
--      explicit cycle, then the specified exact results cannot be
61
--      reasonably expected.  The affected checks in this test have been
62
--      marked as comments, with the additional notation "pwb-math".
63
--      Phil Brashear
64
--!
65
 
66
with Ada.Exceptions;
67
with Ada.Numerics.Elementary_Functions;
68
with Ada.Numerics.Generic_Elementary_Functions;
69
with FXA5A00;
70
with Report;
71
 
72
procedure CXA5A08 is
73
begin
74
 
75
   Report.Test ("CXA5A08", "Check that the Arccot function provides " &
76
                           "correct results");
77
 
78
   Test_Block:
79
   declare
80
 
81
      use Ada.Exceptions;
82
      use Ada.Numerics;
83
      use FXA5A00;
84
 
85
      package GEF is new Ada.Numerics.Generic_Elementary_Functions(New_Float);
86
      package  EF renames Ada.Numerics.Elementary_Functions;
87
 
88
      Float_Result      : Float;
89
      Angle             : Float;
90
      New_Float_Result  : New_Float;
91
      New_Float_Angle   : New_Float;
92
      Incorrect_Inverse : Boolean := False;
93
 
94
      procedure Dont_Optimize_Float     is new Dont_Optimize(Float);
95
      procedure Dont_Optimize_New_Float is new Dont_Optimize(New_Float);
96
 
97
   begin
98
 
99
      -- Testing of Arccot Function, both instantiated and pre-instantiated
100
      -- version.
101
 
102
      -- Check that Argument_Error is raised by the Arccot function when
103
      -- provided parameter values of 0.0, 0.0.
104
 
105
      begin
106
         New_Float_Result := GEF.Arccot(X => 0.0, Y => 0.0);
107
         Report.Failed("Argument_Error not raised when the Arccot " &
108
                       "function is provided input of 0.0, 0.0");
109
         Dont_Optimize_New_Float(New_Float_Result, 1);
110
      exception
111
         when Argument_Error => null;  -- OK, expected exception.
112
         when others         =>
113
            Report.Failed("Incorrect exception raised by the Arccot " &
114
                          "function when provided 0.0, 0.0 input parameters");
115
      end;
116
 
117
 
118
      -- Check that no exception is raised by the Arccot function when
119
      -- provided a large positive or negative X parameter value, when
120
      -- using the default value for parameter Y.
121
 
122
      begin
123
         Float_Result := EF.Arccot(X => FXA5A00.Large);
124
         Dont_Optimize_Float(Float_Result, 2);
125
      exception
126
         when others =>
127
            Report.Failed("Exception raised when the Arccot function is " &
128
                          "provided a large positive X parameter value");
129
      end;
130
 
131
      begin
132
         New_Float_Result := GEF.Arccot(X => New_Float(-FXA5A00.Large));
133
         Dont_Optimize_New_Float(New_Float_Result, 3);
134
      exception
135
         when others =>
136
            Report.Failed("Exception raised when the Arccot function is " &
137
                          "provided a large negative X parameter value");
138
      end;
139
 
140
 
141
      -- Check that no exception is raised by the Arccot function when
142
      -- provided a small positive or negative X parameter value, when
143
      -- using the default value for parameter Y.
144
 
145
      begin
146
         Float_Result := EF.Arccot(X => FXA5A00.Small);
147
         Dont_Optimize_Float(Float_Result, 4);
148
      exception
149
         when others =>
150
            Report.Failed("Exception raised when the Arccot function is " &
151
                          "provided a small positive X parameter value");
152
      end;
153
 
154
      begin
155
         New_Float_Result := GEF.Arccot(X => New_Float(-FXA5A00.Small));
156
         Dont_Optimize_New_Float(New_Float_Result, 5);
157
      exception
158
         when others =>
159
            Report.Failed("Exception raised when the Arccot function is " &
160
                          "provided a small negative X parameter value");
161
      end;
162
 
163
 
164
      -- Check that no exception is raised by the Arccot function when
165
      -- provided combinations of large and small positive or negative
166
      -- parameter values for both X and Y input parameters.
167
 
168
      begin
169
         Float_Result := EF.Arccot(X => FXA5A00.Large, Y => FXA5A00.Large);
170
         Dont_Optimize_Float(Float_Result, 6);
171
      exception
172
         when others =>
173
            Report.Failed("Exception raised when the Arccot function is " &
174
                          "provided large positive X and Y parameter values");
175
      end;
176
 
177
      begin
178
         New_Float_Result := GEF.Arccot(New_Float(-FXA5A00.Large),
179
                                        Y => New_Float(FXA5A00.Small));
180
         Dont_Optimize_New_Float(New_Float_Result, 7);
181
      exception
182
         when others =>
183
            Report.Failed("Exception raised when the Arccot function is " &
184
                          "provided a large negative X parameter value "  &
185
                          "and a small positive Y parameter value");
186
      end;
187
 
188
 
189
      begin
190
         Float_Result := EF.Arccot(X => FXA5A00.Small, Y => FXA5A00.Large);
191
         Dont_Optimize_Float(Float_Result, 8);
192
      exception
193
         when others =>
194
            Report.Failed("Exception raised when the Arccot function is " &
195
                          "provided a small positive X parameter value "  &
196
                          "and a large positive Y parameter value");
197
      end;
198
 
199
      begin
200
         New_Float_Result := GEF.Arccot(New_Float(-FXA5A00.Small),
201
                                        New_Float(-FXA5A00.Large));
202
         Dont_Optimize_New_Float(New_Float_Result, 9);
203
      exception
204
         when others =>
205
            Report.Failed("Exception raised when the Arccot function is " &
206
                          "provided a small negative X parameter value "  &
207
                          "and a large negative Y parameter value");
208
      end;
209
 
210
 
211
      -- Check that when the Arccot function is provided a Y parameter value
212
      -- of 0.0 and a positive X parameter input value, the prescribed result
213
      -- of zero is returned.
214
 
215
      if  EF.Arccot(X => FXA5A00.Large, Y => 0.0)                 /= 0.0 or
216
         GEF.Arccot(2.0*Pi, Y => 0.0)                             /= 0.0 or
217
          EF.Arccot(FXA5A00.Small, 0.0)                           /= 0.0 or
218
          EF.Arccot(X => FXA5A00.Large, Y => 0.0, Cycle => 360.0) /= 0.0 or
219
         GEF.Arccot(2.0*Pi, Y => 0.0, Cycle => 360.0)             /= 0.0 or
220
          EF.Arccot(FXA5A00.Small, 0.0, Cycle => 360.0)           /= 0.0
221
      then
222
         Report.Failed("Incorrect results from the Arccot function when " &
223
                       "provided a Y parameter value of 0.0 and various " &
224
                       "positive X parameter values");
225
      end if;
226
 
227
 
228
      -- Check that the Arccot function provides correct results when
229
      -- provided a variety of X parameter values.
230
 
231
      if not Result_Within_Range( EF.Arccot( 1.0), Pi/4.0, 0.001)     or
232
         not Result_Within_Range(GEF.Arccot( 0.0), Pi/2.0, 0.001)     or
233
         not Result_Within_Range( EF.Arccot(-1.0), 3.0*Pi/4.0, 0.001)
234
      then
235
         Report.Failed("Incorrect results from the Arccot function when " &
236
                       "provided a variety of Y parameter values");
237
      end if;
238
 
239
 
240
      -- Check the results of the Arccot function with specified cycle
241
      -- parameter.
242
 
243
      -- Check that the Arccot function with specified Cycle parameter
244
      -- raises Argument_Error when the value of the Cycle parameter is zero
245
      -- or negative.
246
 
247
      begin
248
         Float_Result := EF.Arccot(X => Pi, Cycle => 0.0);  -- Default Y value
249
         Report.Failed("Argument_Error not raised by the Arccot function " &
250
                       "with default Y parameter value, when the Cycle "   &
251
                       "parameter is 0.0");
252
         Dont_Optimize_Float(Float_Result, 10);
253
      exception
254
         when Argument_Error => null;  -- OK, expected exception.
255
         when others         =>
256
            Report.Failed("Incorrect exception raised by the Arccot "      &
257
                          "function with default Y parameter value, when " &
258
                          "provided a 0.0 cycle parameter value");
259
      end;
260
 
261
      begin
262
         New_Float_Result := GEF.Arccot(X => Pi, Y => 1.0, Cycle => 0.0);
263
         Report.Failed("Argument_Error not raised by the Arccot function " &
264
                       "when the Cycle parameter is 0.0");
265
         Dont_Optimize_New_Float(New_Float_Result, 11);
266
      exception
267
         when Argument_Error => null;  -- OK, expected exception.
268
         when others         =>
269
            Report.Failed("Incorrect exception raised by the Arccot "     &
270
                          "function when provided a 0.0 cycle parameter " &
271
                          "value");
272
      end;
273
 
274
      begin
275
         Float_Result := EF.Arccot(X => Pi, Cycle => -360.0);
276
         Report.Failed("Argument_Error not raised by the Arccot function " &
277
                       "with a default Y parameter value, when the Cycle " &
278
                       "parameter is -360.0");
279
         Dont_Optimize_Float(Float_Result, 12);
280
      exception
281
         when Argument_Error => null;  -- OK, expected exception.
282
         when others         =>
283
            Report.Failed("Incorrect exception raised by the Arccot "        &
284
                          "function with a default Y parameter value, when " &
285
                          "provided a -360.0 cycle parameter value");
286
      end;
287
 
288
      begin
289
         New_Float_Result := GEF.Arccot(X => Pi, Y => 1.0, Cycle => -Pi);
290
         Report.Failed("Argument_Error not raised by the Arccot function " &
291
                       "when the Cycle parameter is -Pi");
292
         Dont_Optimize_New_Float(New_Float_Result, 13);
293
      exception
294
         when Argument_Error => null;  -- OK, expected exception.
295
         when others         =>
296
            Report.Failed("Incorrect exception raised by the Arccot "     &
297
                          "function when provided a -Pi cycle parameter " &
298
                          "value");
299
      end;
300
 
301
 
302
      -- Check that no exception is raised by the Arccot function with
303
      -- specified Cycle parameter, when provided large and small positive
304
      -- or negative parameter values for both X and Y input parameters.
305
 
306
      begin
307
         Float_Result := EF.Arccot(X     => -FXA5A00.Large,
308
                                   Y     => -FXA5A00.Large,
309
--pwb-math  Next line: changed 2.0*Pi to 360.0
310
                                   Cycle => 360.0);
311
         Dont_Optimize_Float(Float_Result, 14);
312
      exception
313
         when others =>
314
            Report.Failed("Exception raised when the Arccot function with " &
315
                          "specified Cycle parameter, when provided large " &
316
                          "negative X and Y parameter values");
317
      end;
318
 
319
 
320
      begin
321
         New_Float_Result := GEF.Arccot(New_Float(FXA5A00.Large),
322
                                        Y     => New_Float(-FXA5A00.Small),
323
--pwb-math  Next line: changed 2.0*Pi to 360.0
324
                                        Cycle => 360.0);
325
         Dont_Optimize_New_Float(New_Float_Result, 15);
326
      exception
327
         when others =>
328
            Report.Failed("Exception raised when the Arccot function with "  &
329
                          "specified Cycle parameter, when provided large "  &
330
                          "positive X parameter value and a small negative " &
331
                          "Y parameter value");
332
      end;
333
 
334
 
335
      begin
336
         Float_Result := EF.Arccot(X     => -FXA5A00.Small,
337
                                   Y     => -FXA5A00.Large,
338
--pwb-math  Next line: changed 2.0*Pi to 360.0
339
                                   Cycle => 360.0);
340
         Dont_Optimize_Float(Float_Result, 16);
341
      exception
342
         when others =>
343
            Report.Failed("Exception raised when the Arccot function with "  &
344
                          "specified Cycle parameter, when provided small "  &
345
                          "negative X parameter value and a large negative " &
346
                          "Y parameter value");
347
      end;
348
 
349
      begin
350
         New_Float_Result := GEF.Arccot(New_Float(FXA5A00.Small),
351
                                        New_Float(FXA5A00.Large),
352
--pwb-math  Next line: changed 2.0*Pi to 360.0
353
                                        360.0);
354
         Dont_Optimize_New_Float(New_Float_Result, 17);
355
      exception
356
         when others =>
357
            Report.Failed("Exception raised when the Arccot function with " &
358
                          "specified Cycle parameter, when provided a "     &
359
                          "small positive X parameter value and a large "   &
360
                          "positive Y parameter value");
361
      end;
362
 
363
 
364
      -- Check that the Arccot function with specified Cycle parameter
365
      -- provides correct results when provided a variety of X parameter
366
      -- input values.
367
 
368
      if not FXA5A00.Result_Within_Range(GEF.Arccot( 0.0, Cycle => 360.0),
369
                                         90.0,
370
                                         0.001) or
371
         not FXA5A00.Result_Within_Range(EF.Arccot( 0.0, Cycle => 100.0),
372
                                         25.0,
373
                                         0.001) or
374
         not FXA5A00.Result_Within_Range(GEF.Arccot( 1.0, Cycle => 360.0),
375
                                         45.0,
376
                                         0.001) or
377
         not FXA5A00.Result_Within_Range(EF.Arccot( 1.0, Cycle => 100.0),
378
                                         12.5,
379
                                         0.001) or
380
         not FXA5A00.Result_Within_Range(GEF.Arccot(-1.0, Cycle => 360.0),
381
                                         135.0,
382
                                         0.001) or
383
         not FXA5A00.Result_Within_Range(EF.Arccot(-1.0, Cycle => 100.0),
384
                                         37.5,
385
                                         0.001)
386
      then
387
         Report.Failed("Incorrect results from the Arccot function with "   &
388
                       "specified Cycle parameter when provided a variety " &
389
                       "of X parameter values");
390
      end if;
391
 
392
 
393
      if not FXA5A00.Result_Within_Range(EF.Arccot(0.2425355, 0.9701420),
394
                                         EF.Arccot(0.25),
395
                                         0.01) or
396
         not FXA5A00.Result_Within_Range(EF.Arccot(0.3162277, 0.9486831),
397
                                         Ef.Arccot(0.33),
398
                                         0.01)
399
      then
400
         Report.Failed("Incorrect results from the Arccot function with " &
401
                       "comparison to other Arccot function results");
402
      end if;
403
 
404
 
405
      if not FXA5A00.Result_Within_Range(EF.Cot(EF.Arccot(0.4472135,
406
                                                          0.8944270)),
407
                                         0.5,
408
                                         0.01) or
409
         not FXA5A00.Result_Within_Range(EF.Cot(EF.Arccot(0.9987380,
410
                                                          0.0499369)),
411
                                         20.0,
412
                                         0.1)
413
      then
414
         Report.Failed("Incorrect results from the Arccot function when " &
415
                       "used as argument to Cot function");
416
      end if;
417
 
418
 
419
      -- Check that inverse function results are correct.
420
      -- Default Cycle test.
421
 
422
      Angle := 0.001;
423
      while Angle < Pi and not Incorrect_Inverse loop
424
         if not Result_Within_Range(EF.Arccot(EF.Cot(Angle)), Angle, 0.001)
425
         then
426
            Incorrect_Inverse := True;
427
         end if;
428
         Angle := Angle + 0.001;
429
      end loop;
430
 
431
      if Incorrect_Inverse then
432
         Report.Failed("Incorrect results returned from the Inverse "    &
433
                       "comparison of Cot and Arccot using the default " &
434
                       "cycle value");
435
         Incorrect_Inverse := False;
436
      end if;
437
 
438
      -- Non-Default Cycle test.
439
 
440
      New_Float_Angle := 0.01;
441
      while New_Float_Angle < 180.0 and not Incorrect_Inverse loop
442
         if not Result_Within_Range(EF.Arccot(EF.Cot(Float(New_Float_Angle),
443
                                                     Cycle => 360.0),
444
                                              Cycle => 360.0),
445
                                    Float(New_Float_Angle),
446
                                    0.01)  or
447
            not Result_Within_Range(GEF.Arccot(
448
                                       New_Float(GEF.Cot(New_Float_Angle,
449
                                                         Cycle => 360.0)),
450
                                       Cycle => 360.0),
451
                                    Float(New_Float_Angle),
452
                                    0.01)
453
         then
454
            Incorrect_Inverse := True;
455
         end if;
456
         New_Float_Angle := New_Float_Angle + 0.01;
457
      end loop;
458
 
459
      if Incorrect_Inverse then
460
         Report.Failed("Incorrect results returned from the Inverse "    &
461
                       "comparison of Cot and Arccot using non-default " &
462
                       "cycle value");
463
      end if;
464
 
465
 
466
   exception
467
      when The_Error : others =>
468
         Report.Failed ("The following exception was raised in the " &
469
                        "Test_Block: " & Exception_Name(The_Error));
470
   end Test_Block;
471
 
472
   Report.Result;
473
 
474
end CXA5A08;

powered by: WebSVN 2.1.0

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