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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- CXA5A05.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 functions Arcsin and Arcsinh provide correct
28
--      results.
29
--
30
-- TEST DESCRIPTION:
31
--      This test examines both the version of Arcsin and Arcsinh
32
--      the instantiation of the Ada.Numerics.Generic_Elementary_Functions
33
--      with a type derived from type Float, as well as the preinstantiated
34
--      version of this package for type Float.
35
--      Prescribed results, including instances prescribed to raise
36
--      exceptions, are examined in the test cases.  In addition,
37
--      certain evaluations are performed where the actual function result
38
--      is compared with the expected result (within an epsilon range of
39
--      accuracy).
40
--
41
-- TEST FILES:
42
--      The following files comprise this test:
43
--
44
--         FXA5A00.A   (foundation code)
45
--         CXA5A05.A
46
--
47
--
48
-- CHANGE HISTORY:
49
--      20 Mar 95   SAIC    Initial prerelease version.
50
--      06 Apr 95   SAIC    Corrected errors in context clause reference and
51
--                          use of Cycle parameter.
52
--      13 Jun 95   SAIC    Incorporated use of Dont_Optimize procedure, and
53
--                          use of Result_Within_Range function overloaded for
54
--                          FXA5A00.New_Float_Type.
55
--      28 Feb 97   PWB.CTA Removed checks with explict Cycle => 2.0*Pi
56
--
57
-- CHANGE NOTE:
58
--      According to Ken Dritz, author of the Numerics Annex of the RM,
59
--      one should never specify the cycle 2.0*Pi for the trigonometric
60
--      functions.  In particular, if the machine number for the first
61
--      argument is not an exact multiple of the machine number for the
62
--      explicit cycle, then the specified exact results cannot be
63
--      reasonably expected.  The affected checks in this test have been
64
--      marked as comments, with the additional notation "pwb-math".
65
--      Phil Brashear
66
--!
67
 
68
with Ada.Numerics.Elementary_Functions;
69
with Ada.Numerics.Generic_Elementary_Functions;
70
with FXA5A00;
71
with Report;
72
 
73
procedure CXA5A05 is
74
begin
75
 
76
   Report.Test ("CXA5A05", "Check that the functions Arcsin and Arcsinh " &
77
                           "provide correct results");
78
 
79
   Test_Block:
80
   declare
81
 
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
      The_Result       : Float;
89
      New_Float_Result : New_Float;
90
 
91
      procedure Dont_Optimize_Float     is new Dont_Optimize(Float);
92
      procedure Dont_Optimize_New_Float is new Dont_Optimize(New_Float);
93
 
94
   begin
95
 
96
      -- Testing of Function Arcsin, both instantiated and pre-instantiated
97
      -- versions.
98
 
99
      -- Check that Argument_Error is raised by the Arcsin function when
100
      -- the absolute value of the parameter X is greater than 1.0.
101
 
102
      begin
103
         New_Float_Result := GEF.Arcsin(New_Float(FXA5A00.One_Plus_Delta));
104
         Report.Failed("Argument_Error not raised by Arcsin function " &
105
                       "when provided a parameter value larger than 1.0");
106
         Dont_Optimize_New_Float(New_Float_Result, 1);
107
      exception
108
         when Argument_Error => null;  -- OK, expected exception.
109
         when others         =>
110
            Report.Failed("Unexpected exception raised by Arcsin function " &
111
                          "when provided a parameter value larger than 1.0");
112
      end;
113
 
114
      begin
115
         The_Result := EF.Arcsin(FXA5A00.Minus_Large);
116
         Report.Failed("Argument_Error not raised by Arcsin function " &
117
                       "when provided a large negative parameter value");
118
         Dont_Optimize_Float(The_Result, 2);
119
      exception
120
         when Argument_Error => null;  -- OK, expected exception.
121
         when others         =>
122
            Report.Failed("Unexpected exception raised by Arcsin function " &
123
                          "when provided a large negative parameter value");
124
      end;
125
 
126
 
127
      -- Check the prescribed result of function Arcsin with parameter 0.0.
128
 
129
      if GEF.Arcsin(X => 0.0) /= 0.0 or
130
          EF.Arcsin(0.0)      /= 0.0
131
      then
132
         Report.Failed("Incorrect result from Function Arcsin when the " &
133
                       "value of the parameter X is 0.0");
134
      end if;
135
 
136
 
137
      -- Check the results of the Arcsin function with various input
138
      -- parameters.
139
 
140
      if not Result_Within_Range(GEF.Arcsin(1.0),    1.571, 0.001) or
141
         not Result_Within_Range( EF.Arcsin(0.62),   0.669, 0.001) or
142
         not Result_Within_Range(GEF.Arcsin(0.01),   0.010, 0.001) or
143
         not Result_Within_Range( EF.Arcsin(-0.29), -0.294, 0.001) or
