1// TR1 cmath -*- C++ -*-
3// Copyright (C) 2006-2025 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
33#pragma GCC system_header
36#include <bits/requires_hosted.h> // TR1
40#ifdef _GLIBCXX_USE_C99_MATH_TR1
150namespace std _GLIBCXX_VISIBILITY(default)
152_GLIBCXX_BEGIN_NAMESPACE_VERSION
156#if _GLIBCXX_USE_C99_MATH_TR1
158 // Using declarations to bring names from libc's <math.h> into std::tr1.
307#if _GLIBCXX_USE_C99_MATH
308#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
310 /// Function template definitions [8.16.3].
311 template<typename _Tp>
312 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
316 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
317 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
318 FP_SUBNORMAL, FP_ZERO, __type(__f));
321 template<typename _Tp>
322 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
326 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
327 return __builtin_isfinite(__type(__f));
330 template<typename _Tp>
331 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
335 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
336 return __builtin_isinf(__type(__f));
339 template<typename _Tp>
340 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
344 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
345 return __builtin_isnan(__type(__f));
348 template<typename _Tp>
349 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
353 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
354 return __builtin_isnormal(__type(__f));
357 template<typename _Tp>
358 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
362 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
363 return __builtin_signbit(__type(__f));
366 template<typename _Tp>
367 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
369 isgreater(_Tp __f1, _Tp __f2)
371 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
372 return __builtin_isgreater(__type(__f1), __type(__f2));
375 template<typename _Tp>
376 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
378 isgreaterequal(_Tp __f1, _Tp __f2)
380 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
381 return __builtin_isgreaterequal(__type(__f1), __type(__f2));
384 template<typename _Tp>
385 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
387 isless(_Tp __f1, _Tp __f2)
389 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
390 return __builtin_isless(__type(__f1), __type(__f2));
393 template<typename _Tp>
394 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
396 islessequal(_Tp __f1, _Tp __f2)
398 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
399 return __builtin_islessequal(__type(__f1), __type(__f2));
402 template<typename _Tp>
403 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
405 islessgreater(_Tp __f1, _Tp __f2)
407 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
408 return __builtin_islessgreater(__type(__f1), __type(__f2));
411 template<typename _Tp>
412 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
414 isunordered(_Tp __f1, _Tp __f2)
416 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
417 return __builtin_isunordered(__type(__f1), __type(__f2));
423#if _GLIBCXX_USE_C99_MATH_TR1
425 /** Additional overloads [8.16.4].
429 // For functions defined in C++03 the additional overloads are already
430 // declared in <cmath> so we can just re-declare them in std::tr1.
452#if __cplusplus >= 201103L
454 // Since C++11, <cmath> defines additional overloads for these functions
481 using std::nearbyint;
482 using std::nextafter;
483 using std::nexttoward;
484 using std::remainder;
493#else // __cplusplus < 201103L
495 // In C++03 we need to provide the additional overloads.
497#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
500 { return __builtin_acoshf(__x); }
503 acosh(long double __x)
504 { return __builtin_acoshl(__x); }
507 template<typename _Tp>
508 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
511 { return __builtin_acosh(__x); }
513#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
516 { return __builtin_asinhf(__x); }
519 asinh(long double __x)
520 { return __builtin_asinhl(__x); }
523 template<typename _Tp>
524 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
527 { return __builtin_asinh(__x); }
529#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
532 { return __builtin_atanhf(__x); }
535 atanh(long double __x)
536 { return __builtin_atanhl(__x); }
539 template<typename _Tp>
540 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
543 { return __builtin_atanh(__x); }
545#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
548 { return __builtin_cbrtf(__x); }
551 cbrt(long double __x)
552 { return __builtin_cbrtl(__x); }
555 template<typename _Tp>
556 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
559 { return __builtin_cbrt(__x); }
561#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
563 copysign(float __x, float __y)
564 { return __builtin_copysignf(__x, __y); }
567 copysign(long double __x, long double __y)
568 { return __builtin_copysignl(__x, __y); }
571 template<typename _Tp, typename _Up>
572 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
573 copysign(_Tp __x, _Up __y)
575 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
576 return copysign(__type(__x), __type(__y));
579#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
582 { return __builtin_erff(__x); }
586 { return __builtin_erfl(__x); }
589 template<typename _Tp>
590 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
593 { return __builtin_erf(__x); }
595#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
598 { return __builtin_erfcf(__x); }
601 erfc(long double __x)
602 { return __builtin_erfcl(__x); }
605 template<typename _Tp>
606 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
609 { return __builtin_erfc(__x); }
611#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
614 { return __builtin_exp2f(__x); }
617 exp2(long double __x)
618 { return __builtin_exp2l(__x); }
621 template<typename _Tp>
622 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
625 { return __builtin_exp2(__x); }
627#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
630 { return __builtin_expm1f(__x); }
633 expm1(long double __x)
634 { return __builtin_expm1l(__x); }
637 template<typename _Tp>
638 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
641 { return __builtin_expm1(__x); }
643#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
645 fdim(float __x, float __y)
646 { return __builtin_fdimf(__x, __y); }
649 fdim(long double __x, long double __y)
650 { return __builtin_fdiml(__x, __y); }
653 template<typename _Tp, typename _Up>
654 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
655 fdim(_Tp __x, _Up __y)
657 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
658 return fdim(__type(__x), __type(__y));
661#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
663 fma(float __x, float __y, float __z)
664 { return __builtin_fmaf(__x, __y, __z); }
667 fma(long double __x, long double __y, long double __z)
668 { return __builtin_fmal(__x, __y, __z); }
671 template<typename _Tp, typename _Up, typename _Vp>
672 inline typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
673 fma(_Tp __x, _Up __y, _Vp __z)
675 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
676 return fma(__type(__x), __type(__y), __type(__z));
679#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
681 fmax(float __x, float __y)
682 { return __builtin_fmaxf(__x, __y); }
685 fmax(long double __x, long double __y)
686 { return __builtin_fmaxl(__x, __y); }
689 template<typename _Tp, typename _Up>
690 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
691 fmax(_Tp __x, _Up __y)
693 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
694 return fmax(__type(__x), __type(__y));
697#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
699 fmin(float __x, float __y)
700 { return __builtin_fminf(__x, __y); }
703 fmin(long double __x, long double __y)
704 { return __builtin_fminl(__x, __y); }
707 template<typename _Tp, typename _Up>
708 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
709 fmin(_Tp __x, _Up __y)
711 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
712 return fmin(__type(__x), __type(__y));
715#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
717 hypot(float __x, float __y)
718 { return __builtin_hypotf(__x, __y); }
721 hypot(long double __x, long double __y)
722 { return __builtin_hypotl(__x, __y); }
725 template<typename _Tp, typename _Up>
726 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
727 hypot(_Tp __y, _Up __x)
729 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
730 return hypot(__type(__y), __type(__x));
733#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
736 { return __builtin_ilogbf(__x); }
739 ilogb(long double __x)
740 { return __builtin_ilogbl(__x); }
743 template<typename _Tp>
744 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
747 { return __builtin_ilogb(__x); }
749#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
752 { return __builtin_lgammaf(__x); }
755 lgamma(long double __x)
756 { return __builtin_lgammal(__x); }
759 template<typename _Tp>
760 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
763 { return __builtin_lgamma(__x); }
765#pragma GCC diagnostic push
766#pragma GCC diagnostic ignored "-Wlong-long"
768#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
771 { return __builtin_llrintf(__x); }
774 llrint(long double __x)
775 { return __builtin_llrintl(__x); }
778 template<typename _Tp>
779 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
782 { return __builtin_llrint(__x); }
784#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
787 { return __builtin_llroundf(__x); }
790 llround(long double __x)
791 { return __builtin_llroundl(__x); }
794 template<typename _Tp>
795 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
798 { return __builtin_llround(__x); }
799#pragma GCC diagnostic pop
801#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
804 { return __builtin_log1pf(__x); }
807 log1p(long double __x)
808 { return __builtin_log1pl(__x); }
811 template<typename _Tp>
812 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
815 { return __builtin_log1p(__x); }
818#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
821 { return __builtin_log2f(__x); }
824 log2(long double __x)
825 { return __builtin_log2l(__x); }
828 template<typename _Tp>
829 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
832 { return __builtin_log2(__x); }
834#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
837 { return __builtin_logbf(__x); }
840 logb(long double __x)
841 { return __builtin_logbl(__x); }
844 template<typename _Tp>
845 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
849 return __builtin_logb(__x);
852#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
855 { return __builtin_lrintf(__x); }
858 lrint(long double __x)
859 { return __builtin_lrintl(__x); }
862 template<typename _Tp>
863 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
866 { return __builtin_lrint(__x); }
868#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
871 { return __builtin_lroundf(__x); }
874 lround(long double __x)
875 { return __builtin_lroundl(__x); }
878 template<typename _Tp>
879 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
882 { return __builtin_lround(__x); }
884#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
887 { return __builtin_nearbyintf(__x); }
890 nearbyint(long double __x)
891 { return __builtin_nearbyintl(__x); }
894 template<typename _Tp>
895 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
898 { return __builtin_nearbyint(__x); }
900#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
902 nextafter(float __x, float __y)
903 { return __builtin_nextafterf(__x, __y); }
906 nextafter(long double __x, long double __y)
907 { return __builtin_nextafterl(__x, __y); }
910 template<typename _Tp, typename _Up>
911 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
912 nextafter(_Tp __x, _Up __y)
914 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
915 return nextafter(__type(__x), __type(__y));
918#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
920 nexttoward(float __x, long double __y)
921 { return __builtin_nexttowardf(__x, __y); }
924 nexttoward(long double __x, long double __y)
925 { return __builtin_nexttowardl(__x, __y); }
928 template<typename _Tp>
929 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
931 nexttoward(_Tp __x, long double __y)
932 { return __builtin_nexttoward(__x, __y); }
934#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
936 remainder(float __x, float __y)
937 { return __builtin_remainderf(__x, __y); }
940 remainder(long double __x, long double __y)
941 { return __builtin_remainderl(__x, __y); }
944 template<typename _Tp, typename _Up>
945 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
946 remainder(_Tp __x, _Up __y)
948 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
949 return remainder(__type(__x), __type(__y));
952#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
954 remquo(float __x, float __y, int* __pquo)
955 { return __builtin_remquof(__x, __y, __pquo); }
958 remquo(long double __x, long double __y, int* __pquo)
959 { return __builtin_remquol(__x, __y, __pquo); }
962 template<typename _Tp, typename _Up>
963 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
964 remquo(_Tp __x, _Up __y, int* __pquo)
966 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
967 return remquo(__type(__x), __type(__y), __pquo);
970#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
973 { return __builtin_rintf(__x); }
976 rint(long double __x)
977 { return __builtin_rintl(__x); }
980 template<typename _Tp>
981 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
984 { return __builtin_rint(__x); }
986#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
989 { return __builtin_roundf(__x); }
992 round(long double __x)
993 { return __builtin_roundl(__x); }
996 template<typename _Tp>
997 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1000 { return __builtin_round(__x); }
1002#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1004 scalbln(float __x, long __ex)
1005 { return __builtin_scalblnf(__x, __ex); }
1008 scalbln(long double __x, long __ex)
1009 { return __builtin_scalblnl(__x, __ex); }
1012 template<typename _Tp>
1013 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1015 scalbln(_Tp __x, long __ex)
1016 { return __builtin_scalbln(__x, __ex); }
1018#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1020 scalbn(float __x, int __ex)
1021 { return __builtin_scalbnf(__x, __ex); }
1024 scalbn(long double __x, int __ex)
1025 { return __builtin_scalbnl(__x, __ex); }
1028 template<typename _Tp>
1029 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1031 scalbn(_Tp __x, int __ex)
1032 { return __builtin_scalbn(__x, __ex); }
1034#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1037 { return __builtin_tgammaf(__x); }
1040 tgamma(long double __x)
1041 { return __builtin_tgammal(__x); }
1044 template<typename _Tp>
1045 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1048 { return __builtin_tgamma(__x); }
1050#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1053 { return __builtin_truncf(__x); }
1056 trunc(long double __x)
1057 { return __builtin_truncl(__x); }
1060 template<typename _Tp>
1061 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1064 { return __builtin_trunc(__x); }
1066#endif // __cplusplus < 201103L
1070#endif /* _GLIBCXX_USE_C99_MATH_TR1 */
1072 // DR 550. What should the return type of pow(float,int) be?
1073 // NB: C++11 and TR1 != C++03.
1075 // We cannot do "using std::pow;" because that would bring in unwanted
1076 // pow(*, int) overloads in C++03, with the wrong return type. Instead we
1077 // define all the necessary overloads, but the std::tr1::pow(double, double)
1078 // overload cannot be provided here, because <tr1/math.h> would add it to
1079 // the global namespace where it would clash with ::pow(double,double) from
1080 // libc (revealed by the fix of PR c++/54537).
1081 // The solution is to forward std::tr1::pow(double,double) to
1082 // std::pow(double,double) via the function template below. See
1083 // the discussion about this issue here:
1084 // http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01278.html
1086#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1088 pow(float __x, float __y)
1089 { return std::pow(__x, __y); }
1092 pow(long double __x, long double __y)
1093 { return std::pow(__x, __y); }
1096 template<typename _Tp, typename _Up>
1097 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1098 pow(_Tp __x, _Up __y)
1100 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1101 return std::pow(__type(__x), __type(__y));
1104#if __cplusplus >= 201103L
1105 // We also deal with fabs in a special way, because "using std::fabs;"
1106 // could bring in C++11's std::fabs<T>(const std::complex<T>&) with a
1107 // different return type from std::tr1::fabs<T>(const std::complex<T>&).
1108 // We define the necessary overloads, except std::tr1::fabs(double) which
1109 // could clash with ::fabs(double) from libc.
1110 // The function template handles double as well as integers, forwarding
1113#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
1114#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1117 { return __builtin_fabsf(__x); }
1120 fabs(long double __x)
1121 { return __builtin_fabsl(__x); }
1125 template<typename _Tp>
1126 inline typename __gnu_cxx::__promote<_Tp>::__type
1128 { return std::fabs(__x); }
1132 // For C++03 just use std::fabs as there is no overload for std::complex<>.
1138_GLIBCXX_END_NAMESPACE_VERSION
1142 * @defgroup tr1_math_spec_func TR1 Mathematical Special Functions
1145 * A collection of advanced mathematical special functions.
1148#if _GLIBCXX_USE_STD_SPEC_FUNCS
1150namespace std _GLIBCXX_VISIBILITY(default)
1152_GLIBCXX_BEGIN_NAMESPACE_VERSION
1156 using std::assoc_laguerref;
1157 using std::assoc_laguerrel;
1158 using std::assoc_laguerre;
1160 using std::assoc_legendref;
1161 using std::assoc_legendrel;
1162 using std::assoc_legendre;
1168 using std::comp_ellint_1f;
1169 using std::comp_ellint_1l;
1170 using std::comp_ellint_1;
1172 using std::comp_ellint_2f;
1173 using std::comp_ellint_2l;
1174 using std::comp_ellint_2;
1176 using std::comp_ellint_3f;
1177 using std::comp_ellint_3l;
1178 using std::comp_ellint_3;
1180 using std::cyl_bessel_if;
1181 using std::cyl_bessel_il;
1182 using std::cyl_bessel_i;
1184 using std::cyl_bessel_jf;
1185 using std::cyl_bessel_jl;
1186 using std::cyl_bessel_j;
1188 using std::cyl_bessel_kf;
1189 using std::cyl_bessel_kl;
1190 using std::cyl_bessel_k;
1192 using std::cyl_neumannf;
1193 using std::cyl_neumannl;
1194 using std::cyl_neumann;
1196 using std::ellint_1f;
1197 using std::ellint_1l;
1198 using std::ellint_1;
1200 using std::ellint_2f;
1201 using std::ellint_2l;
1202 using std::ellint_2;
1204 using std::ellint_3f;
1205 using std::ellint_3l;
1206 using std::ellint_3;
1212 using std::hermitef;
1213 using std::hermitel;
1216 using std::laguerref;
1217 using std::laguerrel;
1218 using std::laguerre;
1220 using std::legendref;
1221 using std::legendrel;
1222 using std::legendre;
1224 using std::riemann_zetaf;
1225 using std::riemann_zetal;
1226 using std::riemann_zeta;
1228 using std::sph_besself;
1229 using std::sph_bessell;
1230 using std::sph_bessel;
1232 using std::sph_legendref;
1233 using std::sph_legendrel;
1234 using std::sph_legendre;
1236 using std::sph_neumannf;
1237 using std::sph_neumannl;
1238 using std::sph_neumann;
1241_GLIBCXX_END_NAMESPACE_VERSION
1244#else // ! _GLIBCXX_USE_STD_SPEC_FUNCS
1246#include <bits/stl_algobase.h>
1248#include <tr1/type_traits>
1250#include <tr1/gamma.tcc>
1251#include <tr1/bessel_function.tcc>
1252#include <tr1/beta_function.tcc>
1253#include <tr1/ell_integral.tcc>
1254#include <tr1/exp_integral.tcc>
1255#include <tr1/legendre_function.tcc>
1256#include <tr1/modified_bessel_func.tcc>
1257#include <tr1/poly_hermite.tcc>
1258#include <tr1/poly_laguerre.tcc>
1259#include <tr1/riemann_zeta.tcc>
1261namespace std _GLIBCXX_VISIBILITY(default)
1263_GLIBCXX_BEGIN_NAMESPACE_VERSION
1266 /** @addtogroup tr1_math_spec_func
1271 assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
1272 { return __detail::__assoc_laguerre<float>(__n, __m, __x); }
1275 assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
1277 return __detail::__assoc_laguerre<long double>(__n, __m, __x);
1280 /// 5.2.1.1 Associated Laguerre polynomials.
1281 template<typename _Tp>
1282 inline typename __gnu_cxx::__promote<_Tp>::__type
1283 assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
1285 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1286 return __detail::__assoc_laguerre<__type>(__n, __m, __x);
1290 assoc_legendref(unsigned int __l, unsigned int __m, float __x)
1291 { return __detail::__assoc_legendre_p<float>(__l, __m, __x); }
1294 assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
1295 { return __detail::__assoc_legendre_p<long double>(__l, __m, __x); }
1297 /// 5.2.1.2 Associated Legendre functions.
1298 template<typename _Tp>
1299 inline typename __gnu_cxx::__promote<_Tp>::__type
1300 assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
1302 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1303 return __detail::__assoc_legendre_p<__type>(__l, __m, __x);
1307 betaf(float __x, float __y)
1308 { return __detail::__beta<float>(__x, __y); }
1311 betal(long double __x, long double __y)
1312 { return __detail::__beta<long double>(__x, __y); }
1314 /// 5.2.1.3 Beta functions.
1315 template<typename _Tpx, typename _Tpy>
1316 inline typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type
1317 beta(_Tpx __x, _Tpy __y)
1319 typedef typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type __type;
1320 return __detail::__beta<__type>(__x, __y);
1324 comp_ellint_1f(float __k)
1325 { return __detail::__comp_ellint_1<float>(__k); }
1328 comp_ellint_1l(long double __k)
1329 { return __detail::__comp_ellint_1<long double>(__k); }
1331 /// 5.2.1.4 Complete elliptic integrals of the first kind.
1332 template<typename _Tp>
1333 inline typename __gnu_cxx::__promote<_Tp>::__type
1334 comp_ellint_1(_Tp __k)
1336 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1337 return __detail::__comp_ellint_1<__type>(__k);
1341 comp_ellint_2f(float __k)
1342 { return __detail::__comp_ellint_2<float>(__k); }
1345 comp_ellint_2l(long double __k)
1346 { return __detail::__comp_ellint_2<long double>(__k); }
1348 /// 5.2.1.5 Complete elliptic integrals of the second kind.
1349 template<typename _Tp>
1350 inline typename __gnu_cxx::__promote<_Tp>::__type
1351 comp_ellint_2(_Tp __k)
1353 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1354 return __detail::__comp_ellint_2<__type>(__k);
1358 comp_ellint_3f(float __k, float __nu)
1359 { return __detail::__comp_ellint_3<float>(__k, __nu); }
1362 comp_ellint_3l(long double __k, long double __nu)
1363 { return __detail::__comp_ellint_3<long double>(__k, __nu); }
1365 /// 5.2.1.6 Complete elliptic integrals of the third kind.
1366 template<typename _Tp, typename _Tpn>
1367 inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type
1368 comp_ellint_3(_Tp __k, _Tpn __nu)
1370 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type;
1371 return __detail::__comp_ellint_3<__type>(__k, __nu);
1375 cyl_bessel_if(float __nu, float __x)
1376 { return __detail::__cyl_bessel_i<float>(__nu, __x); }
1379 cyl_bessel_il(long double __nu, long double __x)
1380 { return __detail::__cyl_bessel_i<long double>(__nu, __x); }
1382 /// 5.2.1.8 Regular modified cylindrical Bessel functions.
1383 template<typename _Tpnu, typename _Tp>
1384 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1385 cyl_bessel_i(_Tpnu __nu, _Tp __x)
1387 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1388 return __detail::__cyl_bessel_i<__type>(__nu, __x);
1392 cyl_bessel_jf(float __nu, float __x)
1393 { return __detail::__cyl_bessel_j<float>(__nu, __x); }
1396 cyl_bessel_jl(long double __nu, long double __x)
1397 { return __detail::__cyl_bessel_j<long double>(__nu, __x); }
1399 /// 5.2.1.9 Cylindrical Bessel functions (of the first kind).
1400 template<typename _Tpnu, typename _Tp>
1401 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1402 cyl_bessel_j(_Tpnu __nu, _Tp __x)
1404 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1405 return __detail::__cyl_bessel_j<__type>(__nu, __x);
1409 cyl_bessel_kf(float __nu, float __x)
1410 { return __detail::__cyl_bessel_k<float>(__nu, __x); }
1413 cyl_bessel_kl(long double __nu, long double __x)
1414 { return __detail::__cyl_bessel_k<long double>(__nu, __x); }
1416 /// 5.2.1.10 Irregular modified cylindrical Bessel functions.
1417 template<typename _Tpnu, typename _Tp>
1418 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1419 cyl_bessel_k(_Tpnu __nu, _Tp __x)
1421 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1422 return __detail::__cyl_bessel_k<__type>(__nu, __x);
1426 cyl_neumannf(float __nu, float __x)
1427 { return __detail::__cyl_neumann_n<float>(__nu, __x); }
1430 cyl_neumannl(long double __nu, long double __x)
1431 { return __detail::__cyl_neumann_n<long double>(__nu, __x); }
1433 /// 5.2.1.11 Cylindrical Neumann functions.
1434 template<typename _Tpnu, typename _Tp>
1435 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1436 cyl_neumann(_Tpnu __nu, _Tp __x)
1438 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1439 return __detail::__cyl_neumann_n<__type>(__nu, __x);
1443 ellint_1f(float __k, float __phi)
1444 { return __detail::__ellint_1<float>(__k, __phi); }
1447 ellint_1l(long double __k, long double __phi)
1448 { return __detail::__ellint_1<long double>(__k, __phi); }
1450 /// 5.2.1.12 Incomplete elliptic integrals of the first kind.
1451 template<typename _Tp, typename _Tpp>
1452 inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
1453 ellint_1(_Tp __k, _Tpp __phi)
1455 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
1456 return __detail::__ellint_1<__type>(__k, __phi);
1460 ellint_2f(float __k, float __phi)
1461 { return __detail::__ellint_2<float>(__k, __phi); }
1464 ellint_2l(long double __k, long double __phi)
1465 { return __detail::__ellint_2<long double>(__k, __phi); }
1467 /// 5.2.1.13 Incomplete elliptic integrals of the second kind.
1468 template<typename _Tp, typename _Tpp>
1469 inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
1470 ellint_2(_Tp __k, _Tpp __phi)
1472 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
1473 return __detail::__ellint_2<__type>(__k, __phi);
1477 ellint_3f(float __k, float __nu, float __phi)
1478 { return __detail::__ellint_3<float>(__k, __nu, __phi); }
1481 ellint_3l(long double __k, long double __nu, long double __phi)
1482 { return __detail::__ellint_3<long double>(__k, __nu, __phi); }
1484 /// 5.2.1.14 Incomplete elliptic integrals of the third kind.
1485 template<typename _Tp, typename _Tpn, typename _Tpp>
1486 inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type
1487 ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
1489 typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type;
1490 return __detail::__ellint_3<__type>(__k, __nu, __phi);
1495 { return __detail::__expint<float>(__x); }
1498 expintl(long double __x)
1499 { return __detail::__expint<long double>(__x); }
1501 /// 5.2.1.15 Exponential integrals.
1502 template<typename _Tp>
1503 inline typename __gnu_cxx::__promote<_Tp>::__type
1506 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1507 return __detail::__expint<__type>(__x);
1511 hermitef(unsigned int __n, float __x)
1512 { return __detail::__poly_hermite<float>(__n, __x); }
1515 hermitel(unsigned int __n, long double __x)
1516 { return __detail::__poly_hermite<long double>(__n, __x); }
1518 /// 5.2.1.16 Hermite polynomials.
1519 template<typename _Tp>
1520 inline typename __gnu_cxx::__promote<_Tp>::__type
1521 hermite(unsigned int __n, _Tp __x)
1523 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1524 return __detail::__poly_hermite<__type>(__n, __x);
1528 laguerref(unsigned int __n, float __x)
1529 { return __detail::__laguerre<float>(__n, __x); }
1532 laguerrel(unsigned int __n, long double __x)
1533 { return __detail::__laguerre<long double>(__n, __x); }
1535 /// 5.2.1.18 Laguerre polynomials.
1536 template<typename _Tp>
1537 inline typename __gnu_cxx::__promote<_Tp>::__type
1538 laguerre(unsigned int __n, _Tp __x)
1540 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1541 return __detail::__laguerre<__type>(__n, __x);
1545 legendref(unsigned int __n, float __x)
1546 { return __detail::__poly_legendre_p<float>(__n, __x); }
1549 legendrel(unsigned int __n, long double __x)
1550 { return __detail::__poly_legendre_p<long double>(__n, __x); }
1552 /// 5.2.1.19 Legendre polynomials.
1553 template<typename _Tp>
1554 inline typename __gnu_cxx::__promote<_Tp>::__type
1555 legendre(unsigned int __n, _Tp __x)
1557 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1558 return __detail::__poly_legendre_p<__type>(__n, __x);
1562 riemann_zetaf(float __x)
1563 { return __detail::__riemann_zeta<float>(__x); }
1566 riemann_zetal(long double __x)
1567 { return __detail::__riemann_zeta<long double>(__x); }
1569 /// 5.2.1.20 Riemann zeta function.
1570 template<typename _Tp>
1571 inline typename __gnu_cxx::__promote<_Tp>::__type
1572 riemann_zeta(_Tp __x)
1574 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1575 return __detail::__riemann_zeta<__type>(__x);
1579 sph_besself(unsigned int __n, float __x)
1580 { return __detail::__sph_bessel<float>(__n, __x); }
1583 sph_bessell(unsigned int __n, long double __x)
1584 { return __detail::__sph_bessel<long double>(__n, __x); }
1586 /// 5.2.1.21 Spherical Bessel functions.
1587 template<typename _Tp>
1588 inline typename __gnu_cxx::__promote<_Tp>::__type
1589 sph_bessel(unsigned int __n, _Tp __x)
1591 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1592 return __detail::__sph_bessel<__type>(__n, __x);
1596 sph_legendref(unsigned int __l, unsigned int __m, float __theta)
1597 { return __detail::__sph_legendre<float>(__l, __m, __theta); }
1600 sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
1601 { return __detail::__sph_legendre<long double>(__l, __m, __theta); }
1603 /// 5.2.1.22 Spherical associated Legendre functions.
1604 template<typename _Tp>
1605 inline typename __gnu_cxx::__promote<_Tp>::__type
1606 sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
1608 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1609 return __detail::__sph_legendre<__type>(__l, __m, __theta);
1613 sph_neumannf(unsigned int __n, float __x)
1614 { return __detail::__sph_neumann<float>(__n, __x); }
1617 sph_neumannl(unsigned int __n, long double __x)
1618 { return __detail::__sph_neumann<long double>(__n, __x); }
1620 /// 5.2.1.23 Spherical Neumann functions.
1621 template<typename _Tp>
1622 inline typename __gnu_cxx::__promote<_Tp>::__type
1623 sph_neumann(unsigned int __n, _Tp __x)
1625 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1626 return __detail::__sph_neumann<__type>(__n, __x);
1629 /// @} tr1_math_spec_func
1633_GLIBCXX_END_NAMESPACE_VERSION
1636#endif // _GLIBCXX_USE_STD_SPEC_FUNCS
1638#if _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)
1639namespace std _GLIBCXX_VISIBILITY(default)
1641_GLIBCXX_BEGIN_NAMESPACE_VERSION
1645 using __gnu_cxx::conf_hypergf;
1646 using __gnu_cxx::conf_hypergl;
1647 using __gnu_cxx::conf_hyperg;
1649 using __gnu_cxx::hypergf;
1650 using __gnu_cxx::hypergl;
1651 using __gnu_cxx::hyperg;
1654_GLIBCXX_END_NAMESPACE_VERSION
1657#else // ! (_GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__))
1659#include <bits/stl_algobase.h>
1661#include <tr1/type_traits>
1663#include <tr1/hypergeometric.tcc>
1665namespace std _GLIBCXX_VISIBILITY(default)
1667_GLIBCXX_BEGIN_NAMESPACE_VERSION
1671 /** @addtogroup tr1_math_spec_func
1676 conf_hypergf(float __a, float __c, float __x)
1677 { return __detail::__conf_hyperg<float>(__a, __c, __x); }
1680 conf_hypergl(long double __a, long double __c, long double __x)
1681 { return __detail::__conf_hyperg<long double>(__a, __c, __x); }
1683 /// 5.2.1.7 Confluent hypergeometric functions.
1684 template<typename _Tpa, typename _Tpc, typename _Tp>
1685 inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type
1686 conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
1688 typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type;
1689 return __detail::__conf_hyperg<__type>(__a, __c, __x);
1693 hypergf(float __a, float __b, float __c, float __x)
1694 { return __detail::__hyperg<float>(__a, __b, __c, __x); }
1697 hypergl(long double __a, long double __b, long double __c, long double __x)
1698 { return __detail::__hyperg<long double>(__a, __b, __c, __x); }
1700 /// 5.2.1.17 Hypergeometric functions.
1701 template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
1702 inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type
1703 hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
1705 typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type;
1706 return __detail::__hyperg<__type>(__a, __b, __c, __x);
1709 /// @} tr1_math_spec_func
1713_GLIBCXX_END_NAMESPACE_VERSION
1715#endif // _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)
1717#endif // _GLIBCXX_TR1_CMATH