1 |
294 |
jeremybenn |
-- CXA5A06.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 Arccos and Arccosh provide correct
|
28 |
|
|
-- results.
|
29 |
|
|
--
|
30 |
|
|
-- TEST DESCRIPTION:
|
31 |
|
|
-- This test examines both the version of Arccos and Arccosh
|
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 |
|
|
-- CXA5A06.A
|
46 |
|
|
--
|
47 |
|
|
--
|
48 |
|
|
-- CHANGE HISTORY:
|
49 |
|
|
-- 27 Mar 95 SAIC Initial prerelease version.
|
50 |
|
|
-- 13 Jun 95 SAIC Incorporated use of Dont_Optimize procedure, and
|
51 |
|
|
-- use of Result_Within_Range function overloaded for
|
52 |
|
|
-- FXA5A00.New_Float_Type.
|
53 |
|
|
-- 28 Feb 97 PWB.CTA 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.Numerics.Elementary_Functions;
|
67 |
|
|
with Ada.Numerics.Generic_Elementary_Functions;
|
68 |
|
|
with FXA5A00;
|
69 |
|
|
with Report;
|
70 |
|
|
|
71 |
|
|
procedure CXA5A06 is
|
72 |
|
|
begin
|
73 |
|
|
|
74 |
|
|
Report.Test ("CXA5A06", "Check that the functions Arccos and Arccosh " &
|
75 |
|
|
"provide correct results");
|
76 |
|
|
|
77 |
|
|
Test_Block:
|
78 |
|
|
declare
|
79 |
|
|
|
80 |
|
|
use Ada.Numerics;
|
81 |
|
|
use FXA5A00;
|
82 |
|
|
|
83 |
|
|
package GEF is new Ada.Numerics.Generic_Elementary_Functions(New_Float);
|
84 |
|
|
package EF renames Ada.Numerics.Elementary_Functions;
|
85 |
|
|
|
86 |
|
|
The_Result : Float;
|
87 |
|
|
New_Float_Result : New_Float;
|
88 |
|
|
|
89 |
|
|
procedure Dont_Optimize_Float is new Dont_Optimize(Float);
|
90 |
|
|
procedure Dont_Optimize_New_Float is new Dont_Optimize(New_Float);
|
91 |
|
|
|
92 |
|
|
begin
|
93 |
|
|
|
94 |
|
|
-- Testing of Arccos Function, both instantiated and pre-instantiated
|
95 |
|
|
-- version.
|
96 |
|
|
|
97 |
|
|
-- Check that Argument_Error is raised by the Arccos function when the
|
98 |
|
|
-- absolute value of the input parameter is greater than 1.0.
|
99 |
|
|
|
100 |
|
|
begin
|
101 |
|
|
New_Float_Result := GEF.Arccos(New_Float(FXA5A00.One_Plus_Delta));
|
102 |
|
|
Report.Failed("Argument_Error not raised by the Arccos function " &
|
103 |
|
|
"when the input parameter is greater than 1.0");
|
104 |
|
|
Dont_Optimize_New_Float(New_Float_Result, 1);
|
105 |
|
|
exception
|
106 |
|
|
when Argument_Error => null; -- OK, expected exception.
|
107 |
|
|
when others =>
|
108 |
|
|
Report.Failed("Unexpected exception raised by the Arccos " &
|
109 |
|
|
"function when the input parameter is greater " &
|
110 |
|
|
"than 1.0");
|
111 |
|
|
end;
|
112 |
|
|
|
113 |
|
|
begin
|
114 |
|
|
The_Result := EF.Arccos(-FXA5A00.Large);
|
115 |
|
|
Report.Failed("Argument_Error not raised by the Arccos function " &
|
116 |
|
|
"when the input parameter is a large negative value");
|
117 |
|
|
Dont_Optimize_Float(The_Result, 2);
|
118 |
|
|
exception
|
119 |
|
|
when Argument_Error => null; -- OK, expected exception.
|
120 |
|
|
when others =>
|
121 |
|
|
Report.Failed("Unexpected exception raised by the Arccos " &
|
122 |
|
|
"function when the input parameter is a " &
|
123 |
|
|
"large negative value");
|
124 |
|
|
end;
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
-- Check the prescribed results of the Arccos function.
|
128 |
|
|
|
129 |
|
|
if GEF.Arccos(X => 1.0) /= 0.0 or
|
130 |
|
|
EF.Arccos(1.0) /= 0.0
|
131 |
|
|
then
|
132 |
|
|
Report.Failed("Incorrect result returned by the Arccos function " &
|
133 |
|
|
"when provided a parameter value of 0.0");
|
134 |
|
|
end if;
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
-- Check the results of the Arccos function with various input
|
138 |
|
|
-- parameters.
|
139 |
|
|
|
140 |
|
|
if not Result_Within_Range(GEF.Arccos(0.77), 0.692, 0.001) or
|
141 |
|
|
not Result_Within_Range( EF.Arccos(0.37), 1.19, 0.01) or
|
142 |
|
|
not Result_Within_Range(GEF.Arccos(0.0), Pi/2.0, 0.01) or
|
143 |
|
|
not Result_Within_Range( EF.Arccos(-0.11), 1.68, 0.01) or
|
144 |
|
|
not Result_Within_Range(GEF.Arccos(-0.67), 2.31, 0.01) or
|
145 |
|
|
not Result_Within_Range( EF.Arccos(-0.94), 2.79, 0.01) or
|
146 |
|
|
not Result_Within_Range(GEF.Arccos(-1.0), Pi, 0.01)
|
147 |
|
|
then
|
148 |
|
|
Report.Failed("Incorrect result returned from the Arccos " &
|
149 |
|
|
"function when provided a variety of input " &
|
150 |
|
|
"parameters");
|
151 |
|
|
end if;
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
-- Testing of the Arccos function with specified Cycle parameter.
|
155 |
|
|
|
156 |
|
|
-- Check that Argument_Error is raised by the Arccos function, with
|
157 |
|
|
-- specified Cycle parameter, when the absolute value of the input
|
158 |
|
|
-- parameter is greater than 1.0.
|
159 |
|
|
|
160 |
|
|
begin
|
161 |
|
|
--pwb-math: Next line: Changed 2.0*Pi to 360.0
|
162 |
|
|
New_Float_Result := GEF.Arccos(New_Float(Large), Cycle => 360.0);
|
163 |
|
|
Report.Failed("Argument_Error not raised by the Arccos function " &
|
164 |
|
|
"with specified Cycle parameter, when the input " &
|
165 |
|
|
"parameter is a large positive value");
|
166 |
|
|
Dont_Optimize_New_Float(New_Float_Result, 3);
|
167 |
|
|
exception
|
168 |
|
|
when Argument_Error => null; -- OK, expected exception.
|
169 |
|
|
when others =>
|
170 |
|
|
Report.Failed("Unexpected exception raised by the Arccos " &
|
171 |
|
|
"function with specified Cycle parameter, when " &
|
172 |
|
|
"the input parameter is a large positive value");
|
173 |
|
|
end;
|
174 |
|
|
|
175 |
|
|
begin
|
176 |
|
|
--pwb-math: Next line: Changed 2.0*Pi to 360.0
|
177 |
|
|
The_Result := EF.Arccos(FXA5A00.Minus_One_Minus_Delta, 360.0);
|
178 |
|
|
Report.Failed("Argument_Error not raised by the Arccos function " &
|
179 |
|
|
"with specified Cycle parameter, when the input " &
|
180 |
|
|
"parameter is less than -1.0");
|
181 |
|
|
Dont_Optimize_Float(The_Result, 4);
|
182 |
|
|
exception
|
183 |
|
|
when Argument_Error => null; -- OK, expected exception.
|
184 |
|
|
when others =>
|
185 |
|
|
Report.Failed("Unexpected exception raised by the Arccos " &
|
186 |
|
|
"function with specified Cycle parameter, " &
|
187 |
|
|
"when the input parameter is less than -1.0");
|
188 |
|
|
end;
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
-- Check that Argument_Error is raised by the Arccos function with
|
192 |
|
|
-- specified cycle when the value of the Cycle parameter is zero or
|
193 |
|
|
-- negative.
|
194 |
|
|
|
195 |
|
|
begin
|
196 |
|
|
New_Float_Result := GEF.Arccos(X => 1.0, Cycle => 0.0 );
|
197 |
|
|
Report.Failed("Argument_Error not raised by the Arccos function " &
|
198 |
|
|
"with specified Cycle parameter, when the Cycle " &
|
199 |
|
|
"parameter is 0.0");
|
200 |
|
|
Dont_Optimize_New_Float(New_Float_Result, 5);
|
201 |
|
|
exception
|
202 |
|
|
when Argument_Error => null; -- OK, expected exception.
|
203 |
|
|
when others =>
|
204 |
|
|
Report.Failed("Unexpected exception raised by the Arccos " &
|
205 |
|
|
"function with specified Cycle parameter, when " &
|
206 |
|
|
"the Cycle parameter is 0.0");
|
207 |
|
|
end;
|
208 |
|
|
|
209 |
|
|
begin
|
210 |
|
|
The_Result := EF.Arccos(1.0, Cycle => -2.0*Pi);
|
211 |
|
|
Report.Failed("Argument_Error not raised by the Arccos function " &
|
212 |
|
|
"with specified Cycle parameter, when the Cycle " &
|
213 |
|
|
"parameter is negative");
|
214 |
|
|
Dont_Optimize_Float(The_Result, 6);
|
215 |
|
|
exception
|
216 |
|
|
when Argument_Error => null; -- OK, expected exception.
|
217 |
|
|
when others =>
|
218 |
|
|
Report.Failed("Unexpected exception raised by the Arccos " &
|
219 |
|
|
"function with specified Cycle parameter, when " &
|
220 |
|
|
"the Cycle parameter is negative");
|
221 |
|
|
end;
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
-- Check the prescribed result of the Arccos function with specified
|
225 |
|
|
-- Cycle parameter.
|
226 |
|
|
|
227 |
|
|
--pwb-math: Next two lines: Changed 2.0*Pi to 360.0
|
228 |
|
|
if GEF.Arccos(X => 1.0, Cycle => 360.0) /= 0.0 or
|
229 |
|
|
EF.Arccos(1.0, 360.0) /= 0.0
|
230 |
|
|
then
|
231 |
|
|
Report.Failed("Incorrect result from the Arccos function with " &
|
232 |
|
|
"specified Cycle parameter, when the input " &
|
233 |
|
|
"parameter value is 1.0");
|
234 |
|
|
end if;
|
235 |
|
|
|
236 |
|
|
|
237 |
|
|
-- Check the results of the Arccos function, with specified Cycle
|
238 |
|
|
-- parameter, with various input parameters.
|
239 |
|
|
|
240 |
|
|
if --pwb-math not Result_Within_Range(GEF.Arccos( 0.04, 2.0*Pi), 1.53, 0.01) or
|
241 |
|
|
--pwb-math not Result_Within_Range( EF.Arccos( 0.14, 2.0*Pi), 1.43, 0.01) or
|
242 |
|
|
--pwb-math not Result_Within_Range(GEF.Arccos( 0.57, 2.0*Pi), 0.96, 0.01) or
|
243 |
|
|
--pwb-math not Result_Within_Range( EF.Arccos( 0.99, 2.0*Pi), 0.14, 0.01) or
|
244 |
|
|
not Result_Within_Range(GEF.Arccos(-1.0, 360.0), 180.0, 0.1) or
|
245 |
|
|
not Result_Within_Range(GEF.Arccos(-1.0, 100.0), 50.0, 0.1) or
|
246 |
|
|
not Result_Within_Range(GEF.Arccos( 0.0, 360.0), 90.0, 0.1) or
|
247 |
|
|
not Result_Within_Range(GEF.Arccos( 0.0, 100.0), 25.0, 0.1)
|
248 |
|
|
then
|
249 |
|
|
Report.Failed("Incorrect result returned from the Arccos " &
|
250 |
|
|
"function with specified Cycle parameter, " &
|
251 |
|
|
"when provided a variety of input parameters");
|
252 |
|
|
end if;
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
-- Testing of Arccosh Function, both instantiated and pre-instantiated
|
257 |
|
|
-- version.
|
258 |
|
|
|
259 |
|
|
-- Check that Argument_Error is raised by the Arccosh function when
|
260 |
|
|
-- the value of the parameter X is less than 1.0.
|
261 |
|
|
|
262 |
|
|
begin
|
263 |
|
|
New_Float_Result := GEF.Arccosh(New_Float(FXA5A00.One_Minus_Delta));
|
264 |
|
|
Report.Failed("Argument_Error not raised by the Arccosh function " &
|
265 |
|
|
"when the parameter value is less than 1.0");
|
266 |
|
|
Dont_Optimize_New_Float(New_Float_Result, 7);
|
267 |
|
|
exception
|
268 |
|
|
when Argument_Error => null; -- OK, expected exception.
|
269 |
|
|
when others =>
|
270 |
|
|
Report.Failed("Unexpected exception raised by the Arccosh " &
|
271 |
|
|
"function when given a parameter value less " &
|
272 |
|
|
"than 1.0");
|
273 |
|
|
end;
|
274 |
|
|
|
275 |
|
|
begin
|
276 |
|
|
The_Result := EF.Arccosh(0.0);
|
277 |
|
|
Report.Failed("Argument_Error not raised by the Arccosh function " &
|
278 |
|
|
"when the parameter value is 0.0");
|
279 |
|
|
Dont_Optimize_Float(The_Result, 8);
|
280 |
|
|
exception
|
281 |
|
|
when Argument_Error => null; -- OK, expected exception.
|
282 |
|
|
when others =>
|
283 |
|
|
Report.Failed("Unexpected exception raised by the Arccosh " &
|
284 |
|
|
"function when given a parameter value of 0.0");
|
285 |
|
|
end;
|
286 |
|
|
|
287 |
|
|
begin
|
288 |
|
|
New_Float_Result := GEF.Arccosh(New_Float(-FXA5A00.Large));
|
289 |
|
|
Report.Failed("Argument_Error not raised by the Arccosh function " &
|
290 |
|
|
"when the large negative parameter value");
|
291 |
|
|
Dont_Optimize_New_Float(New_Float_Result, 9);
|
292 |
|
|
exception
|
293 |
|
|
when Argument_Error => null; -- OK, expected exception.
|
294 |
|
|
when others =>
|
295 |
|
|
Report.Failed("Unexpected exception raised by the Arccosh " &
|
296 |
|
|
"function when given a large negative parameter " &
|
297 |
|
|
"value");
|
298 |
|
|
end;
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
-- Check the prescribed results of the Arccosh function.
|
302 |
|
|
|
303 |
|
|
if GEF.Arccosh(X => 1.0) /= 0.0 or
|
304 |
|
|
EF.Arccosh(1.0) /= 0.0
|
305 |
|
|
then
|
306 |
|
|
Report.Failed("Incorrect result returned by the Arccosh " &
|
307 |
|
|
"function when provided a parameter value of 0.0");
|
308 |
|
|
end if;
|
309 |
|
|
|
310 |
|
|
|
311 |
|
|
-- Check the results of the Arccosh function with various input
|
312 |
|
|
-- parameters.
|
313 |
|
|
|
314 |
|
|
if not Result_Within_Range(GEF.Arccosh(1.03), 0.244, 0.001) or
|
315 |
|
|
not Result_Within_Range( EF.Arccosh(1.28), 0.732, 0.001) or
|
316 |
|
|
not Result_Within_Range(GEF.Arccosh(1.50), 0.962, 0.001) or
|
317 |
|
|
not Result_Within_Range( EF.Arccosh(1.77), 1.17, 0.01) or
|
318 |
|
|
not Result_Within_Range(GEF.Arccosh(2.00), 1.32, 0.01) or
|
319 |
|
|
not Result_Within_Range( EF.Arccosh(4.30), 2.14, 0.01) or
|
320 |
|
|
not Result_Within_Range(GEF.Arccosh(6.90), 2.62, 0.01)
|
321 |
|
|
then
|
322 |
|
|
Report.Failed("Incorrect result returned from the Arccosh " &
|
323 |
|
|
"function when provided a variety of input " &
|
324 |
|
|
"parameters");
|
325 |
|
|
end if;
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
exception
|
329 |
|
|
when others => Report.Failed ("Exception raised in Test_Block");
|
330 |
|
|
end Test_Block;
|
331 |
|
|
|
332 |
|
|
Report.Result;
|
333 |
|
|
|
334 |
|
|
end CXA5A06;
|