144
         not Result_Within_Range(GEF.Arcsin(-0.50), -0.524, 0.001) or
145
         not Result_Within_Range( EF.Arcsin(-1.0),  -1.571, 0.001)
146
      then
147
         Report.Failed("Incorrect result from Function Arcsin with " &
148
                       "various input parameters");
149
      end if;
150
 
151
 
152
      -- Testing of Function Arcsin with specified Cycle parameter.
153
 
154
--pwb-math      -- Check that Argument_Error is raised by the Arcsin function with
155
--pwb-math      -- specified cycle, whenever the absolute value of the parameter X
156
--pwb-math      -- is greater than 1.0.
157
--pwb-math
158
--pwb-math      begin
159
--pwb-math         New_Float_Result := GEF.Arcsin(New_Float(FXA5A00.Large), 2.0*Pi);
160
--pwb-math         Report.Failed("Argument_Error not raised by Function Arcsin " &
161
--pwb-math                       "with specified cycle, when provided a large "  &
162
--pwb-math                       "positive input parameter");
163
--pwb-math         Dont_Optimize_New_Float(New_Float_Result, 3);
164
--pwb-math      exception
165
--pwb-math         when Argument_Error => null;  -- OK, expected exception.
166
--pwb-math         when others         =>
167
--pwb-math            Report.Failed("Unexpected exception raised by Function Arcsin " &
168
--pwb-math                          "with specified cycle, when provided a large "    &
169
--pwb-math                          "positive input parameter");
170
--pwb-math      end;
171
--pwb-math
172
--pwb-math      begin
173
--pwb-math         The_Result := EF.Arcsin(FXA5A00.Minus_One_Minus_Delta, 2.0*Pi);
174
--pwb-math         Report.Failed("Argument_Error not raised by Function Arcsin " &
175
--pwb-math                       "with specified cycle, when provided an input " &
176
--pwb-math                       "parameter less than -1.0");
177
--pwb-math         Dont_Optimize_Float(The_Result, 4);
178
--pwb-math      exception
179
--pwb-math         when Argument_Error => null;  -- OK, expected exception.
180
--pwb-math         when others         =>
181
--pwb-math            Report.Failed("Unexpected exception raised by Function Arcsin " &
182
--pwb-math                          "with specified cycle, when provided an input "   &
183
--pwb-math                          "parameter less than -1.0");
184
--pwb-math      end;
185
--pwb-math
186
      -- Check that Argument_Error is raised by the Arcsin function with
187
      -- specified cycle, whenever the Cycle parameter is zero or negative.
188
 
189
      begin
190
         New_Float_Result := GEF.Arcsin(2.0, 0.0);
191
         Report.Failed("Argument_Error not raised by Function Arcsin " &
192
                       "with specified cycle of 0.0");
193
         Dont_Optimize_New_Float(New_Float_Result, 5);
194
      exception
195
         when Argument_Error => null;  -- OK, expected exception.
196
         when others         =>
197
            Report.Failed("Unexpected exception raised by Function Arcsin " &
198
                          "with specified cycle of 0.0");
199
      end;
200
 
201
      begin
202
         The_Result := EF.Arcsin(2.0, -2.0*Pi);
203
         Report.Failed("Argument_Error not raised by Function Arcsin " &
204
                       "with specified negative cycle parameter");
205
         Dont_Optimize_Float(The_Result, 6);
206
      exception
207
         when Argument_Error => null;  -- OK, expected exception.
208
         when others         =>
209
            Report.Failed("Unexpected exception raised by Function Arcsin " &
210
                          "with specified negative cycle parameter");
211
      end;
212
 
213
 
