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 functions Arcsin and Arcsinh provide correct
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
42 -- The following files comprise this test:
44 -- FXA5A00.A (foundation code)
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
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".
68 with Ada
.Numerics
.Elementary_Functions
;
69 with Ada
.Numerics
.Generic_Elementary_Functions
;
76 Report
.Test
("CXA5A05", "Check that the functions Arcsin and Arcsinh " &
77 "provide correct results");
85 package GEF
is new Ada
.Numerics
.Generic_Elementary_Functions
(New_Float
);
86 package EF
renames Ada
.Numerics
.Elementary_Functions
;
89 New_Float_Result
: New_Float
;
91 procedure Dont_Optimize_Float
is new Dont_Optimize
(Float);
92 procedure Dont_Optimize_New_Float
is new Dont_Optimize
(New_Float
);
96 -- Testing of Function Arcsin, both instantiated and pre-instantiated
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.
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);
108 when Argument_Error
=> null; -- OK, expected exception.
110 Report
.Failed
("Unexpected exception raised by Arcsin function " &
111 "when provided a parameter value larger than 1.0");
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);
120 when Argument_Error
=> null; -- OK, expected exception.
122 Report
.Failed
("Unexpected exception raised by Arcsin function " &
123 "when provided a large negative parameter value");
127 -- Check the prescribed result of function Arcsin with parameter 0.0.
129 if GEF
.Arcsin
(X
=> 0.0) /= 0.0 or
130 EF
.Arcsin
(0.0) /= 0.0
132 Report
.Failed
("Incorrect result from Function Arcsin when the " &
133 "value of the parameter X is 0.0");
137 -- Check the results of the Arcsin function with various input
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)
147 Report
.Failed
("Incorrect result from Function Arcsin with " &
148 "various input parameters");
152 -- Testing of Function Arcsin with specified Cycle parameter.
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.
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);
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");
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);
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");
186 -- Check that Argument_Error is raised by the Arcsin function with
187 -- specified cycle, whenever the Cycle parameter is zero or negative.
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);
195 when Argument_Error
=> null; -- OK, expected exception.
197 Report
.Failed
("Unexpected exception raised by Function Arcsin " &
198 "with specified cycle of 0.0");
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);
207 when Argument_Error
=> null; -- OK, expected exception.
209 Report
.Failed
("Unexpected exception raised by Function Arcsin " &
210 "with specified negative cycle parameter");
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.
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
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");
226 --pwb-math -- Test of the Arcsin function with specified Cycle parameter with
227 --pwb-math -- various input parameters.
229 --pwb-math if not FXA5A00.Result_Within_Range(GEF.Arcsin( 0.01, 2.0*Pi),
232 --pwb-math not FXA5A00.Result_Within_Range( EF.Arcsin( 0.14, 2.0*Pi),
235 --pwb-math not FXA5A00.Result_Within_Range(GEF.Arcsin( 0.37, 2.0*Pi),
238 --pwb-math not FXA5A00.Result_Within_Range( EF.Arcsin( 0.55, 2.0*Pi),
241 --pwb-math not FXA5A00.Result_Within_Range(GEF.Arcsin(-0.22, 2.0*Pi),
244 --pwb-math not FXA5A00.Result_Within_Range( EF.Arcsin(-0.99, 2.0*Pi),
247 --pwb-math not FXA5A00.Result_Within_Range( EF.Arcsin(1.0, 360.0),
250 --pwb-math not FXA5A00.Result_Within_Range( EF.Arcsin(1.0, 100.0),
254 --pwb-math Report.Failed("Incorrect result from Arcsin with specified " &
255 --pwb-math "cycle parameter with various input parameters");
258 -- Testing of Arcsinh Function, both instantiated and pre-instantiated
261 -- Check that no exception occurs on computing the Arcsinh with very
262 -- large (positive and negative) input values.
265 New_Float_Result
:= GEF
.Arcsinh
(New_Float
(FXA5A00
.Large
));
266 Dont_Optimize_New_Float
(New_Float_Result
, 7);
269 Report
.Failed
("Unexpected exception on Arcsinh with large " &
274 The_Result
:= EF
.Arcsinh
(FXA5A00
.Minus_Large
);
275 Dont_Optimize_Float
(The_Result
, 8);
278 Report
.Failed
("Unexpected exception on Arcsinh with large " &
283 -- Check that no exception occurs on computing the Arcsinh with very
284 -- small (positive and negative) input values.
287 New_Float_Result
:= GEF
.Arcsinh
(New_Float
(FXA5A00
.Small
));
288 Dont_Optimize_New_Float
(New_Float_Result
, 9);
291 Report
.Failed
("Unexpected exception on Arcsinh with small " &
296 The_Result
:= EF
.Arcsinh
(-FXA5A00
.Small
);
297 Dont_Optimize_Float
(The_Result
, 10);
300 Report
.Failed
("Unexpected exception on Arcsinh with small " &
305 -- Check function Arcsinh for prescribed result with parameter 0.0.
307 if GEF
.Arcsinh
(X
=> 0.0) /= 0.0 or
308 EF
.Arcsinh
(X
=> 0.0) /= 0.0
310 Report
.Failed
("Incorrect result from Function Arcsinh when " &
311 "provided a 0.0 input parameter");
315 -- Check the results of the Arcsinh function with various input
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)
327 Report
.Failed
("Incorrect result from Function Arcsin with " &
328 "various input parameters");
333 when others => Report
.Failed
("Exception raised in Test_Block");