libstdc++
tr1/cmath
Go to the documentation of this file.
1 // TR1 cmath -*- C++ -*-
2 
3 // Copyright (C) 2006-2025 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 3, 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 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
25 /** @file tr1/cmath
26  * This is a TR1 C++ Library header.
27  */
28 
29 #ifndef _GLIBCXX_TR1_CMATH
30 #define _GLIBCXX_TR1_CMATH 1
31 
32 #ifdef _GLIBCXX_SYSHDR
33 #pragma GCC system_header
34 #endif
35 
36 #include <bits/requires_hosted.h> // TR1
37 
38 #include <cmath>
39 
40 #ifdef _GLIBCXX_USE_C99_MATH_TR1
41 
42 #undef acosh
43 #undef acoshf
44 #undef acoshl
45 #undef asinh
46 #undef asinhf
47 #undef asinhl
48 #undef atanh
49 #undef atanhf
50 #undef atanhl
51 #undef cbrt
52 #undef cbrtf
53 #undef cbrtl
54 #undef copysign
55 #undef copysignf
56 #undef copysignl
57 #undef erf
58 #undef erff
59 #undef erfl
60 #undef erfc
61 #undef erfcf
62 #undef erfcl
63 #undef exp2
64 #undef exp2f
65 #undef exp2l
66 #undef expm1
67 #undef expm1f
68 #undef expm1l
69 #undef fdim
70 #undef fdimf
71 #undef fdiml
72 #undef fma
73 #undef fmaf
74 #undef fmal
75 #undef fmax
76 #undef fmaxf
77 #undef fmaxl
78 #undef fmin
79 #undef fminf
80 #undef fminl
81 #undef hypot
82 #undef hypotf
83 #undef hypotl
84 #undef ilogb
85 #undef ilogbf
86 #undef ilogbl
87 #undef lgamma
88 #undef lgammaf
89 #undef lgammal
90 #undef llrint
91 #undef llrintf
92 #undef llrintl
93 #undef llround
94 #undef llroundf
95 #undef llroundl
96 #undef log1p
97 #undef log1pf
98 #undef log1pl
99 #undef log2
100 #undef log2f
101 #undef log2l
102 #undef logb
103 #undef logbf
104 #undef logbl
105 #undef lrint
106 #undef lrintf
107 #undef lrintl
108 #undef lround
109 #undef lroundf
110 #undef lroundl
111 #undef nan
112 #undef nanf
113 #undef nanl
114 #undef nearbyint
115 #undef nearbyintf
116 #undef nearbyintl
117 #undef nextafter
118 #undef nextafterf
119 #undef nextafterl
120 #undef nexttoward
121 #undef nexttowardf
122 #undef nexttowardl
123 #undef remainder
124 #undef remainderf
125 #undef remainderl
126 #undef remquo
127 #undef remquof
128 #undef remquol
129 #undef rint
130 #undef rintf
131 #undef rintl
132 #undef round
133 #undef roundf
134 #undef roundl
135 #undef scalbln
136 #undef scalblnf
137 #undef scalblnl
138 #undef scalbn
139 #undef scalbnf
140 #undef scalbnl
141 #undef tgamma
142 #undef tgammaf
143 #undef tgammal
144 #undef trunc
145 #undef truncf
146 #undef truncl
147 
148 #endif
149 
150 namespace std _GLIBCXX_VISIBILITY(default)
151 {
152 _GLIBCXX_BEGIN_NAMESPACE_VERSION
153 
154 namespace tr1
155 {
156 #if _GLIBCXX_USE_C99_MATH_TR1
157 
158  // Using declarations to bring names from libc's <math.h> into std::tr1.
159 
160  // types
161  using ::double_t;
162  using ::float_t;
163 
164  // functions
165  using ::acosh;
166  using ::acoshf;
167  using ::acoshl;
168 
169  using ::asinh;
170  using ::asinhf;
171  using ::asinhl;
172 
173  using ::atanh;
174  using ::atanhf;
175  using ::atanhl;
176 
177  using ::cbrt;
178  using ::cbrtf;
179  using ::cbrtl;
180 
181  using ::copysign;
182  using ::copysignf;
183  using ::copysignl;
184 
185  using ::erf;
186  using ::erff;
187  using ::erfl;
188 
189  using ::erfc;
190  using ::erfcf;
191  using ::erfcl;
192 
193  using ::exp2;
194  using ::exp2f;
195  using ::exp2l;
196 
197  using ::expm1;
198  using ::expm1f;
199  using ::expm1l;
200 
201  using ::fdim;
202  using ::fdimf;
203  using ::fdiml;
204 
205  using ::fma;
206  using ::fmaf;
207  using ::fmal;
208 
209  using ::fmax;
210  using ::fmaxf;
211  using ::fmaxl;
212 
213  using ::fmin;
214  using ::fminf;
215  using ::fminl;
216 
217  using ::hypot;
218  using ::hypotf;
219  using ::hypotl;
220 
221  using ::ilogb;
222  using ::ilogbf;
223  using ::ilogbl;
224 
225  using ::lgamma;
226  using ::lgammaf;
227  using ::lgammal;
228 
229  using ::llrint;
230  using ::llrintf;
231  using ::llrintl;
232 
233  using ::llround;
234  using ::llroundf;
235  using ::llroundl;
236 
237  using ::log1p;
238  using ::log1pf;
239  using ::log1pl;
240 
241  using ::log2;
242  using ::log2f;
243  using ::log2l;
244 
245  using ::logb;
246  using ::logbf;
247  using ::logbl;
248 
249  using ::lrint;
250  using ::lrintf;
251  using ::lrintl;
252 
253  using ::lround;
254  using ::lroundf;
255  using ::lroundl;
256 
257  using ::nan;
258  using ::nanf;
259  using ::nanl;
260 
261  using ::nearbyint;
262  using ::nearbyintf;
263  using ::nearbyintl;
264 
265  using ::nextafter;
266  using ::nextafterf;
267  using ::nextafterl;
268 
269  using ::nexttoward;
270  using ::nexttowardf;
271  using ::nexttowardl;
272 
273  using ::remainder;
274  using ::remainderf;
275  using ::remainderl;
276 
277  using ::remquo;
278  using ::remquof;
279  using ::remquol;
280 
281  using ::rint;
282  using ::rintf;
283  using ::rintl;
284 
285  using ::round;
286  using ::roundf;
287  using ::roundl;
288 
289  using ::scalbln;
290  using ::scalblnf;
291  using ::scalblnl;
292 
293  using ::scalbn;
294  using ::scalbnf;
295  using ::scalbnl;
296 
297  using ::tgamma;
298  using ::tgammaf;
299  using ::tgammal;
300 
301  using ::trunc;
302  using ::truncf;
303  using ::truncl;
304 
305 #endif
306 
307 #if _GLIBCXX_USE_C99_MATH
308 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
309 
310  /// Function template definitions [8.16.3].
311  template<typename _Tp>
312  inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
313  int>::__type
314  fpclassify(_Tp __f)
315  {
316  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
317  return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
318  FP_SUBNORMAL, FP_ZERO, __type(__f));
319  }
320 
321  template<typename _Tp>
322  inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
323  int>::__type
324  isfinite(_Tp __f)
325  {
326  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
327  return __builtin_isfinite(__type(__f));
328  }
329 
330  template<typename _Tp>
331  inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
332  int>::__type
333  isinf(_Tp __f)
334  {
335  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
336  return __builtin_isinf(__type(__f));
337  }
338 
339  template<typename _Tp>
340  inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
341  int>::__type
342  isnan(_Tp __f)
343  {
344  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
345  return __builtin_isnan(__type(__f));
346  }
347 
348  template<typename _Tp>
349  inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
350  int>::__type
351  isnormal(_Tp __f)
352  {
353  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
354  return __builtin_isnormal(__type(__f));
355  }
356 
357  template<typename _Tp>
358  inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
359  int>::__type
360  signbit(_Tp __f)
361  {
362  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
363  return __builtin_signbit(__type(__f));
364  }
365 
366  template<typename _Tp>
367  inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
368  int>::__type
369  isgreater(_Tp __f1, _Tp __f2)
370  {
371  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
372  return __builtin_isgreater(__type(__f1), __type(__f2));
373  }
374 
375  template<typename _Tp>
376  inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
377  int>::__type
378  isgreaterequal(_Tp __f1, _Tp __f2)
379  {
380  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
381  return __builtin_isgreaterequal(__type(__f1), __type(__f2));
382  }
383 
384  template<typename _Tp>
385  inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
386  int>::__type
387  isless(_Tp __f1, _Tp __f2)
388  {
389  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
390  return __builtin_isless(__type(__f1), __type(__f2));
391  }
392 
393  template<typename _Tp>
394  inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
395  int>::__type
396  islessequal(_Tp __f1, _Tp __f2)
397  {
398  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
399  return __builtin_islessequal(__type(__f1), __type(__f2));
400  }
401 
402  template<typename _Tp>
403  inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
404  int>::__type
405  islessgreater(_Tp __f1, _Tp __f2)
406  {
407  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
408  return __builtin_islessgreater(__type(__f1), __type(__f2));
409  }
410 
411  template<typename _Tp>
412  inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
413  int>::__type
414  isunordered(_Tp __f1, _Tp __f2)
415  {
416  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
417  return __builtin_isunordered(__type(__f1), __type(__f2));
418  }
419 
420 #endif
421 #endif
422 
423 #if _GLIBCXX_USE_C99_MATH_TR1
424 
425  /** Additional overloads [8.16.4].
426  * @{
427  */
428 
429  // For functions defined in C++03 the additional overloads are already
430  // declared in <cmath> so we can just re-declare them in std::tr1.
431 
432  using std::acos;
433  using std::asin;
434  using std::atan;
435  using std::atan2;
436  using std::ceil;
437  using std::cos;
438  using std::cosh;
439  using std::exp;
440  using std::floor;
441  using std::fmod;
442  using std::frexp;
443  using std::ldexp;
444  using std::log;
445  using std::log10;
446  using std::sin;
447  using std::sinh;
448  using std::sqrt;
449  using std::tan;
450  using std::tanh;
451 
452 #if __cplusplus >= 201103L
453 
454  // Since C++11, <cmath> defines additional overloads for these functions
455  // in namespace std.
456 
457  using std::acosh;
458  using std::asinh;
459  using std::atanh;
460  using std::cbrt;
461  using std::copysign;
462  using std::erf;
463  using std::erfc;
464  using std::exp2;
465  using std::expm1;
466  using std::fdim;
467  using std::fma;
468  using std::fmax;
469  using std::fmin;
470  using std::hypot;
471  using std::ilogb;
472  using std::lgamma;
473  using std::llrint;
474  using std::llround;
475  using std::log1p;
476  using std::log2;
477  using std::logb;
478  using std::lrint;
479  using std::lround;
480  using std::nan;
481  using std::nearbyint;
482  using std::nextafter;
483  using std::nexttoward;
484  using std::remainder;
485  using std::remquo;
486  using std::rint;
487  using std::round;
488  using std::scalbln;
489  using std::scalbn;
490  using std::tgamma;
491  using std::trunc;
492 
493 #else // __cplusplus < 201103L
494 
495  // In C++03 we need to provide the additional overloads.
496 
497 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
498  inline float
499  acosh(float __x)
500  { return __builtin_acoshf(__x); }
501 
502  inline long double
503  acosh(long double __x)
504  { return __builtin_acoshl(__x); }
505 #endif
506 
507  template<typename _Tp>
508  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
509  double>::__type
510  acosh(_Tp __x)
511  { return __builtin_acosh(__x); }
512 
513 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
514  inline float
515  asinh(float __x)
516  { return __builtin_asinhf(__x); }
517 
518  inline long double
519  asinh(long double __x)
520  { return __builtin_asinhl(__x); }
521 #endif
522 
523  template<typename _Tp>
524  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
525  double>::__type
526  asinh(_Tp __x)
527  { return __builtin_asinh(__x); }
528 
529 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
530  inline float
531  atanh(float __x)
532  { return __builtin_atanhf(__x); }
533 
534  inline long double
535  atanh(long double __x)
536  { return __builtin_atanhl(__x); }
537 #endif
538 
539  template<typename _Tp>
540  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
541  double>::__type
542  atanh(_Tp __x)
543  { return __builtin_atanh(__x); }
544 
545 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
546  inline float
547  cbrt(float __x)
548  { return __builtin_cbrtf(__x); }
549 
550  inline long double
551  cbrt(long double __x)
552  { return __builtin_cbrtl(__x); }
553 #endif
554 
555  template<typename _Tp>
556  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
557  double>::__type
558  cbrt(_Tp __x)
559  { return __builtin_cbrt(__x); }
560 
561 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
562  inline float
563  copysign(float __x, float __y)
564  { return __builtin_copysignf(__x, __y); }
565 
566  inline long double
567  copysign(long double __x, long double __y)
568  { return __builtin_copysignl(__x, __y); }
569 #endif
570 
571  template<typename _Tp, typename _Up>
572  inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
573  copysign(_Tp __x, _Up __y)
574  {
575  typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
576  return copysign(__type(__x), __type(__y));
577  }
578 
579 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
580  inline float
581  erf(float __x)
582  { return __builtin_erff(__x); }
583 
584  inline long double
585  erf(long double __x)
586  { return __builtin_erfl(__x); }
587 #endif
588 
589  template<typename _Tp>
590  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
591  double>::__type
592  erf(_Tp __x)
593  { return __builtin_erf(__x); }
594 
595 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
596  inline float
597  erfc(float __x)
598  { return __builtin_erfcf(__x); }
599 
600  inline long double
601  erfc(long double __x)
602  { return __builtin_erfcl(__x); }
603 #endif
604 
605  template<typename _Tp>
606  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
607  double>::__type
608  erfc(_Tp __x)
609  { return __builtin_erfc(__x); }
610 
611 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
612  inline float
613  exp2(float __x)
614  { return __builtin_exp2f(__x); }
615 
616  inline long double
617  exp2(long double __x)
618  { return __builtin_exp2l(__x); }
619 #endif
620 
621  template<typename _Tp>
622  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
623  double>::__type
624  exp2(_Tp __x)
625  { return __builtin_exp2(__x); }
626 
627 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
628  inline float
629  expm1(float __x)
630  { return __builtin_expm1f(__x); }
631 
632  inline long double
633  expm1(long double __x)
634  { return __builtin_expm1l(__x); }
635 #endif
636 
637  template<typename _Tp>
638  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
639  double>::__type
640  expm1(_Tp __x)
641  { return __builtin_expm1(__x); }
642 
643 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
644  inline float
645  fdim(float __x, float __y)
646  { return __builtin_fdimf(__x, __y); }
647 
648  inline long double
649  fdim(long double __x, long double __y)
650  { return __builtin_fdiml(__x, __y); }
651 #endif
652 
653  template<typename _Tp, typename _Up>
654  inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
655  fdim(_Tp __x, _Up __y)
656  {
657  typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
658  return fdim(__type(__x), __type(__y));
659  }
660 
661 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
662  inline float
663  fma(float __x, float __y, float __z)
664  { return __builtin_fmaf(__x, __y, __z); }
665 
666  inline long double
667  fma(long double __x, long double __y, long double __z)
668  { return __builtin_fmal(__x, __y, __z); }
669 #endif
670 
671  template<typename _Tp, typename _Up, typename _Vp>
672  inline typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
673  fma(_Tp __x, _Up __y, _Vp __z)
674  {
675  typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
676  return fma(__type(__x), __type(__y), __type(__z));
677  }
678 
679 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
680  inline float
681  fmax(float __x, float __y)
682  { return __builtin_fmaxf(__x, __y); }
683 
684  inline long double
685  fmax(long double __x, long double __y)
686  { return __builtin_fmaxl(__x, __y); }
687 #endif
688 
689  template<typename _Tp, typename _Up>
690  inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
691  fmax(_Tp __x, _Up __y)
692  {
693  typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
694  return fmax(__type(__x), __type(__y));
695  }
696 
697 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
698  inline float
699  fmin(float __x, float __y)
700  { return __builtin_fminf(__x, __y); }
701 
702  inline long double
703  fmin(long double __x, long double __y)
704  { return __builtin_fminl(__x, __y); }
705 #endif
706 
707  template<typename _Tp, typename _Up>
708  inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
709  fmin(_Tp __x, _Up __y)
710  {
711  typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
712  return fmin(__type(__x), __type(__y));
713  }
714 
715 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
716  inline float
717  hypot(float __x, float __y)
718  { return __builtin_hypotf(__x, __y); }
719 
720  inline long double
721  hypot(long double __x, long double __y)
722  { return __builtin_hypotl(__x, __y); }
723 #endif
724 
725  template<typename _Tp, typename _Up>
726  inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
727  hypot(_Tp __y, _Up __x)
728  {
729  typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
730  return hypot(__type(__y), __type(__x));
731  }
732 
733 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
734  inline int
735  ilogb(float __x)
736  { return __builtin_ilogbf(__x); }
737 
738  inline int
739  ilogb(long double __x)
740  { return __builtin_ilogbl(__x); }
741 #endif
742 
743  template<typename _Tp>
744  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
745  int>::__type
746  ilogb(_Tp __x)
747  { return __builtin_ilogb(__x); }
748 
749 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
750  inline float
751  lgamma(float __x)
752  { return __builtin_lgammaf(__x); }
753 
754  inline long double
755  lgamma(long double __x)
756  { return __builtin_lgammal(__x); }
757 #endif
758 
759  template<typename _Tp>
760  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
761  double>::__type
762  lgamma(_Tp __x)
763  { return __builtin_lgamma(__x); }
764 
765 #pragma GCC diagnostic push
766 #pragma GCC diagnostic ignored "-Wlong-long"
767 
768 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
769  inline long long
770  llrint(float __x)
771  { return __builtin_llrintf(__x); }
772 
773  inline long long
774  llrint(long double __x)
775  { return __builtin_llrintl(__x); }
776 #endif
777 
778  template<typename _Tp>
779  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
780  long long>::__type
781  llrint(_Tp __x)
782  { return __builtin_llrint(__x); }
783 
784 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
785  inline long long
786  llround(float __x)
787  { return __builtin_llroundf(__x); }
788 
789  inline long long
790  llround(long double __x)
791  { return __builtin_llroundl(__x); }
792 #endif
793 
794  template<typename _Tp>
795  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
796  long long>::__type
797  llround(_Tp __x)
798  { return __builtin_llround(__x); }
799 #pragma GCC diagnostic pop
800 
801 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
802  inline float
803  log1p(float __x)
804  { return __builtin_log1pf(__x); }
805 
806  inline long double
807  log1p(long double __x)
808  { return __builtin_log1pl(__x); }
809 #endif
810 
811  template<typename _Tp>
812  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
813  double>::__type
814  log1p(_Tp __x)
815  { return __builtin_log1p(__x); }
816 
817  // DR 568.
818 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
819  inline float
820  log2(float __x)
821  { return __builtin_log2f(__x); }
822 
823  inline long double
824  log2(long double __x)
825  { return __builtin_log2l(__x); }
826 #endif
827 
828  template<typename _Tp>
829  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
830  double>::__type
831  log2(_Tp __x)
832  { return __builtin_log2(__x); }
833 
834 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
835  inline float
836  logb(float __x)
837  { return __builtin_logbf(__x); }
838 
839  inline long double
840  logb(long double __x)
841  { return __builtin_logbl(__x); }
842 #endif
843 
844  template<typename _Tp>
845  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
846  double>::__type
847  logb(_Tp __x)
848  {
849  return __builtin_logb(__x);
850  }
851 
852 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
853  inline long
854  lrint(float __x)
855  { return __builtin_lrintf(__x); }
856 
857  inline long
858  lrint(long double __x)
859  { return __builtin_lrintl(__x); }
860 #endif
861 
862  template<typename _Tp>
863  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
864  long>::__type
865  lrint(_Tp __x)
866  { return __builtin_lrint(__x); }
867 
868 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
869  inline long
870  lround(float __x)
871  { return __builtin_lroundf(__x); }
872 
873  inline long
874  lround(long double __x)
875  { return __builtin_lroundl(__x); }
876 #endif
877 
878  template<typename _Tp>
879  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
880  long>::__type
881  lround(_Tp __x)
882  { return __builtin_lround(__x); }
883 
884 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
885  inline float
886  nearbyint(float __x)
887  { return __builtin_nearbyintf(__x); }
888 
889  inline long double
890  nearbyint(long double __x)
891  { return __builtin_nearbyintl(__x); }
892 #endif
893 
894  template<typename _Tp>
895  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
896  double>::__type
897  nearbyint(_Tp __x)
898  { return __builtin_nearbyint(__x); }
899 
900 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
901  inline float
902  nextafter(float __x, float __y)
903  { return __builtin_nextafterf(__x, __y); }
904 
905  inline long double
906  nextafter(long double __x, long double __y)
907  { return __builtin_nextafterl(__x, __y); }
908 #endif
909 
910  template<typename _Tp, typename _Up>
911  inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
912  nextafter(_Tp __x, _Up __y)
913  {
914  typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
915  return nextafter(__type(__x), __type(__y));
916  }
917 
918 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
919  inline float
920  nexttoward(float __x, long double __y)
921  { return __builtin_nexttowardf(__x, __y); }
922 
923  inline long double
924  nexttoward(long double __x, long double __y)
925  { return __builtin_nexttowardl(__x, __y); }
926 #endif
927 
928  template<typename _Tp>
929  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
930  double>::__type
931  nexttoward(_Tp __x, long double __y)
932  { return __builtin_nexttoward(__x, __y); }
933 
934 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
935  inline float
936  remainder(float __x, float __y)
937  { return __builtin_remainderf(__x, __y); }
938 
939  inline long double
940  remainder(long double __x, long double __y)
941  { return __builtin_remainderl(__x, __y); }
942 #endif
943 
944  template<typename _Tp, typename _Up>
945  inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
946  remainder(_Tp __x, _Up __y)
947  {
948  typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
949  return remainder(__type(__x), __type(__y));
950  }
951 
952 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
953  inline float
954  remquo(float __x, float __y, int* __pquo)
955  { return __builtin_remquof(__x, __y, __pquo); }
956 
957  inline long double
958  remquo(long double __x, long double __y, int* __pquo)
959  { return __builtin_remquol(__x, __y, __pquo); }
960 #endif
961 
962  template<typename _Tp, typename _Up>
963  inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
964  remquo(_Tp __x, _Up __y, int* __pquo)
965  {
966  typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
967  return remquo(__type(__x), __type(__y), __pquo);
968  }
969 
970 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
971  inline float
972  rint(float __x)
973  { return __builtin_rintf(__x); }
974 
975  inline long double
976  rint(long double __x)
977  { return __builtin_rintl(__x); }
978 #endif
979 
980  template<typename _Tp>
981  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
982  double>::__type
983  rint(_Tp __x)
984  { return __builtin_rint(__x); }
985 
986 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
987  inline float
988  round(float __x)
989  { return __builtin_roundf(__x); }
990 
991  inline long double
992  round(long double __x)
993  { return __builtin_roundl(__x); }
994 #endif
995 
996  template<typename _Tp>
997  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
998  double>::__type
999  round(_Tp __x)
1000  { return __builtin_round(__x); }
1001 
1002 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1003  inline float
1004  scalbln(float __x, long __ex)
1005  { return __builtin_scalblnf(__x, __ex); }
1006 
1007  inline long double
1008  scalbln(long double __x, long __ex)
1009  { return __builtin_scalblnl(__x, __ex); }
1010 #endif
1011 
1012  template<typename _Tp>
1013  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1014  double>::__type
1015  scalbln(_Tp __x, long __ex)
1016  { return __builtin_scalbln(__x, __ex); }
1017 
1018 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1019  inline float
1020  scalbn(float __x, int __ex)
1021  { return __builtin_scalbnf(__x, __ex); }
1022 
1023  inline long double
1024  scalbn(long double __x, int __ex)
1025  { return __builtin_scalbnl(__x, __ex); }
1026 #endif
1027 
1028  template<typename _Tp>
1029  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1030  double>::__type
1031  scalbn(_Tp __x, int __ex)
1032  { return __builtin_scalbn(__x, __ex); }
1033 
1034 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1035  inline float
1036  tgamma(float __x)
1037  { return __builtin_tgammaf(__x); }
1038 
1039  inline long double
1040  tgamma(long double __x)
1041  { return __builtin_tgammal(__x); }
1042 #endif
1043 
1044  template<typename _Tp>
1045  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1046  double>::__type
1047  tgamma(_Tp __x)
1048  { return __builtin_tgamma(__x); }
1049 
1050 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1051  inline float
1052  trunc(float __x)
1053  { return __builtin_truncf(__x); }
1054 
1055  inline long double
1056  trunc(long double __x)
1057  { return __builtin_truncl(__x); }
1058 #endif
1059 
1060  template<typename _Tp>
1061  inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1062  double>::__type
1063  trunc(_Tp __x)
1064  { return __builtin_trunc(__x); }
1065 
1066 #endif // __cplusplus < 201103L
1067 
1068  /// @}
1069 
1070 #endif /* _GLIBCXX_USE_C99_MATH_TR1 */
1071 
1072  // DR 550. What should the return type of pow(float,int) be?
1073  // NB: C++11 and TR1 != C++03.
1074 
1075  // We cannot do "using std::pow;" because that would bring in unwanted
1076  // pow(*, int) overloads in C++03, with the wrong return type. Instead we
1077  // define all the necessary overloads, but the std::tr1::pow(double, double)
1078  // overload cannot be provided here, because <tr1/math.h> would add it to
1079  // the global namespace where it would clash with ::pow(double,double) from
1080  // libc (revealed by the fix of PR c++/54537).
1081  // The solution is to forward std::tr1::pow(double,double) to
1082  // std::pow(double,double) via the function template below. See
1083  // the discussion about this issue here:
1084  // http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01278.html
1085 
1086 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1087  inline float
1088  pow(float __x, float __y)
1089  { return std::pow(__x, __y); }
1090 
1091  inline long double
1092  pow(long double __x, long double __y)
1093  { return std::pow(__x, __y); }
1094 #endif
1095 
1096  template<typename _Tp, typename _Up>
1097  inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1098  pow(_Tp __x, _Up __y)
1099  {
1100  typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1101  return std::pow(__type(__x), __type(__y));
1102  }
1103 
1104 #if __cplusplus >= 201103L
1105  // We also deal with fabs in a special way, because "using std::fabs;"
1106  // could bring in C++11's std::fabs<T>(const std::complex<T>&) with a
1107  // different return type from std::tr1::fabs<T>(const std::complex<T>&).
1108  // We define the necessary overloads, except std::tr1::fabs(double) which
1109  // could clash with ::fabs(double) from libc.
1110  // The function template handles double as well as integers, forwarding
1111  // to std::fabs.
1112 
1113 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
1114 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1115  inline float
1116  fabs(float __x)
1117  { return __builtin_fabsf(__x); }
1118 
1119  inline long double
1120  fabs(long double __x)
1121  { return __builtin_fabsl(__x); }
1122 #endif
1123 #endif
1124 
1125  template<typename _Tp>
1126  inline typename __gnu_cxx::__promote<_Tp>::__type
1127  fabs(_Tp __x)
1128  { return std::fabs(__x); }
1129 
1130 #else // ! C++11
1131 
1132  // For C++03 just use std::fabs as there is no overload for std::complex<>.
1133  using std::fabs;
1134 
1135 #endif // C++11
1136 
1137 } // namespace tr1
1138 _GLIBCXX_END_NAMESPACE_VERSION
1139 } // namespace std
1140 
1141 /**
1142  * @defgroup tr1_math_spec_func TR1 Mathematical Special Functions
1143  * @ingroup numerics
1144  *
1145  * A collection of advanced mathematical special functions.
1146  */
1147 
1148 #if _GLIBCXX_USE_STD_SPEC_FUNCS
1149 
1150 namespace std _GLIBCXX_VISIBILITY(default)
1151 {
1152 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1153 
1154 namespace tr1
1155 {
1156  using std::assoc_laguerref;
1157  using std::assoc_laguerrel;
1158  using std::assoc_laguerre;
1159 
1160  using std::assoc_legendref;
1161  using std::assoc_legendrel;
1162  using std::assoc_legendre;
1163 
1164  using std::betaf;
1165  using std::betal;
1166  using std::beta;
1167 
1168  using std::comp_ellint_1f;
1169  using std::comp_ellint_1l;
1170  using std::comp_ellint_1;
1171 
1172  using std::comp_ellint_2f;
1173  using std::comp_ellint_2l;
1174  using std::comp_ellint_2;
1175 
1176  using std::comp_ellint_3f;
1177  using std::comp_ellint_3l;
1178  using std::comp_ellint_3;
1179 
1180  using std::cyl_bessel_if;
1181  using std::cyl_bessel_il;
1182  using std::cyl_bessel_i;
1183 
1184  using std::cyl_bessel_jf;
1185  using std::cyl_bessel_jl;
1186  using std::cyl_bessel_j;
1187 
1188  using std::cyl_bessel_kf;
1189  using std::cyl_bessel_kl;
1190  using std::cyl_bessel_k;
1191 
1192  using std::cyl_neumannf;
1193  using std::cyl_neumannl;
1194  using std::cyl_neumann;
1195 
1196  using std::ellint_1f;
1197  using std::ellint_1l;
1198  using std::ellint_1;
1199 
1200  using std::ellint_2f;
1201  using std::ellint_2l;
1202  using std::ellint_2;
1203 
1204  using std::ellint_3f;
1205  using std::ellint_3l;
1206  using std::ellint_3;
1207 
1208  using std::expintf;
1209  using std::expintl;
1210  using std::expint;
1211 
1212  using std::hermitef;
1213  using std::hermitel;
1214  using std::hermite;
1215 
1216  using std::laguerref;
1217  using std::laguerrel;
1218  using std::laguerre;
1219 
1220  using std::legendref;
1221  using std::legendrel;
1222  using std::legendre;
1223 
1224  using std::riemann_zetaf;
1225  using std::riemann_zetal;
1226  using std::riemann_zeta;
1227 
1228  using std::sph_besself;
1229  using std::sph_bessell;
1230  using std::sph_bessel;
1231 
1232  using std::sph_legendref;
1233  using std::sph_legendrel;
1234  using std::sph_legendre;
1235 
1236  using std::sph_neumannf;
1237  using std::sph_neumannl;
1238  using std::sph_neumann;
1239 
1240 } // namespace tr1
1241 _GLIBCXX_END_NAMESPACE_VERSION
1242 } // namespace std
1243 
1244 #else // ! _GLIBCXX_USE_STD_SPEC_FUNCS
1245 
1246 #include <bits/stl_algobase.h>
1247 #include <limits>
1248 #include <tr1/type_traits>
1249 
1250 #include <tr1/gamma.tcc>
1251 #include <tr1/bessel_function.tcc>
1252 #include <tr1/beta_function.tcc>
1253 #include <tr1/ell_integral.tcc>
1254 #include <tr1/exp_integral.tcc>
1255 #include <tr1/legendre_function.tcc>
1256 #include <tr1/modified_bessel_func.tcc>
1257 #include <tr1/poly_hermite.tcc>
1258 #include <tr1/poly_laguerre.tcc>
1259 #include <tr1/riemann_zeta.tcc>
1260 
1261 namespace std _GLIBCXX_VISIBILITY(default)
1262 {
1263 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1264 namespace tr1
1265  {
1266  /** @addtogroup tr1_math_spec_func
1267  * @{
1268  */
1269 
1270  inline float
1271  assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
1272  { return __detail::__assoc_laguerre<float>(__n, __m, __x); }
1273 
1274  inline long double
1275  assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
1276  {
1277  return __detail::__assoc_laguerre<long double>(__n, __m, __x);
1278  }
1279 
1280  /// 5.2.1.1 Associated Laguerre polynomials.
1281  template<typename _Tp>
1282  inline typename __gnu_cxx::__promote<_Tp>::__type
1283  assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
1284  {
1285  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1286  return __detail::__assoc_laguerre<__type>(__n, __m, __x);
1287  }
1288 
1289  inline float
1290  assoc_legendref(unsigned int __l, unsigned int __m, float __x)
1291  { return __detail::__assoc_legendre_p<float>(__l, __m, __x); }
1292 
1293  inline long double
1294  assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
1295  { return __detail::__assoc_legendre_p<long double>(__l, __m, __x); }
1296 
1297  /// 5.2.1.2 Associated Legendre functions.
1298  template<typename _Tp>
1299  inline typename __gnu_cxx::__promote<_Tp>::__type
1300  assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
1301  {
1302  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1303  return __detail::__assoc_legendre_p<__type>(__l, __m, __x);
1304  }
1305 
1306  inline float
1307  betaf(float __x, float __y)
1308  { return __detail::__beta<float>(__x, __y); }
1309 
1310  inline long double
1311  betal(long double __x, long double __y)
1312  { return __detail::__beta<long double>(__x, __y); }
1313 
1314  /// 5.2.1.3 Beta functions.
1315  template<typename _Tpx, typename _Tpy>
1316  inline typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type
1317  beta(_Tpx __x, _Tpy __y)
1318  {
1319  typedef typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type __type;
1320  return __detail::__beta<__type>(__x, __y);
1321  }
1322 
1323  inline float
1324  comp_ellint_1f(float __k)
1325  { return __detail::__comp_ellint_1<float>(__k); }
1326 
1327  inline long double
1328  comp_ellint_1l(long double __k)
1329  { return __detail::__comp_ellint_1<long double>(__k); }
1330 
1331  /// 5.2.1.4 Complete elliptic integrals of the first kind.
1332  template<typename _Tp>
1333  inline typename __gnu_cxx::__promote<_Tp>::__type
1334  comp_ellint_1(_Tp __k)
1335  {
1336  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1337  return __detail::__comp_ellint_1<__type>(__k);
1338  }
1339 
1340  inline float
1341  comp_ellint_2f(float __k)
1342  { return __detail::__comp_ellint_2<float>(__k); }
1343 
1344  inline long double
1345  comp_ellint_2l(long double __k)
1346  { return __detail::__comp_ellint_2<long double>(__k); }
1347 
1348  /// 5.2.1.5 Complete elliptic integrals of the second kind.
1349  template<typename _Tp>
1350  inline typename __gnu_cxx::__promote<_Tp>::__type
1351  comp_ellint_2(_Tp __k)
1352  {
1353  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1354  return __detail::__comp_ellint_2<__type>(__k);
1355  }
1356 
1357  inline float
1358  comp_ellint_3f(float __k, float __nu)
1359  { return __detail::__comp_ellint_3<float>(__k, __nu); }
1360 
1361  inline long double
1362  comp_ellint_3l(long double __k, long double __nu)
1363  { return __detail::__comp_ellint_3<long double>(__k, __nu); }
1364 
1365  /// 5.2.1.6 Complete elliptic integrals of the third kind.
1366  template<typename _Tp, typename _Tpn>
1367  inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type
1368  comp_ellint_3(_Tp __k, _Tpn __nu)
1369  {
1370  typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type;
1371  return __detail::__comp_ellint_3<__type>(__k, __nu);
1372  }
1373 
1374  inline float
1375  cyl_bessel_if(float __nu, float __x)
1376  { return __detail::__cyl_bessel_i<float>(__nu, __x); }
1377 
1378  inline long double
1379  cyl_bessel_il(long double __nu, long double __x)
1380  { return __detail::__cyl_bessel_i<long double>(__nu, __x); }
1381 
1382  /// 5.2.1.8 Regular modified cylindrical Bessel functions.
1383  template<typename _Tpnu, typename _Tp>
1384  inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1385  cyl_bessel_i(_Tpnu __nu, _Tp __x)
1386  {
1387  typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1388  return __detail::__cyl_bessel_i<__type>(__nu, __x);
1389  }
1390 
1391  inline float
1392  cyl_bessel_jf(float __nu, float __x)
1393  { return __detail::__cyl_bessel_j<float>(__nu, __x); }
1394 
1395  inline long double
1396  cyl_bessel_jl(long double __nu, long double __x)
1397  { return __detail::__cyl_bessel_j<long double>(__nu, __x); }
1398 
1399  /// 5.2.1.9 Cylindrical Bessel functions (of the first kind).
1400  template<typename _Tpnu, typename _Tp>
1401  inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1402  cyl_bessel_j(_Tpnu __nu, _Tp __x)
1403  {
1404  typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1405  return __detail::__cyl_bessel_j<__type>(__nu, __x);
1406  }
1407 
1408  inline float
1409  cyl_bessel_kf(float __nu, float __x)
1410  { return __detail::__cyl_bessel_k<float>(__nu, __x); }
1411 
1412  inline long double
1413  cyl_bessel_kl(long double __nu, long double __x)
1414  { return __detail::__cyl_bessel_k<long double>(__nu, __x); }
1415 
1416  /// 5.2.1.10 Irregular modified cylindrical Bessel functions.
1417  template<typename _Tpnu, typename _Tp>
1418  inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1419  cyl_bessel_k(_Tpnu __nu, _Tp __x)
1420  {
1421  typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1422  return __detail::__cyl_bessel_k<__type>(__nu, __x);
1423  }
1424 
1425  inline float
1426  cyl_neumannf(float __nu, float __x)
1427  { return __detail::__cyl_neumann_n<float>(__nu, __x); }
1428 
1429  inline long double
1430  cyl_neumannl(long double __nu, long double __x)
1431  { return __detail::__cyl_neumann_n<long double>(__nu, __x); }
1432 
1433  /// 5.2.1.11 Cylindrical Neumann functions.
1434  template<typename _Tpnu, typename _Tp>
1435  inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1436  cyl_neumann(_Tpnu __nu, _Tp __x)
1437  {
1438  typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1439  return __detail::__cyl_neumann_n<__type>(__nu, __x);
1440  }
1441 
1442  inline float
1443  ellint_1f(float __k, float __phi)
1444  { return __detail::__ellint_1<float>(__k, __phi); }
1445 
1446  inline long double
1447  ellint_1l(long double __k, long double __phi)
1448  { return __detail::__ellint_1<long double>(__k, __phi); }
1449 
1450  /// 5.2.1.12 Incomplete elliptic integrals of the first kind.
1451  template<typename _Tp, typename _Tpp>
1452  inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
1453  ellint_1(_Tp __k, _Tpp __phi)
1454  {
1455  typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
1456  return __detail::__ellint_1<__type>(__k, __phi);
1457  }
1458 
1459  inline float
1460  ellint_2f(float __k, float __phi)
1461  { return __detail::__ellint_2<float>(__k, __phi); }
1462 
1463  inline long double
1464  ellint_2l(long double __k, long double __phi)
1465  { return __detail::__ellint_2<long double>(__k, __phi); }
1466 
1467  /// 5.2.1.13 Incomplete elliptic integrals of the second kind.
1468  template<typename _Tp, typename _Tpp>
1469  inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
1470  ellint_2(_Tp __k, _Tpp __phi)
1471  {
1472  typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
1473  return __detail::__ellint_2<__type>(__k, __phi);
1474  }
1475 
1476  inline float
1477  ellint_3f(float __k, float __nu, float __phi)
1478  { return __detail::__ellint_3<float>(__k, __nu, __phi); }
1479 
1480  inline long double
1481  ellint_3l(long double __k, long double __nu, long double __phi)
1482  { return __detail::__ellint_3<long double>(__k, __nu, __phi); }
1483 
1484  /// 5.2.1.14 Incomplete elliptic integrals of the third kind.
1485  template<typename _Tp, typename _Tpn, typename _Tpp>
1486  inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type
1487  ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
1488  {
1489  typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type;
1490  return __detail::__ellint_3<__type>(__k, __nu, __phi);
1491  }
1492 
1493  inline float
1494  expintf(float __x)
1495  { return __detail::__expint<float>(__x); }
1496 
1497  inline long double
1498  expintl(long double __x)
1499  { return __detail::__expint<long double>(__x); }
1500 
1501  /// 5.2.1.15 Exponential integrals.
1502  template<typename _Tp>
1503  inline typename __gnu_cxx::__promote<_Tp>::__type
1504  expint(_Tp __x)
1505  {
1506  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1507  return __detail::__expint<__type>(__x);
1508  }
1509 
1510  inline float
1511  hermitef(unsigned int __n, float __x)
1512  { return __detail::__poly_hermite<float>(__n, __x); }
1513 
1514  inline long double
1515  hermitel(unsigned int __n, long double __x)
1516  { return __detail::__poly_hermite<long double>(__n, __x); }
1517 
1518  /// 5.2.1.16 Hermite polynomials.
1519  template<typename _Tp>
1520  inline typename __gnu_cxx::__promote<_Tp>::__type
1521  hermite(unsigned int __n, _Tp __x)
1522  {
1523  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1524  return __detail::__poly_hermite<__type>(__n, __x);
1525  }
1526 
1527  inline float
1528  laguerref(unsigned int __n, float __x)
1529  { return __detail::__laguerre<float>(__n, __x); }
1530 
1531  inline long double
1532  laguerrel(unsigned int __n, long double __x)
1533  { return __detail::__laguerre<long double>(__n, __x); }
1534 
1535  /// 5.2.1.18 Laguerre polynomials.
1536  template<typename _Tp>
1537  inline typename __gnu_cxx::__promote<_Tp>::__type
1538  laguerre(unsigned int __n, _Tp __x)
1539  {
1540  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1541  return __detail::__laguerre<__type>(__n, __x);
1542  }
1543 
1544  inline float
1545  legendref(unsigned int __n, float __x)
1546  { return __detail::__poly_legendre_p<float>(__n, __x); }
1547 
1548  inline long double
1549  legendrel(unsigned int __n, long double __x)
1550  { return __detail::__poly_legendre_p<long double>(__n, __x); }
1551 
1552  /// 5.2.1.19 Legendre polynomials.
1553  template<typename _Tp>
1554  inline typename __gnu_cxx::__promote<_Tp>::__type
1555  legendre(unsigned int __n, _Tp __x)
1556  {
1557  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1558  return __detail::__poly_legendre_p<__type>(__n, __x);
1559  }
1560 
1561  inline float
1562  riemann_zetaf(float __x)
1563  { return __detail::__riemann_zeta<float>(__x); }
1564 
1565  inline long double
1566  riemann_zetal(long double __x)
1567  { return __detail::__riemann_zeta<long double>(__x); }
1568 
1569  /// 5.2.1.20 Riemann zeta function.
1570  template<typename _Tp>
1571  inline typename __gnu_cxx::__promote<_Tp>::__type
1572  riemann_zeta(_Tp __x)
1573  {
1574  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1575  return __detail::__riemann_zeta<__type>(__x);
1576  }
1577 
1578  inline float
1579  sph_besself(unsigned int __n, float __x)
1580  { return __detail::__sph_bessel<float>(__n, __x); }
1581 
1582  inline long double
1583  sph_bessell(unsigned int __n, long double __x)
1584  { return __detail::__sph_bessel<long double>(__n, __x); }
1585 
1586  /// 5.2.1.21 Spherical Bessel functions.
1587  template<typename _Tp>
1588  inline typename __gnu_cxx::__promote<_Tp>::__type
1589  sph_bessel(unsigned int __n, _Tp __x)
1590  {
1591  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1592  return __detail::__sph_bessel<__type>(__n, __x);
1593  }
1594 
1595  inline float
1596  sph_legendref(unsigned int __l, unsigned int __m, float __theta)
1597  { return __detail::__sph_legendre<float>(__l, __m, __theta); }
1598 
1599  inline long double
1600  sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
1601  { return __detail::__sph_legendre<long double>(__l, __m, __theta); }
1602 
1603  /// 5.2.1.22 Spherical associated Legendre functions.
1604  template<typename _Tp>
1605  inline typename __gnu_cxx::__promote<_Tp>::__type
1606  sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
1607  {
1608  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1609  return __detail::__sph_legendre<__type>(__l, __m, __theta);
1610  }
1611 
1612  inline float
1613  sph_neumannf(unsigned int __n, float __x)
1614  { return __detail::__sph_neumann<float>(__n, __x); }
1615 
1616  inline long double
1617  sph_neumannl(unsigned int __n, long double __x)
1618  { return __detail::__sph_neumann<long double>(__n, __x); }
1619 
1620  /// 5.2.1.23 Spherical Neumann functions.
1621  template<typename _Tp>
1622  inline typename __gnu_cxx::__promote<_Tp>::__type
1623  sph_neumann(unsigned int __n, _Tp __x)
1624  {
1625  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1626  return __detail::__sph_neumann<__type>(__n, __x);
1627  }
1628 
1629  /// @} tr1_math_spec_func
1630 
1631 } // namespace tr1
1632 
1633 _GLIBCXX_END_NAMESPACE_VERSION
1634 } // namespace std
1635 
1636 #endif // _GLIBCXX_USE_STD_SPEC_FUNCS
1637 
1638 #if _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)
1639 namespace std _GLIBCXX_VISIBILITY(default)
1640 {
1641 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1642 
1643 namespace tr1
1644 {
1645  using __gnu_cxx::conf_hypergf;
1646  using __gnu_cxx::conf_hypergl;
1647  using __gnu_cxx::conf_hyperg;
1648 
1649  using __gnu_cxx::hypergf;
1650  using __gnu_cxx::hypergl;
1651  using __gnu_cxx::hyperg;
1652 } // namespace tr1
1653 
1654 _GLIBCXX_END_NAMESPACE_VERSION
1655 } // namespace std
1656 
1657 #else // ! (_GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__))
1658 
1659 #include <bits/stl_algobase.h>
1660 #include <limits>
1661 #include <tr1/type_traits>
1662 
1663 #include <tr1/hypergeometric.tcc>
1664 
1665 namespace std _GLIBCXX_VISIBILITY(default)
1666 {
1667 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1668 
1669 namespace tr1
1670 {
1671  /** @addtogroup tr1_math_spec_func
1672  * @{
1673  */
1674 
1675  inline float
1676  conf_hypergf(float __a, float __c, float __x)
1677  { return __detail::__conf_hyperg<float>(__a, __c, __x); }
1678 
1679  inline long double
1680  conf_hypergl(long double __a, long double __c, long double __x)
1681  { return __detail::__conf_hyperg<long double>(__a, __c, __x); }
1682 
1683  /// 5.2.1.7 Confluent hypergeometric functions.
1684  template<typename _Tpa, typename _Tpc, typename _Tp>
1685  inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type
1686  conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
1687  {
1688  typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type;
1689  return __detail::__conf_hyperg<__type>(__a, __c, __x);
1690  }
1691 
1692  inline float
1693  hypergf(float __a, float __b, float __c, float __x)
1694  { return __detail::__hyperg<float>(__a, __b, __c, __x); }
1695 
1696  inline long double
1697  hypergl(long double __a, long double __b, long double __c, long double __x)
1698  { return __detail::__hyperg<long double>(__a, __b, __c, __x); }
1699 
1700  /// 5.2.1.17 Hypergeometric functions.
1701  template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
1702  inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type
1703  hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
1704  {
1705  typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type;
1706  return __detail::__hyperg<__type>(__a, __b, __c, __x);
1707  }
1708 
1709  /// @} tr1_math_spec_func
1710 
1711 } // namespace tr1
1712 
1713 _GLIBCXX_END_NAMESPACE_VERSION
1714 } // namespace std
1715 #endif // _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)
1716 
1717 #endif // _GLIBCXX_TR1_CMATH