1 // TR1 cmath -*- C++ -*-
3 // Copyright (C) 2006-2026 Free Software Foundation, Inc.
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)
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.
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.
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/>.
26 * This is a TR1 C++ Library header.
29 #ifndef _GLIBCXX_TR1_CMATH
30 #define _GLIBCXX_TR1_CMATH 1
32 #ifdef _GLIBCXX_SYSHDR
33 #pragma GCC system_header
36 #include <bits/requires_hosted.h> // TR1
37 #include <bits/stdexcept_throw.h>
41 #ifdef _GLIBCXX_USE_C99_MATH_TR1
151 namespace std _GLIBCXX_VISIBILITY(default)
153 _GLIBCXX_BEGIN_NAMESPACE_VERSION
157 #if _GLIBCXX_USE_C99_MATH_TR1
159 // Using declarations to bring names from libc's <math.h> into std::tr1.
308 #if _GLIBCXX_USE_C99_MATH
309 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
311 /// Function template definitions [8.16.3].
312 template<typename _Tp>
313 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
317 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
318 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
319 FP_SUBNORMAL, FP_ZERO, __type(__f));
322 template<typename _Tp>
323 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
327 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
328 return __builtin_isfinite(__type(__f));
331 template<typename _Tp>
332 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
336 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
337 return __builtin_isinf(__type(__f));
340 template<typename _Tp>
341 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
345 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
346 return __builtin_isnan(__type(__f));
349 template<typename _Tp>
350 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
354 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
355 return __builtin_isnormal(__type(__f));
358 template<typename _Tp>
359 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
363 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
364 return __builtin_signbit(__type(__f));
367 template<typename _Tp>
368 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
370 isgreater(_Tp __f1, _Tp __f2)
372 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
373 return __builtin_isgreater(__type(__f1), __type(__f2));
376 template<typename _Tp>
377 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
379 isgreaterequal(_Tp __f1, _Tp __f2)
381 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
382 return __builtin_isgreaterequal(__type(__f1), __type(__f2));
385 template<typename _Tp>
386 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
388 isless(_Tp __f1, _Tp __f2)
390 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
391 return __builtin_isless(__type(__f1), __type(__f2));
394 template<typename _Tp>
395 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
397 islessequal(_Tp __f1, _Tp __f2)
399 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
400 return __builtin_islessequal(__type(__f1), __type(__f2));
403 template<typename _Tp>
404 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
406 islessgreater(_Tp __f1, _Tp __f2)
408 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
409 return __builtin_islessgreater(__type(__f1), __type(__f2));
412 template<typename _Tp>
413 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
415 isunordered(_Tp __f1, _Tp __f2)
417 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
418 return __builtin_isunordered(__type(__f1), __type(__f2));
424 #if _GLIBCXX_USE_C99_MATH_TR1
426 /** Additional overloads [8.16.4].
430 // For functions defined in C++03 the additional overloads are already
431 // declared in <cmath> so we can just re-declare them in std::tr1.
453 #if __cplusplus >= 201103L
455 // Since C++11, <cmath> defines additional overloads for these functions
482 using std::nearbyint;
483 using std::nextafter;
484 using std::nexttoward;
485 using std::remainder;
494 #else // __cplusplus < 201103L
496 // In C++03 we need to provide the additional overloads.
498 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
501 { return __builtin_acoshf(__x); }
504 acosh(long double __x)
505 { return __builtin_acoshl(__x); }
508 template<typename _Tp>
509 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
512 { return __builtin_acosh(__x); }
514 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
517 { return __builtin_asinhf(__x); }
520 asinh(long double __x)
521 { return __builtin_asinhl(__x); }
524 template<typename _Tp>
525 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
528 { return __builtin_asinh(__x); }
530 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
533 { return __builtin_atanhf(__x); }
536 atanh(long double __x)
537 { return __builtin_atanhl(__x); }
540 template<typename _Tp>
541 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
544 { return __builtin_atanh(__x); }
546 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
549 { return __builtin_cbrtf(__x); }
552 cbrt(long double __x)
553 { return __builtin_cbrtl(__x); }
556 template<typename _Tp>
557 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
560 { return __builtin_cbrt(__x); }
562 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
564 copysign(float __x, float __y)
565 { return __builtin_copysignf(__x, __y); }
568 copysign(long double __x, long double __y)
569 { return __builtin_copysignl(__x, __y); }
572 template<typename _Tp, typename _Up>
573 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
574 copysign(_Tp __x, _Up __y)
576 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
577 return copysign(__type(__x), __type(__y));
580 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
583 { return __builtin_erff(__x); }
587 { return __builtin_erfl(__x); }
590 template<typename _Tp>
591 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
594 { return __builtin_erf(__x); }
596 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
599 { return __builtin_erfcf(__x); }
602 erfc(long double __x)
603 { return __builtin_erfcl(__x); }
606 template<typename _Tp>
607 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
610 { return __builtin_erfc(__x); }
612 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
615 { return __builtin_exp2f(__x); }
618 exp2(long double __x)
619 { return __builtin_exp2l(__x); }
622 template<typename _Tp>
623 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
626 { return __builtin_exp2(__x); }
628 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
631 { return __builtin_expm1f(__x); }
634 expm1(long double __x)
635 { return __builtin_expm1l(__x); }
638 template<typename _Tp>
639 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
642 { return __builtin_expm1(__x); }
644 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
646 fdim(float __x, float __y)
647 { return __builtin_fdimf(__x, __y); }
650 fdim(long double __x, long double __y)
651 { return __builtin_fdiml(__x, __y); }
654 template<typename _Tp, typename _Up>
655 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
656 fdim(_Tp __x, _Up __y)
658 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
659 return fdim(__type(__x), __type(__y));
662 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
664 fma(float __x, float __y, float __z)
665 { return __builtin_fmaf(__x, __y, __z); }
668 fma(long double __x, long double __y, long double __z)
669 { return __builtin_fmal(__x, __y, __z); }
672 template<typename _Tp, typename _Up, typename _Vp>
673 inline typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
674 fma(_Tp __x, _Up __y, _Vp __z)
676 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
677 return fma(__type(__x), __type(__y), __type(__z));
680 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
682 fmax(float __x, float __y)
683 { return __builtin_fmaxf(__x, __y); }
686 fmax(long double __x, long double __y)
687 { return __builtin_fmaxl(__x, __y); }
690 template<typename _Tp, typename _Up>
691 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
692 fmax(_Tp __x, _Up __y)
694 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
695 return fmax(__type(__x), __type(__y));
698 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
700 fmin(float __x, float __y)
701 { return __builtin_fminf(__x, __y); }
704 fmin(long double __x, long double __y)
705 { return __builtin_fminl(__x, __y); }
708 template<typename _Tp, typename _Up>
709 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
710 fmin(_Tp __x, _Up __y)
712 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
713 return fmin(__type(__x), __type(__y));
716 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
718 hypot(float __x, float __y)
719 { return __builtin_hypotf(__x, __y); }
722 hypot(long double __x, long double __y)
723 { return __builtin_hypotl(__x, __y); }
726 template<typename _Tp, typename _Up>
727 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
728 hypot(_Tp __y, _Up __x)
730 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
731 return hypot(__type(__y), __type(__x));
734 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
737 { return __builtin_ilogbf(__x); }
740 ilogb(long double __x)
741 { return __builtin_ilogbl(__x); }
744 template<typename _Tp>
745 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
748 { return __builtin_ilogb(__x); }
750 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
753 { return __builtin_lgammaf(__x); }
756 lgamma(long double __x)
757 { return __builtin_lgammal(__x); }
760 template<typename _Tp>
761 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
764 { return __builtin_lgamma(__x); }
766 #pragma GCC diagnostic push
767 #pragma GCC diagnostic ignored "-Wlong-long"
769 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
772 { return __builtin_llrintf(__x); }
775 llrint(long double __x)
776 { return __builtin_llrintl(__x); }
779 template<typename _Tp>
780 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
783 { return __builtin_llrint(__x); }
785 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
788 { return __builtin_llroundf(__x); }
791 llround(long double __x)
792 { return __builtin_llroundl(__x); }
795 template<typename _Tp>
796 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
799 { return __builtin_llround(__x); }
800 #pragma GCC diagnostic pop
802 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
805 { return __builtin_log1pf(__x); }
808 log1p(long double __x)
809 { return __builtin_log1pl(__x); }
812 template<typename _Tp>
813 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
816 { return __builtin_log1p(__x); }
819 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
822 { return __builtin_log2f(__x); }
825 log2(long double __x)
826 { return __builtin_log2l(__x); }
829 template<typename _Tp>
830 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
833 { return __builtin_log2(__x); }
835 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
838 { return __builtin_logbf(__x); }
841 logb(long double __x)
842 { return __builtin_logbl(__x); }
845 template<typename _Tp>
846 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
850 return __builtin_logb(__x);
853 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
856 { return __builtin_lrintf(__x); }
859 lrint(long double __x)
860 { return __builtin_lrintl(__x); }
863 template<typename _Tp>
864 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
867 { return __builtin_lrint(__x); }
869 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
872 { return __builtin_lroundf(__x); }
875 lround(long double __x)
876 { return __builtin_lroundl(__x); }
879 template<typename _Tp>
880 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
883 { return __builtin_lround(__x); }
885 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
888 { return __builtin_nearbyintf(__x); }
891 nearbyint(long double __x)
892 { return __builtin_nearbyintl(__x); }
895 template<typename _Tp>
896 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
899 { return __builtin_nearbyint(__x); }
901 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
903 nextafter(float __x, float __y)
904 { return __builtin_nextafterf(__x, __y); }
907 nextafter(long double __x, long double __y)
908 { return __builtin_nextafterl(__x, __y); }
911 template<typename _Tp, typename _Up>
912 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
913 nextafter(_Tp __x, _Up __y)
915 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
916 return nextafter(__type(__x), __type(__y));
919 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
921 nexttoward(float __x, long double __y)
922 { return __builtin_nexttowardf(__x, __y); }
925 nexttoward(long double __x, long double __y)
926 { return __builtin_nexttowardl(__x, __y); }
929 template<typename _Tp>
930 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
932 nexttoward(_Tp __x, long double __y)
933 { return __builtin_nexttoward(__x, __y); }
935 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
937 remainder(float __x, float __y)
938 { return __builtin_remainderf(__x, __y); }
941 remainder(long double __x, long double __y)
942 { return __builtin_remainderl(__x, __y); }
945 template<typename _Tp, typename _Up>
946 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
947 remainder(_Tp __x, _Up __y)
949 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
950 return remainder(__type(__x), __type(__y));
953 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
955 remquo(float __x, float __y, int* __pquo)
956 { return __builtin_remquof(__x, __y, __pquo); }
959 remquo(long double __x, long double __y, int* __pquo)
960 { return __builtin_remquol(__x, __y, __pquo); }
963 template<typename _Tp, typename _Up>
964 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
965 remquo(_Tp __x, _Up __y, int* __pquo)
967 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
968 return remquo(__type(__x), __type(__y), __pquo);
971 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
974 { return __builtin_rintf(__x); }
977 rint(long double __x)
978 { return __builtin_rintl(__x); }
981 template<typename _Tp>
982 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
985 { return __builtin_rint(__x); }
987 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
990 { return __builtin_roundf(__x); }
993 round(long double __x)
994 { return __builtin_roundl(__x); }
997 template<typename _Tp>
998 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1001 { return __builtin_round(__x); }
1003 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1005 scalbln(float __x, long __ex)
1006 { return __builtin_scalblnf(__x, __ex); }
1009 scalbln(long double __x, long __ex)
1010 { return __builtin_scalblnl(__x, __ex); }
1013 template<typename _Tp>
1014 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1016 scalbln(_Tp __x, long __ex)
1017 { return __builtin_scalbln(__x, __ex); }
1019 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1021 scalbn(float __x, int __ex)
1022 { return __builtin_scalbnf(__x, __ex); }
1025 scalbn(long double __x, int __ex)
1026 { return __builtin_scalbnl(__x, __ex); }
1029 template<typename _Tp>
1030 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1032 scalbn(_Tp __x, int __ex)
1033 { return __builtin_scalbn(__x, __ex); }
1035 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1038 { return __builtin_tgammaf(__x); }
1041 tgamma(long double __x)
1042 { return __builtin_tgammal(__x); }
1045 template<typename _Tp>
1046 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1049 { return __builtin_tgamma(__x); }
1051 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1054 { return __builtin_truncf(__x); }
1057 trunc(long double __x)
1058 { return __builtin_truncl(__x); }
1061 template<typename _Tp>
1062 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1065 { return __builtin_trunc(__x); }
1067 #endif // __cplusplus < 201103L
1071 #endif /* _GLIBCXX_USE_C99_MATH_TR1 */
1073 // DR 550. What should the return type of pow(float,int) be?
1074 // NB: C++11 and TR1 != C++03.
1076 // We cannot do "using std::pow;" because that would bring in unwanted
1077 // pow(*, int) overloads in C++03, with the wrong return type. Instead we
1078 // define all the necessary overloads, but the std::tr1::pow(double, double)
1079 // overload cannot be provided here, because <tr1/math.h> would add it to
1080 // the global namespace where it would clash with ::pow(double,double) from
1081 // libc (revealed by the fix of PR c++/54537).
1082 // The solution is to forward std::tr1::pow(double,double) to
1083 // std::pow(double,double) via the function template below. See
1084 // the discussion about this issue here:
1085 // http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01278.html
1087 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1089 pow(float __x, float __y)
1090 { return std::pow(__x, __y); }
1093 pow(long double __x, long double __y)
1094 { return std::pow(__x, __y); }
1097 template<typename _Tp, typename _Up>
1098 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1099 pow(_Tp __x, _Up __y)
1101 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1102 return std::pow(__type(__x), __type(__y));
1105 #if __cplusplus >= 201103L
1106 // We also deal with fabs in a special way, because "using std::fabs;"
1107 // could bring in C++11's std::fabs<T>(const std::complex<T>&) with a
1108 // different return type from std::tr1::fabs<T>(const std::complex<T>&).
1109 // We define the necessary overloads, except std::tr1::fabs(double) which
1110 // could clash with ::fabs(double) from libc.
1111 // The function template handles double as well as integers, forwarding
1114 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
1115 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1118 { return __builtin_fabsf(__x); }
1121 fabs(long double __x)
1122 { return __builtin_fabsl(__x); }
1126 template<typename _Tp>
1127 inline typename __gnu_cxx::__promote<_Tp>::__type
1129 { return std::fabs(__x); }
1133 // For C++03 just use std::fabs as there is no overload for std::complex<>.
1139 _GLIBCXX_END_NAMESPACE_VERSION
1143 * @defgroup tr1_math_spec_func TR1 Mathematical Special Functions
1146 * A collection of advanced mathematical special functions.
1149 #if _GLIBCXX_USE_STD_SPEC_FUNCS
1151 namespace std _GLIBCXX_VISIBILITY(default)
1153 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1157 using std::assoc_laguerref;
1158 using std::assoc_laguerrel;
1159 using std::assoc_laguerre;
1161 using std::assoc_legendref;
1162 using std::assoc_legendrel;
1163 using std::assoc_legendre;
1169 using std::comp_ellint_1f;
1170 using std::comp_ellint_1l;
1171 using std::comp_ellint_1;
1173 using std::comp_ellint_2f;
1174 using std::comp_ellint_2l;
1175 using std::comp_ellint_2;
1177 using std::comp_ellint_3f;
1178 using std::comp_ellint_3l;
1179 using std::comp_ellint_3;
1181 using std::cyl_bessel_if;
1182 using std::cyl_bessel_il;
1183 using std::cyl_bessel_i;
1185 using std::cyl_bessel_jf;
1186 using std::cyl_bessel_jl;
1187 using std::cyl_bessel_j;
1189 using std::cyl_bessel_kf;
1190 using std::cyl_bessel_kl;
1191 using std::cyl_bessel_k;
1193 using std::cyl_neumannf;
1194 using std::cyl_neumannl;
1195 using std::cyl_neumann;
1197 using std::ellint_1f;
1198 using std::ellint_1l;
1199 using std::ellint_1;
1201 using std::ellint_2f;
1202 using std::ellint_2l;
1203 using std::ellint_2;
1205 using std::ellint_3f;
1206 using std::ellint_3l;
1207 using std::ellint_3;
1213 using std::hermitef;
1214 using std::hermitel;
1217 using std::laguerref;
1218 using std::laguerrel;
1219 using std::laguerre;
1221 using std::legendref;
1222 using std::legendrel;
1223 using std::legendre;
1225 using std::riemann_zetaf;
1226 using std::riemann_zetal;
1227 using std::riemann_zeta;
1229 using std::sph_besself;
1230 using std::sph_bessell;
1231 using std::sph_bessel;
1233 using std::sph_legendref;
1234 using std::sph_legendrel;
1235 using std::sph_legendre;
1237 using std::sph_neumannf;
1238 using std::sph_neumannl;
1239 using std::sph_neumann;
1242 _GLIBCXX_END_NAMESPACE_VERSION
1245 #else // ! _GLIBCXX_USE_STD_SPEC_FUNCS
1247 #include <bits/stl_algobase.h>
1249 #include <tr1/type_traits>
1251 #include <tr1/gamma.tcc>
1252 #include <tr1/bessel_function.tcc>
1253 #include <tr1/beta_function.tcc>
1254 #include <tr1/ell_integral.tcc>
1255 #include <tr1/exp_integral.tcc>
1256 #include <tr1/legendre_function.tcc>
1257 #include <tr1/modified_bessel_func.tcc>
1258 #include <tr1/poly_hermite.tcc>
1259 #include <tr1/poly_laguerre.tcc>
1260 #include <tr1/riemann_zeta.tcc>
1262 namespace std _GLIBCXX_VISIBILITY(default)
1264 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1267 /** @addtogroup tr1_math_spec_func
1272 assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
1273 { return __detail::__assoc_laguerre<float>(__n, __m, __x); }
1276 assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
1278 return __detail::__assoc_laguerre<long double>(__n, __m, __x);
1281 /// 5.2.1.1 Associated Laguerre polynomials.
1282 template<typename _Tp>
1283 inline typename __gnu_cxx::__promote<_Tp>::__type
1284 assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
1286 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1287 return __detail::__assoc_laguerre<__type>(__n, __m, __x);
1291 assoc_legendref(unsigned int __l, unsigned int __m, float __x)
1292 { return __detail::__assoc_legendre_p<float>(__l, __m, __x); }
1295 assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
1296 { return __detail::__assoc_legendre_p<long double>(__l, __m, __x); }
1298 /// 5.2.1.2 Associated Legendre functions.
1299 template<typename _Tp>
1300 inline typename __gnu_cxx::__promote<_Tp>::__type
1301 assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
1303 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1304 return __detail::__assoc_legendre_p<__type>(__l, __m, __x);
1308 betaf(float __x, float __y)
1309 { return __detail::__beta<float>(__x, __y); }
1312 betal(long double __x, long double __y)
1313 { return __detail::__beta<long double>(__x, __y); }
1315 /// 5.2.1.3 Beta functions.
1316 template<typename _Tpx, typename _Tpy>
1317 inline typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type
1318 beta(_Tpx __x, _Tpy __y)
1320 typedef typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type __type;
1321 return __detail::__beta<__type>(__x, __y);
1325 comp_ellint_1f(float __k)
1326 { return __detail::__comp_ellint_1<float>(__k); }
1329 comp_ellint_1l(long double __k)
1330 { return __detail::__comp_ellint_1<long double>(__k); }
1332 /// 5.2.1.4 Complete elliptic integrals of the first kind.
1333 template<typename _Tp>
1334 inline typename __gnu_cxx::__promote<_Tp>::__type
1335 comp_ellint_1(_Tp __k)
1337 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1338 return __detail::__comp_ellint_1<__type>(__k);
1342 comp_ellint_2f(float __k)
1343 { return __detail::__comp_ellint_2<float>(__k); }
1346 comp_ellint_2l(long double __k)
1347 { return __detail::__comp_ellint_2<long double>(__k); }
1349 /// 5.2.1.5 Complete elliptic integrals of the second kind.
1350 template<typename _Tp>
1351 inline typename __gnu_cxx::__promote<_Tp>::__type
1352 comp_ellint_2(_Tp __k)
1354 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1355 return __detail::__comp_ellint_2<__type>(__k);
1359 comp_ellint_3f(float __k, float __nu)
1360 { return __detail::__comp_ellint_3<float>(__k, __nu); }
1363 comp_ellint_3l(long double __k, long double __nu)
1364 { return __detail::__comp_ellint_3<long double>(__k, __nu); }
1366 /// 5.2.1.6 Complete elliptic integrals of the third kind.
1367 template<typename _Tp, typename _Tpn>
1368 inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type
1369 comp_ellint_3(_Tp __k, _Tpn __nu)
1371 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type;
1372 return __detail::__comp_ellint_3<__type>(__k, __nu);
1376 cyl_bessel_if(float __nu, float __x)
1377 { return __detail::__cyl_bessel_i<float>(__nu, __x); }
1380 cyl_bessel_il(long double __nu, long double __x)
1381 { return __detail::__cyl_bessel_i<long double>(__nu, __x); }
1383 /// 5.2.1.8 Regular modified cylindrical Bessel functions.
1384 template<typename _Tpnu, typename _Tp>
1385 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1386 cyl_bessel_i(_Tpnu __nu, _Tp __x)
1388 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1389 return __detail::__cyl_bessel_i<__type>(__nu, __x);
1393 cyl_bessel_jf(float __nu, float __x)
1394 { return __detail::__cyl_bessel_j<float>(__nu, __x); }
1397 cyl_bessel_jl(long double __nu, long double __x)
1398 { return __detail::__cyl_bessel_j<long double>(__nu, __x); }
1400 /// 5.2.1.9 Cylindrical Bessel functions (of the first kind).
1401 template<typename _Tpnu, typename _Tp>
1402 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1403 cyl_bessel_j(_Tpnu __nu, _Tp __x)
1405 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1406 return __detail::__cyl_bessel_j<__type>(__nu, __x);
1410 cyl_bessel_kf(float __nu, float __x)
1411 { return __detail::__cyl_bessel_k<float>(__nu, __x); }
1414 cyl_bessel_kl(long double __nu, long double __x)
1415 { return __detail::__cyl_bessel_k<long double>(__nu, __x); }
1417 /// 5.2.1.10 Irregular modified cylindrical Bessel functions.
1418 template<typename _Tpnu, typename _Tp>
1419 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1420 cyl_bessel_k(_Tpnu __nu, _Tp __x)
1422 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1423 return __detail::__cyl_bessel_k<__type>(__nu, __x);
1427 cyl_neumannf(float __nu, float __x)
1428 { return __detail::__cyl_neumann_n<float>(__nu, __x); }
1431 cyl_neumannl(long double __nu, long double __x)
1432 { return __detail::__cyl_neumann_n<long double>(__nu, __x); }
1434 /// 5.2.1.11 Cylindrical Neumann functions.
1435 template<typename _Tpnu, typename _Tp>
1436 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1437 cyl_neumann(_Tpnu __nu, _Tp __x)
1439 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1440 return __detail::__cyl_neumann_n<__type>(__nu, __x);
1444 ellint_1f(float __k, float __phi)
1445 { return __detail::__ellint_1<float>(__k, __phi); }
1448 ellint_1l(long double __k, long double __phi)
1449 { return __detail::__ellint_1<long double>(__k, __phi); }
1451 /// 5.2.1.12 Incomplete elliptic integrals of the first kind.
1452 template<typename _Tp, typename _Tpp>
1453 inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
1454 ellint_1(_Tp __k, _Tpp __phi)
1456 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
1457 return __detail::__ellint_1<__type>(__k, __phi);
1461 ellint_2f(float __k, float __phi)
1462 { return __detail::__ellint_2<float>(__k, __phi); }
1465 ellint_2l(long double __k, long double __phi)
1466 { return __detail::__ellint_2<long double>(__k, __phi); }
1468 /// 5.2.1.13 Incomplete elliptic integrals of the second kind.
1469 template<typename _Tp, typename _Tpp>
1470 inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
1471 ellint_2(_Tp __k, _Tpp __phi)
1473 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
1474 return __detail::__ellint_2<__type>(__k, __phi);
1478 ellint_3f(float __k, float __nu, float __phi)
1479 { return __detail::__ellint_3<float>(__k, __nu, __phi); }
1482 ellint_3l(long double __k, long double __nu, long double __phi)
1483 { return __detail::__ellint_3<long double>(__k, __nu, __phi); }
1485 /// 5.2.1.14 Incomplete elliptic integrals of the third kind.
1486 template<typename _Tp, typename _Tpn, typename _Tpp>
1487 inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type
1488 ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
1490 typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type;
1491 return __detail::__ellint_3<__type>(__k, __nu, __phi);
1496 { return __detail::__expint<float>(__x); }
1499 expintl(long double __x)
1500 { return __detail::__expint<long double>(__x); }
1502 /// 5.2.1.15 Exponential integrals.
1503 template<typename _Tp>
1504 inline typename __gnu_cxx::__promote<_Tp>::__type
1507 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1508 return __detail::__expint<__type>(__x);
1512 hermitef(unsigned int __n, float __x)
1513 { return __detail::__poly_hermite<float>(__n, __x); }
1516 hermitel(unsigned int __n, long double __x)
1517 { return __detail::__poly_hermite<long double>(__n, __x); }
1519 /// 5.2.1.16 Hermite polynomials.
1520 template<typename _Tp>
1521 inline typename __gnu_cxx::__promote<_Tp>::__type
1522 hermite(unsigned int __n, _Tp __x)
1524 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1525 return __detail::__poly_hermite<__type>(__n, __x);
1529 laguerref(unsigned int __n, float __x)
1530 { return __detail::__laguerre<float>(__n, __x); }
1533 laguerrel(unsigned int __n, long double __x)
1534 { return __detail::__laguerre<long double>(__n, __x); }
1536 /// 5.2.1.18 Laguerre polynomials.
1537 template<typename _Tp>
1538 inline typename __gnu_cxx::__promote<_Tp>::__type
1539 laguerre(unsigned int __n, _Tp __x)
1541 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1542 return __detail::__laguerre<__type>(__n, __x);
1546 legendref(unsigned int __n, float __x)
1547 { return __detail::__poly_legendre_p<float>(__n, __x); }
1550 legendrel(unsigned int __n, long double __x)
1551 { return __detail::__poly_legendre_p<long double>(__n, __x); }
1553 /// 5.2.1.19 Legendre polynomials.
1554 template<typename _Tp>
1555 inline typename __gnu_cxx::__promote<_Tp>::__type
1556 legendre(unsigned int __n, _Tp __x)
1558 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1559 return __detail::__poly_legendre_p<__type>(__n, __x);
1563 riemann_zetaf(float __x)
1564 { return __detail::__riemann_zeta<float>(__x); }
1567 riemann_zetal(long double __x)
1568 { return __detail::__riemann_zeta<long double>(__x); }
1570 /// 5.2.1.20 Riemann zeta function.
1571 template<typename _Tp>
1572 inline typename __gnu_cxx::__promote<_Tp>::__type
1573 riemann_zeta(_Tp __x)
1575 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1576 return __detail::__riemann_zeta<__type>(__x);
1580 sph_besself(unsigned int __n, float __x)
1581 { return __detail::__sph_bessel<float>(__n, __x); }
1584 sph_bessell(unsigned int __n, long double __x)
1585 { return __detail::__sph_bessel<long double>(__n, __x); }
1587 /// 5.2.1.21 Spherical Bessel functions.
1588 template<typename _Tp>
1589 inline typename __gnu_cxx::__promote<_Tp>::__type
1590 sph_bessel(unsigned int __n, _Tp __x)
1592 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1593 return __detail::__sph_bessel<__type>(__n, __x);
1597 sph_legendref(unsigned int __l, unsigned int __m, float __theta)
1598 { return __detail::__sph_legendre<float>(__l, __m, __theta); }
1601 sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
1602 { return __detail::__sph_legendre<long double>(__l, __m, __theta); }
1604 /// 5.2.1.22 Spherical associated Legendre functions.
1605 template<typename _Tp>
1606 inline typename __gnu_cxx::__promote<_Tp>::__type
1607 sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
1609 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1610 return __detail::__sph_legendre<__type>(__l, __m, __theta);
1614 sph_neumannf(unsigned int __n, float __x)
1615 { return __detail::__sph_neumann<float>(__n, __x); }
1618 sph_neumannl(unsigned int __n, long double __x)
1619 { return __detail::__sph_neumann<long double>(__n, __x); }
1621 /// 5.2.1.23 Spherical Neumann functions.
1622 template<typename _Tp>
1623 inline typename __gnu_cxx::__promote<_Tp>::__type
1624 sph_neumann(unsigned int __n, _Tp __x)
1626 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1627 return __detail::__sph_neumann<__type>(__n, __x);
1630 /// @} tr1_math_spec_func
1634 _GLIBCXX_END_NAMESPACE_VERSION
1637 #endif // _GLIBCXX_USE_STD_SPEC_FUNCS
1639 #if _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)
1640 namespace std _GLIBCXX_VISIBILITY(default)
1642 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1646 using __gnu_cxx::conf_hypergf;
1647 using __gnu_cxx::conf_hypergl;
1648 using __gnu_cxx::conf_hyperg;
1650 using __gnu_cxx::hypergf;
1651 using __gnu_cxx::hypergl;
1652 using __gnu_cxx::hyperg;
1655 _GLIBCXX_END_NAMESPACE_VERSION
1658 #else // ! (_GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__))
1660 #include <bits/stl_algobase.h>
1662 #include <tr1/type_traits>
1664 #include <tr1/hypergeometric.tcc>
1666 namespace std _GLIBCXX_VISIBILITY(default)
1668 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1672 /** @addtogroup tr1_math_spec_func
1677 conf_hypergf(float __a, float __c, float __x)
1678 { return __detail::__conf_hyperg<float>(__a, __c, __x); }
1681 conf_hypergl(long double __a, long double __c, long double __x)
1682 { return __detail::__conf_hyperg<long double>(__a, __c, __x); }
1684 /// 5.2.1.7 Confluent hypergeometric functions.
1685 template<typename _Tpa, typename _Tpc, typename _Tp>
1686 inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type
1687 conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
1689 typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type;
1690 return __detail::__conf_hyperg<__type>(__a, __c, __x);
1694 hypergf(float __a, float __b, float __c, float __x)
1695 { return __detail::__hyperg<float>(__a, __b, __c, __x); }
1698 hypergl(long double __a, long double __b, long double __c, long double __x)
1699 { return __detail::__hyperg<long double>(__a, __b, __c, __x); }
1701 /// 5.2.1.17 Hypergeometric functions.
1702 template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
1703 inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type
1704 hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
1706 typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type;
1707 return __detail::__hyperg<__type>(__a, __b, __c, __x);
1710 /// @} tr1_math_spec_func
1714 _GLIBCXX_END_NAMESPACE_VERSION
1716 #endif // _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)
1718 #endif // _GLIBCXX_TR1_CMATH