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 complex multiplication and division
28 -- operations return results that are within the allowed
30 -- Check that all the required pure Numerics packages are pure.
33 -- This test contains three test packages that are almost
34 -- identical. The first two packages differ only in the
35 -- floating point type that is being tested. The first
36 -- and third package differ only in whether the generic
37 -- complex types package or the pre-instantiated
39 -- The test package is not generic so that the arguments
40 -- and expected results for some of the test values
41 -- can be expressed as universal real instead of being
42 -- computed at runtime.
44 -- SPECIAL REQUIREMENTS
45 -- The Strict Mode for the numerical accuracy must be
46 -- selected. The method by which this mode is selected
47 -- is implementation dependent.
49 -- APPLICABILITY CRITERIA:
50 -- This test applies only to implementations supporting the
52 -- This test only applies to the Strict Mode for numerical
57 -- 24 FEB 96 SAIC Initial release for 2.1
58 -- 03 JUN 98 EDS Correct the test program's incorrect assumption
59 -- that Constraint_Error must be raised by complex
60 -- division by zero, which is contrary to the
61 -- allowance given by the Ada 95 standard G.1.1(40).
62 -- 13 MAR 01 RLB Replaced commented out Pure check on non-generic
63 -- packages, as required by Defect Report
64 -- 8652/0020 and as reflected in Technical
68 ------------------------------------------------------------------------------
69 -- Check that the required pure packages are pure by withing them from a
70 -- pure package. The non-generic versions of those packages are required to
71 -- be pure by Defect Report 8652/0020, Technical Corrigendum 1 [A.5.1(9/1) and
73 with Ada
.Numerics
.Generic_Elementary_Functions
;
74 with Ada
.Numerics
.Elementary_Functions
;
75 with Ada
.Numerics
.Generic_Complex_Types
;
76 with Ada
.Numerics
.Complex_Types
;
77 with Ada
.Numerics
.Generic_Complex_Elementary_Functions
;
78 with Ada
.Numerics
.Complex_Elementary_Functions
;
81 -- CRC Standard Mathematical Tables; 23rd Edition; pg 738
83 1.41421_35623_73095_04880_16887_24209_69807_85696_71875_37695
;
85 1.73205_08075_68877_29352_74463_41505_87236_69428_05253_81039
;
88 ------------------------------------------------------------------------------
92 with Ada
.Numerics
.Generic_Complex_Types
;
93 with Ada
.Numerics
.Complex_Types
;
94 with CXG2008_0
; use CXG2008_0
;
96 Verbose
: constant Boolean := False;
98 package Float_Check
is
99 subtype Real
is Float;
103 package body Float_Check
is
104 package Complex_Types
is new
105 Ada
.Numerics
.Generic_Complex_Types
(Real
);
108 -- keep track if an accuracy failure has occurred so the test
109 -- can be short-circuited to avoid thousands of error messages.
110 Failure_Detected
: Boolean := False;
112 Mult_MBE
: constant Real
:= 5.0;
113 Divide_MBE
: constant Real
:= 13.0;
116 procedure Check
(Actual
, Expected
: Complex
;
123 -- In the case where the expected result is very small or 0
124 -- we compute the maximum error as a multiple of Model_Epsilon instead
125 -- of Model_Epsilon and Expected.
126 Rel_Error
:= MBE
* abs Expected
.Re
* Real
'Model_Epsilon;
127 Abs_Error
:= MBE
* Real
'Model_Epsilon;
128 if Rel_Error
> Abs_Error
then
129 Max_Error
:= Rel_Error
;
131 Max_Error
:= Abs_Error
;
134 if abs (Actual
.Re
- Expected
.Re
) > Max_Error
then
135 Failure_Detected
:= True;
136 Report
.Failed
(Test_Name
&
137 " actual.re: " & Real
'Image (Actual
.Re
) &
138 " expected.re: " & Real
'Image (Expected
.Re
) &
140 Real
'Image (Actual
.Re
- Expected
.Re
) &
141 " mre:" & Real
'Image (Max_Error
) );
143 if Actual
= Expected
then
144 Report
.Comment
(Test_Name
& " exact result for real part");
146 Report
.Comment
(Test_Name
& " passed for real part");
150 Rel_Error
:= MBE
* abs Expected
.Im
* Real
'Model_Epsilon;
151 if Rel_Error
> Abs_Error
then
152 Max_Error
:= Rel_Error
;
154 Max_Error
:= Abs_Error
;
156 if abs (Actual
.Im
- Expected
.Im
) > Max_Error
then
157 Failure_Detected
:= True;
158 Report
.Failed
(Test_Name
&
159 " actual.im: " & Real
'Image (Actual
.Im
) &
160 " expected.im: " & Real
'Image (Expected
.Im
) &
162 Real
'Image (Actual
.Im
- Expected
.Im
) &
163 " mre:" & Real
'Image (Max_Error
) );
165 if Actual
= Expected
then
166 Report
.Comment
(Test_Name
& " exact result for imaginary part");
168 Report
.Comment
(Test_Name
& " passed for imaginary part");
174 procedure Special_Values
is
179 T
: constant := (Real
'Machine_EMax - 1) / 2;
180 Big
: constant := (1.0 * Real
'Machine_Radix) ** (2 * T
);
181 Expected
: Complex
:= (0.0, 0.0);
182 X
: Complex
:= (0.0, 0.0);
183 Y
: Complex
:= (Big
, Big
);
187 Check
(Z
, Expected
, "test 1a -- (0+0i) * (big+big*i)",
190 Check
(Z
, Expected
, "test 1b -- (big+big*i) * (0+0i)",
193 when Constraint_Error
=>
194 Report
.Failed
("Constraint_Error raised in test 1");
196 Report
.Failed
("exception in test 1");
201 T
: constant := Real
'Model_EMin + 1;
202 Tiny
: constant := (1.0 * Real
'Machine_Radix) ** T
;
203 U
: Complex
:= (Tiny
, Tiny
);
204 X
: Complex
:= (0.0, 0.0);
205 Expected
: Complex
:= (0.0, 0.0);
209 Check
(Z
, Expected
, "test 2 -- (tiny,tiny) * (0,0)",
212 when Constraint_Error
=>
213 Report
.Failed
("Constraint_Error raised in test 2");
215 Report
.Failed
("exception in test 2");
220 T
: constant := (Real
'Machine_EMax - 1) / 2;
221 Big
: constant := (1.0 * Real
'Machine_Radix) ** (2 * T
);
222 B
: Complex
:= (Big
, Big
);
223 X
: Complex
:= (0.0, 0.0);
226 if Real
'Machine_Overflows then
228 Report
.Failed
("test 3 - Constraint_Error not raised");
229 Check
(Z
, Z
, "not executed - optimizer thwarting", 0.0);
232 when Constraint_Error
=> null; -- expected
234 Report
.Failed
("exception in test 3");
239 T
: constant := Real
'Model_EMin + 1;
240 Tiny
: constant := (1.0 * Real
'Machine_Radix) ** T
;
241 U
: Complex
:= (Tiny
, Tiny
);
242 X
: Complex
:= (0.0, 0.0);
245 if Real
'Machine_Overflows then
247 Report
.Failed
("test 4 - Constraint_Error not raised");
248 Check
(Z
, Z
, "not executed - optimizer thwarting", 0.0);
251 when Constraint_Error
=> null; -- expected
253 Report
.Failed
("exception in test 4");
259 X
: Complex
:= (Sqrt2
, Sqrt2
);
261 Expected
: constant Complex
:= (0.0, 4.0);
264 Check
(Z
, Expected
, "test 5 -- (sqrt2,sqrt2) * (sqrt2,sqrt2)",
267 when Constraint_Error
=>
268 Report
.Failed
("Constraint_Error raised in test 5");
270 Report
.Failed
("exception in test 5");
275 X
: Complex
:= Sqrt3
- Sqrt3
* i
;
277 Expected
: constant Complex
:= (0.0, -6.0);
280 Check
(Z
, Expected
, "test 6 -- (sqrt3,-sqrt3) * (sqrt3,-sqrt3)",
283 when Constraint_Error
=>
284 Report
.Failed
("Constraint_Error raised in test 6");
286 Report
.Failed
("exception in test 6");
291 X
: Complex
:= Sqrt2
+ Sqrt2
* i
;
292 Y
: Complex
:= Sqrt2
- Sqrt2
* i
;
294 Expected
: constant Complex
:= 0.0 + i
;
297 Check
(Z
, Expected
, "test 7 -- (sqrt2,sqrt2) / (sqrt2,-sqrt2)",
300 when Constraint_Error
=>
301 Report
.Failed
("Constraint_Error raised in test 7");
303 Report
.Failed
("exception in test 7");
308 procedure Do_Mult_Div
(X
, Y
: Complex
) is
310 Args
: constant String :=
311 "X=(" & Real
'Image (X
.Re
) & "," & Real
'Image (X
.Im
) & ") " &
312 "Y=(" & Real
'Image (Y
.Re
) & "," & Real
'Image (Y
.Im
) & ") " ;
315 Check
(Z
, X
, "X*X/X " & Args
, Mult_MBE
+ Divide_MBE
);
317 Check
(Z
, Y
, "X*Y/X " & Args
, Mult_MBE
+ Divide_MBE
);
319 Check
(Z
, X
, "X*Y/Y " & Args
, Mult_MBE
+ Divide_MBE
);
321 when Constraint_Error
=>
322 Report
.Failed
("Constraint_Error in Do_Mult_Div for " & Args
);
324 Report
.Failed
("exception in Do_Mult_Div for " & Args
);
327 -- select complex values X and Y where the real and imaginary
328 -- parts are selected from the ranges (1/radix..1) and
329 -- (1..radix). This translates into quite a few combinations.
330 procedure Mult_Div_Check
is
331 Samples
: constant := 17;
332 Radix
: constant Real
:= Real
(Real
'Machine_Radix);
333 Inv_Radix
: constant Real
:= 1.0 / Real
(Real
'Machine_Radix);
334 Low_Sample
: Real
; -- (1/radix .. 1)
335 High_Sample
: Real
; -- (1 .. radix)
336 Sample
: array (1..2) of Real
;
339 for I
in 1 .. Samples
loop
340 Low_Sample
:= (1.0 - Inv_Radix
) / Real
(Samples
) * Real
(I
) +
342 Sample
(1) := Low_Sample
;
343 for J
in 1 .. Samples
loop
344 High_Sample
:= (Radix
- 1.0) / Real
(Samples
) * Real
(I
) +
346 Sample
(2) := High_Sample
;
349 X
:= Complex
'(Sample (K), Sample (L));
350 Y := Complex'(Sample
(L
), Sample
(K
));
352 if Failure_Detected
then
353 return; -- minimize flood of error messages
369 -----------------------------------------------------------------------
370 -----------------------------------------------------------------------
371 -- check the floating point type with the most digits
373 package A_Long_Float_Check
is
374 type A_Long_Float
is digits System
.Max_Digits
;
375 subtype Real
is A_Long_Float
;
377 end A_Long_Float_Check
;
379 package body A_Long_Float_Check
is
381 package Complex_Types
is new
382 Ada
.Numerics
.Generic_Complex_Types
(Real
);
385 -- keep track if an accuracy failure has occurred so the test
386 -- can be short-circuited to avoid thousands of error messages.
387 Failure_Detected
: Boolean := False;
389 Mult_MBE
: constant Real
:= 5.0;
390 Divide_MBE
: constant Real
:= 13.0;
393 procedure Check
(Actual
, Expected
: Complex
;
400 -- In the case where the expected result is very small or 0
401 -- we compute the maximum error as a multiple of Model_Epsilon instead
402 -- of Model_Epsilon and Expected.
403 Rel_Error
:= MBE
* abs Expected
.Re
* Real
'Model_Epsilon;
404 Abs_Error
:= MBE
* Real
'Model_Epsilon;
405 if Rel_Error
> Abs_Error
then
406 Max_Error
:= Rel_Error
;
408 Max_Error
:= Abs_Error
;
411 if abs (Actual
.Re
- Expected
.Re
) > Max_Error
then
412 Failure_Detected
:= True;
413 Report
.Failed
(Test_Name
&
414 " actual.re: " & Real
'Image (Actual
.Re
) &
415 " expected.re: " & Real
'Image (Expected
.Re
) &
417 Real
'Image (Actual
.Re
- Expected
.Re
) &
418 " mre:" & Real
'Image (Max_Error
) );
420 if Actual
= Expected
then
421 Report
.Comment
(Test_Name
& " exact result for real part");
423 Report
.Comment
(Test_Name
& " passed for real part");
427 Rel_Error
:= MBE
* abs Expected
.Im
* Real
'Model_Epsilon;
428 if Rel_Error
> Abs_Error
then
429 Max_Error
:= Rel_Error
;
431 Max_Error
:= Abs_Error
;
433 if abs (Actual
.Im
- Expected
.Im
) > Max_Error
then
434 Failure_Detected
:= True;
435 Report
.Failed
(Test_Name
&
436 " actual.im: " & Real
'Image (Actual
.Im
) &
437 " expected.im: " & Real
'Image (Expected
.Im
) &
439 Real
'Image (Actual
.Im
- Expected
.Im
) &
440 " mre:" & Real
'Image (Max_Error
) );
442 if Actual
= Expected
then
443 Report
.Comment
(Test_Name
& " exact result for imaginary part");
445 Report
.Comment
(Test_Name
& " passed for imaginary part");
451 procedure Special_Values
is
456 T
: constant := (Real
'Machine_EMax - 1) / 2;
457 Big
: constant := (1.0 * Real
'Machine_Radix) ** (2 * T
);
458 Expected
: Complex
:= (0.0, 0.0);
459 X
: Complex
:= (0.0, 0.0);
460 Y
: Complex
:= (Big
, Big
);
464 Check
(Z
, Expected
, "test 1a -- (0+0i) * (big+big*i)",
467 Check
(Z
, Expected
, "test 1b -- (big+big*i) * (0+0i)",
470 when Constraint_Error
=>
471 Report
.Failed
("Constraint_Error raised in test 1");
473 Report
.Failed
("exception in test 1");
478 T
: constant := Real
'Model_EMin + 1;
479 Tiny
: constant := (1.0 * Real
'Machine_Radix) ** T
;
480 U
: Complex
:= (Tiny
, Tiny
);
481 X
: Complex
:= (0.0, 0.0);
482 Expected
: Complex
:= (0.0, 0.0);
486 Check
(Z
, Expected
, "test 2 -- (tiny,tiny) * (0,0)",
489 when Constraint_Error
=>
490 Report
.Failed
("Constraint_Error raised in test 2");
492 Report
.Failed
("exception in test 2");
497 T
: constant := (Real
'Machine_EMax - 1) / 2;
498 Big
: constant := (1.0 * Real
'Machine_Radix) ** (2 * T
);
499 B
: Complex
:= (Big
, Big
);
500 X
: Complex
:= (0.0, 0.0);
503 if Real
'Machine_Overflows then
505 Report
.Failed
("test 3 - Constraint_Error not raised");
506 Check
(Z
, Z
, "not executed - optimizer thwarting", 0.0);
509 when Constraint_Error
=> null; -- expected
511 Report
.Failed
("exception in test 3");
516 T
: constant := Real
'Model_EMin + 1;
517 Tiny
: constant := (1.0 * Real
'Machine_Radix) ** T
;
518 U
: Complex
:= (Tiny
, Tiny
);
519 X
: Complex
:= (0.0, 0.0);
522 if Real
'Machine_Overflows then
524 Report
.Failed
("test 4 - Constraint_Error not raised");
525 Check
(Z
, Z
, "not executed - optimizer thwarting", 0.0);
528 when Constraint_Error
=> null; -- expected
530 Report
.Failed
("exception in test 4");
536 X
: Complex
:= (Sqrt2
, Sqrt2
);
538 Expected
: constant Complex
:= (0.0, 4.0);
541 Check
(Z
, Expected
, "test 5 -- (sqrt2,sqrt2) * (sqrt2,sqrt2)",
544 when Constraint_Error
=>
545 Report
.Failed
("Constraint_Error raised in test 5");
547 Report
.Failed
("exception in test 5");
552 X
: Complex
:= Sqrt3
- Sqrt3
* i
;
554 Expected
: constant Complex
:= (0.0, -6.0);
557 Check
(Z
, Expected
, "test 6 -- (sqrt3,-sqrt3) * (sqrt3,-sqrt3)",
560 when Constraint_Error
=>
561 Report
.Failed
("Constraint_Error raised in test 6");
563 Report
.Failed
("exception in test 6");
568 X
: Complex
:= Sqrt2
+ Sqrt2
* i
;
569 Y
: Complex
:= Sqrt2
- Sqrt2
* i
;
571 Expected
: constant Complex
:= 0.0 + i
;
574 Check
(Z
, Expected
, "test 7 -- (sqrt2,sqrt2) / (sqrt2,-sqrt2)",
577 when Constraint_Error
=>
578 Report
.Failed
("Constraint_Error raised in test 7");
580 Report
.Failed
("exception in test 7");
585 procedure Do_Mult_Div
(X
, Y
: Complex
) is
587 Args
: constant String :=
588 "X=(" & Real
'Image (X
.Re
) & "," & Real
'Image (X
.Im
) & ") " &
589 "Y=(" & Real
'Image (Y
.Re
) & "," & Real
'Image (Y
.Im
) & ") " ;
592 Check
(Z
, X
, "X*X/X " & Args
, Mult_MBE
+ Divide_MBE
);
594 Check
(Z
, Y
, "X*Y/X " & Args
, Mult_MBE
+ Divide_MBE
);
596 Check
(Z
, X
, "X*Y/Y " & Args
, Mult_MBE
+ Divide_MBE
);
598 when Constraint_Error
=>
599 Report
.Failed
("Constraint_Error in Do_Mult_Div for " & Args
);
601 Report
.Failed
("exception in Do_Mult_Div for " & Args
);
604 -- select complex values X and Y where the real and imaginary
605 -- parts are selected from the ranges (1/radix..1) and
606 -- (1..radix). This translates into quite a few combinations.
607 procedure Mult_Div_Check
is
608 Samples
: constant := 17;
609 Radix
: constant Real
:= Real
(Real
'Machine_Radix);
610 Inv_Radix
: constant Real
:= 1.0 / Real
(Real
'Machine_Radix);
611 Low_Sample
: Real
; -- (1/radix .. 1)
612 High_Sample
: Real
; -- (1 .. radix)
613 Sample
: array (1..2) of Real
;
616 for I
in 1 .. Samples
loop
617 Low_Sample
:= (1.0 - Inv_Radix
) / Real
(Samples
) * Real
(I
) +
619 Sample
(1) := Low_Sample
;
620 for J
in 1 .. Samples
loop
621 High_Sample
:= (Radix
- 1.0) / Real
(Samples
) * Real
(I
) +
623 Sample
(2) := High_Sample
;
626 X
:= Complex
'(Sample (K), Sample (L));
627 Y := Complex'(Sample
(L
), Sample
(K
));
629 if Failure_Detected
then
630 return; -- minimize flood of error messages
644 end A_Long_Float_Check
;
646 -----------------------------------------------------------------------
647 -----------------------------------------------------------------------
649 package Non_Generic_Check
is
650 subtype Real
is Float;
652 end Non_Generic_Check
;
654 package body Non_Generic_Check
is
656 use Ada
.Numerics
.Complex_Types
;
658 -- keep track if an accuracy failure has occurred so the test
659 -- can be short-circuited to avoid thousands of error messages.
660 Failure_Detected
: Boolean := False;
662 Mult_MBE
: constant Real
:= 5.0;
663 Divide_MBE
: constant Real
:= 13.0;
666 procedure Check
(Actual
, Expected
: Complex
;
673 -- In the case where the expected result is very small or 0
674 -- we compute the maximum error as a multiple of Model_Epsilon instead
675 -- of Model_Epsilon and Expected.
676 Rel_Error
:= MBE
* abs Expected
.Re
* Real
'Model_Epsilon;
677 Abs_Error
:= MBE
* Real
'Model_Epsilon;
678 if Rel_Error
> Abs_Error
then
679 Max_Error
:= Rel_Error
;
681 Max_Error
:= Abs_Error
;
684 if abs (Actual
.Re
- Expected
.Re
) > Max_Error
then
685 Failure_Detected
:= True;
686 Report
.Failed
(Test_Name
&
687 " actual.re: " & Real
'Image (Actual
.Re
) &
688 " expected.re: " & Real
'Image (Expected
.Re
) &
690 Real
'Image (Actual
.Re
- Expected
.Re
) &
691 " mre:" & Real
'Image (Max_Error
) );
693 if Actual
= Expected
then
694 Report
.Comment
(Test_Name
& " exact result for real part");
696 Report
.Comment
(Test_Name
& " passed for real part");
700 Rel_Error
:= MBE
* abs Expected
.Im
* Real
'Model_Epsilon;
701 if Rel_Error
> Abs_Error
then
702 Max_Error
:= Rel_Error
;
704 Max_Error
:= Abs_Error
;
706 if abs (Actual
.Im
- Expected
.Im
) > Max_Error
then
707 Failure_Detected
:= True;
708 Report
.Failed
(Test_Name
&
709 " actual.im: " & Real
'Image (Actual
.Im
) &
710 " expected.im: " & Real
'Image (Expected
.Im
) &
712 Real
'Image (Actual
.Im
- Expected
.Im
) &
713 " mre:" & Real
'Image (Max_Error
) );
715 if Actual
= Expected
then
716 Report
.Comment
(Test_Name
& " exact result for imaginary part");
718 Report
.Comment
(Test_Name
& " passed for imaginary part");
724 procedure Special_Values
is
729 T
: constant := (Real
'Machine_EMax - 1) / 2;
730 Big
: constant := (1.0 * Real
'Machine_Radix) ** (2 * T
);
731 Expected
: Complex
:= (0.0, 0.0);
732 X
: Complex
:= (0.0, 0.0);
733 Y
: Complex
:= (Big
, Big
);
737 Check
(Z
, Expected
, "test 1a -- (0+0i) * (big+big*i)",
740 Check
(Z
, Expected
, "test 1b -- (big+big*i) * (0+0i)",
743 when Constraint_Error
=>
744 Report
.Failed
("Constraint_Error raised in test 1");
746 Report
.Failed
("exception in test 1");
751 T
: constant := Real
'Model_EMin + 1;
752 Tiny
: constant := (1.0 * Real
'Machine_Radix) ** T
;
753 U
: Complex
:= (Tiny
, Tiny
);
754 X
: Complex
:= (0.0, 0.0);
755 Expected
: Complex
:= (0.0, 0.0);
759 Check
(Z
, Expected
, "test 2 -- (tiny,tiny) * (0,0)",
762 when Constraint_Error
=>
763 Report
.Failed
("Constraint_Error raised in test 2");
765 Report
.Failed
("exception in test 2");
770 T
: constant := (Real
'Machine_EMax - 1) / 2;
771 Big
: constant := (1.0 * Real
'Machine_Radix) ** (2 * T
);
772 B
: Complex
:= (Big
, Big
);
773 X
: Complex
:= (0.0, 0.0);
776 if Real
'Machine_Overflows then
778 Report
.Failed
("test 3 - Constraint_Error not raised");
779 Check
(Z
, Z
, "not executed - optimizer thwarting", 0.0);
782 when Constraint_Error
=> null; -- expected
784 Report
.Failed
("exception in test 3");
789 T
: constant := Real
'Model_EMin + 1;
790 Tiny
: constant := (1.0 * Real
'Machine_Radix) ** T
;
791 U
: Complex
:= (Tiny
, Tiny
);
792 X
: Complex
:= (0.0, 0.0);
795 if Real
'Machine_Overflows then
797 Report
.Failed
("test 4 - Constraint_Error not raised");
798 Check
(Z
, Z
, "not executed - optimizer thwarting", 0.0);
801 when Constraint_Error
=> null; -- expected
803 Report
.Failed
("exception in test 4");
809 X
: Complex
:= (Sqrt2
, Sqrt2
);
811 Expected
: constant Complex
:= (0.0, 4.0);
814 Check
(Z
, Expected
, "test 5 -- (sqrt2,sqrt2) * (sqrt2,sqrt2)",
817 when Constraint_Error
=>
818 Report
.Failed
("Constraint_Error raised in test 5");
820 Report
.Failed
("exception in test 5");
825 X
: Complex
:= Sqrt3
- Sqrt3
* i
;
827 Expected
: constant Complex
:= (0.0, -6.0);
830 Check
(Z
, Expected
, "test 6 -- (sqrt3,-sqrt3) * (sqrt3,-sqrt3)",
833 when Constraint_Error
=>
834 Report
.Failed
("Constraint_Error raised in test 6");
836 Report
.Failed
("exception in test 6");
841 X
: Complex
:= Sqrt2
+ Sqrt2
* i
;
842 Y
: Complex
:= Sqrt2
- Sqrt2
* i
;
844 Expected
: constant Complex
:= 0.0 + i
;
847 Check
(Z
, Expected
, "test 7 -- (sqrt2,sqrt2) / (sqrt2,-sqrt2)",
850 when Constraint_Error
=>
851 Report
.Failed
("Constraint_Error raised in test 7");
853 Report
.Failed
("exception in test 7");
858 procedure Do_Mult_Div
(X
, Y
: Complex
) is
860 Args
: constant String :=
861 "X=(" & Real
'Image (X
.Re
) & "," & Real
'Image (X
.Im
) & ") " &
862 "Y=(" & Real
'Image (Y
.Re
) & "," & Real
'Image (Y
.Im
) & ") " ;
865 Check
(Z
, X
, "X*X/X " & Args
, Mult_MBE
+ Divide_MBE
);
867 Check
(Z
, Y
, "X*Y/X " & Args
, Mult_MBE
+ Divide_MBE
);
869 Check
(Z
, X
, "X*Y/Y " & Args
, Mult_MBE
+ Divide_MBE
);
871 when Constraint_Error
=>
872 Report
.Failed
("Constraint_Error in Do_Mult_Div for " & Args
);
874 Report
.Failed
("exception in Do_Mult_Div for " & Args
);
877 -- select complex values X and Y where the real and imaginary
878 -- parts are selected from the ranges (1/radix..1) and
879 -- (1..radix). This translates into quite a few combinations.
880 procedure Mult_Div_Check
is
881 Samples
: constant := 17;
882 Radix
: constant Real
:= Real
(Real
'Machine_Radix);
883 Inv_Radix
: constant Real
:= 1.0 / Real
(Real
'Machine_Radix);
884 Low_Sample
: Real
; -- (1/radix .. 1)
885 High_Sample
: Real
; -- (1 .. radix)
886 Sample
: array (1..2) of Real
;
889 for I
in 1 .. Samples
loop
890 Low_Sample
:= (1.0 - Inv_Radix
) / Real
(Samples
) * Real
(I
) +
892 Sample
(1) := Low_Sample
;
893 for J
in 1 .. Samples
loop
894 High_Sample
:= (Radix
- 1.0) / Real
(Samples
) * Real
(I
) +
896 Sample
(2) := High_Sample
;
899 X
:= Complex
'(Sample (K), Sample (L));
900 Y := Complex'(Sample
(L
), Sample
(K
));
902 if Failure_Detected
then
903 return; -- minimize flood of error messages
917 end Non_Generic_Check
;
919 -----------------------------------------------------------------------
920 -----------------------------------------------------------------------
923 Report
.Test
("CXG2008",
924 "Check the accuracy of the complex multiplication and" &
925 " division operators");
928 Report
.Comment
("checking Standard.Float");
934 Report
.Comment
("checking a digits" &
935 Integer'Image (System
.Max_Digits
) &
936 " floating point type");
939 A_Long_Float_Check
.Do_Test
;
942 Report
.Comment
("checking non-generic package");
945 Non_Generic_Check
.Do_Test
;