214
--pwb-math      -- Check the prescribed result of function Arcsin with specified Cycle
215
--pwb-math      -- parameter, when the value of parameter X is 0.0.
216
--pwb-math
217
--pwb-math      if GEF.Arcsin(X => 0.0, Cycle => 2.0*Pi) /= 0.0 or
218
--pwb-math          EF.Arcsin(0.0, 2.0*Pi)               /= 0.0
219
--pwb-math      then
220
--pwb-math         Report.Failed("Incorrect result from Function Arcsin with " &
221
--pwb-math                       "specified Cycle parameter, when the value "  &
222
--pwb-math                       "of parameter X is 0.0");
223
--pwb-math      end if;
224
--pwb-math
225
--pwb-math
226
--pwb-math      -- Test of the Arcsin function with specified Cycle parameter with
227
--pwb-math      -- various input parameters.
228
--pwb-math
229
--pwb-math      if not FXA5A00.Result_Within_Range(GEF.Arcsin( 0.01, 2.0*Pi),
230
--pwb-math                                         0.010,
231
--pwb-math                                         0.001)                    or
232
--pwb-math         not FXA5A00.Result_Within_Range( EF.Arcsin( 0.14, 2.0*Pi),
233
--pwb-math                                         0.141,
234
--pwb-math                                         0.001)                    or
235
--pwb-math         not FXA5A00.Result_Within_Range(GEF.Arcsin( 0.37, 2.0*Pi),
236
--pwb-math                                         0.379,
237
--pwb-math                                         0.001)                    or
238
--pwb-math         not FXA5A00.Result_Within_Range( EF.Arcsin( 0.55, 2.0*Pi),
239
--pwb-math                                         0.582,
240
--pwb-math                                         0.001)                    or
241
--pwb-math         not FXA5A00.Result_Within_Range(GEF.Arcsin(-0.22, 2.0*Pi),
242
--pwb-math                                         -0.222,
243
--pwb-math                                         0.001)                    or
244
--pwb-math         not FXA5A00.Result_Within_Range( EF.Arcsin(-0.99, 2.0*Pi),
245
--pwb-math                                         -1.43,
246
--pwb-math                                          0.01)                    or
247
--pwb-math         not FXA5A00.Result_Within_Range( EF.Arcsin(1.0, 360.0),
248
--pwb-math                                         90.0,
249
--pwb-math                                         0.1)                      or
250
--pwb-math         not FXA5A00.Result_Within_Range( EF.Arcsin(1.0, 100.0),
251
--pwb-math                                         25.0,
252
--pwb-math                                         0.1)
253
--pwb-math      then
254
--pwb-math         Report.Failed("Incorrect result from Arcsin with specified " &
255
--pwb-math                       "cycle parameter with various input parameters");
256
--pwb-math      end if;
257
 
258
      -- Testing of Arcsinh Function, both instantiated and pre-instantiated
259
      -- version.
260
 
261
      -- Check that no exception occurs on computing the Arcsinh with very
262
      -- large (positive and negative) input values.
263
 
264
      begin
265
         New_Float_Result := GEF.Arcsinh(New_Float(FXA5A00.Large));
266
         Dont_Optimize_New_Float(New_Float_Result, 7);
267
      exception
268
         when others =>
269
           Report.Failed("Unexpected exception on Arcsinh with large " &
270
                         "positive value");
271
      end;
272
 
273
      begin
274
         The_Result := EF.Arcsinh(FXA5A00.Minus_Large);
275
         Dont_Optimize_Float(The_Result, 8);
276
      exception
277
         when others =>
278
           Report.Failed("Unexpected exception on Arcsinh with large " &
279
                         "negative value");
280
      end;
281
 
282
 
283
      -- Check that no exception occurs on computing the Arcsinh with very
284
      -- small (positive and negative) input values.
285
 
286
      begin
287
         New_Float_Result := GEF.Arcsinh(New_Float(FXA5A00.Small));
288
         Dont_Optimize_New_Float(New_Float_Result, 9);
289
      exception
290
         when others =>
291
           Report.Failed("Unexpected exception on Arcsinh with small " &
292
                         "positive value");
293
      end;
294
 
295
      begin
296
         The_Result := EF.Arcsinh(-FXA5A00.Small);
297
         Dont_Optimize_Float(The_Result, 10);
298
      exception
299
         when others =>
300
           Report.Failed("Unexpected exception on Arcsinh with small " &
301
                         "negative value");
302
      end;
303
 
304
 
305
      -- Check function Arcsinh for prescribed result with parameter 0.0.
306
 
307
      if GEF.Arcsinh(X => 0.0) /= 0.0 or
308
          EF.Arcsinh(X => 0.0) /= 0.0
309
      then
310
         Report.Failed("Incorrect result from Function Arcsinh when " &
311
                       "provided a 0.0 input parameter");
312
      end if;
313
 
314
 
315
      -- Check the results of the Arcsinh function with various input
316
      -- parameters.
317
 
318
      if not Result_Within_Range(GEF.Arcsinh(0.15),  0.149, 0.001) or
319
         not Result_Within_Range( EF.Arcsinh(0.82),  0.748, 0.001) or
320
         not Result_Within_Range(GEF.Arcsinh(1.44),  1.161, 0.001) or
321
         not Result_Within_Range(GEF.Arcsinh(6.70),  2.601, 0.001) or
322
         not Result_Within_Range( EF.Arcsinh(Pi),    1.862, 0.001) or
323
         not Result_Within_Range( EF.Arcsinh(-Pi),  -1.862, 0.001) or
324
         not Result_Within_Range(GEF.Arcsinh(-1.0), -0.881, 0.001) or
325
         not Result_Within_Range( EF.Arcsinh(-5.5), -2.406, 0.001)
326
      then
327
         Report.Failed("Incorrect result from Function Arcsin with " &
328
                       "various input parameters");
329
      end if;
330
 
331
 
332
   exception
333
      when others => Report.Failed ("Exception raised in Test_Block");
334
   end Test_Block;
335
 
336
   Report.Result;
337
 
338
end CXA5A05;

powered by: WebSVN 2.1.0

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