OSDN Git Service

c25afa6c5527f662a3ecc63503a2ee0496ad7fb4
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / bits / std_cmath.h
1 // -*- C++ -*- C math library.
2
3 // Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library.  This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING.  If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
20
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction.  Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License.  This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
29
30 //
31 // ISO C++ 14882: 26.5  C library
32 //
33
34 // Note: this is not a conforming implementation.
35
36 #ifndef _CPP_CMATH
37 #define _CPP_CMATH 1
38 # pragma GCC system_header
39 # include_next <math.h>
40 # include_next <stdlib.h>
41
42 # include <bits/c++config.h>
43
44 namespace std {
45
46     //
47     // float
48     //
49
50 #if _GLIBCPP_HAVE___BUILTIN_FABSF
51     inline float abs(float __x)
52       { return __builtin_fabsf(__x); }
53 #elif _GLIBCPP_HAVE_FABSF
54     inline float abs(float __x)
55       { return ::fabsf(__x); }
56 #else
57     inline float abs(float __x)
58       { return ::fabs(static_cast<double>(__x)); }
59 #endif
60
61 #if _GLIBCPP_HAVE_ACOSF
62     inline float acos(float __x)
63       { return ::acosf(__x); }
64 #else
65     inline float acos(float __x)
66       { return ::acos(static_cast<double>(__x)); }
67 #endif
68
69 #if _GLIBCPP_HAVE_ASINF
70     inline float asin(float __x)
71       { return ::asinf(__x); }
72 #else
73     inline float asin(float __x)
74       { return ::asin(static_cast<double>(__x)); }
75 #endif
76
77 #if _GLIBCPP_HAVE_ATANF
78     inline float atan(float __x)
79       { return ::atanf(__x); }
80 #else
81     inline float atan(float __x)
82       { return ::atan(static_cast<double>(__x)); }
83 #endif
84
85 #if _GLIBCPP_HAVE_ATAN2F
86     inline float atan2(float __y, float __x)
87       { return ::atan2f(__y, __x); }
88 #else
89     inline float atan2(float __y, float __x)
90       { return ::atan2(static_cast<double>(__y), static_cast<double>(__x)); }
91 #endif
92
93 #if _GLIBCPP_HAVE_CEILF
94     inline float ceil(float __x)
95       { return ::ceilf(__x); }
96 #else
97     inline float ceil(float __x)
98       { return ::ceil(static_cast<double>(__x)); }
99 #endif
100
101 #if _GLIBCPP_HAVE___BUILTIN_COSF
102     inline float cos(float __x)
103       { return __builtin_cosf(__x); }
104 #elif _GLIBCPP_HAVE_COSF
105     inline float cos(float __x)
106       { return ::cosf(__x); }
107 #else
108     inline float cos(float __x)
109       { return ::cos(static_cast<double>(__x)); }
110 #endif
111
112 #if _GLIBCPP_HAVE_COSHF
113     inline float cosh(float __x)
114       { return ::coshf(__x); }
115 #else
116     inline float cosh(float __x)
117       { return ::cosh(static_cast<double>(__x)); }
118 #endif
119
120 #if _GLIBCPP_HAVE_EXPF
121     inline float exp(float __x)
122       { return ::expf(__x); }
123 #else
124     inline float exp(float __x)
125       { return ::exp(static_cast<double>(__x)); }
126 #endif
127
128 #if _GLIBCPP_HAVE___BUILTIN_FABSF
129     inline float fabs(float __x)
130       { return __builtin_fabsf(__x); }
131 #elif _GLIBCPP_HAVE_FABSF
132     inline float fabs(float __x)
133       { return ::fabsf(__x); }
134 #else
135     inline float fabs(float __x)
136       { return ::fabs(static_cast<double>(__x)); }
137 #endif
138
139 #if _GLIBCPP_HAVE_FLOORF
140     inline float floor(float __x)
141       { return ::floorf(__x); }
142 #else
143     inline float floor(float __x)
144       { return ::floor(static_cast<double>(__x)); }
145 #endif
146
147 #if _GLIBCPP_HAVE_FMODF
148     inline float fmod(float __x, float __y)
149       { return ::fmodf(__x, __y); }
150 #else
151     inline float fmod(float __x, float __y)
152       { return ::fmod(static_cast<double>(__x), static_cast<double>(__y)); }
153 #endif
154
155 #if _GLIBCPP_HAVE_FREXPF
156     inline float frexp(float __x, int* __exp)
157       { return ::frexpf(__x, __exp); }
158 #else
159     inline float frexp(float __x, int* __exp)
160       { return ::frexp(__x, __exp); }
161 #endif
162
163 #if _GLIBCPP_HAVE_LDEXPF
164     inline float ldexp(float __x, int __exp)
165       { return ::ldexpf(__x, __exp); }
166 #else
167     inline float ldexp(float __x, int __exp)
168       { return ::ldexp(static_cast<double>(__x), __exp); }
169 #endif
170
171 #if _GLIBCPP_HAVE_LOGF
172     inline float log(float __x)
173       { return ::logf(__x); }
174 #else
175     inline float log(float __x)
176       { return ::log(static_cast<double>(__x)); }
177 #endif
178
179 #if _GLIBCPP_HAVE_LOG10F
180     inline float log10(float __x)
181       { return ::log10f(__x); }
182 #else
183     inline float log10(float __x)
184       { return ::log10(static_cast<double>(__x)); }
185 #endif
186
187 #if _GLIBCPP_HAVE_MODFF
188     inline float modf(float __x, float* __iptr)
189       { return ::modff(__x, __iptr); }
190 #else
191     inline float modf(float __x, float* __iptr)
192     {
193        double __tmp;
194        double __res = ::modf(static_cast<double>(__x), &__tmp);
195        *__iptr = static_cast<float> (__tmp);
196        return __res;
197     }
198 #endif
199
200 #if _GLIBCPP_HAVE_POWF
201     inline float pow(float __x, float __y)
202       { return ::powf(__x, __y); }
203 #else
204     inline float pow(float __x, float __y)
205       { return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }
206 #endif
207
208     float pow(float, int);
209
210 #if _GLIBCPP_HAVE___BUILTIN_SINF
211     inline float sin(float __x)
212       { return __builtin_sinf(__x); }
213 #elif _GLIBCPP_HAVE_SINF
214     inline float sin(float __x)
215       { return ::sinf(__x); }
216 #else
217     inline float sin(float __x)
218       { return ::sin(static_cast<double>(__x)); }
219 #endif
220
221 #if _GLIBCPP_HAVE_SINHF
222     inline float sinh(float __x)
223       { return ::sinhf(__x); }
224 #else
225     inline float sinh(float __x)
226       { return ::sinh(static_cast<double>(__x)); }
227 #endif
228
229 #if _GLIBCPP_HAVE___BUILTIN_SQRTF
230     inline float sqrt(float __x)
231       { return __builtin_sqrtf(__x); }
232 #elif _GLIBCPP_HAVE_SQRTF
233     inline float sqrt(float __x)
234       { return ::sqrtf(__x); }
235 #else
236     inline float sqrt(float __x)
237       { return ::sqrt(static_cast<double>(__x)); }
238 #endif
239
240 #if _GLIBCPP_HAVE_TANF
241     inline float tan(float __x)
242       { return ::tanf(__x); }
243 #else
244     inline float tan(float __x)
245       { return ::tan(static_cast<double>(__x)); }
246 #endif
247
248 #if _GLIBCPP_HAVE_TANHF
249     inline float tanh(float __x)
250       { return ::tanhf(__x); }
251 #else
252     inline float tanh(float __x)
253       { return ::tanh(static_cast<double>(__x)); }
254 #endif
255
256     //
257     // double
258     //
259
260 #if _GLIBCPP_HAVE___BUILTIN_FABS
261     inline double abs(double __x)
262       { return __builtin_fabs(__x); }
263 #else
264     inline double abs(double __x)
265       { return ::fabs(__x); }
266 #endif
267
268     inline double acos(double __x)
269       { return ::acos(__x); }
270
271     inline double asin(double __x)
272       { return ::asin(__x); }
273
274     inline double atan(double __x)
275       { return ::atan(__x); }
276
277     inline double atan2(double __y, double __x)
278       { return ::atan2(__y, __x); }
279
280     inline double ceil(double __x)
281       { return ::ceil(__x); }
282
283 #if _GLIBCPP_HAVE___BUILTIN_COS
284     inline double cos(double __x)
285       { return __builtin_cos(__x); }
286 #else
287     inline double cos(double __x)
288       { return ::cos(__x); }
289 #endif
290
291     inline double cosh(double __x)
292       { return ::cosh(__x); }
293
294     inline double exp(double __x)
295       { return ::exp(__x); }
296
297
298 #if _GLIBCPP_HAVE___BUILTIN_FABS
299     inline double fabs(double __x)
300       { return __builtin_fabs(__x); }
301 #else
302     inline double fabs(double __x)
303       { return ::fabs(__x); }
304 #endif
305
306     inline double floor(double __x)
307       { return ::floor(__x); }
308
309     inline double fmod(double __x, double __y)
310       { return ::fmod(__x, __y); }
311
312     inline double frexp(double __x, int* __exp)
313       { return ::frexp(__x, __exp); }
314
315     inline double ldexp(double __x, int __exp)
316       { return ::ldexp(__x, __exp); }
317
318     inline double log(double __x)
319       { return ::log(__x); }
320
321     inline double log10(double __x)
322       { return ::log10(__x); }
323
324     inline double modf(double __x, double* __iptr)
325       { return ::modf(__x, __iptr); }
326
327     inline double pow(double __x, double __y)
328       { return ::pow(__x, __y); }
329
330     double pow (double, int);
331
332 #if _GLIBCPP_HAVE___BUILTIN_SIN
333     inline double sin(double __x)
334       { return __builtin_sin(__x); }
335 #else
336     inline double sin(double __x)
337       { return ::sin(__x); }
338 #endif
339
340     inline double sinh(double __x)
341       { return ::sinh(__x); }
342
343 #if _GLIBCPP_HAVE___BUILTIN_SQRT
344     inline double sqrt(double __x)
345       { return __builtin_fsqrt(__x); }
346 #else
347     inline double sqrt(double __x)
348       { return ::sqrt(__x); }
349 #endif
350
351     inline double tan(double __x)
352       { return ::tan(__x); }
353
354     inline double tanh(double __x)
355       { return ::tanh(__x); }
356
357     //
358     // long double
359     //
360 #if _GLIBCPP_HAVE___BUILTIN_FABSL
361     inline long double abs(long double __x)
362       { return __builtin_fabsl(__x); }
363 #elif _GLIBCPP_HAVE_FABSL
364     inline long double abs(long double __x)
365       { return ::fabsl(__x); }
366 #endif
367
368 #if _GLIBCPP_HAVE_ACOSL
369     inline long double acos(long double __x)
370       { return ::acosl(__x); }
371 #endif
372
373 #if _GLIBCPP_HAVE_ASINL
374     inline long double asin(long double __x)
375       { return ::asinl(__x); }
376 #endif
377
378 #if _GLIBCPP_HAVE_ATANL
379     inline long double atan(long double __x)
380       { return ::atanl(__x); }
381 #endif
382
383 #if _GLIBCPP_HAVE_ATAN2L
384     inline long double atan2(long double __y, long double __x)
385       { return ::atan2l(__y, __x); }
386 #endif
387
388 #if _GLIBCPP_HAVE_CEILL
389     inline long double ceil(long double __x)
390       { return ::ceill(__x); }
391 #endif
392
393 #if _GLIBCPP_HAVE___BUILTIN_COSL
394     inline long double cos(long double __x)
395       { return __builtin_cosl(__x); }
396 #elif _GLIBCPP_HAVE_COSL
397     inline long double cos(long double __x)
398       { return ::cosl(__x); }
399 #endif
400
401 #if _GLIBCPP_HAVE_COSHL
402     inline long double cosh(long double __x)
403       { return ::coshl(__x); }
404 #endif
405
406 #if _GLIBCPP_HAVE_EXPL
407     inline long double exp(long double __x)
408       { return ::expl(__x); }
409 #endif
410
411 #if _GLIBCPP_HAVE___BUILTIN_FABSL
412     inline long double fabs(long double __x)
413       { return __builtin_fabsl(__x); }
414 #elif _GLIBCPP_HAVE_FABSL
415     inline long double fabs(long double __x)
416       { return ::fabsl(__x); }
417 #endif
418
419 #if _GLIBCPP_HAVE_FLOORL
420     inline long double floor(long double __x)
421       { return ::floorl(__x); }
422 #endif
423
424 #if _GLIBCPP_HAVE_FMODL
425     inline long double fmod(long double __x, long double __y)
426       { return ::fmodl(__x, __y); }
427 #endif
428
429 #if _GLIBCPP_HAVE_FREXPL
430     inline long double frexp(long double __x, int* __exp)
431       { return ::frexpl(__x, __exp); }
432 #endif
433
434 #if _GLIBCPP_HAVE_LDEXPL
435     inline long double ldexp(long double __x, int __exp)
436       { return ::ldexpl(__x, __exp); }
437 #endif
438
439 #if _GLIBCPP_HAVE_LOGL
440     inline long double log(long double __x)
441       { return ::logl(__x); }
442 #endif
443
444 #if _GLIBCPP_HAVE_LOG10L
445     inline long double log10(long double __x)
446       { return ::log10l(__x); }
447 #endif
448
449 #if _GLIBCPP_HAVE_MODFL
450     inline long double modf(long double __x, long double* __iptr)
451       { return ::modfl(__x, __iptr); }
452 #endif
453
454 #if _GLIBCPP_HAVE_POWL
455     inline long double pow(long double __x, long double __y)
456       { return ::powl(__x, __y); }
457 #endif
458
459     long double pow(long double, int);
460
461 #if _GLIBCPP_HAVE___BUILTIN_SINL
462     inline long double sin(long double __x)
463       { return __builtin_sinl(__x); }
464 #elif _GLIBCPP_HAVE_SINL
465     inline long double sin(long double __x)
466       { return ::sinl(__x); }
467 #endif
468
469 #if _GLIBCPP_HAVE_SINHL
470     inline long double sinh(long double __x)
471       { return ::sinhl(__x); }
472 #endif
473
474 #if _GLIBCPP_HAVE___BUILTIN_SQRTL
475     inline long double sqrt(long double __x)
476       { return __builtin_sqrtl(__x); }
477 #elif _GLIBCPP_HAVE_SQRTL
478     inline long double sqrt(long double __x)
479       { return ::sqrtl(__x); }
480 #endif
481
482 #if _GLIBCPP_HAVE_TANL
483     inline long double tan(long double __x)
484       { return ::tanl(__x); }
485 #endif
486
487 #if _GLIBCPP_HAVE_TANHL
488     inline long double tanh(long double __x)
489       { return ::tanhl(__x); }
490 #endif
491
492 } // std
493
494 #endif // _CPP_CMATH
495
496