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