File : s-gcmain-ada.ads


   1 ------------------------------------------------------------------------------
   2 --                                                                          --
   3 --                         GNAT RUNTIME COMPONENTS                          --
   4 --                                                                          --
   5 --       S Y S T E M . G E N E R I C _ C _ M A T H _ I N T E R F A C E      --
   6 --                                                                          --
   7 --                                 S p e c                                  --
   8 --                                                                          --
   9 --          Copyright (C) 1992-2015, Free Software Foundation, Inc.         --
  10 --                                                                          --
  11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  12 -- terms of the  GNU General Public License as published  by the Free Soft- --
  13 -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
  14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  16 -- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
  17 --                                                                          --
  18 --                                                                          --
  19 --                                                                          --
  20 --                                                                          --
  21 --                                                                          --
  22 -- You should have received a copy of the GNU General Public License and    --
  23 -- a copy of the GCC Runtime Library Exception along with this program;     --
  24 -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
  25 -- <http://www.gnu.org/licenses/>.                                          --
  26 --                                                                          --
  27 -- GNAT was originally developed  by the GNAT team at  New York University. --
  28 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
  29 --                                                                          --
  30 ------------------------------------------------------------------------------
  31 
  32 --  This is the Ada Cert Math specific version of s-gcmain.ads.
  33 
  34 --  @llrset s-gcmain.ads
  35 --  Generic C Math Interface
  36 --  ========================
  37 --  Provide the elementary mathematical functions support library packages.
  38 
  39 --  This package is an implementation of the Ada elementary functions
  40 --  using the C math library. The C library is assumed to be conforming
  41 --  with ISO/IEC 9899:1999 (C99). In particular, all identities specified
  42 --  in chapter F.9 must hold. Furthermore, the accuracy of the various
  43 --  functions is assumed to be sufficient for the strict mode specified
  44 --  in Annex G of the Ada standard.
  45 
  46 --  For environments where this is not true, the generic Ada implementations
  47 --  should be used. These only require the standard arithmetic operations.
  48 
  49 --  Typically, the generic functions are imported from C as follows.
  50 --  For the C type "float":
  51 --    function Sin (X : Float) return Float;
  52 --    pragma Import (C, Sin, "sinf");
  53 
  54 --  or for the C type "double":
  55 --    function Sin (X : Long_Float) return Long_Float;
  56 --    pragma Import (C, Sin, "sin");
  57 
  58 --  or for the C type "long double":
  59 --    function Sin (X : Long_Long_Float) return Long_Long_Float
  60 --    pragma Import (C, Sin, "sinl");
  61 
  62 generic
  63    type Float_Type is digits <>;
  64 
  65    with function C_Sqrt  (X    : Float_Type) return Float_Type is <>;
  66    with function C_Log   (X    : Float_Type) return Float_Type is <>;
  67    with function C_Exp   (X    : Float_Type) return Float_Type is <>;
  68    with function C_Pow   (X, Y : Float_Type) return Float_Type is <>;
  69 
  70    with function C_Sin   (X    : Float_Type) return Float_Type is <>;
  71    with function C_Cos   (X    : Float_Type) return Float_Type is <>;
  72    with function C_Tan   (X    : Float_Type) return Float_Type is <>;
  73 
  74    with function C_Asin  (X    : Float_Type) return Float_Type is <>;
  75    with function C_Acos  (X    : Float_Type) return Float_Type is <>;
  76    with function C_Atan2 (Y, X : Float_Type) return Float_Type is <>;
  77 
  78    with function C_Sinh  (X    : Float_Type) return Float_Type is <>;
  79    with function C_Cosh  (X    : Float_Type) return Float_Type is <>;
  80    with function C_Tanh  (X    : Float_Type) return Float_Type is <>;
  81 
  82    with function C_Asinh (X    : Float_Type) return Float_Type is <>;
  83    with function C_Acosh (X    : Float_Type) return Float_Type is <>;
  84    with function C_Atanh (Y    : Float_Type) return Float_Type is <>;
  85 
  86 package System.Generic_C_Math_Interface is
  87 pragma Pure (Generic_C_Math_Interface);
  88 
  89    --  pragma Assert (Float_Type'Signed_Zeros);
  90    --  Assertion fails on e500v2 targets
  91    pragma Assert (Float_Type'Machine_Radix = 2);
  92 
  93    function Sqrt (X : Float_Type'Base) return Float_Type'Base;
  94    --  @llr Sqrt (Float_Type)
  95    --  This function shall return the square root of <X>
  96 
  97    function Log (X : Float_Type'Base) return Float_Type'Base;
  98    --  @llr Log (Float_Type)
  99    --  This function shall return the logarithm of <X>
 100 
 101    function Log (X, Base : Float_Type'Base) return Float_Type'Base;
 102    --  @llr Log (Float_Type; Float_Type)
 103    --  This function shall compute the logarithm of <X> with the specified base
 104 
 105    function Exp (X : Float_Type'Base) return Float_Type'Base;
 106    --  @llr Exp (Float_Type)
 107    --  This function shall compute the exponent of <X>
 108 
 109    function "**" (Left, Right : Float_Type'Base) return Float_Type'Base;
 110    --  @llr "**" (Float_Type; Float_Type)
 111    --  This function shall compute <Left> to the power of <Right>
 112 
 113    function Sin (X : Float_Type'Base) return Float_Type'Base;
 114    --  @llr Sin (Float_Type)
 115    --  This function shall return the sine of <X>
 116 
 117    function Sin (X, Cycle : Float_Type'Base) return Float_Type'Base;
 118    --  @llr Sin (Float_Type; Float_Type)
 119    --  This function shall return the sine of <X> with the specified base
 120 
 121    function Cos (X : Float_Type'Base) return Float_Type'Base;
 122    --  @llr Cos (Float_Type)
 123    --  This function shall return the cosine of <X>
 124 
 125    function Cos (X, Cycle : Float_Type'Base) return Float_Type'Base;
 126    --  @llr Cos (Float_Type; Float_Type)
 127    --  This function shall return the cosine of <X> with the specified base
 128 
 129    function Tan (X : Float_Type'Base) return Float_Type'Base;
 130    --  @llr Tan (Float_Type)
 131    --  This function shall return the tangent of <X>
 132 
 133    function Tan (X, Cycle : Float_Type'Base) return Float_Type'Base;
 134    --  @llr Tan (Float_Type; Float_Type)
 135    --  This function shall return the tangent of <X> with the specified base
 136 
 137    function Cot (X : Float_Type'Base) return Float_Type'Base;
 138    --  @llr Cot (Float_Type)
 139    --  This function shall return the cotangent of <X>
 140 
 141    function Cot (X, Cycle : Float_Type'Base) return Float_Type'Base;
 142    --  @llr Cot (Float_Type; Float_Type)
 143    --  This function shall return the cotangent of <X> with the specified base
 144 
 145    function Arcsin (X : Float_Type'Base) return Float_Type'Base;
 146    --  @llr Arcsin (Float_Type)
 147    --  This function shall return the inverse sine of <X>
 148 
 149    function Arcsin (X, Cycle : Float_Type'Base) return Float_Type'Base;
 150    --  @llr Arcsin (Float_Type; Float_Type)
 151    --  This function shall return the inverse sine of <X> with the specified
 152    --  base
 153 
 154    function Arccos (X  : Float_Type'Base) return Float_Type'Base;
 155    --  @llr Arccos (Float_Type)
 156    --  This function shall return the inverse cosine of <X>
 157 
 158    function Arccos  (X, Cycle    : Float_Type'Base) return Float_Type'Base;
 159    --  @llr Arccos (Float_Type; Float_Type)
 160    --  This function shall return the inverse cosine of <X> with the specified
 161    --  base
 162 
 163    function Arctan
 164      (Y : Float_Type'Base;
 165       X : Float_Type'Base := 1.0) return Float_Type'Base;
 166    --  @llr Arctan (Float_Type; Float_Type)
 167    --  This function shall compute the principal value of the inverse tangent
 168    --  of <Y> / <X>
 169 
 170    function Arctan
 171      (Y     : Float_Type'Base;
 172       X     : Float_Type'Base := 1.0;
 173       Cycle : Float_Type'Base) return Float_Type'Base;
 174    --  @llr Arctan (Float_Type; Float_Type; Float_Type)
 175    --  This function shall compute the principal value of the inverse tangent
 176    --  of <Y> / <X> with the specified base
 177 
 178    function Arccot
 179      (X : Float_Type'Base;
 180       Y : Float_Type'Base := 1.0) return Float_Type'Base;
 181    --  @llr Arccot (Float_Type; Float_Type)
 182    --  This function shall compute the principal value of the inverse cotangent
 183    --  of <Y> / <X>
 184 
 185    function Arccot
 186      (X     : Float_Type'Base;
 187       Y     : Float_Type'Base := 1.0;
 188       Cycle : Float_Type'Base) return Float_Type'Base;
 189    --  @llr Arccot (Float_Type; Float_Type; FLoat_Type)
 190    --  This function shall compute the principal value of the inverse cotangent
 191    --  of <Y> / <X> with the specified base
 192 
 193    function Sinh (X : Float_Type'Base) return Float_Type'Base;
 194    --  @llr Sinh (Float_Type)
 195    --  This function shall return the hyperbolic sine of <X>
 196 
 197    function Cosh (X : Float_Type'Base) return Float_Type'Base;
 198    --  @llr Cosh (Float_Type)
 199    --  This function shall return the hyperbolic cosine of <X>
 200 
 201    function Tanh (X : Float_Type'Base) return Float_Type'Base;
 202    --  @llr Tanh (Float_Type)
 203    --  This function shall return the hyperbolic tangent of <X>
 204 
 205    function Coth (X : Float_Type'Base) return Float_Type'Base;
 206    --  @llr Coth (Float_Type)
 207    --  This function shall return the hyperbolic cotangent of <X>
 208 
 209    function Arcsinh (X : Float_Type'Base) return Float_Type'Base;
 210    --  @llr Arcsinh (Float_Type)
 211    --  This function shall return the inverse hyperbolic sine of <X>
 212 
 213    function Arccosh (X : Float_Type'Base) return Float_Type'Base;
 214    --  @llr Arccosh (Float_Type)
 215    --  This function shall return the inverse hyperbolic cosine of <X>
 216 
 217    function Arctanh (X : Float_Type'Base) return Float_Type'Base;
 218    --  @llr Arctanh (Float_Type)
 219    --  This function shall return the inverse hyperbolic tangent of <X>
 220 
 221    function Arccoth (X : Float_Type'Base) return Float_Type'Base;
 222    --  @llr Arccoth (Float_Type)
 223    --  This function shall return the inverse hyperbolic cotangent of <X>
 224 
 225 end System.Generic_C_Math_Interface;