1 // -*- C++ -*- C forwarding header.
2 
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library.  This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
10 // any later version.
11 
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING.  If not, write to the Free
19 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 // USA.
21 
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction.  Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License.  This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
30 
31 //
32 // ISO C++ 14882: 26.5  C library
33 //
34 
35 /** @file cmath
36  *  This is a Standard C++ Library file.  You should @c #include this file
37  *  in your programs, rather than any of the "*.h" implementation files.
38  *
39  *  This is the C++ version of the Standard C Library header @c math.h,
40  *  and its contents are (mostly) the same as that header, but are all
41  *  contained in the namespace @c std.
42  */
43 
44 #ifndef _CPP_CMATH
45 #define _CPP_CMATH 1
46 
47 #pragma GCC system_header
48 
49 #include <bits/c++config.h>
50 #include <bits/cpp_type_traits.h>
51 
52 #include <math.h>
53 
54 // Get rid of those macros defined in <math.h> in lieu of real functions.
55 #undef abs
56 #undef div
57 #undef acos
58 #undef asin
59 #undef atan
60 #undef atan2
61 #undef ceil
62 #undef cos
63 #undef cosh
64 #undef exp
65 #undef fabs
66 #undef floor
67 #undef fmod
68 #undef frexp
69 #undef ldexp
70 #undef log
71 #undef log10
72 #undef modf
73 #undef pow
74 #undef sin
75 #undef sinh
76 #undef sqrt
77 #undef tan
78 #undef tanh
79 
80 // ...and in the darkness bind them...
81 namespace __gnu_cxx
82 {
83   namespace  __c99_binding
84   {
85 #if defined(_GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_CHECK) || \
86     defined(_GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC)
87     extern "C" float (acosf)(float);
88     extern "C" float (asinf)(float);
89     extern "C" float (atanf)(float);
90     extern "C" float (atan2f)(float, float);
91     extern "C" float (ceilf)(float);
92     extern "C" float (coshf)(float);
93     extern "C" float (expf)(float);
94     extern "C" float (floorf)(float);
95     extern "C" float (fmodf)(float, float);
96     extern "C" float (frexpf)(float, int*);
97     extern "C" float (ldexpf)(float, int);
98     extern "C" float (logf)(float);
99     extern "C" float (log10f)(float);
100     extern "C" float (modff)(float, float*);
101     extern "C" float (powf)(float, float);
102     extern "C" float (sinhf)(float);
103     extern "C" float (tanf)(float);
104     extern "C" float (tanhf)(float);
105 #endif
106 #if !defined(_GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC)
107 #if defined(_GLIBCPP_HAVE_ACOSF)
108     using ::acosf;
109 #endif
110 #if defined(_GLIBCPP_HAVE_ASINF)
111     using ::asinf;
112 #endif
113 #if defined(_GLIBCPP_HAVE_ATANF)
114     using ::atanf;
115 #endif
116 #if defined(_GLIBCPP_HAVE_ATAN2F)
117     using ::atan2f;
118 #endif
119 #if defined(_GLIBCPP_HAVE_CEILF)
120     using ::ceilf;
121 #endif
122 #if defined(_GLIBCPP_HAVE_COSHF)
123     using ::coshf;
124 #endif
125 #if defined(_GLIBCPP_HAVE_EXPF)
126     using ::expf;
127 #endif
128 #if defined(_GLIBCPP_HAVE_FLOORF)
129     using ::floorf;
130 #endif
131 #if defined(_GLIBCPP_HAVE_FMODF)
132     using ::fmodf;
133 #endif
134 #if defined(_GLIBCPP_HAVE_FREXPF)
135     using ::frexpf;
136 #endif
137 #if defined(_GLIBCPP_HAVE_LDEXPF)
138     using ::ldexpf;
139 #endif
140 #if defined(_GLIBCPP_HAVE_LOGF)
141     using ::logf;
142 #endif
143 #if defined(_GLIBCPP_HAVE_LOG10F)
144     using ::log10f;
145 #endif
146 #if defined(_GLIBCPP_HAVE_MODFF)
147     using ::modff;
148 #endif
149 #if defined(_GLIBCPP_HAVE_POWF)
150     using ::powf;
151 #endif
152 #if defined(_GLIBCPP_HAVE_SINHF)
153     using ::sinhf;
154 #endif
155 #if defined(_GLIBCPP_HAVE_TANF)
156     using ::tanf;
157 #endif
158 #if defined(_GLIBCPP_HAVE_TANHF)
159     using ::tanhf;
160 #endif
161 #endif /* _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC */
162   }
163 }
164 
165 namespace std
166 {
167   // Forward declaration of a helper function.  This really should be
168   // an `exported' forward declaration.
169   template<typename _Tp> _Tp __cmath_power(_Tp, unsigned int);
170 
171   inline double
abs(double __x)172   abs(double __x)
173   { return __builtin_fabs(__x); }
174 
175   inline float
abs(float __x)176   abs(float __x)
177   { return __builtin_fabsf(__x); }
178 
179   inline long double
abs(long double __x)180   abs(long double __x)
181   { return __builtin_fabsl(__x); }
182 
183 #if defined(_GLIBCPP_HAVE_ACOSF)
184   inline float
acos(float __x)185   acos(float __x) { return __gnu_cxx::__c99_binding::acosf(__x); }
186 #else
187   inline float
acos(float __x)188   acos(float __x) { return ::acos(static_cast<double>(__x)); }
189 #endif
190 
191   using ::acos;
192 
193 #if defined(_GLIBCPP_HAVE_ACOSL)
194   inline long double
acos(long double __x)195   acos(long double __x) { return ::acosl(__x); }
196 #else
197   inline long double
acos(long double __x)198   acos(long double __x) { return ::acos(static_cast<double>(__x)); }
199 #endif
200 
201   template<typename _Tp>
202     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
acos(_Tp __x)203     acos(_Tp __x)
204     {
205       return ::acos(static_cast<double>(__x));
206     }
207 
208   using ::asin;
209 
210 #if defined(_GLIBCPP_HAVE_ASINF)
211   inline float
asin(float __x)212   asin(float __x) { return __gnu_cxx::__c99_binding::asinf(__x); }
213 #else
214   inline float
asin(float __x)215   asin(float __x) { return ::asin(static_cast<double>(__x)); }
216 #endif
217 
218 #if defined(_GLIBCPP_HAVE_ASINL)
219   inline long double
asin(long double __x)220   asin(long double __x) { return ::asinl(__x); }
221 #else
222   inline long double
asin(long double __x)223   asin(long double __x) { return ::asin(static_cast<double>(__x)); }
224 #endif
225 
226   template<typename _Tp>
227     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
asin(_Tp __x)228     asin(_Tp __x)
229     { return ::asin(static_cast<double>(__x)); }
230 
231   using ::atan;
232 
233 #if defined(_GLIBCPP_HAVE_ATANF)
234   inline float
atan(float __x)235   atan(float __x) { return __gnu_cxx::__c99_binding::atanf(__x); }
236 #else
237   inline float
atan(float __x)238   atan(float __x) { return ::atan(static_cast<double>(__x)); }
239 #endif
240 
241 #if defined(_GLIBCPP_HAVE_ATANL)
242   inline long double
atan(long double __x)243   atan(long double __x) { return ::atanl(__x); }
244 #else
245   inline long double
atan(long double __x)246   atan(long double __x) { return ::atan(static_cast<double>(__x)); }
247 #endif
248 
249   template<typename _Tp>
250     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
atan(_Tp __x)251     atan(_Tp __x)
252     { return ::atan(static_cast<double>(__x)); }
253 
254   using ::atan2;
255 
256 #if defined(_GLIBCPP_HAVE_ATAN2F)
257   inline float
atan2(float __y,float __x)258   atan2(float __y, float __x) { return __gnu_cxx::__c99_binding::atan2f(__y, __x); }
259 #else
260   inline float
atan2(float __y,float __x)261   atan2(float __y, float __x)
262   { return ::atan2(static_cast<double>(__y), static_cast<double>(__x)); }
263 #endif
264 
265 #if defined(_GLIBCPP_HAVE_ATAN2L)
266   inline long double
atan2(long double __y,long double __x)267   atan2(long double __y, long double __x) { return ::atan2l(__y, __x); }
268 #else
269   inline long double
atan2(long double __y,long double __x)270   atan2(long double __y, long double __x)
271   { return ::atan2(static_cast<double>(__y), static_cast<double>(__x)); }
272 #endif
273 
274   template<typename _Tp, typename _Up>
275     inline typename __enable_if<double, __is_integer<_Tp>::_M_type
276                                         && __is_integer<_Up>::_M_type>::_M_type
atan2(_Tp __x,_Up __y)277     atan2(_Tp __x, _Up __y)
278     { return ::atan2(static_cast<double>(__x), static_cast<double>(__y)); }
279 
280   using ::ceil;
281 
282 #if defined(_GLIBCPP_HAVE_CEILF)
283   inline float
ceil(float __x)284   ceil(float __x) { return __gnu_cxx::__c99_binding::ceilf(__x); }
285 #else
286   inline float
ceil(float __x)287   ceil(float __x) { return ::ceil(static_cast<double>(__x)); }
288 #endif
289 
290 #if defined(_GLIBCPP_HAVE_CEILL)
291   inline long double
ceil(long double __x)292   ceil(long double __x) { return ::ceill(__x); }
293 #else
294   inline long double
ceil(long double __x)295   ceil(long double __x) { return ::ceil(static_cast<double>(__x)); }
296 #endif
297 
298   template<typename _Tp>
299     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
ceil(_Tp __x)300     ceil(_Tp __x)
301     { return ::ceil(static_cast<double>(__x)); }
302 
303   using ::cos;
304 
305   inline float
cos(float __x)306   cos(float __x)
307   { return __builtin_cosf(__x); }
308 
309   inline long double
cos(long double __x)310   cos(long double __x)
311   { return __builtin_cosl(__x); }
312 
313   template<typename _Tp>
314     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
cos(_Tp __x)315     cos(_Tp __x)
316     { return __builtin_cos(__x); }
317 
318   using ::cosh;
319 
320 #if defined(_GLIBCPP_HAVE_COSHF)
321   inline float
cosh(float __x)322   cosh(float __x) { return __gnu_cxx::__c99_binding::coshf(__x); }
323 #else
324   inline float
cosh(float __x)325   cosh(float __x) { return ::cosh(static_cast<double>(__x)); }
326 #endif
327 
328 #if defined(_GLIBCPP_HAVE_COSHL)
329   inline long double
cosh(long double __x)330   cosh(long double __x) { return ::coshl(__x); }
331 #else
332   inline long double
cosh(long double __x)333   cosh(long double __x) { return ::cosh(static_cast<double>(__x)); }
334 #endif
335 
336   template<typename _Tp>
337     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
cosh(_Tp __x)338     cosh(_Tp __x)
339     { return ::cosh(static_cast<double>(__x)); }
340 
341   using ::exp;
342 
343 #if defined(_GLIBCPP_HAVE_EXPF)
344   inline float
exp(float __x)345   exp(float __x) { return __gnu_cxx::__c99_binding::expf(__x); }
346 #else
347   inline float
exp(float __x)348   exp(float __x) { return ::exp(static_cast<double>(__x)); }
349 #endif
350 
351 #if defined(_GLIBCPP_HAVE_EXPL)
352   inline long double
exp(long double __x)353   exp(long double __x) { return ::expl(__x); }
354 #else
355   inline long double
exp(long double __x)356   exp(long double __x) { return ::exp(static_cast<double>(__x)); }
357 #endif
358 
359   template<typename _Tp>
360     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
exp(_Tp __x)361     exp(_Tp __x)
362     { return ::exp(static_cast<double>(__x)); }
363 
364   using ::fabs;
365 
366   inline float
fabs(float __x)367   fabs(float __x)
368   { return __builtin_fabsf(__x); }
369 
370   inline long double
fabs(long double __x)371   fabs(long double __x)
372   { return __builtin_fabsl(__x); }
373 
374   template<typename _Tp>
375     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
fabs(_Tp __x)376     fabs(_Tp __x)
377     { return __builtin_fabs(__x); }
378 
379   using ::floor;
380 
381 #if defined(_GLIBCPP_HAVE_FLOORF)
382   inline float
floor(float __x)383   floor(float __x) { return __gnu_cxx::__c99_binding::floorf(__x); }
384 #else
385   inline float
floor(float __x)386   floor(float __x) { return ::floor(static_cast<double>(__x)); }
387 #endif
388 
389 #if defined(_GLIBCPP_HAVE_FLOORL)
390   inline long double
floor(long double __x)391   floor(long double __x) { return ::floorl(__x); }
392 #else
393   inline long double
floor(long double __x)394   floor(long double __x) { return ::floor(static_cast<double>(__x)); }
395 #endif
396 
397   template<typename _Tp>
398     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
floor(_Tp __x)399     floor(_Tp __x)
400     { return ::floor(static_cast<double>(__x)); }
401 
402   using ::fmod;
403 
404 #if defined(_GLIBCPP_HAVE_FMODF)
405   inline float
fmod(float __x,float __y)406   fmod(float __x, float __y) { return __gnu_cxx::__c99_binding::fmodf(__x, __y); }
407 #else
408   inline float
fmod(float __x,float __y)409   fmod(float __x, float __y)
410   { return ::fmod(static_cast<double>(__x), static_cast<double>(__y)); }
411 #endif
412 
413 #if defined(_GLIBCPP_HAVE_FMODL)
414   inline long double
fmod(long double __x,long double __y)415   fmod(long double __x, long double __y) { return ::fmodl(__x, __y); }
416 #else
417   inline long double
fmod(long double __x,long double __y)418   fmod(long double __x, long double __y)
419   { return ::fmod(static_cast<double>(__x), static_cast<double>(__y)); }
420 #endif
421 
422   using ::frexp;
423 
424 #if defined(_GLIBCPP_HAVE_FREXPF)
425   inline float
frexp(float __x,int * __exp)426   frexp(float __x, int* __exp) { return __gnu_cxx::__c99_binding::frexpf(__x, __exp); }
427 #else
428   inline float
frexp(float __x,int * __exp)429   frexp(float __x, int* __exp) { return ::frexp(__x, __exp); }
430 #endif
431 
432 #if defined(_GLIBCPP_HAVE_FREXPL)
433   inline long double
frexp(long double __x,int * __exp)434   frexp(long double __x, int* __exp) { return ::frexpl(__x, __exp); }
435 #else
436   inline long double
frexp(long double __x,int * __exp)437   frexp(long double __x, int* __exp)
438   { return ::frexp(static_cast<double>(__x), __exp); }
439 #endif
440 
441   template<typename _Tp>
442     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
frexp(_Tp __x,int * __exp)443     frexp(_Tp __x, int* __exp)
444     { return ::frexp(static_cast<double>(__x), __exp); }
445 
446   using ::ldexp;
447 
448 #if defined(_GLIBCPP_HAVE_LDEXPF)
449   inline float
ldexp(float __x,int __exp)450   ldexp(float __x, int __exp) { return __gnu_cxx::__c99_binding::ldexpf(__x, __exp); }
451 #else
452   inline float
ldexp(float __x,int __exp)453   ldexp(float __x, int __exp)
454   { return ::ldexp(static_cast<double>(__x), __exp); }
455 #endif
456 
457 #if defined(_GLIBCPP_HAVE_LDEXPL)
458   inline long double
ldexp(long double __x,int __exp)459   ldexp(long double __x, int __exp) { return ::ldexpl(__x, __exp); }
460 #else
461   inline long double
ldexp(long double __x,int __exp)462   ldexp(long double __x, int __exp)
463   { return ::ldexp(static_cast<double>(__x), __exp); }
464 #endif
465 
466   template<typename _Tp>
467   inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
ldexp(_Tp __x,int __exp)468   ldexp(_Tp __x, int __exp)
469   { return ::ldexp(static_cast<double>(__x), __exp); }
470 
471   using ::log;
472 
473 #if defined(_GLIBCPP_HAVE_LOGF)
474   inline float
log(float __x)475   log(float __x) { return __gnu_cxx::__c99_binding::logf(__x); }
476 #else
log(float __x)477   inline float log(float __x)
478   { return ::log(static_cast<double>(__x)); }
479 #endif
480 
481 #if defined(_GLIBCPP_HAVE_LOGL)
482   inline long double
log(long double __x)483   log(long double __x) { return ::logl(__x); }
484 #else
485   inline long double
log(long double __x)486   log(long double __x) { return ::log(static_cast<double>(__x)); }
487 #endif
488 
489   template<typename _Tp>
490     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
log(_Tp __x)491     log(_Tp __x)
492     { return ::log(static_cast<double>(__x)); }
493 
494   using ::log10;
495 
496 #if defined(_GLIBCPP_HAVE_LOG10F)
497   inline float
log10(float __x)498   log10(float __x) { return __gnu_cxx::__c99_binding::log10f(__x); }
499 #else
500   inline float
log10(float __x)501   log10(float __x) { return ::log10(static_cast<double>(__x)); }
502 #endif
503 
504 #if defined(_GLIBCPP_HAVE_LOG10L)
505   inline long double
log10(long double __x)506   log10(long double __x) { return ::log10l(__x); }
507 #else
508   inline long double
log10(long double __x)509   log10(long double __x) { return ::log10(static_cast<double>(__x)); }
510 #endif
511 
512   template<typename _Tp>
513     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
log10(_Tp __x)514     log10(_Tp __x)
515     { return ::log10(static_cast<double>(__x)); }
516 
517   using ::modf;
518 
519 #if defined(_GLIBCPP_HAVE_MODFF)
520   inline float
modf(float __x,float * __iptr)521   modf(float __x, float* __iptr) { return __gnu_cxx::__c99_binding::modff(__x, __iptr); }
522 #else
523   inline float
modf(float __x,float * __iptr)524   modf(float __x, float* __iptr)
525   {
526     double __tmp;
527     double __res = ::modf(static_cast<double>(__x), &__tmp);
528     *__iptr = static_cast<float>(__tmp);
529     return __res;
530   }
531 #endif
532 
533 #if defined(_GLIBCPP_HAVE_MODFL)
534   inline long double
modf(long double __x,long double * __iptr)535   modf(long double __x, long double* __iptr) { return ::modfl(__x, __iptr); }
536 #else
537   inline long double
modf(long double __x,long double * __iptr)538   modf(long double __x, long double* __iptr)
539   {
540     double __tmp;
541     double __res = ::modf(static_cast<double>(__x), &__tmp);
542     * __iptr = static_cast<long double>(__tmp);
543     return __res;
544   }
545 #endif
546 
547   template<typename _Tp>
548     inline _Tp
__pow_helper(_Tp __x,int __n)549     __pow_helper(_Tp __x, int __n)
550     {
551       return __n < 0
552         ? _Tp(1)/__cmath_power(__x, -__n)
553         : __cmath_power(__x, __n);
554     }
555 
556   using ::pow;
557 
558 #if defined(_GLIBCPP_HAVE_POWF)
559   inline float
pow(float __x,float __y)560   pow(float __x, float __y) { return __gnu_cxx::__c99_binding::powf(__x, __y); }
561 #else
562   inline float
pow(float __x,float __y)563   pow(float __x, float __y)
564   { return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }
565 #endif
566 
567 #if defined(_GLIBCPP_HAVE_POWL)
568   inline long double
pow(long double __x,long double __y)569   pow(long double __x, long double __y) { return ::powl(__x, __y); }
570 #else
571   inline long double
pow(long double __x,long double __y)572   pow(long double __x, long double __y)
573   { return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }
574 #endif
575 
576   inline double
pow(double __x,int __i)577   pow(double __x, int __i)
578   { return __pow_helper(__x, __i); }
579 
580   inline float
pow(float __x,int __n)581   pow(float __x, int __n)
582   { return __pow_helper(__x, __n); }
583 
584   inline long double
pow(long double __x,int __n)585   pow(long double __x, int __n)
586   { return __pow_helper(__x, __n); }
587 
588   using ::sin;
589 
590   inline float
sin(float __x)591   sin(float __x)
592   { return __builtin_sinf(__x); }
593 
594   inline long double
sin(long double __x)595   sin(long double __x)
596   { return __builtin_sinl(__x); }
597 
598   template<typename _Tp>
599     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
sin(_Tp __x)600     sin(_Tp __x)
601     { return __builtin_sin(__x); }
602 
603   using ::sinh;
604 
605 #if defined(_GLIBCPP_HAVE_SINHF)
606   inline float
sinh(float __x)607   sinh(float __x) { return __gnu_cxx::__c99_binding::sinhf(__x); }
608 #else
609   inline float
sinh(float __x)610   sinh(float __x) { return ::sinh(static_cast<double>(__x)); }
611 #endif
612 
613 #if defined(_GLIBCPP_HAVE_SINHL)
614   inline long double
sinh(long double __x)615   sinh(long double __x) { return ::sinhl(__x); }
616 #else
617   inline long double
sinh(long double __x)618   sinh(long double __x) { return ::sinh(static_cast<double>(__x)); }
619 #endif
620 
621   template<typename _Tp>
622     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
sinh(_Tp __x)623     sinh(_Tp __x)
624     { return ::sinh(static_cast<_Tp>(__x)); }
625 
626   using ::sqrt;
627 
628   inline float
sqrt(float __x)629   sqrt(float __x)
630   { return __builtin_sqrtf(__x); }
631 
632   inline long double
sqrt(long double __x)633   sqrt(long double __x)
634   { return __builtin_sqrtl(__x); }
635 
636   template<typename _Tp>
637     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
sqrt(_Tp __x)638     sqrt(_Tp __x)
639     { return __builtin_sqrt(__x); }
640 
641   using ::tan;
642 
643 #if defined(_GLIBCPP_HAVE_TANF)
644   inline float
tan(float __x)645   tan(float __x) { return __gnu_cxx::__c99_binding::tanf(__x); }
646 #else
647   inline float
tan(float __x)648   tan(float __x) { return ::tan(static_cast<double>(__x)); }
649 #endif
650 
651 #if defined(_GLIBCPP_HAVE_TANL)
652   inline long double
tan(long double __x)653   tan(long double __x) { return ::tanl(__x); }
654 #else
655   inline long double
tan(long double __x)656   tan(long double __x) { return ::tan(static_cast<double>(__x)); }
657 #endif
658 
659   template<typename _Tp>
660     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
tan(_Tp __x)661     tan(_Tp __x)
662     { return ::tan(static_cast<double>(__x)); }
663 
664   using ::tanh;
665 
666 #if defined(_GLIBCPP_HAVE_TANHF)
667   inline float
tanh(float __x)668   tanh(float __x) { return __gnu_cxx::__c99_binding::tanhf(__x); }
669 #else
670   inline float
tanh(float __x)671   tanh(float __x) { return ::tanh(static_cast<double>(__x)); }
672 #endif
673 
674 #if defined(_GLIBCPP_HAVE_TANHL)
675   inline long double
tanh(long double __x)676   tanh(long double __x) { return ::tanhl(__x); }
677 #else
678   inline long double
tanh(long double __x)679   tanh(long double __x) { return ::tanh(static_cast<double>(__x)); }
680 #endif
681 
682   template<typename _Tp>
683     inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
tanh(_Tp __x)684     tanh(_Tp __x)
685     { return ::tanh(static_cast<double>(__x)); }
686 }
687 
688 
689 #if defined(_GLIBCPP_USE_C99)
690 #if !defined(_GLIBCPP_USE_C99_FP_MACROS_DYNAMIC)
691 // These are possible macros imported from C99-land. For strict
692 // conformance, remove possible C99-injected names from the global
693 // namespace, and sequester them in the __gnu_cxx extension namespace.
694 namespace __gnu_cxx
695 {
696   template<typename _Tp>
697     int
__capture_fpclassify(_Tp __f)698     __capture_fpclassify(_Tp __f) { return fpclassify(__f); }
699 
700   template<typename _Tp>
701     int
__capture_isfinite(_Tp __f)702     __capture_isfinite(_Tp __f) { return isfinite(__f); }
703 
704   template<typename _Tp>
705     int
__capture_isinf(_Tp __f)706     __capture_isinf(_Tp __f) { return isinf(__f); }
707 
708   template<typename _Tp>
709     int
__capture_isnan(_Tp __f)710     __capture_isnan(_Tp __f) { return isnan(__f); }
711 
712   template<typename _Tp>
713     int
__capture_isnormal(_Tp __f)714     __capture_isnormal(_Tp __f) { return isnormal(__f); }
715 
716   template<typename _Tp>
717     int
__capture_signbit(_Tp __f)718     __capture_signbit(_Tp __f) { return signbit(__f); }
719 
720   template<typename _Tp>
721     int
__capture_isgreater(_Tp __f1,_Tp __f2)722     __capture_isgreater(_Tp __f1, _Tp __f2)
723     { return isgreater(__f1, __f2); }
724 
725   template<typename _Tp>
726      int
__capture_isgreaterequal(_Tp __f1,_Tp __f2)727      __capture_isgreaterequal(_Tp __f1, _Tp __f2)
728      { return isgreaterequal(__f1, __f2); }
729 
730   template<typename _Tp>
731      int
__capture_isless(_Tp __f1,_Tp __f2)732      __capture_isless(_Tp __f1, _Tp __f2) { return isless(__f1, __f2); }
733 
734   template<typename _Tp>
735      int
__capture_islessequal(_Tp __f1,_Tp __f2)736      __capture_islessequal(_Tp __f1, _Tp __f2)
737      { return islessequal(__f1, __f2); }
738 
739   template<typename _Tp>
740      int
__capture_islessgreater(_Tp __f1,_Tp __f2)741      __capture_islessgreater(_Tp __f1, _Tp __f2)
742      { return islessgreater(__f1, __f2); }
743 
744   template<typename _Tp>
745      int
__capture_isunordered(_Tp __f1,_Tp __f2)746      __capture_isunordered(_Tp __f1, _Tp __f2)
747      { return isunordered(__f1, __f2); }
748 }
749 
750 #undef fpclassify
751 #undef isfinite
752 #undef isinf
753 #undef isnan
754 #undef isnormal
755 #undef signbit
756 #undef isgreater
757 #undef isgreaterequal
758 #undef isless
759 #undef islessequal
760 #undef islessgreater
761 #undef isunordered
762 
763 namespace __gnu_cxx
764 {
765   template<typename _Tp>
766     int
fpclassify(_Tp __f)767     fpclassify(_Tp __f) { return __capture_fpclassify(__f); }
768 
769   template<typename _Tp>
770     int
isfinite(_Tp __f)771     isfinite(_Tp __f) { return __capture_isfinite(__f); }
772 
773   template<typename _Tp>
774     int
isinf(_Tp __f)775     isinf(_Tp __f) { return __capture_isinf(__f); }
776 
777   template<typename _Tp>
778     int
isnan(_Tp __f)779     isnan(_Tp __f) { return __capture_isnan(__f); }
780 
781   template<typename _Tp>
782     int
isnormal(_Tp __f)783     isnormal(_Tp __f) { return __capture_isnormal(__f); }
784 
785   template<typename _Tp>
786     int
signbit(_Tp __f)787     signbit(_Tp __f) { return __capture_signbit(__f); }
788 
789   template<typename _Tp>
790     int
isgreater(_Tp __f1,_Tp __f2)791     isgreater(_Tp __f1, _Tp __f2) { return __capture_isgreater(__f1, __f2); }
792 
793   template<typename _Tp>
794     int
isgreaterequal(_Tp __f1,_Tp __f2)795     isgreaterequal(_Tp __f1, _Tp __f2)
796     { return __capture_isgreaterequal(__f1, __f2); }
797 
798   template<typename _Tp>
799     int
isless(_Tp __f1,_Tp __f2)800     isless(_Tp __f1, _Tp __f2) { return __capture_isless(__f1, __f2); }
801 
802   template<typename _Tp>
803     int
islessequal(_Tp __f1,_Tp __f2)804     islessequal(_Tp __f1, _Tp __f2)
805     { return __capture_islessequal(__f1, __f2); }
806 
807   template<typename _Tp>
808     int
islessgreater(_Tp __f1,_Tp __f2)809     islessgreater(_Tp __f1, _Tp __f2)
810     { return __capture_islessgreater(__f1, __f2); }
811 
812   template<typename _Tp>
813     int
isunordered(_Tp __f1,_Tp __f2)814     isunordered(_Tp __f1, _Tp __f2)
815     { return __capture_isunordered(__f1, __f2); }
816 }
817 
818 namespace std
819 {
820   using __gnu_cxx::fpclassify;
821   using __gnu_cxx::isfinite;
822   using __gnu_cxx::isinf;
823   using __gnu_cxx::isnan;
824   using __gnu_cxx::isnormal;
825   using __gnu_cxx::signbit;
826   using __gnu_cxx::isgreater;
827   using __gnu_cxx::isgreaterequal;
828   using __gnu_cxx::isless;
829   using __gnu_cxx::islessequal;
830   using __gnu_cxx::islessgreater;
831   using __gnu_cxx::isunordered;
832 }
833 #endif /* _GLIBCPP_USE_C99_FP_MACROS_DYNAMIC */
834 #endif
835 
836 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
837 #  define export
838 #  include <bits/cmath.tcc>
839 #endif
840 
841 #endif
842