1// TR1 cmath -*- C++ -*-
3// Copyright (C) 2006-2023 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#pragma GCC system_header
34#include <bits/requires_hosted.h> // TR1
38#ifdef _GLIBCXX_USE_C99_MATH_TR1
148namespace std _GLIBCXX_VISIBILITY(default)
150_GLIBCXX_BEGIN_NAMESPACE_VERSION
154#if _GLIBCXX_USE_C99_MATH_TR1
156 // Using declarations to bring names from libc's <math.h> into std::tr1.
305#if _GLIBCXX_USE_C99_MATH
306#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
308 /// Function template definitions [8.16.3].
309 template<typename _Tp>
310 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
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));
319 template<typename _Tp>
320 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
324 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
325 return __builtin_isfinite(__type(__f));
328 template<typename _Tp>
329 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
333 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
334 return __builtin_isinf(__type(__f));
337 template<typename _Tp>
338 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
342 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
343 return __builtin_isnan(__type(__f));
346 template<typename _Tp>
347 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
351 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
352 return __builtin_isnormal(__type(__f));
355 template<typename _Tp>
356 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
360 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
361 return __builtin_signbit(__type(__f));
364 template<typename _Tp>
365 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
367 isgreater(_Tp __f1, _Tp __f2)
369 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
370 return __builtin_isgreater(__type(__f1), __type(__f2));
373 template<typename _Tp>
374 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
376 isgreaterequal(_Tp __f1, _Tp __f2)
378 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
379 return __builtin_isgreaterequal(__type(__f1), __type(__f2));
382 template<typename _Tp>
383 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
385 isless(_Tp __f1, _Tp __f2)
387 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
388 return __builtin_isless(__type(__f1), __type(__f2));
391 template<typename _Tp>
392 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
394 islessequal(_Tp __f1, _Tp __f2)
396 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
397 return __builtin_islessequal(__type(__f1), __type(__f2));
400 template<typename _Tp>
401 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
403 islessgreater(_Tp __f1, _Tp __f2)
405 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
406 return __builtin_islessgreater(__type(__f1), __type(__f2));
409 template<typename _Tp>
410 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
412 isunordered(_Tp __f1, _Tp __f2)
414 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
415 return __builtin_isunordered(__type(__f1), __type(__f2));
421#if _GLIBCXX_USE_C99_MATH_TR1
423 /** Additional overloads [8.16.4].
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.
450#if __cplusplus >= 201103L
452 // Since C++11, <cmath> defines additional overloads for these functions
479 using std::nearbyint;
480 using std::nextafter;
481 using std::nexttoward;
482 using std::remainder;
491#else // __cplusplus < 201103L
493 // In C++03 we need to provide the additional overloads.
495#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
498 { return __builtin_acoshf(__x); }
501 acosh(long double __x)
502 { return __builtin_acoshl(__x); }
505 template<typename _Tp>
506 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
509 { return __builtin_acosh(__x); }
511#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
514 { return __builtin_asinhf(__x); }
517 asinh(long double __x)
518 { return __builtin_asinhl(__x); }
521 template<typename _Tp>
522 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
525 { return __builtin_asinh(__x); }
527#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
530 { return __builtin_atanhf(__x); }
533 atanh(long double __x)
534 { return __builtin_atanhl(__x); }
537 template<typename _Tp>
538 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
541 { return __builtin_atanh(__x); }
543#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
546 { return __builtin_cbrtf(__x); }
549 cbrt(long double __x)
550 { return __builtin_cbrtl(__x); }
553 template<typename _Tp>
554 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
557 { return __builtin_cbrt(__x); }
559#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
561 copysign(float __x, float __y)
562 { return __builtin_copysignf(__x, __y); }
565 copysign(long double __x, long double __y)
566 { return __builtin_copysignl(__x, __y); }
569 template<typename _Tp, typename _Up>
570 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
571 copysign(_Tp __x, _Up __y)
573 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
574 return copysign(__type(__x), __type(__y));
577#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
580 { return __builtin_erff(__x); }
584 { return __builtin_erfl(__x); }
587 template<typename _Tp>
588 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
591 { return __builtin_erf(__x); }
593#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
596 { return __builtin_erfcf(__x); }
599 erfc(long double __x)
600 { return __builtin_erfcl(__x); }
603 template<typename _Tp>
604 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
607 { return __builtin_erfc(__x); }
609#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
612 { return __builtin_exp2f(__x); }
615 exp2(long double __x)
616 { return __builtin_exp2l(__x); }
619 template<typename _Tp>
620 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
623 { return __builtin_exp2(__x); }
625#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
628 { return __builtin_expm1f(__x); }
631 expm1(long double __x)
632 { return __builtin_expm1l(__x); }
635 template<typename _Tp>
636 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
639 { return __builtin_expm1(__x); }
641#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
643 fdim(float __x, float __y)
644 { return __builtin_fdimf(__x, __y); }
647 fdim(long double __x, long double __y)
648 { return __builtin_fdiml(__x, __y); }
651 template<typename _Tp, typename _Up>
652 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
653 fdim(_Tp __x, _Up __y)
655 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
656 return fdim(__type(__x), __type(__y));
659#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
661 fma(float __x, float __y, float __z)
662 { return __builtin_fmaf(__x, __y, __z); }
665 fma(long double __x, long double __y, long double __z)
666 { return __builtin_fmal(__x, __y, __z); }
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)
673 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
674 return fma(__type(__x), __type(__y), __type(__z));
677#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
679 fmax(float __x, float __y)
680 { return __builtin_fmaxf(__x, __y); }
683 fmax(long double __x, long double __y)
684 { return __builtin_fmaxl(__x, __y); }
687 template<typename _Tp, typename _Up>
688 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
689 fmax(_Tp __x, _Up __y)
691 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
692 return fmax(__type(__x), __type(__y));
695#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
697 fmin(float __x, float __y)
698 { return __builtin_fminf(__x, __y); }
701 fmin(long double __x, long double __y)
702 { return __builtin_fminl(__x, __y); }
705 template<typename _Tp, typename _Up>
706 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
707 fmin(_Tp __x, _Up __y)
709 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
710 return fmin(__type(__x), __type(__y));
713#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
715 hypot(float __x, float __y)
716 { return __builtin_hypotf(__x, __y); }
719 hypot(long double __x, long double __y)
720 { return __builtin_hypotl(__x, __y); }
723 template<typename _Tp, typename _Up>
724 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
725 hypot(_Tp __y, _Up __x)
727 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
728 return hypot(__type(__y), __type(__x));
731#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
734 { return __builtin_ilogbf(__x); }
737 ilogb(long double __x)
738 { return __builtin_ilogbl(__x); }
741 template<typename _Tp>
742 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
745 { return __builtin_ilogb(__x); }
747#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
750 { return __builtin_lgammaf(__x); }
753 lgamma(long double __x)
754 { return __builtin_lgammal(__x); }
757 template<typename _Tp>
758 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
761 { return __builtin_lgamma(__x); }
763#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
766 { return __builtin_llrintf(__x); }
769 llrint(long double __x)
770 { return __builtin_llrintl(__x); }
773 template<typename _Tp>
774 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
777 { return __builtin_llrint(__x); }
779#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
782 { return __builtin_llroundf(__x); }
785 llround(long double __x)
786 { return __builtin_llroundl(__x); }
789 template<typename _Tp>
790 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
793 { return __builtin_llround(__x); }
795#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
798 { return __builtin_log1pf(__x); }
801 log1p(long double __x)
802 { return __builtin_log1pl(__x); }
805 template<typename _Tp>
806 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
809 { return __builtin_log1p(__x); }
812#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
815 { return __builtin_log2f(__x); }
818 log2(long double __x)
819 { return __builtin_log2l(__x); }
822 template<typename _Tp>
823 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
826 { return __builtin_log2(__x); }
828#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
831 { return __builtin_logbf(__x); }
834 logb(long double __x)
835 { return __builtin_logbl(__x); }
838 template<typename _Tp>
839 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
843 return __builtin_logb(__x);
846#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
849 { return __builtin_lrintf(__x); }
852 lrint(long double __x)
853 { return __builtin_lrintl(__x); }
856 template<typename _Tp>
857 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
860 { return __builtin_lrint(__x); }
862#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
865 { return __builtin_lroundf(__x); }
868 lround(long double __x)
869 { return __builtin_lroundl(__x); }
872 template<typename _Tp>
873 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
876 { return __builtin_lround(__x); }
878#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
881 { return __builtin_nearbyintf(__x); }
884 nearbyint(long double __x)
885 { return __builtin_nearbyintl(__x); }
888 template<typename _Tp>
889 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
892 { return __builtin_nearbyint(__x); }
894#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
896 nextafter(float __x, float __y)
897 { return __builtin_nextafterf(__x, __y); }
900 nextafter(long double __x, long double __y)
901 { return __builtin_nextafterl(__x, __y); }
904 template<typename _Tp, typename _Up>
905 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
906 nextafter(_Tp __x, _Up __y)
908 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
909 return nextafter(__type(__x), __type(__y));
912#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
914 nexttoward(float __x, long double __y)
915 { return __builtin_nexttowardf(__x, __y); }
918 nexttoward(long double __x, long double __y)
919 { return __builtin_nexttowardl(__x, __y); }
922 template<typename _Tp>
923 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
925 nexttoward(_Tp __x, long double __y)
926 { return __builtin_nexttoward(__x, __y); }
928#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
930 remainder(float __x, float __y)
931 { return __builtin_remainderf(__x, __y); }
934 remainder(long double __x, long double __y)
935 { return __builtin_remainderl(__x, __y); }
938 template<typename _Tp, typename _Up>
939 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
940 remainder(_Tp __x, _Up __y)
942 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
943 return remainder(__type(__x), __type(__y));
946#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
948 remquo(float __x, float __y, int* __pquo)
949 { return __builtin_remquof(__x, __y, __pquo); }
952 remquo(long double __x, long double __y, int* __pquo)
953 { return __builtin_remquol(__x, __y, __pquo); }
956 template<typename _Tp, typename _Up>
957 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
958 remquo(_Tp __x, _Up __y, int* __pquo)
960 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
961 return remquo(__type(__x), __type(__y), __pquo);
964#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
967 { return __builtin_rintf(__x); }
970 rint(long double __x)
971 { return __builtin_rintl(__x); }
974 template<typename _Tp>
975 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
978 { return __builtin_rint(__x); }
980#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
983 { return __builtin_roundf(__x); }
986 round(long double __x)
987 { return __builtin_roundl(__x); }
990 template<typename _Tp>
991 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
994 { return __builtin_round(__x); }
996#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
998 scalbln(float __x, long __ex)
999 { return __builtin_scalblnf(__x, __ex); }
1002 scalbln(long double __x, long __ex)
1003 { return __builtin_scalblnl(__x, __ex); }
1006 template<typename _Tp>
1007 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1009 scalbln(_Tp __x, long __ex)
1010 { return __builtin_scalbln(__x, __ex); }
1012#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1014 scalbn(float __x, int __ex)
1015 { return __builtin_scalbnf(__x, __ex); }
1018 scalbn(long double __x, int __ex)
1019 { return __builtin_scalbnl(__x, __ex); }
1022 template<typename _Tp>
1023 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1025 scalbn(_Tp __x, int __ex)
1026 { return __builtin_scalbn(__x, __ex); }
1028#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1031 { return __builtin_tgammaf(__x); }
1034 tgamma(long double __x)
1035 { return __builtin_tgammal(__x); }
1038 template<typename _Tp>
1039 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1042 { return __builtin_tgamma(__x); }
1044#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1047 { return __builtin_truncf(__x); }
1050 trunc(long double __x)
1051 { return __builtin_truncl(__x); }
1054 template<typename _Tp>
1055 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1058 { return __builtin_trunc(__x); }
1060#endif // __cplusplus < 201103L
1064#endif /* _GLIBCXX_USE_C99_MATH_TR1 */
1066 // DR 550. What should the return type of pow(float,int) be?
1067 // NB: C++11 and TR1 != C++03.
1069 // We cannot do "using std::pow;" because that would bring in unwanted
1070 // pow(*, int) overloads in C++03, with the wrong return type. Instead we
1071 // define all the necessary overloads, but the std::tr1::pow(double, double)
1072 // overload cannot be provided here, because <tr1/math.h> would add it to
1073 // the global namespace where it would clash with ::pow(double,double) from
1074 // libc (revealed by the fix of PR c++/54537).
1075 // The solution is to forward std::tr1::pow(double,double) to
1076 // std::pow(double,double) via the function template below. See
1077 // the discussion about this issue here:
1078 // http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01278.html
1080#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1082 pow(float __x, float __y)
1083 { return std::pow(__x, __y); }
1086 pow(long double __x, long double __y)
1087 { return std::pow(__x, __y); }
1090 template<typename _Tp, typename _Up>
1091 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1092 pow(_Tp __x, _Up __y)
1094 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1095 return std::pow(__type(__x), __type(__y));
1098#if __cplusplus >= 201103L
1099 // We also deal with fabs in a special way, because "using std::fabs;"
1100 // could bring in C++11's std::fabs<T>(const std::complex<T>&) with a
1101 // different return type from std::tr1::fabs<T>(const std::complex<T>&).
1102 // We define the necessary overloads, except std::tr1::fabs(double) which
1103 // could clash with ::fabs(double) from libc.
1104 // The function template handles double as well as integers, forwarding
1107#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
1108#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1111 { return __builtin_fabsf(__x); }
1114 fabs(long double __x)
1115 { return __builtin_fabsl(__x); }
1119 template<typename _Tp>
1120 inline typename __gnu_cxx::__promote<_Tp>::__type
1122 { return std::fabs(__x); }
1126 // For C++03 just use std::fabs as there is no overload for std::complex<>.
1132_GLIBCXX_END_NAMESPACE_VERSION
1136 * @defgroup tr1_math_spec_func TR1 Mathematical Special Functions
1139 * A collection of advanced mathematical special functions.
1142#if _GLIBCXX_USE_STD_SPEC_FUNCS
1144namespace std _GLIBCXX_VISIBILITY(default)
1146_GLIBCXX_BEGIN_NAMESPACE_VERSION
1150 using std::assoc_laguerref;
1151 using std::assoc_laguerrel;
1152 using std::assoc_laguerre;
1154 using std::assoc_legendref;
1155 using std::assoc_legendrel;
1156 using std::assoc_legendre;
1162 using std::comp_ellint_1f;
1163 using std::comp_ellint_1l;
1164 using std::comp_ellint_1;
1166 using std::comp_ellint_2f;
1167 using std::comp_ellint_2l;
1168 using std::comp_ellint_2;
1170 using std::comp_ellint_3f;
1171 using std::comp_ellint_3l;
1172 using std::comp_ellint_3;
1174 using std::cyl_bessel_if;
1175 using std::cyl_bessel_il;
1176 using std::cyl_bessel_i;
1178 using std::cyl_bessel_jf;
1179 using std::cyl_bessel_jl;
1180 using std::cyl_bessel_j;
1182 using std::cyl_bessel_kf;
1183 using std::cyl_bessel_kl;
1184 using std::cyl_bessel_k;
1186 using std::cyl_neumannf;
1187 using std::cyl_neumannl;
1188 using std::cyl_neumann;
1190 using std::ellint_1f;
1191 using std::ellint_1l;
1192 using std::ellint_1;
1194 using std::ellint_2f;
1195 using std::ellint_2l;
1196 using std::ellint_2;
1198 using std::ellint_3f;
1199 using std::ellint_3l;
1200 using std::ellint_3;
1206 using std::hermitef;
1207 using std::hermitel;
1210 using std::laguerref;
1211 using std::laguerrel;
1212 using std::laguerre;
1214 using std::legendref;
1215 using std::legendrel;
1216 using std::legendre;
1218 using std::riemann_zetaf;
1219 using std::riemann_zetal;
1220 using std::riemann_zeta;
1222 using std::sph_besself;
1223 using std::sph_bessell;
1224 using std::sph_bessel;
1226 using std::sph_legendref;
1227 using std::sph_legendrel;
1228 using std::sph_legendre;
1230 using std::sph_neumannf;
1231 using std::sph_neumannl;
1232 using std::sph_neumann;
1235_GLIBCXX_END_NAMESPACE_VERSION
1238#else // ! _GLIBCXX_USE_STD_SPEC_FUNCS
1240#include <bits/stl_algobase.h>
1242#include <tr1/type_traits>
1244#include <tr1/gamma.tcc>
1245#include <tr1/bessel_function.tcc>
1246#include <tr1/beta_function.tcc>
1247#include <tr1/ell_integral.tcc>
1248#include <tr1/exp_integral.tcc>
1249#include <tr1/legendre_function.tcc>
1250#include <tr1/modified_bessel_func.tcc>
1251#include <tr1/poly_hermite.tcc>
1252#include <tr1/poly_laguerre.tcc>
1253#include <tr1/riemann_zeta.tcc>
1255namespace std _GLIBCXX_VISIBILITY(default)
1257_GLIBCXX_BEGIN_NAMESPACE_VERSION
1260 /** @addtogroup tr1_math_spec_func
1265 assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
1266 { return __detail::__assoc_laguerre<float>(__n, __m, __x); }
1269 assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
1271 return __detail::__assoc_laguerre<long double>(__n, __m, __x);
1274 /// 5.2.1.1 Associated Laguerre polynomials.
1275 template<typename _Tp>
1276 inline typename __gnu_cxx::__promote<_Tp>::__type
1277 assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
1279 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1280 return __detail::__assoc_laguerre<__type>(__n, __m, __x);
1284 assoc_legendref(unsigned int __l, unsigned int __m, float __x)
1285 { return __detail::__assoc_legendre_p<float>(__l, __m, __x); }
1288 assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
1289 { return __detail::__assoc_legendre_p<long double>(__l, __m, __x); }
1291 /// 5.2.1.2 Associated Legendre functions.
1292 template<typename _Tp>
1293 inline typename __gnu_cxx::__promote<_Tp>::__type
1294 assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
1296 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1297 return __detail::__assoc_legendre_p<__type>(__l, __m, __x);
1301 betaf(float __x, float __y)
1302 { return __detail::__beta<float>(__x, __y); }
1305 betal(long double __x, long double __y)
1306 { return __detail::__beta<long double>(__x, __y); }
1308 /// 5.2.1.3 Beta functions.
1309 template<typename _Tpx, typename _Tpy>
1310 inline typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type
1311 beta(_Tpx __x, _Tpy __y)
1313 typedef typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type __type;
1314 return __detail::__beta<__type>(__x, __y);
1318 comp_ellint_1f(float __k)
1319 { return __detail::__comp_ellint_1<float>(__k); }
1322 comp_ellint_1l(long double __k)
1323 { return __detail::__comp_ellint_1<long double>(__k); }
1325 /// 5.2.1.4 Complete elliptic integrals of the first kind.
1326 template<typename _Tp>
1327 inline typename __gnu_cxx::__promote<_Tp>::__type
1328 comp_ellint_1(_Tp __k)
1330 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1331 return __detail::__comp_ellint_1<__type>(__k);
1335 comp_ellint_2f(float __k)
1336 { return __detail::__comp_ellint_2<float>(__k); }
1339 comp_ellint_2l(long double __k)
1340 { return __detail::__comp_ellint_2<long double>(__k); }
1342 /// 5.2.1.5 Complete elliptic integrals of the second kind.
1343 template<typename _Tp>
1344 inline typename __gnu_cxx::__promote<_Tp>::__type
1345 comp_ellint_2(_Tp __k)
1347 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1348 return __detail::__comp_ellint_2<__type>(__k);
1352 comp_ellint_3f(float __k, float __nu)
1353 { return __detail::__comp_ellint_3<float>(__k, __nu); }
1356 comp_ellint_3l(long double __k, long double __nu)
1357 { return __detail::__comp_ellint_3<long double>(__k, __nu); }
1359 /// 5.2.1.6 Complete elliptic integrals of the third kind.
1360 template<typename _Tp, typename _Tpn>
1361 inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type
1362 comp_ellint_3(_Tp __k, _Tpn __nu)
1364 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type;
1365 return __detail::__comp_ellint_3<__type>(__k, __nu);
1369 cyl_bessel_if(float __nu, float __x)
1370 { return __detail::__cyl_bessel_i<float>(__nu, __x); }
1373 cyl_bessel_il(long double __nu, long double __x)
1374 { return __detail::__cyl_bessel_i<long double>(__nu, __x); }
1376 /// 5.2.1.8 Regular modified cylindrical Bessel functions.
1377 template<typename _Tpnu, typename _Tp>
1378 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1379 cyl_bessel_i(_Tpnu __nu, _Tp __x)
1381 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1382 return __detail::__cyl_bessel_i<__type>(__nu, __x);
1386 cyl_bessel_jf(float __nu, float __x)
1387 { return __detail::__cyl_bessel_j<float>(__nu, __x); }
1390 cyl_bessel_jl(long double __nu, long double __x)
1391 { return __detail::__cyl_bessel_j<long double>(__nu, __x); }
1393 /// 5.2.1.9 Cylindrical Bessel functions (of the first kind).
1394 template<typename _Tpnu, typename _Tp>
1395 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1396 cyl_bessel_j(_Tpnu __nu, _Tp __x)
1398 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1399 return __detail::__cyl_bessel_j<__type>(__nu, __x);
1403 cyl_bessel_kf(float __nu, float __x)
1404 { return __detail::__cyl_bessel_k<float>(__nu, __x); }
1407 cyl_bessel_kl(long double __nu, long double __x)
1408 { return __detail::__cyl_bessel_k<long double>(__nu, __x); }
1410 /// 5.2.1.10 Irregular modified cylindrical Bessel functions.
1411 template<typename _Tpnu, typename _Tp>
1412 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1413 cyl_bessel_k(_Tpnu __nu, _Tp __x)
1415 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1416 return __detail::__cyl_bessel_k<__type>(__nu, __x);
1420 cyl_neumannf(float __nu, float __x)
1421 { return __detail::__cyl_neumann_n<float>(__nu, __x); }
1424 cyl_neumannl(long double __nu, long double __x)
1425 { return __detail::__cyl_neumann_n<long double>(__nu, __x); }
1427 /// 5.2.1.11 Cylindrical Neumann functions.
1428 template<typename _Tpnu, typename _Tp>
1429 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1430 cyl_neumann(_Tpnu __nu, _Tp __x)
1432 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1433 return __detail::__cyl_neumann_n<__type>(__nu, __x);
1437 ellint_1f(float __k, float __phi)
1438 { return __detail::__ellint_1<float>(__k, __phi); }
1441 ellint_1l(long double __k, long double __phi)
1442 { return __detail::__ellint_1<long double>(__k, __phi); }
1444 /// 5.2.1.12 Incomplete elliptic integrals of the first kind.
1445 template<typename _Tp, typename _Tpp>
1446 inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
1447 ellint_1(_Tp __k, _Tpp __phi)
1449 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
1450 return __detail::__ellint_1<__type>(__k, __phi);
1454 ellint_2f(float __k, float __phi)
1455 { return __detail::__ellint_2<float>(__k, __phi); }
1458 ellint_2l(long double __k, long double __phi)
1459 { return __detail::__ellint_2<long double>(__k, __phi); }
1461 /// 5.2.1.13 Incomplete elliptic integrals of the second kind.
1462 template<typename _Tp, typename _Tpp>
1463 inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
1464 ellint_2(_Tp __k, _Tpp __phi)
1466 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
1467 return __detail::__ellint_2<__type>(__k, __phi);
1471 ellint_3f(float __k, float __nu, float __phi)
1472 { return __detail::__ellint_3<float>(__k, __nu, __phi); }
1475 ellint_3l(long double __k, long double __nu, long double __phi)
1476 { return __detail::__ellint_3<long double>(__k, __nu, __phi); }
1478 /// 5.2.1.14 Incomplete elliptic integrals of the third kind.
1479 template<typename _Tp, typename _Tpn, typename _Tpp>
1480 inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type
1481 ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
1483 typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type;
1484 return __detail::__ellint_3<__type>(__k, __nu, __phi);
1489 { return __detail::__expint<float>(__x); }
1492 expintl(long double __x)
1493 { return __detail::__expint<long double>(__x); }
1495 /// 5.2.1.15 Exponential integrals.
1496 template<typename _Tp>
1497 inline typename __gnu_cxx::__promote<_Tp>::__type
1500 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1501 return __detail::__expint<__type>(__x);
1505 hermitef(unsigned int __n, float __x)
1506 { return __detail::__poly_hermite<float>(__n, __x); }
1509 hermitel(unsigned int __n, long double __x)
1510 { return __detail::__poly_hermite<long double>(__n, __x); }
1512 /// 5.2.1.16 Hermite polynomials.
1513 template<typename _Tp>
1514 inline typename __gnu_cxx::__promote<_Tp>::__type
1515 hermite(unsigned int __n, _Tp __x)
1517 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1518 return __detail::__poly_hermite<__type>(__n, __x);
1522 laguerref(unsigned int __n, float __x)
1523 { return __detail::__laguerre<float>(__n, __x); }
1526 laguerrel(unsigned int __n, long double __x)
1527 { return __detail::__laguerre<long double>(__n, __x); }
1529 /// 5.2.1.18 Laguerre polynomials.
1530 template<typename _Tp>
1531 inline typename __gnu_cxx::__promote<_Tp>::__type
1532 laguerre(unsigned int __n, _Tp __x)
1534 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1535 return __detail::__laguerre<__type>(__n, __x);
1539 legendref(unsigned int __n, float __x)
1540 { return __detail::__poly_legendre_p<float>(__n, __x); }
1543 legendrel(unsigned int __n, long double __x)
1544 { return __detail::__poly_legendre_p<long double>(__n, __x); }
1546 /// 5.2.1.19 Legendre polynomials.
1547 template<typename _Tp>
1548 inline typename __gnu_cxx::__promote<_Tp>::__type
1549 legendre(unsigned int __n, _Tp __x)
1551 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1552 return __detail::__poly_legendre_p<__type>(__n, __x);
1556 riemann_zetaf(float __x)
1557 { return __detail::__riemann_zeta<float>(__x); }
1560 riemann_zetal(long double __x)
1561 { return __detail::__riemann_zeta<long double>(__x); }
1563 /// 5.2.1.20 Riemann zeta function.
1564 template<typename _Tp>
1565 inline typename __gnu_cxx::__promote<_Tp>::__type
1566 riemann_zeta(_Tp __x)
1568 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1569 return __detail::__riemann_zeta<__type>(__x);
1573 sph_besself(unsigned int __n, float __x)
1574 { return __detail::__sph_bessel<float>(__n, __x); }
1577 sph_bessell(unsigned int __n, long double __x)
1578 { return __detail::__sph_bessel<long double>(__n, __x); }
1580 /// 5.2.1.21 Spherical Bessel functions.
1581 template<typename _Tp>
1582 inline typename __gnu_cxx::__promote<_Tp>::__type
1583 sph_bessel(unsigned int __n, _Tp __x)
1585 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1586 return __detail::__sph_bessel<__type>(__n, __x);
1590 sph_legendref(unsigned int __l, unsigned int __m, float __theta)
1591 { return __detail::__sph_legendre<float>(__l, __m, __theta); }
1594 sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
1595 { return __detail::__sph_legendre<long double>(__l, __m, __theta); }
1597 /// 5.2.1.22 Spherical associated Legendre functions.
1598 template<typename _Tp>
1599 inline typename __gnu_cxx::__promote<_Tp>::__type
1600 sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
1602 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1603 return __detail::__sph_legendre<__type>(__l, __m, __theta);
1607 sph_neumannf(unsigned int __n, float __x)
1608 { return __detail::__sph_neumann<float>(__n, __x); }
1611 sph_neumannl(unsigned int __n, long double __x)
1612 { return __detail::__sph_neumann<long double>(__n, __x); }
1614 /// 5.2.1.23 Spherical Neumann functions.
1615 template<typename _Tp>
1616 inline typename __gnu_cxx::__promote<_Tp>::__type
1617 sph_neumann(unsigned int __n, _Tp __x)
1619 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1620 return __detail::__sph_neumann<__type>(__n, __x);
1623 /// @} tr1_math_spec_func
1627_GLIBCXX_END_NAMESPACE_VERSION
1630#endif // _GLIBCXX_USE_STD_SPEC_FUNCS
1632#if _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)
1633namespace std _GLIBCXX_VISIBILITY(default)
1635_GLIBCXX_BEGIN_NAMESPACE_VERSION
1639 using __gnu_cxx::conf_hypergf;
1640 using __gnu_cxx::conf_hypergl;
1641 using __gnu_cxx::conf_hyperg;
1643 using __gnu_cxx::hypergf;
1644 using __gnu_cxx::hypergl;
1645 using __gnu_cxx::hyperg;
1648_GLIBCXX_END_NAMESPACE_VERSION
1651#else // ! (_GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__))
1653#include <bits/stl_algobase.h>
1655#include <tr1/type_traits>
1657#include <tr1/hypergeometric.tcc>
1659namespace std _GLIBCXX_VISIBILITY(default)
1661_GLIBCXX_BEGIN_NAMESPACE_VERSION
1665 /** @addtogroup tr1_math_spec_func
1670 conf_hypergf(float __a, float __c, float __x)
1671 { return __detail::__conf_hyperg<float>(__a, __c, __x); }
1674 conf_hypergl(long double __a, long double __c, long double __x)
1675 { return __detail::__conf_hyperg<long double>(__a, __c, __x); }
1677 /// 5.2.1.7 Confluent hypergeometric functions.
1678 template<typename _Tpa, typename _Tpc, typename _Tp>
1679 inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type
1680 conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
1682 typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type;
1683 return __detail::__conf_hyperg<__type>(__a, __c, __x);
1687 hypergf(float __a, float __b, float __c, float __x)
1688 { return __detail::__hyperg<float>(__a, __b, __c, __x); }
1691 hypergl(long double __a, long double __b, long double __c, long double __x)
1692 { return __detail::__hyperg<long double>(__a, __b, __c, __x); }
1694 /// 5.2.1.17 Hypergeometric functions.
1695 template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
1696 inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type
1697 hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
1699 typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type;
1700 return __detail::__hyperg<__type>(__a, __b, __c, __x);
1703 /// @} tr1_math_spec_func
1707_GLIBCXX_END_NAMESPACE_VERSION
1709#endif // _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)
1711#endif // _GLIBCXX_TR1_CMATH