3 -- Grant of Unlimited Rights
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
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.
27 -- Check that the function Arccot provides correct results.
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
41 -- The following files comprise this test:
43 -- FXA5A00.A (foundation code)
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
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".
67 with Ada
.Numerics
.Elementary_Functions
;
68 with Ada
.Numerics
.Generic_Elementary_Functions
;
75 Report
.Test
("CXA5A08", "Check that the Arccot function provides " &
85 package GEF
is new Ada
.Numerics
.Generic_Elementary_Functions
(New_Float
);
86 package EF
renames Ada
.Numerics
.Elementary_Functions
;
90 New_Float_Result
: New_Float
;
91 New_Float_Angle
: New_Float
;
92 Incorrect_Inverse
: Boolean := False;
94 procedure Dont_Optimize_Float
is new Dont_Optimize
(Float);
95 procedure Dont_Optimize_New_Float
is new Dont_Optimize
(New_Float
);
99 -- Testing of Arccot Function, both instantiated and pre-instantiated
102 -- Check that Argument_Error is raised by the Arccot function when
103 -- provided parameter values of 0.0, 0.0.
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);
111 when Argument_Error
=> null; -- OK, expected exception.
113 Report
.Failed
("Incorrect exception raised by the Arccot " &
114 "function when provided 0.0, 0.0 input parameters");
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.
123 Float_Result
:= EF
.Arccot
(X
=> FXA5A00
.Large
);
124 Dont_Optimize_Float
(Float_Result
, 2);
127 Report
.Failed
("Exception raised when the Arccot function is " &
128 "provided a large positive X parameter value");
132 New_Float_Result
:= GEF
.Arccot
(X
=> New_Float
(-FXA5A00
.Large
));
133 Dont_Optimize_New_Float
(New_Float_Result
, 3);
136 Report
.Failed
("Exception raised when the Arccot function is " &
137 "provided a large negative X parameter value");
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.
146 Float_Result
:= EF
.Arccot
(X
=> FXA5A00
.Small
);
147 Dont_Optimize_Float
(Float_Result
, 4);
150 Report
.Failed
("Exception raised when the Arccot function is " &
151 "provided a small positive X parameter value");
155 New_Float_Result
:= GEF
.Arccot
(X
=> New_Float
(-FXA5A00
.Small
));
156 Dont_Optimize_New_Float
(New_Float_Result
, 5);
159 Report
.Failed
("Exception raised when the Arccot function is " &
160 "provided a small negative X parameter value");
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.
169 Float_Result
:= EF
.Arccot
(X
=> FXA5A00
.Large
, Y
=> FXA5A00
.Large
);
170 Dont_Optimize_Float
(Float_Result
, 6);
173 Report
.Failed
("Exception raised when the Arccot function is " &
174 "provided large positive X and Y parameter values");
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);
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");
190 Float_Result
:= EF
.Arccot
(X
=> FXA5A00
.Small
, Y
=> FXA5A00
.Large
);
191 Dont_Optimize_Float
(Float_Result
, 8);
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");
200 New_Float_Result
:= GEF
.Arccot
(New_Float
(-FXA5A00
.Small
),
201 New_Float
(-FXA5A00
.Large
));
202 Dont_Optimize_New_Float
(New_Float_Result
, 9);
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");
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.
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
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");
228 -- Check that the Arccot function provides correct results when
229 -- provided a variety of X parameter values.
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)
235 Report
.Failed
("Incorrect results from the Arccot function when " &
236 "provided a variety of Y parameter values");
240 -- Check the results of the Arccot function with specified cycle
243 -- Check that the Arccot function with specified Cycle parameter
244 -- raises Argument_Error when the value of the Cycle parameter is zero
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 " &
252 Dont_Optimize_Float
(Float_Result
, 10);
254 when Argument_Error
=> null; -- OK, expected exception.
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");
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);
267 when Argument_Error
=> null; -- OK, expected exception.
269 Report
.Failed
("Incorrect exception raised by the Arccot " &
270 "function when provided a 0.0 cycle parameter " &
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);
281 when Argument_Error
=> null; -- OK, expected exception.
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");
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);
294 when Argument_Error
=> null; -- OK, expected exception.
296 Report
.Failed
("Incorrect exception raised by the Arccot " &
297 "function when provided a -Pi cycle parameter " &
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.
307 Float_Result
:= EF
.Arccot
(X
=> -FXA5A00
.Large
,
309 --pwb-math Next line: changed 2.0*Pi to 360.0
311 Dont_Optimize_Float
(Float_Result
, 14);
314 Report
.Failed
("Exception raised when the Arccot function with " &
315 "specified Cycle parameter, when provided large " &
316 "negative X and Y parameter values");
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
325 Dont_Optimize_New_Float
(New_Float_Result
, 15);
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");
336 Float_Result
:= EF
.Arccot
(X
=> -FXA5A00
.Small
,
338 --pwb-math Next line: changed 2.0*Pi to 360.0
340 Dont_Optimize_Float
(Float_Result
, 16);
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");
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
354 Dont_Optimize_New_Float
(New_Float_Result
, 17);
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");
364 -- Check that the Arccot function with specified Cycle parameter
365 -- provides correct results when provided a variety of X parameter
368 if not FXA5A00
.Result_Within_Range
(GEF
.Arccot
( 0.0, Cycle
=> 360.0),
371 not FXA5A00
.Result_Within_Range
(EF
.Arccot
( 0.0, Cycle
=> 100.0),
374 not FXA5A00
.Result_Within_Range
(GEF
.Arccot
( 1.0, Cycle
=> 360.0),
377 not FXA5A00
.Result_Within_Range
(EF
.Arccot
( 1.0, Cycle
=> 100.0),
380 not FXA5A00
.Result_Within_Range
(GEF
.Arccot
(-1.0, Cycle
=> 360.0),
383 not FXA5A00
.Result_Within_Range
(EF
.Arccot
(-1.0, Cycle
=> 100.0),
387 Report
.Failed
("Incorrect results from the Arccot function with " &
388 "specified Cycle parameter when provided a variety " &
389 "of X parameter values");
393 if not FXA5A00
.Result_Within_Range
(EF
.Arccot
(0.2425355, 0.9701420),
396 not FXA5A00
.Result_Within_Range
(EF
.Arccot
(0.3162277, 0.9486831),
400 Report
.Failed
("Incorrect results from the Arccot function with " &
401 "comparison to other Arccot function results");
405 if not FXA5A00
.Result_Within_Range
(EF
.Cot
(EF
.Arccot
(0.4472135,
409 not FXA5A00
.Result_Within_Range
(EF
.Cot
(EF
.Arccot
(0.9987380,
414 Report
.Failed
("Incorrect results from the Arccot function when " &
415 "used as argument to Cot function");
419 -- Check that inverse function results are correct.
420 -- Default Cycle test.
423 while Angle
< Pi
and not Incorrect_Inverse
loop
424 if not Result_Within_Range
(EF
.Arccot
(EF
.Cot
(Angle
)), Angle
, 0.001)
426 Incorrect_Inverse
:= True;
428 Angle
:= Angle
+ 0.001;
431 if Incorrect_Inverse
then
432 Report
.Failed
("Incorrect results returned from the Inverse " &
433 "comparison of Cot and Arccot using the default " &
435 Incorrect_Inverse
:= False;
438 -- Non-Default Cycle test.
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
),
445 Float(New_Float_Angle
),
447 not Result_Within_Range
(GEF
.Arccot
(
448 New_Float
(GEF
.Cot
(New_Float_Angle
,
451 Float(New_Float_Angle
),
454 Incorrect_Inverse
:= True;
456 New_Float_Angle
:= New_Float_Angle
+ 0.01;
459 if Incorrect_Inverse
then
460 Report
.Failed
("Incorrect results returned from the Inverse " &
461 "comparison of Cot and Arccot using non-default " &
467 when The_Error
: others =>
468 Report
.Failed
("The following exception was raised in the " &
469 "Test_Block: " & Exception_Name
(The_Error
));