46 #ifndef _GLIBCXX_TR1_EXP_INTEGRAL_TCC
47 #define _GLIBCXX_TR1_EXP_INTEGRAL_TCC 1
75 template<
typename _Tp>
83 const unsigned int __max_iter = 100;
84 for (
unsigned int __i = 1; __i < __max_iter; ++__i)
86 __term *= - __x / __i;
90 __esum += __term / __i;
92 __osum += __term / __i;
95 return - __esum - __osum
112 template<
typename _Tp>
119 const unsigned int __max_iter = 1000;
120 for (
unsigned int __i = 1; __i < __max_iter; ++__i)
123 __term *= - __i / __x;
126 if (__term >= _Tp(0))
132 return std::exp(- __x) * (__esum + __osum) / __x;
149 template<
typename _Tp>
153 const unsigned int __max_iter = 100;
155 const int __nm1 = __n - 1;
156 _Tp __ans = (__nm1 != 0
160 for (
int __i = 1; __i <= __max_iter; ++__i)
162 __fact *= -__x / _Tp(__i);
165 __del = -__fact / _Tp(__i - __nm1);
168 _Tp
__psi = -_TR1_GAMMA_TCC;
169 for (
int __ii = 1; __ii <= __nm1; ++__ii)
170 __psi += _Tp(1) / _Tp(__ii);
171 __del = __fact * (__psi -
std::log(__x));
177 std::__throw_runtime_error(__N(
"Series summation failed "
178 "in __expint_En_series."));
195 template<
typename _Tp>
199 const unsigned int __max_iter = 100;
202 const int __nm1 = __n - 1;
203 _Tp __b = __x + _Tp(__n);
204 _Tp __c = _Tp(1) / __fp_min;
205 _Tp __d = _Tp(1) / __b;
207 for (
unsigned int __i = 1; __i <= __max_iter; ++__i )
209 _Tp __a = -_Tp(__i * (__nm1 + __i));
211 __d = _Tp(1) / (__a * __d + __b);
212 __c = __b + __a / __c;
213 const _Tp __del = __c * __d;
215 if (
std::abs(__del - _Tp(1)) < __eps)
217 const _Tp __ans = __h *
std::exp(-__x);
221 std::__throw_runtime_error(__N(
"Continued fraction failed "
222 "in __expint_En_cont_frac."));
240 template<
typename _Tp>
250 for (
unsigned int __j = 2; __j < __n; ++__j)
251 __En = (
std::exp(-__x) - __x * __En) / _Tp(__j - 1);
257 const int __N = __n + 20;
259 for (
int __j = __N; __j > 0; --__j)
261 __En = (
std::exp(-__x) - __j * __En) / __x;
265 _Tp __norm = __En / __E1;
284 template<
typename _Tp>
290 const unsigned int __max_iter = 1000;
291 for (
unsigned int __i = 1; __i < __max_iter; ++__i)
294 __sum += __term / __i;
315 template<
typename _Tp>
321 const unsigned int __max_iter = 1000;
322 for (
unsigned int __i = 1; __i < __max_iter; ++__i)
328 if (__term >= __prev)
348 template<
typename _Tp>
372 template<
typename _Tp>
378 else if (__x < _Tp(1))
380 else if (__x < _Tp(100))
402 template<
typename _Tp>
408 for (
unsigned int __i = 1; __i <= __n; ++__i)
411 __term *= -(__n - __i + 1) / __x;
417 return std::exp(-__x) * __sum / __x;
436 template<
typename _Tp>
440 const _Tp __xpn = __x + __n;
441 const _Tp __xpn2 = __xpn * __xpn;
444 for (
unsigned int __i = 1; __i <= __n; ++__i)
447 __term *= (__n - 2 * (__i - 1) * __x) / __xpn2;
453 return std::exp(-__x) * __sum / __xpn;
470 template<
typename _Tp>
477 else if (__n <= 1 && __x == _Tp(0))
490 return _Tp(1) /
static_cast<_Tp
>(__n - 1);
510 template<
typename _Tp>
524 #endif // _GLIBCXX_TR1_EXP_INTEGRAL_TCC
_Tp __expint(const unsigned int __n, const _Tp __x)
Return the exponential integral .
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
static _Tp __gamma_e()
Constant Euler's constant .
_Tp __expint_En_cont_frac(const unsigned int __n, const _Tp __x)
Return the exponential integral by continued fractions.
_Tp __expint_En_series(const unsigned int __n, const _Tp __x)
Return the exponential integral by series summation.
_Tp __expint_E1_series(const _Tp __x)
Return the exponential integral by series summation. This should be good for .
Properties of fundamental types.
_Tp __psi(const _Tp __x)
Return the digamma function. The digamma or function is defined by For negative argument the reflec...
_Tp __expint_En_recursion(const unsigned int __n, const _Tp __x)
Return the exponential integral by recursion. Use upward recursion for and downward recursion (Mill...
_Tp __expint_large_n(const unsigned int __n, const _Tp __x)
Return the exponential integral for large order.
_Tp __expint_E1_asymp(const _Tp __x)
Return the exponential integral by asymptotic expansion.
_Tp __expint_asymp(const unsigned int __n, const _Tp __x)
Return the exponential integral for large argument.
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
_Tp __expint_Ei_asymp(const _Tp __x)
Return the exponential integral by asymptotic expansion.
_Tp __expint_Ei_series(const _Tp __x)
Return the exponential integral by series summation.
_Tp __expint_E1(const _Tp __x)
Return the exponential integral .
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
_Tp __expint_Ei(const _Tp __x)
Return the exponential integral .