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 Arctan provides correct results.
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
41 -- The following files comprise this test:
43 -- FXA5A00.A (foundation code)
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
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".
65 with Ada
.Numerics
.Elementary_Functions
;
66 with Ada
.Numerics
.Generic_Elementary_Functions
;
73 Report
.Test
("CXA5A07", "Check that the Arctan function provides " &
82 package GEF
is new Ada
.Numerics
.Generic_Elementary_Functions
(New_Float
);
83 package EF
renames Ada
.Numerics
.Elementary_Functions
;
86 New_Float_Result
: New_Float
;
88 procedure Dont_Optimize_Float
is new Dont_Optimize
(Float);
89 procedure Dont_Optimize_New_Float
is new Dont_Optimize
(New_Float
);
93 -- Testing of Arctan Function, both instantiated and pre-instantiated
96 -- Check that Argument_Error is raised by the Arctan function when
97 -- provided parameter values of 0.0, 0.0.
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);
105 when Argument_Error
=> null; -- OK, expected exception.
107 Report
.Failed
("Incorrect exception raised by the Arctan " &
108 "function when provided 0.0, 0.0 input parameters");
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.
117 Float_Result
:= EF
.Arctan
(Y
=> FXA5A00
.Large
);
118 Dont_Optimize_Float
(Float_Result
, 2);
121 Report
.Failed
("Exception raised when the Arctan function is " &
122 "provided a large positive Y parameter value");
126 New_Float_Result
:= GEF
.Arctan
(Y
=> New_Float
(-FXA5A00
.Large
));
127 Dont_Optimize_New_Float
(New_Float_Result
, 3);
130 Report
.Failed
("Exception raised when the Arctan function is " &
131 "provided a large negative Y parameter value");
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.
140 Float_Result
:= EF
.Arctan
(Y
=> FXA5A00
.Small
);
141 Dont_Optimize_Float
(Float_Result
, 4);
144 Report
.Failed
("Exception raised when the Arctan function is " &
145 "provided a small positive Y parameter value");
149 New_Float_Result
:= GEF
.Arctan
(Y
=> New_Float
(-FXA5A00
.Small
));
150 Dont_Optimize_New_Float
(New_Float_Result
, 5);
153 Report
.Failed
("Exception raised when the Arctan function is " &
154 "provided a small negative Y parameter value");
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.
163 Float_Result
:= EF
.Arctan
(Y
=> FXA5A00
.Large
, X
=> FXA5A00
.Large
);
164 Dont_Optimize_Float
(Float_Result
, 6);
167 Report
.Failed
("Exception raised when the Arctan function is " &
168 "provided large positive X and Y parameter values");
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);
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");
184 Float_Result
:= EF
.Arctan
(Y
=> FXA5A00
.Small
, X
=> FXA5A00
.Large
);
185 Dont_Optimize_Float
(Float_Result
, 8);
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");
194 New_Float_Result
:= GEF
.Arctan
(New_Float
(-FXA5A00
.Small
),
195 New_Float
(-FXA5A00
.Large
));
196 Dont_Optimize_New_Float
(New_Float_Result
, 9);
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");
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.
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
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");
221 -- Check that the Arctan function provides correct results when provided
222 -- a variety of Y parameter values.
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)
231 Report
.Failed
("Incorrect results from the Arctan function when " &
232 "provided a variety of Y parameter values");
237 -- Check the results of the Arctan function with specified cycle
240 -- Check that the Arctan function with specified Cycle parameter
241 -- raises Argument_Error when the value of the Cycle parameter is zero
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 " &
249 Dont_Optimize_Float
(Float_Result
, 10);
251 when Argument_Error
=> null; -- OK, expected exception.
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");
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);
264 when Argument_Error
=> null; -- OK, expected exception.
266 Report
.Failed
("Incorrect exception raised by the Arctan " &
267 "function when provided a 0.0 cycle parameter " &
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);
278 when Argument_Error
=> null; -- OK, expected exception.
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");
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);
291 when Argument_Error
=> null; -- OK, expected exception.
293 Report
.Failed
("Incorrect exception raised by the Arctan " &
294 "function when provided a -Pi cycle parameter " &
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.
304 Float_Result
:= EF
.Arctan
(Y
=> -FXA5A00
.Large
,
306 --pwb-math: Next line: changed 2.0*Pi to 360.0
308 Dont_Optimize_Float
(Float_Result
, 14);
311 Report
.Failed
("Exception raised when the Arctan function with " &
312 "specified Cycle parameter, when provided large " &
313 "negative X and Y parameter values");
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
322 Dont_Optimize_New_Float
(New_Float_Result
, 15);
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");
333 Float_Result
:= EF
.Arctan
(Y
=> -FXA5A00
.Small
,
335 --pwb-math: Next line: changed 2.0*Pi to 360.0
337 Dont_Optimize_Float
(Float_Result
, 16);
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");
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
351 Dont_Optimize_New_Float
(New_Float_Result
, 17);
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");
361 -- Check that the Arctan function with specified Cycle parameter
362 -- provides correct results when provided a variety of Y parameter
365 --pwb-math if not FXA5A00.Result_Within_Range(EF.Arctan(Pi, Cycle => 2.0*Pi),
368 --pwb-math not FXA5A00.Result_Within_Range(EF.Arctan(-Pi, Cycle => 2.0*Pi),
371 --pwb-math not FXA5A00.Result_Within_Range(GEF.Arctan(1.0, Cycle => 2.0*Pi),
374 --pwb-math not FXA5A00.Result_Within_Range(EF.Arctan(-1.0, Cycle => 2.0*Pi),
377 --pwb-math not FXA5A00.Result_Within_Range(GEF.Arctan(0.16, Cycle => 2.0*Pi),
380 --pwb-math not FXA5A00.Result_Within_Range(EF.Arctan(1.0, Cycle => 360.0),
383 --pwb-math not FXA5A00.Result_Within_Range(GEF.Arctan(1.0, Cycle => 100.0),
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),
391 not FXA5A00
.Result_Within_Range
(EF
.Arctan
(-1.0, Cycle
=> 2.0*180.0),
394 not FXA5A00
.Result_Within_Range
(EF
.Arctan
(1.0, Cycle
=> 360.0),
397 not FXA5A00
.Result_Within_Range
(GEF
.Arctan
(1.0, Cycle
=> 100.0),
401 Report
.Failed
("Incorrect results from the Arctan function with " &
402 "specified Cycle parameter when provided a variety " &
403 "of Y parameter values");
408 when others => Report
.Failed
("Exception raised in Test_Block");