annotate gcc/ada/libgnat/a-ngelfu.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- ADA.NUMERICS.GENERIC_ELEMENTARY_FUNCTIONS --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2012-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- This specification is derived from the Ada Reference Manual for use with --
kono
parents:
diff changeset
12 -- GNAT. The copyright notice above, and the license provisions that follow --
kono
parents:
diff changeset
13 -- apply solely to the Post aspects that have been added to the spec. --
kono
parents:
diff changeset
14 -- --
kono
parents:
diff changeset
15 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
16 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
17 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
18 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
19 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
20 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
23 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
24 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
25 -- --
kono
parents:
diff changeset
26 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
27 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
28 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
29 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
30 -- --
kono
parents:
diff changeset
31 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
32 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
33 -- --
kono
parents:
diff changeset
34 ------------------------------------------------------------------------------
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 generic
kono
parents:
diff changeset
37 type Float_Type is digits <>;
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 package Ada.Numerics.Generic_Elementary_Functions with
kono
parents:
diff changeset
40 SPARK_Mode => On
kono
parents:
diff changeset
41 is
kono
parents:
diff changeset
42 pragma Pure;
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 -- Preconditions in this unit are meant for analysis only, not for run-time
kono
parents:
diff changeset
45 -- checking, so that the expected exceptions are raised when calling
kono
parents:
diff changeset
46 -- Assert. This is enforced by setting the corresponding assertion policy
kono
parents:
diff changeset
47 -- to Ignore. This is done in the generic spec so that it applies to all
kono
parents:
diff changeset
48 -- instances.
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 pragma Assertion_Policy (Pre => Ignore);
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 function Sqrt (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
53 Pre => X >= 0.0,
kono
parents:
diff changeset
54 Post => Sqrt'Result >= 0.0
kono
parents:
diff changeset
55 and then (if X = 0.0 then Sqrt'Result = 0.0)
kono
parents:
diff changeset
56 and then (if X = 1.0 then Sqrt'Result = 1.0)
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 -- Finally if X is positive, the result of Sqrt is positive (because
kono
parents:
diff changeset
59 -- the sqrt of numbers greater than 1 is greater than or equal to 1,
kono
parents:
diff changeset
60 -- and the sqrt of numbers less than 1 is greater than the argument).
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 -- This property is useful in particular for static analysis. The
kono
parents:
diff changeset
63 -- property that X is positive is not expressed as (X > 0.0), as
kono
parents:
diff changeset
64 -- the value X may be held in registers that have larger range and
kono
parents:
diff changeset
65 -- precision on some architecture (for example, on x86 using x387
kono
parents:
diff changeset
66 -- FPU, as opposed to SSE2). So, it might be possible for X to be
kono
parents:
diff changeset
67 -- 2.0**(-5000) or so, which could cause the number to compare as
kono
parents:
diff changeset
68 -- greater than 0, but Sqrt would still return a zero result.
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 -- Note: we use the comparison with Succ (0.0) here because this is
kono
parents:
diff changeset
71 -- more amenable to CodePeer analysis than the use of 'Machine.
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 and then (if X >= Float_Type'Succ (0.0) then Sqrt'Result > 0.0);
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 function Log (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
76 Pre => X > 0.0,
kono
parents:
diff changeset
77 Post => (if X = 1.0 then Log'Result = 0.0);
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 function Log (X, Base : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
80 Pre => X > 0.0 and Base > 0.0 and Base /= 1.0,
kono
parents:
diff changeset
81 Post => (if X = 1.0 then Log'Result = 0.0);
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 function Exp (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
84 Post => (if X = 0.0 then Exp'Result = 1.0);
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 function "**" (Left, Right : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
87 Pre => (if Left = 0.0 then Right > 0.0) and Left >= 0.0,
kono
parents:
diff changeset
88 Post => "**"'Result >= 0.0
kono
parents:
diff changeset
89 and then (if Right = 0.0 then "**"'Result = 1.0)
kono
parents:
diff changeset
90 and then (if Right = 1.0 then "**"'Result = Left)
kono
parents:
diff changeset
91 and then (if Left = 1.0 then "**"'Result = 1.0)
kono
parents:
diff changeset
92 and then (if Left = 0.0 then "**"'Result = 0.0);
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 function Sin (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
95 Post => Sin'Result in -1.0 .. 1.0
kono
parents:
diff changeset
96 and then (if X = 0.0 then Sin'Result = 0.0);
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 function Sin (X, Cycle : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
99 Pre => Cycle > 0.0,
kono
parents:
diff changeset
100 Post => Sin'Result in -1.0 .. 1.0
kono
parents:
diff changeset
101 and then (if X = 0.0 then Sin'Result = 0.0);
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 function Cos (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
104 Post => Cos'Result in -1.0 .. 1.0
kono
parents:
diff changeset
105 and then (if X = 0.0 then Cos'Result = 1.0);
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 function Cos (X, Cycle : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
108 Pre => Cycle > 0.0,
kono
parents:
diff changeset
109 Post => Cos'Result in -1.0 .. 1.0
kono
parents:
diff changeset
110 and then (if X = 0.0 then Cos'Result = 1.0);
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 function Tan (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
113 Post => (if X = 0.0 then Tan'Result = 0.0);
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 function Tan (X, Cycle : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
116 Pre => Cycle > 0.0
kono
parents:
diff changeset
117 and then abs Float_Type'Base'Remainder (X, Cycle) /= 0.25 * Cycle,
kono
parents:
diff changeset
118 Post => (if X = 0.0 then Tan'Result = 0.0);
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 function Cot (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
121 Pre => X /= 0.0;
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 function Cot (X, Cycle : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
124 Pre => Cycle > 0.0
kono
parents:
diff changeset
125 and then X /= 0.0
kono
parents:
diff changeset
126 and then Float_Type'Base'Remainder (X, Cycle) /= 0.0
kono
parents:
diff changeset
127 and then abs Float_Type'Base'Remainder (X, Cycle) = 0.5 * Cycle;
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 function Arcsin (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
130 Pre => abs X <= 1.0,
kono
parents:
diff changeset
131 Post => (if X = 0.0 then Arcsin'Result = 0.0);
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 function Arcsin (X, Cycle : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
134 Pre => Cycle > 0.0 and abs X <= 1.0,
kono
parents:
diff changeset
135 Post => (if X = 0.0 then Arcsin'Result = 0.0);
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 function Arccos (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
138 Pre => abs X <= 1.0,
kono
parents:
diff changeset
139 Post => (if X = 1.0 then Arccos'Result = 0.0);
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 function Arccos (X, Cycle : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
142 Pre => Cycle > 0.0 and abs X <= 1.0,
kono
parents:
diff changeset
143 Post => (if X = 1.0 then Arccos'Result = 0.0);
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 function Arctan
kono
parents:
diff changeset
146 (Y : Float_Type'Base;
kono
parents:
diff changeset
147 X : Float_Type'Base := 1.0) return Float_Type'Base
kono
parents:
diff changeset
148 with
kono
parents:
diff changeset
149 Pre => X /= 0.0 or Y /= 0.0,
kono
parents:
diff changeset
150 Post => (if X > 0.0 and then Y = 0.0 then Arctan'Result = 0.0);
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 function Arctan
kono
parents:
diff changeset
153 (Y : Float_Type'Base;
kono
parents:
diff changeset
154 X : Float_Type'Base := 1.0;
kono
parents:
diff changeset
155 Cycle : Float_Type'Base) return Float_Type'Base
kono
parents:
diff changeset
156 with
kono
parents:
diff changeset
157 Pre => Cycle > 0.0 and (X /= 0.0 or Y /= 0.0),
kono
parents:
diff changeset
158 Post => (if X > 0.0 and then Y = 0.0 then Arctan'Result = 0.0);
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 function Arccot
kono
parents:
diff changeset
161 (X : Float_Type'Base;
kono
parents:
diff changeset
162 Y : Float_Type'Base := 1.0) return Float_Type'Base
kono
parents:
diff changeset
163 with
kono
parents:
diff changeset
164 Pre => X /= 0.0 or Y /= 0.0,
kono
parents:
diff changeset
165 Post => (if X > 0.0 and then Y = 0.0 then Arccot'Result = 0.0);
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 function Arccot
kono
parents:
diff changeset
168 (X : Float_Type'Base;
kono
parents:
diff changeset
169 Y : Float_Type'Base := 1.0;
kono
parents:
diff changeset
170 Cycle : Float_Type'Base) return Float_Type'Base
kono
parents:
diff changeset
171 with
kono
parents:
diff changeset
172 Pre => Cycle > 0.0 and (X /= 0.0 or Y /= 0.0),
kono
parents:
diff changeset
173 Post => (if X > 0.0 and then Y = 0.0 then Arccot'Result = 0.0);
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 function Sinh (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
176 Post => (if X = 0.0 then Sinh'Result = 0.0);
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 function Cosh (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
179 Post => Cosh'Result >= 1.0
kono
parents:
diff changeset
180 and then (if X = 0.0 then Cosh'Result = 1.0);
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 function Tanh (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
183 Post => Tanh'Result in -1.0 .. 1.0
kono
parents:
diff changeset
184 and then (if X = 0.0 then Tanh'Result = 0.0);
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 function Coth (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
187 Pre => X /= 0.0,
kono
parents:
diff changeset
188 Post => abs Coth'Result >= 1.0;
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 function Arcsinh (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
191 Post => (if X = 0.0 then Arcsinh'Result = 0.0);
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 function Arccosh (X : Float_Type'Base) return Float_Type'Base with
kono
parents:
diff changeset
194 Pre => X >= 1.0,
kono
parents:
diff changeset
195 Post => Arccosh'Result >= 0.0
kono
parents:
diff changeset
196 and then (if X = 1.0 then Arccosh'Result = 0.0);
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 function Arctanh (X : Float_Type'Base) return Float_Type'Base with
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
199 Pre => abs X < 1.0,
111
kono
parents:
diff changeset
200 Post => (if X = 0.0 then Arctanh'Result = 0.0);
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 function Arccoth (X : Float_Type'Base) return Float_Type'Base with
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
203 Pre => abs X > 1.0;
111
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 end Ada.Numerics.Generic_Elementary_Functions;