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