File : a-ngelfu-cert.ads
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUNTIME COMPONENTS --
4 -- --
5 -- ADA.NUMERICS.GENERIC_ELEMENTARY_FUNCTIONS --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2013, 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 Cert specific version of a-ngelfu.ads
33
34 -- Although this version of Ada.Numerics.Generic_Elementary_Functions is very
35 -- similar to the package defined by the Ada 95 standard, it is not intended
36 -- to fully implement the standard. Rather, the intent is to provide the
37 -- functionality of the environment in a convenient way. In particular, this
38 -- package does not implement Annex G, Numerics, and thus does not implement
39 -- strict mode.
40
41 -- One particular implication of the above is that, in contrast to libraries
42 -- adhering to the Ada 95 standard:
43
44 -- * Sqrt (1.0 - Cos(X) * Cos(x)) might raise an exception,
45 -- because Cos(x) might be slightly above 1.0
46
47 -- * Sin (X) might be slightly larger than X
48
49 -- * Sqrt (X) might be negative for very small X
50
51 -- This is not to say that these situations will occur. Just that there is no
52 -- requirement that explicitly states it will not occur.
53
54 -- Furthermore, hyperbolic functions are not provided, as they are not
55 -- implemented in the environment.
56
57 generic
58 type Float_Type is digits <>;
59
60 package Ada.Numerics.Generic_Elementary_Functions is
61 pragma Pure (Generic_Elementary_Functions);
62
63 function Sqrt (X : Float_Type'Base) return Float_Type'Base;
64 function Log (X : Float_Type'Base) return Float_Type'Base;
65 function Log (X, Base : Float_Type'Base) return Float_Type'Base;
66 function Exp (X : Float_Type'Base) return Float_Type'Base;
67 function "**" (Left, Right : Float_Type'Base) return Float_Type'Base;
68
69 function Sin (X : Float_Type'Base) return Float_Type'Base;
70 function Sin (X, Cycle : Float_Type'Base) return Float_Type'Base;
71 function Cos (X : Float_Type'Base) return Float_Type'Base;
72 function Cos (X, Cycle : Float_Type'Base) return Float_Type'Base;
73 function Tan (X : Float_Type'Base) return Float_Type'Base;
74 function Tan (X, Cycle : Float_Type'Base) return Float_Type'Base;
75 function Cot (X : Float_Type'Base) return Float_Type'Base;
76 function Cot (X, Cycle : Float_Type'Base) return Float_Type'Base;
77
78 function Arcsin (X : Float_Type'Base) return Float_Type'Base;
79 function Arcsin (X, Cycle : Float_Type'Base) return Float_Type'Base;
80 function Arccos (X : Float_Type'Base) return Float_Type'Base;
81 function Arccos (X, Cycle : Float_Type'Base) return Float_Type'Base;
82
83 function Arctan
84 (Y : Float_Type'Base;
85 X : Float_Type'Base := 1.0) return Float_Type'Base;
86
87 function Arctan
88 (Y : Float_Type'Base;
89 X : Float_Type'Base := 1.0;
90 Cycle : Float_Type'Base) return Float_Type'Base;
91
92 function Arccot
93 (X : Float_Type'Base;
94 Y : Float_Type'Base := 1.0) return Float_Type'Base;
95
96 function Arccot
97 (X : Float_Type'Base;
98 Y : Float_Type'Base := 1.0;
99 Cycle : Float_Type'Base) return Float_Type'Base;
100
101 private
102 pragma Assert
103 (Float_Type'Machine_Radix = 2,
104 "only binary floating-point types supported");
105
106 pragma Inline ("**");
107 pragma Inline (Arccos);
108 pragma Inline (Arccot);
109 pragma Inline (Arcsin);
110 pragma Inline (Arctan);
111 pragma Inline (Cos);
112 pragma Inline (Cot);
113 pragma Inline (Exp);
114 pragma Inline (Log);
115 pragma Inline (Sin);
116 pragma Inline (Sqrt);
117 pragma Inline (Tan);
118
119 end Ada.Numerics.Generic_Elementary_Functions;