-- TEST_GENERIC_COMPLEX_PRESCRIBED.ADA -- part 1 of multiple part test -- This part tests prescribed values, range constraints and proper -- raising of exceptions. -- Additional parts test accuracy based on Peter Tang's techniques. -- This version is for a system that does not implement signed zeros. -- This is version 1.0, 9 September, 1996, -- of a specification compliance test suite -- for the Generic_Complex_Elementary_Functions package as specified in -- ISO/IEC 13814:1996 Generic package of complex elementary functions -- for Ada. -- The ACVC Ada Compiler Validation Capability philosophy is intended to -- be used. e.g. This is a test against a specification on a specific -- implementation. A specific implementation means the combination of three -- items : 1) a specific Ada compilation system, 2) a specific hardware -- configuration and 3) a specific Generic Complex Elementary Functions -- implementation. The specification is interpreted by the NRG -- the same way ISO/IEC 8652:1987 is interpreted by the ARG. -- (A minor update to this file has been made for ISO/IEC 8652:1995 -- Note to implementors: Once an initial release of this test suite is -- released, there may be periodic updates. There is no guarantee that -- passing any particular version implies passing another version. -- This is the same philosophy as for ACVC. -- When the specification says the domain is unbounded, then the test -- suite checks for no exceptions being raised for FLOAT_TYPE'LARGE, -- 'SMALL their negatives, and possibly other values. Similarly for a -- domain of X>0 or X>=0 'LARGE and 'SMALL are used. When there is -- a note about "restricted domain" then the check for no exceptions is made by -- replacing 'LARGE reduced by enough to be within the relative -- error. -- The functions are tested in the order the functions appear -- in the specification. Required exceptions are tested. -- Some tests where exceptions should not occur are tested. -- Prescribed values required by the specification are tested. -- This part of the test is itself generic. There are four instantiations -- at the end. Only some instantiations will compile on any given compiler. -- All instantiations that compile must pass the test in order to -- achieve compliance. The instantiations are for FLOAT_TYPE being: -- FLOAT and LONG_FLOAT. -- The corresponding procedures that compile must be linked and executed are: -- TEST_COMPLEX_PRESCRIBED -- TEST_LONG_COMPLEX_PRESCRIBED -- The compliance test must be compiled from this file, unmodified with -- the following exclusions: If a compiler has not yet implemented -- AI 387, then a global edit may be made to change CONSTRAINT_ERROR -- to CONSTRAINT_ERROR | NUMERIC_ERROR . -- -- If all "PASSED" messages are desired, uncomment all "-- PASSED" calls by -- substituting "PASSED" for "-- PASSED". This causes thousands of lines -- of output. -- Please report problems or suggested additions to Jon Squire -- Net mail squire@cs.umbc.edu , phone (410)765-3748 generic type REAL is digits <>; procedure TEST_GENERIC_COMPLEX_PRESCRIBED; with GENERIC_REAL_ARRAYS; with GENERIC_COMPLEX_TYPES; with GENERIC_COMPLEX_ARRAYS; with GENERIC_COMPLEX_ELEMENTARY_FUNCTIONS; with TEST_GCEF_UTILITIES; with GENERIC_ELEMENTARY_FUNCTIONS; with TEXT_IO; procedure TEST_GENERIC_COMPLEX_PRESCRIBED is package REAL_ARRAYS is new GENERIC_REAL_ARRAYS ( REAL ); use REAL_ARRAYS; package COMPLEX_TYPES is new GENERIC_COMPLEX_TYPES ( REAL ); use COMPLEX_TYPES; package COMPLEX_ARRAYS is new GENERIC_COMPLEX_ARRAYS ( REAL, REAL_VECTOR, REAL_MATRIX, COMPLEX ); use COMPLEX_ARRAYS; package COMPLEX_ELEMENTARY_FUNCTIONS is new GENERIC_COMPLEX_ELEMENTARY_FUNCTIONS(REAL, COMPLEX, IMAGINARY); use COMPLEX_ELEMENTARY_FUNCTIONS; package TEST_UTILITIES is new TEST_GCEF_UTILITIES(REAL, COMPLEX); use TEST_UTILITIES; use LT_CONSTANTS; package GEF is new GENERIC_ELEMENTARY_FUNCTIONS ( REAL ); ARGUMENT_ERROR : exception renames COMPLEX_ELEMENTARY_FUNCTIONS.ARGUMENT_ERROR; Y : COMPLEX; VALUES : array(0..9) of REAL:= ( 0.0, SMALL, EPSILON, 0.5, ONE_MINUS, 1.0, ONE_PLUS, 2.0, INV_EPSILON, LARGE); TESTS : COMPLEX_VECTOR(1..(2*VALUES'LAST+1)*(2*VALUES'LAST+1)); K : INTEGER := TESTS'FIRST; LOG_LAST : REAL := GEF.LOG(REAL'LAST); LOG_LARGE_2 : REAL := GEF.LOG(REAL'LARGE) - GEF.LOG(2.0); STAR1_PASSED, STAR2_PASSED, STAR3_PASSED, STAR4_PASSED : BOOLEAN := FALSE; STAR5_PASSED, STAR6_PASSED, STAR7_PASSED, STAR8_PASSED : BOOLEAN := FALSE; STAR9_PASSED, STAR10_PASSED, STAR11_PASSED, STAR12_PASSED : BOOLEAN := FALSE; STARE1_PASSED, STARE2_PASSED, STARE3_PASSED : BOOLEAN := FALSE; begin for I in VALUES'RANGE loop for J in VALUES'RANGE loop TESTS(K) := COMPOSE_FROM_CARTESIAN(VALUES(I),VALUES(J)); K:=K+1; if I /= 0 then TESTS(K) := COMPOSE_FROM_CARTESIAN(-VALUES(I),VALUES(J)); K:=K+1; end if; if J /= 0 then TESTS(K) := COMPOSE_FROM_CARTESIAN(VALUES(I),-VALUES(J)); K:=K+1; end if; if I /= 0 and J /= 0 then TESTS(K) := COMPOSE_FROM_CARTESIAN(-VALUES(I),-VALUES(J)); K:=K+1; end if; end loop; end loop; TEXT_IO.PUT_LINE("SQRT testing"); for I in TESTS'RANGE loop begin Y := SQRT ( TESTS(I) ) ; if RE(Y) < 0.0 then FAILED("SQRT real part < 0.0 ", TESTS(I)); end if; if (IM(TESTS(I)) < 0.0 and IM(Y) > 0.0) or (IM(TESTS(I)) > 0.0 and IM(Y) < 0.0) then FAILED("SQRT sign imag part ", TESTS(I)); end if; if RE(Y) < 0.0 then FAILED("SQRT sign of real part ", TESTS(I)); end if; if TESTS(I) = COMPLEX_ZERO then if Y = COMPLEX_ZERO then PASSED("SQRT(0+i0)=0+i0 ", TESTS(I)); else FAILED("SQRT(0+i0)=0+i0 ", TESTS(I)); end if; end if; if TESTS(I) = COMPLEX_ONE then if Y = COMPLEX_ONE then PASSED("SQRT(1+i0)=1+i0 ", TESTS(I)); else FAILED("SQRT(1+i0)=1+i0 ", TESTS(I)); end if; end if; if TESTS(I) = -COMPLEX_ONE then if Y = COMPLEX_I then PASSED("SQRT(-1+i0)=0+i ", TESTS(I)); else FAILED("SQRT(-1+i0)=0+i ", TESTS(I)); end if; end if; -- PASSED("no exception on SQRT", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on SQRT", TESTS(I)); when CONSTRAINT_ERROR=> FAILED("CONSTRAINT_ERROR raised on SQRT", TESTS(I)); when others => FAILED("unexpected exception on SQRT", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("LOG testing"); for I in TESTS'RANGE loop begin Y := LOG ( TESTS(I) ) ; if IM(Y) > PI+EPSILON or IM(Y) < -(PI+EPSILON) then FAILED("LOG imag part not in [-Pi,Pi] ", TESTS(I)); end if; if (IM(TESTS(I)) < 0.0 and IM(Y) > 0.0) or (IM(TESTS(I)) > 0.0 and IM(Y) < 0.0) then FAILED("LOG sign imag part ", TESTS(I)); end if; if TESTS(I) = COMPLEX_ONE then if Y = COMPLEX_ZERO then PASSED("LOG(1+i0)=0+i0 ", TESTS(I)); else FAILED("LOG(1+i0)=0+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on LOG", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on LOG", TESTS(I)); when CONSTRAINT_ERROR => if TESTS(I) = COMPLEX_ZERO then PASSED("CONSTRAINT_ERROR raised on LOG", TESTS(I)); else FAILED("CONSTRAINT_ERROR raised on LOG", TESTS(I)); end if; when others => FAILED("unexpected exception on LOG", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("EXP testing"); for I in TESTS'RANGE loop begin Y := EXP ( TESTS(I) ) ; if TESTS(I) = COMPLEX_ZERO then if Y = COMPLEX_ONE then PASSED("EXP(0+i0)=1+i0 ", TESTS(I)); else FAILED("EXP(0+i0)=1+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on EXP", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT on EXP", TESTS(I)); when CONSTRAINT_ERROR => if RE(TESTS(I)) > LOG_LAST or RE(TESTS(I)) < -LOG_LAST then -- PASSED("CONSTRAINT_ERROR on EXP", TESTS(I)); null; elsif RE(TESTS(I)) < LOG_LARGE_2 and RE(TESTS(I)) > -LOG_LARGE_2 then FAILED("CONSTRAINT_ERROR on EXP", TESTS(I)); else PASSED("CONSTRAINT_ERROR on EXP", TESTS(I)); end if; when others => FAILED("unexpected exception on EXP", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("""**"" testing complex,complex"); for I in TESTS'RANGE loop begin Y := TESTS(I) ** COMPLEX_ONE ; -- X**1=X if Y = TESTS(I) then if not STAR1_PASSED then PASSED("X**(1+i0)=X ", TESTS(I)); STAR1_PASSED := TRUE; end if; else FAILED("X**(1+i0)=X ", TESTS(I)); end if; if TESTS(I) /= COMPLEX_ZERO then -- X**0=1 Y := TESTS(I) ** COMPLEX_ZERO ; if Y = COMPLEX_ONE then if not STAR2_PASSED then PASSED("X**(0+i0)=1+i0 ", TESTS(I)); STAR2_PASSED := TRUE; end if; else FAILED("X**(0+i0)=1+i0 ", TESTS(I)); end if; end if; if TESTS(I) /= COMPLEX_ZERO then -- 0**Y=0 Y := COMPLEX_ZERO **TESTS(I); if Y = COMPLEX_ZERO then if not STAR3_PASSED then PASSED("(0+i0)**Y=0+i0 ", TESTS(I)); STAR3_PASSED := TRUE; end if; else FAILED("(0+i0)**Y=0+i0 ", TESTS(I)); end if; end if; Y := COMPLEX_ONE ** TESTS(I); -- 1**Y=1 if Y = COMPLEX_ONE then if not STAR4_PASSED then PASSED("(1+i0)**Y=1+i0 ", TESTS(I)); STAR4_PASSED := TRUE; end if; else FAILED("(1+i0)**Y=1+i0 ", TESTS(I)); end if; -- PASSED("no exception on **", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT on **", TESTS(I)); when CONSTRAINT_ERROR => if not STARE1_PASSED then PASSED("CONSTRAINT_ERROR on **", TESTS(I)); STARE1_PASSED := TRUE; end if; when others => FAILED("unexpected exception on **", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("""**"" testing complex,float"); for I in TESTS'RANGE loop begin Y := TESTS(I) ** 1.0 ; -- X**1=X if Y = TESTS(I) then if not STAR5_PASSED then PASSED("X**1=X ", TESTS(I)); STAR5_PASSED := TRUE; end if; else FAILED("X**1=X ", TESTS(I)); end if; if TESTS(I) /= COMPLEX_ZERO then -- X**0=1 Y := TESTS(I) ** 0.0 ; if Y = COMPLEX_ONE then if not STAR6_PASSED then PASSED("X**0=1+i0 ", TESTS(I)); STAR6_PASSED := TRUE; end if; else FAILED("X**0=1+i0 ", TESTS(I)); end if; end if; if RE(TESTS(I)) /= 0.0 then -- 0**Y=0 Y := COMPLEX_ZERO **RE(TESTS(I)); if Y = COMPLEX_ZERO then if not STAR7_PASSED then PASSED("(0+i0)**re Y=0+i0 ", TESTS(I)); STAR7_PASSED := TRUE; end if; else FAILED("(0+i0)**re Y=0+i0 ", TESTS(I)); end if; end if; Y := COMPLEX_ONE ** TESTS(I); -- 1**Y=1 if Y = COMPLEX_ONE then if not STAR8_PASSED then PASSED("(1+i0)**re Y=1+i0 ", TESTS(I)); STAR8_PASSED := TRUE; end if; else FAILED("(1+i0)**re Y=1+i0 ", TESTS(I)); end if; -- PASSED("no exception on **", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT on **", TESTS(I)); when CONSTRAINT_ERROR => if not STARE2_PASSED then PASSED("CONSTRAINT_ERROR on **", TESTS(I)); STARE1_PASSED := TRUE; end if; when others => FAILED("unexpected exception on **", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("""**"" testing float,complex"); for I in TESTS'RANGE loop begin Y := RE(TESTS(I)) ** COMPLEX_ONE ; -- X**1=X if Y = COMPOSE_FROM_CARTESIAN(RE(TESTS(I)),0.0) then if not STAR9_PASSED then PASSED("re X**(1+i0)=re X ", TESTS(I)); STAR9_PASSED := TRUE; end if; else FAILED("re X**(1+i0)=re X ", TESTS(I)); end if; if RE(TESTS(I)) /= 0.0 then -- X**0=1 Y := RE(TESTS(I)) ** COMPLEX_ZERO ; if Y = COMPLEX_ONE then if not STAR10_PASSED then PASSED("re X**(0+i0)=1+i0 ", TESTS(I)); STAR10_PASSED := TRUE; end if; else FAILED("re X**(0+i0)=1+i0 ", TESTS(I)); end if; end if; if TESTS(I) /= COMPLEX_ZERO then -- 0**Y=0 Y := 0.0 **TESTS(I); if Y = COMPLEX_ZERO then if not STAR11_PASSED then PASSED("0**Y=0+i0 ", TESTS(I)); STAR11_PASSED := TRUE; end if; else FAILED("0**Y=0+i0 ", TESTS(I)); end if; end if; Y := 1.0 ** TESTS(I); -- 1**Y=1 if Y = COMPLEX_ONE then if not STAR12_PASSED then PASSED("1**Y=1+i0 ", TESTS(I)); STAR12_PASSED := TRUE; end if; else FAILED("1**Y=1+i0 ", TESTS(I)); end if; -- PASSED("no exception on **", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT on **", TESTS(I)); when CONSTRAINT_ERROR => if not STARE3_PASSED then PASSED("CONSTRAINT_ERROR on **", TESTS(I)); STARE1_PASSED := TRUE; end if; when others => FAILED("unexpected exception on **", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("SIN testing"); for I in TESTS'RANGE loop begin Y := SIN ( TESTS(I) ) ; if TESTS(I) = COMPLEX_ZERO then if Y = COMPLEX_ZERO then PASSED("SIN(0+i0)=0+i0 ", TESTS(I)); else FAILED("SIN(0+i0)=0+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on SIN", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on SIN", TESTS(I)); when CONSTRAINT_ERROR => if IM(TESTS(I)) > LOG_LAST or IM(TESTS(I)) < -LOG_LAST then -- PASSED("CONSTRAINT_ERROR on SIN", TESTS(I)); null; elsif IM(TESTS(I)) < LOG_LARGE_2 and IM(TESTS(I)) > -LOG_LARGE_2 then FAILED("CONSTRAINT_ERROR on SIN", TESTS(I)); else PASSED("CONSTRAINT_ERROR on SIN", TESTS(I)); end if; when others => FAILED("unexpected exception on SIN", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("COS testing"); for I in TESTS'RANGE loop begin Y := COS ( TESTS(I) ) ; if TESTS(I) = COMPLEX_ZERO then if Y = COMPLEX_ONE then PASSED("COS(0+i0)=1+i0 ", TESTS(I)); else FAILED("COS(0+i0)=1+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on COS", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on COS", TESTS(I)); when CONSTRAINT_ERROR => if IM(TESTS(I)) > LOG_LAST or IM(TESTS(I)) < -LOG_LAST then -- PASSED("CONSTRAINT_ERROR on COS", TESTS(I)); null; elsif IM(TESTS(I)) < LOG_LARGE_2 and IM(TESTS(I)) > -LOG_LARGE_2 then FAILED("CONSTRAINT_ERROR on COS", TESTS(I)); else PASSED("CONSTRAINT_ERROR on COS", TESTS(I)); end if; when others => FAILED("unexpected exception on COS", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("TAN testing"); for I in TESTS'RANGE loop begin Y := TAN ( TESTS(I) ) ; if (IM(TESTS(I)) < 0.0 and IM(Y) > 0.0) or (IM(TESTS(I)) > 0.0 and IM(Y) < 0.0) then FAILED("TAN sign imag part ", TESTS(I)); end if; if TESTS(I) = COMPLEX_ZERO then if Y = COMPLEX_ZERO then PASSED("TAN(0+i0)=0+i0 ", TESTS(I)); else FAILED("TAN(0+i0)=0+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on TAN", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on TAN", TESTS(I)); when CONSTRAINT_ERROR => FAILED("CONSTRAINT_ERROR raised on TAN", TESTS(I)); when others => FAILED("unexpected exception on TAN", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("COT testing"); for I in TESTS'RANGE loop begin Y := COT ( TESTS(I) ) ; -- PASSED("no exception on COT", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on COT", TESTS(I)); when CONSTRAINT_ERROR => begin -- CONSTRAINT_ERROR OK if 1.0/TESTS(I) gives it Y := 1.0 / TESTS(I); FAILED("CONSTRAINT_ERROR raised on COT", TESTS(I)); exception when others => PASSED("CONSTRAINT_ERROR raised on COT", TESTS(I)); end; when others => FAILED("unexpected exception on COT", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("ARCSIN testing"); for I in TESTS'RANGE loop begin Y := ARCSIN ( TESTS(I) ) ; if RE(Y) > HALF_PI+EPSILON or RE(Y) < -(HALF_PI+EPSILON) then FAILED("ARCSIN real part not in [-Pi/2,Pi/2] ", TESTS(I)); end if; if (IM(TESTS(I)) < 0.0 and IM(Y) > 0.0) or (IM(TESTS(I)) > 0.0 and IM(Y) < 0.0) then FAILED("ARCSIN sign imag part ", TESTS(I)); end if; if (RE(TESTS(I)) < 0.0 and RE(Y) > 0.0) or (RE(TESTS(I)) > 0.0 and RE(Y) < 0.0) then FAILED("ARCSIN sign of real part ", TESTS(I)); end if; if TESTS(I) = COMPLEX_ZERO then if Y = COMPLEX_ZERO then PASSED("ARCSIN(0+i0)=0+i0 ", TESTS(I)); else FAILED("ARCSIN(0+i0)=0+i0 ", TESTS(I)); end if; end if; if TESTS(I) = COMPLEX_ONE then if SAFE_INTERVAL(Y, PI2_LT, ZERO_LT) then PASSED("ARCSIN(1+i0)=Pi/2+i0 ", TESTS(I)); else FAILED("ARCSIN(1+i0)=Pi/2+i0 ", TESTS(I)); end if; end if; if TESTS(I) = -COMPLEX_ONE then if SAFE_INTERVAL(-Y, PI2_LT, ZERO_LT) then PASSED("ARCSIN(-1+i0)=-Pi/2+i0 ", TESTS(I)); else FAILED("ARCSIN(-1+i0)=-Pi/2+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on ARCSIN", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on ARCSIN", TESTS(I)); when CONSTRAINT_ERROR => FAILED("CONSTRAINT_ERROR raised on ARCSIN", TESTS(I)); when others => FAILED("unexpected exception on ARCSIN", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("ARCCOS testing"); for I in TESTS'RANGE loop begin Y := ARCCOS ( TESTS(I) ) ; if RE(Y) < 0.0 or RE(Y) > PI+EPSILON then FAILED("ARCCOS real part not in [0,Pi] ", TESTS(I)); end if; if (IM(TESTS(I)) < 0.0 and IM(Y) < 0.0) or (IM(TESTS(I)) > 0.0 and IM(Y) > 0.0) then FAILED("ARCCOS sign imag part ", TESTS(I)); end if; if TESTS(I) = COMPLEX_ONE then if Y = COMPLEX_ZERO then PASSED("ARCCOS(1+i0)=0+i0 ", TESTS(I)); else FAILED("ARCCOS(1+i0)=0+i0 ", TESTS(I)); end if; end if; if TESTS(I) = -COMPLEX_ONE then if SAFE_INTERVAL(Y, PI_LT, ZERO_LT) then PASSED("ARCCOS(-1+i0)=Pi+i0 ", TESTS(I)); else FAILED("ARCCOS(-1+i0)=Pi+i0 ", TESTS(I)); end if; end if; if TESTS(I) = COMPLEX_ZERO then if SAFE_INTERVAL(Y, PI2_LT, ZERO_LT) then PASSED("ARCCOS(0+i0)=Pi/2+i0 ", TESTS(I)); else FAILED("ARCCOS(0+i0)=Pi/2+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on ARCCOS", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on ARCCOS", TESTS(I)); when CONSTRAINT_ERROR => FAILED("CONSTRAINT_ERROR raised on ARCCOS", TESTS(I)); when others => FAILED("unexpected exception on ARCCOS", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("ARCTAN testing"); for I in TESTS'RANGE loop begin Y := ARCTAN ( TESTS(I) ) ; if RE(Y) > HALF_PI+EPSILON or RE(Y) < -(HALF_PI+EPSILON) then FAILED("ARCTAN real part not in [-Pi/2,Pi/2] ", TESTS(I)); end if; if (IM(TESTS(I)) < 0.0 and IM(Y) > 0.0) or (IM(TESTS(I)) > 0.0 and IM(Y) < 0.0) then FAILED("ARCTAN sign imag part ", TESTS(I)); end if; if (RE(TESTS(I)) < 0.0 and RE(Y) > 0.0) or (RE(TESTS(I)) > 0.0 and RE(Y) < 0.0) then FAILED("ARCTAN sign of real part ", TESTS(I)); end if; if TESTS(I) = COMPLEX_ZERO then if Y = COMPLEX_ZERO then PASSED("ARCTAN(0+i0)=0+i0 ", TESTS(I)); else FAILED("ARCTAN(0+i0)=0+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on ARCTAN", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on ARCTAN", TESTS(I)); when CONSTRAINT_ERROR => if TESTS(I) = COMPLEX_I or TESTS(I) = -COMPLEX_I then PASSED("CONSTRAINT_ERROR raised on ARCTAN", TESTS(I)); else FAILED("CONSTRAINT_ERROR raised on ARCTAN", TESTS(I)); end if; when others => FAILED("unexpected exception on ARCTAN", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("ARCCOT testing"); for I in TESTS'RANGE loop begin Y := ARCCOT ( TESTS(I) ) ; if RE(Y) < 0.0 or RE(Y) > PI+EPSILON then FAILED("ARCCOT real part not in [0,Pi] ", TESTS(I)); end if; if (IM(TESTS(I)) < 0.0 and IM(Y) < 0.0) or (IM(TESTS(I)) > 0.0 and IM(Y) > 0.0) then FAILED("ARCCOT sign imag part ", TESTS(I)); end if; if TESTS(I) = COMPLEX_ZERO then if SAFE_INTERVAL(Y, PI2_LT, ZERO_LT) then PASSED("ARCCOT(0+i0)=Pi/2+i0 ", TESTS(I)); else FAILED("ARCCOT(0+i0)=Pi/2+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on ARCCOT", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on ARCCOT", TESTS(I)); when CONSTRAINT_ERROR => begin -- CONSTRAINT_ERROR OK if 1.0/(TESTS(I)+/-i) gives it Y := (1.0/(TESTS(I)-COMPLEX_I)) + (1.0/(TESTS(I)+COMPLEX_I)); FAILED("CONSTRAINT_ERROR raised on ARCCOT", TESTS(I)); exception when others => PASSED("CONSTRAINT_ERROR raised on ARCCOT", TESTS(I)); end; when others => FAILED("unexpected exception on ARCCOT", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("SINH testing"); for I in TESTS'RANGE loop begin Y := SINH ( TESTS(I) ) ; if TESTS(I) = COMPLEX_ZERO then if Y = COMPLEX_ZERO then PASSED("SINH(0+i0)=0+i0 ", TESTS(I)); else FAILED("SINH(0+i0)=0+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on SINH", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on SINH", TESTS(I)); when CONSTRAINT_ERROR => if RE(TESTS(I)) > LOG_LAST or RE(TESTS(I)) < -LOG_LAST then -- PASSED("CONSTRAINT_ERROR on SINH", TESTS(I)); null; elsif RE(TESTS(I)) < LOG_LARGE_2 and RE(TESTS(I)) > -LOG_LARGE_2 then FAILED("CONSTRAINT_ERROR on SINH", TESTS(I)); else PASSED("CONSTRAINT_ERROR on SINH", TESTS(I)); end if; when others => FAILED("unexpected exception on SINH", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("COSH testing"); for I in TESTS'RANGE loop begin Y := COSH ( TESTS(I) ) ; if TESTS(I) = COMPLEX_ZERO then if Y = COMPLEX_ONE then PASSED("COSH(0+i0)=1+i0 ", TESTS(I)); else FAILED("COSH(0+i0)=1+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on COSH", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on COSH", TESTS(I)); when CONSTRAINT_ERROR => if RE(TESTS(I)) > LOG_LAST or RE(TESTS(I)) < -LOG_LAST then -- PASSED("CONSTRAINT_ERROR on COSH", TESTS(I)); null; elsif RE(TESTS(I)) < LOG_LARGE_2 and RE(TESTS(I)) > -LOG_LARGE_2 then FAILED("CONSTRAINT_ERROR on COSH", TESTS(I)); else PASSED("CONSTRAINT_ERROR on COSH", TESTS(I)); end if; when others => FAILED("unexpected exception on COSH", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("TANH testing"); for I in TESTS'RANGE loop begin Y := TANH ( TESTS(I) ) ; if (RE(TESTS(I)) < 0.0 and RE(Y) > 0.0) or (RE(TESTS(I)) > 0.0 and RE(Y) < 0.0) then FAILED("TANH sign of real part ", TESTS(I)); end if; if TESTS(I) = COMPLEX_ZERO then if Y = COMPLEX_ZERO then PASSED("TANH(0+i0)=0+i0 ", TESTS(I)); else FAILED("TANH(0+i0)=0+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on TANH", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on TANH", TESTS(I)); when CONSTRAINT_ERROR => FAILED("CONSTRAINT_ERROR raised on TANH", TESTS(I)); when others => FAILED("unexpected exception on TANH", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("COTH testing"); for I in TESTS'RANGE loop begin Y := COTH ( TESTS(I) ) ; if (RE(TESTS(I)) < 0.0 and RE(Y) > 0.0) or (RE(TESTS(I)) > 0.0 and RE(Y) < 0.0) then FAILED("COTH sign of real part ", TESTS(I)); end if; -- PASSED("no exception on COTH", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on COTH", TESTS(I)); when CONSTRAINT_ERROR => begin -- CONSTRAINT_ERROR OK if 1.0/TESTS(I) gives it Y := 1.0 / TESTS(I); FAILED("CONSTRAINT_ERROR raised on COTH", TESTS(I)); exception when others => PASSED("CONSTRAINT_ERROR raised on COTH", TESTS(I)); end; when others => FAILED("unexpected exception on COTH", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("ARCSINH testing"); for I in TESTS'RANGE loop begin Y := ARCSINH ( TESTS(I) ) ; if IM(Y) > HALF_PI+EPSILON or IM(Y) < -(HALF_PI+EPSILON) then FAILED("ARCSINH imag part not in [-Pi/2,Pi/2] ", TESTS(I)); end if; if (IM(TESTS(I)) < 0.0 and IM(Y) > 0.0) or (IM(TESTS(I)) > 0.0 and IM(Y) < 0.0) then FAILED("ARCSINH sign imag part ", TESTS(I)); end if; if (RE(TESTS(I)) < 0.0 and RE(Y) > 0.0) or (RE(TESTS(I)) > 0.0 and RE(Y) < 0.0) then FAILED("ARCSINH sign of real part ", TESTS(I)); end if; if TESTS(I) = COMPLEX_ZERO then if Y = COMPLEX_ZERO then PASSED("ARCSINH(0+i0)=0+i0 ", TESTS(I)); else FAILED("ARCSINH(0+i0)=0+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on ARCSINH", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on ARCSINH", TESTS(I)); when CONSTRAINT_ERROR => FAILED("CONSTRAINT_ERROR raised on ARCSINH", TESTS(I)); when others => FAILED("unexpected exception on ARCSINH", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("ARCCOSH testing"); for I in TESTS'RANGE loop begin Y := ARCCOSH ( TESTS(I) ) ; if RE(Y) < 0.0 then FAILED("ARCCOSH real part < 0.0 ", TESTS(I)); end if; if IM(Y) > PI+EPSILON or IM(Y) < -(PI+EPSILON) then FAILED("ARCCOSH imag part not in [-Pi,Pi] ", TESTS(I)); end if; if (IM(TESTS(I)) < 0.0 and IM(Y) > 0.0) or (IM(TESTS(I)) > 0.0 and IM(Y) < 0.0) then FAILED("ARCCOSH sign imag part ", TESTS(I)); end if; if TESTS(I) = COMPLEX_ONE then if Y = COMPLEX_ZERO then PASSED("ARCCOSH(1+i0)=0+i0 ", TESTS(I)); else FAILED("ARCCOSH(1+i0)=0+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on ARCCOSH", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on ARCCOSH", TESTS(I)); when CONSTRAINT_ERROR => FAILED("CONSTRAINT_ERROR raised on ARCCOSH", TESTS(I)); when others => FAILED("unexpected exception on ARCCOSH", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("ARCTANH testing"); for I in TESTS'RANGE loop begin Y := ARCTANH ( TESTS(I) ) ; if IM(Y) > HALF_PI+EPSILON or IM(Y) < -(HALF_PI+EPSILON) then FAILED("ARCTANH imag part not in [-Pi/2,Pi/2] ", TESTS(I)); end if; if (IM(TESTS(I)) < 0.0 and IM(Y) > 0.0) or (IM(TESTS(I)) > 0.0 and IM(Y) < 0.0) then FAILED("ARCTANH sign imag part ", TESTS(I)); end if; if (RE(TESTS(I)) < 0.0 and RE(Y) > 0.0) or (RE(TESTS(I)) > 0.0 and RE(Y) < 0.0) then FAILED("ARCTANH sign of real part ", TESTS(I)); end if; if TESTS(I) = COMPLEX_ZERO then if Y = COMPLEX_ZERO then PASSED("ARCTANH(0+i0)=0+i0 ", TESTS(I)); else FAILED("ARCTANH(0+i0)=0+i0 ", TESTS(I)); end if; end if; -- PASSED("no exception on ARCTANH", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on ARCTANH", TESTS(I)); when CONSTRAINT_ERROR => -- only these exact values if TESTS(I) = COMPLEX_ONE or TESTS(I) = -COMPLEX_ONE then PASSED("CONSTRAINT_ERROR raised on ARCTANH", TESTS(I)); else FAILED("CONSTRAINT_ERROR raised on ARCTANH", TESTS(I)); end if; when others => FAILED("unexpected exception on ARCTANH", TESTS(I)); end; end loop; TEXT_IO.PUT_LINE("ARCCOTH testing"); for I in TESTS'RANGE loop begin Y := ARCCOTH ( TESTS(I) ) ; if IM(Y) < 0.0 or IM(Y) > PI+EPSILON then FAILED("ARCCOTH imag part not in [0,Pi] ", TESTS(I)); end if; if (RE(TESTS(I)) < 0.0 and RE(Y) > 0.0) or (RE(TESTS(I)) > 0.0 and RE(Y) < 0.0) then FAILED("ARCCOTH sign of real part ", TESTS(I)); end if; if TESTS(I) = COMPLEX_ZERO then if SAFE_INTERVAL(Y, ZERO_LT, PI2_LT) then PASSED("ARCCOTH(0+i0)=0+iPi/2 ", TESTS(I)); else FAILED("ARCCOTH(0+i0)=0+iPi/2 ", TESTS(I)); end if; end if; -- PASSED("no exception on ARCCOTH", TESTS(I)); exception when ARGUMENT_ERROR => FAILED("ARGUMENT_ERROR raised on ARCCOTH", TESTS(I)); when CONSTRAINT_ERROR => -- only these exact values if TESTS(I) = -COMPLEX_ONE or TESTS(I) = COMPLEX_ONE then PASSED("CONSTRAINT_ERROR raised on ARCCOTH", TESTS(I)); else FAILED("CONSTRAINT_ERROR raised on ARCCOTH", TESTS(I)); end if; when others => FAILED("unexpected exception on ARCCOTH", TESTS(I)); end; end loop; end TEST_GENERIC_COMPLEX_PRESCRIBED; -- Even if some of these compilation units fail, others will compile. -- The compliance test must be run on all that compile. with TEST_GENERIC_COMPLEX_PRESCRIBED; procedure TEST_COMPLEX_PRESCRIBED is new TEST_GENERIC_COMPLEX_PRESCRIBED ( FLOAT ) ; with TEST_GENERIC_COMPLEX_PRESCRIBED; procedure TEST_LONG_COMPLEX_PRESCRIBED is new TEST_GENERIC_COMPLEX_PRESCRIBED ( LONG_FLOAT ) ;