Synchronize with trunk's revision r57629.
[reactos.git] / include / c++ / cmath
1 //Standard C++ math declarations
2
3 #pragma once
4
5 #include <math.h>
6
7 // Get rid of those macros defined in <math.h> in lieu of real functions.
8 #undef abs
9 #undef div
10 #undef acos
11 #undef asin
12 #undef atan
13 #undef atan2
14 #undef ceil
15 #undef cos
16 #undef cosh
17 #undef exp
18 #undef fabs
19 #undef floor
20 #undef fmod
21 #undef frexp
22 #undef ldexp
23 #undef log
24 #undef log10
25 #undef modf
26 #undef pow
27 #undef sin
28 #undef sinh
29 #undef sqrt
30 #undef tan
31 #undef tanh
32
33 namespace std
34 {
35 // Forward declaration of a helper function. This really should be
36 // an `exported' forward declaration.
37 template<typename _Tp>
38 _Tp __cmath_power(_Tp, unsigned int);
39
40 template<typename _Tp>
41 inline _Tp
42 __pow_helper(_Tp __x, int __n)
43 {
44 return __n < 0
45 ? _Tp(1)/__cmath_power(__x, -__n)
46 : __cmath_power(__x, __n);
47 }
48
49 inline double
50 abs(double __x)
51 { return fabs(__x); }
52
53 inline float
54 abs(float __x)
55 { return fabsf(__x); }
56
57 inline long double
58 abs(long double __x)
59 { return fabsl(__x); }
60
61 using ::acos;
62
63 inline float
64 acos(float __x)
65 { return acosf(__x); }
66
67 inline long double
68 acos(long double __x)
69 { return acosl(__x); }
70
71 using ::asin;
72
73 inline float
74 asin(float __x)
75 { return asinf(__x); }
76
77 inline long double
78 asin(long double __x)
79 { return asinl(__x); }
80
81 using ::atan;
82
83 inline float
84 atan(float __x)
85 { return atanf(__x); }
86
87 inline long double
88 atan(long double __x)
89 { return atanl(__x); }
90
91 using ::atan2;
92
93 inline float
94 atan2(float __y, float __x)
95 { return atan2f(__y, __x); }
96
97 inline long double
98 atan2(long double __y, long double __x)
99 { return atan2l(__y, __x); }
100
101 using ::ceil;
102
103 inline float
104 ceil(float __x)
105 { return ceilf(__x); }
106
107 inline long double
108 ceil(long double __x)
109 { return ceill(__x); }
110
111 using ::cos;
112
113 inline float
114 cos(float __x)
115 { return cosf(__x); }
116
117 inline long double
118 cos(long double __x)
119 { return cosl(__x); }
120
121 using ::cosh;
122
123 inline float
124 cosh(float __x)
125 { return coshf(__x); }
126
127 inline long double
128 cosh(long double __x)
129 { return coshl(__x); }
130
131 using ::exp;
132
133 inline float
134 exp(float __x)
135 { return expf(__x); }
136
137 inline long double
138 exp(long double __x)
139 { return expl(__x); }
140
141 using ::fabs;
142
143 inline float
144 fabs(float __x)
145 { return fabsf(__x); }
146
147 inline long double
148 fabs(long double __x)
149 { return fabsl(__x); }
150
151 using ::floor;
152
153 inline float
154 floor(float __x)
155 { return floorf(__x); }
156
157 inline long double
158 floor(long double __x)
159 { return floorl(__x); }
160
161 using ::fmod;
162
163 inline float
164 fmod(float __x, float __y)
165 { return fmodf(__x, __y); }
166
167 inline long double
168 fmod(long double __x, long double __y)
169 { return fmodl(__x, __y); }
170
171 using ::frexp;
172
173 inline float
174 frexp(float __x, int* __exp)
175 { return frexpf(__x, __exp); }
176
177 inline long double
178 frexp(long double __x, int* __exp)
179 { return frexpl(__x, __exp); }
180
181 using ::ldexp;
182
183 inline float
184 ldexp(float __x, int __exp)
185 { return ldexpf(__x, __exp); }
186
187 inline long double
188 ldexp(long double __x, int __exp)
189 { return ldexpl(__x, __exp); }
190
191 using ::log;
192
193 inline float
194 log(float __x)
195 { return logf(__x); }
196
197 inline long double
198 log(long double __x)
199 { return logl(__x); }
200
201 using ::log10;
202
203 inline float
204 log10(float __x)
205 { return log10f(__x); }
206
207 inline long double
208 log10(long double __x)
209 { return log10l(__x); }
210
211 using ::modf;
212
213 inline float
214 modf(float __x, float* __iptr)
215 { return modff(__x, __iptr); }
216
217 inline long double
218 modf(long double __x, long double* __iptr)
219 { return modfl(__x, __iptr); }
220
221 using ::pow;
222
223 inline float
224 pow(float __x, float __y)
225 { return powf(__x, __y); }
226
227 inline long double
228 pow(long double __x, long double __y)
229 { return powl(__x, __y); }
230
231 inline double
232 pow(double __x, int __i)
233 { return pow(__x, static_cast<double>(__i)); }
234
235 inline float
236 pow(float __x, int __n)
237 { return powf(__x, static_cast<float>(__n)); }
238
239 inline long double
240 pow(long double __x, int __n)
241 { return powl(__x, static_cast<long double>(__n)); }
242
243 using ::sin;
244
245 inline float
246 sin(float __x)
247 { return sinf(__x); }
248
249 inline long double
250 sin(long double __x)
251 { return sinl(__x); }
252
253 using ::sinh;
254
255 inline float
256 sinh(float __x)
257 { return sinhf(__x); }
258
259 inline long double
260 sinh(long double __x)
261 { return sinhl(__x); }
262
263 using ::sqrt;
264
265 inline float
266 sqrt(float __x)
267 { return sqrtf(__x); }
268
269 inline long double
270 sqrt(long double __x)
271 { return sqrtl(__x); }
272
273 using ::tan;
274
275 inline float
276 tan(float __x)
277 { return tanf(__x); }
278
279 inline long double
280 tan(long double __x)
281 { return tanl(__x); }
282
283 using ::tanh;
284
285 inline float
286 tanh(float __x)
287 { return tanhf(__x); }
288
289 inline long double
290 tanh(long double __x)
291 { return tanhl(__x); }
292 }