diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-12-01 08:10:14 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-12-01 19:42:06 +0100 |
commit | 1570a52a2f6d326696841853471afb5a17efb7ca (patch) | |
tree | 80f4655dcdc7dd7134556f28be792dd77d63f09d /libraries | |
parent | bde1e82a42b1c6468726434f35f80f06c4f83704 (diff) | |
download | ghdl-1570a52a2f6d326696841853471afb5a17efb7ca.tar.gz ghdl-1570a52a2f6d326696841853471afb5a17efb7ca.tar.bz2 ghdl-1570a52a2f6d326696841853471afb5a17efb7ca.zip |
library/ieee: re-import math_real and math_complex from vhdl 2019.
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/ieee/math_complex-body.vhdl | 218 | ||||
-rw-r--r-- | libraries/ieee/math_complex.vhdl | 2162 | ||||
-rw-r--r-- | libraries/ieee/math_real-body.vhdl | 230 | ||||
-rw-r--r-- | libraries/ieee/math_real.vhdl | 1247 |
4 files changed, 1917 insertions, 1940 deletions
diff --git a/libraries/ieee/math_complex-body.vhdl b/libraries/ieee/math_complex-body.vhdl index 97fb6bbdf..6245b8eca 100644 --- a/libraries/ieee/math_complex-body.vhdl +++ b/libraries/ieee/math_complex-body.vhdl @@ -1,53 +1,52 @@ ------------------------------------------------------------------------- +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- --- Copyright 1996 by IEEE. All rights reserved. --- --- This source file is an informative part of IEEE Std 1076.2-1996, IEEE Standard --- VHDL Mathematical Packages. This source file may not be copied, sold, or --- included with software that is sold without written permission from the IEEE --- Standards Department. This source file may be used to implement this standard --- and may be distributed in compiled form in any manner so long as the --- compiled form does not allow direct decompilation of the original source file. --- This source file may be copied for individual use between licensed users. --- This source file is provided on an AS IS basis. The IEEE disclaims ANY --- WARRANTY EXPRESS OR IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY --- AND FITNESS FOR USE FOR A PARTICULAR PURPOSE. The user of the source --- file shall indemnify and hold IEEE harmless from any damages or liability --- arising out of the use thereof. --- --- Title: Standard VHDL Mathematical Packages (IEEE Std 1076.2-1996, --- MATH_COMPLEX) --- --- Library: This package shall be compiled into a library --- symbolically named IEEE. --- --- Developers: IEEE DASC VHDL Mathematical Packages Working Group --- --- Purpose: This package body is a nonnormative implementation of the --- functionality defined in the MATH_COMPLEX package declaration. --- --- Limitation: The values generated by the functions in this package may --- vary from platform to platform, and the precision of results --- is only guaranteed to be the minimum required by IEEE Std 1076 --- -1993. --- --- Notes: --- The "package declaration" defines the types, subtypes, and --- declarations of MATH_COMPLEX. --- The standard mathematical definition and conventional meaning --- of the mathematical functions that are part of this standard --- represent the formal semantics of the implementation of the --- MATH_COMPLEX package declaration. The purpose of the --- MATH_COMPLEX package body is to clarify such semantics and --- provide a guideline for implementations to verify their --- implementation of MATH_COMPLEX. Tool developers may choose to --- implement the package body in the most efficient manner --- available to them. --- --- ----------------------------------------------------------------------------- --- Version : 1.5 --- Date : 24 July 1996 --- ----------------------------------------------------------------------------- +-- Title : Standard VHDL Mathematical Packages +-- : (MATH_COMPLEX package body) +-- : +-- Library : This package shall be compiled into a library +-- : symbolically named IEEE. +-- : +-- Developers: IEEE DASC VHDL Mathematical Packages Working Group +-- : +-- Purpose : This package defines a standard for designers to use in +-- : describing VHDL models that make use of common COMPLEX +-- : constants and common COMPLEX mathematical functions and +-- : operators. +-- : +-- Limitation: The values generated by the functions in this package +-- : may vary from platform to platform, and the precision +-- : of results is only guaranteed to be the minimum required +-- : by IEEE Std 1076-2008. +-- : +-- Note : This package may be modified to include additional data +-- : required by tools, but it must in no way change the +-- : external interfaces or simulation behavior of the +-- : description. It is permissible to add comments and/or +-- : attributes to the package declarations, but not to change +-- : or delete any original lines of the package declaration. +-- : The package body may be changed only in accordance with +-- : the terms of Clause 16 of this standard. +-- : +-- -------------------------------------------------------------------- +-- $Revision: 1220 $ +-- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ +-- -------------------------------------------------------------------- use WORK.MATH_REAL.all; @@ -89,7 +88,7 @@ package body MATH_COMPLEX is end if; return FALSE; - end "="; + end function "="; function "/=" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR ) return BOOLEAN @@ -125,7 +124,7 @@ package body MATH_COMPLEX is end if; return TRUE; - end "/="; + end function "/="; -- -- Other Functions Start Here @@ -138,7 +137,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(X, Y); - end CMPLX; + end function CMPLX; function GET_PRINCIPAL_VALUE(X: in REAL ) return PRINCIPAL_VALUE is @@ -163,7 +162,7 @@ package body MATH_COMPLEX is end loop; return PRINCIPAL_VALUE'(TEMP); - end GET_PRINCIPAL_VALUE; + end function GET_PRINCIPAL_VALUE; function COMPLEX_TO_POLAR(Z: in COMPLEX ) return COMPLEX_POLAR is -- Description: @@ -198,7 +197,7 @@ package body MATH_COMPLEX is return COMPLEX_POLAR'(SQRT(Z.RE*Z.RE + Z.IM*Z.IM), GET_PRINCIPAL_VALUE(TEMP)); - end COMPLEX_TO_POLAR; + end function COMPLEX_TO_POLAR; function POLAR_TO_COMPLEX(Z: in COMPLEX_POLAR ) return COMPLEX is -- Description: @@ -216,7 +215,7 @@ package body MATH_COMPLEX is -- Get value for general case return COMPLEX'( Z.MAG*COS(Z.ARG), Z.MAG*SIN(Z.ARG) ); - end POLAR_TO_COMPLEX; + end function POLAR_TO_COMPLEX; function "ABS"(Z: in COMPLEX ) return POSITIVE_REAL is @@ -228,7 +227,7 @@ package body MATH_COMPLEX is begin -- Get value for general case return POSITIVE_REAL'(SQRT(Z.RE*Z.RE + Z.IM*Z.IM)); - end "ABS"; + end function "ABS"; function "ABS"(Z: in COMPLEX_POLAR ) return POSITIVE_REAL is -- Description: @@ -248,7 +247,7 @@ package body MATH_COMPLEX is -- Get value for general case return Z.MAG; - end "ABS"; + end function "ABS"; function ARG(Z: in COMPLEX ) return PRINCIPAL_VALUE is @@ -262,7 +261,7 @@ package body MATH_COMPLEX is -- Get value for general case ZTEMP := COMPLEX_TO_POLAR(Z); return ZTEMP.ARG; - end ARG; + end function ARG; function ARG(Z: in COMPLEX_POLAR ) return PRINCIPAL_VALUE is -- Description: @@ -282,7 +281,7 @@ package body MATH_COMPLEX is -- Get value for general case return Z.ARG; - end ARG; + end function ARG; function "-" (Z: in COMPLEX ) return COMPLEX is -- Description: @@ -292,7 +291,7 @@ package body MATH_COMPLEX is begin -- Get value for general case return COMPLEX'(-Z.RE, -Z.IM); - end "-"; + end function "-"; function "-" (Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -314,7 +313,7 @@ package body MATH_COMPLEX is TEMP := REAL'(Z.ARG) + MATH_PI; return COMPLEX_POLAR'(Z.MAG, GET_PRINCIPAL_VALUE(TEMP)); - end "-"; + end function "-"; function CONJ (Z: in COMPLEX) return COMPLEX is -- Description: @@ -324,7 +323,7 @@ package body MATH_COMPLEX is begin -- Get value for general case return COMPLEX'(Z.RE, -Z.IM); - end CONJ; + end function CONJ; function CONJ (Z: in COMPLEX_POLAR) return COMPLEX_POLAR is -- Description: @@ -351,7 +350,7 @@ package body MATH_COMPLEX is end if; return COMPLEX_POLAR'(Z.MAG, TEMP); - end CONJ; + end function CONJ; function SQRT(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -394,7 +393,7 @@ package body MATH_COMPLEX is ZOUT.RE := 0.0; ZOUT.IM := TMAG*SIN(TARG + MATH_PI); return ZOUT; - end SQRT; + end function SQRT; function SQRT(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -435,7 +434,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(TARG); return ZOUT; - end SQRT; + end function SQRT; function EXP(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -467,7 +466,7 @@ package body MATH_COMPLEX is -- Get value for general case TEMP := EXP(Z.RE); return COMPLEX'(TEMP*COS(Z.IM), TEMP*SIN(Z.IM)); - end EXP; + end function EXP; function EXP(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -476,7 +475,6 @@ package body MATH_COMPLEX is -- a) Returns Z on error variable ZTEMP : COMPLEX; - variable temp: REAL; variable ZOUT : COMPLEX_POLAR; begin -- Check validity of input arguments @@ -513,7 +511,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(ZTEMP.IM); return ZOUT; - end EXP; + end function EXP; function LOG(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -558,7 +556,7 @@ package body MATH_COMPLEX is ZTEMP := COMPLEX_TO_POLAR(Z); TEMP := LOG(ZTEMP.MAG); return COMPLEX'(TEMP, ZTEMP.ARG); - end LOG; + end function LOG; function LOG2(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -592,7 +590,7 @@ package body MATH_COMPLEX is ZTEMP := COMPLEX_TO_POLAR(Z); TEMP := MATH_LOG2_OF_E*LOG(ZTEMP.MAG); return COMPLEX'(TEMP, MATH_LOG2_OF_E*ZTEMP.ARG); - end LOG2; + end function LOG2; function LOG10(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -625,7 +623,7 @@ package body MATH_COMPLEX is ZTEMP := COMPLEX_TO_POLAR(Z); TEMP := MATH_LOG10_OF_E*LOG(ZTEMP.MAG); return COMPLEX'(TEMP, MATH_LOG10_OF_E*ZTEMP.ARG); - end LOG10; + end function LOG10; function LOG(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is @@ -680,7 +678,7 @@ package body MATH_COMPLEX is ZTEMP.IM := Z.ARG; ZOUT := COMPLEX_TO_POLAR(ZTEMP); return ZOUT; - end LOG; + end function LOG; @@ -722,7 +720,7 @@ package body MATH_COMPLEX is ZTEMP.IM := MATH_LOG2_OF_E*Z.ARG; ZOUT := COMPLEX_TO_POLAR(ZTEMP); return ZOUT; - end LOG2; + end function LOG2; function LOG10(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -762,7 +760,7 @@ package body MATH_COMPLEX is ZTEMP.IM := MATH_LOG10_OF_E*Z.ARG; ZOUT := COMPLEX_TO_POLAR(ZTEMP); return ZOUT; - end LOG10; + end function LOG10; function LOG(Z: in COMPLEX; BASE: in REAL ) return COMPLEX is -- Description: @@ -804,7 +802,7 @@ package body MATH_COMPLEX is TEMPRE := LOG(ZTEMP.MAG, BASE); TEMPIM := ZTEMP.ARG/LOG(BASE); return COMPLEX'(TEMPRE, TEMPIM); - end LOG; + end function LOG; function LOG(Z: in COMPLEX_POLAR; BASE: in REAL ) return COMPLEX_POLAR is -- Description: @@ -851,7 +849,7 @@ package body MATH_COMPLEX is ZTEMP.IM := Z.ARG/LOG(BASE); ZOUT := COMPLEX_TO_POLAR(ZTEMP); return ZOUT; - end LOG; + end function LOG; function SIN(Z: in COMPLEX ) return COMPLEX is @@ -869,7 +867,7 @@ package body MATH_COMPLEX is -- Get value for general case return COMPLEX'(SIN(Z.RE)*COSH(Z.IM), COS(Z.RE)*SINH(Z.IM)); - end SIN; + end function SIN; function SIN(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -902,7 +900,7 @@ package body MATH_COMPLEX is Z2 := COMPLEX'(SIN(Z1.RE)*COSH(Z1.IM), COS(Z1.RE)*SINH(Z1.IM)); ZOUT := COMPLEX_TO_POLAR(Z2); return ZOUT; - end SIN; + end function SIN; function COS(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -921,7 +919,7 @@ package body MATH_COMPLEX is -- Get value for general case return COMPLEX'(COS(Z.RE)*COSH(Z.IM), -SIN(Z.RE)*SINH(Z.IM)); - end COS; + end function COS; function COS(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -954,7 +952,7 @@ package body MATH_COMPLEX is Z2 := COMPLEX'(COS(Z1.RE)*COSH(Z1.IM), -SIN(Z1.RE)*SINH(Z1.IM)); ZOUT := COMPLEX_TO_POLAR(Z2); return ZOUT; - end COS; + end function COS; function SINH(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -981,7 +979,7 @@ package body MATH_COMPLEX is -- Get value for general case return COMPLEX'(SINH(Z.RE)*COS(Z.IM), COSH(Z.RE)*SIN(Z.IM)); - end SINH; + end function SINH; function SINH(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -1022,7 +1020,7 @@ package body MATH_COMPLEX is Z2 := COMPLEX'(SINH(Z1.RE)*COS(Z1.IM), COSH(Z1.RE)*SIN(Z1.IM)); ZOUT := COMPLEX_TO_POLAR(Z2); return ZOUT; - end SINH; + end function SINH; function COSH(Z: in COMPLEX ) return COMPLEX is @@ -1048,7 +1046,7 @@ package body MATH_COMPLEX is -- Get value for general case return COMPLEX'(COSH(Z.RE)*COS(Z.IM), SINH(Z.RE)*SIN(Z.IM)); - end COSH; + end function COSH; function COSH(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -1089,7 +1087,7 @@ package body MATH_COMPLEX is Z2 := COMPLEX'(COSH(Z1.RE)*COS(Z1.IM), SINH(Z1.RE)*SIN(Z1.IM)); ZOUT := COMPLEX_TO_POLAR(Z2); return ZOUT; - end COSH; + end function COSH; -- @@ -1102,7 +1100,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L.RE + R.RE, L.IM + R.IM); - end "+"; + end function "+"; function "+" ( L: in REAL; R: in COMPLEX ) return COMPLEX is -- Description: @@ -1111,7 +1109,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L + R.RE, R.IM); - end "+"; + end function "+"; function "+" ( L: in COMPLEX; R: in REAL ) return COMPLEX is -- Description: @@ -1120,7 +1118,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L.RE + R, L.IM); - end "+"; + end function "+"; function "+" (L: in COMPLEX_POLAR; R: in COMPLEX_POLAR) return COMPLEX_POLAR is @@ -1153,7 +1151,7 @@ package body MATH_COMPLEX is ZR := POLAR_TO_COMPLEX( R ); ZOUT := COMPLEX_TO_POLAR(COMPLEX'(ZL.RE + ZR.RE, ZL.IM +ZR.IM)); return ZOUT; - end "+"; + end function "+"; function "+" ( L: in REAL; R: in COMPLEX_POLAR) return COMPLEX_POLAR is -- Description: @@ -1175,7 +1173,7 @@ package body MATH_COMPLEX is ZR := POLAR_TO_COMPLEX( R ); ZOUT := COMPLEX_TO_POLAR(COMPLEX'(L + ZR.RE, ZR.IM)); return ZOUT; - end "+"; + end function "+"; function "+" ( L: in COMPLEX_POLAR; R: in REAL) return COMPLEX_POLAR is -- Description: @@ -1198,7 +1196,7 @@ package body MATH_COMPLEX is ZL := POLAR_TO_COMPLEX( L ); ZOUT := COMPLEX_TO_POLAR(COMPLEX'(ZL.RE + R, ZL.IM)); return ZOUT; - end "+"; + end function "+"; function "-" ( L: in COMPLEX; R: in COMPLEX ) return COMPLEX is -- Description: @@ -1207,7 +1205,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L.RE - R.RE, L.IM - R.IM); - end "-"; + end function "-"; function "-" ( L: in REAL; R: in COMPLEX ) return COMPLEX is -- Description: @@ -1216,7 +1214,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L - R.RE, -1.0 * R.IM); - end "-"; + end function "-"; function "-" ( L: in COMPLEX; R: in REAL ) return COMPLEX is -- Description: @@ -1225,7 +1223,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L.RE - R, L.IM); - end "-"; + end function "-"; function "-" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR) return COMPLEX_POLAR is @@ -1256,7 +1254,7 @@ package body MATH_COMPLEX is ZR := POLAR_TO_COMPLEX( R ); ZOUT := COMPLEX_TO_POLAR(COMPLEX'(ZL.RE - ZR.RE, ZL.IM -ZR.IM)); return ZOUT; - end "-"; + end function "-"; function "-" ( L: in REAL; R: in COMPLEX_POLAR) return COMPLEX_POLAR is -- Description: @@ -1279,7 +1277,7 @@ package body MATH_COMPLEX is ZR := POLAR_TO_COMPLEX( R ); ZOUT := COMPLEX_TO_POLAR(COMPLEX'(L - ZR.RE, -1.0*ZR.IM)); return ZOUT; - end "-"; + end function "-"; function "-" ( L: in COMPLEX_POLAR; R: in REAL) return COMPLEX_POLAR is -- Description: @@ -1302,7 +1300,7 @@ package body MATH_COMPLEX is ZL := POLAR_TO_COMPLEX( L ); ZOUT := COMPLEX_TO_POLAR(COMPLEX'(ZL.RE - R, ZL.IM)); return ZOUT; - end "-"; + end function "-"; function "*" ( L: in COMPLEX; R: in COMPLEX ) return COMPLEX is @@ -1312,7 +1310,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L.RE * R.RE - L.IM * R.IM, L.RE * R.IM + L.IM * R.RE); - end "*"; + end function "*"; function "*" ( L: in REAL; R: in COMPLEX ) return COMPLEX is @@ -1322,7 +1320,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L * R.RE, L * R.IM); - end "*"; + end function "*"; function "*" ( L: in COMPLEX; R: in REAL ) return COMPLEX is -- Description: @@ -1331,7 +1329,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L.RE * R, L.IM * R); - end "*"; + end function "*"; function "*" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR) return COMPLEX_POLAR is @@ -1362,7 +1360,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(L.ARG + R.ARG); return ZOUT; - end "*"; + end function "*"; function "*" ( L: in REAL; R: in COMPLEX_POLAR) return COMPLEX_POLAR is -- Description: @@ -1393,7 +1391,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(ZL.ARG + R.ARG); return ZOUT; - end "*"; + end function "*"; function "*" ( L: in COMPLEX_POLAR; R: in REAL) return COMPLEX_POLAR is -- Description: @@ -1424,7 +1422,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(L.ARG + ZR.ARG); return ZOUT; - end "*"; + end function "*"; function "/" ( L: in COMPLEX; R: in COMPLEX ) return COMPLEX is -- Description: @@ -1432,7 +1430,7 @@ package body MATH_COMPLEX is -- Notes: -- a) Returns COMPLEX'(REAL'HIGH, 0.0) on error -- - variable TEMP : REAL := R.RE*R.RE + R.IM*R.IM; + constant TEMP : REAL := R.RE*R.RE + R.IM*R.IM; begin -- Check validity of input arguments if (TEMP = 0.0) then @@ -1445,7 +1443,7 @@ package body MATH_COMPLEX is -- Get value return COMPLEX'( (L.RE * R.RE + L.IM * R.IM) / TEMP, (L.IM * R.RE - L.RE * R.IM) / TEMP); - end "/"; + end function "/"; function "/" ( L: in REAL; R: in COMPLEX ) return COMPLEX is -- Description: @@ -1466,7 +1464,7 @@ package body MATH_COMPLEX is -- Get value TEMP := L / TEMP; return COMPLEX'( TEMP * R.RE, -TEMP * R.IM ); - end "/"; + end function "/"; function "/" ( L: in COMPLEX; R: in REAL ) return COMPLEX is -- Description: @@ -1484,7 +1482,7 @@ package body MATH_COMPLEX is -- Get value return COMPLEX'(L.RE / R, L.IM / R); - end "/"; + end function "/"; function "/" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR) @@ -1523,7 +1521,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(L.ARG - R.ARG); return ZOUT; - end "/"; + end function "/"; function "/" ( L: in COMPLEX_POLAR; R: in REAL) return COMPLEX_POLAR is -- Description: @@ -1561,7 +1559,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(L.ARG - ZR.ARG); return ZOUT; - end "/"; + end function "/"; function "/" ( L: in REAL; R: in COMPLEX_POLAR) return COMPLEX_POLAR is -- Description: @@ -1599,6 +1597,6 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(ZL.ARG - R.ARG); return ZOUT; - end "/"; + end function "/"; -end MATH_COMPLEX; +end package body MATH_COMPLEX; diff --git a/libraries/ieee/math_complex.vhdl b/libraries/ieee/math_complex.vhdl index 278f7413f..af7c3c3fe 100644 --- a/libraries/ieee/math_complex.vhdl +++ b/libraries/ieee/math_complex.vhdl @@ -1,1087 +1,1083 @@ ------------------------------------------------------------------------- +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- --- Copyright 1996 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076.2-1996, IEEE Standard --- VHDL Mathematical Packages. This source file may not be copied, sold, or --- included with software that is sold without written permission from the IEEE --- Standards Department. This source file may be used to implement this standard --- and may be distributed in compiled form in any manner so long as the --- compiled form does not allow direct decompilation of the original source file. --- This source file may be copied for individual use between licensed users. --- This source file is provided on an AS IS basis. The IEEE disclaims ANY --- WARRANTY EXPRESS OR IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY --- AND FITNESS FOR USE FOR A PARTICULAR PURPOSE. The user of the source --- file shall indemnify and hold IEEE harmless from any damages or liability --- arising out of the use thereof. --- --- Title: Standard VHDL Mathematical Packages (IEEE Std 1076.2-1996, --- MATH_COMPLEX) --- --- Library: This package shall be compiled into a library --- symbolically named IEEE. --- --- Developers: IEEE DASC VHDL Mathematical Packages Working Group --- --- Purpose: This package defines a standard for designers to use in --- describing VHDL models that make use of common COMPLEX --- constants and common COMPLEX mathematical functions and --- operators. --- --- Limitation: The values generated by the functions in this package may --- vary from platform to platform, and the precision of results --- is only guaranteed to be the minimum required by IEEE Std 1076- --- 1993. --- --- Notes: --- No declarations or definitions shall be included in, or --- excluded from, this package. --- The "package declaration" defines the types, subtypes, and --- declarations of MATH_COMPLEX. --- The standard mathematical definition and conventional meaning --- of the mathematical functions that are part of this standard --- represent the formal semantics of the implementation of the --- MATH_COMPLEX package declaration. The purpose of the --- MATH_COMPLEX package body is to provide a guideline for --- implementations to verify their implementation of MATH_COMPLEX. --- Tool developers may choose to implement the package body in --- the most efficient manner available to them. --- --- ----------------------------------------------------------------------------- --- Version : 1.5 --- Date : 24 July 1996 --- ----------------------------------------------------------------------------- +-- Title : Standard VHDL Mathematical Packages +-- : (MATH_COMPLEX package declaration) +-- : +-- Library : This package shall be compiled into a library +-- : symbolically named IEEE. +-- : +-- Developers: IEEE DASC VHDL Mathematical Packages Working Group +-- : +-- Purpose : This package defines a standard for designers to use in +-- : describing VHDL models that make use of common COMPLEX +-- : constants and common COMPLEX mathematical functions and +-- : operators. +-- : +-- Limitation: The values generated by the functions in this package +-- : may vary from platform to platform, and the precision +-- : of results is only guaranteed to be the minimum required +-- : by IEEE Std 1076-2008. +-- : +-- Note : This package may be modified to include additional data +-- : required by tools, but it must in no way change the +-- : external interfaces or simulation behavior of the +-- : description. It is permissible to add comments and/or +-- : attributes to the package declarations, but not to change +-- : or delete any original lines of the package declaration. +-- : The package body may be changed only in accordance with +-- : the terms of Clause 16 of this standard. +-- : +-- -------------------------------------------------------------------- +-- $Revision: 1220 $ +-- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ +-- -------------------------------------------------------------------- use WORK.MATH_REAL.all; package MATH_COMPLEX is - constant CopyRightNotice: STRING - := "Copyright 1996 IEEE. All rights reserved."; - - -- - -- Type Definitions - -- - type COMPLEX is - record - RE: REAL; -- Real part - IM: REAL; -- Imaginary part - end record; - - subtype POSITIVE_REAL is REAL range 0.0 to REAL'HIGH; - - subtype PRINCIPAL_VALUE is REAL range -MATH_PI to MATH_PI; - - type COMPLEX_POLAR is - record - MAG: POSITIVE_REAL; -- Magnitude - ARG: PRINCIPAL_VALUE; -- Angle in radians; -MATH_PI is illegal - end record; - - -- - -- Constant Definitions - -- - constant MATH_CBASE_1: COMPLEX := COMPLEX'(1.0, 0.0); - constant MATH_CBASE_J: COMPLEX := COMPLEX'(0.0, 1.0); - constant MATH_CZERO: COMPLEX := COMPLEX'(0.0, 0.0); - - - -- - -- Overloaded equality and inequality operators for COMPLEX_POLAR - -- (equality and inequality operators for COMPLEX are predefined) - -- - - function "=" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR ) return BOOLEAN; - -- Purpose: - -- Returns TRUE if L is equal to R and returns FALSE otherwise - -- Special values: - -- COMPLEX_POLAR'(0.0, X) = COMPLEX_POLAR'(0.0, Y) returns TRUE - -- regardless of the value of X and Y. - -- Domain: - -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI - -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI - -- Error conditions: - -- Error if L.ARG = -MATH_PI - -- Error if R.ARG = -MATH_PI - -- Range: - -- "="(L,R) is either TRUE or FALSE - -- Notes: - -- None - - function "/=" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR ) return BOOLEAN; - -- Purpose: - -- Returns TRUE if L is not equal to R and returns FALSE - -- otherwise - -- Special values: - -- COMPLEX_POLAR'(0.0, X) /= COMPLEX_POLAR'(0.0, Y) returns - -- FALSE regardless of the value of X and Y. - -- Domain: - -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI - -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI - -- Error conditions: - -- Error if L.ARG = -MATH_PI - -- Error if R.ARG = -MATH_PI - -- Range: - -- "/="(L,R) is either TRUE or FALSE - -- Notes: - -- None - - -- - -- Function Declarations - -- - function CMPLX(X: in REAL; Y: in REAL:= 0.0 ) return COMPLEX; - -- Purpose: - -- Returns COMPLEX number X + iY - -- Special values: - -- None - -- Domain: - -- X in REAL - -- Y in REAL - -- Error conditions: - -- None - -- Range: - -- CMPLX(X,Y) is mathematically unbounded - -- Notes: - -- None - - function GET_PRINCIPAL_VALUE(X: in REAL ) return PRINCIPAL_VALUE; - -- Purpose: - -- Returns principal value of angle X; X in radians - -- Special values: - -- None - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- -MATH_PI < GET_PRINCIPAL_VALUE(X) <= MATH_PI - -- Notes: - -- None - - function COMPLEX_TO_POLAR(Z: in COMPLEX ) return COMPLEX_POLAR; - -- Purpose: - -- Returns principal value COMPLEX_POLAR of Z - -- Special values: - -- COMPLEX_TO_POLAR(MATH_CZERO) = COMPLEX_POLAR'(0.0, 0.0) - -- COMPLEX_TO_POLAR(Z) = COMPLEX_POLAR'(ABS(Z.IM), - -- SIGN(Z.IM)*MATH_PI_OVER_2) if Z.RE = 0.0 - -- Domain: - -- Z in COMPLEX - -- Error conditions: - -- None - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function POLAR_TO_COMPLEX(Z: in COMPLEX_POLAR ) return COMPLEX; - -- Purpose: - -- Returns COMPLEX value of Z - -- Special values: - -- None - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Range: - -- POLAR_TO_COMPLEX(Z) is mathematically unbounded - -- Notes: - -- None - - function "ABS"(Z: in COMPLEX ) return POSITIVE_REAL; - -- Purpose: - -- Returns absolute value (magnitude) of Z - -- Special values: - -- None - -- Domain: - -- Z in COMPLEX - -- Error conditions: - -- None - -- Range: - -- ABS(Z) is mathematically unbounded - -- Notes: - -- ABS(Z) = SQRT(Z.RE*Z.RE + Z.IM*Z.IM) - - function "ABS"(Z: in COMPLEX_POLAR ) return POSITIVE_REAL; - -- Purpose: - -- Returns absolute value (magnitude) of Z - -- Special values: - -- None - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Range: - -- ABS(Z) >= 0.0 - -- Notes: - -- ABS(Z) = Z.MAG - - function ARG(Z: in COMPLEX ) return PRINCIPAL_VALUE; - -- Purpose: - -- Returns argument (angle) in radians of the principal - -- value of Z - -- Special values: - -- ARG(Z) = 0.0 if Z.RE >= 0.0 and Z.IM = 0.0 - -- ARG(Z) = SIGN(Z.IM)*MATH_PI_OVER_2 if Z.RE = 0.0 - -- ARG(Z) = MATH_PI if Z.RE < 0.0 and Z.IM = 0.0 - -- Domain: - -- Z in COMPLEX - -- Error conditions: - -- None - -- Range: - -- -MATH_PI < ARG(Z) <= MATH_PI - -- Notes: - -- ARG(Z) = ARCTAN(Z.IM, Z.RE) - - function ARG(Z: in COMPLEX_POLAR ) return PRINCIPAL_VALUE; - -- Purpose: - -- Returns argument (angle) in radians of the principal - -- value of Z - -- Special values: - -- None - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Range: - -- -MATH_PI < ARG(Z) <= MATH_PI - -- Notes: - -- ARG(Z) = Z.ARG - - - function "-" (Z: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns unary minus of Z - -- Special values: - -- None - -- Domain: - -- Z in COMPLEX - -- Error conditions: - -- None - -- Range: - -- "-"(Z) is mathematically unbounded - -- Notes: - -- Returns -x -jy for Z= x + jy - - function "-" (Z: in COMPLEX_POLAR ) return COMPLEX_POLAR; - -- Purpose: - -- Returns principal value of unary minus of Z - -- Special values: - -- "-"(Z) = COMPLEX_POLAR'(Z.MAG, MATH_PI) if Z.ARG = 0.0 - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- Returns COMPLEX_POLAR'(Z.MAG, Z.ARG - SIGN(Z.ARG)*MATH_PI) if - -- Z.ARG /= 0.0 - - function CONJ (Z: in COMPLEX) return COMPLEX; - -- Purpose: - -- Returns complex conjugate of Z - -- Special values: - -- None - -- Domain: - -- Z in COMPLEX - -- Error conditions: - -- None - -- Range: - -- CONJ(Z) is mathematically unbounded - -- Notes: - -- Returns x -jy for Z= x + jy - - function CONJ (Z: in COMPLEX_POLAR) return COMPLEX_POLAR; - -- Purpose: - -- Returns principal value of complex conjugate of Z - -- Special values: - -- CONJ(Z) = COMPLEX_POLAR'(Z.MAG, MATH_PI) if Z.ARG = MATH_PI - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- Returns COMPLEX_POLAR'(Z.MAG, -Z.ARG) if Z.ARG /= MATH_PI - - function SQRT(Z: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns square root of Z with positive real part - -- or, if the real part is zero, the one with nonnegative - -- imaginary part - -- Special values: - -- SQRT(MATH_CZERO) = MATH_CZERO - -- Domain: - -- Z in COMPLEX - -- Error conditions: - -- None - -- Range: - -- SQRT(Z) is mathematically unbounded - -- Notes: - -- None - - function SQRT(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR; - -- Purpose: - -- Returns square root of Z with positive real part - -- or, if the real part is zero, the one with nonnegative - -- imaginary part - -- Special values: - -- SQRT(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 0.0 - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function EXP(Z: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns exponential of Z - -- Special values: - -- EXP(MATH_CZERO) = MATH_CBASE_1 - -- EXP(Z) = -MATH_CBASE_1 if Z.RE = 0.0 and ABS(Z.IM) = MATH_PI - -- EXP(Z) = SIGN(Z.IM)*MATH_CBASE_J if Z.RE = 0.0 and - -- ABS(Z.IM) = MATH_PI_OVER_2 - -- Domain: - -- Z in COMPLEX - -- Error conditions: - -- None - -- Range: - -- EXP(Z) is mathematically unbounded - -- Notes: - -- None - - - - function EXP(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR; - -- Purpose: - -- Returns principal value of exponential of Z - -- Special values: - -- EXP(Z) = COMPLEX_POLAR'(1.0, 0.0) if Z.MAG =0.0 and - -- Z.ARG = 0.0 - -- EXP(Z) = COMPLEX_POLAR'(1.0, MATH_PI) if Z.MAG = MATH_PI and - -- ABS(Z.ARG) = MATH_PI_OVER_2 - -- EXP(Z) = COMPLEX_POLAR'(1.0, MATH_PI_OVER_2) if - -- Z.MAG = MATH_PI_OVER_2 and - -- Z.ARG = MATH_PI_OVER_2 - -- EXP(Z) = COMPLEX_POLAR'(1.0, -MATH_PI_OVER_2) if - -- Z.MAG = MATH_PI_OVER_2 and - -- Z.ARG = -MATH_PI_OVER_2 - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function LOG(Z: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns natural logarithm of Z - -- Special values: - -- LOG(MATH_CBASE_1) = MATH_CZERO - -- LOG(-MATH_CBASE_1) = COMPLEX'(0.0, MATH_PI) - -- LOG(MATH_CBASE_J) = COMPLEX'(0.0, MATH_PI_OVER_2) - -- LOG(-MATH_CBASE_J) = COMPLEX'(0.0, -MATH_PI_OVER_2) - -- LOG(Z) = MATH_CBASE_1 if Z = COMPLEX'(MATH_E, 0.0) - -- Domain: - -- Z in COMPLEX and ABS(Z) /= 0.0 - -- Error conditions: - -- Error if ABS(Z) = 0.0 - -- Range: - -- LOG(Z) is mathematically unbounded - -- Notes: - -- None - - function LOG2(Z: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns logarithm base 2 of Z - -- Special values: - -- LOG2(MATH_CBASE_1) = MATH_CZERO - -- LOG2(Z) = MATH_CBASE_1 if Z = COMPLEX'(2.0, 0.0) - -- Domain: - -- Z in COMPLEX and ABS(Z) /= 0.0 - -- Error conditions: - -- Error if ABS(Z) = 0.0 - -- Range: - -- LOG2(Z) is mathematically unbounded - -- Notes: - -- None - - function LOG10(Z: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns logarithm base 10 of Z - -- Special values: - -- LOG10(MATH_CBASE_1) = MATH_CZERO - -- LOG10(Z) = MATH_CBASE_1 if Z = COMPLEX'(10.0, 0.0) - -- Domain: - -- Z in COMPLEX and ABS(Z) /= 0.0 - -- Error conditions: - -- Error if ABS(Z) = 0.0 - -- Range: - -- LOG10(Z) is mathematically unbounded - -- Notes: - -- None - - function LOG(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR; - -- Purpose: - -- Returns principal value of natural logarithm of Z - -- Special values: - -- LOG(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 1.0 and - -- Z.ARG = 0.0 - -- LOG(Z) = COMPLEX_POLAR'(MATH_PI, MATH_PI_OVER_2) if - -- Z.MAG = 1.0 and Z.ARG = MATH_PI - -- LOG(Z) = COMPLEX_POLAR'(MATH_PI_OVER_2, MATH_PI_OVER_2) if - -- Z.MAG = 1.0 and Z.ARG = MATH_PI_OVER_2 - -- LOG(Z) = COMPLEX_POLAR'(MATH_PI_OVER_2, -MATH_PI_OVER_2) if - -- Z.MAG = 1.0 and Z.ARG = -MATH_PI_OVER_2 - -- LOG(Z) = COMPLEX_POLAR'(1.0, 0.0) if Z.MAG = MATH_E and - -- Z.ARG = 0.0 - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Z.MAG /= 0.0 - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Error if Z.MAG = 0.0 - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function LOG2(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR; - -- Purpose: - -- Returns principal value of logarithm base 2 of Z - -- Special values: - -- LOG2(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 1.0 and - -- Z.ARG = 0.0 - -- LOG2(Z) = COMPLEX_POLAR'(1.0, 0.0) if Z.MAG = 2.0 and - -- Z.ARG = 0.0 - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Z.MAG /= 0.0 - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Error if Z.MAG = 0.0 - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function LOG10(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR; - -- Purpose: - -- Returns principal value of logarithm base 10 of Z - -- Special values: - -- LOG10(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 1.0 and - -- Z.ARG = 0.0 - -- LOG10(Z) = COMPLEX_POLAR'(1.0, 0.0) if Z.MAG = 10.0 and - -- Z.ARG = 0.0 - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Z.MAG /= 0.0 - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Error if Z.MAG = 0.0 - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function LOG(Z: in COMPLEX; BASE: in REAL) return COMPLEX; - -- Purpose: - -- Returns logarithm base BASE of Z - -- Special values: - -- LOG(MATH_CBASE_1, BASE) = MATH_CZERO - -- LOG(Z,BASE) = MATH_CBASE_1 if Z = COMPLEX'(BASE, 0.0) - -- Domain: - -- Z in COMPLEX and ABS(Z) /= 0.0 - -- BASE > 0.0 - -- BASE /= 1.0 - -- Error conditions: - -- Error if ABS(Z) = 0.0 - -- Error if BASE <= 0.0 - -- Error if BASE = 1.0 - -- Range: - -- LOG(Z,BASE) is mathematically unbounded - -- Notes: - -- None - - function LOG(Z: in COMPLEX_POLAR; BASE: in REAL ) return COMPLEX_POLAR; - -- Purpose: - -- Returns principal value of logarithm base BASE of Z - -- Special values: - -- LOG(Z, BASE) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 1.0 and - -- Z.ARG = 0.0 - -- LOG(Z, BASE) = COMPLEX_POLAR'(1.0, 0.0) if Z.MAG = BASE and - -- Z.ARG = 0.0 - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Z.MAG /= 0.0 - -- BASE > 0.0 - -- BASE /= 1.0 - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Error if Z.MAG = 0.0 - -- Error if BASE <= 0.0 - -- Error if BASE = 1.0 - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function SIN (Z : in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns sine of Z - -- Special values: - -- SIN(MATH_CZERO) = MATH_CZERO - -- SIN(Z) = MATH_CZERO if Z = COMPLEX'(MATH_PI, 0.0) - -- Domain: - -- Z in COMPLEX - -- Error conditions: - -- None - -- Range: - -- ABS(SIN(Z)) <= SQRT(SIN(Z.RE)*SIN(Z.RE) + - -- SINH(Z.IM)*SINH(Z.IM)) - -- Notes: - -- None - - function SIN (Z : in COMPLEX_POLAR ) return COMPLEX_POLAR; - -- Purpose: - -- Returns principal value of sine of Z - -- Special values: - -- SIN(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 0.0 and - -- Z.ARG = 0.0 - -- SIN(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = MATH_PI and - -- Z.ARG = 0.0 - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function COS (Z : in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns cosine of Z - -- Special values: - -- COS(Z) = MATH_CZERO if Z = COMPLEX'(MATH_PI_OVER_2, 0.0) - -- COS(Z) = MATH_CZERO if Z = COMPLEX'(-MATH_PI_OVER_2, 0.0) - -- Domain: - -- Z in COMPLEX - -- Error conditions: - -- None - -- Range: - -- ABS(COS(Z)) <= SQRT(COS(Z.RE)*COS(Z.RE) + - -- SINH(Z.IM)*SINH(Z.IM)) - -- Notes: - -- None - - - function COS (Z : in COMPLEX_POLAR ) return COMPLEX_POLAR; - -- Purpose: - -- Returns principal value of cosine of Z - -- Special values: - -- COS(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = MATH_PI_OVER_2 - -- and Z.ARG = 0.0 - -- COS(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = MATH_PI_OVER_2 - -- and Z.ARG = MATH_PI - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function SINH (Z : in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns hyperbolic sine of Z - -- Special values: - -- SINH(MATH_CZERO) = MATH_CZERO - -- SINH(Z) = MATH_CZERO if Z.RE = 0.0 and Z.IM = MATH_PI - -- SINH(Z) = MATH_CBASE_J if Z.RE = 0.0 and - -- Z.IM = MATH_PI_OVER_2 - -- SINH(Z) = -MATH_CBASE_J if Z.RE = 0.0 and - -- Z.IM = -MATH_PI_OVER_2 - -- Domain: - -- Z in COMPLEX - -- Error conditions: - -- None - -- Range: - -- ABS(SINH(Z)) <= SQRT(SINH(Z.RE)*SINH(Z.RE) + - -- SIN(Z.IM)*SIN(Z.IM)) - -- Notes: - -- None - - function SINH (Z : in COMPLEX_POLAR ) return COMPLEX_POLAR; - -- Purpose: - -- Returns principal value of hyperbolic sine of Z - -- Special values: - -- SINH(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 0.0 and - -- Z.ARG = 0.0 - -- SINH(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = MATH_PI and - -- Z.ARG = MATH_PI_OVER_2 - -- SINH(Z) = COMPLEX_POLAR'(1.0, MATH_PI_OVER_2) if Z.MAG = - -- MATH_PI_OVER_2 and Z.ARG = MATH_PI_OVER_2 - -- SINH(Z) = COMPLEX_POLAR'(1.0, -MATH_PI_OVER_2) if Z.MAG = - -- MATH_PI_OVER_2 and Z.ARG = -MATH_PI_OVER_2 - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function COSH (Z : in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns hyperbolic cosine of Z - -- Special values: - -- COSH(MATH_CZERO) = MATH_CBASE_1 - -- COSH(Z) = -MATH_CBASE_1 if Z.RE = 0.0 and Z.IM = MATH_PI - -- COSH(Z) = MATH_CZERO if Z.RE = 0.0 and Z.IM = MATH_PI_OVER_2 - -- COSH(Z) = MATH_CZERO if Z.RE = 0.0 and Z.IM = -MATH_PI_OVER_2 - -- Domain: - -- Z in COMPLEX - -- Error conditions: - -- None - -- Range: - -- ABS(COSH(Z)) <= SQRT(SINH(Z.RE)*SINH(Z.RE) + - -- COS(Z.IM)*COS(Z.IM)) - -- Notes: - -- None - - - function COSH (Z : in COMPLEX_POLAR ) return COMPLEX_POLAR; - -- Purpose: - -- Returns principal value of hyperbolic cosine of Z - -- Special values: - -- COSH(Z) = COMPLEX_POLAR'(1.0, 0.0) if Z.MAG = 0.0 and - -- Z.ARG = 0.0 - -- COSH(Z) = COMPLEX_POLAR'(1.0, MATH_PI) if Z.MAG = MATH_PI and - -- Z.ARG = MATH_PI_OVER_2 - -- COSH(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = - -- MATH_PI_OVER_2 and Z.ARG = MATH_PI_OVER_2 - -- COSH(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = - -- MATH_PI_OVER_2 and Z.ARG = -MATH_PI_OVER_2 - -- Domain: - -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI - -- Error conditions: - -- Error if Z.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - -- - -- Arithmetic Operators - -- - - function "+" ( L: in COMPLEX; R: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns arithmetic addition of L and R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX - -- R in COMPLEX - -- Error conditions: - -- None - -- Range: - -- "+"(Z) is mathematically unbounded - -- Notes: - -- None - - function "+" ( L: in REAL; R: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns arithmetic addition of L and R - -- Special values: - -- None - -- Domain: - -- L in REAL - -- R in COMPLEX - -- Error conditions: - -- None - -- Range: - -- "+"(Z) is mathematically unbounded - -- Notes: - -- None - - function "+" ( L: in COMPLEX; R: in REAL ) return COMPLEX; - -- Purpose: - -- Returns arithmetic addition of L and R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX - -- R in REAL - -- Error conditions: - -- None - -- Range: - -- "+"(Z) is mathematically unbounded - -- Notes: - -- None - - function "+" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR) - return COMPLEX_POLAR; - -- Purpose: - -- Returns arithmetic addition of L and R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI - -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI - -- Error conditions: - -- Error if L.ARG = -MATH_PI - -- Error if R.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - - function "+" ( L: in REAL; R: in COMPLEX_POLAR) return COMPLEX_POLAR; - -- Purpose: - -- Returns arithmetic addition of L and R - -- Special values: - -- None - -- Domain: - -- L in REAL - -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI - -- Error conditions: - -- Error if R.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function "+" ( L: in COMPLEX_POLAR; R: in REAL) return COMPLEX_POLAR; - -- Purpose: - -- Returns arithmetic addition of L and R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI - -- R in REAL - -- Error conditions: - -- Error if L.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function "-" ( L: in COMPLEX; R: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns arithmetic subtraction of L minus R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX - -- R in COMPLEX - -- Error conditions: - -- None - -- Range: - -- "-"(Z) is mathematically unbounded - -- Notes: - -- None - - function "-" ( L: in REAL; R: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns arithmetic subtraction of L minus R - -- Special values: - -- None - -- Domain: - -- L in REAL - -- R in COMPLEX - -- Error conditions: - -- None - -- Range: - -- "-"(Z) is mathematically unbounded - -- Notes: - -- None - - function "-" ( L: in COMPLEX; R: in REAL ) return COMPLEX; - -- Purpose: - -- Returns arithmetic subtraction of L minus R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX - -- R in REAL - -- Error conditions: - -- None - -- Range: - -- "-"(Z) is mathematically unbounded - -- Notes: - -- None - - function "-" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR) - return COMPLEX_POLAR; - -- Purpose: - -- Returns arithmetic subtraction of L minus R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI - -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI - -- Error conditions: - -- Error if L.ARG = -MATH_PI - -- Error if R.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function "-" ( L: in REAL; R: in COMPLEX_POLAR) return COMPLEX_POLAR; - -- Purpose: - -- Returns arithmetic subtraction of L minus R - -- Special values: - -- None - -- Domain: - -- L in REAL - -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI - -- Error conditions: - -- Error if R.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - - function "-" ( L: in COMPLEX_POLAR; R: in REAL) return COMPLEX_POLAR; - -- Purpose: - -- Returns arithmetic subtraction of L minus R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI - -- R in REAL - -- Error conditions: - -- Error if L.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function "*" ( L: in COMPLEX; R: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns arithmetic multiplication of L and R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX - -- R in COMPLEX - -- Error conditions: - -- None - -- Range: - -- "*"(Z) is mathematically unbounded - -- Notes: - -- None - - function "*" ( L: in REAL; R: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns arithmetic multiplication of L and R - -- Special values: - -- None - -- Domain: - -- L in REAL - -- R in COMPLEX - -- Error conditions: - -- None - -- Range: - -- "*"(Z) is mathematically unbounded - -- Notes: - -- None - - function "*" ( L: in COMPLEX; R: in REAL ) return COMPLEX; - -- Purpose: - -- Returns arithmetic multiplication of L and R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX - -- R in REAL - -- Error conditions: - -- None - - -- Range: - -- "*"(Z) is mathematically unbounded - -- Notes: - -- None - - function "*" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR) - return COMPLEX_POLAR; - -- Purpose: - -- Returns arithmetic multiplication of L and R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI - -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI - -- Error conditions: - -- Error if L.ARG = -MATH_PI - -- Error if R.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function "*" ( L: in REAL; R: in COMPLEX_POLAR) return COMPLEX_POLAR; - -- Purpose: - -- Returns arithmetic multiplication of L and R - -- Special values: - -- None - -- Domain: - -- L in REAL - -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI - -- Error conditions: - -- Error if R.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function "*" ( L: in COMPLEX_POLAR; R: in REAL) return COMPLEX_POLAR; - -- Purpose: - -- Returns arithmetic multiplication of L and R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI - -- R in REAL - -- Error conditions: - -- Error if L.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - - function "/" ( L: in COMPLEX; R: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns arithmetic division of L by R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX - -- R in COMPLEX and R /= MATH_CZERO - -- Error conditions: - -- Error if R = MATH_CZERO - -- Range: - -- "/"(Z) is mathematically unbounded - -- Notes: - -- None - - function "/" ( L: in REAL; R: in COMPLEX ) return COMPLEX; - -- Purpose: - -- Returns arithmetic division of L by R - -- Special values: - -- None - -- Domain: - -- L in REAL - -- R in COMPLEX and R /= MATH_CZERO - -- Error conditions: - -- Error if R = MATH_CZERO - -- Range: - -- "/"(Z) is mathematically unbounded - -- Notes: - -- None - - function "/" ( L: in COMPLEX; R: in REAL ) return COMPLEX; - -- Purpose: - -- Returns arithmetic division of L by R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX - -- R in REAL and R /= 0.0 - -- Error conditions: - -- Error if R = 0.0 - -- Range: - -- "/"(Z) is mathematically unbounded - -- Notes: - -- None - - function "/" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR) - return COMPLEX_POLAR; - -- Purpose: - -- Returns arithmetic division of L by R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI - -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI - -- R.MAG > 0.0 - -- Error conditions: - -- Error if R.MAG <= 0.0 - -- Error if L.ARG = -MATH_PI - -- Error if R.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function "/" ( L: in REAL; R: in COMPLEX_POLAR) return COMPLEX_POLAR; - -- Purpose: - -- Returns arithmetic division of L by R - -- Special values: - -- None - -- Domain: - -- L in REAL - -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI - -- R.MAG > 0.0 - -- Error conditions: - -- Error if R.MAG <= 0.0 - -- Error if R.ARG = -MATH_PI - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None - - function "/" ( L: in COMPLEX_POLAR; R: in REAL) return COMPLEX_POLAR; - -- Purpose: - -- Returns arithmetic division of L by R - -- Special values: - -- None - -- Domain: - -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI - -- R /= 0.0 - -- Error conditions: - -- Error if L.ARG = -MATH_PI - -- Error if R = 0.0 - -- Range: - -- result.MAG >= 0.0 - -- -MATH_PI < result.ARG <= MATH_PI - -- Notes: - -- None -end MATH_COMPLEX; + constant CopyRightNotice : STRING + := "Copyright IEEE P1076 WG. Licensed Apache 2.0"; + + -- + -- Type Definitions + -- + type COMPLEX is + record + RE : REAL; -- Real part + IM : REAL; -- Imaginary part + end record; + + subtype POSITIVE_REAL is REAL range 0.0 to REAL'high; + + subtype PRINCIPAL_VALUE is REAL range -MATH_PI to MATH_PI; + + type COMPLEX_POLAR is + record + MAG : POSITIVE_REAL; -- Magnitude + ARG : PRINCIPAL_VALUE; -- Angle in radians; -MATH_PI is illegal + end record; + + -- + -- Constant Definitions + -- + constant MATH_CBASE_1 : COMPLEX := COMPLEX'(1.0, 0.0); + constant MATH_CBASE_J : COMPLEX := COMPLEX'(0.0, 1.0); + constant MATH_CZERO : COMPLEX := COMPLEX'(0.0, 0.0); + + + -- + -- Overloaded equality and inequality operators for COMPLEX_POLAR + -- (equality and inequality operators for COMPLEX are predefined) + -- + + function "=" (L : in COMPLEX_POLAR; R : in COMPLEX_POLAR) return BOOLEAN; + -- Purpose: + -- Returns TRUE if L is equal to R and returns FALSE otherwise + -- Special values: + -- COMPLEX_POLAR'(0.0, X) = COMPLEX_POLAR'(0.0, Y) returns TRUE + -- regardless of the value of X and Y. + -- Domain: + -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI + -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI + -- Error conditions: + -- Error if L.ARG = -MATH_PI + -- Error if R.ARG = -MATH_PI + -- Range: + -- "="(L,R) is either TRUE or FALSE + -- Notes: + -- None + + function "/=" (L : in COMPLEX_POLAR; R : in COMPLEX_POLAR) return BOOLEAN; + -- Purpose: + -- Returns TRUE if L is not equal to R and returns FALSE + -- otherwise + -- Special values: + -- COMPLEX_POLAR'(0.0, X) /= COMPLEX_POLAR'(0.0, Y) returns + -- FALSE regardless of the value of X and Y. + -- Domain: + -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI + -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI + -- Error conditions: + -- Error if L.ARG = -MATH_PI + -- Error if R.ARG = -MATH_PI + -- Range: + -- "/="(L,R) is either TRUE or FALSE + -- Notes: + -- None + + -- + -- Function Declarations + -- + function CMPLX(X : in REAL; Y : in REAL := 0.0) return COMPLEX; + -- Purpose: + -- Returns COMPLEX number X + iY + -- Special values: + -- None + -- Domain: + -- X in REAL + -- Y in REAL + -- Error conditions: + -- None + -- Range: + -- CMPLX(X,Y) is mathematically unbounded + -- Notes: + -- None + + function GET_PRINCIPAL_VALUE(X : in REAL) return PRINCIPAL_VALUE; + -- Purpose: + -- Returns principal value of angle X; X in radians + -- Special values: + -- None + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- -MATH_PI < GET_PRINCIPAL_VALUE(X) <= MATH_PI + -- Notes: + -- None + + function COMPLEX_TO_POLAR(Z : in COMPLEX) return COMPLEX_POLAR; + -- Purpose: + -- Returns principal value COMPLEX_POLAR of Z + -- Special values: + -- COMPLEX_TO_POLAR(MATH_CZERO) = COMPLEX_POLAR'(0.0, 0.0) + -- COMPLEX_TO_POLAR(Z) = COMPLEX_POLAR'(ABS(Z.IM), + -- SIGN(Z.IM)*MATH_PI_OVER_2) if Z.RE = 0.0 + -- Domain: + -- Z in COMPLEX + -- Error conditions: + -- None + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function POLAR_TO_COMPLEX(Z : in COMPLEX_POLAR) return COMPLEX; + -- Purpose: + -- Returns COMPLEX value of Z + -- Special values: + -- None + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Range: + -- POLAR_TO_COMPLEX(Z) is mathematically unbounded + -- Notes: + -- None + + function "ABS"(Z : in COMPLEX) return POSITIVE_REAL; + -- Purpose: + -- Returns absolute value (magnitude) of Z + -- Special values: + -- None + -- Domain: + -- Z in COMPLEX + -- Error conditions: + -- None + -- Range: + -- ABS(Z) is mathematically unbounded + -- Notes: + -- ABS(Z) = SQRT(Z.RE*Z.RE + Z.IM*Z.IM) + + function "ABS"(Z : in COMPLEX_POLAR) return POSITIVE_REAL; + -- Purpose: + -- Returns absolute value (magnitude) of Z + -- Special values: + -- None + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Range: + -- ABS(Z) >= 0.0 + -- Notes: + -- ABS(Z) = Z.MAG + + function ARG(Z : in COMPLEX) return PRINCIPAL_VALUE; + -- Purpose: + -- Returns argument (angle) in radians of the principal + -- value of Z + -- Special values: + -- ARG(Z) = 0.0 if Z.RE >= 0.0 and Z.IM = 0.0 + -- ARG(Z) = SIGN(Z.IM)*MATH_PI_OVER_2 if Z.RE = 0.0 + -- ARG(Z) = MATH_PI if Z.RE < 0.0 and Z.IM = 0.0 + -- Domain: + -- Z in COMPLEX + -- Error conditions: + -- None + -- Range: + -- -MATH_PI < ARG(Z) <= MATH_PI + -- Notes: + -- ARG(Z) = ARCTAN(Z.IM, Z.RE) + + function ARG(Z : in COMPLEX_POLAR) return PRINCIPAL_VALUE; + -- Purpose: + -- Returns argument (angle) in radians of the principal + -- value of Z + -- Special values: + -- None + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Range: + -- -MATH_PI < ARG(Z) <= MATH_PI + -- Notes: + -- ARG(Z) = Z.ARG + + + function "-" (Z : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns unary minus of Z + -- Special values: + -- None + -- Domain: + -- Z in COMPLEX + -- Error conditions: + -- None + -- Range: + -- "-"(Z) is mathematically unbounded + -- Notes: + -- Returns -x -jy for Z= x + jy + + function "-" (Z : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns principal value of unary minus of Z + -- Special values: + -- "-"(Z) = COMPLEX_POLAR'(Z.MAG, MATH_PI) if Z.ARG = 0.0 + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- Returns COMPLEX_POLAR'(Z.MAG, Z.ARG - SIGN(Z.ARG)*MATH_PI) if + -- Z.ARG /= 0.0 + + function CONJ (Z : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns complex conjugate of Z + -- Special values: + -- None + -- Domain: + -- Z in COMPLEX + -- Error conditions: + -- None + -- Range: + -- CONJ(Z) is mathematically unbounded + -- Notes: + -- Returns x -jy for Z= x + jy + + function CONJ (Z : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns principal value of complex conjugate of Z + -- Special values: + -- CONJ(Z) = COMPLEX_POLAR'(Z.MAG, MATH_PI) if Z.ARG = MATH_PI + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- Returns COMPLEX_POLAR'(Z.MAG, -Z.ARG) if Z.ARG /= MATH_PI + + function SQRT(Z : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns square root of Z with positive real part + -- or, if the real part is zero, the one with nonnegative + -- imaginary part + -- Special values: + -- SQRT(MATH_CZERO) = MATH_CZERO + -- Domain: + -- Z in COMPLEX + -- Error conditions: + -- None + -- Range: + -- SQRT(Z) is mathematically unbounded + -- Notes: + -- None + + function SQRT(Z : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns square root of Z with positive real part + -- or, if the real part is zero, the one with nonnegative + -- imaginary part + -- Special values: + -- SQRT(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 0.0 + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function EXP(Z : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns exponential of Z + -- Special values: + -- EXP(MATH_CZERO) = MATH_CBASE_1 + -- EXP(Z) = -MATH_CBASE_1 if Z.RE = 0.0 and ABS(Z.IM) = MATH_PI + -- EXP(Z) = SIGN(Z.IM)*MATH_CBASE_J if Z.RE = 0.0 and + -- ABS(Z.IM) = MATH_PI_OVER_2 + -- Domain: + -- Z in COMPLEX + -- Error conditions: + -- None + -- Range: + -- EXP(Z) is mathematically unbounded + -- Notes: + -- None + + + + function EXP(Z : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns principal value of exponential of Z + -- Special values: + -- EXP(Z) = COMPLEX_POLAR'(1.0, 0.0) if Z.MAG =0.0 and + -- Z.ARG = 0.0 + -- EXP(Z) = COMPLEX_POLAR'(1.0, MATH_PI) if Z.MAG = MATH_PI and + -- ABS(Z.ARG) = MATH_PI_OVER_2 + -- EXP(Z) = COMPLEX_POLAR'(1.0, MATH_PI_OVER_2) if + -- Z.MAG = MATH_PI_OVER_2 and + -- Z.ARG = MATH_PI_OVER_2 + -- EXP(Z) = COMPLEX_POLAR'(1.0, -MATH_PI_OVER_2) if + -- Z.MAG = MATH_PI_OVER_2 and + -- Z.ARG = -MATH_PI_OVER_2 + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function LOG(Z : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns natural logarithm of Z + -- Special values: + -- LOG(MATH_CBASE_1) = MATH_CZERO + -- LOG(-MATH_CBASE_1) = COMPLEX'(0.0, MATH_PI) + -- LOG(MATH_CBASE_J) = COMPLEX'(0.0, MATH_PI_OVER_2) + -- LOG(-MATH_CBASE_J) = COMPLEX'(0.0, -MATH_PI_OVER_2) + -- LOG(Z) = MATH_CBASE_1 if Z = COMPLEX'(MATH_E, 0.0) + -- Domain: + -- Z in COMPLEX and ABS(Z) /= 0.0 + -- Error conditions: + -- Error if ABS(Z) = 0.0 + -- Range: + -- LOG(Z) is mathematically unbounded + -- Notes: + -- None + + function LOG2(Z : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns logarithm base 2 of Z + -- Special values: + -- LOG2(MATH_CBASE_1) = MATH_CZERO + -- LOG2(Z) = MATH_CBASE_1 if Z = COMPLEX'(2.0, 0.0) + -- Domain: + -- Z in COMPLEX and ABS(Z) /= 0.0 + -- Error conditions: + -- Error if ABS(Z) = 0.0 + -- Range: + -- LOG2(Z) is mathematically unbounded + -- Notes: + -- None + + function LOG10(Z : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns logarithm base 10 of Z + -- Special values: + -- LOG10(MATH_CBASE_1) = MATH_CZERO + -- LOG10(Z) = MATH_CBASE_1 if Z = COMPLEX'(10.0, 0.0) + -- Domain: + -- Z in COMPLEX and ABS(Z) /= 0.0 + -- Error conditions: + -- Error if ABS(Z) = 0.0 + -- Range: + -- LOG10(Z) is mathematically unbounded + -- Notes: + -- None + + function LOG(Z : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns principal value of natural logarithm of Z + -- Special values: + -- LOG(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 1.0 and + -- Z.ARG = 0.0 + -- LOG(Z) = COMPLEX_POLAR'(MATH_PI, MATH_PI_OVER_2) if + -- Z.MAG = 1.0 and Z.ARG = MATH_PI + -- LOG(Z) = COMPLEX_POLAR'(MATH_PI_OVER_2, MATH_PI_OVER_2) if + -- Z.MAG = 1.0 and Z.ARG = MATH_PI_OVER_2 + -- LOG(Z) = COMPLEX_POLAR'(MATH_PI_OVER_2, -MATH_PI_OVER_2) if + -- Z.MAG = 1.0 and Z.ARG = -MATH_PI_OVER_2 + -- LOG(Z) = COMPLEX_POLAR'(1.0, 0.0) if Z.MAG = MATH_E and + -- Z.ARG = 0.0 + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Z.MAG /= 0.0 + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Error if Z.MAG = 0.0 + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function LOG2(Z : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns principal value of logarithm base 2 of Z + -- Special values: + -- LOG2(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 1.0 and + -- Z.ARG = 0.0 + -- LOG2(Z) = COMPLEX_POLAR'(1.0, 0.0) if Z.MAG = 2.0 and + -- Z.ARG = 0.0 + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Z.MAG /= 0.0 + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Error if Z.MAG = 0.0 + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function LOG10(Z : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns principal value of logarithm base 10 of Z + -- Special values: + -- LOG10(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 1.0 and + -- Z.ARG = 0.0 + -- LOG10(Z) = COMPLEX_POLAR'(1.0, 0.0) if Z.MAG = 10.0 and + -- Z.ARG = 0.0 + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Z.MAG /= 0.0 + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Error if Z.MAG = 0.0 + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function LOG(Z : in COMPLEX; BASE : in REAL) return COMPLEX; + -- Purpose: + -- Returns logarithm base BASE of Z + -- Special values: + -- LOG(MATH_CBASE_1, BASE) = MATH_CZERO + -- LOG(Z,BASE) = MATH_CBASE_1 if Z = COMPLEX'(BASE, 0.0) + -- Domain: + -- Z in COMPLEX and ABS(Z) /= 0.0 + -- BASE > 0.0 + -- BASE /= 1.0 + -- Error conditions: + -- Error if ABS(Z) = 0.0 + -- Error if BASE <= 0.0 + -- Error if BASE = 1.0 + -- Range: + -- LOG(Z,BASE) is mathematically unbounded + -- Notes: + -- None + + function LOG(Z : in COMPLEX_POLAR; BASE : in REAL) return COMPLEX_POLAR; + -- Purpose: + -- Returns principal value of logarithm base BASE of Z + -- Special values: + -- LOG(Z, BASE) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 1.0 and + -- Z.ARG = 0.0 + -- LOG(Z, BASE) = COMPLEX_POLAR'(1.0, 0.0) if Z.MAG = BASE and + -- Z.ARG = 0.0 + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Z.MAG /= 0.0 + -- BASE > 0.0 + -- BASE /= 1.0 + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Error if Z.MAG = 0.0 + -- Error if BASE <= 0.0 + -- Error if BASE = 1.0 + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function SIN (Z : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns sine of Z + -- Special values: + -- SIN(MATH_CZERO) = MATH_CZERO + -- SIN(Z) = MATH_CZERO if Z = COMPLEX'(MATH_PI, 0.0) + -- Domain: + -- Z in COMPLEX + -- Error conditions: + -- None + -- Range: + -- ABS(SIN(Z)) <= SQRT(SIN(Z.RE)*SIN(Z.RE) + + -- SINH(Z.IM)*SINH(Z.IM)) + -- Notes: + -- None + + function SIN (Z : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns principal value of sine of Z + -- Special values: + -- SIN(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 0.0 and + -- Z.ARG = 0.0 + -- SIN(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = MATH_PI and + -- Z.ARG = 0.0 + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function COS (Z : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns cosine of Z + -- Special values: + -- COS(Z) = MATH_CZERO if Z = COMPLEX'(MATH_PI_OVER_2, 0.0) + -- COS(Z) = MATH_CZERO if Z = COMPLEX'(-MATH_PI_OVER_2, 0.0) + -- Domain: + -- Z in COMPLEX + -- Error conditions: + -- None + -- Range: + -- ABS(COS(Z)) <= SQRT(COS(Z.RE)*COS(Z.RE) + + -- SINH(Z.IM)*SINH(Z.IM)) + -- Notes: + -- None + + + function COS (Z : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns principal value of cosine of Z + -- Special values: + -- COS(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = MATH_PI_OVER_2 + -- and Z.ARG = 0.0 + -- COS(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = MATH_PI_OVER_2 + -- and Z.ARG = MATH_PI + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function SINH (Z : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns hyperbolic sine of Z + -- Special values: + -- SINH(MATH_CZERO) = MATH_CZERO + -- SINH(Z) = MATH_CZERO if Z.RE = 0.0 and Z.IM = MATH_PI + -- SINH(Z) = MATH_CBASE_J if Z.RE = 0.0 and + -- Z.IM = MATH_PI_OVER_2 + -- SINH(Z) = -MATH_CBASE_J if Z.RE = 0.0 and + -- Z.IM = -MATH_PI_OVER_2 + -- Domain: + -- Z in COMPLEX + -- Error conditions: + -- None + -- Range: + -- ABS(SINH(Z)) <= SQRT(SINH(Z.RE)*SINH(Z.RE) + + -- SIN(Z.IM)*SIN(Z.IM)) + -- Notes: + -- None + + function SINH (Z : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns principal value of hyperbolic sine of Z + -- Special values: + -- SINH(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = 0.0 and + -- Z.ARG = 0.0 + -- SINH(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = MATH_PI and + -- Z.ARG = MATH_PI_OVER_2 + -- SINH(Z) = COMPLEX_POLAR'(1.0, MATH_PI_OVER_2) if Z.MAG = + -- MATH_PI_OVER_2 and Z.ARG = MATH_PI_OVER_2 + -- SINH(Z) = COMPLEX_POLAR'(1.0, -MATH_PI_OVER_2) if Z.MAG = + -- MATH_PI_OVER_2 and Z.ARG = -MATH_PI_OVER_2 + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function COSH (Z : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns hyperbolic cosine of Z + -- Special values: + -- COSH(MATH_CZERO) = MATH_CBASE_1 + -- COSH(Z) = -MATH_CBASE_1 if Z.RE = 0.0 and Z.IM = MATH_PI + -- COSH(Z) = MATH_CZERO if Z.RE = 0.0 and Z.IM = MATH_PI_OVER_2 + -- COSH(Z) = MATH_CZERO if Z.RE = 0.0 and Z.IM = -MATH_PI_OVER_2 + -- Domain: + -- Z in COMPLEX + -- Error conditions: + -- None + -- Range: + -- ABS(COSH(Z)) <= SQRT(SINH(Z.RE)*SINH(Z.RE) + + -- COS(Z.IM)*COS(Z.IM)) + -- Notes: + -- None + + + function COSH (Z : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns principal value of hyperbolic cosine of Z + -- Special values: + -- COSH(Z) = COMPLEX_POLAR'(1.0, 0.0) if Z.MAG = 0.0 and + -- Z.ARG = 0.0 + -- COSH(Z) = COMPLEX_POLAR'(1.0, MATH_PI) if Z.MAG = MATH_PI and + -- Z.ARG = MATH_PI_OVER_2 + -- COSH(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = + -- MATH_PI_OVER_2 and Z.ARG = MATH_PI_OVER_2 + -- COSH(Z) = COMPLEX_POLAR'(0.0, 0.0) if Z.MAG = + -- MATH_PI_OVER_2 and Z.ARG = -MATH_PI_OVER_2 + -- Domain: + -- Z in COMPLEX_POLAR and Z.ARG /= -MATH_PI + -- Error conditions: + -- Error if Z.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + -- + -- Arithmetic Operators + -- + + function "+" (L : in COMPLEX; R : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns arithmetic addition of L and R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX + -- R in COMPLEX + -- Error conditions: + -- None + -- Range: + -- "+"(Z) is mathematically unbounded + -- Notes: + -- None + + function "+" (L : in REAL; R : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns arithmetic addition of L and R + -- Special values: + -- None + -- Domain: + -- L in REAL + -- R in COMPLEX + -- Error conditions: + -- None + -- Range: + -- "+"(Z) is mathematically unbounded + -- Notes: + -- None + + function "+" (L : in COMPLEX; R : in REAL) return COMPLEX; + -- Purpose: + -- Returns arithmetic addition of L and R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX + -- R in REAL + -- Error conditions: + -- None + -- Range: + -- "+"(Z) is mathematically unbounded + -- Notes: + -- None + + function "+" (L : in COMPLEX_POLAR; R : in COMPLEX_POLAR) + return COMPLEX_POLAR; + -- Purpose: + -- Returns arithmetic addition of L and R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI + -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI + -- Error conditions: + -- Error if L.ARG = -MATH_PI + -- Error if R.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + + function "+" (L : in REAL; R : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns arithmetic addition of L and R + -- Special values: + -- None + -- Domain: + -- L in REAL + -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI + -- Error conditions: + -- Error if R.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function "+" (L : in COMPLEX_POLAR; R : in REAL) return COMPLEX_POLAR; + -- Purpose: + -- Returns arithmetic addition of L and R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI + -- R in REAL + -- Error conditions: + -- Error if L.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function "-" (L : in COMPLEX; R : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns arithmetic subtraction of L minus R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX + -- R in COMPLEX + -- Error conditions: + -- None + -- Range: + -- "-"(Z) is mathematically unbounded + -- Notes: + -- None + + function "-" (L : in REAL; R : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns arithmetic subtraction of L minus R + -- Special values: + -- None + -- Domain: + -- L in REAL + -- R in COMPLEX + -- Error conditions: + -- None + -- Range: + -- "-"(Z) is mathematically unbounded + -- Notes: + -- None + + function "-" (L : in COMPLEX; R : in REAL) return COMPLEX; + -- Purpose: + -- Returns arithmetic subtraction of L minus R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX + -- R in REAL + -- Error conditions: + -- None + -- Range: + -- "-"(Z) is mathematically unbounded + -- Notes: + -- None + + function "-" (L : in COMPLEX_POLAR; R : in COMPLEX_POLAR) + return COMPLEX_POLAR; + -- Purpose: + -- Returns arithmetic subtraction of L minus R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI + -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI + -- Error conditions: + -- Error if L.ARG = -MATH_PI + -- Error if R.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function "-" (L : in REAL; R : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns arithmetic subtraction of L minus R + -- Special values: + -- None + -- Domain: + -- L in REAL + -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI + -- Error conditions: + -- Error if R.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + + function "-" (L : in COMPLEX_POLAR; R : in REAL) return COMPLEX_POLAR; + -- Purpose: + -- Returns arithmetic subtraction of L minus R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI + -- R in REAL + -- Error conditions: + -- Error if L.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function "*" (L : in COMPLEX; R : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns arithmetic multiplication of L and R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX + -- R in COMPLEX + -- Error conditions: + -- None + -- Range: + -- "*"(Z) is mathematically unbounded + -- Notes: + -- None + + function "*" (L : in REAL; R : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns arithmetic multiplication of L and R + -- Special values: + -- None + -- Domain: + -- L in REAL + -- R in COMPLEX + -- Error conditions: + -- None + -- Range: + -- "*"(Z) is mathematically unbounded + -- Notes: + -- None + + function "*" (L : in COMPLEX; R : in REAL) return COMPLEX; + -- Purpose: + -- Returns arithmetic multiplication of L and R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX + -- R in REAL + -- Error conditions: + -- None + + -- Range: + -- "*"(Z) is mathematically unbounded + -- Notes: + -- None + + function "*" (L : in COMPLEX_POLAR; R : in COMPLEX_POLAR) + return COMPLEX_POLAR; + -- Purpose: + -- Returns arithmetic multiplication of L and R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI + -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI + -- Error conditions: + -- Error if L.ARG = -MATH_PI + -- Error if R.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function "*" (L : in REAL; R : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns arithmetic multiplication of L and R + -- Special values: + -- None + -- Domain: + -- L in REAL + -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI + -- Error conditions: + -- Error if R.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function "*" (L : in COMPLEX_POLAR; R : in REAL) return COMPLEX_POLAR; + -- Purpose: + -- Returns arithmetic multiplication of L and R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI + -- R in REAL + -- Error conditions: + -- Error if L.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + + function "/" (L : in COMPLEX; R : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns arithmetic division of L by R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX + -- R in COMPLEX and R /= MATH_CZERO + -- Error conditions: + -- Error if R = MATH_CZERO + -- Range: + -- "/"(Z) is mathematically unbounded + -- Notes: + -- None + + function "/" (L : in REAL; R : in COMPLEX) return COMPLEX; + -- Purpose: + -- Returns arithmetic division of L by R + -- Special values: + -- None + -- Domain: + -- L in REAL + -- R in COMPLEX and R /= MATH_CZERO + -- Error conditions: + -- Error if R = MATH_CZERO + -- Range: + -- "/"(Z) is mathematically unbounded + -- Notes: + -- None + + function "/" (L : in COMPLEX; R : in REAL) return COMPLEX; + -- Purpose: + -- Returns arithmetic division of L by R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX + -- R in REAL and R /= 0.0 + -- Error conditions: + -- Error if R = 0.0 + -- Range: + -- "/"(Z) is mathematically unbounded + -- Notes: + -- None + + function "/" (L : in COMPLEX_POLAR; R : in COMPLEX_POLAR) + return COMPLEX_POLAR; + -- Purpose: + -- Returns arithmetic division of L by R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI + -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI + -- R.MAG > 0.0 + -- Error conditions: + -- Error if R.MAG <= 0.0 + -- Error if L.ARG = -MATH_PI + -- Error if R.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function "/" (L : in REAL; R : in COMPLEX_POLAR) return COMPLEX_POLAR; + -- Purpose: + -- Returns arithmetic division of L by R + -- Special values: + -- None + -- Domain: + -- L in REAL + -- R in COMPLEX_POLAR and R.ARG /= -MATH_PI + -- R.MAG > 0.0 + -- Error conditions: + -- Error if R.MAG <= 0.0 + -- Error if R.ARG = -MATH_PI + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None + + function "/" (L : in COMPLEX_POLAR; R : in REAL) return COMPLEX_POLAR; + -- Purpose: + -- Returns arithmetic division of L by R + -- Special values: + -- None + -- Domain: + -- L in COMPLEX_POLAR and L.ARG /= -MATH_PI + -- R /= 0.0 + -- Error conditions: + -- Error if L.ARG = -MATH_PI + -- Error if R = 0.0 + -- Range: + -- result.MAG >= 0.0 + -- -MATH_PI < result.ARG <= MATH_PI + -- Notes: + -- None +end package MATH_COMPLEX; diff --git a/libraries/ieee/math_real-body.vhdl b/libraries/ieee/math_real-body.vhdl index c20aab7c9..2386f82fa 100644 --- a/libraries/ieee/math_real-body.vhdl +++ b/libraries/ieee/math_real-body.vhdl @@ -1,53 +1,52 @@ ------------------------------------------------------------------------- +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- --- Copyright 1996 by IEEE. All rights reserved. - --- This source file is an informative part of IEEE Std 1076.2-1996, IEEE Standard --- VHDL Mathematical Packages. This source file may not be copied, sold, or --- included with software that is sold without written permission from the IEEE --- Standards Department. This source file may be used to implement this standard --- and may be distributed in compiled form in any manner so long as the --- compiled form does not allow direct decompilation of the original source file. --- This source file may be copied for individual use between licensed users. --- This source file is provided on an AS IS basis. The IEEE disclaims ANY --- WARRANTY EXPRESS OR IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY --- AND FITNESS FOR USE FOR A PARTICULAR PURPOSE. The user of the source --- file shall indemnify and hold IEEE harmless from any damages or liability --- arising out of the use thereof. - --- --- Title: Standard VHDL Mathematical Packages (IEEE Std 1076.2-1996, --- MATH_REAL) --- --- Library: This package shall be compiled into a library --- symbolically named IEEE. --- --- Developers: IEEE DASC VHDL Mathematical Packages Working Group --- --- Purpose: This package body is a nonnormative implementation of the --- functionality defined in the MATH_REAL package declaration. --- --- Limitation: The values generated by the functions in this package may --- vary from platform to platform, and the precision of results --- is only guaranteed to be the minimum required by IEEE Std 1076 --- -1993. --- --- Notes: --- The "package declaration" defines the types, subtypes, and --- declarations of MATH_REAL. --- The standard mathematical definition and conventional meaning --- of the mathematical functions that are part of this standard --- represent the formal semantics of the implementation of the --- MATH_REAL package declaration. The purpose of the MATH_REAL --- package body is to clarify such semantics and provide a --- guideline for implementations to verify their implementation --- of MATH_REAL. Tool developers may choose to implement --- the package body in the most efficient manner available to them. --- --- ----------------------------------------------------------------------------- --- Version : 1.5 --- Date : 24 July 1996 --- ----------------------------------------------------------------------------- +-- Title : Standard VHDL Mathematical Packages +-- : (MATH_REAL package body) +-- : +-- Library : This package shall be compiled into a library +-- : symbolically named IEEE. +-- : +-- Developers: IEEE DASC VHDL Mathematical Packages Working Group +-- : +-- Purpose : This package defines a standard for designers to use in +-- : describing VHDL models that make use of common REAL +-- : constants and common REAL elementary mathematical +-- : functions. +-- : +-- Limitation: The values generated by the functions in this package +-- : may vary from platform to platform, and the precision +-- : of results is only guaranteed to be the minimum required +-- : by IEEE Std 1076-2008. +-- : +-- Note : This package may be modified to include additional data +-- : required by tools, but it must in no way change the +-- : external interfaces or simulation behavior of the +-- : description. It is permissible to add comments and/or +-- : attributes to the package declarations, but not to change +-- : or delete any original lines of the package declaration. +-- : The package body may be changed only in accordance with +-- : the terms of Clause 16 of this standard. +-- : +-- -------------------------------------------------------------------- +-- $Revision: 1220 $ +-- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ +-- -------------------------------------------------------------------- package body MATH_REAL is @@ -101,7 +100,7 @@ package body MATH_REAL is FLAG := TRUE; end loop; return V; - end POWER_OF_2_SERIES; + end function POWER_OF_2_SERIES; constant TWO_AT_MINUS : REAL_VECTOR := POWER_OF_2_SERIES( @@ -183,7 +182,7 @@ package body MATH_REAL is end loop; end if; return REAL_ARR_3'(X, Y, Z); - end CORDIC; + end function CORDIC; -- -- Bodies for Global Mathematical Functions Start Here @@ -201,7 +200,7 @@ package body MATH_REAL is else return 0.0; end if; - end SIGN; + end function SIGN; function CEIL (X : in REAL ) return REAL is -- Description: @@ -240,7 +239,7 @@ package body MATH_REAL is return RD; end if; end if; - end CEIL; + end function CEIL; function FLOOR (X : in REAL ) return REAL is -- Description: @@ -279,7 +278,7 @@ package body MATH_REAL is return RD; end if; end if; - end FLOOR; + end function FLOOR; function ROUND (X : in REAL ) return REAL is -- Description: @@ -297,7 +296,7 @@ package body MATH_REAL is else return 0.0; end if; - end ROUND; + end function ROUND; function TRUNC (X : in REAL ) return REAL is -- Description: @@ -315,7 +314,7 @@ package body MATH_REAL is else return 0.0; end if; - end TRUNC; + end function TRUNC; @@ -326,8 +325,8 @@ package body MATH_REAL is -- Notes: -- a) Returns 0.0 on error - variable XNEGATIVE : BOOLEAN := X < 0.0; - variable YNEGATIVE : BOOLEAN := Y < 0.0; + constant XNEGATIVE : BOOLEAN := X < 0.0; + constant YNEGATIVE : BOOLEAN := Y < 0.0; variable VALUE : REAL; begin -- Check validity of input arguments @@ -354,7 +353,7 @@ package body MATH_REAL is end if; return VALUE; - end "MOD"; + end function "MOD"; function REALMAX (X, Y : in REAL ) return REAL is @@ -369,7 +368,7 @@ package body MATH_REAL is else return Y; end if; - end REALMAX; + end function REALMAX; function REALMIN (X, Y : in REAL ) return REAL is -- Description: @@ -383,7 +382,7 @@ package body MATH_REAL is else return Y; end if; - end REALMIN; + end function REALMIN; procedure UNIFORM(variable SEED1,SEED2:inout POSITIVE;variable X:out REAL) @@ -438,7 +437,7 @@ package body MATH_REAL is SEED1 := POSITIVE'(TSEED1); SEED2 := POSITIVE'(TSEED2); X := REAL(Z)*4.656613e-10; - end UNIFORM; + end procedure UNIFORM; @@ -490,7 +489,7 @@ package body MATH_REAL is COUNT := COUNT + 1; end loop; return NEWVAL; - end SQRT; + end function SQRT; function CBRT (X : in REAL ) return REAL is -- Description: @@ -503,7 +502,7 @@ package body MATH_REAL is variable INIVAL: REAL; variable XLOCAL : REAL := X; - variable NEGATIVE : BOOLEAN := X < 0.0; + constant NEGATIVE : BOOLEAN := X < 0.0; variable OLDVAL : REAL ; variable NEWVAL : REAL ; variable COUNT : INTEGER := 1; @@ -545,7 +544,7 @@ package body MATH_REAL is end if; return NEWVAL; - end CBRT; + end function CBRT; function "**" (X : in INTEGER; Y : in REAL) return REAL is -- Description: @@ -588,7 +587,7 @@ package body MATH_REAL is -- Get value for general case return EXP (Y * LOG (REAL(X))); - end "**"; + end function "**"; function "**" (X : in REAL; Y : in REAL) return REAL is -- Description: @@ -631,7 +630,7 @@ package body MATH_REAL is -- Get value for general case return EXP (Y * LOG (X)); - end "**"; + end function "**"; function EXP (X : in REAL ) return REAL is -- Description: @@ -649,7 +648,7 @@ package body MATH_REAL is -- constant EPS : REAL := BASE_EPS*BASE_EPS*BASE_EPS;-- Precision criteria - variable RECIPROCAL: BOOLEAN := X < 0.0;-- Check sign of argument + constant RECIPROCAL: BOOLEAN := X < 0.0;-- Check sign of argument variable XLOCAL : REAL := ABS(X); -- Use positive value variable OLDVAL: REAL ; variable COUNT: INTEGER ; @@ -733,7 +732,7 @@ package body MATH_REAL is end if; return NEWVAL; - end EXP; + end function EXP; -- @@ -767,7 +766,7 @@ package body MATH_REAL is N := N -1; end loop; return N; - end ILOGB; + end function ILOGB; function LDEXP(X: in REAL; N: in INTEGER) RETURN REAL IS -- Description: @@ -776,7 +775,7 @@ package body MATH_REAL is -- None begin return X*(2.0 ** N); - end LDEXP; + end function LDEXP; function LOG (X : in REAL ) return REAL IS -- Description: @@ -796,11 +795,7 @@ package body MATH_REAL is -- 2. Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. - -- 3. All advertising materials mentioning features or use of this - -- software must display the following acknowledgement: - -- This product includes software developed by the University of - -- California, Berkeley and its contributors. - -- 4. Neither the name of the University nor the names of its + -- 3. Neither the name of the University nor the names of its -- contributors may be used to endorse or promote products derived -- from this software without specific prior written permission. -- @@ -1103,8 +1098,6 @@ package body MATH_REAL is variable M, J:INTEGER; variable F1, F2, G, Q, U, U2, V: REAL; - variable ZERO: REAL := 0.0;--Made variable so no constant folding occurs - variable ONE: REAL := 1.0; --Made variable so no constant folding occurs -- double logb(), ldexp(); @@ -1171,7 +1164,7 @@ package body MATH_REAL is U2 := (U2 + LOGF_TAIL(J)) + Q; -- Tiny U2 := U2 + LOGF_TAIL(N)*REAL(M); return (U1 + U2); - end LOG; + end function LOG; function LOG2 (X: in REAL) return REAL is @@ -1199,7 +1192,7 @@ package body MATH_REAL is -- Compute value for general case return ( MATH_LOG2_OF_E*LOG(X) ); - end LOG2; + end function LOG2; function LOG10 (X: in REAL) return REAL is @@ -1227,7 +1220,7 @@ package body MATH_REAL is -- Compute value for general case return ( MATH_LOG10_OF_E*LOG(X) ); - end LOG10; + end function LOG10; function LOG (X: in REAL; BASE: in REAL) return REAL is @@ -1262,7 +1255,7 @@ package body MATH_REAL is -- Compute value for general case return ( LOG(X)/LOG(BASE)); - end LOG; + end function LOG; function SIN (X : in REAL ) return REAL is @@ -1280,7 +1273,7 @@ package body MATH_REAL is constant EPS : REAL := BASE_EPS*BASE_EPS; -- Convergence criteria variable N : INTEGER; - variable NEGATIVE : BOOLEAN := X < 0.0; + constant NEGATIVE : BOOLEAN := X < 0.0; variable XLOCAL : REAL := ABS(X) ; variable VALUE: REAL; variable TEMP : REAL; @@ -1293,10 +1286,8 @@ package body MATH_REAL is end if; if XLOCAL < 0.0 then - assert FALSE - report "XLOCAL <= 0.0 after reduction in SIN(X)" - severity ERROR; - XLOCAL := -XLOCAL; + -- adjust for rounding error + XLOCAL := 0.0; end if; -- Compute value for special cases @@ -1413,7 +1404,7 @@ package body MATH_REAL is -- Compute value for general cases if ((XLOCAL < MATH_PI_OVER_2 ) and (XLOCAL > 0.0)) then - VALUE:= CORDIC( KC, 0.0, x, 27, ROTATION)(1); + VALUE:= CORDIC( KC, 0.0, X, 27, ROTATION)(1); end if; N := INTEGER ( FLOOR(XLOCAL/MATH_PI_OVER_2)); @@ -1435,7 +1426,7 @@ package body MATH_REAL is else return VALUE; end if; - end SIN; + end function SIN; function COS (X : in REAL) return REAL is @@ -1452,7 +1443,6 @@ package body MATH_REAL is constant EPS : REAL := BASE_EPS*BASE_EPS; variable XLOCAL : REAL := ABS(X); - variable VALUE: REAL; variable TEMP : REAL; begin @@ -1463,10 +1453,8 @@ package body MATH_REAL is end if; if XLOCAL < 0.0 then - assert FALSE - report "XLOCAL <= 0.0 after reduction in COS(X)" - severity ERROR; - XLOCAL := -XLOCAL; + -- adjust for rounding error + XLOCAL := 0.0; end if; -- Compute value for special cases @@ -1511,7 +1499,7 @@ package body MATH_REAL is -- Compute value for general cases return SIN(MATH_PI_OVER_2 - XLOCAL); - end COS; + end function COS; function TAN (X : in REAL) return REAL is -- Description: @@ -1522,7 +1510,7 @@ package body MATH_REAL is -- c) Returns REAL'LOW on error if X < 0.0 -- d) Returns REAL'HIGH on error if X > 0.0 - variable NEGATIVE : BOOLEAN := X < 0.0; + constant NEGATIVE : BOOLEAN := X < 0.0; variable XLOCAL : REAL := ABS(X) ; variable VALUE: REAL; variable TEMP : REAL; @@ -1535,10 +1523,8 @@ package body MATH_REAL is end if; if XLOCAL < 0.0 then - assert FALSE - report "XLOCAL <= 0.0 after reduction in TAN(X)" - severity ERROR; - XLOCAL := -XLOCAL; + -- adjust for rounding error + XLOCAL := 0.0; end if; -- Check validity of argument @@ -1576,7 +1562,7 @@ package body MATH_REAL is else return VALUE; end if; - end TAN; + end function TAN; function ARCSIN (X : in REAL ) return REAL is -- Description: @@ -1585,8 +1571,8 @@ package body MATH_REAL is -- a) ARCSIN(-X) = -ARCSIN(X) -- b) Returns X on error - variable NEGATIVE : BOOLEAN := X < 0.0; - variable XLOCAL : REAL := ABS(X); + constant NEGATIVE : BOOLEAN := X < 0.0; + constant XLOCAL : REAL := ABS(X); variable VALUE : REAL; begin @@ -1621,7 +1607,7 @@ package body MATH_REAL is end if; return VALUE; - end ARCSIN; + end function ARCSIN; function ARCCOS (X : in REAL) return REAL is -- Description: @@ -1630,8 +1616,8 @@ package body MATH_REAL is -- a) ARCCOS(-X) = MATH_PI - ARCCOS(X) -- b) Returns X on error - variable NEGATIVE : BOOLEAN := X < 0.0; - variable XLOCAL : REAL := ABS(X); + constant NEGATIVE : BOOLEAN := X < 0.0; + constant XLOCAL : REAL := ABS(X); variable VALUE : REAL; begin @@ -1665,7 +1651,7 @@ package body MATH_REAL is end if; return VALUE; - end ARCCOS; + end function ARCCOS; function ARCTAN (Y : in REAL) return REAL is @@ -1678,7 +1664,7 @@ package body MATH_REAL is constant EPS : REAL := BASE_EPS*BASE_EPS*BASE_EPS; - variable NEGATIVE : BOOLEAN := Y < 0.0; + constant NEGATIVE : BOOLEAN := Y < 0.0; variable RECIPROCAL : BOOLEAN; variable YLOCAL : REAL := ABS(Y); variable VALUE : REAL; @@ -1733,7 +1719,7 @@ package body MATH_REAL is end if; return VALUE; - end ARCTAN; + end function ARCTAN; function ARCTAN (Y : in REAL; X : in REAL) return REAL is @@ -1786,7 +1772,7 @@ package body MATH_REAL is end if; return VALUE; - end ARCTAN; + end function ARCTAN; function SINH (X : in REAL) return REAL is @@ -1796,8 +1782,8 @@ package body MATH_REAL is -- a) Returns (EXP(X) - EXP(-X))/2.0 -- b) SINH(-X) = SINH(X) - variable NEGATIVE : BOOLEAN := X < 0.0; - variable XLOCAL : REAL := ABS(X); + constant NEGATIVE : BOOLEAN := X < 0.0; + constant XLOCAL : REAL := ABS(X); variable TEMP : REAL; variable VALUE : REAL; @@ -1816,7 +1802,7 @@ package body MATH_REAL is end if; return VALUE; - end SINH; + end function SINH; function COSH (X : in REAL) return REAL is -- Description: @@ -1825,7 +1811,7 @@ package body MATH_REAL is -- a) Returns (EXP(X) + EXP(-X))/2.0 -- b) COSH(-X) = COSH(X) - variable XLOCAL : REAL := ABS(X); + constant XLOCAL : REAL := ABS(X); variable TEMP : REAL; variable VALUE : REAL; begin @@ -1840,7 +1826,7 @@ package body MATH_REAL is VALUE := (TEMP + 1.0/TEMP)*0.5; return VALUE; - end COSH; + end function COSH; function TANH (X : in REAL) return REAL is -- Description: @@ -1849,8 +1835,8 @@ package body MATH_REAL is -- a) Returns (EXP(X) - EXP(-X))/(EXP(X) + EXP(-X)) -- b) TANH(-X) = -TANH(X) - variable NEGATIVE : BOOLEAN := X < 0.0; - variable XLOCAL : REAL := ABS(X); + constant NEGATIVE : BOOLEAN := X < 0.0; + constant XLOCAL : REAL := ABS(X); variable TEMP : REAL; variable VALUE : REAL; @@ -1869,7 +1855,7 @@ package body MATH_REAL is else return VALUE; end if; - end TANH; + end function TANH; function ARCSINH (X : in REAL) return REAL is -- Description: @@ -1885,7 +1871,7 @@ package body MATH_REAL is -- Compute value for general cases return ( LOG( X + SQRT( X*X + 1.0)) ); - end ARCSINH; + end function ARCSINH; @@ -1912,7 +1898,7 @@ package body MATH_REAL is -- Compute value for general cases return ( LOG( X + SQRT( X*X - 1.0))); - end ARCCOSH; + end function ARCCOSH; function ARCTANH (X : in REAL) return REAL is -- Description: @@ -1936,6 +1922,6 @@ package body MATH_REAL is -- Compute value for general cases return( 0.5*LOG( (1.0+X)/(1.0-X) ) ); - end ARCTANH; + end function ARCTANH; -end MATH_REAL; +end package body MATH_REAL; diff --git a/libraries/ieee/math_real.vhdl b/libraries/ieee/math_real.vhdl index ca1cec3fe..37d9a35df 100644 --- a/libraries/ieee/math_real.vhdl +++ b/libraries/ieee/math_real.vhdl @@ -1,628 +1,625 @@ ------------------------------------------------------------------------- +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- --- Copyright 1996 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076.2-1996, IEEE Standard --- VHDL Mathematical Packages. This source file may not be copied, sold, or --- included with software that is sold without written permission from the IEEE --- Standards Department. This source file may be used to implement this standard --- and may be distributed in compiled form in any manner so long as the --- compiled form does not allow direct decompilation of the original source file. --- This source file may be copied for individual use between licensed users. --- This source file is provided on an AS IS basis. The IEEE disclaims ANY --- WARRANTY EXPRESS OR IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY --- AND FITNESS FOR USE FOR A PARTICULAR PURPOSE. The user of the source --- file shall indemnify and hold IEEE harmless from any damages or liability --- arising out of the use thereof. --- --- Title: Standard VHDL Mathematical Packages (IEEE Std 1076.2-1996, --- MATH_REAL) --- --- Library: This package shall be compiled into a library --- symbolically named IEEE. --- --- Developers: IEEE DASC VHDL Mathematical Packages Working Group --- --- Purpose: This package defines a standard for designers to use in --- describing VHDL models that make use of common REAL constants --- and common REAL elementary mathematical functions. --- --- Limitation: The values generated by the functions in this package may --- vary from platform to platform, and the precision of results --- is only guaranteed to be the minimum required by IEEE Std 1076- --- 1993. --- --- Notes: --- No declarations or definitions shall be included in, or --- excluded from, this package. --- The "package declaration" defines the types, subtypes, and --- declarations of MATH_REAL. --- The standard mathematical definition and conventional meaning --- of the mathematical functions that are part of this standard --- represent the formal semantics of the implementation of the --- MATH_REAL package declaration. The purpose of the MATH_REAL --- package body is to provide a guideline for implementations to --- verify their implementation of MATH_REAL. Tool developers may --- choose to implement the package body in the most efficient --- manner available to them. --- --- ----------------------------------------------------------------------------- --- Version : 1.5 --- Date : 24 July 1996 --- ----------------------------------------------------------------------------- +-- Title : Standard VHDL Mathematical Packages +-- : (MATH_REAL package declaration) +-- : +-- Library : This package shall be compiled into a library +-- : symbolically named IEEE. +-- : +-- Developers: IEEE DASC VHDL Mathematical Packages Working Group +-- : +-- Purpose : This package defines a standard for designers to use in +-- : describing VHDL models that make use of common REAL +-- : constants and common REAL elementary mathematical +-- : functions. +-- : +-- Limitation: The values generated by the functions in this package +-- : may vary from platform to platform, and the precision +-- : of results is only guaranteed to be the minimum required +-- : by IEEE Std 1076-2008. +-- : +-- Note : This package may be modified to include additional data +-- : required by tools, but it must in no way change the +-- : external interfaces or simulation behavior of the +-- : description. It is permissible to add comments and/or +-- : attributes to the package declarations, but not to change +-- : or delete any original lines of the package declaration. +-- : The package body may be changed only in accordance with +-- : the terms of Clause 16 of this standard. +-- : +-- -------------------------------------------------------------------- +-- $Revision: 1220 $ +-- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ +-- -------------------------------------------------------------------- package MATH_REAL is - constant CopyRightNotice: STRING - := "Copyright 1996 IEEE. All rights reserved."; - - -- - -- Constant Definitions - -- - constant MATH_E : REAL := 2.71828_18284_59045_23536; - -- Value of e - constant MATH_1_OVER_E : REAL := 0.36787_94411_71442_32160; - -- Value of 1/e - constant MATH_PI : REAL := 3.14159_26535_89793_23846; - -- Value of pi - constant MATH_2_PI : REAL := 6.28318_53071_79586_47693; - -- Value of 2*pi - constant MATH_1_OVER_PI : REAL := 0.31830_98861_83790_67154; - -- Value of 1/pi - constant MATH_PI_OVER_2 : REAL := 1.57079_63267_94896_61923; - -- Value of pi/2 - constant MATH_PI_OVER_3 : REAL := 1.04719_75511_96597_74615; - -- Value of pi/3 - constant MATH_PI_OVER_4 : REAL := 0.78539_81633_97448_30962; - -- Value of pi/4 - constant MATH_3_PI_OVER_2 : REAL := 4.71238_89803_84689_85769; - -- Value 3*pi/2 - constant MATH_LOG_OF_2 : REAL := 0.69314_71805_59945_30942; - -- Natural log of 2 - constant MATH_LOG_OF_10 : REAL := 2.30258_50929_94045_68402; - -- Natural log of 10 - constant MATH_LOG2_OF_E : REAL := 1.44269_50408_88963_4074; - -- Log base 2 of e - constant MATH_LOG10_OF_E: REAL := 0.43429_44819_03251_82765; - -- Log base 10 of e - constant MATH_SQRT_2: REAL := 1.41421_35623_73095_04880; - -- square root of 2 - constant MATH_1_OVER_SQRT_2: REAL := 0.70710_67811_86547_52440; - -- square root of 1/2 - constant MATH_SQRT_PI: REAL := 1.77245_38509_05516_02730; - -- square root of pi - constant MATH_DEG_TO_RAD: REAL := 0.01745_32925_19943_29577; - -- Conversion factor from degree to radian - constant MATH_RAD_TO_DEG: REAL := 57.29577_95130_82320_87680; - -- Conversion factor from radian to degree - - -- - -- Function Declarations - -- - function SIGN (X: in REAL ) return REAL; - -- Purpose: - -- Returns 1.0 if X > 0.0; 0.0 if X = 0.0; -1.0 if X < 0.0 - -- Special values: - -- None - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- ABS(SIGN(X)) <= 1.0 - -- Notes: - -- None - - function CEIL (X : in REAL ) return REAL; - -- Purpose: - -- Returns smallest INTEGER value (as REAL) not less than X - -- Special values: - -- None - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- CEIL(X) is mathematically unbounded - -- Notes: - -- a) Implementations have to support at least the domain - -- ABS(X) < REAL(INTEGER'HIGH) - - function FLOOR (X : in REAL ) return REAL; - -- Purpose: - -- Returns largest INTEGER value (as REAL) not greater than X - -- Special values: - -- FLOOR(0.0) = 0.0 - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- FLOOR(X) is mathematically unbounded - -- Notes: - -- a) Implementations have to support at least the domain - -- ABS(X) < REAL(INTEGER'HIGH) - - function ROUND (X : in REAL ) return REAL; - -- Purpose: - -- Rounds X to the nearest integer value (as real). If X is - -- halfway between two integers, rounding is away from 0.0 - -- Special values: - -- ROUND(0.0) = 0.0 - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- ROUND(X) is mathematically unbounded - -- Notes: - -- a) Implementations have to support at least the domain - -- ABS(X) < REAL(INTEGER'HIGH) - - function TRUNC (X : in REAL ) return REAL; - -- Purpose: - -- Truncates X towards 0.0 and returns truncated value - -- Special values: - -- TRUNC(0.0) = 0.0 - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- TRUNC(X) is mathematically unbounded - -- Notes: - -- a) Implementations have to support at least the domain - -- ABS(X) < REAL(INTEGER'HIGH) - - function "MOD" (X, Y: in REAL ) return REAL; - -- Purpose: - -- Returns floating point modulus of X/Y, with the same sign as - -- Y, and absolute value less than the absolute value of Y, and - -- for some INTEGER value N the result satisfies the relation - -- X = Y*N + MOD(X,Y) - -- Special values: - -- None - -- Domain: - -- X in REAL; Y in REAL and Y /= 0.0 - -- Error conditions: - -- Error if Y = 0.0 - -- Range: - -- ABS(MOD(X,Y)) < ABS(Y) - -- Notes: - -- None - - function REALMAX (X, Y : in REAL ) return REAL; - -- Purpose: - -- Returns the algebraically larger of X and Y - -- Special values: - -- REALMAX(X,Y) = X when X = Y - -- Domain: - -- X in REAL; Y in REAL - -- Error conditions: - -- None - -- Range: - -- REALMAX(X,Y) is mathematically unbounded - -- Notes: - -- None - - function REALMIN (X, Y : in REAL ) return REAL; - -- Purpose: - -- Returns the algebraically smaller of X and Y - -- Special values: - -- REALMIN(X,Y) = X when X = Y - -- Domain: - -- X in REAL; Y in REAL - -- Error conditions: - -- None - -- Range: - -- REALMIN(X,Y) is mathematically unbounded - -- Notes: - -- None - - procedure UNIFORM(variable SEED1,SEED2:inout POSITIVE; variable X:out REAL); - -- Purpose: - -- Returns, in X, a pseudo-random number with uniform - -- distribution in the open interval (0.0, 1.0). - -- Special values: - -- None - -- Domain: - -- 1 <= SEED1 <= 2147483562; 1 <= SEED2 <= 2147483398 - -- Error conditions: - -- Error if SEED1 or SEED2 outside of valid domain - -- Range: - -- 0.0 < X < 1.0 - -- Notes: - -- a) The semantics for this function are described by the - -- algorithm published by Pierre L'Ecuyer in "Communications - -- of the ACM," vol. 31, no. 6, June 1988, pp. 742-774. - -- The algorithm is based on the combination of two - -- multiplicative linear congruential generators for 32-bit - -- platforms. - -- - -- b) Before the first call to UNIFORM, the seed values - -- (SEED1, SEED2) have to be initialized to values in the range - -- [1, 2147483562] and [1, 2147483398] respectively. The - -- seed values are modified after each call to UNIFORM. - -- - -- c) This random number generator is portable for 32-bit - -- computers, and it has a period of ~2.30584*(10**18) for each - -- set of seed values. - -- - -- d) For information on spectral tests for the algorithm, refer - -- to the L'Ecuyer article. - - function SQRT (X : in REAL ) return REAL; - -- Purpose: - -- Returns square root of X - -- Special values: - -- SQRT(0.0) = 0.0 - -- SQRT(1.0) = 1.0 - -- Domain: - -- X >= 0.0 - -- Error conditions: - -- Error if X < 0.0 - -- Range: - -- SQRT(X) >= 0.0 - -- Notes: - -- a) The upper bound of the reachable range of SQRT is - -- approximately given by: - -- SQRT(X) <= SQRT(REAL'HIGH) - - function CBRT (X : in REAL ) return REAL; - -- Purpose: - -- Returns cube root of X - -- Special values: - -- CBRT(0.0) = 0.0 - -- CBRT(1.0) = 1.0 - -- CBRT(-1.0) = -1.0 - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- CBRT(X) is mathematically unbounded - -- Notes: - -- a) The reachable range of CBRT is approximately given by: - -- ABS(CBRT(X)) <= CBRT(REAL'HIGH) - - function "**" (X : in INTEGER; Y : in REAL) return REAL; - -- Purpose: - -- Returns Y power of X ==> X**Y - -- Special values: - -- X**0.0 = 1.0; X /= 0 - -- 0**Y = 0.0; Y > 0.0 - -- X**1.0 = REAL(X); X >= 0 - -- 1**Y = 1.0 - -- Domain: - -- X > 0 - -- X = 0 for Y > 0.0 - -- X < 0 for Y = 0.0 - -- Error conditions: - -- Error if X < 0 and Y /= 0.0 - -- Error if X = 0 and Y <= 0.0 - -- Range: - -- X**Y >= 0.0 - -- Notes: - -- a) The upper bound of the reachable range for "**" is - -- approximately given by: - -- X**Y <= REAL'HIGH - - function "**" (X : in REAL; Y : in REAL) return REAL; - -- Purpose: - -- Returns Y power of X ==> X**Y - -- Special values: - -- X**0.0 = 1.0; X /= 0.0 - -- 0.0**Y = 0.0; Y > 0.0 - -- X**1.0 = X; X >= 0.0 - -- 1.0**Y = 1.0 - -- Domain: - -- X > 0.0 - -- X = 0.0 for Y > 0.0 - -- X < 0.0 for Y = 0.0 - -- Error conditions: - -- Error if X < 0.0 and Y /= 0.0 - -- Error if X = 0.0 and Y <= 0.0 - -- Range: - -- X**Y >= 0.0 - -- Notes: - -- a) The upper bound of the reachable range for "**" is - -- approximately given by: - -- X**Y <= REAL'HIGH - - function EXP (X : in REAL ) return REAL; - -- Purpose: - -- Returns e**X; where e = MATH_E - -- Special values: - -- EXP(0.0) = 1.0 - -- EXP(1.0) = MATH_E - -- EXP(-1.0) = MATH_1_OVER_E - -- EXP(X) = 0.0 for X <= -LOG(REAL'HIGH) - -- Domain: - -- X in REAL such that EXP(X) <= REAL'HIGH - -- Error conditions: - -- Error if X > LOG(REAL'HIGH) - -- Range: - -- EXP(X) >= 0.0 - -- Notes: - -- a) The usable domain of EXP is approximately given by: - -- X <= LOG(REAL'HIGH) - - function LOG (X : in REAL ) return REAL; - -- Purpose: - -- Returns natural logarithm of X - -- Special values: - -- LOG(1.0) = 0.0 - -- LOG(MATH_E) = 1.0 - -- Domain: - -- X > 0.0 - -- Error conditions: - -- Error if X <= 0.0 - -- Range: - -- LOG(X) is mathematically unbounded - -- Notes: - -- a) The reachable range of LOG is approximately given by: - -- LOG(0+) <= LOG(X) <= LOG(REAL'HIGH) - - function LOG2 (X : in REAL ) return REAL; - -- Purpose: - -- Returns logarithm base 2 of X - -- Special values: - -- LOG2(1.0) = 0.0 - -- LOG2(2.0) = 1.0 - -- Domain: - -- X > 0.0 - -- Error conditions: - -- Error if X <= 0.0 - -- Range: - -- LOG2(X) is mathematically unbounded - -- Notes: - -- a) The reachable range of LOG2 is approximately given by: - -- LOG2(0+) <= LOG2(X) <= LOG2(REAL'HIGH) - - function LOG10 (X : in REAL ) return REAL; - -- Purpose: - -- Returns logarithm base 10 of X - -- Special values: - -- LOG10(1.0) = 0.0 - -- LOG10(10.0) = 1.0 - -- Domain: - -- X > 0.0 - -- Error conditions: - -- Error if X <= 0.0 - -- Range: - -- LOG10(X) is mathematically unbounded - -- Notes: - -- a) The reachable range of LOG10 is approximately given by: - -- LOG10(0+) <= LOG10(X) <= LOG10(REAL'HIGH) - - function LOG (X: in REAL; BASE: in REAL) return REAL; - -- Purpose: - -- Returns logarithm base BASE of X - -- Special values: - -- LOG(1.0, BASE) = 0.0 - -- LOG(BASE, BASE) = 1.0 - -- Domain: - -- X > 0.0 - -- BASE > 0.0 - -- BASE /= 1.0 - -- Error conditions: - -- Error if X <= 0.0 - -- Error if BASE <= 0.0 - -- Error if BASE = 1.0 - -- Range: - -- LOG(X, BASE) is mathematically unbounded - -- Notes: - -- a) When BASE > 1.0, the reachable range of LOG is - -- approximately given by: - -- LOG(0+, BASE) <= LOG(X, BASE) <= LOG(REAL'HIGH, BASE) - -- b) When 0.0 < BASE < 1.0, the reachable range of LOG is - -- approximately given by: - -- LOG(REAL'HIGH, BASE) <= LOG(X, BASE) <= LOG(0+, BASE) - - function SIN (X : in REAL ) return REAL; - -- Purpose: - -- Returns sine of X; X in radians - -- Special values: - -- SIN(X) = 0.0 for X = k*MATH_PI, where k is an INTEGER - -- SIN(X) = 1.0 for X = (4*k+1)*MATH_PI_OVER_2, where k is an - -- INTEGER - -- SIN(X) = -1.0 for X = (4*k+3)*MATH_PI_OVER_2, where k is an - -- INTEGER - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- ABS(SIN(X)) <= 1.0 - -- Notes: - -- a) For larger values of ABS(X), degraded accuracy is allowed. - - function COS ( X : in REAL ) return REAL; - -- Purpose: - -- Returns cosine of X; X in radians - -- Special values: - -- COS(X) = 0.0 for X = (2*k+1)*MATH_PI_OVER_2, where k is an - -- INTEGER - -- COS(X) = 1.0 for X = (2*k)*MATH_PI, where k is an INTEGER - -- COS(X) = -1.0 for X = (2*k+1)*MATH_PI, where k is an INTEGER - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- ABS(COS(X)) <= 1.0 - -- Notes: - -- a) For larger values of ABS(X), degraded accuracy is allowed. - - function TAN (X : in REAL ) return REAL; - -- Purpose: - -- Returns tangent of X; X in radians - -- Special values: - -- TAN(X) = 0.0 for X = k*MATH_PI, where k is an INTEGER - -- Domain: - -- X in REAL and - -- X /= (2*k+1)*MATH_PI_OVER_2, where k is an INTEGER - -- Error conditions: - -- Error if X = ((2*k+1) * MATH_PI_OVER_2), where k is an - -- INTEGER - -- Range: - -- TAN(X) is mathematically unbounded - -- Notes: - -- a) For larger values of ABS(X), degraded accuracy is allowed. - - function ARCSIN (X : in REAL ) return REAL; - -- Purpose: - -- Returns inverse sine of X - -- Special values: - -- ARCSIN(0.0) = 0.0 - -- ARCSIN(1.0) = MATH_PI_OVER_2 - -- ARCSIN(-1.0) = -MATH_PI_OVER_2 - -- Domain: - -- ABS(X) <= 1.0 - -- Error conditions: - -- Error if ABS(X) > 1.0 - -- Range: - -- ABS(ARCSIN(X) <= MATH_PI_OVER_2 - -- Notes: - -- None - - function ARCCOS (X : in REAL ) return REAL; - -- Purpose: - -- Returns inverse cosine of X - -- Special values: - -- ARCCOS(1.0) = 0.0 - -- ARCCOS(0.0) = MATH_PI_OVER_2 - -- ARCCOS(-1.0) = MATH_PI - -- Domain: - -- ABS(X) <= 1.0 - -- Error conditions: - -- Error if ABS(X) > 1.0 - -- Range: - -- 0.0 <= ARCCOS(X) <= MATH_PI - -- Notes: - -- None - - function ARCTAN (Y : in REAL) return REAL; - -- Purpose: - -- Returns the value of the angle in radians of the point - -- (1.0, Y), which is in rectangular coordinates - -- Special values: - -- ARCTAN(0.0) = 0.0 - -- Domain: - -- Y in REAL - -- Error conditions: - -- None - -- Range: - -- ABS(ARCTAN(Y)) <= MATH_PI_OVER_2 - -- Notes: - -- None - - function ARCTAN (Y : in REAL; X : in REAL) return REAL; - -- Purpose: - -- Returns the principal value of the angle in radians of - -- the point (X, Y), which is in rectangular coordinates - -- Special values: - -- ARCTAN(0.0, X) = 0.0 if X > 0.0 - -- ARCTAN(0.0, X) = MATH_PI if X < 0.0 - -- ARCTAN(Y, 0.0) = MATH_PI_OVER_2 if Y > 0.0 - -- ARCTAN(Y, 0.0) = -MATH_PI_OVER_2 if Y < 0.0 - -- Domain: - -- Y in REAL - -- X in REAL, X /= 0.0 when Y = 0.0 - -- Error conditions: - -- Error if X = 0.0 and Y = 0.0 - -- Range: - -- -MATH_PI < ARCTAN(Y,X) <= MATH_PI - -- Notes: - -- None - - function SINH (X : in REAL) return REAL; - -- Purpose: - -- Returns hyperbolic sine of X - -- Special values: - -- SINH(0.0) = 0.0 - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- SINH(X) is mathematically unbounded - -- Notes: - -- a) The usable domain of SINH is approximately given by: - -- ABS(X) <= LOG(REAL'HIGH) - - - function COSH (X : in REAL) return REAL; - -- Purpose: - -- Returns hyperbolic cosine of X - -- Special values: - -- COSH(0.0) = 1.0 - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- COSH(X) >= 1.0 - -- Notes: - -- a) The usable domain of COSH is approximately given by: - -- ABS(X) <= LOG(REAL'HIGH) - - function TANH (X : in REAL) return REAL; - -- Purpose: - -- Returns hyperbolic tangent of X - -- Special values: - -- TANH(0.0) = 0.0 - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- ABS(TANH(X)) <= 1.0 - -- Notes: - -- None - - function ARCSINH (X : in REAL) return REAL; - -- Purpose: - -- Returns inverse hyperbolic sine of X - -- Special values: - -- ARCSINH(0.0) = 0.0 - -- Domain: - -- X in REAL - -- Error conditions: - -- None - -- Range: - -- ARCSINH(X) is mathematically unbounded - -- Notes: - -- a) The reachable range of ARCSINH is approximately given by: - -- ABS(ARCSINH(X)) <= LOG(REAL'HIGH) - - function ARCCOSH (X : in REAL) return REAL; - -- Purpose: - -- Returns inverse hyperbolic cosine of X - -- Special values: - -- ARCCOSH(1.0) = 0.0 - -- Domain: - -- X >= 1.0 - -- Error conditions: - -- Error if X < 1.0 - -- Range: - -- ARCCOSH(X) >= 0.0 - -- Notes: - -- a) The upper bound of the reachable range of ARCCOSH is - -- approximately given by: ARCCOSH(X) <= LOG(REAL'HIGH) - - function ARCTANH (X : in REAL) return REAL; - -- Purpose: - -- Returns inverse hyperbolic tangent of X - -- Special values: - -- ARCTANH(0.0) = 0.0 - -- Domain: - -- ABS(X) < 1.0 - -- Error conditions: - -- Error if ABS(X) >= 1.0 - -- Range: - -- ARCTANH(X) is mathematically unbounded - -- Notes: - -- a) The reachable range of ARCTANH is approximately given by: - -- ABS(ARCTANH(X)) < LOG(REAL'HIGH) - -end MATH_REAL; + constant CopyRightNotice : STRING + := "Copyright IEEE P1076 WG. Licensed Apache 2.0"; + + -- + -- Constant Definitions + -- + constant MATH_E : REAL := 2.71828_18284_59045_23536; + -- Value of e + constant MATH_1_OVER_E : REAL := 0.36787_94411_71442_32160; + -- Value of 1/e + constant MATH_PI : REAL := 3.14159_26535_89793_23846; + -- Value of pi + constant MATH_2_PI : REAL := 6.28318_53071_79586_47693; + -- Value of 2*pi + constant MATH_1_OVER_PI : REAL := 0.31830_98861_83790_67154; + -- Value of 1/pi + constant MATH_PI_OVER_2 : REAL := 1.57079_63267_94896_61923; + -- Value of pi/2 + constant MATH_PI_OVER_3 : REAL := 1.04719_75511_96597_74615; + -- Value of pi/3 + constant MATH_PI_OVER_4 : REAL := 0.78539_81633_97448_30962; + -- Value of pi/4 + constant MATH_3_PI_OVER_2 : REAL := 4.71238_89803_84689_85769; + -- Value 3*pi/2 + constant MATH_LOG_OF_2 : REAL := 0.69314_71805_59945_30942; + -- Natural log of 2 + constant MATH_LOG_OF_10 : REAL := 2.30258_50929_94045_68402; + -- Natural log of 10 + constant MATH_LOG2_OF_E : REAL := 1.44269_50408_88963_4074; + -- Log base 2 of e + constant MATH_LOG10_OF_E : REAL := 0.43429_44819_03251_82765; + -- Log base 10 of e + constant MATH_SQRT_2 : REAL := 1.41421_35623_73095_04880; + -- square root of 2 + constant MATH_1_OVER_SQRT_2 : REAL := 0.70710_67811_86547_52440; + -- square root of 1/2 + constant MATH_SQRT_PI : REAL := 1.77245_38509_05516_02730; + -- square root of pi + constant MATH_DEG_TO_RAD : REAL := 0.01745_32925_19943_29577; + -- Conversion factor from degree to radian + constant MATH_RAD_TO_DEG : REAL := 57.29577_95130_82320_87680; + -- Conversion factor from radian to degree + + -- + -- Function Declarations + -- + function SIGN (X : in REAL) return REAL; + -- Purpose: + -- Returns 1.0 if X > 0.0; 0.0 if X = 0.0; -1.0 if X < 0.0 + -- Special values: + -- None + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- ABS(SIGN(X)) <= 1.0 + -- Notes: + -- None + + function CEIL (X : in REAL) return REAL; + -- Purpose: + -- Returns smallest INTEGER value (as REAL) not less than X + -- Special values: + -- None + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- CEIL(X) is mathematically unbounded + -- Notes: + -- a) Implementations have to support at least the domain + -- ABS(X) < REAL(INTEGER'HIGH) + + function FLOOR (X : in REAL) return REAL; + -- Purpose: + -- Returns largest INTEGER value (as REAL) not greater than X + -- Special values: + -- FLOOR(0.0) = 0.0 + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- FLOOR(X) is mathematically unbounded + -- Notes: + -- a) Implementations have to support at least the domain + -- ABS(X) < REAL(INTEGER'HIGH) + + function ROUND (X : in REAL) return REAL; + -- Purpose: + -- Rounds X to the nearest integer value (as real). If X is + -- halfway between two integers, rounding is away from 0.0 + -- Special values: + -- ROUND(0.0) = 0.0 + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- ROUND(X) is mathematically unbounded + -- Notes: + -- a) Implementations have to support at least the domain + -- ABS(X) < REAL(INTEGER'HIGH) + + function TRUNC (X : in REAL) return REAL; + -- Purpose: + -- Truncates X towards 0.0 and returns truncated value + -- Special values: + -- TRUNC(0.0) = 0.0 + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- TRUNC(X) is mathematically unbounded + -- Notes: + -- a) Implementations have to support at least the domain + -- ABS(X) < REAL(INTEGER'HIGH) + + function "MOD" (X, Y : in REAL) return REAL; + -- Purpose: + -- Returns floating point modulus of X/Y, with the same sign as + -- Y, and absolute value less than the absolute value of Y, and + -- for some INTEGER value N the result satisfies the relation + -- X = Y*N + MOD(X,Y) + -- Special values: + -- None + -- Domain: + -- X in REAL; Y in REAL and Y /= 0.0 + -- Error conditions: + -- Error if Y = 0.0 + -- Range: + -- ABS(MOD(X,Y)) < ABS(Y) + -- Notes: + -- None + + function REALMAX (X, Y : in REAL) return REAL; + -- Purpose: + -- Returns the algebraically larger of X and Y + -- Special values: + -- REALMAX(X,Y) = X when X = Y + -- Domain: + -- X in REAL; Y in REAL + -- Error conditions: + -- None + -- Range: + -- REALMAX(X,Y) is mathematically unbounded + -- Notes: + -- None + + function REALMIN (X, Y : in REAL) return REAL; + -- Purpose: + -- Returns the algebraically smaller of X and Y + -- Special values: + -- REALMIN(X,Y) = X when X = Y + -- Domain: + -- X in REAL; Y in REAL + -- Error conditions: + -- None + -- Range: + -- REALMIN(X,Y) is mathematically unbounded + -- Notes: + -- None + + procedure UNIFORM(variable SEED1, SEED2 : inout POSITIVE; variable X : out REAL); + -- Purpose: + -- Returns, in X, a pseudo-random number with uniform + -- distribution in the open interval (0.0, 1.0). + -- Special values: + -- None + -- Domain: + -- 1 <= SEED1 <= 2147483562; 1 <= SEED2 <= 2147483398 + -- Error conditions: + -- Error if SEED1 or SEED2 outside of valid domain + -- Range: + -- 0.0 < X < 1.0 + -- Notes: + -- a) The semantics for this function are described by the + -- algorithm published by Pierre L'Ecuyer in "Communications + -- of the ACM," vol. 31, no. 6, June 1988, pp. 742-774. + -- The algorithm is based on the combination of two + -- multiplicative linear congruential generators for 32-bit + -- platforms. + -- + -- b) Before the first call to UNIFORM, the seed values + -- (SEED1, SEED2) have to be initialized to values in the range + -- [1, 2147483562] and [1, 2147483398] respectively. The + -- seed values are modified after each call to UNIFORM. + -- + -- c) This random number generator is portable for 32-bit + -- computers, and it has a period of ~2.30584*(10**18) for each + -- set of seed values. + -- + -- d) For information on spectral tests for the algorithm, refer + -- to the L'Ecuyer article. + + function SQRT (X : in REAL) return REAL; + -- Purpose: + -- Returns square root of X + -- Special values: + -- SQRT(0.0) = 0.0 + -- SQRT(1.0) = 1.0 + -- Domain: + -- X >= 0.0 + -- Error conditions: + -- Error if X < 0.0 + -- Range: + -- SQRT(X) >= 0.0 + -- Notes: + -- a) The upper bound of the reachable range of SQRT is + -- approximately given by: + -- SQRT(X) <= SQRT(REAL'HIGH) + + function CBRT (X : in REAL) return REAL; + -- Purpose: + -- Returns cube root of X + -- Special values: + -- CBRT(0.0) = 0.0 + -- CBRT(1.0) = 1.0 + -- CBRT(-1.0) = -1.0 + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- CBRT(X) is mathematically unbounded + -- Notes: + -- a) The reachable range of CBRT is approximately given by: + -- ABS(CBRT(X)) <= CBRT(REAL'HIGH) + + function "**" (X : in INTEGER; Y : in REAL) return REAL; + -- Purpose: + -- Returns Y power of X ==> X**Y + -- Special values: + -- X**0.0 = 1.0; X /= 0 + -- 0**Y = 0.0; Y > 0.0 + -- X**1.0 = REAL(X); X >= 0 + -- 1**Y = 1.0 + -- Domain: + -- X > 0 + -- X = 0 for Y > 0.0 + -- X < 0 for Y = 0.0 + -- Error conditions: + -- Error if X < 0 and Y /= 0.0 + -- Error if X = 0 and Y <= 0.0 + -- Range: + -- X**Y >= 0.0 + -- Notes: + -- a) The upper bound of the reachable range for "**" is + -- approximately given by: + -- X**Y <= REAL'HIGH + + function "**" (X : in REAL; Y : in REAL) return REAL; + -- Purpose: + -- Returns Y power of X ==> X**Y + -- Special values: + -- X**0.0 = 1.0; X /= 0.0 + -- 0.0**Y = 0.0; Y > 0.0 + -- X**1.0 = X; X >= 0.0 + -- 1.0**Y = 1.0 + -- Domain: + -- X > 0.0 + -- X = 0.0 for Y > 0.0 + -- X < 0.0 for Y = 0.0 + -- Error conditions: + -- Error if X < 0.0 and Y /= 0.0 + -- Error if X = 0.0 and Y <= 0.0 + -- Range: + -- X**Y >= 0.0 + -- Notes: + -- a) The upper bound of the reachable range for "**" is + -- approximately given by: + -- X**Y <= REAL'HIGH + + function EXP (X : in REAL) return REAL; + -- Purpose: + -- Returns e**X; where e = MATH_E + -- Special values: + -- EXP(0.0) = 1.0 + -- EXP(1.0) = MATH_E + -- EXP(-1.0) = MATH_1_OVER_E + -- EXP(X) = 0.0 for X <= -LOG(REAL'HIGH) + -- Domain: + -- X in REAL such that EXP(X) <= REAL'HIGH + -- Error conditions: + -- Error if X > LOG(REAL'HIGH) + -- Range: + -- EXP(X) >= 0.0 + -- Notes: + -- a) The usable domain of EXP is approximately given by: + -- X <= LOG(REAL'HIGH) + + function LOG (X : in REAL) return REAL; + -- Purpose: + -- Returns natural logarithm of X + -- Special values: + -- LOG(1.0) = 0.0 + -- LOG(MATH_E) = 1.0 + -- Domain: + -- X > 0.0 + -- Error conditions: + -- Error if X <= 0.0 + -- Range: + -- LOG(X) is mathematically unbounded + -- Notes: + -- a) The reachable range of LOG is approximately given by: + -- LOG(0+) <= LOG(X) <= LOG(REAL'HIGH) + + function LOG2 (X : in REAL) return REAL; + -- Purpose: + -- Returns logarithm base 2 of X + -- Special values: + -- LOG2(1.0) = 0.0 + -- LOG2(2.0) = 1.0 + -- Domain: + -- X > 0.0 + -- Error conditions: + -- Error if X <= 0.0 + -- Range: + -- LOG2(X) is mathematically unbounded + -- Notes: + -- a) The reachable range of LOG2 is approximately given by: + -- LOG2(0+) <= LOG2(X) <= LOG2(REAL'HIGH) + + function LOG10 (X : in REAL) return REAL; + -- Purpose: + -- Returns logarithm base 10 of X + -- Special values: + -- LOG10(1.0) = 0.0 + -- LOG10(10.0) = 1.0 + -- Domain: + -- X > 0.0 + -- Error conditions: + -- Error if X <= 0.0 + -- Range: + -- LOG10(X) is mathematically unbounded + -- Notes: + -- a) The reachable range of LOG10 is approximately given by: + -- LOG10(0+) <= LOG10(X) <= LOG10(REAL'HIGH) + + function LOG (X : in REAL; BASE : in REAL) return REAL; + -- Purpose: + -- Returns logarithm base BASE of X + -- Special values: + -- LOG(1.0, BASE) = 0.0 + -- LOG(BASE, BASE) = 1.0 + -- Domain: + -- X > 0.0 + -- BASE > 0.0 + -- BASE /= 1.0 + -- Error conditions: + -- Error if X <= 0.0 + -- Error if BASE <= 0.0 + -- Error if BASE = 1.0 + -- Range: + -- LOG(X, BASE) is mathematically unbounded + -- Notes: + -- a) When BASE > 1.0, the reachable range of LOG is + -- approximately given by: + -- LOG(0+, BASE) <= LOG(X, BASE) <= LOG(REAL'HIGH, BASE) + -- b) When 0.0 < BASE < 1.0, the reachable range of LOG is + -- approximately given by: + -- LOG(REAL'HIGH, BASE) <= LOG(X, BASE) <= LOG(0+, BASE) + + function SIN (X : in REAL) return REAL; + -- Purpose: + -- Returns sine of X; X in radians + -- Special values: + -- SIN(X) = 0.0 for X = k*MATH_PI, where k is an INTEGER + -- SIN(X) = 1.0 for X = (4*k+1)*MATH_PI_OVER_2, where k is an + -- INTEGER + -- SIN(X) = -1.0 for X = (4*k+3)*MATH_PI_OVER_2, where k is an + -- INTEGER + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- ABS(SIN(X)) <= 1.0 + -- Notes: + -- a) For larger values of ABS(X), degraded accuracy is allowed. + + function COS (X : in REAL) return REAL; + -- Purpose: + -- Returns cosine of X; X in radians + -- Special values: + -- COS(X) = 0.0 for X = (2*k+1)*MATH_PI_OVER_2, where k is an + -- INTEGER + -- COS(X) = 1.0 for X = (2*k)*MATH_PI, where k is an INTEGER + -- COS(X) = -1.0 for X = (2*k+1)*MATH_PI, where k is an INTEGER + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- ABS(COS(X)) <= 1.0 + -- Notes: + -- a) For larger values of ABS(X), degraded accuracy is allowed. + + function TAN (X : in REAL) return REAL; + -- Purpose: + -- Returns tangent of X; X in radians + -- Special values: + -- TAN(X) = 0.0 for X = k*MATH_PI, where k is an INTEGER + -- Domain: + -- X in REAL and + -- X /= (2*k+1)*MATH_PI_OVER_2, where k is an INTEGER + -- Error conditions: + -- Error if X = ((2*k+1) * MATH_PI_OVER_2), where k is an + -- INTEGER + -- Range: + -- TAN(X) is mathematically unbounded + -- Notes: + -- a) For larger values of ABS(X), degraded accuracy is allowed. + + function ARCSIN (X : in REAL) return REAL; + -- Purpose: + -- Returns inverse sine of X + -- Special values: + -- ARCSIN(0.0) = 0.0 + -- ARCSIN(1.0) = MATH_PI_OVER_2 + -- ARCSIN(-1.0) = -MATH_PI_OVER_2 + -- Domain: + -- ABS(X) <= 1.0 + -- Error conditions: + -- Error if ABS(X) > 1.0 + -- Range: + -- ABS(ARCSIN(X) <= MATH_PI_OVER_2 + -- Notes: + -- None + + function ARCCOS (X : in REAL) return REAL; + -- Purpose: + -- Returns inverse cosine of X + -- Special values: + -- ARCCOS(1.0) = 0.0 + -- ARCCOS(0.0) = MATH_PI_OVER_2 + -- ARCCOS(-1.0) = MATH_PI + -- Domain: + -- ABS(X) <= 1.0 + -- Error conditions: + -- Error if ABS(X) > 1.0 + -- Range: + -- 0.0 <= ARCCOS(X) <= MATH_PI + -- Notes: + -- None + + function ARCTAN (Y : in REAL) return REAL; + -- Purpose: + -- Returns the value of the angle in radians of the point + -- (1.0, Y), which is in rectangular coordinates + -- Special values: + -- ARCTAN(0.0) = 0.0 + -- Domain: + -- Y in REAL + -- Error conditions: + -- None + -- Range: + -- ABS(ARCTAN(Y)) <= MATH_PI_OVER_2 + -- Notes: + -- None + + function ARCTAN (Y : in REAL; X : in REAL) return REAL; + -- Purpose: + -- Returns the principal value of the angle in radians of + -- the point (X, Y), which is in rectangular coordinates + -- Special values: + -- ARCTAN(0.0, X) = 0.0 if X > 0.0 + -- ARCTAN(0.0, X) = MATH_PI if X < 0.0 + -- ARCTAN(Y, 0.0) = MATH_PI_OVER_2 if Y > 0.0 + -- ARCTAN(Y, 0.0) = -MATH_PI_OVER_2 if Y < 0.0 + -- Domain: + -- Y in REAL + -- X in REAL, X /= 0.0 when Y = 0.0 + -- Error conditions: + -- Error if X = 0.0 and Y = 0.0 + -- Range: + -- -MATH_PI < ARCTAN(Y,X) <= MATH_PI + -- Notes: + -- None + + function SINH (X : in REAL) return REAL; + -- Purpose: + -- Returns hyperbolic sine of X + -- Special values: + -- SINH(0.0) = 0.0 + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- SINH(X) is mathematically unbounded + -- Notes: + -- a) The usable domain of SINH is approximately given by: + -- ABS(X) <= LOG(REAL'HIGH) + + + function COSH (X : in REAL) return REAL; + -- Purpose: + -- Returns hyperbolic cosine of X + -- Special values: + -- COSH(0.0) = 1.0 + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- COSH(X) >= 1.0 + -- Notes: + -- a) The usable domain of COSH is approximately given by: + -- ABS(X) <= LOG(REAL'HIGH) + + function TANH (X : in REAL) return REAL; + -- Purpose: + -- Returns hyperbolic tangent of X + -- Special values: + -- TANH(0.0) = 0.0 + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- ABS(TANH(X)) <= 1.0 + -- Notes: + -- None + + function ARCSINH (X : in REAL) return REAL; + -- Purpose: + -- Returns inverse hyperbolic sine of X + -- Special values: + -- ARCSINH(0.0) = 0.0 + -- Domain: + -- X in REAL + -- Error conditions: + -- None + -- Range: + -- ARCSINH(X) is mathematically unbounded + -- Notes: + -- a) The reachable range of ARCSINH is approximately given by: + -- ABS(ARCSINH(X)) <= LOG(REAL'HIGH) + + function ARCCOSH (X : in REAL) return REAL; + -- Purpose: + -- Returns inverse hyperbolic cosine of X + -- Special values: + -- ARCCOSH(1.0) = 0.0 + -- Domain: + -- X >= 1.0 + -- Error conditions: + -- Error if X < 1.0 + -- Range: + -- ARCCOSH(X) >= 0.0 + -- Notes: + -- a) The upper bound of the reachable range of ARCCOSH is + -- approximately given by: ARCCOSH(X) <= LOG(REAL'HIGH) + + function ARCTANH (X : in REAL) return REAL; + -- Purpose: + -- Returns inverse hyperbolic tangent of X + -- Special values: + -- ARCTANH(0.0) = 0.0 + -- Domain: + -- ABS(X) < 1.0 + -- Error conditions: + -- Error if ABS(X) >= 1.0 + -- Range: + -- ARCTANH(X) is mathematically unbounded + -- Notes: + -- a) The reachable range of ARCTANH is approximately given by: + -- ABS(ARCTANH(X)) < LOG(REAL'HIGH) + +end package MATH_REAL; |