-- CXA5A10.A
|
-- CXA5A10.A
|
--
|
--
|
-- Grant of Unlimited Rights
|
-- Grant of Unlimited Rights
|
--
|
--
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- unlimited rights in the software and documentation contained herein.
|
-- unlimited rights in the software and documentation contained herein.
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- this public release, the Government intends to confer upon all
|
-- this public release, the Government intends to confer upon all
|
-- recipients unlimited rights equal to those held by the Government.
|
-- recipients unlimited rights equal to those held by the Government.
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- released technical data and computer software in whole or in part, in
|
-- released technical data and computer software in whole or in part, in
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- to do so.
|
-- to do so.
|
--
|
--
|
-- DISCLAIMER
|
-- DISCLAIMER
|
--
|
--
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
--*
|
--*
|
--
|
--
|
-- OBJECTIVE:
|
-- OBJECTIVE:
|
-- Check that the functions Exp and Sqrt, and the exponentiation
|
-- Check that the functions Exp and Sqrt, and the exponentiation
|
-- operator "**" provide correct results.
|
-- operator "**" provide correct results.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- This test examines both the versions of Exp, Sqrt, and "**"
|
-- This test examines both the versions of Exp, Sqrt, and "**"
|
-- resulting from the instantiation of the
|
-- resulting from the instantiation of the
|
-- Ada.Numerics.Generic_Elementary_Functions with a type derived from
|
-- Ada.Numerics.Generic_Elementary_Functions with a type derived from
|
-- type Float, as well as the preinstantiated version of this package
|
-- type Float, as well as the preinstantiated version of this package
|
-- for type Float.
|
-- for type Float.
|
-- Prescribed results (stated as such in the reference manual),
|
-- Prescribed results (stated as such in the reference manual),
|
-- including instances prescribed to raise exceptions, are examined
|
-- including instances prescribed to raise exceptions, are examined
|
-- in the test cases. In addition, certain evaluations are performed
|
-- in the test cases. In addition, certain evaluations are performed
|
-- for the preinstantiated package where the actual function result is
|
-- for the preinstantiated package where the actual function result is
|
-- compared with the expected result (within an epsilon range of
|
-- compared with the expected result (within an epsilon range of
|
-- accuracy).
|
-- accuracy).
|
--
|
--
|
-- TEST FILES:
|
-- TEST FILES:
|
-- The following files comprise this test:
|
-- The following files comprise this test:
|
--
|
--
|
-- FXA5A00.A (foundation code)
|
-- FXA5A00.A (foundation code)
|
-- CXA5A10.A
|
-- CXA5A10.A
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 17 Apr 95 SAIC Initial prerelease version.
|
-- 17 Apr 95 SAIC Initial prerelease version.
|
-- 13 Jun 95 SAIC Incorporated use of Dont_Optimize procedure, and
|
-- 13 Jun 95 SAIC Incorporated use of Dont_Optimize procedure, and
|
-- use of Result_Within_Range function overloaded for
|
-- use of Result_Within_Range function overloaded for
|
-- FXA5A00.New_Float_Type.
|
-- FXA5A00.New_Float_Type.
|
-- 18 Apr 96 SAIC Incorporated reviewer comments for ACVC 2.1.
|
-- 18 Apr 96 SAIC Incorporated reviewer comments for ACVC 2.1.
|
-- 01 Oct 01 RLB Protected Constraint_Error exception tests by
|
-- 01 Oct 01 RLB Protected Constraint_Error exception tests by
|
-- first testing for 'Machine_Overflows.
|
-- first testing for 'Machine_Overflows.
|
--
|
--
|
--!
|
--!
|
|
|
with Ada.Exceptions;
|
with Ada.Exceptions;
|
with Ada.Numerics.Elementary_Functions;
|
with Ada.Numerics.Elementary_Functions;
|
with Ada.Numerics.Generic_Elementary_Functions;
|
with Ada.Numerics.Generic_Elementary_Functions;
|
with FXA5A00;
|
with FXA5A00;
|
with Report;
|
with Report;
|
|
|
procedure CXA5A10 is
|
procedure CXA5A10 is
|
begin
|
begin
|
|
|
Report.Test ("CXA5A10", "Check that Exp, Sqrt, and the ""**"" operator " &
|
Report.Test ("CXA5A10", "Check that Exp, Sqrt, and the ""**"" operator " &
|
"provide correct results");
|
"provide correct results");
|
|
|
Test_Block:
|
Test_Block:
|
declare
|
declare
|
|
|
use FXA5A00, Ada.Numerics;
|
use FXA5A00, Ada.Numerics;
|
use Ada.Exceptions;
|
use Ada.Exceptions;
|
|
|
package GEF is new Ada.Numerics.Generic_Elementary_Functions(New_Float);
|
package GEF is new Ada.Numerics.Generic_Elementary_Functions(New_Float);
|
package EF renames Ada.Numerics.Elementary_Functions;
|
package EF renames Ada.Numerics.Elementary_Functions;
|
|
|
use GEF, EF;
|
use GEF, EF;
|
|
|
Arg,
|
Arg,
|
Float_Result : Float;
|
Float_Result : Float;
|
New_Float_Result : New_Float;
|
New_Float_Result : New_Float;
|
|
|
Flag_1, Flag_2, Flag_3, Flag_4,
|
Flag_1, Flag_2, Flag_3, Flag_4,
|
Incorrect_Inverse_Base_e,
|
Incorrect_Inverse_Base_e,
|
Incorrect_Inverse_Base_2,
|
Incorrect_Inverse_Base_2,
|
Incorrect_Inverse_Base_8,
|
Incorrect_Inverse_Base_8,
|
Incorrect_Inverse_Base_10,
|
Incorrect_Inverse_Base_10,
|
Incorrect_Inverse_Base_16 : Boolean := False;
|
Incorrect_Inverse_Base_16 : Boolean := False;
|
|
|
procedure Dont_Optimize_Float is new Dont_Optimize(Float);
|
procedure Dont_Optimize_Float is new Dont_Optimize(Float);
|
procedure Dont_Optimize_New_Float is new Dont_Optimize(New_Float);
|
procedure Dont_Optimize_New_Float is new Dont_Optimize(New_Float);
|
|
|
begin
|
begin
|
|
|
-- Testing of the "**" operator, both instantiated and pre-instantiated
|
-- Testing of the "**" operator, both instantiated and pre-instantiated
|
-- version.
|
-- version.
|
|
|
-- Check that Argument_Error is raised by the exponentiation operator
|
-- Check that Argument_Error is raised by the exponentiation operator
|
-- when the value of the Left parameter (operand) is negative.
|
-- when the value of the Left parameter (operand) is negative.
|
|
|
begin
|
begin
|
New_Float_Result := GEF."**"(Left => -10.0,
|
New_Float_Result := GEF."**"(Left => -10.0,
|
Right => 2.0);
|
Right => 2.0);
|
Report.Failed("Argument_Error not raised by the instantiated " &
|
Report.Failed("Argument_Error not raised by the instantiated " &
|
"version of the exponentiation operator when the " &
|
"version of the exponentiation operator when the " &
|
"value of the Left parameter is negative");
|
"value of the Left parameter is negative");
|
Dont_Optimize_New_Float(New_Float_Result, 1);
|
Dont_Optimize_New_Float(New_Float_Result, 1);
|
exception
|
exception
|
when Argument_Error => null; -- OK, expected exception.
|
when Argument_Error => null; -- OK, expected exception.
|
when others =>
|
when others =>
|
Report.Failed("Unexpected exception raised by the " &
|
Report.Failed("Unexpected exception raised by the " &
|
"instantiated version of the exponentiation " &
|
"instantiated version of the exponentiation " &
|
"operator when the value of the Left parameter " &
|
"operator when the value of the Left parameter " &
|
"is negative");
|
"is negative");
|
end;
|
end;
|
|
|
begin
|
begin
|
Float_Result := (-FXA5A00.Small) ** 4.0;
|
Float_Result := (-FXA5A00.Small) ** 4.0;
|
Report.Failed("Argument_Error not raised by the preinstantiated " &
|
Report.Failed("Argument_Error not raised by the preinstantiated " &
|
"version of the exponentiation operator when the " &
|
"version of the exponentiation operator when the " &
|
"value of the Left parameter is negative");
|
"value of the Left parameter is negative");
|
Dont_Optimize_Float(Float_Result, 2);
|
Dont_Optimize_Float(Float_Result, 2);
|
exception
|
exception
|
when Argument_Error => null; -- OK, expected exception.
|
when Argument_Error => null; -- OK, expected exception.
|
when others =>
|
when others =>
|
Report.Failed("Unexpected exception raised by the " &
|
Report.Failed("Unexpected exception raised by the " &
|
"preinstantiated version of the exponentiation " &
|
"preinstantiated version of the exponentiation " &
|
"operator when the value of the Left parameter " &
|
"operator when the value of the Left parameter " &
|
"is negative");
|
"is negative");
|
end;
|
end;
|
|
|
|
|
-- Check that Argument_Error is raised by the exponentiation operator
|
-- Check that Argument_Error is raised by the exponentiation operator
|
-- when both parameters (operands) have the value 0.0.
|
-- when both parameters (operands) have the value 0.0.
|
|
|
begin
|
begin
|
New_Float_Result := GEF."**"(0.0, Right => 0.0);
|
New_Float_Result := GEF."**"(0.0, Right => 0.0);
|
Report.Failed("Argument_Error not raised by the instantiated " &
|
Report.Failed("Argument_Error not raised by the instantiated " &
|
"version of the exponentiation operator when " &
|
"version of the exponentiation operator when " &
|
"both operands are zero");
|
"both operands are zero");
|
Dont_Optimize_New_Float(New_Float_Result, 3);
|
Dont_Optimize_New_Float(New_Float_Result, 3);
|
exception
|
exception
|
when Argument_Error => null; -- OK, expected exception.
|
when Argument_Error => null; -- OK, expected exception.
|
when others =>
|
when others =>
|
Report.Failed("Unexpected exception raised by the " &
|
Report.Failed("Unexpected exception raised by the " &
|
"instantiated version of the exponentiation " &
|
"instantiated version of the exponentiation " &
|
"operator when both operands are zero");
|
"operator when both operands are zero");
|
end;
|
end;
|
|
|
begin
|
begin
|
Float_Result := 0.0**0.0;
|
Float_Result := 0.0**0.0;
|
Report.Failed("Argument_Error not raised by the preinstantiated " &
|
Report.Failed("Argument_Error not raised by the preinstantiated " &
|
"version of the exponentiation operator when both " &
|
"version of the exponentiation operator when both " &
|
"operands are zero");
|
"operands are zero");
|
Dont_Optimize_Float(Float_Result, 4);
|
Dont_Optimize_Float(Float_Result, 4);
|
exception
|
exception
|
when Argument_Error => null; -- OK, expected exception.
|
when Argument_Error => null; -- OK, expected exception.
|
when others =>
|
when others =>
|
Report.Failed("Unexpected exception raised by the " &
|
Report.Failed("Unexpected exception raised by the " &
|
"preinstantiated version of the exponentiation " &
|
"preinstantiated version of the exponentiation " &
|
"operator when both operands are zero");
|
"operator when both operands are zero");
|
end;
|
end;
|
|
|
|
|
-- Check that Constraint_Error is raised by the exponentiation
|
-- Check that Constraint_Error is raised by the exponentiation
|
-- operator when the value of the left parameter (operand) is zero,
|
-- operator when the value of the left parameter (operand) is zero,
|
-- and the value of the right parameter (exponent) is negative.
|
-- and the value of the right parameter (exponent) is negative.
|
-- This check applies only if Machine_Overflows is true [A.5.1(28, 30)].
|
-- This check applies only if Machine_Overflows is true [A.5.1(28, 30)].
|
|
|
if New_Float'Machine_Overflows = True then
|
if New_Float'Machine_Overflows = True then
|
begin
|
begin
|
New_Float_Result := GEF."**"(0.0, Right => -2.0);
|
New_Float_Result := GEF."**"(0.0, Right => -2.0);
|
Report.Failed("Constraint_Error not raised by the instantiated " &
|
Report.Failed("Constraint_Error not raised by the instantiated " &
|
"version of the exponentiation operator when " &
|
"version of the exponentiation operator when " &
|
"the left parameter is 0.0, and the right " &
|
"the left parameter is 0.0, and the right " &
|
"parameter is negative");
|
"parameter is negative");
|
Dont_Optimize_New_Float(New_Float_Result, 5);
|
Dont_Optimize_New_Float(New_Float_Result, 5);
|
exception
|
exception
|
when Constraint_Error => null; -- OK, expected exception.
|
when Constraint_Error => null; -- OK, expected exception.
|
when others =>
|
when others =>
|
Report.Failed("Unexpected exception raised by the " &
|
Report.Failed("Unexpected exception raised by the " &
|
"instantiated version of the exponentiation " &
|
"instantiated version of the exponentiation " &
|
"operator when the left parameter is 0.0, " &
|
"operator when the left parameter is 0.0, " &
|
"and the right parameter is negative");
|
"and the right parameter is negative");
|
end;
|
end;
|
end if;
|
end if;
|
|
|
if Float'Machine_Overflows = True then
|
if Float'Machine_Overflows = True then
|
begin
|
begin
|
Float_Result := 0.0 ** (-FXA5A00.Small);
|
Float_Result := 0.0 ** (-FXA5A00.Small);
|
Report.Failed("Constraint_Error not raised by the " &
|
Report.Failed("Constraint_Error not raised by the " &
|
"preinstantiated version of the exponentiation " &
|
"preinstantiated version of the exponentiation " &
|
"operator when the left parameter is 0.0, and the " &
|
"operator when the left parameter is 0.0, and the " &
|
"right parameter is negative");
|
"right parameter is negative");
|
Dont_Optimize_Float(Float_Result, 6);
|
Dont_Optimize_Float(Float_Result, 6);
|
exception
|
exception
|
when Constraint_Error => null; -- OK, expected exception.
|
when Constraint_Error => null; -- OK, expected exception.
|
when others =>
|
when others =>
|
Report.Failed("Unexpected exception raised by the " &
|
Report.Failed("Unexpected exception raised by the " &
|
"preinstantiated version of the exponentiation " &
|
"preinstantiated version of the exponentiation " &
|
"operator when the left parameter is 0.0, and " &
|
"operator when the left parameter is 0.0, and " &
|
"the right parameter is negative");
|
"the right parameter is negative");
|
end;
|
end;
|
end if;
|
end if;
|
|
|
-- Prescribed results.
|
-- Prescribed results.
|
-- Check that exponentiation by a 0.0 exponent yields the value one.
|
-- Check that exponentiation by a 0.0 exponent yields the value one.
|
|
|
if GEF."**"(Left => 10.0, Right => 0.0) /= 1.0 or
|
if GEF."**"(Left => 10.0, Right => 0.0) /= 1.0 or
|
EF."**"(FXA5A00.Large, Right => 0.0) /= 1.0 or
|
EF."**"(FXA5A00.Large, Right => 0.0) /= 1.0 or
|
GEF."**"(3.0, 0.0) /= 1.0 or
|
GEF."**"(3.0, 0.0) /= 1.0 or
|
FXA5A00.Small ** 0.0 /= 1.0
|
FXA5A00.Small ** 0.0 /= 1.0
|
then
|
then
|
Report.Failed("Incorrect results returned from the ""**"" " &
|
Report.Failed("Incorrect results returned from the ""**"" " &
|
"operator when the value of the exponent is 0.0");
|
"operator when the value of the exponent is 0.0");
|
end if;
|
end if;
|
|
|
|
|
-- Check that exponentiation by a unit exponent yields the value
|
-- Check that exponentiation by a unit exponent yields the value
|
-- of the left operand.
|
-- of the left operand.
|
|
|
if GEF."**"(Left => 50.0, Right => 1.0) /= 50.0 or
|
if GEF."**"(Left => 50.0, Right => 1.0) /= 50.0 or
|
EF."**"(FXA5A00.Large, Right => 1.0) /= FXA5A00.Large or
|
EF."**"(FXA5A00.Large, Right => 1.0) /= FXA5A00.Large or
|
GEF."**"(6.0, 1.0) /= 6.0 or
|
GEF."**"(6.0, 1.0) /= 6.0 or
|
FXA5A00.Small ** 1.0 /= FXA5A00.Small
|
FXA5A00.Small ** 1.0 /= FXA5A00.Small
|
then
|
then
|
Report.Failed("Incorrect results returned from the ""**"" " &
|
Report.Failed("Incorrect results returned from the ""**"" " &
|
"operator when the value of the exponent is 1.0");
|
"operator when the value of the exponent is 1.0");
|
end if;
|
end if;
|
|
|
|
|
-- Check that exponentiation of the value 1.0 yields the value 1.0.
|
-- Check that exponentiation of the value 1.0 yields the value 1.0.
|
|
|
if GEF."**"(Left => 1.0, Right => 16.0) /= 1.0 or
|
if GEF."**"(Left => 1.0, Right => 16.0) /= 1.0 or
|
EF."**"(1.0, Right => FXA5A00.Large) /= 1.0 or
|
EF."**"(1.0, Right => FXA5A00.Large) /= 1.0 or
|
GEF."**"(1.0, 3.0) /= 1.0 or
|
GEF."**"(1.0, 3.0) /= 1.0 or
|
1.0 ** FXA5A00.Small /= 1.0
|
1.0 ** FXA5A00.Small /= 1.0
|
then
|
then
|
Report.Failed("Incorrect results returned from the ""**"" " &
|
Report.Failed("Incorrect results returned from the ""**"" " &
|
"operator when the value of the operand is 1.0");
|
"operator when the value of the operand is 1.0");
|
end if;
|
end if;
|
|
|
|
|
-- Check that exponentiation of the value 0.0 yields the value 0.0.
|
-- Check that exponentiation of the value 0.0 yields the value 0.0.
|
|
|
if GEF."**"(Left => 0.0, Right => 10.0) /= 0.0 or
|
if GEF."**"(Left => 0.0, Right => 10.0) /= 0.0 or
|
EF."**"(0.0, Right => FXA5A00.Large) /= 0.0 or
|
EF."**"(0.0, Right => FXA5A00.Large) /= 0.0 or
|
GEF."**"(0.0, 4.0) /= 0.0 or
|
GEF."**"(0.0, 4.0) /= 0.0 or
|
0.0 ** FXA5A00.Small /= 0.0
|
0.0 ** FXA5A00.Small /= 0.0
|
then
|
then
|
Report.Failed("Incorrect results returned from the ""**"" " &
|
Report.Failed("Incorrect results returned from the ""**"" " &
|
"operator when the value of the operand is 0.0");
|
"operator when the value of the operand is 0.0");
|
end if;
|
end if;
|
|
|
|
|
-- Check that exponentiation of various operands with a variety of
|
-- Check that exponentiation of various operands with a variety of
|
-- of exponent values yield correct results.
|
-- of exponent values yield correct results.
|
|
|
if not Result_Within_Range(GEF."**"(5.0, 2.0), 25.0, 0.01) or
|
if not Result_Within_Range(GEF."**"(5.0, 2.0), 25.0, 0.01) or
|
not Result_Within_Range(GEF."**"(1.225, 1.5), 1.36, 0.01) or
|
not Result_Within_Range(GEF."**"(1.225, 1.5), 1.36, 0.01) or
|
not Result_Within_Range(GEF."**"(0.26, 2.0), 0.068, 0.001) or
|
not Result_Within_Range(GEF."**"(0.26, 2.0), 0.068, 0.001) or
|
not Result_Within_Range( EF."**"(e, 5.0), 148.4, 0.1) or
|
not Result_Within_Range( EF."**"(e, 5.0), 148.4, 0.1) or
|
not Result_Within_Range( EF."**"(10.0, e), 522.7, 0.1) or
|
not Result_Within_Range( EF."**"(10.0, e), 522.7, 0.1) or
|
not Result_Within_Range( EF."**"(e, (-3.0)), 0.050, 0.001) or
|
not Result_Within_Range( EF."**"(e, (-3.0)), 0.050, 0.001) or
|
not Result_Within_Range(GEF."**"(10.0,(-2.0)), 0.010, 0.001)
|
not Result_Within_Range(GEF."**"(10.0,(-2.0)), 0.010, 0.001)
|
then
|
then
|
Report.Failed("Incorrect results returned from the ""**"" " &
|
Report.Failed("Incorrect results returned from the ""**"" " &
|
"operator with a variety of operand and exponent " &
|
"operator with a variety of operand and exponent " &
|
"values");
|
"values");
|
end if;
|
end if;
|
|
|
|
|
-- Use the following loops to check for internal consistency between
|
-- Use the following loops to check for internal consistency between
|
-- inverse functions.
|
-- inverse functions.
|
|
|
declare
|
declare
|
-- Use the relative error value to account for non-exact
|
-- Use the relative error value to account for non-exact
|
-- computations.
|
-- computations.
|
TC_Relative_Error: Float := 0.005;
|
TC_Relative_Error: Float := 0.005;
|
begin
|
begin
|
for i in 1..5 loop
|
for i in 1..5 loop
|
for j in 0..5 loop
|
for j in 0..5 loop
|
if not Incorrect_Inverse_Base_e and
|
if not Incorrect_Inverse_Base_e and
|
not FXA5A00.Result_Within_Range
|
not FXA5A00.Result_Within_Range
|
(Float(i)**Float(j),
|
(Float(i)**Float(j),
|
e**(Float(j)*EF.Log(Float(i))),
|
e**(Float(j)*EF.Log(Float(i))),
|
TC_Relative_Error)
|
TC_Relative_Error)
|
then
|
then
|
Incorrect_Inverse_Base_e := True;
|
Incorrect_Inverse_Base_e := True;
|
Report.Failed("Incorrect Log-** Inverse calc for Base e " &
|
Report.Failed("Incorrect Log-** Inverse calc for Base e " &
|
"with i= " & Integer'Image(i) & " and j= " &
|
"with i= " & Integer'Image(i) & " and j= " &
|
Integer'Image(j));
|
Integer'Image(j));
|
end if;
|
end if;
|
if not Incorrect_Inverse_Base_2 and
|
if not Incorrect_Inverse_Base_2 and
|
not FXA5A00.Result_Within_Range
|
not FXA5A00.Result_Within_Range
|
(Float(i)**Float(j),
|
(Float(i)**Float(j),
|
2.0**(Float(j)*EF.Log(Float(i),2.0)),
|
2.0**(Float(j)*EF.Log(Float(i),2.0)),
|
TC_Relative_Error)
|
TC_Relative_Error)
|
then
|
then
|
Incorrect_Inverse_Base_2 := True;
|
Incorrect_Inverse_Base_2 := True;
|
Report.Failed("Incorrect Log-** Inverse calc for Base 2 " &
|
Report.Failed("Incorrect Log-** Inverse calc for Base 2 " &
|
"with i= " & Integer'Image(i) & " and j= " &
|
"with i= " & Integer'Image(i) & " and j= " &
|
Integer'Image(j));
|
Integer'Image(j));
|
end if;
|
end if;
|
if not Incorrect_Inverse_Base_8 and
|
if not Incorrect_Inverse_Base_8 and
|
not FXA5A00.Result_Within_Range
|
not FXA5A00.Result_Within_Range
|
(Float(i)**Float(j),
|
(Float(i)**Float(j),
|
8.0**(Float(j)*EF.Log(Float(i),8.0)),
|
8.0**(Float(j)*EF.Log(Float(i),8.0)),
|
TC_Relative_Error)
|
TC_Relative_Error)
|
then
|
then
|
Incorrect_Inverse_Base_8 := True;
|
Incorrect_Inverse_Base_8 := True;
|
Report.Failed("Incorrect Log-** Inverse calc for Base 8 " &
|
Report.Failed("Incorrect Log-** Inverse calc for Base 8 " &
|
"with i= " & Integer'Image(i) & " and j= " &
|
"with i= " & Integer'Image(i) & " and j= " &
|
Integer'Image(j));
|
Integer'Image(j));
|
end if;
|
end if;
|
if not Incorrect_Inverse_Base_10 and
|
if not Incorrect_Inverse_Base_10 and
|
not FXA5A00.Result_Within_Range
|
not FXA5A00.Result_Within_Range
|
(Float(i)**Float(j),
|
(Float(i)**Float(j),
|
10.0**(Float(j)*EF.Log(Float(i),10.0)),
|
10.0**(Float(j)*EF.Log(Float(i),10.0)),
|
TC_Relative_Error)
|
TC_Relative_Error)
|
then
|
then
|
Incorrect_Inverse_Base_10 := True;
|
Incorrect_Inverse_Base_10 := True;
|
Report.Failed("Incorrect Log-** Inverse calc for Base 10 " &
|
Report.Failed("Incorrect Log-** Inverse calc for Base 10 " &
|
"with i= " & Integer'Image(i) & " and j= " &
|
"with i= " & Integer'Image(i) & " and j= " &
|
Integer'Image(j));
|
Integer'Image(j));
|
end if;
|
end if;
|
if not Incorrect_Inverse_Base_16 and
|
if not Incorrect_Inverse_Base_16 and
|
not FXA5A00.Result_Within_Range
|
not FXA5A00.Result_Within_Range
|
(Float(i)**Float(j),
|
(Float(i)**Float(j),
|
16.0**(Float(j)*EF.Log(Float(i),16.0)),
|
16.0**(Float(j)*EF.Log(Float(i),16.0)),
|
TC_Relative_Error)
|
TC_Relative_Error)
|
then
|
then
|
Incorrect_Inverse_Base_16 := True;
|
Incorrect_Inverse_Base_16 := True;
|
Report.Failed("Incorrect Log-** Inverse calc for Base 16 " &
|
Report.Failed("Incorrect Log-** Inverse calc for Base 16 " &
|
"with i= " & Integer'Image(i) & " and j= " &
|
"with i= " & Integer'Image(i) & " and j= " &
|
Integer'Image(j));
|
Integer'Image(j));
|
end if;
|
end if;
|
end loop;
|
end loop;
|
end loop;
|
end loop;
|
end;
|
end;
|
|
|
-- Reset Flags.
|
-- Reset Flags.
|
Incorrect_Inverse_Base_e := False;
|
Incorrect_Inverse_Base_e := False;
|
Incorrect_Inverse_Base_2 := False;
|
Incorrect_Inverse_Base_2 := False;
|
Incorrect_Inverse_Base_8 := False;
|
Incorrect_Inverse_Base_8 := False;
|
Incorrect_Inverse_Base_10 := False;
|
Incorrect_Inverse_Base_10 := False;
|
Incorrect_Inverse_Base_16 := False;
|
Incorrect_Inverse_Base_16 := False;
|
|
|
|
|
-- Testing of Exp Function, both instantiated and pre-instantiated
|
-- Testing of Exp Function, both instantiated and pre-instantiated
|
-- version.
|
-- version.
|
|
|
-- Check that the result of the Exp Function, when provided an X
|
-- Check that the result of the Exp Function, when provided an X
|
-- parameter value of 0.0, is 1.0.
|
-- parameter value of 0.0, is 1.0.
|
|
|
if GEF.Exp(X => 0.0) /= 1.0 or
|
if GEF.Exp(X => 0.0) /= 1.0 or
|
EF.Exp(0.0) /= 1.0
|
EF.Exp(0.0) /= 1.0
|
then
|
then
|
Report.Failed("Incorrect result returned by Function Exp when " &
|
Report.Failed("Incorrect result returned by Function Exp when " &
|
"given a parameter value of 0.0");
|
"given a parameter value of 0.0");
|
end if;
|
end if;
|
|
|
|
|
-- Check that the Exp Function provides correct results when provided
|
-- Check that the Exp Function provides correct results when provided
|
-- a variety of input parameter values.
|
-- a variety of input parameter values.
|
|
|
if not Result_Within_Range(GEF.Exp(0.001), 1.01, 0.01) or
|
if not Result_Within_Range(GEF.Exp(0.001), 1.01, 0.01) or
|
not Result_Within_Range( EF.Exp(0.1), 1.11, 0.01) or
|
not Result_Within_Range( EF.Exp(0.1), 1.11, 0.01) or
|
not Result_Within_Range(GEF.Exp(1.2697), 3.56, 0.01) or
|
not Result_Within_Range(GEF.Exp(1.2697), 3.56, 0.01) or
|
not Result_Within_Range( EF.Exp(3.2525), 25.9, 0.1) or
|
not Result_Within_Range( EF.Exp(3.2525), 25.9, 0.1) or
|
not Result_Within_Range(GEF.Exp(-0.2198), 0.803, 0.001) or
|
not Result_Within_Range(GEF.Exp(-0.2198), 0.803, 0.001) or
|
not Result_Within_Range( EF.Exp(-1.6621), 0.190, 0.001) or
|
not Result_Within_Range( EF.Exp(-1.6621), 0.190, 0.001) or
|
not Result_Within_Range(GEF.Exp(-2.3888), 0.092, 0.001) or
|
not Result_Within_Range(GEF.Exp(-2.3888), 0.092, 0.001) or
|
not Result_Within_Range( EF.Exp(-5.4415), 0.004, 0.001)
|
not Result_Within_Range( EF.Exp(-5.4415), 0.004, 0.001)
|
then
|
then
|
Report.Failed("Incorrect result from Function Exp when provided " &
|
Report.Failed("Incorrect result from Function Exp when provided " &
|
"a variety of input parameter values");
|
"a variety of input parameter values");
|
end if;
|
end if;
|
|
|
-- Use the following loops to check for internal consistency between
|
-- Use the following loops to check for internal consistency between
|
-- inverse functions.
|
-- inverse functions.
|
|
|
Arg := 0.01;
|
Arg := 0.01;
|
while Arg < 10.0 loop
|
while Arg < 10.0 loop
|
if not Incorrect_Inverse_Base_e and
|
if not Incorrect_Inverse_Base_e and
|
FXA5A00.Result_Within_Range(EF.Exp(Arg),
|
FXA5A00.Result_Within_Range(EF.Exp(Arg),
|
e**(Arg*EF.Log(Arg)),
|
e**(Arg*EF.Log(Arg)),
|
0.001)
|
0.001)
|
then
|
then
|
Incorrect_Inverse_Base_e := True;
|
Incorrect_Inverse_Base_e := True;
|
Report.Failed("Incorrect Exp-** Inverse calc for Base e");
|
Report.Failed("Incorrect Exp-** Inverse calc for Base e");
|
end if;
|
end if;
|
if not Incorrect_Inverse_Base_2 and
|
if not Incorrect_Inverse_Base_2 and
|
FXA5A00.Result_Within_Range(EF.Exp(Arg),
|
FXA5A00.Result_Within_Range(EF.Exp(Arg),
|
2.0**(Arg*EF.Log(Arg,2.0)),
|
2.0**(Arg*EF.Log(Arg,2.0)),
|
0.001)
|
0.001)
|
then
|
then
|
Incorrect_Inverse_Base_2 := True;
|
Incorrect_Inverse_Base_2 := True;
|
Report.Failed("Incorrect Exp-** Inverse calc for Base 2");
|
Report.Failed("Incorrect Exp-** Inverse calc for Base 2");
|
end if;
|
end if;
|
if not Incorrect_Inverse_Base_8 and
|
if not Incorrect_Inverse_Base_8 and
|
FXA5A00.Result_Within_Range(EF.Exp(Arg),
|
FXA5A00.Result_Within_Range(EF.Exp(Arg),
|
8.0**(Arg*EF.Log(Arg,8.0)),
|
8.0**(Arg*EF.Log(Arg,8.0)),
|
0.001)
|
0.001)
|
then
|
then
|
Incorrect_Inverse_Base_8 := True;
|
Incorrect_Inverse_Base_8 := True;
|
Report.Failed("Incorrect Exp-** Inverse calc for Base 8");
|
Report.Failed("Incorrect Exp-** Inverse calc for Base 8");
|
end if;
|
end if;
|
if not Incorrect_Inverse_Base_10 and
|
if not Incorrect_Inverse_Base_10 and
|
FXA5A00.Result_Within_Range(EF.Exp(Arg),
|
FXA5A00.Result_Within_Range(EF.Exp(Arg),
|
10.0**(Arg*EF.Log(Arg,10.0)),
|
10.0**(Arg*EF.Log(Arg,10.0)),
|
0.001)
|
0.001)
|
then
|
then
|
Incorrect_Inverse_Base_10 := True;
|
Incorrect_Inverse_Base_10 := True;
|
Report.Failed("Incorrect Exp-** Inverse calc for Base 10");
|
Report.Failed("Incorrect Exp-** Inverse calc for Base 10");
|
end if;
|
end if;
|
if not Incorrect_Inverse_Base_16 and
|
if not Incorrect_Inverse_Base_16 and
|
FXA5A00.Result_Within_Range(EF.Exp(Arg),
|
FXA5A00.Result_Within_Range(EF.Exp(Arg),
|
16.0**(Arg*EF.Log(Arg,16.0)),
|
16.0**(Arg*EF.Log(Arg,16.0)),
|
0.001)
|
0.001)
|
then
|
then
|
Incorrect_Inverse_Base_16 := True;
|
Incorrect_Inverse_Base_16 := True;
|
Report.Failed("Incorrect Exp-** Inverse calc for Base 16");
|
Report.Failed("Incorrect Exp-** Inverse calc for Base 16");
|
end if;
|
end if;
|
Arg := Arg + 0.01;
|
Arg := Arg + 0.01;
|
end loop;
|
end loop;
|
|
|
|
|
-- Testing of Sqrt Function, both instantiated and pre-instantiated
|
-- Testing of Sqrt Function, both instantiated and pre-instantiated
|
-- version.
|
-- version.
|
|
|
-- Check that Argument_Error is raised by the Sqrt Function when
|
-- Check that Argument_Error is raised by the Sqrt Function when
|
-- the value of the input parameter X is negative.
|
-- the value of the input parameter X is negative.
|
|
|
begin
|
begin
|
Float_Result := EF.Sqrt(X => -FXA5A00.Small);
|
Float_Result := EF.Sqrt(X => -FXA5A00.Small);
|
Report.Failed("Argument_Error not raised by Function Sqrt " &
|
Report.Failed("Argument_Error not raised by Function Sqrt " &
|
"when provided a small negative input parameter " &
|
"when provided a small negative input parameter " &
|
"value");
|
"value");
|
Dont_Optimize_Float(Float_Result, 7);
|
Dont_Optimize_Float(Float_Result, 7);
|
exception
|
exception
|
when Argument_Error => null; -- OK, expected exception.
|
when Argument_Error => null; -- OK, expected exception.
|
when others =>
|
when others =>
|
Report.Failed("Unexpected exception raised by Function Sqrt " &
|
Report.Failed("Unexpected exception raised by Function Sqrt " &
|
"when provided a small negative input parameter " &
|
"when provided a small negative input parameter " &
|
"value");
|
"value");
|
end;
|
end;
|
|
|
begin
|
begin
|
New_Float_Result := GEF.Sqrt(X => -64.0);
|
New_Float_Result := GEF.Sqrt(X => -64.0);
|
Report.Failed("Argument_Error not raised by Function Sqrt " &
|
Report.Failed("Argument_Error not raised by Function Sqrt " &
|
"when provided a large negative input parameter " &
|
"when provided a large negative input parameter " &
|
"value");
|
"value");
|
Dont_Optimize_New_Float(New_Float_Result, 8);
|
Dont_Optimize_New_Float(New_Float_Result, 8);
|
exception
|
exception
|
when Argument_Error => null; -- OK, expected exception.
|
when Argument_Error => null; -- OK, expected exception.
|
when others =>
|
when others =>
|
Report.Failed("Unexpected exception raised by Function Sqrt " &
|
Report.Failed("Unexpected exception raised by Function Sqrt " &
|
"when provided a large negative input parameter " &
|
"when provided a large negative input parameter " &
|
"value");
|
"value");
|
end;
|
end;
|
|
|
|
|
-- Check that the Sqrt Function, when given an X parameter value of 0.0,
|
-- Check that the Sqrt Function, when given an X parameter value of 0.0,
|
-- returns a result of 0.0.
|
-- returns a result of 0.0.
|
|
|
if GEF.Sqrt(X => 0.0) /= 0.0 or
|
if GEF.Sqrt(X => 0.0) /= 0.0 or
|
EF.Sqrt(0.0) /= 0.0
|
EF.Sqrt(0.0) /= 0.0
|
then
|
then
|
Report.Failed("Incorrect result from Function Sqrt when provided " &
|
Report.Failed("Incorrect result from Function Sqrt when provided " &
|
"an input parameter value of 0.0");
|
"an input parameter value of 0.0");
|
end if;
|
end if;
|
|
|
|
|
-- Check that the Sqrt Function, when given an X parameter input value
|
-- Check that the Sqrt Function, when given an X parameter input value
|
-- of 1.0, returns a result of 1.0.
|
-- of 1.0, returns a result of 1.0.
|
|
|
if GEF.Sqrt(X => 1.0) /= 1.0 or
|
if GEF.Sqrt(X => 1.0) /= 1.0 or
|
EF.Sqrt(1.0) /= 1.0
|
EF.Sqrt(1.0) /= 1.0
|
then
|
then
|
Report.Failed("Incorrect result from Function Sqrt when provided " &
|
Report.Failed("Incorrect result from Function Sqrt when provided " &
|
"an input parameter value of 1.0");
|
"an input parameter value of 1.0");
|
end if;
|
end if;
|
|
|
|
|
-- Check that the Sqrt Function provides correct results when provided
|
-- Check that the Sqrt Function provides correct results when provided
|
-- a variety of input parameter values.
|
-- a variety of input parameter values.
|
|
|
if not FXA5A00.Result_Within_Range(GEF.Sqrt(0.0327), 0.181, 0.001) or
|
if not FXA5A00.Result_Within_Range(GEF.Sqrt(0.0327), 0.181, 0.001) or
|
not FXA5A00.Result_Within_Range( EF.Sqrt(0.1808), 0.425, 0.001) or
|
not FXA5A00.Result_Within_Range( EF.Sqrt(0.1808), 0.425, 0.001) or
|
not FXA5A00.Result_Within_Range(GEF.Sqrt(1.0556), 1.03, 0.01) or
|
not FXA5A00.Result_Within_Range(GEF.Sqrt(1.0556), 1.03, 0.01) or
|
not FXA5A00.Result_Within_Range( EF.Sqrt(32.8208), 5.73, 0.01) or
|
not FXA5A00.Result_Within_Range( EF.Sqrt(32.8208), 5.73, 0.01) or
|
not FXA5A00.Result_Within_Range( EF.Sqrt(27851.0), 166.9, 0.1) or
|
not FXA5A00.Result_Within_Range( EF.Sqrt(27851.0), 166.9, 0.1) or
|
not FXA5A00.Result_Within_Range( EF.Sqrt(61203.4), 247.4, 0.1) or
|
not FXA5A00.Result_Within_Range( EF.Sqrt(61203.4), 247.4, 0.1) or
|
not FXA5A00.Result_Within_Range( EF.Sqrt(655891.0), 809.9, 0.1)
|
not FXA5A00.Result_Within_Range( EF.Sqrt(655891.0), 809.9, 0.1)
|
then
|
then
|
Report.Failed("Incorrect result from Function Sqrt when provided " &
|
Report.Failed("Incorrect result from Function Sqrt when provided " &
|
"a variety of input parameter values");
|
"a variety of input parameter values");
|
end if;
|
end if;
|
|
|
-- Check internal consistency between functions.
|
-- Check internal consistency between functions.
|
|
|
Arg := 0.01;
|
Arg := 0.01;
|
while Arg < 10.0 loop
|
while Arg < 10.0 loop
|
if not Flag_1 and
|
if not Flag_1 and
|
not FXA5A00.Result_Within_Range(Arg,
|
not FXA5A00.Result_Within_Range(Arg,
|
EF.Sqrt(Arg)*EF.Sqrt(Arg),
|
EF.Sqrt(Arg)*EF.Sqrt(Arg),
|
0.01)
|
0.01)
|
then
|
then
|
Report.Failed("Inconsistency found in Case 1");
|
Report.Failed("Inconsistency found in Case 1");
|
Flag_1 := True;
|
Flag_1 := True;
|
end if;
|
end if;
|
if not Flag_2 and
|
if not Flag_2 and
|
not FXA5A00.Result_Within_Range(Arg, EF.Sqrt(Arg)**2.0, 0.01)
|
not FXA5A00.Result_Within_Range(Arg, EF.Sqrt(Arg)**2.0, 0.01)
|
then
|
then
|
Report.Failed("Inconsistency found in Case 2");
|
Report.Failed("Inconsistency found in Case 2");
|
Flag_2 := True;
|
Flag_2 := True;
|
end if;
|
end if;
|
if not Flag_3 and
|
if not Flag_3 and
|
not FXA5A00.Result_Within_Range(EF.Log(Arg),
|
not FXA5A00.Result_Within_Range(EF.Log(Arg),
|
EF.Log(Sqrt(Arg)**2.0), 0.01)
|
EF.Log(Sqrt(Arg)**2.0), 0.01)
|
then
|
then
|
Report.Failed("Inconsistency found in Case 3");
|
Report.Failed("Inconsistency found in Case 3");
|
Flag_3 := True;
|
Flag_3 := True;
|
end if;
|
end if;
|
if not Flag_4 and
|
if not Flag_4 and
|
not FXA5A00.Result_Within_Range(EF.Log(Arg),
|
not FXA5A00.Result_Within_Range(EF.Log(Arg),
|
2.00*EF.Log(EF.Sqrt(Arg)),
|
2.00*EF.Log(EF.Sqrt(Arg)),
|
0.01)
|
0.01)
|
then
|
then
|
Report.Failed("Inconsistency found in Case 4");
|
Report.Failed("Inconsistency found in Case 4");
|
Flag_4 := True;
|
Flag_4 := True;
|
end if;
|
end if;
|
Arg := Arg + 1.0;
|
Arg := Arg + 1.0;
|
end loop;
|
end loop;
|
|
|
|
|
exception
|
exception
|
when The_Error : others =>
|
when The_Error : others =>
|
Report.Failed ("The following exception was raised in the " &
|
Report.Failed ("The following exception was raised in the " &
|
"Test_Block: " & Exception_Name(The_Error));
|
"Test_Block: " & Exception_Name(The_Error));
|
end Test_Block;
|
end Test_Block;
|
|
|
Report.Result;
|
Report.Result;
|
|
|
end CXA5A10;
|
end CXA5A10;
|
|
|