diff options
Diffstat (limited to 'gcc-4.4.3/libstdc++-v3/include/tr1')
57 files changed, 9404 insertions, 0 deletions
diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/array b/gcc-4.4.3/libstdc++-v3/include/tr1/array new file mode 100644 index 000000000..17cf5d290 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/array @@ -0,0 +1,54 @@ +// class template array -*- C++ -*- + +// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/array + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_ARRAY +#define _GLIBCXX_TR1_ARRAY 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <bits/stl_algobase.h> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/array> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/array> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_ARRAY diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/bessel_function.tcc b/gcc-4.4.3/libstdc++-v3/include/tr1/bessel_function.tcc new file mode 100644 index 000000000..25102151b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/bessel_function.tcc @@ -0,0 +1,627 @@ +// Special functions -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/bessel_function.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +// +// ISO C++ 14882 TR1: 5.2 Special functions +// + +// Written by Edward Smith-Rowland. +// +// References: +// (1) Handbook of Mathematical Functions, +// ed. Milton Abramowitz and Irene A. Stegun, +// Dover Publications, +// Section 9, pp. 355-434, Section 10 pp. 435-478 +// (2) The Gnu Scientific Library, http://www.gnu.org/software/gsl +// (3) Numerical Recipes in C, by W. H. Press, S. A. Teukolsky, +// W. T. Vetterling, B. P. Flannery, Cambridge University Press (1992), +// 2nd ed, pp. 240-245 + +#ifndef _GLIBCXX_TR1_BESSEL_FUNCTION_TCC +#define _GLIBCXX_TR1_BESSEL_FUNCTION_TCC 1 + +#include "special_function_util.h" + +namespace std +{ +namespace tr1 +{ + + // [5.2] Special functions + + // Implementation-space details. + namespace __detail + { + + /** + * @brief Compute the gamma functions required by the Temme series + * expansions of @f$ N_\nu(x) @f$ and @f$ K_\nu(x) @f$. + * @f[ + * \Gamma_1 = \frac{1}{2\mu} + * [\frac{1}{\Gamma(1 - \mu)} - \frac{1}{\Gamma(1 + \mu)}] + * @f] + * and + * @f[ + * \Gamma_2 = \frac{1}{2} + * [\frac{1}{\Gamma(1 - \mu)} + \frac{1}{\Gamma(1 + \mu)}] + * @f] + * where @f$ -1/2 <= \mu <= 1/2 @f$ is @f$ \mu = \nu - N @f$ and @f$ N @f$. + * is the nearest integer to @f$ \nu @f$. + * The values of \f$ \Gamma(1 + \mu) \f$ and \f$ \Gamma(1 - \mu) \f$ + * are returned as well. + * + * The accuracy requirements on this are exquisite. + * + * @param __mu The input parameter of the gamma functions. + * @param __gam1 The output function \f$ \Gamma_1(\mu) \f$ + * @param __gam2 The output function \f$ \Gamma_2(\mu) \f$ + * @param __gampl The output function \f$ \Gamma(1 + \mu) \f$ + * @param __gammi The output function \f$ \Gamma(1 - \mu) \f$ + */ + template <typename _Tp> + void + __gamma_temme(const _Tp __mu, + _Tp & __gam1, _Tp & __gam2, _Tp & __gampl, _Tp & __gammi) + { +#if _GLIBCXX_USE_C99_MATH_TR1 + __gampl = _Tp(1) / std::tr1::tgamma(_Tp(1) + __mu); + __gammi = _Tp(1) / std::tr1::tgamma(_Tp(1) - __mu); +#else + __gampl = _Tp(1) / __gamma(_Tp(1) + __mu); + __gammi = _Tp(1) / __gamma(_Tp(1) - __mu); +#endif + + if (std::abs(__mu) < std::numeric_limits<_Tp>::epsilon()) + __gam1 = -_Tp(__numeric_constants<_Tp>::__gamma_e()); + else + __gam1 = (__gammi - __gampl) / (_Tp(2) * __mu); + + __gam2 = (__gammi + __gampl) / (_Tp(2)); + + return; + } + + + /** + * @brief Compute the Bessel @f$ J_\nu(x) @f$ and Neumann + * @f$ N_\nu(x) @f$ functions and their first derivatives + * @f$ J'_\nu(x) @f$ and @f$ N'_\nu(x) @f$ respectively. + * These four functions are computed together for numerical + * stability. + * + * @param __nu The order of the Bessel functions. + * @param __x The argument of the Bessel functions. + * @param __Jnu The output Bessel function of the first kind. + * @param __Nnu The output Neumann function (Bessel function of the second kind). + * @param __Jpnu The output derivative of the Bessel function of the first kind. + * @param __Npnu The output derivative of the Neumann function. + */ + template <typename _Tp> + void + __bessel_jn(const _Tp __nu, const _Tp __x, + _Tp & __Jnu, _Tp & __Nnu, _Tp & __Jpnu, _Tp & __Npnu) + { + if (__x == _Tp(0)) + { + if (__nu == _Tp(0)) + { + __Jnu = _Tp(1); + __Jpnu = _Tp(0); + } + else if (__nu == _Tp(1)) + { + __Jnu = _Tp(0); + __Jpnu = _Tp(0.5L); + } + else + { + __Jnu = _Tp(0); + __Jpnu = _Tp(0); + } + __Nnu = -std::numeric_limits<_Tp>::infinity(); + __Npnu = std::numeric_limits<_Tp>::infinity(); + return; + } + + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + // When the multiplier is N i.e. + // fp_min = N * min() + // Then J_0 and N_0 tank at x = 8 * N (J_0 = 0 and N_0 = nan)! + //const _Tp __fp_min = _Tp(20) * std::numeric_limits<_Tp>::min(); + const _Tp __fp_min = std::sqrt(std::numeric_limits<_Tp>::min()); + const int __max_iter = 15000; + const _Tp __x_min = _Tp(2); + + const int __nl = (__x < __x_min + ? static_cast<int>(__nu + _Tp(0.5L)) + : std::max(0, static_cast<int>(__nu - __x + _Tp(1.5L)))); + + const _Tp __mu = __nu - __nl; + const _Tp __mu2 = __mu * __mu; + const _Tp __xi = _Tp(1) / __x; + const _Tp __xi2 = _Tp(2) * __xi; + _Tp __w = __xi2 / __numeric_constants<_Tp>::__pi(); + int __isign = 1; + _Tp __h = __nu * __xi; + if (__h < __fp_min) + __h = __fp_min; + _Tp __b = __xi2 * __nu; + _Tp __d = _Tp(0); + _Tp __c = __h; + int __i; + for (__i = 1; __i <= __max_iter; ++__i) + { + __b += __xi2; + __d = __b - __d; + if (std::abs(__d) < __fp_min) + __d = __fp_min; + __c = __b - _Tp(1) / __c; + if (std::abs(__c) < __fp_min) + __c = __fp_min; + __d = _Tp(1) / __d; + const _Tp __del = __c * __d; + __h *= __del; + if (__d < _Tp(0)) + __isign = -__isign; + if (std::abs(__del - _Tp(1)) < __eps) + break; + } + if (__i > __max_iter) + std::__throw_runtime_error(__N("Argument x too large in __bessel_jn; " + "try asymptotic expansion.")); + _Tp __Jnul = __isign * __fp_min; + _Tp __Jpnul = __h * __Jnul; + _Tp __Jnul1 = __Jnul; + _Tp __Jpnu1 = __Jpnul; + _Tp __fact = __nu * __xi; + for ( int __l = __nl; __l >= 1; --__l ) + { + const _Tp __Jnutemp = __fact * __Jnul + __Jpnul; + __fact -= __xi; + __Jpnul = __fact * __Jnutemp - __Jnul; + __Jnul = __Jnutemp; + } + if (__Jnul == _Tp(0)) + __Jnul = __eps; + _Tp __f= __Jpnul / __Jnul; + _Tp __Nmu, __Nnu1, __Npmu, __Jmu; + if (__x < __x_min) + { + const _Tp __x2 = __x / _Tp(2); + const _Tp __pimu = __numeric_constants<_Tp>::__pi() * __mu; + _Tp __fact = (std::abs(__pimu) < __eps + ? _Tp(1) : __pimu / std::sin(__pimu)); + _Tp __d = -std::log(__x2); + _Tp __e = __mu * __d; + _Tp __fact2 = (std::abs(__e) < __eps + ? _Tp(1) : std::sinh(__e) / __e); + _Tp __gam1, __gam2, __gampl, __gammi; + __gamma_temme(__mu, __gam1, __gam2, __gampl, __gammi); + _Tp __ff = (_Tp(2) / __numeric_constants<_Tp>::__pi()) + * __fact * (__gam1 * std::cosh(__e) + __gam2 * __fact2 * __d); + __e = std::exp(__e); + _Tp __p = __e / (__numeric_constants<_Tp>::__pi() * __gampl); + _Tp __q = _Tp(1) / (__e * __numeric_constants<_Tp>::__pi() * __gammi); + const _Tp __pimu2 = __pimu / _Tp(2); + _Tp __fact3 = (std::abs(__pimu2) < __eps + ? _Tp(1) : std::sin(__pimu2) / __pimu2 ); + _Tp __r = __numeric_constants<_Tp>::__pi() * __pimu2 * __fact3 * __fact3; + _Tp __c = _Tp(1); + __d = -__x2 * __x2; + _Tp __sum = __ff + __r * __q; + _Tp __sum1 = __p; + for (__i = 1; __i <= __max_iter; ++__i) + { + __ff = (__i * __ff + __p + __q) / (__i * __i - __mu2); + __c *= __d / _Tp(__i); + __p /= _Tp(__i) - __mu; + __q /= _Tp(__i) + __mu; + const _Tp __del = __c * (__ff + __r * __q); + __sum += __del; + const _Tp __del1 = __c * __p - __i * __del; + __sum1 += __del1; + if ( std::abs(__del) < __eps * (_Tp(1) + std::abs(__sum)) ) + break; + } + if ( __i > __max_iter ) + std::__throw_runtime_error(__N("Bessel y series failed to converge " + "in __bessel_jn.")); + __Nmu = -__sum; + __Nnu1 = -__sum1 * __xi2; + __Npmu = __mu * __xi * __Nmu - __Nnu1; + __Jmu = __w / (__Npmu - __f * __Nmu); + } + else + { + _Tp __a = _Tp(0.25L) - __mu2; + _Tp __q = _Tp(1); + _Tp __p = -__xi / _Tp(2); + _Tp __br = _Tp(2) * __x; + _Tp __bi = _Tp(2); + _Tp __fact = __a * __xi / (__p * __p + __q * __q); + _Tp __cr = __br + __q * __fact; + _Tp __ci = __bi + __p * __fact; + _Tp __den = __br * __br + __bi * __bi; + _Tp __dr = __br / __den; + _Tp __di = -__bi / __den; + _Tp __dlr = __cr * __dr - __ci * __di; + _Tp __dli = __cr * __di + __ci * __dr; + _Tp __temp = __p * __dlr - __q * __dli; + __q = __p * __dli + __q * __dlr; + __p = __temp; + int __i; + for (__i = 2; __i <= __max_iter; ++__i) + { + __a += _Tp(2 * (__i - 1)); + __bi += _Tp(2); + __dr = __a * __dr + __br; + __di = __a * __di + __bi; + if (std::abs(__dr) + std::abs(__di) < __fp_min) + __dr = __fp_min; + __fact = __a / (__cr * __cr + __ci * __ci); + __cr = __br + __cr * __fact; + __ci = __bi - __ci * __fact; + if (std::abs(__cr) + std::abs(__ci) < __fp_min) + __cr = __fp_min; + __den = __dr * __dr + __di * __di; + __dr /= __den; + __di /= -__den; + __dlr = __cr * __dr - __ci * __di; + __dli = __cr * __di + __ci * __dr; + __temp = __p * __dlr - __q * __dli; + __q = __p * __dli + __q * __dlr; + __p = __temp; + if (std::abs(__dlr - _Tp(1)) + std::abs(__dli) < __eps) + break; + } + if (__i > __max_iter) + std::__throw_runtime_error(__N("Lentz's method failed " + "in __bessel_jn.")); + const _Tp __gam = (__p - __f) / __q; + __Jmu = std::sqrt(__w / ((__p - __f) * __gam + __q)); +#if _GLIBCXX_USE_C99_MATH_TR1 + __Jmu = std::tr1::copysign(__Jmu, __Jnul); +#else + if (__Jmu * __Jnul < _Tp(0)) + __Jmu = -__Jmu; +#endif + __Nmu = __gam * __Jmu; + __Npmu = (__p + __q / __gam) * __Nmu; + __Nnu1 = __mu * __xi * __Nmu - __Npmu; + } + __fact = __Jmu / __Jnul; + __Jnu = __fact * __Jnul1; + __Jpnu = __fact * __Jpnu1; + for (__i = 1; __i <= __nl; ++__i) + { + const _Tp __Nnutemp = (__mu + __i) * __xi2 * __Nnu1 - __Nmu; + __Nmu = __Nnu1; + __Nnu1 = __Nnutemp; + } + __Nnu = __Nmu; + __Npnu = __nu * __xi * __Nmu - __Nnu1; + + return; + } + + + /** + * @brief This routine computes the asymptotic cylindrical Bessel + * and Neumann functions of order nu: \f$ J_{\nu} \f$, + * \f$ N_{\nu} \f$. + * + * References: + * (1) Handbook of Mathematical Functions, + * ed. Milton Abramowitz and Irene A. Stegun, + * Dover Publications, + * Section 9 p. 364, Equations 9.2.5-9.2.10 + * + * @param __nu The order of the Bessel functions. + * @param __x The argument of the Bessel functions. + * @param __Jnu The output Bessel function of the first kind. + * @param __Nnu The output Neumann function (Bessel function of the second kind). + */ + template <typename _Tp> + void + __cyl_bessel_jn_asymp(const _Tp __nu, const _Tp __x, + _Tp & __Jnu, _Tp & __Nnu) + { + const _Tp __coef = std::sqrt(_Tp(2) + / (__numeric_constants<_Tp>::__pi() * __x)); + const _Tp __mu = _Tp(4) * __nu * __nu; + const _Tp __mum1 = __mu - _Tp(1); + const _Tp __mum9 = __mu - _Tp(9); + const _Tp __mum25 = __mu - _Tp(25); + const _Tp __mum49 = __mu - _Tp(49); + const _Tp __xx = _Tp(64) * __x * __x; + const _Tp __P = _Tp(1) - __mum1 * __mum9 / (_Tp(2) * __xx) + * (_Tp(1) - __mum25 * __mum49 / (_Tp(12) * __xx)); + const _Tp __Q = __mum1 / (_Tp(8) * __x) + * (_Tp(1) - __mum9 * __mum25 / (_Tp(6) * __xx)); + + const _Tp __chi = __x - (__nu + _Tp(0.5L)) + * __numeric_constants<_Tp>::__pi_2(); + const _Tp __c = std::cos(__chi); + const _Tp __s = std::sin(__chi); + + __Jnu = __coef * (__c * __P - __s * __Q); + __Nnu = __coef * (__s * __P + __c * __Q); + + return; + } + + + /** + * @brief This routine returns the cylindrical Bessel functions + * of order \f$ \nu \f$: \f$ J_{\nu} \f$ or \f$ I_{\nu} \f$ + * by series expansion. + * + * The modified cylindrical Bessel function is: + * @f[ + * Z_{\nu}(x) = \sum_{k=0}^{\infty} + * \frac{\sigma^k (x/2)^{\nu + 2k}}{k!\Gamma(\nu+k+1)} + * @f] + * where \f$ \sigma = +1 \f$ or\f$ -1 \f$ for + * \f$ Z = I \f$ or \f$ J \f$ respectively. + * + * See Abramowitz & Stegun, 9.1.10 + * Abramowitz & Stegun, 9.6.7 + * (1) Handbook of Mathematical Functions, + * ed. Milton Abramowitz and Irene A. Stegun, + * Dover Publications, + * Equation 9.1.10 p. 360 and Equation 9.6.10 p. 375 + * + * @param __nu The order of the Bessel function. + * @param __x The argument of the Bessel function. + * @param __sgn The sign of the alternate terms + * -1 for the Bessel function of the first kind. + * +1 for the modified Bessel function of the first kind. + * @return The output Bessel function. + */ + template <typename _Tp> + _Tp + __cyl_bessel_ij_series(const _Tp __nu, const _Tp __x, const _Tp __sgn, + const unsigned int __max_iter) + { + + const _Tp __x2 = __x / _Tp(2); + _Tp __fact = __nu * std::log(__x2); +#if _GLIBCXX_USE_C99_MATH_TR1 + __fact -= std::tr1::lgamma(__nu + _Tp(1)); +#else + __fact -= __log_gamma(__nu + _Tp(1)); +#endif + __fact = std::exp(__fact); + const _Tp __xx4 = __sgn * __x2 * __x2; + _Tp __Jn = _Tp(1); + _Tp __term = _Tp(1); + + for (unsigned int __i = 1; __i < __max_iter; ++__i) + { + __term *= __xx4 / (_Tp(__i) * (__nu + _Tp(__i))); + __Jn += __term; + if (std::abs(__term / __Jn) < std::numeric_limits<_Tp>::epsilon()) + break; + } + + return __fact * __Jn; + } + + + /** + * @brief Return the Bessel function of order \f$ \nu \f$: + * \f$ J_{\nu}(x) \f$. + * + * The cylindrical Bessel function is: + * @f[ + * J_{\nu}(x) = \sum_{k=0}^{\infty} + * \frac{(-1)^k (x/2)^{\nu + 2k}}{k!\Gamma(\nu+k+1)} + * @f] + * + * @param __nu The order of the Bessel function. + * @param __x The argument of the Bessel function. + * @return The output Bessel function. + */ + template<typename _Tp> + _Tp + __cyl_bessel_j(const _Tp __nu, const _Tp __x) + { + if (__nu < _Tp(0) || __x < _Tp(0)) + std::__throw_domain_error(__N("Bad argument " + "in __cyl_bessel_j.")); + else if (__isnan(__nu) || __isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__x * __x < _Tp(10) * (__nu + _Tp(1))) + return __cyl_bessel_ij_series(__nu, __x, -_Tp(1), 200); + else if (__x > _Tp(1000)) + { + _Tp __J_nu, __N_nu; + __cyl_bessel_jn_asymp(__nu, __x, __J_nu, __N_nu); + return __J_nu; + } + else + { + _Tp __J_nu, __N_nu, __Jp_nu, __Np_nu; + __bessel_jn(__nu, __x, __J_nu, __N_nu, __Jp_nu, __Np_nu); + return __J_nu; + } + } + + + /** + * @brief Return the Neumann function of order \f$ \nu \f$: + * \f$ N_{\nu}(x) \f$. + * + * The Neumann function is defined by: + * @f[ + * N_{\nu}(x) = \frac{J_{\nu}(x) \cos \nu\pi - J_{-\nu}(x)} + * {\sin \nu\pi} + * @f] + * where for integral \f$ \nu = n \f$ a limit is taken: + * \f$ lim_{\nu \to n} \f$. + * + * @param __nu The order of the Neumann function. + * @param __x The argument of the Neumann function. + * @return The output Neumann function. + */ + template<typename _Tp> + _Tp + __cyl_neumann_n(const _Tp __nu, const _Tp __x) + { + if (__nu < _Tp(0) || __x < _Tp(0)) + std::__throw_domain_error(__N("Bad argument " + "in __cyl_neumann_n.")); + else if (__isnan(__nu) || __isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__x > _Tp(1000)) + { + _Tp __J_nu, __N_nu; + __cyl_bessel_jn_asymp(__nu, __x, __J_nu, __N_nu); + return __N_nu; + } + else + { + _Tp __J_nu, __N_nu, __Jp_nu, __Np_nu; + __bessel_jn(__nu, __x, __J_nu, __N_nu, __Jp_nu, __Np_nu); + return __N_nu; + } + } + + + /** + * @brief Compute the spherical Bessel @f$ j_n(x) @f$ + * and Neumann @f$ n_n(x) @f$ functions and their first + * derivatives @f$ j'_n(x) @f$ and @f$ n'_n(x) @f$ + * respectively. + * + * @param __n The order of the spherical Bessel function. + * @param __x The argument of the spherical Bessel function. + * @param __j_n The output spherical Bessel function. + * @param __n_n The output spherical Neumann function. + * @param __jp_n The output derivative of the spherical Bessel function. + * @param __np_n The output derivative of the spherical Neumann function. + */ + template <typename _Tp> + void + __sph_bessel_jn(const unsigned int __n, const _Tp __x, + _Tp & __j_n, _Tp & __n_n, _Tp & __jp_n, _Tp & __np_n) + { + const _Tp __nu = _Tp(__n) + _Tp(0.5L); + + _Tp __J_nu, __N_nu, __Jp_nu, __Np_nu; + __bessel_jn(__nu, __x, __J_nu, __N_nu, __Jp_nu, __Np_nu); + + const _Tp __factor = __numeric_constants<_Tp>::__sqrtpio2() + / std::sqrt(__x); + + __j_n = __factor * __J_nu; + __n_n = __factor * __N_nu; + __jp_n = __factor * __Jp_nu - __j_n / (_Tp(2) * __x); + __np_n = __factor * __Np_nu - __n_n / (_Tp(2) * __x); + + return; + } + + + /** + * @brief Return the spherical Bessel function + * @f$ j_n(x) @f$ of order n. + * + * The spherical Bessel function is defined by: + * @f[ + * j_n(x) = \left( \frac{\pi}{2x} \right) ^{1/2} J_{n+1/2}(x) + * @f] + * + * @param __n The order of the spherical Bessel function. + * @param __x The argument of the spherical Bessel function. + * @return The output spherical Bessel function. + */ + template <typename _Tp> + _Tp + __sph_bessel(const unsigned int __n, const _Tp __x) + { + if (__x < _Tp(0)) + std::__throw_domain_error(__N("Bad argument " + "in __sph_bessel.")); + else if (__isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__x == _Tp(0)) + { + if (__n == 0) + return _Tp(1); + else + return _Tp(0); + } + else + { + _Tp __j_n, __n_n, __jp_n, __np_n; + __sph_bessel_jn(__n, __x, __j_n, __n_n, __jp_n, __np_n); + return __j_n; + } + } + + + /** + * @brief Return the spherical Neumann function + * @f$ n_n(x) @f$. + * + * The spherical Neumann function is defined by: + * @f[ + * n_n(x) = \left( \frac{\pi}{2x} \right) ^{1/2} N_{n+1/2}(x) + * @f] + * + * @param __n The order of the spherical Neumann function. + * @param __x The argument of the spherical Neumann function. + * @return The output spherical Neumann function. + */ + template <typename _Tp> + _Tp + __sph_neumann(const unsigned int __n, const _Tp __x) + { + if (__x < _Tp(0)) + std::__throw_domain_error(__N("Bad argument " + "in __sph_neumann.")); + else if (__isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__x == _Tp(0)) + return -std::numeric_limits<_Tp>::infinity(); + else + { + _Tp __j_n, __n_n, __jp_n, __np_n; + __sph_bessel_jn(__n, __x, __j_n, __n_n, __jp_n, __np_n); + return __n_n; + } + } + + } // namespace std::tr1::__detail +} +} + +#endif // _GLIBCXX_TR1_BESSEL_FUNCTION_TCC diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/beta_function.tcc b/gcc-4.4.3/libstdc++-v3/include/tr1/beta_function.tcc new file mode 100644 index 000000000..f9d18604d --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/beta_function.tcc @@ -0,0 +1,197 @@ +// Special functions -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/beta_function.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +// +// ISO C++ 14882 TR1: 5.2 Special functions +// + +// Written by Edward Smith-Rowland based on: +// (1) Handbook of Mathematical Functions, +// ed. Milton Abramowitz and Irene A. Stegun, +// Dover Publications, +// Section 6, pp. 253-266 +// (2) The Gnu Scientific Library, http://www.gnu.org/software/gsl +// (3) Numerical Recipes in C, by W. H. Press, S. A. Teukolsky, +// W. T. Vetterling, B. P. Flannery, Cambridge University Press (1992), +// 2nd ed, pp. 213-216 +// (4) Gamma, Exploring Euler's Constant, Julian Havil, +// Princeton, 2003. + +#ifndef _GLIBCXX_TR1_BETA_FUNCTION_TCC +#define _GLIBCXX_TR1_BETA_FUNCTION_TCC 1 + +namespace std +{ +namespace tr1 +{ + + // [5.2] Special functions + + // Implementation-space details. + namespace __detail + { + + /** + * @brief Return the beta function: \f$B(x,y)\f$. + * + * The beta function is defined by + * @f[ + * B(x,y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} + * @f] + * + * @param __x The first argument of the beta function. + * @param __y The second argument of the beta function. + * @return The beta function. + */ + template<typename _Tp> + _Tp + __beta_gamma(_Tp __x, _Tp __y) + { + + _Tp __bet; +#if _GLIBCXX_USE_C99_MATH_TR1 + if (__x > __y) + { + __bet = std::tr1::tgamma(__x) + / std::tr1::tgamma(__x + __y); + __bet *= std::tr1::tgamma(__y); + } + else + { + __bet = std::tr1::tgamma(__y) + / std::tr1::tgamma(__x + __y); + __bet *= std::tr1::tgamma(__x); + } +#else + if (__x > __y) + { + __bet = __gamma(__x) / __gamma(__x + __y); + __bet *= __gamma(__y); + } + else + { + __bet = __gamma(__y) / __gamma(__x + __y); + __bet *= __gamma(__x); + } +#endif + + return __bet; + } + + /** + * @brief Return the beta function \f$B(x,y)\f$ using + * the log gamma functions. + * + * The beta function is defined by + * @f[ + * B(x,y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} + * @f] + * + * @param __x The first argument of the beta function. + * @param __y The second argument of the beta function. + * @return The beta function. + */ + template<typename _Tp> + _Tp + __beta_lgamma(_Tp __x, _Tp __y) + { +#if _GLIBCXX_USE_C99_MATH_TR1 + _Tp __bet = std::tr1::lgamma(__x) + + std::tr1::lgamma(__y) + - std::tr1::lgamma(__x + __y); +#else + _Tp __bet = __log_gamma(__x) + + __log_gamma(__y) + - __log_gamma(__x + __y); +#endif + __bet = std::exp(__bet); + return __bet; + } + + + /** + * @brief Return the beta function \f$B(x,y)\f$ using + * the product form. + * + * The beta function is defined by + * @f[ + * B(x,y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} + * @f] + * + * @param __x The first argument of the beta function. + * @param __y The second argument of the beta function. + * @return The beta function. + */ + template<typename _Tp> + _Tp + __beta_product(_Tp __x, _Tp __y) + { + + _Tp __bet = (__x + __y) / (__x * __y); + + unsigned int __max_iter = 1000000; + for (unsigned int __k = 1; __k < __max_iter; ++__k) + { + _Tp __term = (_Tp(1) + (__x + __y) / __k) + / ((_Tp(1) + __x / __k) * (_Tp(1) + __y / __k)); + __bet *= __term; + } + + return __bet; + } + + + /** + * @brief Return the beta function \f$ B(x,y) \f$. + * + * The beta function is defined by + * @f[ + * B(x,y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} + * @f] + * + * @param __x The first argument of the beta function. + * @param __y The second argument of the beta function. + * @return The beta function. + */ + template<typename _Tp> + inline _Tp + __beta(_Tp __x, _Tp __y) + { + if (__isnan(__x) || __isnan(__y)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else + return __beta_lgamma(__x, __y); + } + + } // namespace std::tr1::__detail +} +} + +#endif // __GLIBCXX_TR1_BETA_FUNCTION_TCC diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/ccomplex b/gcc-4.4.3/libstdc++-v3/include/tr1/ccomplex new file mode 100644 index 000000000..a0ae33e0c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/ccomplex @@ -0,0 +1,34 @@ +// TR1 ccomplex -*- C++ -*- + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/ccomplex + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CCOMPLEX +#define _GLIBCXX_TR1_CCOMPLEX 1 + +#include <tr1/complex> + +#endif // _GLIBCXX_TR1_CCOMPLEX diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/cctype b/gcc-4.4.3/libstdc++-v3/include/tr1/cctype new file mode 100644 index 000000000..93e864eb8 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/cctype @@ -0,0 +1,49 @@ +// TR1 cctype -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/cctype + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CCTYPE +#define _GLIBCXX_TR1_CCTYPE 1 + +#include <bits/c++config.h> +#include <cctype> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/cctype> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/cctype> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_CCTYPE diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/cfenv b/gcc-4.4.3/libstdc++-v3/include/tr1/cfenv new file mode 100644 index 000000000..e4c4facaa --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/cfenv @@ -0,0 +1,53 @@ +// TR1 cfenv -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/cfenv + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CFENV +#define _GLIBCXX_TR1_CFENV 1 + +#pragma GCC system_header + +#include <bits/c++config.h> +#if _GLIBCXX_HAVE_FENV_H +# include <fenv.h> +#endif + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/cfenv> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/cfenv> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_CFENV diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/cfloat b/gcc-4.4.3/libstdc++-v3/include/tr1/cfloat new file mode 100644 index 000000000..801cfc39e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/cfloat @@ -0,0 +1,42 @@ +// TR1 cfloat -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/cfloat + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CFLOAT +#define _GLIBCXX_TR1_CFLOAT 1 + +#include <cfloat> + +#ifndef DECIMAL_DIG +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif + +#ifndef FLT_EVAL_METHOD +#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +#endif + +#endif //_GLIBCXX_TR1_CFLOAT diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/cinttypes b/gcc-4.4.3/libstdc++-v3/include/tr1/cinttypes new file mode 100644 index 000000000..71fd545d2 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/cinttypes @@ -0,0 +1,63 @@ +// TR1 cinttypes -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/cinttypes + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CINTTYPES +#define _GLIBCXX_TR1_CINTTYPES 1 + +#pragma GCC system_header + +#include <tr1/cstdint> + +// For 8.11.1/1 (see C99, Note 184) +#if _GLIBCXX_HAVE_INTTYPES_H +# ifndef __STDC_FORMAT_MACROS +# define _UNDEF__STDC_FORMAT_MACROS +# define __STDC_FORMAT_MACROS +# endif +# include <inttypes.h> +# ifdef _UNDEF__STDC_FORMAT_MACROS +# undef __STDC_FORMAT_MACROS +# undef _UNDEF__STDC_FORMAT_MACROS +# endif +#endif + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/cinttypes> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/cinttypes> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_CINTTYPES diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/climits b/gcc-4.4.3/libstdc++-v3/include/tr1/climits new file mode 100644 index 000000000..91af96bae --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/climits @@ -0,0 +1,46 @@ +// TR1 climits -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/climits + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CLIMITS +#define _GLIBCXX_TR1_CLIMITS 1 + +#include <climits> + +#ifndef LLONG_MIN +#define LLONG_MIN (-__LONG_LONG_MAX__ - 1) +#endif + +#ifndef LLONG_MAX +#define LLONG_MAX __LONG_LONG_MAX__ +#endif + +#ifndef ULLONG_MAX +#define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1) +#endif + +#endif // _GLIBCXX_TR1_CLIMITS diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/cmath b/gcc-4.4.3/libstdc++-v3/include/tr1/cmath new file mode 100644 index 000000000..a9fbf2b6b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/cmath @@ -0,0 +1,507 @@ +// TR1 cmath -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/cmath + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CMATH +#define _GLIBCXX_TR1_CMATH 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <cmath> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/cmath> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/cmath> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +namespace std +{ +namespace tr1 +{ + // DR 550. What should the return type of pow(float,int) be? + // NB: C++0x and TR1 != C++03. + inline double + pow(double __x, double __y) + { return std::pow(__x, __y); } + + inline float + pow(float __x, float __y) + { return std::pow(__x, __y); } + + inline long double + pow(long double __x, long double __y) + { return std::pow(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + pow(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(__type(__x), __type(__y)); + } +} +} + +#include <bits/stl_algobase.h> +#include <limits> +#include <tr1/type_traits> + +#include <tr1/gamma.tcc> +#include <tr1/bessel_function.tcc> +#include <tr1/beta_function.tcc> +#include <tr1/ell_integral.tcc> +#include <tr1/exp_integral.tcc> +#include <tr1/hypergeometric.tcc> +#include <tr1/legendre_function.tcc> +#include <tr1/modified_bessel_func.tcc> +#include <tr1/poly_hermite.tcc> +#include <tr1/poly_laguerre.tcc> +#include <tr1/riemann_zeta.tcc> + +namespace std +{ +namespace tr1 +{ + /** + * @defgroup tr1_math_spec_func Mathematical Special Functions + * @ingroup numerics + * + * A collection of advanced mathematical special functions. + * @{ + */ + + inline float + assoc_laguerref(unsigned int __n, unsigned int __m, float __x) + { return __detail::__assoc_laguerre<float>(__n, __m, __x); } + + inline long double + assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x) + { + return __detail::__assoc_laguerre<long double>(__n, __m, __x); + } + + /// 5.2.1.1 Associated Laguerre polynomials. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__assoc_laguerre<__type>(__n, __m, __x); + } + + inline float + assoc_legendref(unsigned int __l, unsigned int __m, float __x) + { return __detail::__assoc_legendre_p<float>(__l, __m, __x); } + + inline long double + assoc_legendrel(unsigned int __l, unsigned int __m, long double __x) + { return __detail::__assoc_legendre_p<long double>(__l, __m, __x); } + + /// 5.2.1.2 Associated Legendre functions. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__assoc_legendre_p<__type>(__l, __m, __x); + } + + inline float + betaf(float __x, float __y) + { return __detail::__beta<float>(__x, __y); } + + inline long double + betal(long double __x, long double __y) + { return __detail::__beta<long double>(__x, __y); } + + /// 5.2.1.3 Beta functions. + template<typename _Tpx, typename _Tpy> + inline typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type + beta(_Tpx __x, _Tpy __y) + { + typedef typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type __type; + return __detail::__beta<__type>(__x, __y); + } + + inline float + comp_ellint_1f(float __k) + { return __detail::__comp_ellint_1<float>(__k); } + + inline long double + comp_ellint_1l(long double __k) + { return __detail::__comp_ellint_1<long double>(__k); } + + /// 5.2.1.4 Complete elliptic integrals of the first kind. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + comp_ellint_1(_Tp __k) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__comp_ellint_1<__type>(__k); + } + + inline float + comp_ellint_2f(float __k) + { return __detail::__comp_ellint_2<float>(__k); } + + inline long double + comp_ellint_2l(long double __k) + { return __detail::__comp_ellint_2<long double>(__k); } + + /// 5.2.1.5 Complete elliptic integrals of the second kind. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + comp_ellint_2(_Tp __k) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__comp_ellint_2<__type>(__k); + } + + inline float + comp_ellint_3f(float __k, float __nu) + { return __detail::__comp_ellint_3<float>(__k, __nu); } + + inline long double + comp_ellint_3l(long double __k, long double __nu) + { return __detail::__comp_ellint_3<long double>(__k, __nu); } + + /// 5.2.1.6 Complete elliptic integrals of the third kind. + template<typename _Tp, typename _Tpn> + inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type + comp_ellint_3(_Tp __k, _Tpn __nu) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type; + return __detail::__comp_ellint_3<__type>(__k, __nu); + } + + inline float + conf_hypergf(float __a, float __c, float __x) + { return __detail::__conf_hyperg<float>(__a, __c, __x); } + + inline long double + conf_hypergl(long double __a, long double __c, long double __x) + { return __detail::__conf_hyperg<long double>(__a, __c, __x); } + + /// 5.2.1.7 Confluent hypergeometric functions. + template<typename _Tpa, typename _Tpc, typename _Tp> + inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type + conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x) + { + typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type; + return __detail::__conf_hyperg<__type>(__a, __c, __x); + } + + inline float + cyl_bessel_if(float __nu, float __x) + { return __detail::__cyl_bessel_i<float>(__nu, __x); } + + inline long double + cyl_bessel_il(long double __nu, long double __x) + { return __detail::__cyl_bessel_i<long double>(__nu, __x); } + + /// 5.2.1.8 Regular modified cylindrical Bessel functions. + template<typename _Tpnu, typename _Tp> + inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type + cyl_bessel_i(_Tpnu __nu, _Tp __x) + { + typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type; + return __detail::__cyl_bessel_i<__type>(__nu, __x); + } + + inline float + cyl_bessel_jf(float __nu, float __x) + { return __detail::__cyl_bessel_j<float>(__nu, __x); } + + inline long double + cyl_bessel_jl(long double __nu, long double __x) + { return __detail::__cyl_bessel_j<long double>(__nu, __x); } + + /// 5.2.1.9 Cylindrical Bessel functions (of the first kind). + template<typename _Tpnu, typename _Tp> + inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type + cyl_bessel_j(_Tpnu __nu, _Tp __x) + { + typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type; + return __detail::__cyl_bessel_j<__type>(__nu, __x); + } + + inline float + cyl_bessel_kf(float __nu, float __x) + { return __detail::__cyl_bessel_k<float>(__nu, __x); } + + inline long double + cyl_bessel_kl(long double __nu, long double __x) + { return __detail::__cyl_bessel_k<long double>(__nu, __x); } + + /// 5.2.1.10 Irregular modified cylindrical Bessel functions. + template<typename _Tpnu, typename _Tp> + inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type + cyl_bessel_k(_Tpnu __nu, _Tp __x) + { + typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type; + return __detail::__cyl_bessel_k<__type>(__nu, __x); + } + + inline float + cyl_neumannf(float __nu, float __x) + { return __detail::__cyl_neumann_n<float>(__nu, __x); } + + inline long double + cyl_neumannl(long double __nu, long double __x) + { return __detail::__cyl_neumann_n<long double>(__nu, __x); } + + /// 5.2.1.11 Cylindrical Neumann functions. + template<typename _Tpnu, typename _Tp> + inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type + cyl_neumann(_Tpnu __nu, _Tp __x) + { + typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type; + return __detail::__cyl_neumann_n<__type>(__nu, __x); + } + + inline float + ellint_1f(float __k, float __phi) + { return __detail::__ellint_1<float>(__k, __phi); } + + inline long double + ellint_1l(long double __k, long double __phi) + { return __detail::__ellint_1<long double>(__k, __phi); } + + /// 5.2.1.12 Incomplete elliptic integrals of the first kind. + template<typename _Tp, typename _Tpp> + inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type + ellint_1(_Tp __k, _Tpp __phi) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type; + return __detail::__ellint_1<__type>(__k, __phi); + } + + inline float + ellint_2f(float __k, float __phi) + { return __detail::__ellint_2<float>(__k, __phi); } + + inline long double + ellint_2l(long double __k, long double __phi) + { return __detail::__ellint_2<long double>(__k, __phi); } + + /// 5.2.1.13 Incomplete elliptic integrals of the second kind. + template<typename _Tp, typename _Tpp> + inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type + ellint_2(_Tp __k, _Tpp __phi) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type; + return __detail::__ellint_2<__type>(__k, __phi); + } + + inline float + ellint_3f(float __k, float __nu, float __phi) + { return __detail::__ellint_3<float>(__k, __nu, __phi); } + + inline long double + ellint_3l(long double __k, long double __nu, long double __phi) + { return __detail::__ellint_3<long double>(__k, __nu, __phi); } + + /// 5.2.1.14 Incomplete elliptic integrals of the third kind. + template<typename _Tp, typename _Tpn, typename _Tpp> + inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type + ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi) + { + typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type; + return __detail::__ellint_3<__type>(__k, __nu, __phi); + } + + inline float + expintf(float __x) + { return __detail::__expint<float>(__x); } + + inline long double + expintl(long double __x) + { return __detail::__expint<long double>(__x); } + + /// 5.2.1.15 Exponential integrals. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + expint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__expint<__type>(__x); + } + + inline float + hermitef(unsigned int __n, float __x) + { return __detail::__poly_hermite<float>(__n, __x); } + + inline long double + hermitel(unsigned int __n, long double __x) + { return __detail::__poly_hermite<long double>(__n, __x); } + + /// 5.2.1.16 Hermite polynomials. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + hermite(unsigned int __n, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__poly_hermite<__type>(__n, __x); + } + + inline float + hypergf(float __a, float __b, float __c, float __x) + { return __detail::__hyperg<float>(__a, __b, __c, __x); } + + inline long double + hypergl(long double __a, long double __b, long double __c, long double __x) + { return __detail::__hyperg<long double>(__a, __b, __c, __x); } + + /// 5.2.1.17 Hypergeometric functions. + template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp> + inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type + hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x) + { + typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type; + return __detail::__hyperg<__type>(__a, __b, __c, __x); + } + + inline float + laguerref(unsigned int __n, float __x) + { return __detail::__laguerre<float>(__n, __x); } + + inline long double + laguerrel(unsigned int __n, long double __x) + { return __detail::__laguerre<long double>(__n, __x); } + + /// 5.2.1.18 Laguerre polynomials. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + laguerre(unsigned int __n, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__laguerre<__type>(__n, __x); + } + + inline float + legendref(unsigned int __n, float __x) + { return __detail::__poly_legendre_p<float>(__n, __x); } + + inline long double + legendrel(unsigned int __n, long double __x) + { return __detail::__poly_legendre_p<long double>(__n, __x); } + + /// 5.2.1.19 Legendre polynomials. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + legendre(unsigned int __n, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__poly_legendre_p<__type>(__n, __x); + } + + inline float + riemann_zetaf(float __x) + { return __detail::__riemann_zeta<float>(__x); } + + inline long double + riemann_zetal(long double __x) + { return __detail::__riemann_zeta<long double>(__x); } + + /// 5.2.1.20 Riemann zeta function. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + riemann_zeta(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__riemann_zeta<__type>(__x); + } + + inline float + sph_besself(unsigned int __n, float __x) + { return __detail::__sph_bessel<float>(__n, __x); } + + inline long double + sph_bessell(unsigned int __n, long double __x) + { return __detail::__sph_bessel<long double>(__n, __x); } + + /// 5.2.1.21 Spherical Bessel functions. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + sph_bessel(unsigned int __n, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__sph_bessel<__type>(__n, __x); + } + + inline float + sph_legendref(unsigned int __l, unsigned int __m, float __theta) + { return __detail::__sph_legendre<float>(__l, __m, __theta); } + + inline long double + sph_legendrel(unsigned int __l, unsigned int __m, long double __theta) + { return __detail::__sph_legendre<long double>(__l, __m, __theta); } + + /// 5.2.1.22 Spherical associated Legendre functions. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__sph_legendre<__type>(__l, __m, __theta); + } + + inline float + sph_neumannf(unsigned int __n, float __x) + { return __detail::__sph_neumann<float>(__n, __x); } + + inline long double + sph_neumannl(unsigned int __n, long double __x) + { return __detail::__sph_neumann<long double>(__n, __x); } + + /// 5.2.1.23 Spherical Neumann functions. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + sph_neumann(unsigned int __n, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__sph_neumann<__type>(__n, __x); + } + + /* @} */ // tr1_math_spec_func +} +} + +#endif // _GLIBCXX_TR1_CMATH diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/complex b/gcc-4.4.3/libstdc++-v3/include/tr1/complex new file mode 100644 index 000000000..3ed1eb97f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/complex @@ -0,0 +1,91 @@ +// TR1 complex -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/complex + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_COMPLEX +#define _GLIBCXX_TR1_COMPLEX 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <complex> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/complex> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/complex> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +namespace std +{ +namespace tr1 +{ + using std::arg; + using std::conj; + using std::imag; + using std::norm; + using std::polar; + + template<typename _Tp, typename _Up> + inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> + polar(const _Tp& __rho, const _Up& __theta) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::polar(__type(__rho), __type(__theta)); + } + + using std::real; + + template<typename _Tp> + inline std::complex<_Tp> + pow(const std::complex<_Tp>& __x, const _Tp& __y) + { return std::pow(__x, __y); } + + template<typename _Tp> + inline std::complex<_Tp> + pow(const _Tp& __x, const std::complex<_Tp>& __y) + { return std::pow(__x, __y); } + + template<typename _Tp> + inline std::complex<_Tp> + pow(const std::complex<_Tp>& __x, const std::complex<_Tp>& __y) + { return std::pow(__x, __y); } +} +} + +#endif // _GLIBCXX_TR1_COMPLEX diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/complex.h b/gcc-4.4.3/libstdc++-v3/include/tr1/complex.h new file mode 100644 index 000000000..0f28810b7 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/complex.h @@ -0,0 +1,34 @@ +// TR1 complex.h -*- C++ -*- + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/complex.h + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_COMPLEX_H +#define _GLIBCXX_TR1_COMPLEX_H 1 + +#include <tr1/ccomplex> + +#endif // _GLIBCXX_TR1_COMPLEX_H diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/cstdarg b/gcc-4.4.3/libstdc++-v3/include/tr1/cstdarg new file mode 100644 index 000000000..bc2e88153 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/cstdarg @@ -0,0 +1,34 @@ +// TR1 cstdarg -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/cstdarg + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CSTDARG +#define _GLIBCXX_TR1_CSTDARG 1 + +#include <cstdarg> + +#endif // _GLIBCXX_TR1_CSTDARG diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/cstdbool b/gcc-4.4.3/libstdc++-v3/include/tr1/cstdbool new file mode 100644 index 000000000..d68e4b896 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/cstdbool @@ -0,0 +1,40 @@ +// TR1 cstdbool -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/cstdbool + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CSTDBOOL +#define _GLIBCXX_TR1_CSTDBOOL 1 + +#pragma GCC system_header + +#include <bits/c++config.h> + +#if _GLIBCXX_HAVE_STDBOOL_H +#include <stdbool.h> +#endif + +#endif // _GLIBCXX_TR1_CSTDBOOL diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/cstdint b/gcc-4.4.3/libstdc++-v3/include/tr1/cstdint new file mode 100644 index 000000000..1e6cc3714 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/cstdint @@ -0,0 +1,76 @@ +// TR1 cstdint -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/cstdint + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CSTDINT +#define _GLIBCXX_TR1_CSTDINT 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <bits/c++config.h> + +// For 8.22.1/1 (see C99, Notes 219, 220, 222) +# if _GLIBCXX_HAVE_STDINT_H +# ifndef __STDC_LIMIT_MACROS +# define _UNDEF__STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS +# endif +# ifndef __STDC_CONSTANT_MACROS +# define _UNDEF__STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS +# endif +# include <stdint.h> +# ifdef _UNDEF__STDC_LIMIT_MACROS +# undef __STDC_LIMIT_MACROS +# undef _UNDEF__STDC_LIMIT_MACROS +# endif +# ifdef _UNDEF__STDC_CONSTANT_MACROS +# undef __STDC_CONSTANT_MACROS +# undef _UNDEF__STDC_CONSTANT_MACROS +# endif +# endif + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/cstdint> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/cstdint> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_CSTDINT + diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/cstdio b/gcc-4.4.3/libstdc++-v3/include/tr1/cstdio new file mode 100644 index 000000000..cfcf31a3f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/cstdio @@ -0,0 +1,54 @@ +// TR1 cstdio -*- C++ -*- + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/cstdio + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CSTDIO +#define _GLIBCXX_TR1_CSTDIO 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <cstdio> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/cstdio> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/cstdio> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_CSTDIO diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/cstdlib b/gcc-4.4.3/libstdc++-v3/include/tr1/cstdlib new file mode 100644 index 000000000..c9fab202d --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/cstdlib @@ -0,0 +1,54 @@ +// TR1 cstdlib -*- C++ -*- + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/cstdlib + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CSTDLIB +#define _GLIBCXX_TR1_CSTDLIB 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <cstdlib> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/cstdlib> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/cstdlib> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_CSTDLIB diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/ctgmath b/gcc-4.4.3/libstdc++-v3/include/tr1/ctgmath new file mode 100644 index 000000000..e82a9a15f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/ctgmath @@ -0,0 +1,34 @@ +// TR1 ctgmath -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/ctgmath + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CTGMATH +#define _GLIBCXX_TR1_CTGMATH 1 + +#include <tr1/cmath> + +#endif // _GLIBCXX_TR1_CTGMATH diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/ctime b/gcc-4.4.3/libstdc++-v3/include/tr1/ctime new file mode 100644 index 000000000..bf763377d --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/ctime @@ -0,0 +1,34 @@ +// TR1 ctime -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/ctime + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CTIME +#define _GLIBCXX_TR1_CTIME 1 + +#include <ctime> + +#endif // _GLIBCXX_TR1_CTIME diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/ctype.h b/gcc-4.4.3/libstdc++-v3/include/tr1/ctype.h new file mode 100644 index 000000000..712bedb67 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/ctype.h @@ -0,0 +1,34 @@ +// TR1 ctype.h -*- C++ -*- + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/ctype.h + * This is a TR1 C++ Library header. + */ + +#ifndef _TR1_CTYPE_H +#define _TR1_CTYPE_H 1 + +#include <tr1/cctype> + +#endif diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/cwchar b/gcc-4.4.3/libstdc++-v3/include/tr1/cwchar new file mode 100644 index 000000000..a27ebc3b4 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/cwchar @@ -0,0 +1,54 @@ +// TR1 cwchar -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/cwchar + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CWCHAR +#define _GLIBCXX_TR1_CWCHAR 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <cwchar> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/cwchar> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/cwchar> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_CWCHAR diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/cwctype b/gcc-4.4.3/libstdc++-v3/include/tr1/cwctype new file mode 100644 index 000000000..77cbb14a1 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/cwctype @@ -0,0 +1,54 @@ +// TR1 cwctype -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/cwctype + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_CWCTYPE +#define _GLIBCXX_TR1_CWCTYPE 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <cwctype> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/cwctype> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/cwctype> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_CWCTYPE diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/ell_integral.tcc b/gcc-4.4.3/libstdc++-v3/include/tr1/ell_integral.tcc new file mode 100644 index 000000000..09bda9aa9 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/ell_integral.tcc @@ -0,0 +1,750 @@ +// Special functions -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/ell_integral.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +// +// ISO C++ 14882 TR1: 5.2 Special functions +// + +// Written by Edward Smith-Rowland based on: +// (1) B. C. Carlson Numer. Math. 33, 1 (1979) +// (2) B. C. Carlson, Special Functions of Applied Mathematics (1977) +// (3) The Gnu Scientific Library, http://www.gnu.org/software/gsl +// (4) Numerical Recipes in C, 2nd ed, by W. H. Press, S. A. Teukolsky, +// W. T. Vetterling, B. P. Flannery, Cambridge University Press +// (1992), pp. 261-269 + +#ifndef _GLIBCXX_TR1_ELL_INTEGRAL_TCC +#define _GLIBCXX_TR1_ELL_INTEGRAL_TCC 1 + +namespace std +{ +namespace tr1 +{ + + // [5.2] Special functions + + // Implementation-space details. + namespace __detail + { + + /** + * @brief Return the Carlson elliptic function @f$ R_F(x,y,z) @f$ + * of the first kind. + * + * The Carlson elliptic function of the first kind is defined by: + * @f[ + * R_F(x,y,z) = \frac{1}{2} \int_0^\infty + * \frac{dt}{(t + x)^{1/2}(t + y)^{1/2}(t + z)^{1/2}} + * @f] + * + * @param __x The first of three symmetric arguments. + * @param __y The second of three symmetric arguments. + * @param __z The third of three symmetric arguments. + * @return The Carlson elliptic function of the first kind. + */ + template<typename _Tp> + _Tp + __ellint_rf(const _Tp __x, const _Tp __y, const _Tp __z) + { + const _Tp __min = std::numeric_limits<_Tp>::min(); + const _Tp __max = std::numeric_limits<_Tp>::max(); + const _Tp __lolim = _Tp(5) * __min; + const _Tp __uplim = __max / _Tp(5); + + if (__x < _Tp(0) || __y < _Tp(0) || __z < _Tp(0)) + std::__throw_domain_error(__N("Argument less than zero " + "in __ellint_rf.")); + else if (__x + __y < __lolim || __x + __z < __lolim + || __y + __z < __lolim) + std::__throw_domain_error(__N("Argument too small in __ellint_rf")); + else + { + const _Tp __c0 = _Tp(1) / _Tp(4); + const _Tp __c1 = _Tp(1) / _Tp(24); + const _Tp __c2 = _Tp(1) / _Tp(10); + const _Tp __c3 = _Tp(3) / _Tp(44); + const _Tp __c4 = _Tp(1) / _Tp(14); + + _Tp __xn = __x; + _Tp __yn = __y; + _Tp __zn = __z; + + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + const _Tp __errtol = std::pow(__eps, _Tp(1) / _Tp(6)); + _Tp __mu; + _Tp __xndev, __yndev, __zndev; + + const unsigned int __max_iter = 100; + for (unsigned int __iter = 0; __iter < __max_iter; ++__iter) + { + __mu = (__xn + __yn + __zn) / _Tp(3); + __xndev = 2 - (__mu + __xn) / __mu; + __yndev = 2 - (__mu + __yn) / __mu; + __zndev = 2 - (__mu + __zn) / __mu; + _Tp __epsilon = std::max(std::abs(__xndev), std::abs(__yndev)); + __epsilon = std::max(__epsilon, std::abs(__zndev)); + if (__epsilon < __errtol) + break; + const _Tp __xnroot = std::sqrt(__xn); + const _Tp __ynroot = std::sqrt(__yn); + const _Tp __znroot = std::sqrt(__zn); + const _Tp __lambda = __xnroot * (__ynroot + __znroot) + + __ynroot * __znroot; + __xn = __c0 * (__xn + __lambda); + __yn = __c0 * (__yn + __lambda); + __zn = __c0 * (__zn + __lambda); + } + + const _Tp __e2 = __xndev * __yndev - __zndev * __zndev; + const _Tp __e3 = __xndev * __yndev * __zndev; + const _Tp __s = _Tp(1) + (__c1 * __e2 - __c2 - __c3 * __e3) * __e2 + + __c4 * __e3; + + return __s / std::sqrt(__mu); + } + } + + + /** + * @brief Return the complete elliptic integral of the first kind + * @f$ K(k) @f$ by series expansion. + * + * The complete elliptic integral of the first kind is defined as + * @f[ + * K(k) = F(k,\pi/2) = \int_0^{\pi/2}\frac{d\theta} + * {\sqrt{1 - k^2sin^2\theta}} + * @f] + * + * This routine is not bad as long as |k| is somewhat smaller than 1 + * but is not is good as the Carlson elliptic integral formulation. + * + * @param __k The argument of the complete elliptic function. + * @return The complete elliptic function of the first kind. + */ + template<typename _Tp> + _Tp + __comp_ellint_1_series(const _Tp __k) + { + + const _Tp __kk = __k * __k; + + _Tp __term = __kk / _Tp(4); + _Tp __sum = _Tp(1) + __term; + + const unsigned int __max_iter = 1000; + for (unsigned int __i = 2; __i < __max_iter; ++__i) + { + __term *= (2 * __i - 1) * __kk / (2 * __i); + if (__term < std::numeric_limits<_Tp>::epsilon()) + break; + __sum += __term; + } + + return __numeric_constants<_Tp>::__pi_2() * __sum; + } + + + /** + * @brief Return the complete elliptic integral of the first kind + * @f$ K(k) @f$ using the Carlson formulation. + * + * The complete elliptic integral of the first kind is defined as + * @f[ + * K(k) = F(k,\pi/2) = \int_0^{\pi/2}\frac{d\theta} + * {\sqrt{1 - k^2 sin^2\theta}} + * @f] + * where @f$ F(k,\phi) @f$ is the incomplete elliptic integral of the + * first kind. + * + * @param __k The argument of the complete elliptic function. + * @return The complete elliptic function of the first kind. + */ + template<typename _Tp> + _Tp + __comp_ellint_1(const _Tp __k) + { + + if (__isnan(__k)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (std::abs(__k) >= _Tp(1)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else + return __ellint_rf(_Tp(0), _Tp(1) - __k * __k, _Tp(1)); + } + + + /** + * @brief Return the incomplete elliptic integral of the first kind + * @f$ F(k,\phi) @f$ using the Carlson formulation. + * + * The incomplete elliptic integral of the first kind is defined as + * @f[ + * F(k,\phi) = \int_0^{\phi}\frac{d\theta} + * {\sqrt{1 - k^2 sin^2\theta}} + * @f] + * + * @param __k The argument of the elliptic function. + * @param __phi The integral limit argument of the elliptic function. + * @return The elliptic function of the first kind. + */ + template<typename _Tp> + _Tp + __ellint_1(const _Tp __k, const _Tp __phi) + { + + if (__isnan(__k) || __isnan(__phi)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (std::abs(__k) > _Tp(1)) + std::__throw_domain_error(__N("Bad argument in __ellint_1.")); + else + { + // Reduce phi to -pi/2 < phi < +pi/2. + const int __n = std::floor(__phi / __numeric_constants<_Tp>::__pi() + + _Tp(0.5L)); + const _Tp __phi_red = __phi + - __n * __numeric_constants<_Tp>::__pi(); + + const _Tp __s = std::sin(__phi_red); + const _Tp __c = std::cos(__phi_red); + + const _Tp __F = __s + * __ellint_rf(__c * __c, + _Tp(1) - __k * __k * __s * __s, _Tp(1)); + + if (__n == 0) + return __F; + else + return __F + _Tp(2) * __n * __comp_ellint_1(__k); + } + } + + + /** + * @brief Return the complete elliptic integral of the second kind + * @f$ E(k) @f$ by series expansion. + * + * The complete elliptic integral of the second kind is defined as + * @f[ + * E(k,\pi/2) = \int_0^{\pi/2}\sqrt{1 - k^2 sin^2\theta} + * @f] + * + * This routine is not bad as long as |k| is somewhat smaller than 1 + * but is not is good as the Carlson elliptic integral formulation. + * + * @param __k The argument of the complete elliptic function. + * @return The complete elliptic function of the second kind. + */ + template<typename _Tp> + _Tp + __comp_ellint_2_series(const _Tp __k) + { + + const _Tp __kk = __k * __k; + + _Tp __term = __kk; + _Tp __sum = __term; + + const unsigned int __max_iter = 1000; + for (unsigned int __i = 2; __i < __max_iter; ++__i) + { + const _Tp __i2m = 2 * __i - 1; + const _Tp __i2 = 2 * __i; + __term *= __i2m * __i2m * __kk / (__i2 * __i2); + if (__term < std::numeric_limits<_Tp>::epsilon()) + break; + __sum += __term / __i2m; + } + + return __numeric_constants<_Tp>::__pi_2() * (_Tp(1) - __sum); + } + + + /** + * @brief Return the Carlson elliptic function of the second kind + * @f$ R_D(x,y,z) = R_J(x,y,z,z) @f$ where + * @f$ R_J(x,y,z,p) @f$ is the Carlson elliptic function + * of the third kind. + * + * The Carlson elliptic function of the second kind is defined by: + * @f[ + * R_D(x,y,z) = \frac{3}{2} \int_0^\infty + * \frac{dt}{(t + x)^{1/2}(t + y)^{1/2}(t + z)^{3/2}} + * @f] + * + * Based on Carlson's algorithms: + * - B. C. Carlson Numer. Math. 33, 1 (1979) + * - B. C. Carlson, Special Functions of Applied Mathematics (1977) + * - Numerical Recipes in C, 2nd ed, pp. 261-269, + * by Press, Teukolsky, Vetterling, Flannery (1992) + * + * @param __x The first of two symmetric arguments. + * @param __y The second of two symmetric arguments. + * @param __z The third argument. + * @return The Carlson elliptic function of the second kind. + */ + template<typename _Tp> + _Tp + __ellint_rd(const _Tp __x, const _Tp __y, const _Tp __z) + { + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + const _Tp __errtol = std::pow(__eps / _Tp(8), _Tp(1) / _Tp(6)); + const _Tp __min = std::numeric_limits<_Tp>::min(); + const _Tp __max = std::numeric_limits<_Tp>::max(); + const _Tp __lolim = _Tp(2) / std::pow(__max, _Tp(2) / _Tp(3)); + const _Tp __uplim = std::pow(_Tp(0.1L) * __errtol / __min, _Tp(2) / _Tp(3)); + + if (__x < _Tp(0) || __y < _Tp(0)) + std::__throw_domain_error(__N("Argument less than zero " + "in __ellint_rd.")); + else if (__x + __y < __lolim || __z < __lolim) + std::__throw_domain_error(__N("Argument too small " + "in __ellint_rd.")); + else + { + const _Tp __c0 = _Tp(1) / _Tp(4); + const _Tp __c1 = _Tp(3) / _Tp(14); + const _Tp __c2 = _Tp(1) / _Tp(6); + const _Tp __c3 = _Tp(9) / _Tp(22); + const _Tp __c4 = _Tp(3) / _Tp(26); + + _Tp __xn = __x; + _Tp __yn = __y; + _Tp __zn = __z; + _Tp __sigma = _Tp(0); + _Tp __power4 = _Tp(1); + + _Tp __mu; + _Tp __xndev, __yndev, __zndev; + + const unsigned int __max_iter = 100; + for (unsigned int __iter = 0; __iter < __max_iter; ++__iter) + { + __mu = (__xn + __yn + _Tp(3) * __zn) / _Tp(5); + __xndev = (__mu - __xn) / __mu; + __yndev = (__mu - __yn) / __mu; + __zndev = (__mu - __zn) / __mu; + _Tp __epsilon = std::max(std::abs(__xndev), std::abs(__yndev)); + __epsilon = std::max(__epsilon, std::abs(__zndev)); + if (__epsilon < __errtol) + break; + _Tp __xnroot = std::sqrt(__xn); + _Tp __ynroot = std::sqrt(__yn); + _Tp __znroot = std::sqrt(__zn); + _Tp __lambda = __xnroot * (__ynroot + __znroot) + + __ynroot * __znroot; + __sigma += __power4 / (__znroot * (__zn + __lambda)); + __power4 *= __c0; + __xn = __c0 * (__xn + __lambda); + __yn = __c0 * (__yn + __lambda); + __zn = __c0 * (__zn + __lambda); + } + + // Note: __ea is an SPU badname. + _Tp __eaa = __xndev * __yndev; + _Tp __eb = __zndev * __zndev; + _Tp __ec = __eaa - __eb; + _Tp __ed = __eaa - _Tp(6) * __eb; + _Tp __ef = __ed + __ec + __ec; + _Tp __s1 = __ed * (-__c1 + __c3 * __ed + / _Tp(3) - _Tp(3) * __c4 * __zndev * __ef + / _Tp(2)); + _Tp __s2 = __zndev + * (__c2 * __ef + + __zndev * (-__c3 * __ec - __zndev * __c4 - __eaa)); + + return _Tp(3) * __sigma + __power4 * (_Tp(1) + __s1 + __s2) + / (__mu * std::sqrt(__mu)); + } + } + + + /** + * @brief Return the complete elliptic integral of the second kind + * @f$ E(k) @f$ using the Carlson formulation. + * + * The complete elliptic integral of the second kind is defined as + * @f[ + * E(k,\pi/2) = \int_0^{\pi/2}\sqrt{1 - k^2 sin^2\theta} + * @f] + * + * @param __k The argument of the complete elliptic function. + * @return The complete elliptic function of the second kind. + */ + template<typename _Tp> + _Tp + __comp_ellint_2(const _Tp __k) + { + + if (__isnan(__k)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (std::abs(__k) == 1) + return _Tp(1); + else if (std::abs(__k) > _Tp(1)) + std::__throw_domain_error(__N("Bad argument in __comp_ellint_2.")); + else + { + const _Tp __kk = __k * __k; + + return __ellint_rf(_Tp(0), _Tp(1) - __kk, _Tp(1)) + - __kk * __ellint_rd(_Tp(0), _Tp(1) - __kk, _Tp(1)) / _Tp(3); + } + } + + + /** + * @brief Return the incomplete elliptic integral of the second kind + * @f$ E(k,\phi) @f$ using the Carlson formulation. + * + * The incomplete elliptic integral of the second kind is defined as + * @f[ + * E(k,\phi) = \int_0^{\phi} \sqrt{1 - k^2 sin^2\theta} + * @f] + * + * @param __k The argument of the elliptic function. + * @param __phi The integral limit argument of the elliptic function. + * @return The elliptic function of the second kind. + */ + template<typename _Tp> + _Tp + __ellint_2(const _Tp __k, const _Tp __phi) + { + + if (__isnan(__k) || __isnan(__phi)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (std::abs(__k) > _Tp(1)) + std::__throw_domain_error(__N("Bad argument in __ellint_2.")); + else + { + // Reduce phi to -pi/2 < phi < +pi/2. + const int __n = std::floor(__phi / __numeric_constants<_Tp>::__pi() + + _Tp(0.5L)); + const _Tp __phi_red = __phi + - __n * __numeric_constants<_Tp>::__pi(); + + const _Tp __kk = __k * __k; + const _Tp __s = std::sin(__phi_red); + const _Tp __ss = __s * __s; + const _Tp __sss = __ss * __s; + const _Tp __c = std::cos(__phi_red); + const _Tp __cc = __c * __c; + + const _Tp __E = __s + * __ellint_rf(__cc, _Tp(1) - __kk * __ss, _Tp(1)) + - __kk * __sss + * __ellint_rd(__cc, _Tp(1) - __kk * __ss, _Tp(1)) + / _Tp(3); + + if (__n == 0) + return __E; + else + return __E + _Tp(2) * __n * __comp_ellint_2(__k); + } + } + + + /** + * @brief Return the Carlson elliptic function + * @f$ R_C(x,y) = R_F(x,y,y) @f$ where @f$ R_F(x,y,z) @f$ + * is the Carlson elliptic function of the first kind. + * + * The Carlson elliptic function is defined by: + * @f[ + * R_C(x,y) = \frac{1}{2} \int_0^\infty + * \frac{dt}{(t + x)^{1/2}(t + y)} + * @f] + * + * Based on Carlson's algorithms: + * - B. C. Carlson Numer. Math. 33, 1 (1979) + * - B. C. Carlson, Special Functions of Applied Mathematics (1977) + * - Numerical Recipes in C, 2nd ed, pp. 261-269, + * by Press, Teukolsky, Vetterling, Flannery (1992) + * + * @param __x The first argument. + * @param __y The second argument. + * @return The Carlson elliptic function. + */ + template<typename _Tp> + _Tp + __ellint_rc(const _Tp __x, const _Tp __y) + { + const _Tp __min = std::numeric_limits<_Tp>::min(); + const _Tp __max = std::numeric_limits<_Tp>::max(); + const _Tp __lolim = _Tp(5) * __min; + const _Tp __uplim = __max / _Tp(5); + + if (__x < _Tp(0) || __y < _Tp(0) || __x + __y < __lolim) + std::__throw_domain_error(__N("Argument less than zero " + "in __ellint_rc.")); + else + { + const _Tp __c0 = _Tp(1) / _Tp(4); + const _Tp __c1 = _Tp(1) / _Tp(7); + const _Tp __c2 = _Tp(9) / _Tp(22); + const _Tp __c3 = _Tp(3) / _Tp(10); + const _Tp __c4 = _Tp(3) / _Tp(8); + + _Tp __xn = __x; + _Tp __yn = __y; + + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + const _Tp __errtol = std::pow(__eps / _Tp(30), _Tp(1) / _Tp(6)); + _Tp __mu; + _Tp __sn; + + const unsigned int __max_iter = 100; + for (unsigned int __iter = 0; __iter < __max_iter; ++__iter) + { + __mu = (__xn + _Tp(2) * __yn) / _Tp(3); + __sn = (__yn + __mu) / __mu - _Tp(2); + if (std::abs(__sn) < __errtol) + break; + const _Tp __lambda = _Tp(2) * std::sqrt(__xn) * std::sqrt(__yn) + + __yn; + __xn = __c0 * (__xn + __lambda); + __yn = __c0 * (__yn + __lambda); + } + + _Tp __s = __sn * __sn + * (__c3 + __sn*(__c1 + __sn * (__c4 + __sn * __c2))); + + return (_Tp(1) + __s) / std::sqrt(__mu); + } + } + + + /** + * @brief Return the Carlson elliptic function @f$ R_J(x,y,z,p) @f$ + * of the third kind. + * + * The Carlson elliptic function of the third kind is defined by: + * @f[ + * R_J(x,y,z,p) = \frac{3}{2} \int_0^\infty + * \frac{dt}{(t + x)^{1/2}(t + y)^{1/2}(t + z)^{1/2}(t + p)} + * @f] + * + * Based on Carlson's algorithms: + * - B. C. Carlson Numer. Math. 33, 1 (1979) + * - B. C. Carlson, Special Functions of Applied Mathematics (1977) + * - Numerical Recipes in C, 2nd ed, pp. 261-269, + * by Press, Teukolsky, Vetterling, Flannery (1992) + * + * @param __x The first of three symmetric arguments. + * @param __y The second of three symmetric arguments. + * @param __z The third of three symmetric arguments. + * @param __p The fourth argument. + * @return The Carlson elliptic function of the fourth kind. + */ + template<typename _Tp> + _Tp + __ellint_rj(const _Tp __x, const _Tp __y, const _Tp __z, const _Tp __p) + { + const _Tp __min = std::numeric_limits<_Tp>::min(); + const _Tp __max = std::numeric_limits<_Tp>::max(); + const _Tp __lolim = std::pow(_Tp(5) * __min, _Tp(1)/_Tp(3)); + const _Tp __uplim = _Tp(0.3L) + * std::pow(_Tp(0.2L) * __max, _Tp(1)/_Tp(3)); + + if (__x < _Tp(0) || __y < _Tp(0) || __z < _Tp(0)) + std::__throw_domain_error(__N("Argument less than zero " + "in __ellint_rj.")); + else if (__x + __y < __lolim || __x + __z < __lolim + || __y + __z < __lolim || __p < __lolim) + std::__throw_domain_error(__N("Argument too small " + "in __ellint_rj")); + else + { + const _Tp __c0 = _Tp(1) / _Tp(4); + const _Tp __c1 = _Tp(3) / _Tp(14); + const _Tp __c2 = _Tp(1) / _Tp(3); + const _Tp __c3 = _Tp(3) / _Tp(22); + const _Tp __c4 = _Tp(3) / _Tp(26); + + _Tp __xn = __x; + _Tp __yn = __y; + _Tp __zn = __z; + _Tp __pn = __p; + _Tp __sigma = _Tp(0); + _Tp __power4 = _Tp(1); + + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + const _Tp __errtol = std::pow(__eps / _Tp(8), _Tp(1) / _Tp(6)); + + _Tp __lambda, __mu; + _Tp __xndev, __yndev, __zndev, __pndev; + + const unsigned int __max_iter = 100; + for (unsigned int __iter = 0; __iter < __max_iter; ++__iter) + { + __mu = (__xn + __yn + __zn + _Tp(2) * __pn) / _Tp(5); + __xndev = (__mu - __xn) / __mu; + __yndev = (__mu - __yn) / __mu; + __zndev = (__mu - __zn) / __mu; + __pndev = (__mu - __pn) / __mu; + _Tp __epsilon = std::max(std::abs(__xndev), std::abs(__yndev)); + __epsilon = std::max(__epsilon, std::abs(__zndev)); + __epsilon = std::max(__epsilon, std::abs(__pndev)); + if (__epsilon < __errtol) + break; + const _Tp __xnroot = std::sqrt(__xn); + const _Tp __ynroot = std::sqrt(__yn); + const _Tp __znroot = std::sqrt(__zn); + const _Tp __lambda = __xnroot * (__ynroot + __znroot) + + __ynroot * __znroot; + const _Tp __alpha1 = __pn * (__xnroot + __ynroot + __znroot) + + __xnroot * __ynroot * __znroot; + const _Tp __alpha2 = __alpha1 * __alpha1; + const _Tp __beta = __pn * (__pn + __lambda) + * (__pn + __lambda); + __sigma += __power4 * __ellint_rc(__alpha2, __beta); + __power4 *= __c0; + __xn = __c0 * (__xn + __lambda); + __yn = __c0 * (__yn + __lambda); + __zn = __c0 * (__zn + __lambda); + __pn = __c0 * (__pn + __lambda); + } + + // Note: __ea is an SPU badname. + _Tp __eaa = __xndev * (__yndev + __zndev) + __yndev * __zndev; + _Tp __eb = __xndev * __yndev * __zndev; + _Tp __ec = __pndev * __pndev; + _Tp __e2 = __eaa - _Tp(3) * __ec; + _Tp __e3 = __eb + _Tp(2) * __pndev * (__eaa - __ec); + _Tp __s1 = _Tp(1) + __e2 * (-__c1 + _Tp(3) * __c3 * __e2 / _Tp(4) + - _Tp(3) * __c4 * __e3 / _Tp(2)); + _Tp __s2 = __eb * (__c2 / _Tp(2) + + __pndev * (-__c3 - __c3 + __pndev * __c4)); + _Tp __s3 = __pndev * __eaa * (__c2 - __pndev * __c3) + - __c2 * __pndev * __ec; + + return _Tp(3) * __sigma + __power4 * (__s1 + __s2 + __s3) + / (__mu * std::sqrt(__mu)); + } + } + + + /** + * @brief Return the complete elliptic integral of the third kind + * @f$ \Pi(k,\nu) = \Pi(k,\nu,\pi/2) @f$ using the + * Carlson formulation. + * + * The complete elliptic integral of the third kind is defined as + * @f[ + * \Pi(k,\nu) = \int_0^{\pi/2} + * \frac{d\theta} + * {(1 - \nu \sin^2\theta)\sqrt{1 - k^2 \sin^2\theta}} + * @f] + * + * @param __k The argument of the elliptic function. + * @param __nu The second argument of the elliptic function. + * @return The complete elliptic function of the third kind. + */ + template<typename _Tp> + _Tp + __comp_ellint_3(const _Tp __k, const _Tp __nu) + { + + if (__isnan(__k) || __isnan(__nu)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__nu == _Tp(1)) + return std::numeric_limits<_Tp>::infinity(); + else if (std::abs(__k) > _Tp(1)) + std::__throw_domain_error(__N("Bad argument in __comp_ellint_3.")); + else + { + const _Tp __kk = __k * __k; + + return __ellint_rf(_Tp(0), _Tp(1) - __kk, _Tp(1)) + - __nu + * __ellint_rj(_Tp(0), _Tp(1) - __kk, _Tp(1), _Tp(1) + __nu) + / _Tp(3); + } + } + + + /** + * @brief Return the incomplete elliptic integral of the third kind + * @f$ \Pi(k,\nu,\phi) @f$ using the Carlson formulation. + * + * The incomplete elliptic integral of the third kind is defined as + * @f[ + * \Pi(k,\nu,\phi) = \int_0^{\phi} + * \frac{d\theta} + * {(1 - \nu \sin^2\theta) + * \sqrt{1 - k^2 \sin^2\theta}} + * @f] + * + * @param __k The argument of the elliptic function. + * @param __nu The second argument of the elliptic function. + * @param __phi The integral limit argument of the elliptic function. + * @return The elliptic function of the third kind. + */ + template<typename _Tp> + _Tp + __ellint_3(const _Tp __k, const _Tp __nu, const _Tp __phi) + { + + if (__isnan(__k) || __isnan(__nu) || __isnan(__phi)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (std::abs(__k) > _Tp(1)) + std::__throw_domain_error(__N("Bad argument in __ellint_3.")); + else + { + // Reduce phi to -pi/2 < phi < +pi/2. + const int __n = std::floor(__phi / __numeric_constants<_Tp>::__pi() + + _Tp(0.5L)); + const _Tp __phi_red = __phi + - __n * __numeric_constants<_Tp>::__pi(); + + const _Tp __kk = __k * __k; + const _Tp __s = std::sin(__phi_red); + const _Tp __ss = __s * __s; + const _Tp __sss = __ss * __s; + const _Tp __c = std::cos(__phi_red); + const _Tp __cc = __c * __c; + + const _Tp __Pi = __s + * __ellint_rf(__cc, _Tp(1) - __kk * __ss, _Tp(1)) + - __nu * __sss + * __ellint_rj(__cc, _Tp(1) - __kk * __ss, _Tp(1), + _Tp(1) + __nu * __ss) / _Tp(3); + + if (__n == 0) + return __Pi; + else + return __Pi + _Tp(2) * __n * __comp_ellint_3(__k, __nu); + } + } + + } // namespace std::tr1::__detail +} +} + +#endif // _GLIBCXX_TR1_ELL_INTEGRAL_TCC + diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/exp_integral.tcc b/gcc-4.4.3/libstdc++-v3/include/tr1/exp_integral.tcc new file mode 100644 index 000000000..5b3af5d8e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/exp_integral.tcc @@ -0,0 +1,524 @@ +// Special functions -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/exp_integral.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +// +// ISO C++ 14882 TR1: 5.2 Special functions +// + +// Written by Edward Smith-Rowland based on: +// +// (1) Handbook of Mathematical Functions, +// Ed. by Milton Abramowitz and Irene A. Stegun, +// Dover Publications, New-York, Section 5, pp. 228-251. +// (2) The Gnu Scientific Library, http://www.gnu.org/software/gsl +// (3) Numerical Recipes in C, by W. H. Press, S. A. Teukolsky, +// W. T. Vetterling, B. P. Flannery, Cambridge University Press (1992), +// 2nd ed, pp. 222-225. +// + +#ifndef _GLIBCXX_TR1_EXP_INTEGRAL_TCC +#define _GLIBCXX_TR1_EXP_INTEGRAL_TCC 1 + +#include "special_function_util.h" + +namespace std +{ +namespace tr1 +{ + + // [5.2] Special functions + + // Implementation-space details. + namespace __detail + { + + /** + * @brief Return the exponential integral @f$ E_1(x) @f$ + * by series summation. This should be good + * for @f$ x < 1 @f$. + * + * The exponential integral is given by + * \f[ + * E_1(x) = \int_{1}^{\infty} \frac{e^{-xt}}{t} dt + * \f] + * + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + _Tp + __expint_E1_series(const _Tp __x) + { + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + _Tp __term = _Tp(1); + _Tp __esum = _Tp(0); + _Tp __osum = _Tp(0); + const unsigned int __max_iter = 100; + for (unsigned int __i = 1; __i < __max_iter; ++__i) + { + __term *= - __x / __i; + if (std::abs(__term) < __eps) + break; + if (__term >= _Tp(0)) + __esum += __term / __i; + else + __osum += __term / __i; + } + + return - __esum - __osum + - __numeric_constants<_Tp>::__gamma_e() - std::log(__x); + } + + + /** + * @brief Return the exponential integral @f$ E_1(x) @f$ + * by asymptotic expansion. + * + * The exponential integral is given by + * \f[ + * E_1(x) = \int_{1}^\infty \frac{e^{-xt}}{t} dt + * \f] + * + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + _Tp + __expint_E1_asymp(const _Tp __x) + { + _Tp __term = _Tp(1); + _Tp __esum = _Tp(1); + _Tp __osum = _Tp(0); + const unsigned int __max_iter = 1000; + for (unsigned int __i = 1; __i < __max_iter; ++__i) + { + _Tp __prev = __term; + __term *= - __i / __x; + if (std::abs(__term) > std::abs(__prev)) + break; + if (__term >= _Tp(0)) + __esum += __term; + else + __osum += __term; + } + + return std::exp(- __x) * (__esum + __osum) / __x; + } + + + /** + * @brief Return the exponential integral @f$ E_n(x) @f$ + * by series summation. + * + * The exponential integral is given by + * \f[ + * E_n(x) = \int_{1}^\infty \frac{e^{-xt}}{t^n} dt + * \f] + * + * @param __n The order of the exponential integral function. + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + _Tp + __expint_En_series(const unsigned int __n, const _Tp __x) + { + const unsigned int __max_iter = 100; + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + const int __nm1 = __n - 1; + _Tp __ans = (__nm1 != 0 + ? _Tp(1) / __nm1 : -std::log(__x) + - __numeric_constants<_Tp>::__gamma_e()); + _Tp __fact = _Tp(1); + for (int __i = 1; __i <= __max_iter; ++__i) + { + __fact *= -__x / _Tp(__i); + _Tp __del; + if ( __i != __nm1 ) + __del = -__fact / _Tp(__i - __nm1); + else + { + _Tp __psi = -_TR1_GAMMA_TCC; + for (int __ii = 1; __ii <= __nm1; ++__ii) + __psi += _Tp(1) / _Tp(__ii); + __del = __fact * (__psi - std::log(__x)); + } + __ans += __del; + if (std::abs(__del) < __eps * std::abs(__ans)) + return __ans; + } + std::__throw_runtime_error(__N("Series summation failed " + "in __expint_En_series.")); + } + + + /** + * @brief Return the exponential integral @f$ E_n(x) @f$ + * by continued fractions. + * + * The exponential integral is given by + * \f[ + * E_n(x) = \int_{1}^\infty \frac{e^{-xt}}{t^n} dt + * \f] + * + * @param __n The order of the exponential integral function. + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + _Tp + __expint_En_cont_frac(const unsigned int __n, const _Tp __x) + { + const unsigned int __max_iter = 100; + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + const _Tp __fp_min = std::numeric_limits<_Tp>::min(); + const int __nm1 = __n - 1; + _Tp __b = __x + _Tp(__n); + _Tp __c = _Tp(1) / __fp_min; + _Tp __d = _Tp(1) / __b; + _Tp __h = __d; + for ( unsigned int __i = 1; __i <= __max_iter; ++__i ) + { + _Tp __a = -_Tp(__i * (__nm1 + __i)); + __b += _Tp(2); + __d = _Tp(1) / (__a * __d + __b); + __c = __b + __a / __c; + const _Tp __del = __c * __d; + __h *= __del; + if (std::abs(__del - _Tp(1)) < __eps) + { + const _Tp __ans = __h * std::exp(-__x); + return __ans; + } + } + std::__throw_runtime_error(__N("Continued fraction failed " + "in __expint_En_cont_frac.")); + } + + + /** + * @brief Return the exponential integral @f$ E_n(x) @f$ + * by recursion. Use upward recursion for @f$ x < n @f$ + * and downward recursion (Miller's algorithm) otherwise. + * + * The exponential integral is given by + * \f[ + * E_n(x) = \int_{1}^\infty \frac{e^{-xt}}{t^n} dt + * \f] + * + * @param __n The order of the exponential integral function. + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + _Tp + __expint_En_recursion(const unsigned int __n, const _Tp __x) + { + _Tp __En; + _Tp __E1 = __expint_E1(__x); + if (__x < _Tp(__n)) + { + // Forward recursion is stable only for n < x. + __En = __E1; + for (unsigned int __j = 2; __j < __n; ++__j) + __En = (std::exp(-__x) - __x * __En) / _Tp(__j - 1); + } + else + { + // Backward recursion is stable only for n >= x. + __En = _Tp(1); + const int __N = __n + 20; // TODO: Check this starting number. + _Tp __save = _Tp(0); + for (int __j = __N; __j > 0; --__j) + { + __En = (std::exp(-__x) - __j * __En) / __x; + if (__j == __n) + __save = __En; + } + _Tp __norm = __En / __E1; + __En /= __norm; + } + + return __En; + } + + /** + * @brief Return the exponential integral @f$ Ei(x) @f$ + * by series summation. + * + * The exponential integral is given by + * \f[ + * Ei(x) = -\int_{-x}^\infty \frac{e^t}{t} dt + * \f] + * + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + _Tp + __expint_Ei_series(const _Tp __x) + { + _Tp __term = _Tp(1); + _Tp __sum = _Tp(0); + const unsigned int __max_iter = 1000; + for (unsigned int __i = 1; __i < __max_iter; ++__i) + { + __term *= __x / __i; + __sum += __term / __i; + if (__term < std::numeric_limits<_Tp>::epsilon() * __sum) + break; + } + + return __numeric_constants<_Tp>::__gamma_e() + __sum + std::log(__x); + } + + + /** + * @brief Return the exponential integral @f$ Ei(x) @f$ + * by asymptotic expansion. + * + * The exponential integral is given by + * \f[ + * Ei(x) = -\int_{-x}^\infty \frac{e^t}{t} dt + * \f] + * + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + _Tp + __expint_Ei_asymp(const _Tp __x) + { + _Tp __term = _Tp(1); + _Tp __sum = _Tp(1); + const unsigned int __max_iter = 1000; + for (unsigned int __i = 1; __i < __max_iter; ++__i) + { + _Tp __prev = __term; + __term *= __i / __x; + if (__term < std::numeric_limits<_Tp>::epsilon()) + break; + if (__term >= __prev) + break; + __sum += __term; + } + + return std::exp(__x) * __sum / __x; + } + + + /** + * @brief Return the exponential integral @f$ Ei(x) @f$. + * + * The exponential integral is given by + * \f[ + * Ei(x) = -\int_{-x}^\infty \frac{e^t}{t} dt + * \f] + * + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + _Tp + __expint_Ei(const _Tp __x) + { + if (__x < _Tp(0)) + return -__expint_E1(-__x); + else if (__x < -std::log(std::numeric_limits<_Tp>::epsilon())) + return __expint_Ei_series(__x); + else + return __expint_Ei_asymp(__x); + } + + + /** + * @brief Return the exponential integral @f$ E_1(x) @f$. + * + * The exponential integral is given by + * \f[ + * E_1(x) = \int_{1}^\infty \frac{e^{-xt}}{t} dt + * \f] + * + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + _Tp + __expint_E1(const _Tp __x) + { + if (__x < _Tp(0)) + return -__expint_Ei(-__x); + else if (__x < _Tp(1)) + return __expint_E1_series(__x); + else if (__x < _Tp(100)) // TODO: Find a good asymptotic switch point. + return __expint_En_cont_frac(1, __x); + else + return __expint_E1_asymp(__x); + } + + + /** + * @brief Return the exponential integral @f$ E_n(x) @f$ + * for large argument. + * + * The exponential integral is given by + * \f[ + * E_n(x) = \int_{1}^\infty \frac{e^{-xt}}{t^n} dt + * \f] + * + * This is something of an extension. + * + * @param __n The order of the exponential integral function. + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + _Tp + __expint_asymp(const unsigned int __n, const _Tp __x) + { + _Tp __term = _Tp(1); + _Tp __sum = _Tp(1); + for (unsigned int __i = 1; __i <= __n; ++__i) + { + _Tp __prev = __term; + __term *= -(__n - __i + 1) / __x; + if (std::abs(__term) > std::abs(__prev)) + break; + __sum += __term; + } + + return std::exp(-__x) * __sum / __x; + } + + + /** + * @brief Return the exponential integral @f$ E_n(x) @f$ + * for large order. + * + * The exponential integral is given by + * \f[ + * E_n(x) = \int_{1}^\infty \frac{e^{-xt}}{t^n} dt + * \f] + * + * This is something of an extension. + * + * @param __n The order of the exponential integral function. + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + _Tp + __expint_large_n(const unsigned int __n, const _Tp __x) + { + const _Tp __xpn = __x + __n; + const _Tp __xpn2 = __xpn * __xpn; + _Tp __term = _Tp(1); + _Tp __sum = _Tp(1); + for (unsigned int __i = 1; __i <= __n; ++__i) + { + _Tp __prev = __term; + __term *= (__n - 2 * (__i - 1) * __x) / __xpn2; + if (std::abs(__term) < std::numeric_limits<_Tp>::epsilon()) + break; + __sum += __term; + } + + return std::exp(-__x) * __sum / __xpn; + } + + + /** + * @brief Return the exponential integral @f$ E_n(x) @f$. + * + * The exponential integral is given by + * \f[ + * E_n(x) = \int_{1}^\infty \frac{e^{-xt}}{t^n} dt + * \f] + * This is something of an extension. + * + * @param __n The order of the exponential integral function. + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + _Tp + __expint(const unsigned int __n, const _Tp __x) + { + // Return NaN on NaN input. + if (__isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__n <= 1 && __x == _Tp(0)) + return std::numeric_limits<_Tp>::infinity(); + else + { + _Tp __E0 = std::exp(__x) / __x; + if (__n == 0) + return __E0; + + _Tp __E1 = __expint_E1(__x); + if (__n == 1) + return __E1; + + if (__x == _Tp(0)) + return _Tp(1) / static_cast<_Tp>(__n - 1); + + _Tp __En = __expint_En_recursion(__n, __x); + + return __En; + } + } + + + /** + * @brief Return the exponential integral @f$ Ei(x) @f$. + * + * The exponential integral is given by + * \f[ + * Ei(x) = -\int_{-x}^\infty \frac{e^t}{t} dt + * \f] + * + * @param __x The argument of the exponential integral function. + * @return The exponential integral. + */ + template<typename _Tp> + inline _Tp + __expint(const _Tp __x) + { + if (__isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else + return __expint_Ei(__x); + } + + } // namespace std::tr1::__detail +} +} + +#endif // _GLIBCXX_TR1_EXP_INTEGRAL_TCC diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/fenv.h b/gcc-4.4.3/libstdc++-v3/include/tr1/fenv.h new file mode 100644 index 000000000..118630e49 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/fenv.h @@ -0,0 +1,34 @@ +// TR1 fenv.h -*- C++ -*- + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/fenv.h + * This is a TR1 C++ Library header. + */ + +#ifndef _TR1_FENV_H +#define _TR1_FENV_H 1 + +#include <tr1/cfenv> + +#endif diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/float.h b/gcc-4.4.3/libstdc++-v3/include/tr1/float.h new file mode 100644 index 000000000..bbeff6e3a --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/float.h @@ -0,0 +1,34 @@ +// TR1 float.h -*- C++ -*- + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/float.h + * This is a TR1 C++ Library header. + */ + +#ifndef _TR1_FLOAT_H +#define _TR1_FLOAT_H 1 + +#include <tr1/cfloat> + +#endif diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/functional b/gcc-4.4.3/libstdc++-v3/include/tr1/functional new file mode 100644 index 000000000..3deaa5ea5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/functional @@ -0,0 +1,63 @@ +// TR1 functional header -*- C++ -*- + +// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/functional + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_FUNCTIONAL +#define _GLIBCXX_TR1_FUNCTIONAL 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <bits/c++config.h> +#include <bits/stl_function.h> + +#include <typeinfo> +#include <new> +#include <tr1/tuple> +#include <tr1/type_traits> +#include <bits/stringfwd.h> +#include <tr1/functional_hash.h> +#include <ext/type_traits.h> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/functional> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/functional> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_FUNCTIONAL diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/functional_hash.h b/gcc-4.4.3/libstdc++-v3/include/tr1/functional_hash.h new file mode 100644 index 000000000..933ded9ac --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/functional_hash.h @@ -0,0 +1,53 @@ +// TR1 functional_hash.h header -*- C++ -*- + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/functional_hash.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +#ifndef _GLIBCXX_TR1_FUNCTIONAL_HASH_H +#define _GLIBCXX_TR1_FUNCTIONAL_HASH_H 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/functional_hash.h> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/functional_hash.h> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_FUNCTIONAL_HASH_H diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/gamma.tcc b/gcc-4.4.3/libstdc++-v3/include/tr1/gamma.tcc new file mode 100644 index 000000000..f456da32b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/gamma.tcc @@ -0,0 +1,471 @@ +// Special functions -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/gamma.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +// +// ISO C++ 14882 TR1: 5.2 Special functions +// + +// Written by Edward Smith-Rowland based on: +// (1) Handbook of Mathematical Functions, +// ed. Milton Abramowitz and Irene A. Stegun, +// Dover Publications, +// Section 6, pp. 253-266 +// (2) The Gnu Scientific Library, http://www.gnu.org/software/gsl +// (3) Numerical Recipes in C, by W. H. Press, S. A. Teukolsky, +// W. T. Vetterling, B. P. Flannery, Cambridge University Press (1992), +// 2nd ed, pp. 213-216 +// (4) Gamma, Exploring Euler's Constant, Julian Havil, +// Princeton, 2003. + +#ifndef _TR1_GAMMA_TCC +#define _TR1_GAMMA_TCC 1 + +#include "special_function_util.h" + +namespace std +{ +namespace tr1 +{ + // Implementation-space details. + namespace __detail + { + + /** + * @brief This returns Bernoulli numbers from a table or by summation + * for larger values. + * + * Recursion is unstable. + * + * @param __n the order n of the Bernoulli number. + * @return The Bernoulli number of order n. + */ + template <typename _Tp> + _Tp __bernoulli_series(unsigned int __n) + { + + static const _Tp __num[28] = { + _Tp(1UL), -_Tp(1UL) / _Tp(2UL), + _Tp(1UL) / _Tp(6UL), _Tp(0UL), + -_Tp(1UL) / _Tp(30UL), _Tp(0UL), + _Tp(1UL) / _Tp(42UL), _Tp(0UL), + -_Tp(1UL) / _Tp(30UL), _Tp(0UL), + _Tp(5UL) / _Tp(66UL), _Tp(0UL), + -_Tp(691UL) / _Tp(2730UL), _Tp(0UL), + _Tp(7UL) / _Tp(6UL), _Tp(0UL), + -_Tp(3617UL) / _Tp(510UL), _Tp(0UL), + _Tp(43867UL) / _Tp(798UL), _Tp(0UL), + -_Tp(174611) / _Tp(330UL), _Tp(0UL), + _Tp(854513UL) / _Tp(138UL), _Tp(0UL), + -_Tp(236364091UL) / _Tp(2730UL), _Tp(0UL), + _Tp(8553103UL) / _Tp(6UL), _Tp(0UL) + }; + + if (__n == 0) + return _Tp(1); + + if (__n == 1) + return -_Tp(1) / _Tp(2); + + // Take care of the rest of the odd ones. + if (__n % 2 == 1) + return _Tp(0); + + // Take care of some small evens that are painful for the series. + if (__n < 28) + return __num[__n]; + + + _Tp __fact = _Tp(1); + if ((__n / 2) % 2 == 0) + __fact *= _Tp(-1); + for (unsigned int __k = 1; __k <= __n; ++__k) + __fact *= __k / (_Tp(2) * __numeric_constants<_Tp>::__pi()); + __fact *= _Tp(2); + + _Tp __sum = _Tp(0); + for (unsigned int __i = 1; __i < 1000; ++__i) + { + _Tp __term = std::pow(_Tp(__i), -_Tp(__n)); + if (__term < std::numeric_limits<_Tp>::epsilon()) + break; + __sum += __term; + } + + return __fact * __sum; + } + + + /** + * @brief This returns Bernoulli number \f$B_n\f$. + * + * @param __n the order n of the Bernoulli number. + * @return The Bernoulli number of order n. + */ + template<typename _Tp> + inline _Tp + __bernoulli(const int __n) + { + return __bernoulli_series<_Tp>(__n); + } + + + /** + * @brief Return \f$log(\Gamma(x))\f$ by asymptotic expansion + * with Bernoulli number coefficients. This is like + * Sterling's approximation. + * + * @param __x The argument of the log of the gamma function. + * @return The logarithm of the gamma function. + */ + template<typename _Tp> + _Tp + __log_gamma_bernoulli(const _Tp __x) + { + _Tp __lg = (__x - _Tp(0.5L)) * std::log(__x) - __x + + _Tp(0.5L) * std::log(_Tp(2) + * __numeric_constants<_Tp>::__pi()); + + const _Tp __xx = __x * __x; + _Tp __help = _Tp(1) / __x; + for ( unsigned int __i = 1; __i < 20; ++__i ) + { + const _Tp __2i = _Tp(2 * __i); + __help /= __2i * (__2i - _Tp(1)) * __xx; + __lg += __bernoulli<_Tp>(2 * __i) * __help; + } + + return __lg; + } + + + /** + * @brief Return \f$log(\Gamma(x))\f$ by the Lanczos method. + * This method dominates all others on the positive axis I think. + * + * @param __x The argument of the log of the gamma function. + * @return The logarithm of the gamma function. + */ + template<typename _Tp> + _Tp + __log_gamma_lanczos(const _Tp __x) + { + const _Tp __xm1 = __x - _Tp(1); + + static const _Tp __lanczos_cheb_7[9] = { + _Tp( 0.99999999999980993227684700473478L), + _Tp( 676.520368121885098567009190444019L), + _Tp(-1259.13921672240287047156078755283L), + _Tp( 771.3234287776530788486528258894L), + _Tp(-176.61502916214059906584551354L), + _Tp( 12.507343278686904814458936853L), + _Tp(-0.13857109526572011689554707L), + _Tp( 9.984369578019570859563e-6L), + _Tp( 1.50563273514931155834e-7L) + }; + + static const _Tp __LOGROOT2PI + = _Tp(0.9189385332046727417803297364056176L); + + _Tp __sum = __lanczos_cheb_7[0]; + for(unsigned int __k = 1; __k < 9; ++__k) + __sum += __lanczos_cheb_7[__k] / (__xm1 + __k); + + const _Tp __term1 = (__xm1 + _Tp(0.5L)) + * std::log((__xm1 + _Tp(7.5L)) + / __numeric_constants<_Tp>::__euler()); + const _Tp __term2 = __LOGROOT2PI + std::log(__sum); + const _Tp __result = __term1 + (__term2 - _Tp(7)); + + return __result; + } + + + /** + * @brief Return \f$ log(|\Gamma(x)|) \f$. + * This will return values even for \f$ x < 0 \f$. + * To recover the sign of \f$ \Gamma(x) \f$ for + * any argument use @a __log_gamma_sign. + * + * @param __x The argument of the log of the gamma function. + * @return The logarithm of the gamma function. + */ + template<typename _Tp> + _Tp + __log_gamma(const _Tp __x) + { + if (__x > _Tp(0.5L)) + return __log_gamma_lanczos(__x); + else + { + const _Tp __sin_fact + = std::abs(std::sin(__numeric_constants<_Tp>::__pi() * __x)); + if (__sin_fact == _Tp(0)) + std::__throw_domain_error(__N("Argument is nonpositive integer " + "in __log_gamma")); + return __numeric_constants<_Tp>::__lnpi() + - std::log(__sin_fact) + - __log_gamma_lanczos(_Tp(1) - __x); + } + } + + + /** + * @brief Return the sign of \f$ \Gamma(x) \f$. + * At nonpositive integers zero is returned. + * + * @param __x The argument of the gamma function. + * @return The sign of the gamma function. + */ + template<typename _Tp> + _Tp + __log_gamma_sign(const _Tp __x) + { + if (__x > _Tp(0)) + return _Tp(1); + else + { + const _Tp __sin_fact + = std::sin(__numeric_constants<_Tp>::__pi() * __x); + if (__sin_fact > _Tp(0)) + return (1); + else if (__sin_fact < _Tp(0)) + return -_Tp(1); + else + return _Tp(0); + } + } + + + /** + * @brief Return the logarithm of the binomial coefficient. + * The binomial coefficient is given by: + * @f[ + * \left( \right) = \frac{n!}{(n-k)! k!} + * @f] + * + * @param __n The first argument of the binomial coefficient. + * @param __k The second argument of the binomial coefficient. + * @return The binomial coefficient. + */ + template<typename _Tp> + _Tp + __log_bincoef(const unsigned int __n, const unsigned int __k) + { + // Max e exponent before overflow. + static const _Tp __max_bincoeff + = std::numeric_limits<_Tp>::max_exponent10 + * std::log(_Tp(10)) - _Tp(1); +#if _GLIBCXX_USE_C99_MATH_TR1 + _Tp __coeff = std::tr1::lgamma(_Tp(1 + __n)) + - std::tr1::lgamma(_Tp(1 + __k)) + - std::tr1::lgamma(_Tp(1 + __n - __k)); +#else + _Tp __coeff = __log_gamma(_Tp(1 + __n)) + - __log_gamma(_Tp(1 + __k)) + - __log_gamma(_Tp(1 + __n - __k)); +#endif + } + + + /** + * @brief Return the binomial coefficient. + * The binomial coefficient is given by: + * @f[ + * \left( \right) = \frac{n!}{(n-k)! k!} + * @f] + * + * @param __n The first argument of the binomial coefficient. + * @param __k The second argument of the binomial coefficient. + * @return The binomial coefficient. + */ + template<typename _Tp> + _Tp + __bincoef(const unsigned int __n, const unsigned int __k) + { + // Max e exponent before overflow. + static const _Tp __max_bincoeff + = std::numeric_limits<_Tp>::max_exponent10 + * std::log(_Tp(10)) - _Tp(1); + + const _Tp __log_coeff = __log_bincoef<_Tp>(__n, __k); + if (__log_coeff > __max_bincoeff) + return std::numeric_limits<_Tp>::quiet_NaN(); + else + return std::exp(__log_coeff); + } + + + /** + * @brief Return \f$ \Gamma(x) \f$. + * + * @param __x The argument of the gamma function. + * @return The gamma function. + */ + template<typename _Tp> + inline _Tp + __gamma(const _Tp __x) + { + return std::exp(__log_gamma(__x)); + } + + + /** + * @brief Return the digamma function by series expansion. + * The digamma or @f$ \psi(x) @f$ function is defined by + * @f[ + * \psi(x) = \frac{\Gamma'(x)}{\Gamma(x)} + * @f] + * + * The series is given by: + * @f[ + * \psi(x) = -\gamma_E - \frac{1}{x} + * \sum_{k=1}^{\infty} \frac{x}{k(x + k)} + * @f] + */ + template<typename _Tp> + _Tp + __psi_series(const _Tp __x) + { + _Tp __sum = -__numeric_constants<_Tp>::__gamma_e() - _Tp(1) / __x; + const unsigned int __max_iter = 100000; + for (unsigned int __k = 1; __k < __max_iter; ++__k) + { + const _Tp __term = __x / (__k * (__k + __x)); + __sum += __term; + if (std::abs(__term / __sum) < std::numeric_limits<_Tp>::epsilon()) + break; + } + return __sum; + } + + + /** + * @brief Return the digamma function for large argument. + * The digamma or @f$ \psi(x) @f$ function is defined by + * @f[ + * \psi(x) = \frac{\Gamma'(x)}{\Gamma(x)} + * @f] + * + * The asymptotic series is given by: + * @f[ + * \psi(x) = \ln(x) - \frac{1}{2x} + * - \sum_{n=1}^{\infty} \frac{B_{2n}}{2 n x^{2n}} + * @f] + */ + template<typename _Tp> + _Tp + __psi_asymp(const _Tp __x) + { + _Tp __sum = std::log(__x) - _Tp(0.5L) / __x; + const _Tp __xx = __x * __x; + _Tp __xp = __xx; + const unsigned int __max_iter = 100; + for (unsigned int __k = 1; __k < __max_iter; ++__k) + { + const _Tp __term = __bernoulli<_Tp>(2 * __k) / (2 * __k * __xp); + __sum -= __term; + if (std::abs(__term / __sum) < std::numeric_limits<_Tp>::epsilon()) + break; + __xp *= __xx; + } + return __sum; + } + + + /** + * @brief Return the digamma function. + * The digamma or @f$ \psi(x) @f$ function is defined by + * @f[ + * \psi(x) = \frac{\Gamma'(x)}{\Gamma(x)} + * @f] + * For negative argument the reflection formula is used: + * @f[ + * \psi(x) = \psi(1-x) - \pi \cot(\pi x) + * @f] + */ + template<typename _Tp> + _Tp + __psi(const _Tp __x) + { + const int __n = static_cast<int>(__x + 0.5L); + const _Tp __eps = _Tp(4) * std::numeric_limits<_Tp>::epsilon(); + if (__n <= 0 && std::abs(__x - _Tp(__n)) < __eps) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__x < _Tp(0)) + { + const _Tp __pi = __numeric_constants<_Tp>::__pi(); + return __psi(_Tp(1) - __x) + - __pi * std::cos(__pi * __x) / std::sin(__pi * __x); + } + else if (__x > _Tp(100)) + return __psi_asymp(__x); + else + return __psi_series(__x); + } + + + /** + * @brief Return the polygamma function @f$ \psi^{(n)}(x) @f$. + * + * The polygamma function is related to the Hurwitz zeta function: + * @f[ + * \psi^{(n)}(x) = (-1)^{n+1} m! \zeta(m+1,x) + * @f] + */ + template<typename _Tp> + _Tp + __psi(const unsigned int __n, const _Tp __x) + { + if (__x <= _Tp(0)) + std::__throw_domain_error(__N("Argument out of range " + "in __psi")); + else if (__n == 0) + return __psi(__x); + else + { + const _Tp __hzeta = __hurwitz_zeta(_Tp(__n + 1), __x); +#if _GLIBCXX_USE_C99_MATH_TR1 + const _Tp __ln_nfact = std::tr1::lgamma(_Tp(__n + 1)); +#else + const _Tp __ln_nfact = __log_gamma(_Tp(__n + 1)); +#endif + _Tp __result = std::exp(__ln_nfact) * __hzeta; + if (__n % 2 == 1) + __result = -__result; + return __result; + } + } + + } // namespace std::tr1::__detail +} +} + +#endif // _TR1_GAMMA_TCC + diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/hashtable.h b/gcc-4.4.3/libstdc++-v3/include/tr1/hashtable.h new file mode 100644 index 000000000..22fdbff6f --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/hashtable.h @@ -0,0 +1,53 @@ +// TR1 hashtable.h header -*- C++ -*- + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/hashtable.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +#ifndef _GLIBCXX_TR1_HASHTABLE_H +#define _GLIBCXX_TR1_HASHTABLE_H 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/hashtable> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/hashtable> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_HASHTABLE_H diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/hypergeometric.tcc b/gcc-4.4.3/libstdc++-v3/include/tr1/hypergeometric.tcc new file mode 100644 index 000000000..c975afa59 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/hypergeometric.tcc @@ -0,0 +1,774 @@ +// Special functions -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/hypergeometric.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +// +// ISO C++ 14882 TR1: 5.2 Special functions +// + +// Written by Edward Smith-Rowland based: +// (1) Handbook of Mathematical Functions, +// ed. Milton Abramowitz and Irene A. Stegun, +// Dover Publications, +// Section 6, pp. 555-566 +// (2) The Gnu Scientific Library, http://www.gnu.org/software/gsl + +#ifndef _GLIBCXX_TR1_HYPERGEOMETRIC_TCC +#define _GLIBCXX_TR1_HYPERGEOMETRIC_TCC 1 + +namespace std +{ +namespace tr1 +{ + + // [5.2] Special functions + + // Implementation-space details. + namespace __detail + { + + /** + * @brief This routine returns the confluent hypergeometric function + * by series expansion. + * + * @f[ + * _1F_1(a;c;x) = \frac{\Gamma(c)}{\Gamma(a)} + * \sum_{n=0}^{\infty} + * \frac{\Gamma(a+n)}{\Gamma(c+n)} + * \frac{x^n}{n!} + * @f] + * + * If a and b are integers and a < 0 and either b > 0 or b < a then the + * series is a polynomial with a finite number of terms. If b is an integer + * and b <= 0 the confluent hypergeometric function is undefined. + * + * @param __a The "numerator" parameter. + * @param __c The "denominator" parameter. + * @param __x The argument of the confluent hypergeometric function. + * @return The confluent hypergeometric function. + */ + template<typename _Tp> + _Tp + __conf_hyperg_series(const _Tp __a, const _Tp __c, const _Tp __x) + { + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + + _Tp __term = _Tp(1); + _Tp __Fac = _Tp(1); + const unsigned int __max_iter = 100000; + unsigned int __i; + for (__i = 0; __i < __max_iter; ++__i) + { + __term *= (__a + _Tp(__i)) * __x + / ((__c + _Tp(__i)) * _Tp(1 + __i)); + if (std::abs(__term) < __eps) + { + break; + } + __Fac += __term; + } + if (__i == __max_iter) + std::__throw_runtime_error(__N("Series failed to converge " + "in __conf_hyperg_series.")); + + return __Fac; + } + + + /** + * @brief Return the hypogeometric function @f$ _2F_1(a,b;c;x) @f$ + * by an iterative procedure described in + * Luke, Algorithms for the Computation of Mathematical Functions. + * + * Like the case of the 2F1 rational approximations, these are + * probably guaranteed to converge for x < 0, barring gross + * numerical instability in the pre-asymptotic regime. + */ + template<typename _Tp> + _Tp + __conf_hyperg_luke(const _Tp __a, const _Tp __c, const _Tp __xin) + { + const _Tp __big = std::pow(std::numeric_limits<_Tp>::max(), _Tp(0.16L)); + const int __nmax = 20000; + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + const _Tp __x = -__xin; + const _Tp __x3 = __x * __x * __x; + const _Tp __t0 = __a / __c; + const _Tp __t1 = (__a + _Tp(1)) / (_Tp(2) * __c); + const _Tp __t2 = (__a + _Tp(2)) / (_Tp(2) * (__c + _Tp(1))); + _Tp __F = _Tp(1); + _Tp __prec; + + _Tp __Bnm3 = _Tp(1); + _Tp __Bnm2 = _Tp(1) + __t1 * __x; + _Tp __Bnm1 = _Tp(1) + __t2 * __x * (_Tp(1) + __t1 / _Tp(3) * __x); + + _Tp __Anm3 = _Tp(1); + _Tp __Anm2 = __Bnm2 - __t0 * __x; + _Tp __Anm1 = __Bnm1 - __t0 * (_Tp(1) + __t2 * __x) * __x + + __t0 * __t1 * (__c / (__c + _Tp(1))) * __x * __x; + + int __n = 3; + while(1) + { + _Tp __npam1 = _Tp(__n - 1) + __a; + _Tp __npcm1 = _Tp(__n - 1) + __c; + _Tp __npam2 = _Tp(__n - 2) + __a; + _Tp __npcm2 = _Tp(__n - 2) + __c; + _Tp __tnm1 = _Tp(2 * __n - 1); + _Tp __tnm3 = _Tp(2 * __n - 3); + _Tp __tnm5 = _Tp(2 * __n - 5); + _Tp __F1 = (_Tp(__n - 2) - __a) / (_Tp(2) * __tnm3 * __npcm1); + _Tp __F2 = (_Tp(__n) + __a) * __npam1 + / (_Tp(4) * __tnm1 * __tnm3 * __npcm2 * __npcm1); + _Tp __F3 = -__npam2 * __npam1 * (_Tp(__n - 2) - __a) + / (_Tp(8) * __tnm3 * __tnm3 * __tnm5 + * (_Tp(__n - 3) + __c) * __npcm2 * __npcm1); + _Tp __E = -__npam1 * (_Tp(__n - 1) - __c) + / (_Tp(2) * __tnm3 * __npcm2 * __npcm1); + + _Tp __An = (_Tp(1) + __F1 * __x) * __Anm1 + + (__E + __F2 * __x) * __x * __Anm2 + __F3 * __x3 * __Anm3; + _Tp __Bn = (_Tp(1) + __F1 * __x) * __Bnm1 + + (__E + __F2 * __x) * __x * __Bnm2 + __F3 * __x3 * __Bnm3; + _Tp __r = __An / __Bn; + + __prec = std::abs((__F - __r) / __F); + __F = __r; + + if (__prec < __eps || __n > __nmax) + break; + + if (std::abs(__An) > __big || std::abs(__Bn) > __big) + { + __An /= __big; + __Bn /= __big; + __Anm1 /= __big; + __Bnm1 /= __big; + __Anm2 /= __big; + __Bnm2 /= __big; + __Anm3 /= __big; + __Bnm3 /= __big; + } + else if (std::abs(__An) < _Tp(1) / __big + || std::abs(__Bn) < _Tp(1) / __big) + { + __An *= __big; + __Bn *= __big; + __Anm1 *= __big; + __Bnm1 *= __big; + __Anm2 *= __big; + __Bnm2 *= __big; + __Anm3 *= __big; + __Bnm3 *= __big; + } + + ++__n; + __Bnm3 = __Bnm2; + __Bnm2 = __Bnm1; + __Bnm1 = __Bn; + __Anm3 = __Anm2; + __Anm2 = __Anm1; + __Anm1 = __An; + } + + if (__n >= __nmax) + std::__throw_runtime_error(__N("Iteration failed to converge " + "in __conf_hyperg_luke.")); + + return __F; + } + + + /** + * @brief Return the confluent hypogeometric function + * @f$ _1F_1(a;c;x) @f$. + * + * @todo Handle b == nonpositive integer blowup - return NaN. + * + * @param __a The "numerator" parameter. + * @param __c The "denominator" parameter. + * @param __x The argument of the confluent hypergeometric function. + * @return The confluent hypergeometric function. + */ + template<typename _Tp> + inline _Tp + __conf_hyperg(const _Tp __a, const _Tp __c, const _Tp __x) + { +#if _GLIBCXX_USE_C99_MATH_TR1 + const _Tp __c_nint = std::tr1::nearbyint(__c); +#else + const _Tp __c_nint = static_cast<int>(__c + _Tp(0.5L)); +#endif + if (__isnan(__a) || __isnan(__c) || __isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__c_nint == __c && __c_nint <= 0) + return std::numeric_limits<_Tp>::infinity(); + else if (__a == _Tp(0)) + return _Tp(1); + else if (__c == __a) + return std::exp(__x); + else if (__x < _Tp(0)) + return __conf_hyperg_luke(__a, __c, __x); + else + return __conf_hyperg_series(__a, __c, __x); + } + + + /** + * @brief Return the hypogeometric function @f$ _2F_1(a,b;c;x) @f$ + * by series expansion. + * + * The hypogeometric function is defined by + * @f[ + * _2F_1(a,b;c;x) = \frac{\Gamma(c)}{\Gamma(a)\Gamma(b)} + * \sum_{n=0}^{\infty} + * \frac{\Gamma(a+n)\Gamma(b+n)}{\Gamma(c+n)} + * \frac{x^n}{n!} + * @f] + * + * This works and it's pretty fast. + * + * @param __a The first "numerator" parameter. + * @param __a The second "numerator" parameter. + * @param __c The "denominator" parameter. + * @param __x The argument of the confluent hypergeometric function. + * @return The confluent hypergeometric function. + */ + template<typename _Tp> + _Tp + __hyperg_series(const _Tp __a, const _Tp __b, + const _Tp __c, const _Tp __x) + { + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + + _Tp __term = _Tp(1); + _Tp __Fabc = _Tp(1); + const unsigned int __max_iter = 100000; + unsigned int __i; + for (__i = 0; __i < __max_iter; ++__i) + { + __term *= (__a + _Tp(__i)) * (__b + _Tp(__i)) * __x + / ((__c + _Tp(__i)) * _Tp(1 + __i)); + if (std::abs(__term) < __eps) + { + break; + } + __Fabc += __term; + } + if (__i == __max_iter) + std::__throw_runtime_error(__N("Series failed to converge " + "in __hyperg_series.")); + + return __Fabc; + } + + + /** + * @brief Return the hypogeometric function @f$ _2F_1(a,b;c;x) @f$ + * by an iterative procedure described in + * Luke, Algorithms for the Computation of Mathematical Functions. + */ + template<typename _Tp> + _Tp + __hyperg_luke(const _Tp __a, const _Tp __b, const _Tp __c, + const _Tp __xin) + { + const _Tp __big = std::pow(std::numeric_limits<_Tp>::max(), _Tp(0.16L)); + const int __nmax = 20000; + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + const _Tp __x = -__xin; + const _Tp __x3 = __x * __x * __x; + const _Tp __t0 = __a * __b / __c; + const _Tp __t1 = (__a + _Tp(1)) * (__b + _Tp(1)) / (_Tp(2) * __c); + const _Tp __t2 = (__a + _Tp(2)) * (__b + _Tp(2)) + / (_Tp(2) * (__c + _Tp(1))); + + _Tp __F = _Tp(1); + + _Tp __Bnm3 = _Tp(1); + _Tp __Bnm2 = _Tp(1) + __t1 * __x; + _Tp __Bnm1 = _Tp(1) + __t2 * __x * (_Tp(1) + __t1 / _Tp(3) * __x); + + _Tp __Anm3 = _Tp(1); + _Tp __Anm2 = __Bnm2 - __t0 * __x; + _Tp __Anm1 = __Bnm1 - __t0 * (_Tp(1) + __t2 * __x) * __x + + __t0 * __t1 * (__c / (__c + _Tp(1))) * __x * __x; + + int __n = 3; + while (1) + { + const _Tp __npam1 = _Tp(__n - 1) + __a; + const _Tp __npbm1 = _Tp(__n - 1) + __b; + const _Tp __npcm1 = _Tp(__n - 1) + __c; + const _Tp __npam2 = _Tp(__n - 2) + __a; + const _Tp __npbm2 = _Tp(__n - 2) + __b; + const _Tp __npcm2 = _Tp(__n - 2) + __c; + const _Tp __tnm1 = _Tp(2 * __n - 1); + const _Tp __tnm3 = _Tp(2 * __n - 3); + const _Tp __tnm5 = _Tp(2 * __n - 5); + const _Tp __n2 = __n * __n; + const _Tp __F1 = (_Tp(3) * __n2 + (__a + __b - _Tp(6)) * __n + + _Tp(2) - __a * __b - _Tp(2) * (__a + __b)) + / (_Tp(2) * __tnm3 * __npcm1); + const _Tp __F2 = -(_Tp(3) * __n2 - (__a + __b + _Tp(6)) * __n + + _Tp(2) - __a * __b) * __npam1 * __npbm1 + / (_Tp(4) * __tnm1 * __tnm3 * __npcm2 * __npcm1); + const _Tp __F3 = (__npam2 * __npam1 * __npbm2 * __npbm1 + * (_Tp(__n - 2) - __a) * (_Tp(__n - 2) - __b)) + / (_Tp(8) * __tnm3 * __tnm3 * __tnm5 + * (_Tp(__n - 3) + __c) * __npcm2 * __npcm1); + const _Tp __E = -__npam1 * __npbm1 * (_Tp(__n - 1) - __c) + / (_Tp(2) * __tnm3 * __npcm2 * __npcm1); + + _Tp __An = (_Tp(1) + __F1 * __x) * __Anm1 + + (__E + __F2 * __x) * __x * __Anm2 + __F3 * __x3 * __Anm3; + _Tp __Bn = (_Tp(1) + __F1 * __x) * __Bnm1 + + (__E + __F2 * __x) * __x * __Bnm2 + __F3 * __x3 * __Bnm3; + const _Tp __r = __An / __Bn; + + const _Tp __prec = std::abs((__F - __r) / __F); + __F = __r; + + if (__prec < __eps || __n > __nmax) + break; + + if (std::abs(__An) > __big || std::abs(__Bn) > __big) + { + __An /= __big; + __Bn /= __big; + __Anm1 /= __big; + __Bnm1 /= __big; + __Anm2 /= __big; + __Bnm2 /= __big; + __Anm3 /= __big; + __Bnm3 /= __big; + } + else if (std::abs(__An) < _Tp(1) / __big + || std::abs(__Bn) < _Tp(1) / __big) + { + __An *= __big; + __Bn *= __big; + __Anm1 *= __big; + __Bnm1 *= __big; + __Anm2 *= __big; + __Bnm2 *= __big; + __Anm3 *= __big; + __Bnm3 *= __big; + } + + ++__n; + __Bnm3 = __Bnm2; + __Bnm2 = __Bnm1; + __Bnm1 = __Bn; + __Anm3 = __Anm2; + __Anm2 = __Anm1; + __Anm1 = __An; + } + + if (__n >= __nmax) + std::__throw_runtime_error(__N("Iteration failed to converge " + "in __hyperg_luke.")); + + return __F; + } + + + /** + * @brief Return the hypogeometric function @f$ _2F_1(a,b;c;x) @f$ by the reflection + * formulae in Abramowitz & Stegun formula 15.3.6 for d = c - a - b not integral + * and formula 15.3.11 for d = c - a - b integral. + * This assumes a, b, c != negative integer. + * + * The hypogeometric function is defined by + * @f[ + * _2F_1(a,b;c;x) = \frac{\Gamma(c)}{\Gamma(a)\Gamma(b)} + * \sum_{n=0}^{\infty} + * \frac{\Gamma(a+n)\Gamma(b+n)}{\Gamma(c+n)} + * \frac{x^n}{n!} + * @f] + * + * The reflection formula for nonintegral @f$ d = c - a - b @f$ is: + * @f[ + * _2F_1(a,b;c;x) = \frac{\Gamma(c)\Gamma(d)}{\Gamma(c-a)\Gamma(c-b)} + * _2F_1(a,b;1-d;1-x) + * + \frac{\Gamma(c)\Gamma(-d)}{\Gamma(a)\Gamma(b)} + * _2F_1(c-a,c-b;1+d;1-x) + * @f] + * + * The reflection formula for integral @f$ m = c - a - b @f$ is: + * @f[ + * _2F_1(a,b;a+b+m;x) = \frac{\Gamma(m)\Gamma(a+b+m)}{\Gamma(a+m)\Gamma(b+m)} + * \sum_{k=0}^{m-1} \frac{(m+a)_k(m+b)_k}{k!(1-m)_k} + * - + * @f] + */ + template<typename _Tp> + _Tp + __hyperg_reflect(const _Tp __a, const _Tp __b, const _Tp __c, + const _Tp __x) + { + const _Tp __d = __c - __a - __b; + const int __intd = std::floor(__d + _Tp(0.5L)); + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + const _Tp __toler = _Tp(1000) * __eps; + const _Tp __log_max = std::log(std::numeric_limits<_Tp>::max()); + const bool __d_integer = (std::abs(__d - __intd) < __toler); + + if (__d_integer) + { + const _Tp __ln_omx = std::log(_Tp(1) - __x); + const _Tp __ad = std::abs(__d); + _Tp __F1, __F2; + + _Tp __d1, __d2; + if (__d >= _Tp(0)) + { + __d1 = __d; + __d2 = _Tp(0); + } + else + { + __d1 = _Tp(0); + __d2 = __d; + } + + const _Tp __lng_c = __log_gamma(__c); + + // Evaluate F1. + if (__ad < __eps) + { + // d = c - a - b = 0. + __F1 = _Tp(0); + } + else + { + + bool __ok_d1 = true; + _Tp __lng_ad, __lng_ad1, __lng_bd1; + __try + { + __lng_ad = __log_gamma(__ad); + __lng_ad1 = __log_gamma(__a + __d1); + __lng_bd1 = __log_gamma(__b + __d1); + } + __catch(...) + { + __ok_d1 = false; + } + + if (__ok_d1) + { + /* Gamma functions in the denominator are ok. + * Proceed with evaluation. + */ + _Tp __sum1 = _Tp(1); + _Tp __term = _Tp(1); + _Tp __ln_pre1 = __lng_ad + __lng_c + __d2 * __ln_omx + - __lng_ad1 - __lng_bd1; + + /* Do F1 sum. + */ + for (int __i = 1; __i < __ad; ++__i) + { + const int __j = __i - 1; + __term *= (__a + __d2 + __j) * (__b + __d2 + __j) + / (_Tp(1) + __d2 + __j) / __i * (_Tp(1) - __x); + __sum1 += __term; + } + + if (__ln_pre1 > __log_max) + std::__throw_runtime_error(__N("Overflow of gamma functions " + "in __hyperg_luke.")); + else + __F1 = std::exp(__ln_pre1) * __sum1; + } + else + { + // Gamma functions in the denominator were not ok. + // So the F1 term is zero. + __F1 = _Tp(0); + } + } // end F1 evaluation + + // Evaluate F2. + bool __ok_d2 = true; + _Tp __lng_ad2, __lng_bd2; + __try + { + __lng_ad2 = __log_gamma(__a + __d2); + __lng_bd2 = __log_gamma(__b + __d2); + } + __catch(...) + { + __ok_d2 = false; + } + + if (__ok_d2) + { + // Gamma functions in the denominator are ok. + // Proceed with evaluation. + const int __maxiter = 2000; + const _Tp __psi_1 = -__numeric_constants<_Tp>::__gamma_e(); + const _Tp __psi_1pd = __psi(_Tp(1) + __ad); + const _Tp __psi_apd1 = __psi(__a + __d1); + const _Tp __psi_bpd1 = __psi(__b + __d1); + + _Tp __psi_term = __psi_1 + __psi_1pd - __psi_apd1 + - __psi_bpd1 - __ln_omx; + _Tp __fact = _Tp(1); + _Tp __sum2 = __psi_term; + _Tp __ln_pre2 = __lng_c + __d1 * __ln_omx + - __lng_ad2 - __lng_bd2; + + // Do F2 sum. + int __j; + for (__j = 1; __j < __maxiter; ++__j) + { + // Values for psi functions use recurrence; Abramowitz & Stegun 6.3.5 + const _Tp __term1 = _Tp(1) / _Tp(__j) + + _Tp(1) / (__ad + __j); + const _Tp __term2 = _Tp(1) / (__a + __d1 + _Tp(__j - 1)) + + _Tp(1) / (__b + __d1 + _Tp(__j - 1)); + __psi_term += __term1 - __term2; + __fact *= (__a + __d1 + _Tp(__j - 1)) + * (__b + __d1 + _Tp(__j - 1)) + / ((__ad + __j) * __j) * (_Tp(1) - __x); + const _Tp __delta = __fact * __psi_term; + __sum2 += __delta; + if (std::abs(__delta) < __eps * std::abs(__sum2)) + break; + } + if (__j == __maxiter) + std::__throw_runtime_error(__N("Sum F2 failed to converge " + "in __hyperg_reflect")); + + if (__sum2 == _Tp(0)) + __F2 = _Tp(0); + else + __F2 = std::exp(__ln_pre2) * __sum2; + } + else + { + // Gamma functions in the denominator not ok. + // So the F2 term is zero. + __F2 = _Tp(0); + } // end F2 evaluation + + const _Tp __sgn_2 = (__intd % 2 == 1 ? -_Tp(1) : _Tp(1)); + const _Tp __F = __F1 + __sgn_2 * __F2; + + return __F; + } + else + { + // d = c - a - b not an integer. + + // These gamma functions appear in the denominator, so we + // catch their harmless domain errors and set the terms to zero. + bool __ok1 = true; + _Tp __sgn_g1ca = _Tp(0), __ln_g1ca = _Tp(0); + _Tp __sgn_g1cb = _Tp(0), __ln_g1cb = _Tp(0); + __try + { + __sgn_g1ca = __log_gamma_sign(__c - __a); + __ln_g1ca = __log_gamma(__c - __a); + __sgn_g1cb = __log_gamma_sign(__c - __b); + __ln_g1cb = __log_gamma(__c - __b); + } + __catch(...) + { + __ok1 = false; + } + + bool __ok2 = true; + _Tp __sgn_g2a = _Tp(0), __ln_g2a = _Tp(0); + _Tp __sgn_g2b = _Tp(0), __ln_g2b = _Tp(0); + __try + { + __sgn_g2a = __log_gamma_sign(__a); + __ln_g2a = __log_gamma(__a); + __sgn_g2b = __log_gamma_sign(__b); + __ln_g2b = __log_gamma(__b); + } + __catch(...) + { + __ok2 = false; + } + + const _Tp __sgn_gc = __log_gamma_sign(__c); + const _Tp __ln_gc = __log_gamma(__c); + const _Tp __sgn_gd = __log_gamma_sign(__d); + const _Tp __ln_gd = __log_gamma(__d); + const _Tp __sgn_gmd = __log_gamma_sign(-__d); + const _Tp __ln_gmd = __log_gamma(-__d); + + const _Tp __sgn1 = __sgn_gc * __sgn_gd * __sgn_g1ca * __sgn_g1cb; + const _Tp __sgn2 = __sgn_gc * __sgn_gmd * __sgn_g2a * __sgn_g2b; + + _Tp __pre1, __pre2; + if (__ok1 && __ok2) + { + _Tp __ln_pre1 = __ln_gc + __ln_gd - __ln_g1ca - __ln_g1cb; + _Tp __ln_pre2 = __ln_gc + __ln_gmd - __ln_g2a - __ln_g2b + + __d * std::log(_Tp(1) - __x); + if (__ln_pre1 < __log_max && __ln_pre2 < __log_max) + { + __pre1 = std::exp(__ln_pre1); + __pre2 = std::exp(__ln_pre2); + __pre1 *= __sgn1; + __pre2 *= __sgn2; + } + else + { + std::__throw_runtime_error(__N("Overflow of gamma functions " + "in __hyperg_reflect")); + } + } + else if (__ok1 && !__ok2) + { + _Tp __ln_pre1 = __ln_gc + __ln_gd - __ln_g1ca - __ln_g1cb; + if (__ln_pre1 < __log_max) + { + __pre1 = std::exp(__ln_pre1); + __pre1 *= __sgn1; + __pre2 = _Tp(0); + } + else + { + std::__throw_runtime_error(__N("Overflow of gamma functions " + "in __hyperg_reflect")); + } + } + else if (!__ok1 && __ok2) + { + _Tp __ln_pre2 = __ln_gc + __ln_gmd - __ln_g2a - __ln_g2b + + __d * std::log(_Tp(1) - __x); + if (__ln_pre2 < __log_max) + { + __pre1 = _Tp(0); + __pre2 = std::exp(__ln_pre2); + __pre2 *= __sgn2; + } + else + { + std::__throw_runtime_error(__N("Overflow of gamma functions " + "in __hyperg_reflect")); + } + } + else + { + __pre1 = _Tp(0); + __pre2 = _Tp(0); + std::__throw_runtime_error(__N("Underflow of gamma functions " + "in __hyperg_reflect")); + } + + const _Tp __F1 = __hyperg_series(__a, __b, _Tp(1) - __d, + _Tp(1) - __x); + const _Tp __F2 = __hyperg_series(__c - __a, __c - __b, _Tp(1) + __d, + _Tp(1) - __x); + + const _Tp __F = __pre1 * __F1 + __pre2 * __F2; + + return __F; + } + } + + + /** + * @brief Return the hypogeometric function @f$ _2F_1(a,b;c;x) @f$. + * + * The hypogeometric function is defined by + * @f[ + * _2F_1(a,b;c;x) = \frac{\Gamma(c)}{\Gamma(a)\Gamma(b)} + * \sum_{n=0}^{\infty} + * \frac{\Gamma(a+n)\Gamma(b+n)}{\Gamma(c+n)} + * \frac{x^n}{n!} + * @f] + * + * @param __a The first "numerator" parameter. + * @param __a The second "numerator" parameter. + * @param __c The "denominator" parameter. + * @param __x The argument of the confluent hypergeometric function. + * @return The confluent hypergeometric function. + */ + template<typename _Tp> + inline _Tp + __hyperg(const _Tp __a, const _Tp __b, const _Tp __c, const _Tp __x) + { +#if _GLIBCXX_USE_C99_MATH_TR1 + const _Tp __a_nint = std::tr1::nearbyint(__a); + const _Tp __b_nint = std::tr1::nearbyint(__b); + const _Tp __c_nint = std::tr1::nearbyint(__c); +#else + const _Tp __a_nint = static_cast<int>(__a + _Tp(0.5L)); + const _Tp __b_nint = static_cast<int>(__b + _Tp(0.5L)); + const _Tp __c_nint = static_cast<int>(__c + _Tp(0.5L)); +#endif + const _Tp __toler = _Tp(1000) * std::numeric_limits<_Tp>::epsilon(); + if (std::abs(__x) >= _Tp(1)) + std::__throw_domain_error(__N("Argument outside unit circle " + "in __hyperg.")); + else if (__isnan(__a) || __isnan(__b) + || __isnan(__c) || __isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__c_nint == __c && __c_nint <= _Tp(0)) + return std::numeric_limits<_Tp>::infinity(); + else if (std::abs(__c - __b) < __toler || std::abs(__c - __a) < __toler) + return std::pow(_Tp(1) - __x, __c - __a - __b); + else if (__a >= _Tp(0) && __b >= _Tp(0) && __c >= _Tp(0) + && __x >= _Tp(0) && __x < _Tp(0.995L)) + return __hyperg_series(__a, __b, __c, __x); + else if (std::abs(__a) < _Tp(10) && std::abs(__b) < _Tp(10)) + { + // For integer a and b the hypergeometric function is a finite polynomial. + if (__a < _Tp(0) && std::abs(__a - __a_nint) < __toler) + return __hyperg_series(__a_nint, __b, __c, __x); + else if (__b < _Tp(0) && std::abs(__b - __b_nint) < __toler) + return __hyperg_series(__a, __b_nint, __c, __x); + else if (__x < -_Tp(0.25L)) + return __hyperg_luke(__a, __b, __c, __x); + else if (__x < _Tp(0.5L)) + return __hyperg_series(__a, __b, __c, __x); + else + if (std::abs(__c) > _Tp(10)) + return __hyperg_series(__a, __b, __c, __x); + else + return __hyperg_reflect(__a, __b, __c, __x); + } + else + return __hyperg_luke(__a, __b, __c, __x); + } + + } // namespace std::tr1::__detail +} +} + +#endif // _GLIBCXX_TR1_HYPERGEOMETRIC_TCC diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/inttypes.h b/gcc-4.4.3/libstdc++-v3/include/tr1/inttypes.h new file mode 100644 index 000000000..4c8fd45d8 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/inttypes.h @@ -0,0 +1,34 @@ +// TR1 inttypes.h -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/inttypes.h + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_INTTYPES_H +#define _GLIBCXX_TR1_INTTYPES_H 1 + +#include <tr1/cinttypes> + +#endif // _GLIBCXX_TR1_INTTYPES_H diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/legendre_function.tcc b/gcc-4.4.3/libstdc++-v3/include/tr1/legendre_function.tcc new file mode 100644 index 000000000..8b59814da --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/legendre_function.tcc @@ -0,0 +1,305 @@ +// Special functions -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/legendre_function.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +// +// ISO C++ 14882 TR1: 5.2 Special functions +// + +// Written by Edward Smith-Rowland based on: +// (1) Handbook of Mathematical Functions, +// ed. Milton Abramowitz and Irene A. Stegun, +// Dover Publications, +// Section 8, pp. 331-341 +// (2) The Gnu Scientific Library, http://www.gnu.org/software/gsl +// (3) Numerical Recipes in C, by W. H. Press, S. A. Teukolsky, +// W. T. Vetterling, B. P. Flannery, Cambridge University Press (1992), +// 2nd ed, pp. 252-254 + +#ifndef _GLIBCXX_TR1_LEGENDRE_FUNCTION_TCC +#define _GLIBCXX_TR1_LEGENDRE_FUNCTION_TCC 1 + +#include "special_function_util.h" + +namespace std +{ +namespace tr1 +{ + + // [5.2] Special functions + + // Implementation-space details. + namespace __detail + { + + /** + * @brief Return the Legendre polynomial by recursion on order + * @f$ l @f$. + * + * The Legendre function of @f$ l @f$ and @f$ x @f$, + * @f$ P_l(x) @f$, is defined by: + * @f[ + * P_l(x) = \frac{1}{2^l l!}\frac{d^l}{dx^l}(x^2 - 1)^{l} + * @f] + * + * @param l The order of the Legendre polynomial. @f$l >= 0@f$. + * @param x The argument of the Legendre polynomial. @f$|x| <= 1@f$. + */ + template<typename _Tp> + _Tp + __poly_legendre_p(const unsigned int __l, const _Tp __x) + { + + if ((__x < _Tp(-1)) || (__x > _Tp(+1))) + std::__throw_domain_error(__N("Argument out of range" + " in __poly_legendre_p.")); + else if (__isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__x == +_Tp(1)) + return +_Tp(1); + else if (__x == -_Tp(1)) + return (__l % 2 == 1 ? -_Tp(1) : +_Tp(1)); + else + { + _Tp __p_lm2 = _Tp(1); + if (__l == 0) + return __p_lm2; + + _Tp __p_lm1 = __x; + if (__l == 1) + return __p_lm1; + + _Tp __p_l = 0; + for (unsigned int __ll = 2; __ll <= __l; ++__ll) + { + // This arrangement is supposed to be better for roundoff + // protection, Arfken, 2nd Ed, Eq 12.17a. + __p_l = _Tp(2) * __x * __p_lm1 - __p_lm2 + - (__x * __p_lm1 - __p_lm2) / _Tp(__ll); + __p_lm2 = __p_lm1; + __p_lm1 = __p_l; + } + + return __p_l; + } + } + + + /** + * @brief Return the associated Legendre function by recursion + * on @f$ l @f$. + * + * The associated Legendre function is derived from the Legendre function + * @f$ P_l(x) @f$ by the Rodrigues formula: + * @f[ + * P_l^m(x) = (1 - x^2)^{m/2}\frac{d^m}{dx^m}P_l(x) + * @f] + * + * @param l The order of the associated Legendre function. + * @f$ l >= 0 @f$. + * @param m The order of the associated Legendre function. + * @f$ m <= l @f$. + * @param x The argument of the associated Legendre function. + * @f$ |x| <= 1 @f$. + */ + template<typename _Tp> + _Tp + __assoc_legendre_p(const unsigned int __l, const unsigned int __m, + const _Tp __x) + { + + if (__x < _Tp(-1) || __x > _Tp(+1)) + std::__throw_domain_error(__N("Argument out of range" + " in __assoc_legendre_p.")); + else if (__m > __l) + std::__throw_domain_error(__N("Degree out of range" + " in __assoc_legendre_p.")); + else if (__isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__m == 0) + return __poly_legendre_p(__l, __x); + else + { + _Tp __p_mm = _Tp(1); + if (__m > 0) + { + // Two square roots seem more accurate more of the time + // than just one. + _Tp __root = std::sqrt(_Tp(1) - __x) * std::sqrt(_Tp(1) + __x); + _Tp __fact = _Tp(1); + for (unsigned int __i = 1; __i <= __m; ++__i) + { + __p_mm *= -__fact * __root; + __fact += _Tp(2); + } + } + if (__l == __m) + return __p_mm; + + _Tp __p_mp1m = _Tp(2 * __m + 1) * __x * __p_mm; + if (__l == __m + 1) + return __p_mp1m; + + _Tp __p_lm2m = __p_mm; + _Tp __P_lm1m = __p_mp1m; + _Tp __p_lm = _Tp(0); + for (unsigned int __j = __m + 2; __j <= __l; ++__j) + { + __p_lm = (_Tp(2 * __j - 1) * __x * __P_lm1m + - _Tp(__j + __m - 1) * __p_lm2m) / _Tp(__j - __m); + __p_lm2m = __P_lm1m; + __P_lm1m = __p_lm; + } + + return __p_lm; + } + } + + + /** + * @brief Return the spherical associated Legendre function. + * + * The spherical associated Legendre function of @f$ l @f$, @f$ m @f$, + * and @f$ \theta @f$ is defined as @f$ Y_l^m(\theta,0) @f$ where + * @f[ + * Y_l^m(\theta,\phi) = (-1)^m[\frac{(2l+1)}{4\pi} + * \frac{(l-m)!}{(l+m)!}] + * P_l^m(\cos\theta) \exp^{im\phi} + * @f] + * is the spherical harmonic function and @f$ P_l^m(x) @f$ is the + * associated Legendre function. + * + * This function differs from the associated Legendre function by + * argument (@f$x = \cos(\theta)@f$) and by a normalization factor + * but this factor is rather large for large @f$ l @f$ and @f$ m @f$ + * and so this function is stable for larger differences of @f$ l @f$ + * and @f$ m @f$. + * + * @param l The order of the spherical associated Legendre function. + * @f$ l >= 0 @f$. + * @param m The order of the spherical associated Legendre function. + * @f$ m <= l @f$. + * @param theta The radian angle argument of the spherical associated + * Legendre function. + */ + template <typename _Tp> + _Tp + __sph_legendre(const unsigned int __l, const unsigned int __m, + const _Tp __theta) + { + if (__isnan(__theta)) + return std::numeric_limits<_Tp>::quiet_NaN(); + + const _Tp __x = std::cos(__theta); + + if (__l < __m) + { + std::__throw_domain_error(__N("Bad argument " + "in __sph_legendre.")); + } + else if (__m == 0) + { + _Tp __P = __poly_legendre_p(__l, __x); + _Tp __fact = std::sqrt(_Tp(2 * __l + 1) + / (_Tp(4) * __numeric_constants<_Tp>::__pi())); + __P *= __fact; + return __P; + } + else if (__x == _Tp(1) || __x == -_Tp(1)) + { + // m > 0 here + return _Tp(0); + } + else + { + // m > 0 and |x| < 1 here + + // Starting value for recursion. + // Y_m^m(x) = sqrt( (2m+1)/(4pi m) gamma(m+1/2)/gamma(m) ) + // (-1)^m (1-x^2)^(m/2) / pi^(1/4) + const _Tp __sgn = ( __m % 2 == 1 ? -_Tp(1) : _Tp(1)); + const _Tp __y_mp1m_factor = __x * std::sqrt(_Tp(2 * __m + 3)); +#if _GLIBCXX_USE_C99_MATH_TR1 + const _Tp __lncirc = std::tr1::log1p(-__x * __x); +#else + const _Tp __lncirc = std::log(_Tp(1) - __x * __x); +#endif + // Gamma(m+1/2) / Gamma(m) +#if _GLIBCXX_USE_C99_MATH_TR1 + const _Tp __lnpoch = std::tr1::lgamma(_Tp(__m + _Tp(0.5L))) + - std::tr1::lgamma(_Tp(__m)); +#else + const _Tp __lnpoch = __log_gamma(_Tp(__m + _Tp(0.5L))) + - __log_gamma(_Tp(__m)); +#endif + const _Tp __lnpre_val = + -_Tp(0.25L) * __numeric_constants<_Tp>::__lnpi() + + _Tp(0.5L) * (__lnpoch + __m * __lncirc); + _Tp __sr = std::sqrt((_Tp(2) + _Tp(1) / __m) + / (_Tp(4) * __numeric_constants<_Tp>::__pi())); + _Tp __y_mm = __sgn * __sr * std::exp(__lnpre_val); + _Tp __y_mp1m = __y_mp1m_factor * __y_mm; + + if (__l == __m) + { + return __y_mm; + } + else if (__l == __m + 1) + { + return __y_mp1m; + } + else + { + _Tp __y_lm = _Tp(0); + + // Compute Y_l^m, l > m+1, upward recursion on l. + for ( int __ll = __m + 2; __ll <= __l; ++__ll) + { + const _Tp __rat1 = _Tp(__ll - __m) / _Tp(__ll + __m); + const _Tp __rat2 = _Tp(__ll - __m - 1) / _Tp(__ll + __m - 1); + const _Tp __fact1 = std::sqrt(__rat1 * _Tp(2 * __ll + 1) + * _Tp(2 * __ll - 1)); + const _Tp __fact2 = std::sqrt(__rat1 * __rat2 * _Tp(2 * __ll + 1) + / _Tp(2 * __ll - 3)); + __y_lm = (__x * __y_mp1m * __fact1 + - (__ll + __m - 1) * __y_mm * __fact2) / _Tp(__ll - __m); + __y_mm = __y_mp1m; + __y_mp1m = __y_lm; + } + + return __y_lm; + } + } + } + + } // namespace std::tr1::__detail +} +} + +#endif // _GLIBCXX_TR1_LEGENDRE_FUNCTION_TCC diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/limits.h b/gcc-4.4.3/libstdc++-v3/include/tr1/limits.h new file mode 100644 index 000000000..d95d360fd --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/limits.h @@ -0,0 +1,34 @@ +// TR1 limits.h -*- C++ -*- + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/limits.h + * This is a TR1 C++ Library header. + */ + +#ifndef _TR1_LIMITS_H +#define _TR1_LIMITS_H 1 + +#include <tr1/climits> + +#endif diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/math.h b/gcc-4.4.3/libstdc++-v3/include/tr1/math.h new file mode 100644 index 000000000..15d6d6419 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/math.h @@ -0,0 +1,186 @@ +// TR1 math.h -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/math.h + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_MATH_H +#define _GLIBCXX_TR1_MATH_H 1 + +#include <tr1/cmath> + +#if _GLIBCXX_USE_C99_MATH_TR1 + +using std::tr1::acos; +using std::tr1::acosh; +using std::tr1::asin; +using std::tr1::asinh; +using std::tr1::atan; +using std::tr1::atan2; +using std::tr1::atanh; +using std::tr1::cbrt; +using std::tr1::ceil; +using std::tr1::copysign; +using std::tr1::cos; +using std::tr1::cosh; +using std::tr1::erf; +using std::tr1::erfc; +using std::tr1::exp; +using std::tr1::exp2; +using std::tr1::expm1; +using std::tr1::fabs; +using std::tr1::fdim; +using std::tr1::floor; +using std::tr1::fma; +using std::tr1::fmax; +using std::tr1::fmin; +using std::tr1::fmod; +using std::tr1::frexp; +using std::tr1::hypot; +using std::tr1::ilogb; +using std::tr1::ldexp; +using std::tr1::lgamma; +using std::tr1::llrint; +using std::tr1::llround; +using std::tr1::log; +using std::tr1::log10; +using std::tr1::log1p; +using std::tr1::log2; +using std::tr1::logb; +using std::tr1::lrint; +using std::tr1::lround; +using std::tr1::nearbyint; +using std::tr1::nextafter; +using std::tr1::nexttoward; +using std::tr1::pow; +using std::tr1::remainder; +using std::tr1::remquo; +using std::tr1::rint; +using std::tr1::round; +using std::tr1::scalbln; +using std::tr1::scalbn; +using std::tr1::sin; +using std::tr1::sinh; +using std::tr1::sqrt; +using std::tr1::tan; +using std::tr1::tanh; +using std::tr1::tgamma; +using std::tr1::trunc; + +#endif + +using std::tr1::assoc_laguerref; +using std::tr1::assoc_laguerre; +using std::tr1::assoc_laguerrel; + +using std::tr1::assoc_legendref; +using std::tr1::assoc_legendre; +using std::tr1::assoc_legendrel; + +using std::tr1::betaf; +using std::tr1::beta; +using std::tr1::betal; + +using std::tr1::comp_ellint_1f; +using std::tr1::comp_ellint_1; +using std::tr1::comp_ellint_1l; + +using std::tr1::comp_ellint_2f; +using std::tr1::comp_ellint_2; +using std::tr1::comp_ellint_2l; + +using std::tr1::comp_ellint_3f; +using std::tr1::comp_ellint_3; +using std::tr1::comp_ellint_3l; + +using std::tr1::conf_hypergf; +using std::tr1::conf_hyperg; +using std::tr1::conf_hypergl; + +using std::tr1::cyl_bessel_if; +using std::tr1::cyl_bessel_i; +using std::tr1::cyl_bessel_il; + +using std::tr1::cyl_bessel_jf; +using std::tr1::cyl_bessel_j; +using std::tr1::cyl_bessel_jl; + +using std::tr1::cyl_bessel_kf; +using std::tr1::cyl_bessel_k; +using std::tr1::cyl_bessel_kl; + +using std::tr1::cyl_neumannf; +using std::tr1::cyl_neumann; +using std::tr1::cyl_neumannl; + +using std::tr1::ellint_1f; +using std::tr1::ellint_1; +using std::tr1::ellint_1l; + +using std::tr1::ellint_2f; +using std::tr1::ellint_2; +using std::tr1::ellint_2l; + +using std::tr1::ellint_3f; +using std::tr1::ellint_3; +using std::tr1::ellint_3l; + +using std::tr1::expintf; +using std::tr1::expint; +using std::tr1::expintl; + +using std::tr1::hermitef; +using std::tr1::hermite; +using std::tr1::hermitel; + +using std::tr1::hypergf; +using std::tr1::hyperg; +using std::tr1::hypergl; + +using std::tr1::laguerref; +using std::tr1::laguerre; +using std::tr1::laguerrel; + +using std::tr1::legendref; +using std::tr1::legendre; +using std::tr1::legendrel; + +using std::tr1::riemann_zetaf; +using std::tr1::riemann_zeta; +using std::tr1::riemann_zetal; + +using std::tr1::sph_besself; +using std::tr1::sph_bessel; +using std::tr1::sph_bessell; + +using std::tr1::sph_legendref; +using std::tr1::sph_legendre; +using std::tr1::sph_legendrel; + +using std::tr1::sph_neumannf; +using std::tr1::sph_neumann; +using std::tr1::sph_neumannl; + +#endif // _GLIBCXX_TR1_MATH_H diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/memory b/gcc-4.4.3/libstdc++-v3/include/tr1/memory new file mode 100644 index 000000000..8b021a1b1 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/memory @@ -0,0 +1,67 @@ +// <tr1/memory> -*- C++ -*- + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** + * @file tr1/memory + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_MEMORY +#define _GLIBCXX_TR1_MEMORY 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <memory> +#include <exception> // std::exception +#include <typeinfo> // std::type_info in get_deleter +#include <bits/stl_algobase.h> // std::swap +#include <iosfwd> // std::basic_ostream +#include <ext/atomicity.h> +#include <ext/concurrence.h> +#include <bits/functexcept.h> +#include <bits/stl_function.h> // std::less +#include <debug/debug.h> +#include <tr1/type_traits> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/boost_sp_counted_base.h> +# include <tr1/shared_ptr.h> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/boost_sp_counted_base.h> +# include <tr1/shared_ptr.h> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_MEMORY diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/modified_bessel_func.tcc b/gcc-4.4.3/libstdc++-v3/include/tr1/modified_bessel_func.tcc new file mode 100644 index 000000000..7b8aebc3b --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/modified_bessel_func.tcc @@ -0,0 +1,436 @@ +// Special functions -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/modified_bessel_func.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +// +// ISO C++ 14882 TR1: 5.2 Special functions +// + +// Written by Edward Smith-Rowland. +// +// References: +// (1) Handbook of Mathematical Functions, +// Ed. Milton Abramowitz and Irene A. Stegun, +// Dover Publications, +// Section 9, pp. 355-434, Section 10 pp. 435-478 +// (2) The Gnu Scientific Library, http://www.gnu.org/software/gsl +// (3) Numerical Recipes in C, by W. H. Press, S. A. Teukolsky, +// W. T. Vetterling, B. P. Flannery, Cambridge University Press (1992), +// 2nd ed, pp. 246-249. + +#ifndef _GLIBCXX_TR1_MODIFIED_BESSEL_FUNC_TCC +#define _GLIBCXX_TR1_MODIFIED_BESSEL_FUNC_TCC 1 + +#include "special_function_util.h" + +namespace std +{ +namespace tr1 +{ + + // [5.2] Special functions + + // Implementation-space details. + namespace __detail + { + + /** + * @brief Compute the modified Bessel functions @f$ I_\nu(x) @f$ and + * @f$ K_\nu(x) @f$ and their first derivatives + * @f$ I'_\nu(x) @f$ and @f$ K'_\nu(x) @f$ respectively. + * These four functions are computed together for numerical + * stability. + * + * @param __nu The order of the Bessel functions. + * @param __x The argument of the Bessel functions. + * @param __Inu The output regular modified Bessel function. + * @param __Knu The output irregular modified Bessel function. + * @param __Ipnu The output derivative of the regular + * modified Bessel function. + * @param __Kpnu The output derivative of the irregular + * modified Bessel function. + */ + template <typename _Tp> + void + __bessel_ik(const _Tp __nu, const _Tp __x, + _Tp & __Inu, _Tp & __Knu, _Tp & __Ipnu, _Tp & __Kpnu) + { + if (__x == _Tp(0)) + { + if (__nu == _Tp(0)) + { + __Inu = _Tp(1); + __Ipnu = _Tp(0); + } + else if (__nu == _Tp(1)) + { + __Inu = _Tp(0); + __Ipnu = _Tp(0.5L); + } + else + { + __Inu = _Tp(0); + __Ipnu = _Tp(0); + } + __Knu = std::numeric_limits<_Tp>::infinity(); + __Kpnu = -std::numeric_limits<_Tp>::infinity(); + return; + } + + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + const _Tp __fp_min = _Tp(10) * std::numeric_limits<_Tp>::epsilon(); + const int __max_iter = 15000; + const _Tp __x_min = _Tp(2); + + const int __nl = static_cast<int>(__nu + _Tp(0.5L)); + + const _Tp __mu = __nu - __nl; + const _Tp __mu2 = __mu * __mu; + const _Tp __xi = _Tp(1) / __x; + const _Tp __xi2 = _Tp(2) * __xi; + _Tp __h = __nu * __xi; + if ( __h < __fp_min ) + __h = __fp_min; + _Tp __b = __xi2 * __nu; + _Tp __d = _Tp(0); + _Tp __c = __h; + int __i; + for ( __i = 1; __i <= __max_iter; ++__i ) + { + __b += __xi2; + __d = _Tp(1) / (__b + __d); + __c = __b + _Tp(1) / __c; + const _Tp __del = __c * __d; + __h *= __del; + if (std::abs(__del - _Tp(1)) < __eps) + break; + } + if (__i > __max_iter) + std::__throw_runtime_error(__N("Argument x too large " + "in __bessel_jn; " + "try asymptotic expansion.")); + _Tp __Inul = __fp_min; + _Tp __Ipnul = __h * __Inul; + _Tp __Inul1 = __Inul; + _Tp __Ipnu1 = __Ipnul; + _Tp __fact = __nu * __xi; + for (int __l = __nl; __l >= 1; --__l) + { + const _Tp __Inutemp = __fact * __Inul + __Ipnul; + __fact -= __xi; + __Ipnul = __fact * __Inutemp + __Inul; + __Inul = __Inutemp; + } + _Tp __f = __Ipnul / __Inul; + _Tp __Kmu, __Knu1; + if (__x < __x_min) + { + const _Tp __x2 = __x / _Tp(2); + const _Tp __pimu = __numeric_constants<_Tp>::__pi() * __mu; + const _Tp __fact = (std::abs(__pimu) < __eps + ? _Tp(1) : __pimu / std::sin(__pimu)); + _Tp __d = -std::log(__x2); + _Tp __e = __mu * __d; + const _Tp __fact2 = (std::abs(__e) < __eps + ? _Tp(1) : std::sinh(__e) / __e); + _Tp __gam1, __gam2, __gampl, __gammi; + __gamma_temme(__mu, __gam1, __gam2, __gampl, __gammi); + _Tp __ff = __fact + * (__gam1 * std::cosh(__e) + __gam2 * __fact2 * __d); + _Tp __sum = __ff; + __e = std::exp(__e); + _Tp __p = __e / (_Tp(2) * __gampl); + _Tp __q = _Tp(1) / (_Tp(2) * __e * __gammi); + _Tp __c = _Tp(1); + __d = __x2 * __x2; + _Tp __sum1 = __p; + int __i; + for (__i = 1; __i <= __max_iter; ++__i) + { + __ff = (__i * __ff + __p + __q) / (__i * __i - __mu2); + __c *= __d / __i; + __p /= __i - __mu; + __q /= __i + __mu; + const _Tp __del = __c * __ff; + __sum += __del; + const _Tp __del1 = __c * (__p - __i * __ff); + __sum1 += __del1; + if (std::abs(__del) < __eps * std::abs(__sum)) + break; + } + if (__i > __max_iter) + std::__throw_runtime_error(__N("Bessel k series failed to converge " + "in __bessel_jn.")); + __Kmu = __sum; + __Knu1 = __sum1 * __xi2; + } + else + { + _Tp __b = _Tp(2) * (_Tp(1) + __x); + _Tp __d = _Tp(1) / __b; + _Tp __delh = __d; + _Tp __h = __delh; + _Tp __q1 = _Tp(0); + _Tp __q2 = _Tp(1); + _Tp __a1 = _Tp(0.25L) - __mu2; + _Tp __q = __c = __a1; + _Tp __a = -__a1; + _Tp __s = _Tp(1) + __q * __delh; + int __i; + for (__i = 2; __i <= __max_iter; ++__i) + { + __a -= 2 * (__i - 1); + __c = -__a * __c / __i; + const _Tp __qnew = (__q1 - __b * __q2) / __a; + __q1 = __q2; + __q2 = __qnew; + __q += __c * __qnew; + __b += _Tp(2); + __d = _Tp(1) / (__b + __a * __d); + __delh = (__b * __d - _Tp(1)) * __delh; + __h += __delh; + const _Tp __dels = __q * __delh; + __s += __dels; + if ( std::abs(__dels / __s) < __eps ) + break; + } + if (__i > __max_iter) + std::__throw_runtime_error(__N("Steed's method failed " + "in __bessel_jn.")); + __h = __a1 * __h; + __Kmu = std::sqrt(__numeric_constants<_Tp>::__pi() / (_Tp(2) * __x)) + * std::exp(-__x) / __s; + __Knu1 = __Kmu * (__mu + __x + _Tp(0.5L) - __h) * __xi; + } + + _Tp __Kpmu = __mu * __xi * __Kmu - __Knu1; + _Tp __Inumu = __xi / (__f * __Kmu - __Kpmu); + __Inu = __Inumu * __Inul1 / __Inul; + __Ipnu = __Inumu * __Ipnu1 / __Inul; + for ( __i = 1; __i <= __nl; ++__i ) + { + const _Tp __Knutemp = (__mu + __i) * __xi2 * __Knu1 + __Kmu; + __Kmu = __Knu1; + __Knu1 = __Knutemp; + } + __Knu = __Kmu; + __Kpnu = __nu * __xi * __Kmu - __Knu1; + + return; + } + + + /** + * @brief Return the regular modified Bessel function of order + * \f$ \nu \f$: \f$ I_{\nu}(x) \f$. + * + * The regular modified cylindrical Bessel function is: + * @f[ + * I_{\nu}(x) = \sum_{k=0}^{\infty} + * \frac{(x/2)^{\nu + 2k}}{k!\Gamma(\nu+k+1)} + * @f] + * + * @param __nu The order of the regular modified Bessel function. + * @param __x The argument of the regular modified Bessel function. + * @return The output regular modified Bessel function. + */ + template<typename _Tp> + _Tp + __cyl_bessel_i(const _Tp __nu, const _Tp __x) + { + if (__nu < _Tp(0) || __x < _Tp(0)) + std::__throw_domain_error(__N("Bad argument " + "in __cyl_bessel_i.")); + else if (__isnan(__nu) || __isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__x * __x < _Tp(10) * (__nu + _Tp(1))) + return __cyl_bessel_ij_series(__nu, __x, +_Tp(1), 200); + else + { + _Tp __I_nu, __K_nu, __Ip_nu, __Kp_nu; + __bessel_ik(__nu, __x, __I_nu, __K_nu, __Ip_nu, __Kp_nu); + return __I_nu; + } + } + + + /** + * @brief Return the irregular modified Bessel function + * \f$ K_{\nu}(x) \f$ of order \f$ \nu \f$. + * + * The irregular modified Bessel function is defined by: + * @f[ + * K_{\nu}(x) = \frac{\pi}{2} + * \frac{I_{-\nu}(x) - I_{\nu}(x)}{\sin \nu\pi} + * @f] + * where for integral \f$ \nu = n \f$ a limit is taken: + * \f$ lim_{\nu \to n} \f$. + * + * @param __nu The order of the irregular modified Bessel function. + * @param __x The argument of the irregular modified Bessel function. + * @return The output irregular modified Bessel function. + */ + template<typename _Tp> + _Tp + __cyl_bessel_k(const _Tp __nu, const _Tp __x) + { + if (__nu < _Tp(0) || __x < _Tp(0)) + std::__throw_domain_error(__N("Bad argument " + "in __cyl_bessel_k.")); + else if (__isnan(__nu) || __isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else + { + _Tp __I_nu, __K_nu, __Ip_nu, __Kp_nu; + __bessel_ik(__nu, __x, __I_nu, __K_nu, __Ip_nu, __Kp_nu); + return __K_nu; + } + } + + + /** + * @brief Compute the spherical modified Bessel functions + * @f$ i_n(x) @f$ and @f$ k_n(x) @f$ and their first + * derivatives @f$ i'_n(x) @f$ and @f$ k'_n(x) @f$ + * respectively. + * + * @param __n The order of the modified spherical Bessel function. + * @param __x The argument of the modified spherical Bessel function. + * @param __i_n The output regular modified spherical Bessel function. + * @param __k_n The output irregular modified spherical + * Bessel function. + * @param __ip_n The output derivative of the regular modified + * spherical Bessel function. + * @param __kp_n The output derivative of the irregular modified + * spherical Bessel function. + */ + template <typename _Tp> + void + __sph_bessel_ik(const unsigned int __n, const _Tp __x, + _Tp & __i_n, _Tp & __k_n, _Tp & __ip_n, _Tp & __kp_n) + { + const _Tp __nu = _Tp(__n) + _Tp(0.5L); + + _Tp __I_nu, __Ip_nu, __K_nu, __Kp_nu; + __bessel_ik(__nu, __x, __I_nu, __K_nu, __Ip_nu, __Kp_nu); + + const _Tp __factor = __numeric_constants<_Tp>::__sqrtpio2() + / std::sqrt(__x); + + __i_n = __factor * __I_nu; + __k_n = __factor * __K_nu; + __ip_n = __factor * __Ip_nu - __i_n / (_Tp(2) * __x); + __kp_n = __factor * __Kp_nu - __k_n / (_Tp(2) * __x); + + return; + } + + + /** + * @brief Compute the Airy functions + * @f$ Ai(x) @f$ and @f$ Bi(x) @f$ and their first + * derivatives @f$ Ai'(x) @f$ and @f$ Bi(x) @f$ + * respectively. + * + * @param __n The order of the Airy functions. + * @param __x The argument of the Airy functions. + * @param __i_n The output Airy function. + * @param __k_n The output Airy function. + * @param __ip_n The output derivative of the Airy function. + * @param __kp_n The output derivative of the Airy function. + */ + template <typename _Tp> + void + __airy(const _Tp __x, + _Tp & __Ai, _Tp & __Bi, _Tp & __Aip, _Tp & __Bip) + { + const _Tp __absx = std::abs(__x); + const _Tp __rootx = std::sqrt(__absx); + const _Tp __z = _Tp(2) * __absx * __rootx / _Tp(3); + + if (__isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__x > _Tp(0)) + { + _Tp __I_nu, __Ip_nu, __K_nu, __Kp_nu; + + __bessel_ik(_Tp(1) / _Tp(3), __z, __I_nu, __K_nu, __Ip_nu, __Kp_nu); + __Ai = __rootx * __K_nu + / (__numeric_constants<_Tp>::__sqrt3() + * __numeric_constants<_Tp>::__pi()); + __Bi = __rootx * (__K_nu / __numeric_constants<_Tp>::__pi() + + _Tp(2) * __I_nu / __numeric_constants<_Tp>::__sqrt3()); + + __bessel_ik(_Tp(2) / _Tp(3), __z, __I_nu, __K_nu, __Ip_nu, __Kp_nu); + __Aip = -__x * __K_nu + / (__numeric_constants<_Tp>::__sqrt3() + * __numeric_constants<_Tp>::__pi()); + __Bip = __x * (__K_nu / __numeric_constants<_Tp>::__pi() + + _Tp(2) * __I_nu + / __numeric_constants<_Tp>::__sqrt3()); + } + else if (__x < _Tp(0)) + { + _Tp __J_nu, __Jp_nu, __N_nu, __Np_nu; + + __bessel_jn(_Tp(1) / _Tp(3), __z, __J_nu, __N_nu, __Jp_nu, __Np_nu); + __Ai = __rootx * (__J_nu + - __N_nu / __numeric_constants<_Tp>::__sqrt3()) / _Tp(2); + __Bi = -__rootx * (__N_nu + + __J_nu / __numeric_constants<_Tp>::__sqrt3()) / _Tp(2); + + __bessel_jn(_Tp(2) / _Tp(3), __z, __J_nu, __N_nu, __Jp_nu, __Np_nu); + __Aip = __absx * (__N_nu / __numeric_constants<_Tp>::__sqrt3() + + __J_nu) / _Tp(2); + __Bip = __absx * (__J_nu / __numeric_constants<_Tp>::__sqrt3() + - __N_nu) / _Tp(2); + } + else + { + // Reference: + // Abramowitz & Stegun, page 446 section 10.4.4 on Airy functions. + // The number is Ai(0) = 3^{-2/3}/\Gamma(2/3). + __Ai = _Tp(0.35502805388781723926L); + __Bi = __Ai * __numeric_constants<_Tp>::__sqrt3(); + + // Reference: + // Abramowitz & Stegun, page 446 section 10.4.5 on Airy functions. + // The number is Ai'(0) = -3^{-1/3}/\Gamma(1/3). + __Aip = -_Tp(0.25881940379280679840L); + __Bip = -__Aip * __numeric_constants<_Tp>::__sqrt3(); + } + + return; + } + + } // namespace std::tr1::__detail +} +} + +#endif // _GLIBCXX_TR1_MODIFIED_BESSEL_FUNC_TCC diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/poly_hermite.tcc b/gcc-4.4.3/libstdc++-v3/include/tr1/poly_hermite.tcc new file mode 100644 index 000000000..d4825a31e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/poly_hermite.tcc @@ -0,0 +1,124 @@ +// Special functions -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/poly_hermite.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +// +// ISO C++ 14882 TR1: 5.2 Special functions +// + +// Written by Edward Smith-Rowland based on: +// (1) Handbook of Mathematical Functions, +// Ed. Milton Abramowitz and Irene A. Stegun, +// Dover Publications, Section 22 pp. 773-802 + +#ifndef _GLIBCXX_TR1_POLY_HERMITE_TCC +#define _GLIBCXX_TR1_POLY_HERMITE_TCC 1 + +namespace std +{ +namespace tr1 +{ + + // [5.2] Special functions + + // Implementation-space details. + namespace __detail + { + + /** + * @brief This routine returns the Hermite polynomial + * of order n: \f$ H_n(x) \f$ by recursion on n. + * + * The Hermite polynomial is defined by: + * @f[ + * H_n(x) = (-1)^n e^{x^2} \frac{d^n}{dx^n} e^{-x^2} + * @f] + * + * @param __n The order of the Hermite polynomial. + * @param __x The argument of the Hermite polynomial. + * @return The value of the Hermite polynomial of order n + * and argument x. + */ + template<typename _Tp> + _Tp + __poly_hermite_recursion(const unsigned int __n, const _Tp __x) + { + // Compute H_0. + _Tp __H_0 = 1; + if (__n == 0) + return __H_0; + + // Compute H_1. + _Tp __H_1 = 2 * __x; + if (__n == 1) + return __H_1; + + // Compute H_n. + _Tp __H_n, __H_nm1, __H_nm2; + unsigned int __i; + for (__H_nm2 = __H_0, __H_nm1 = __H_1, __i = 2; __i <= __n; ++__i) + { + __H_n = 2 * (__x * __H_nm1 + (__i - 1) * __H_nm2); + __H_nm2 = __H_nm1; + __H_nm1 = __H_n; + } + + return __H_n; + } + + + /** + * @brief This routine returns the Hermite polynomial + * of order n: \f$ H_n(x) \f$. + * + * The Hermite polynomial is defined by: + * @f[ + * H_n(x) = (-1)^n e^{x^2} \frac{d^n}{dx^n} e^{-x^2} + * @f] + * + * @param __n The order of the Hermite polynomial. + * @param __x The argument of the Hermite polynomial. + * @return The value of the Hermite polynomial of order n + * and argument x. + */ + template<typename _Tp> + inline _Tp + __poly_hermite(const unsigned int __n, const _Tp __x) + { + if (__isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else + return __poly_hermite_recursion(__n, __x); + } + + } // namespace std::tr1::__detail +} +} + +#endif // _GLIBCXX_TR1_POLY_HERMITE_TCC diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/poly_laguerre.tcc b/gcc-4.4.3/libstdc++-v3/include/tr1/poly_laguerre.tcc new file mode 100644 index 000000000..9c999dbdf --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/poly_laguerre.tcc @@ -0,0 +1,329 @@ +// Special functions -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/poly_laguerre.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +// +// ISO C++ 14882 TR1: 5.2 Special functions +// + +// Written by Edward Smith-Rowland based on: +// (1) Handbook of Mathematical Functions, +// Ed. Milton Abramowitz and Irene A. Stegun, +// Dover Publications, +// Section 13, pp. 509-510, Section 22 pp. 773-802 +// (2) The Gnu Scientific Library, http://www.gnu.org/software/gsl + +#ifndef _GLIBCXX_TR1_POLY_LAGUERRE_TCC +#define _GLIBCXX_TR1_POLY_LAGUERRE_TCC 1 + +namespace std +{ +namespace tr1 +{ + + // [5.2] Special functions + + // Implementation-space details. + namespace __detail + { + + + /** + * @brief This routine returns the associated Laguerre polynomial + * of order @f$ n @f$, degree @f$ \alpha @f$ for large n. + * Abramowitz & Stegun, 13.5.21 + * + * @param __n The order of the Laguerre function. + * @param __alpha The degree of the Laguerre function. + * @param __x The argument of the Laguerre function. + * @return The value of the Laguerre function of order n, + * degree @f$ \alpha @f$, and argument x. + * + * This is from the GNU Scientific Library. + */ + template<typename _Tpa, typename _Tp> + _Tp + __poly_laguerre_large_n(const unsigned __n, const _Tpa __alpha1, + const _Tp __x) + { + const _Tp __a = -_Tp(__n); + const _Tp __b = _Tp(__alpha1) + _Tp(1); + const _Tp __eta = _Tp(2) * __b - _Tp(4) * __a; + const _Tp __cos2th = __x / __eta; + const _Tp __sin2th = _Tp(1) - __cos2th; + const _Tp __th = std::acos(std::sqrt(__cos2th)); + const _Tp __pre_h = __numeric_constants<_Tp>::__pi_2() + * __numeric_constants<_Tp>::__pi_2() + * __eta * __eta * __cos2th * __sin2th; + +#if _GLIBCXX_USE_C99_MATH_TR1 + const _Tp __lg_b = std::tr1::lgamma(_Tp(__n) + __b); + const _Tp __lnfact = std::tr1::lgamma(_Tp(__n + 1)); +#else + const _Tp __lg_b = __log_gamma(_Tp(__n) + __b); + const _Tp __lnfact = __log_gamma(_Tp(__n + 1)); +#endif + + _Tp __pre_term1 = _Tp(0.5L) * (_Tp(1) - __b) + * std::log(_Tp(0.25L) * __x * __eta); + _Tp __pre_term2 = _Tp(0.25L) * std::log(__pre_h); + _Tp __lnpre = __lg_b - __lnfact + _Tp(0.5L) * __x + + __pre_term1 - __pre_term2; + _Tp __ser_term1 = std::sin(__a * __numeric_constants<_Tp>::__pi()); + _Tp __ser_term2 = std::sin(_Tp(0.25L) * __eta + * (_Tp(2) * __th + - std::sin(_Tp(2) * __th)) + + __numeric_constants<_Tp>::__pi_4()); + _Tp __ser = __ser_term1 + __ser_term2; + + return std::exp(__lnpre) * __ser; + } + + + /** + * @brief Evaluate the polynomial based on the confluent hypergeometric + * function in a safe way, with no restriction on the arguments. + * + * The associated Laguerre function is defined by + * @f[ + * L_n^\alpha(x) = \frac{(\alpha + 1)_n}{n!} + * _1F_1(-n; \alpha + 1; x) + * @f] + * where @f$ (\alpha)_n @f$ is the Pochhammer symbol and + * @f$ _1F_1(a; c; x) @f$ is the confluent hypergeometric function. + * + * This function assumes x != 0. + * + * This is from the GNU Scientific Library. + */ + template<typename _Tpa, typename _Tp> + _Tp + __poly_laguerre_hyperg(const unsigned int __n, const _Tpa __alpha1, + const _Tp __x) + { + const _Tp __b = _Tp(__alpha1) + _Tp(1); + const _Tp __mx = -__x; + const _Tp __tc_sgn = (__x < _Tp(0) ? _Tp(1) + : ((__n % 2 == 1) ? -_Tp(1) : _Tp(1))); + // Get |x|^n/n! + _Tp __tc = _Tp(1); + const _Tp __ax = std::abs(__x); + for (unsigned int __k = 1; __k <= __n; ++__k) + __tc *= (__ax / __k); + + _Tp __term = __tc * __tc_sgn; + _Tp __sum = __term; + for (int __k = int(__n) - 1; __k >= 0; --__k) + { + __term *= ((__b + _Tp(__k)) / _Tp(int(__n) - __k)) + * _Tp(__k + 1) / __mx; + __sum += __term; + } + + return __sum; + } + + + /** + * @brief This routine returns the associated Laguerre polynomial + * of order @f$ n @f$, degree @f$ \alpha @f$: @f$ L_n^\alpha(x) @f$ + * by recursion. + * + * The associated Laguerre function is defined by + * @f[ + * L_n^\alpha(x) = \frac{(\alpha + 1)_n}{n!} + * _1F_1(-n; \alpha + 1; x) + * @f] + * where @f$ (\alpha)_n @f$ is the Pochhammer symbol and + * @f$ _1F_1(a; c; x) @f$ is the confluent hypergeometric function. + * + * The associated Laguerre polynomial is defined for integral + * @f$ \alpha = m @f$ by: + * @f[ + * L_n^m(x) = (-1)^m \frac{d^m}{dx^m} L_{n + m}(x) + * @f] + * where the Laguerre polynomial is defined by: + * @f[ + * L_n(x) = \frac{e^x}{n!} \frac{d^n}{dx^n} (x^ne^{-x}) + * @f] + * + * @param __n The order of the Laguerre function. + * @param __alpha The degree of the Laguerre function. + * @param __x The argument of the Laguerre function. + * @return The value of the Laguerre function of order n, + * degree @f$ \alpha @f$, and argument x. + */ + template<typename _Tpa, typename _Tp> + _Tp + __poly_laguerre_recursion(const unsigned int __n, + const _Tpa __alpha1, const _Tp __x) + { + // Compute l_0. + _Tp __l_0 = _Tp(1); + if (__n == 0) + return __l_0; + + // Compute l_1^alpha. + _Tp __l_1 = -__x + _Tp(1) + _Tp(__alpha1); + if (__n == 1) + return __l_1; + + // Compute l_n^alpha by recursion on n. + _Tp __l_n2 = __l_0; + _Tp __l_n1 = __l_1; + _Tp __l_n = _Tp(0); + for (unsigned int __nn = 2; __nn <= __n; ++__nn) + { + __l_n = (_Tp(2 * __nn - 1) + _Tp(__alpha1) - __x) + * __l_n1 / _Tp(__nn) + - (_Tp(__nn - 1) + _Tp(__alpha1)) * __l_n2 / _Tp(__nn); + __l_n2 = __l_n1; + __l_n1 = __l_n; + } + + return __l_n; + } + + + /** + * @brief This routine returns the associated Laguerre polynomial + * of order n, degree @f$ \alpha @f$: @f$ L_n^alpha(x) @f$. + * + * The associated Laguerre function is defined by + * @f[ + * L_n^\alpha(x) = \frac{(\alpha + 1)_n}{n!} + * _1F_1(-n; \alpha + 1; x) + * @f] + * where @f$ (\alpha)_n @f$ is the Pochhammer symbol and + * @f$ _1F_1(a; c; x) @f$ is the confluent hypergeometric function. + * + * The associated Laguerre polynomial is defined for integral + * @f$ \alpha = m @f$ by: + * @f[ + * L_n^m(x) = (-1)^m \frac{d^m}{dx^m} L_{n + m}(x) + * @f] + * where the Laguerre polynomial is defined by: + * @f[ + * L_n(x) = \frac{e^x}{n!} \frac{d^n}{dx^n} (x^ne^{-x}) + * @f] + * + * @param __n The order of the Laguerre function. + * @param __alpha The degree of the Laguerre function. + * @param __x The argument of the Laguerre function. + * @return The value of the Laguerre function of order n, + * degree @f$ \alpha @f$, and argument x. + */ + template<typename _Tpa, typename _Tp> + inline _Tp + __poly_laguerre(const unsigned int __n, const _Tpa __alpha1, + const _Tp __x) + { + if (__x < _Tp(0)) + std::__throw_domain_error(__N("Negative argument " + "in __poly_laguerre.")); + // Return NaN on NaN input. + else if (__isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__n == 0) + return _Tp(1); + else if (__n == 1) + return _Tp(1) + _Tp(__alpha1) - __x; + else if (__x == _Tp(0)) + { + _Tp __prod = _Tp(__alpha1) + _Tp(1); + for (unsigned int __k = 2; __k <= __n; ++__k) + __prod *= (_Tp(__alpha1) + _Tp(__k)) / _Tp(__k); + return __prod; + } + else if (__n > 10000000 && _Tp(__alpha1) > -_Tp(1) + && __x < _Tp(2) * (_Tp(__alpha1) + _Tp(1)) + _Tp(4 * __n)) + return __poly_laguerre_large_n(__n, __alpha1, __x); + else if (_Tp(__alpha1) >= _Tp(0) + || (__x > _Tp(0) && _Tp(__alpha1) < -_Tp(__n + 1))) + return __poly_laguerre_recursion(__n, __alpha1, __x); + else + return __poly_laguerre_hyperg(__n, __alpha1, __x); + } + + + /** + * @brief This routine returns the associated Laguerre polynomial + * of order n, degree m: @f$ L_n^m(x) @f$. + * + * The associated Laguerre polynomial is defined for integral + * @f$ \alpha = m @f$ by: + * @f[ + * L_n^m(x) = (-1)^m \frac{d^m}{dx^m} L_{n + m}(x) + * @f] + * where the Laguerre polynomial is defined by: + * @f[ + * L_n(x) = \frac{e^x}{n!} \frac{d^n}{dx^n} (x^ne^{-x}) + * @f] + * + * @param __n The order of the Laguerre polynomial. + * @param __m The degree of the Laguerre polynomial. + * @param __x The argument of the Laguerre polynomial. + * @return The value of the associated Laguerre polynomial of order n, + * degree m, and argument x. + */ + template<typename _Tp> + inline _Tp + __assoc_laguerre(const unsigned int __n, const unsigned int __m, + const _Tp __x) + { + return __poly_laguerre<unsigned int, _Tp>(__n, __m, __x); + } + + + /** + * @brief This routine returns the Laguerre polynomial + * of order n: @f$ L_n(x) @f$. + * + * The Laguerre polynomial is defined by: + * @f[ + * L_n(x) = \frac{e^x}{n!} \frac{d^n}{dx^n} (x^ne^{-x}) + * @f] + * + * @param __n The order of the Laguerre polynomial. + * @param __x The argument of the Laguerre polynomial. + * @return The value of the Laguerre polynomial of order n + * and argument x. + */ + template<typename _Tp> + inline _Tp + __laguerre(const unsigned int __n, const _Tp __x) + { + return __poly_laguerre<unsigned int, _Tp>(__n, 0, __x); + } + + } // namespace std::tr1::__detail +} +} + +#endif // _GLIBCXX_TR1_POLY_LAGUERRE_TCC diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/random b/gcc-4.4.3/libstdc++-v3/include/tr1/random new file mode 100644 index 000000000..a23519c52 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/random @@ -0,0 +1,66 @@ +// random number generation -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** + * @file tr1/random + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_RANDOM +#define _GLIBCXX_TR1_RANDOM 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <cmath> +#include <cstdio> +#include <cstdlib> +#include <string> +#include <iosfwd> +#include <limits> +#include <ext/type_traits.h> +#include <ext/numeric_traits.h> +#include <bits/concept_check.h> +#include <debug/debug.h> +#include <tr1/type_traits> +#include <tr1/cmath> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/random> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/random> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_RANDOM diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/regex b/gcc-4.4.3/libstdc++-v3/include/tr1/regex new file mode 100644 index 000000000..b7e2cdfc8 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/regex @@ -0,0 +1,64 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** + * @file tr1/regex + * @author Stephen M. Webb <stephen.webb@bregmasoft.ca> + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_REGEX +#define _GLIBCXX_TR1_REGEX 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <algorithm> +#include <bitset> +#include <iterator> +#include <locale> +#include <stdexcept> +#include <string> +#include <vector> +#include <utility> +#include <sstream> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/regex> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/regex> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_REGEX diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/riemann_zeta.tcc b/gcc-4.4.3/libstdc++-v3/include/tr1/riemann_zeta.tcc new file mode 100644 index 000000000..c646c2e40 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/riemann_zeta.tcc @@ -0,0 +1,435 @@ +// Special functions -*- C++ -*- + +// Copyright (C) 2006, 2007, 2008, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/riemann_zeta.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +// +// ISO C++ 14882 TR1: 5.2 Special functions +// + +// Written by Edward Smith-Rowland based on: +// (1) Handbook of Mathematical Functions, +// Ed. by Milton Abramowitz and Irene A. Stegun, +// Dover Publications, New-York, Section 5, pp. 807-808. +// (2) The Gnu Scientific Library, http://www.gnu.org/software/gsl +// (3) Gamma, Exploring Euler's Constant, Julian Havil, +// Princeton, 2003. + +#ifndef _GLIBCXX_TR1_RIEMANN_ZETA_TCC +#define _GLIBCXX_TR1_RIEMANN_ZETA_TCC 1 + +#include "special_function_util.h" + +namespace std +{ +namespace tr1 +{ + + // [5.2] Special functions + + // Implementation-space details. + namespace __detail + { + + /** + * @brief Compute the Riemann zeta function @f$ \zeta(s) @f$ + * by summation for s > 1. + * + * The Riemann zeta function is defined by: + * \f[ + * \zeta(s) = \sum_{k=1}^{\infty} \frac{1}{k^{s}} for s > 1 + * \f] + * For s < 1 use the reflection formula: + * \f[ + * \zeta(s) = 2^s \pi^{s-1} \Gamma(1-s) \zeta(1-s) + * \f] + */ + template<typename _Tp> + _Tp + __riemann_zeta_sum(const _Tp __s) + { + // A user shouldn't get to this. + if (__s < _Tp(1)) + std::__throw_domain_error(__N("Bad argument in zeta sum.")); + + const unsigned int max_iter = 10000; + _Tp __zeta = _Tp(0); + for (unsigned int __k = 1; __k < max_iter; ++__k) + { + _Tp __term = std::pow(static_cast<_Tp>(__k), -__s); + if (__term < std::numeric_limits<_Tp>::epsilon()) + { + break; + } + __zeta += __term; + } + + return __zeta; + } + + + /** + * @brief Evaluate the Riemann zeta function @f$ \zeta(s) @f$ + * by an alternate series for s > 0. + * + * The Riemann zeta function is defined by: + * \f[ + * \zeta(s) = \sum_{k=1}^{\infty} \frac{1}{k^{s}} for s > 1 + * \f] + * For s < 1 use the reflection formula: + * \f[ + * \zeta(s) = 2^s \pi^{s-1} \Gamma(1-s) \zeta(1-s) + * \f] + */ + template<typename _Tp> + _Tp + __riemann_zeta_alt(const _Tp __s) + { + _Tp __sgn = _Tp(1); + _Tp __zeta = _Tp(0); + for (unsigned int __i = 1; __i < 10000000; ++__i) + { + _Tp __term = __sgn / std::pow(__i, __s); + if (std::abs(__term) < std::numeric_limits<_Tp>::epsilon()) + break; + __zeta += __term; + __sgn *= _Tp(-1); + } + __zeta /= _Tp(1) - std::pow(_Tp(2), _Tp(1) - __s); + + return __zeta; + } + + + /** + * @brief Evaluate the Riemann zeta function by series for all s != 1. + * Convergence is great until largish negative numbers. + * Then the convergence of the > 0 sum gets better. + * + * The series is: + * \f[ + * \zeta(s) = \frac{1}{1-2^{1-s}} + * \sum_{n=0}^{\infty} \frac{1}{2^{n+1}} + * \sum_{k=0}^{n} (-1)^k \frac{n!}{(n-k)!k!} (k+1)^{-s} + * \f] + * Havil 2003, p. 206. + * + * The Riemann zeta function is defined by: + * \f[ + * \zeta(s) = \sum_{k=1}^{\infty} \frac{1}{k^{s}} for s > 1 + * \f] + * For s < 1 use the reflection formula: + * \f[ + * \zeta(s) = 2^s \pi^{s-1} \Gamma(1-s) \zeta(1-s) + * \f] + */ + template<typename _Tp> + _Tp + __riemann_zeta_glob(const _Tp __s) + { + _Tp __zeta = _Tp(0); + + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + // Max e exponent before overflow. + const _Tp __max_bincoeff = std::numeric_limits<_Tp>::max_exponent10 + * std::log(_Tp(10)) - _Tp(1); + + // This series works until the binomial coefficient blows up + // so use reflection. + if (__s < _Tp(0)) + { +#if _GLIBCXX_USE_C99_MATH_TR1 + if (std::tr1::fmod(__s,_Tp(2)) == _Tp(0)) + return _Tp(0); + else +#endif + { + _Tp __zeta = __riemann_zeta_glob(_Tp(1) - __s); + __zeta *= std::pow(_Tp(2) + * __numeric_constants<_Tp>::__pi(), __s) + * std::sin(__numeric_constants<_Tp>::__pi_2() * __s) +#if _GLIBCXX_USE_C99_MATH_TR1 + * std::exp(std::tr1::lgamma(_Tp(1) - __s)) +#else + * std::exp(__log_gamma(_Tp(1) - __s)) +#endif + / __numeric_constants<_Tp>::__pi(); + return __zeta; + } + } + + _Tp __num = _Tp(0.5L); + const unsigned int __maxit = 10000; + for (unsigned int __i = 0; __i < __maxit; ++__i) + { + bool __punt = false; + _Tp __sgn = _Tp(1); + _Tp __term = _Tp(0); + for (unsigned int __j = 0; __j <= __i; ++__j) + { +#if _GLIBCXX_USE_C99_MATH_TR1 + _Tp __bincoeff = std::tr1::lgamma(_Tp(1 + __i)) + - std::tr1::lgamma(_Tp(1 + __j)) + - std::tr1::lgamma(_Tp(1 + __i - __j)); +#else + _Tp __bincoeff = __log_gamma(_Tp(1 + __i)) + - __log_gamma(_Tp(1 + __j)) + - __log_gamma(_Tp(1 + __i - __j)); +#endif + if (__bincoeff > __max_bincoeff) + { + // This only gets hit for x << 0. + __punt = true; + break; + } + __bincoeff = std::exp(__bincoeff); + __term += __sgn * __bincoeff * std::pow(_Tp(1 + __j), -__s); + __sgn *= _Tp(-1); + } + if (__punt) + break; + __term *= __num; + __zeta += __term; + if (std::abs(__term/__zeta) < __eps) + break; + __num *= _Tp(0.5L); + } + + __zeta /= _Tp(1) - std::pow(_Tp(2), _Tp(1) - __s); + + return __zeta; + } + + + /** + * @brief Compute the Riemann zeta function @f$ \zeta(s) @f$ + * using the product over prime factors. + * \f[ + * \zeta(s) = \Pi_{i=1}^\infty \frac{1}{1 - p_i^{-s}} + * \f] + * where @f$ {p_i} @f$ are the prime numbers. + * + * The Riemann zeta function is defined by: + * \f[ + * \zeta(s) = \sum_{k=1}^{\infty} \frac{1}{k^{s}} for s > 1 + * \f] + * For s < 1 use the reflection formula: + * \f[ + * \zeta(s) = 2^s \pi^{s-1} \Gamma(1-s) \zeta(1-s) + * \f] + */ + template<typename _Tp> + _Tp + __riemann_zeta_product(const _Tp __s) + { + static const _Tp __prime[] = { + _Tp(2), _Tp(3), _Tp(5), _Tp(7), _Tp(11), _Tp(13), _Tp(17), _Tp(19), + _Tp(23), _Tp(29), _Tp(31), _Tp(37), _Tp(41), _Tp(43), _Tp(47), + _Tp(53), _Tp(59), _Tp(61), _Tp(67), _Tp(71), _Tp(73), _Tp(79), + _Tp(83), _Tp(89), _Tp(97), _Tp(101), _Tp(103), _Tp(107), _Tp(109) + }; + static const unsigned int __num_primes = sizeof(__prime) / sizeof(_Tp); + + _Tp __zeta = _Tp(1); + for (unsigned int __i = 0; __i < __num_primes; ++__i) + { + const _Tp __fact = _Tp(1) - std::pow(__prime[__i], -__s); + __zeta *= __fact; + if (_Tp(1) - __fact < std::numeric_limits<_Tp>::epsilon()) + break; + } + + __zeta = _Tp(1) / __zeta; + + return __zeta; + } + + + /** + * @brief Return the Riemann zeta function @f$ \zeta(s) @f$. + * + * The Riemann zeta function is defined by: + * \f[ + * \zeta(s) = \sum_{k=1}^{\infty} k^{-s} for s > 1 + * \frac{(2\pi)^s}{pi} sin(\frac{\pi s}{2}) + * \Gamma (1 - s) \zeta (1 - s) for s < 1 + * \f] + * For s < 1 use the reflection formula: + * \f[ + * \zeta(s) = 2^s \pi^{s-1} \Gamma(1-s) \zeta(1-s) + * \f] + */ + template<typename _Tp> + _Tp + __riemann_zeta(const _Tp __s) + { + if (__isnan(__s)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else if (__s == _Tp(1)) + return std::numeric_limits<_Tp>::infinity(); + else if (__s < -_Tp(19)) + { + _Tp __zeta = __riemann_zeta_product(_Tp(1) - __s); + __zeta *= std::pow(_Tp(2) * __numeric_constants<_Tp>::__pi(), __s) + * std::sin(__numeric_constants<_Tp>::__pi_2() * __s) +#if _GLIBCXX_USE_C99_MATH_TR1 + * std::exp(std::tr1::lgamma(_Tp(1) - __s)) +#else + * std::exp(__log_gamma(_Tp(1) - __s)) +#endif + / __numeric_constants<_Tp>::__pi(); + return __zeta; + } + else if (__s < _Tp(20)) + { + // Global double sum or McLaurin? + bool __glob = true; + if (__glob) + return __riemann_zeta_glob(__s); + else + { + if (__s > _Tp(1)) + return __riemann_zeta_sum(__s); + else + { + _Tp __zeta = std::pow(_Tp(2) + * __numeric_constants<_Tp>::__pi(), __s) + * std::sin(__numeric_constants<_Tp>::__pi_2() * __s) +#if _GLIBCXX_USE_C99_MATH_TR1 + * std::tr1::tgamma(_Tp(1) - __s) +#else + * std::exp(__log_gamma(_Tp(1) - __s)) +#endif + * __riemann_zeta_sum(_Tp(1) - __s); + return __zeta; + } + } + } + else + return __riemann_zeta_product(__s); + } + + + /** + * @brief Return the Hurwitz zeta function @f$ \zeta(x,s) @f$ + * for all s != 1 and x > -1. + * + * The Hurwitz zeta function is defined by: + * @f[ + * \zeta(x,s) = \sum_{n=0}^{\infty} \frac{1}{(n + x)^s} + * @f] + * The Riemann zeta function is a special case: + * @f[ + * \zeta(s) = \zeta(1,s) + * @f] + * + * This functions uses the double sum that converges for s != 1 + * and x > -1: + * @f[ + * \zeta(x,s) = \frac{1}{s-1} + * \sum_{n=0}^{\infty} \frac{1}{n + 1} + * \sum_{k=0}^{n} (-1)^k \frac{n!}{(n-k)!k!} (x+k)^{-s} + * @f] + */ + template<typename _Tp> + _Tp + __hurwitz_zeta_glob(const _Tp __a, const _Tp __s) + { + _Tp __zeta = _Tp(0); + + const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + // Max e exponent before overflow. + const _Tp __max_bincoeff = std::numeric_limits<_Tp>::max_exponent10 + * std::log(_Tp(10)) - _Tp(1); + + const unsigned int __maxit = 10000; + for (unsigned int __i = 0; __i < __maxit; ++__i) + { + bool __punt = false; + _Tp __sgn = _Tp(1); + _Tp __term = _Tp(0); + for (unsigned int __j = 0; __j <= __i; ++__j) + { +#if _GLIBCXX_USE_C99_MATH_TR1 + _Tp __bincoeff = std::tr1::lgamma(_Tp(1 + __i)) + - std::tr1::lgamma(_Tp(1 + __j)) + - std::tr1::lgamma(_Tp(1 + __i - __j)); +#else + _Tp __bincoeff = __log_gamma(_Tp(1 + __i)) + - __log_gamma(_Tp(1 + __j)) + - __log_gamma(_Tp(1 + __i - __j)); +#endif + if (__bincoeff > __max_bincoeff) + { + // This only gets hit for x << 0. + __punt = true; + break; + } + __bincoeff = std::exp(__bincoeff); + __term += __sgn * __bincoeff * std::pow(_Tp(__a + __j), -__s); + __sgn *= _Tp(-1); + } + if (__punt) + break; + __term /= _Tp(__i + 1); + if (std::abs(__term / __zeta) < __eps) + break; + __zeta += __term; + } + + __zeta /= __s - _Tp(1); + + return __zeta; + } + + + /** + * @brief Return the Hurwitz zeta function @f$ \zeta(x,s) @f$ + * for all s != 1 and x > -1. + * + * The Hurwitz zeta function is defined by: + * @f[ + * \zeta(x,s) = \sum_{n=0}^{\infty} \frac{1}{(n + x)^s} + * @f] + * The Riemann zeta function is a special case: + * @f[ + * \zeta(s) = \zeta(1,s) + * @f] + */ + template<typename _Tp> + inline _Tp + __hurwitz_zeta(const _Tp __a, const _Tp __s) + { + return __hurwitz_zeta_glob(__a, __s); + } + + } // namespace std::tr1::__detail +} +} + +#endif // _GLIBCXX_TR1_RIEMANN_ZETA_TCC diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/shared_ptr.h b/gcc-4.4.3/libstdc++-v3/include/tr1/shared_ptr.h new file mode 100644 index 000000000..0afce0155 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/shared_ptr.h @@ -0,0 +1,1020 @@ +// <tr1/shared_ptr.h> -*- C++ -*- + +// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +// shared_count.hpp +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. + +// shared_ptr.hpp +// Copyright (C) 1998, 1999 Greg Colvin and Beman Dawes. +// Copyright (C) 2001, 2002, 2003 Peter Dimov + +// weak_ptr.hpp +// Copyright (C) 2001, 2002, 2003 Peter Dimov + +// enable_shared_from_this.hpp +// Copyright (C) 2002 Peter Dimov + +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// GCC Note: based on version 1.32.0 of the Boost library. + +/** @file tr1/shared_ptr.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +#ifndef _TR1_SHARED_PTR_H +#define _TR1_SHARED_PTR_H 1 + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +namespace std +{ +namespace tr1 +{ + + template<typename _Ptr, typename _Deleter, _Lock_policy _Lp> + class _Sp_counted_base_impl + : public _Sp_counted_base<_Lp> + { + public: + /** + * @brief + * @pre __d(__p) must not throw. + */ + _Sp_counted_base_impl(_Ptr __p, _Deleter __d) + : _M_ptr(__p), _M_del(__d) { } + + virtual void + _M_dispose() // nothrow + { _M_del(_M_ptr); } + + virtual void* + _M_get_deleter(const std::type_info& __ti) + { return __ti == typeid(_Deleter) ? &_M_del : 0; } + + private: + _Sp_counted_base_impl(const _Sp_counted_base_impl&); + _Sp_counted_base_impl& operator=(const _Sp_counted_base_impl&); + + _Ptr _M_ptr; // copy constructor must not throw + _Deleter _M_del; // copy constructor must not throw + }; + + template<_Lock_policy _Lp = __default_lock_policy> + class __weak_count; + + template<typename _Tp> + struct _Sp_deleter + { + typedef void result_type; + typedef _Tp* argument_type; + void operator()(_Tp* __p) const { delete __p; } + }; + + template<_Lock_policy _Lp = __default_lock_policy> + class __shared_count + { + public: + __shared_count() + : _M_pi(0) // nothrow + { } + + template<typename _Ptr> + __shared_count(_Ptr __p) : _M_pi(0) + { + __try + { + typedef typename std::tr1::remove_pointer<_Ptr>::type _Tp; + _M_pi = new _Sp_counted_base_impl<_Ptr, _Sp_deleter<_Tp>, _Lp>( + __p, _Sp_deleter<_Tp>()); + } + __catch(...) + { + delete __p; + __throw_exception_again; + } + } + + template<typename _Ptr, typename _Deleter> + __shared_count(_Ptr __p, _Deleter __d) : _M_pi(0) + { + __try + { + _M_pi = new _Sp_counted_base_impl<_Ptr, _Deleter, _Lp>(__p, __d); + } + __catch(...) + { + __d(__p); // Call _Deleter on __p. + __throw_exception_again; + } + } + + // Special case for auto_ptr<_Tp> to provide the strong guarantee. + template<typename _Tp> + explicit + __shared_count(std::auto_ptr<_Tp>& __r) + : _M_pi(new _Sp_counted_base_impl<_Tp*, + _Sp_deleter<_Tp>, _Lp >(__r.get(), _Sp_deleter<_Tp>())) + { __r.release(); } + + // Throw bad_weak_ptr when __r._M_get_use_count() == 0. + explicit + __shared_count(const __weak_count<_Lp>& __r); + + ~__shared_count() // nothrow + { + if (_M_pi != 0) + _M_pi->_M_release(); + } + + __shared_count(const __shared_count& __r) + : _M_pi(__r._M_pi) // nothrow + { + if (_M_pi != 0) + _M_pi->_M_add_ref_copy(); + } + + __shared_count& + operator=(const __shared_count& __r) // nothrow + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + if (__tmp != _M_pi) + { + if (__tmp != 0) + __tmp->_M_add_ref_copy(); + if (_M_pi != 0) + _M_pi->_M_release(); + _M_pi = __tmp; + } + return *this; + } + + void + _M_swap(__shared_count& __r) // nothrow + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + __r._M_pi = _M_pi; + _M_pi = __tmp; + } + + long + _M_get_use_count() const // nothrow + { return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; } + + bool + _M_unique() const // nothrow + { return this->_M_get_use_count() == 1; } + + friend inline bool + operator==(const __shared_count& __a, const __shared_count& __b) + { return __a._M_pi == __b._M_pi; } + + friend inline bool + operator<(const __shared_count& __a, const __shared_count& __b) + { return std::less<_Sp_counted_base<_Lp>*>()(__a._M_pi, __b._M_pi); } + + void* + _M_get_deleter(const std::type_info& __ti) const + { return _M_pi ? _M_pi->_M_get_deleter(__ti) : 0; } + + private: + friend class __weak_count<_Lp>; + + _Sp_counted_base<_Lp>* _M_pi; + }; + + + template<_Lock_policy _Lp> + class __weak_count + { + public: + __weak_count() + : _M_pi(0) // nothrow + { } + + __weak_count(const __shared_count<_Lp>& __r) + : _M_pi(__r._M_pi) // nothrow + { + if (_M_pi != 0) + _M_pi->_M_weak_add_ref(); + } + + __weak_count(const __weak_count<_Lp>& __r) + : _M_pi(__r._M_pi) // nothrow + { + if (_M_pi != 0) + _M_pi->_M_weak_add_ref(); + } + + ~__weak_count() // nothrow + { + if (_M_pi != 0) + _M_pi->_M_weak_release(); + } + + __weak_count<_Lp>& + operator=(const __shared_count<_Lp>& __r) // nothrow + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + if (__tmp != 0) + __tmp->_M_weak_add_ref(); + if (_M_pi != 0) + _M_pi->_M_weak_release(); + _M_pi = __tmp; + return *this; + } + + __weak_count<_Lp>& + operator=(const __weak_count<_Lp>& __r) // nothrow + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + if (__tmp != 0) + __tmp->_M_weak_add_ref(); + if (_M_pi != 0) + _M_pi->_M_weak_release(); + _M_pi = __tmp; + return *this; + } + + void + _M_swap(__weak_count<_Lp>& __r) // nothrow + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + __r._M_pi = _M_pi; + _M_pi = __tmp; + } + + long + _M_get_use_count() const // nothrow + { return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; } + + friend inline bool + operator==(const __weak_count<_Lp>& __a, const __weak_count<_Lp>& __b) + { return __a._M_pi == __b._M_pi; } + + friend inline bool + operator<(const __weak_count<_Lp>& __a, const __weak_count<_Lp>& __b) + { return std::less<_Sp_counted_base<_Lp>*>()(__a._M_pi, __b._M_pi); } + + private: + friend class __shared_count<_Lp>; + + _Sp_counted_base<_Lp>* _M_pi; + }; + + // now that __weak_count is defined we can define this constructor: + template<_Lock_policy _Lp> + inline + __shared_count<_Lp>:: + __shared_count(const __weak_count<_Lp>& __r) + : _M_pi(__r._M_pi) + { + if (_M_pi != 0) + _M_pi->_M_add_ref_lock(); + else + __throw_bad_weak_ptr(); + } + + // Forward declarations. + template<typename _Tp, _Lock_policy _Lp = __default_lock_policy> + class __shared_ptr; + + template<typename _Tp, _Lock_policy _Lp = __default_lock_policy> + class __weak_ptr; + + template<typename _Tp, _Lock_policy _Lp = __default_lock_policy> + class __enable_shared_from_this; + + template<typename _Tp> + class shared_ptr; + + template<typename _Tp> + class weak_ptr; + + template<typename _Tp> + class enable_shared_from_this; + + // Support for enable_shared_from_this. + + // Friend of __enable_shared_from_this. + template<_Lock_policy _Lp, typename _Tp1, typename _Tp2> + void + __enable_shared_from_this_helper(const __shared_count<_Lp>&, + const __enable_shared_from_this<_Tp1, + _Lp>*, const _Tp2*); + + // Friend of enable_shared_from_this. + template<typename _Tp1, typename _Tp2> + void + __enable_shared_from_this_helper(const __shared_count<>&, + const enable_shared_from_this<_Tp1>*, + const _Tp2*); + + template<_Lock_policy _Lp> + inline void + __enable_shared_from_this_helper(const __shared_count<_Lp>&, ...) + { } + + + struct __static_cast_tag { }; + struct __const_cast_tag { }; + struct __dynamic_cast_tag { }; + + /** + * @class __shared_ptr + * + * A smart pointer with reference-counted copy semantics. + * The object pointed to is deleted when the last shared_ptr pointing to + * it is destroyed or reset. + */ + template<typename _Tp, _Lock_policy _Lp> + class __shared_ptr + { + public: + typedef _Tp element_type; + + /** @brief Construct an empty %__shared_ptr. + * @post use_count()==0 && get()==0 + */ + __shared_ptr() + : _M_ptr(0), _M_refcount() // never throws + { } + + /** @brief Construct a %__shared_ptr that owns the pointer @a __p. + * @param __p A pointer that is convertible to element_type*. + * @post use_count() == 1 && get() == __p + * @throw std::bad_alloc, in which case @c delete @a __p is called. + */ + template<typename _Tp1> + explicit + __shared_ptr(_Tp1* __p) + : _M_ptr(__p), _M_refcount(__p) + { + __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) + // __glibcxx_function_requires(_CompleteConcept<_Tp1*>) + __enable_shared_from_this_helper(_M_refcount, __p, __p); + } + + // + // Requirements: _Deleter's copy constructor and destructor must + // not throw + // + // __shared_ptr will release __p by calling __d(__p) + // + /** @brief Construct a %__shared_ptr that owns the pointer @a __p + * and the deleter @a __d. + * @param __p A pointer. + * @param __d A deleter. + * @post use_count() == 1 && get() == __p + * @throw std::bad_alloc, in which case @a __d(__p) is called. + */ + template<typename _Tp1, typename _Deleter> + __shared_ptr(_Tp1* __p, _Deleter __d) + : _M_ptr(__p), _M_refcount(__p, __d) + { + __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) + // TODO requires _Deleter CopyConstructible and __d(__p) well-formed + __enable_shared_from_this_helper(_M_refcount, __p, __p); + } + + // generated copy constructor, assignment, destructor are fine. + + /** @brief If @a __r is empty, constructs an empty %__shared_ptr; + * otherwise construct a %__shared_ptr that shares ownership + * with @a __r. + * @param __r A %__shared_ptr. + * @post get() == __r.get() && use_count() == __r.use_count() + */ + template<typename _Tp1> + __shared_ptr(const __shared_ptr<_Tp1, _Lp>& __r) + : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) // never throws + { __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) } + + /** @brief Constructs a %__shared_ptr that shares ownership with @a __r + * and stores a copy of the pointer stored in @a __r. + * @param __r A weak_ptr. + * @post use_count() == __r.use_count() + * @throw bad_weak_ptr when __r.expired(), + * in which case the constructor has no effect. + */ + template<typename _Tp1> + explicit + __shared_ptr(const __weak_ptr<_Tp1, _Lp>& __r) + : _M_refcount(__r._M_refcount) // may throw + { + __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) + // It is now safe to copy __r._M_ptr, as _M_refcount(__r._M_refcount) + // did not throw. + _M_ptr = __r._M_ptr; + } + +#if !defined(__GXX_EXPERIMENTAL_CXX0X__) || _GLIBCXX_DEPRECATED + /** + * @post use_count() == 1 and __r.get() == 0 + */ + template<typename _Tp1> + explicit + __shared_ptr(std::auto_ptr<_Tp1>& __r) + : _M_ptr(__r.get()), _M_refcount() + { + __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) + // TODO requires _Tp1 is complete, delete __r.release() well-formed + _Tp1* __tmp = __r.get(); + _M_refcount = __shared_count<_Lp>(__r); + __enable_shared_from_this_helper(_M_refcount, __tmp, __tmp); + } + +#endif + + template<typename _Tp1> + __shared_ptr(const __shared_ptr<_Tp1, _Lp>& __r, __static_cast_tag) + : _M_ptr(static_cast<element_type*>(__r._M_ptr)), + _M_refcount(__r._M_refcount) + { } + + template<typename _Tp1> + __shared_ptr(const __shared_ptr<_Tp1, _Lp>& __r, __const_cast_tag) + : _M_ptr(const_cast<element_type*>(__r._M_ptr)), + _M_refcount(__r._M_refcount) + { } + + template<typename _Tp1> + __shared_ptr(const __shared_ptr<_Tp1, _Lp>& __r, __dynamic_cast_tag) + : _M_ptr(dynamic_cast<element_type*>(__r._M_ptr)), + _M_refcount(__r._M_refcount) + { + if (_M_ptr == 0) // need to allocate new counter -- the cast failed + _M_refcount = __shared_count<_Lp>(); + } + + template<typename _Tp1> + __shared_ptr& + operator=(const __shared_ptr<_Tp1, _Lp>& __r) // never throws + { + _M_ptr = __r._M_ptr; + _M_refcount = __r._M_refcount; // __shared_count::op= doesn't throw + return *this; + } + +#if !defined(__GXX_EXPERIMENTAL_CXX0X__) || _GLIBCXX_DEPRECATED + template<typename _Tp1> + __shared_ptr& + operator=(std::auto_ptr<_Tp1>& __r) + { + __shared_ptr(__r).swap(*this); + return *this; + } +#endif + + void + reset() // never throws + { __shared_ptr().swap(*this); } + + template<typename _Tp1> + void + reset(_Tp1* __p) // _Tp1 must be complete. + { + // Catch self-reset errors. + _GLIBCXX_DEBUG_ASSERT(__p == 0 || __p != _M_ptr); + __shared_ptr(__p).swap(*this); + } + + template<typename _Tp1, typename _Deleter> + void + reset(_Tp1* __p, _Deleter __d) + { __shared_ptr(__p, __d).swap(*this); } + + // Allow class instantiation when _Tp is [cv-qual] void. + typename std::tr1::add_reference<_Tp>::type + operator*() const // never throws + { + _GLIBCXX_DEBUG_ASSERT(_M_ptr != 0); + return *_M_ptr; + } + + _Tp* + operator->() const // never throws + { + _GLIBCXX_DEBUG_ASSERT(_M_ptr != 0); + return _M_ptr; + } + + _Tp* + get() const // never throws + { return _M_ptr; } + + // Implicit conversion to "bool" + private: + typedef _Tp* __shared_ptr::*__unspecified_bool_type; + + public: + operator __unspecified_bool_type() const // never throws + { return _M_ptr == 0 ? 0 : &__shared_ptr::_M_ptr; } + + bool + unique() const // never throws + { return _M_refcount._M_unique(); } + + long + use_count() const // never throws + { return _M_refcount._M_get_use_count(); } + + void + swap(__shared_ptr<_Tp, _Lp>& __other) // never throws + { + std::swap(_M_ptr, __other._M_ptr); + _M_refcount._M_swap(__other._M_refcount); + } + + private: + void* + _M_get_deleter(const std::type_info& __ti) const + { return _M_refcount._M_get_deleter(__ti); } + + template<typename _Tp1, _Lock_policy _Lp1> + bool + _M_less(const __shared_ptr<_Tp1, _Lp1>& __rhs) const + { return _M_refcount < __rhs._M_refcount; } + + template<typename _Tp1, _Lock_policy _Lp1> friend class __shared_ptr; + template<typename _Tp1, _Lock_policy _Lp1> friend class __weak_ptr; + + template<typename _Del, typename _Tp1, _Lock_policy _Lp1> + friend _Del* get_deleter(const __shared_ptr<_Tp1, _Lp1>&); + + // Friends injected into enclosing namespace and found by ADL: + template<typename _Tp1> + friend inline bool + operator==(const __shared_ptr& __a, const __shared_ptr<_Tp1, _Lp>& __b) + { return __a.get() == __b.get(); } + + template<typename _Tp1> + friend inline bool + operator!=(const __shared_ptr& __a, const __shared_ptr<_Tp1, _Lp>& __b) + { return __a.get() != __b.get(); } + + template<typename _Tp1> + friend inline bool + operator<(const __shared_ptr& __a, const __shared_ptr<_Tp1, _Lp>& __b) + { return __a._M_less(__b); } + + _Tp* _M_ptr; // Contained pointer. + __shared_count<_Lp> _M_refcount; // Reference counter. + }; + + // 2.2.3.8 shared_ptr specialized algorithms. + template<typename _Tp, _Lock_policy _Lp> + inline void + swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b) + { __a.swap(__b); } + + // 2.2.3.9 shared_ptr casts + /** @warning The seemingly equivalent + * <code>shared_ptr<_Tp, _Lp>(static_cast<_Tp*>(__r.get()))</code> + * will eventually result in undefined behaviour, + * attempting to delete the same object twice. + */ + template<typename _Tp, typename _Tp1, _Lock_policy _Lp> + inline __shared_ptr<_Tp, _Lp> + static_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) + { return __shared_ptr<_Tp, _Lp>(__r, __static_cast_tag()); } + + /** @warning The seemingly equivalent + * <code>shared_ptr<_Tp, _Lp>(const_cast<_Tp*>(__r.get()))</code> + * will eventually result in undefined behaviour, + * attempting to delete the same object twice. + */ + template<typename _Tp, typename _Tp1, _Lock_policy _Lp> + inline __shared_ptr<_Tp, _Lp> + const_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) + { return __shared_ptr<_Tp, _Lp>(__r, __const_cast_tag()); } + + /** @warning The seemingly equivalent + * <code>shared_ptr<_Tp, _Lp>(dynamic_cast<_Tp*>(__r.get()))</code> + * will eventually result in undefined behaviour, + * attempting to delete the same object twice. + */ + template<typename _Tp, typename _Tp1, _Lock_policy _Lp> + inline __shared_ptr<_Tp, _Lp> + dynamic_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) + { return __shared_ptr<_Tp, _Lp>(__r, __dynamic_cast_tag()); } + + // 2.2.3.7 shared_ptr I/O + template<typename _Ch, typename _Tr, typename _Tp, _Lock_policy _Lp> + std::basic_ostream<_Ch, _Tr>& + operator<<(std::basic_ostream<_Ch, _Tr>& __os, + const __shared_ptr<_Tp, _Lp>& __p) + { + __os << __p.get(); + return __os; + } + + // 2.2.3.10 shared_ptr get_deleter (experimental) + template<typename _Del, typename _Tp, _Lock_policy _Lp> + inline _Del* + get_deleter(const __shared_ptr<_Tp, _Lp>& __p) + { return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del))); } + + + template<typename _Tp, _Lock_policy _Lp> + class __weak_ptr + { + public: + typedef _Tp element_type; + + __weak_ptr() + : _M_ptr(0), _M_refcount() // never throws + { } + + // Generated copy constructor, assignment, destructor are fine. + + // The "obvious" converting constructor implementation: + // + // template<typename _Tp1> + // __weak_ptr(const __weak_ptr<_Tp1, _Lp>& __r) + // : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) // never throws + // { } + // + // has a serious problem. + // + // __r._M_ptr may already have been invalidated. The _M_ptr(__r._M_ptr) + // conversion may require access to *__r._M_ptr (virtual inheritance). + // + // It is not possible to avoid spurious access violations since + // in multithreaded programs __r._M_ptr may be invalidated at any point. + template<typename _Tp1> + __weak_ptr(const __weak_ptr<_Tp1, _Lp>& __r) + : _M_refcount(__r._M_refcount) // never throws + { + __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) + _M_ptr = __r.lock().get(); + } + + template<typename _Tp1> + __weak_ptr(const __shared_ptr<_Tp1, _Lp>& __r) + : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) // never throws + { __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) } + + template<typename _Tp1> + __weak_ptr& + operator=(const __weak_ptr<_Tp1, _Lp>& __r) // never throws + { + _M_ptr = __r.lock().get(); + _M_refcount = __r._M_refcount; + return *this; + } + + template<typename _Tp1> + __weak_ptr& + operator=(const __shared_ptr<_Tp1, _Lp>& __r) // never throws + { + _M_ptr = __r._M_ptr; + _M_refcount = __r._M_refcount; + return *this; + } + + __shared_ptr<_Tp, _Lp> + lock() const // never throws + { +#ifdef __GTHREADS + // Optimization: avoid throw overhead. + if (expired()) + return __shared_ptr<element_type, _Lp>(); + + __try + { + return __shared_ptr<element_type, _Lp>(*this); + } + __catch(const bad_weak_ptr&) + { + // Q: How can we get here? + // A: Another thread may have invalidated r after the + // use_count test above. + return __shared_ptr<element_type, _Lp>(); + } + +#else + // Optimization: avoid try/catch overhead when single threaded. + return expired() ? __shared_ptr<element_type, _Lp>() + : __shared_ptr<element_type, _Lp>(*this); + +#endif + } // XXX MT + + long + use_count() const // never throws + { return _M_refcount._M_get_use_count(); } + + bool + expired() const // never throws + { return _M_refcount._M_get_use_count() == 0; } + + void + reset() // never throws + { __weak_ptr().swap(*this); } + + void + swap(__weak_ptr& __s) // never throws + { + std::swap(_M_ptr, __s._M_ptr); + _M_refcount._M_swap(__s._M_refcount); + } + + private: + // Used by __enable_shared_from_this. + void + _M_assign(_Tp* __ptr, const __shared_count<_Lp>& __refcount) + { + _M_ptr = __ptr; + _M_refcount = __refcount; + } + + template<typename _Tp1> + bool + _M_less(const __weak_ptr<_Tp1, _Lp>& __rhs) const + { return _M_refcount < __rhs._M_refcount; } + + template<typename _Tp1, _Lock_policy _Lp1> friend class __shared_ptr; + template<typename _Tp1, _Lock_policy _Lp1> friend class __weak_ptr; + friend class __enable_shared_from_this<_Tp, _Lp>; + friend class enable_shared_from_this<_Tp>; + + // Friend injected into namespace and found by ADL. + template<typename _Tp1> + friend inline bool + operator<(const __weak_ptr& __lhs, const __weak_ptr<_Tp1, _Lp>& __rhs) + { return __lhs._M_less(__rhs); } + + _Tp* _M_ptr; // Contained pointer. + __weak_count<_Lp> _M_refcount; // Reference counter. + }; + + // 2.2.4.7 weak_ptr specialized algorithms. + template<typename _Tp, _Lock_policy _Lp> + inline void + swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b) + { __a.swap(__b); } + + + template<typename _Tp, _Lock_policy _Lp> + class __enable_shared_from_this + { + protected: + __enable_shared_from_this() { } + + __enable_shared_from_this(const __enable_shared_from_this&) { } + + __enable_shared_from_this& + operator=(const __enable_shared_from_this&) + { return *this; } + + ~__enable_shared_from_this() { } + + public: + __shared_ptr<_Tp, _Lp> + shared_from_this() + { return __shared_ptr<_Tp, _Lp>(this->_M_weak_this); } + + __shared_ptr<const _Tp, _Lp> + shared_from_this() const + { return __shared_ptr<const _Tp, _Lp>(this->_M_weak_this); } + + private: + template<typename _Tp1> + void + _M_weak_assign(_Tp1* __p, const __shared_count<_Lp>& __n) const + { _M_weak_this._M_assign(__p, __n); } + + template<typename _Tp1> + friend void + __enable_shared_from_this_helper(const __shared_count<_Lp>& __pn, + const __enable_shared_from_this* __pe, + const _Tp1* __px) + { + if (__pe != 0) + __pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn); + } + + mutable __weak_ptr<_Tp, _Lp> _M_weak_this; + }; + + + /// shared_ptr + // The actual shared_ptr, with forwarding constructors and + // assignment operators. + template<typename _Tp> + class shared_ptr + : public __shared_ptr<_Tp> + { + public: + shared_ptr() + : __shared_ptr<_Tp>() { } + + template<typename _Tp1> + explicit + shared_ptr(_Tp1* __p) + : __shared_ptr<_Tp>(__p) { } + + template<typename _Tp1, typename _Deleter> + shared_ptr(_Tp1* __p, _Deleter __d) + : __shared_ptr<_Tp>(__p, __d) { } + + template<typename _Tp1> + shared_ptr(const shared_ptr<_Tp1>& __r) + : __shared_ptr<_Tp>(__r) { } + + template<typename _Tp1> + explicit + shared_ptr(const weak_ptr<_Tp1>& __r) + : __shared_ptr<_Tp>(__r) { } + +#if !defined(__GXX_EXPERIMENTAL_CXX0X__) || _GLIBCXX_DEPRECATED + template<typename _Tp1> + explicit + shared_ptr(std::auto_ptr<_Tp1>& __r) + : __shared_ptr<_Tp>(__r) { } +#endif + + template<typename _Tp1> + shared_ptr(const shared_ptr<_Tp1>& __r, __static_cast_tag) + : __shared_ptr<_Tp>(__r, __static_cast_tag()) { } + + template<typename _Tp1> + shared_ptr(const shared_ptr<_Tp1>& __r, __const_cast_tag) + : __shared_ptr<_Tp>(__r, __const_cast_tag()) { } + + template<typename _Tp1> + shared_ptr(const shared_ptr<_Tp1>& __r, __dynamic_cast_tag) + : __shared_ptr<_Tp>(__r, __dynamic_cast_tag()) { } + + template<typename _Tp1> + shared_ptr& + operator=(const shared_ptr<_Tp1>& __r) // never throws + { + this->__shared_ptr<_Tp>::operator=(__r); + return *this; + } + +#if !defined(__GXX_EXPERIMENTAL_CXX0X__) || _GLIBCXX_DEPRECATED + template<typename _Tp1> + shared_ptr& + operator=(std::auto_ptr<_Tp1>& __r) + { + this->__shared_ptr<_Tp>::operator=(__r); + return *this; + } +#endif + }; + + // 2.2.3.8 shared_ptr specialized algorithms. + template<typename _Tp> + inline void + swap(__shared_ptr<_Tp>& __a, __shared_ptr<_Tp>& __b) + { __a.swap(__b); } + + template<typename _Tp, typename _Tp1> + inline shared_ptr<_Tp> + static_pointer_cast(const shared_ptr<_Tp1>& __r) + { return shared_ptr<_Tp>(__r, __static_cast_tag()); } + + template<typename _Tp, typename _Tp1> + inline shared_ptr<_Tp> + const_pointer_cast(const shared_ptr<_Tp1>& __r) + { return shared_ptr<_Tp>(__r, __const_cast_tag()); } + + template<typename _Tp, typename _Tp1> + inline shared_ptr<_Tp> + dynamic_pointer_cast(const shared_ptr<_Tp1>& __r) + { return shared_ptr<_Tp>(__r, __dynamic_cast_tag()); } + + + /// weak_ptr + // The actual weak_ptr, with forwarding constructors and + // assignment operators. + template<typename _Tp> + class weak_ptr + : public __weak_ptr<_Tp> + { + public: + weak_ptr() + : __weak_ptr<_Tp>() { } + + template<typename _Tp1> + weak_ptr(const weak_ptr<_Tp1>& __r) + : __weak_ptr<_Tp>(__r) { } + + template<typename _Tp1> + weak_ptr(const shared_ptr<_Tp1>& __r) + : __weak_ptr<_Tp>(__r) { } + + template<typename _Tp1> + weak_ptr& + operator=(const weak_ptr<_Tp1>& __r) // never throws + { + this->__weak_ptr<_Tp>::operator=(__r); + return *this; + } + + template<typename _Tp1> + weak_ptr& + operator=(const shared_ptr<_Tp1>& __r) // never throws + { + this->__weak_ptr<_Tp>::operator=(__r); + return *this; + } + + shared_ptr<_Tp> + lock() const // never throws + { +#ifdef __GTHREADS + if (this->expired()) + return shared_ptr<_Tp>(); + + __try + { + return shared_ptr<_Tp>(*this); + } + __catch(const bad_weak_ptr&) + { + return shared_ptr<_Tp>(); + } +#else + return this->expired() ? shared_ptr<_Tp>() + : shared_ptr<_Tp>(*this); +#endif + } + }; + + /// enable_shared_from_this + template<typename _Tp> + class enable_shared_from_this + { + protected: + enable_shared_from_this() { } + + enable_shared_from_this(const enable_shared_from_this&) { } + + enable_shared_from_this& + operator=(const enable_shared_from_this&) + { return *this; } + + ~enable_shared_from_this() { } + + public: + shared_ptr<_Tp> + shared_from_this() + { return shared_ptr<_Tp>(this->_M_weak_this); } + + shared_ptr<const _Tp> + shared_from_this() const + { return shared_ptr<const _Tp>(this->_M_weak_this); } + + private: + template<typename _Tp1> + void + _M_weak_assign(_Tp1* __p, const __shared_count<>& __n) const + { _M_weak_this._M_assign(__p, __n); } + + template<typename _Tp1> + friend void + __enable_shared_from_this_helper(const __shared_count<>& __pn, + const enable_shared_from_this* __pe, + const _Tp1* __px) + { + if (__pe != 0) + __pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn); + } + + mutable weak_ptr<_Tp> _M_weak_this; + }; + +} +} + +#endif // _TR1_SHARED_PTR_H diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/special_function_util.h b/gcc-4.4.3/libstdc++-v3/include/tr1/special_function_util.h new file mode 100644 index 000000000..d2699bd85 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/special_function_util.h @@ -0,0 +1,144 @@ +// Special functions -*- C++ -*- + +// Copyright (C) 2006, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/special_function_util.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +// +// ISO C++ 14882 TR1: 5.2 Special functions +// + +// Written by Edward Smith-Rowland based on numerous mathematics books. + +#ifndef _GLIBCXX_TR1_SPECIAL_FUNCTION_UTIL_H +#define _GLIBCXX_TR1_SPECIAL_FUNCTION_UTIL_H 1 + +namespace std +{ +namespace tr1 +{ + + namespace __detail + { + + /// A class to encapsulate type dependent floating point + /// constants. Not everything will be able to be expressed as + /// type logic. + template<typename _Tp> + struct __floating_point_constant + { + static const _Tp __value; + }; + + + /// A structure for numeric constants. + template<typename _Tp> + struct __numeric_constants + { + /// Constant @f$ \pi @f$. + static _Tp __pi() throw() + { return static_cast<_Tp>(3.1415926535897932384626433832795029L); } + /// Constant @f$ \pi / 2 @f$. + static _Tp __pi_2() throw() + { return static_cast<_Tp>(1.5707963267948966192313216916397514L); } + /// Constant @f$ \pi / 3 @f$. + static _Tp __pi_3() throw() + { return static_cast<_Tp>(1.0471975511965977461542144610931676L); } + /// Constant @f$ \pi / 4 @f$. + static _Tp __pi_4() throw() + { return static_cast<_Tp>(0.7853981633974483096156608458198757L); } + /// Constant @f$ 1 / \pi @f$. + static _Tp __1_pi() throw() + { return static_cast<_Tp>(0.3183098861837906715377675267450287L); } + /// Constant @f$ 2 / \sqrt(\pi) @f$. + static _Tp __2_sqrtpi() throw() + { return static_cast<_Tp>(1.1283791670955125738961589031215452L); } + /// Constant @f$ \sqrt(2) @f$. + static _Tp __sqrt2() throw() + { return static_cast<_Tp>(1.4142135623730950488016887242096981L); } + /// Constant @f$ \sqrt(3) @f$. + static _Tp __sqrt3() throw() + { return static_cast<_Tp>(1.7320508075688772935274463415058723L); } + /// Constant @f$ \sqrt(\pi/2) @f$. + static _Tp __sqrtpio2() throw() + { return static_cast<_Tp>(1.2533141373155002512078826424055226L); } + /// Constant @f$ 1 / sqrt(2) @f$. + static _Tp __sqrt1_2() throw() + { return static_cast<_Tp>(0.7071067811865475244008443621048490L); } + /// Constant @f$ \log(\pi) @f$. + static _Tp __lnpi() throw() + { return static_cast<_Tp>(1.1447298858494001741434273513530587L); } + /// Constant Euler's constant @f$ \gamma_E @f$. + static _Tp __gamma_e() throw() + { return static_cast<_Tp>(0.5772156649015328606065120900824024L); } + /// Constant Euler-Mascheroni @f$ e @f$ + static _Tp __euler() throw() + { return static_cast<_Tp>(2.7182818284590452353602874713526625L); } + }; + + +#if _GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC + + /// This is a wrapper for the isnan function. Otherwise, for NaN, + /// all comparisons result in false. If/when we build a std::isnan + /// out of intrinsics, this will disappear completely in favor of + /// std::isnan. + template<typename _Tp> + inline bool __isnan(const _Tp __x) + { + return std::isnan(__x); + } + +#else + + template<typename _Tp> + inline bool __isnan(const _Tp __x) + { + return __builtin_isnan(__x); + } + + template<> + inline bool __isnan<float>(const float __x) + { + return __builtin_isnanf(__x); + } + + template<> + inline bool __isnan<long double>(const long double __x) + { + return __builtin_isnanl(__x); + } + +#endif + + } // namespace __detail + +} +} + +#endif // _GLIBCXX_TR1_SPECIAL_FUNCTION_UTIL_H + diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/stdarg.h b/gcc-4.4.3/libstdc++-v3/include/tr1/stdarg.h new file mode 100644 index 000000000..41173e847 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/stdarg.h @@ -0,0 +1,34 @@ +// TR1 stdarg.h -*- C++ -*- + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/stdarg.h + * This is a TR1 C++ Library header. + */ + +#ifndef _TR1_STDARG_H +#define _TR1_STDARG_H 1 + +#include <tr1/cstdarg> + +#endif diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/stdbool.h b/gcc-4.4.3/libstdc++-v3/include/tr1/stdbool.h new file mode 100644 index 000000000..3861e4457 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/stdbool.h @@ -0,0 +1,34 @@ +// TR1 stdbool.h -*- C++ -*- + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/stdbool.h + * This is a TR1 C++ Library header. + */ + +#ifndef _TR1_STDBOOL_H +#define _TR1_STDBOOL_H 1 + +#include <tr1/cstdbool> + +#endif diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/stdint.h b/gcc-4.4.3/libstdc++-v3/include/tr1/stdint.h new file mode 100644 index 000000000..8113fa5ad --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/stdint.h @@ -0,0 +1,34 @@ +// TR1 stdint.h -*- C++ -*- + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/stdint.h + * This is a TR1 C++ Library header. + */ + +#ifndef _TR1_STDINT_H +#define _TR1_STDINT_H 1 + +#include <tr1/cstdint> + +#endif diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/stdio.h b/gcc-4.4.3/libstdc++-v3/include/tr1/stdio.h new file mode 100644 index 000000000..f1edf8395 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/stdio.h @@ -0,0 +1,34 @@ +// TR1 stdio.h -*- C++ -*- + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/stdio.h + * This is a TR1 C++ Library header. + */ + +#ifndef _TR1_STDIO_H +#define _TR1_STDIO_H 1 + +#include <tr1/cstdio> + +#endif diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/stdlib.h b/gcc-4.4.3/libstdc++-v3/include/tr1/stdlib.h new file mode 100644 index 000000000..5e57aecbf --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/stdlib.h @@ -0,0 +1,52 @@ +// TR1 stdlib.h -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/stdlib.h + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_STDLIB_H +#define _GLIBCXX_TR1_STDLIB_H 1 + +#include <tr1/cstdlib> + +#if _GLIBCXX_HOSTED + +#if _GLIBCXX_USE_C99 + +using std::tr1::atoll; +using std::tr1::strtoll; +using std::tr1::strtoull; + +using std::tr1::abs; +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC +using std::tr1::div; +#endif + +#endif + +#endif + +#endif // _GLIBCXX_TR1_STDLIB_H + diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/tgmath.h b/gcc-4.4.3/libstdc++-v3/include/tr1/tgmath.h new file mode 100644 index 000000000..c807031e5 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/tgmath.h @@ -0,0 +1,34 @@ +// TR1 tgmath.h -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/tgmath.h + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_TGMATH_H +#define _GLIBCXX_TR1_TGMATH_H 1 + +#include <tr1/ctgmath> + +#endif // _GLIBCXX_TR1_TGMATH_H diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/tuple b/gcc-4.4.3/libstdc++-v3/include/tr1/tuple new file mode 100644 index 000000000..ff9f22061 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/tuple @@ -0,0 +1,422 @@ +// class template tuple -*- C++ -*- + +// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/tuple +* This is a TR1 C++ Library header. +*/ + +// Chris Jefferson <chris@bubblescope.net> +// Variadic Templates support by Douglas Gregor <doug.gregor@gmail.com> + +#ifndef _GLIBCXX_TR1_TUPLE +#define _GLIBCXX_TR1_TUPLE 1 + +#pragma GCC system_header + +#include <utility> + +namespace std +{ +namespace tr1 +{ + // Adds a const reference to a non-reference type. + template<typename _Tp> + struct __add_c_ref + { typedef const _Tp& type; }; + + template<typename _Tp> + struct __add_c_ref<_Tp&> + { typedef _Tp& type; }; + + // Adds a reference to a non-reference type. + template<typename _Tp> + struct __add_ref + { typedef _Tp& type; }; + + template<typename _Tp> + struct __add_ref<_Tp&> + { typedef _Tp& type; }; + + /** + * Contains the actual implementation of the @c tuple template, stored + * as a recursive inheritance hierarchy from the first element (most + * derived class) to the last (least derived class). The @c Idx + * parameter gives the 0-based index of the element stored at this + * point in the hierarchy; we use it to implement a constant-time + * get() operation. + */ + template<int _Idx, typename... _Elements> + struct _Tuple_impl; + + /** + * Zero-element tuple implementation. This is the basis case for the + * inheritance recursion. + */ + template<int _Idx> + struct _Tuple_impl<_Idx> { }; + + /** + * Recursive tuple implementation. Here we store the @c Head element + * and derive from a @c Tuple_impl containing the remaining elements + * (which contains the @c Tail). + */ + template<int _Idx, typename _Head, typename... _Tail> + struct _Tuple_impl<_Idx, _Head, _Tail...> + : public _Tuple_impl<_Idx + 1, _Tail...> + { + typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited; + + _Head _M_head; + + _Inherited& _M_tail() { return *this; } + const _Inherited& _M_tail() const { return *this; } + + _Tuple_impl() : _Inherited(), _M_head() { } + + explicit + _Tuple_impl(typename __add_c_ref<_Head>::type __head, + typename __add_c_ref<_Tail>::type... __tail) + : _Inherited(__tail...), _M_head(__head) { } + + template<typename... _UElements> + _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in) + : _Inherited(__in._M_tail()), _M_head(__in._M_head) { } + + _Tuple_impl(const _Tuple_impl& __in) + : _Inherited(__in._M_tail()), _M_head(__in._M_head) { } + + template<typename... _UElements> + _Tuple_impl& + operator=(const _Tuple_impl<_Idx, _UElements...>& __in) + { + _M_head = __in._M_head; + _M_tail() = __in._M_tail(); + return *this; + } + + _Tuple_impl& + operator=(const _Tuple_impl& __in) + { + _M_head = __in._M_head; + _M_tail() = __in._M_tail(); + return *this; + } + }; + + template<typename... _Elements> + class tuple : public _Tuple_impl<0, _Elements...> + { + typedef _Tuple_impl<0, _Elements...> _Inherited; + + public: + tuple() : _Inherited() { } + + explicit + tuple(typename __add_c_ref<_Elements>::type... __elements) + : _Inherited(__elements...) { } + + template<typename... _UElements> + tuple(const tuple<_UElements...>& __in) + : _Inherited(__in) { } + + tuple(const tuple& __in) + : _Inherited(__in) { } + + template<typename... _UElements> + tuple& + operator=(const tuple<_UElements...>& __in) + { + static_cast<_Inherited&>(*this) = __in; + return *this; + } + + tuple& + operator=(const tuple& __in) + { + static_cast<_Inherited&>(*this) = __in; + return *this; + } + }; + + template<> class tuple<> { }; + + // 2-element tuple, with construction and assignment from a pair. + template<typename _T1, typename _T2> + class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2> + { + typedef _Tuple_impl<0, _T1, _T2> _Inherited; + + public: + tuple() : _Inherited() { } + + explicit + tuple(typename __add_c_ref<_T1>::type __a1, + typename __add_c_ref<_T2>::type __a2) + : _Inherited(__a1, __a2) { } + + template<typename _U1, typename _U2> + tuple(const tuple<_U1, _U2>& __in) + : _Inherited(__in) { } + + tuple(const tuple& __in) + : _Inherited(__in) { } + + template<typename _U1, typename _U2> + tuple(const pair<_U1, _U2>& __in) + : _Inherited(_Tuple_impl<0, + typename __add_c_ref<_U1>::type, + typename __add_c_ref<_U2>::type>(__in.first, + __in.second)) + { } + + template<typename _U1, typename _U2> + tuple& + operator=(const tuple<_U1, _U2>& __in) + { + static_cast<_Inherited&>(*this) = __in; + return *this; + } + + tuple& + operator=(const tuple& __in) + { + static_cast<_Inherited&>(*this) = __in; + return *this; + } + + template<typename _U1, typename _U2> + tuple& + operator=(const pair<_U1, _U2>& __in) + { + this->_M_head = __in.first; + this->_M_tail()._M_head = __in.second; + return *this; + } + }; + + + /// Gives the type of the ith element of a given tuple type. + template<int __i, typename _Tp> + struct tuple_element; + + /** + * Recursive case for tuple_element: strip off the first element in + * the tuple and retrieve the (i-1)th element of the remaining tuple. + */ + template<int __i, typename _Head, typename... _Tail> + struct tuple_element<__i, tuple<_Head, _Tail...> > + : tuple_element<__i - 1, tuple<_Tail...> > { }; + + /** + * Basis case for tuple_element: The first element is the one we're seeking. + */ + template<typename _Head, typename... _Tail> + struct tuple_element<0, tuple<_Head, _Tail...> > + { + typedef _Head type; + }; + + /// Finds the size of a given tuple type. + template<typename _Tp> + struct tuple_size; + + /// class tuple_size + template<typename... _Elements> + struct tuple_size<tuple<_Elements...> > + { + static const int value = sizeof...(_Elements); + }; + + template<typename... _Elements> + const int tuple_size<tuple<_Elements...> >::value; + + template<int __i, typename _Head, typename... _Tail> + inline typename __add_ref<_Head>::type + __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t) + { + return __t._M_head; + } + + template<int __i, typename _Head, typename... _Tail> + inline typename __add_c_ref<_Head>::type + __get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t) + { + return __t._M_head; + } + + // Return a reference (const reference) to the ith element of a tuple. + // Any const or non-const ref elements are returned with their original type. + template<int __i, typename... _Elements> + inline typename __add_ref< + typename tuple_element<__i, tuple<_Elements...> >::type + >::type + get(tuple<_Elements...>& __t) + { + return __get_helper<__i>(__t); + } + + template<int __i, typename... _Elements> + inline typename __add_c_ref< + typename tuple_element<__i, tuple<_Elements...> >::type + >::type + get(const tuple<_Elements...>& __t) + { + return __get_helper<__i>(__t); + } + + // This class helps construct the various comparison operations on tuples + template<int __check_equal_size, int __i, int __j, + typename _Tp, typename _Up> + struct __tuple_compare; + + template<int __i, int __j, typename _Tp, typename _Up> + struct __tuple_compare<0, __i, __j, _Tp, _Up> + { + static bool __eq(const _Tp& __t, const _Up& __u) + { + return (get<__i>(__t) == get<__i>(__u) && + __tuple_compare<0, __i+1, __j, _Tp, _Up>::__eq(__t, __u)); + } + + static bool __less(const _Tp& __t, const _Up& __u) + { + return ((get<__i>(__t) < get<__i>(__u)) + || !(get<__i>(__u) < get<__i>(__t)) && + __tuple_compare<0, __i+1, __j, _Tp, _Up>::__less(__t, __u)); + } + }; + + template<int __i, typename _Tp, typename _Up> + struct __tuple_compare<0, __i, __i, _Tp, _Up> + { + static bool __eq(const _Tp&, const _Up&) + { return true; } + + static bool __less(const _Tp&, const _Up&) + { return false; } + }; + + template<typename... _TElements, typename... _UElements> + bool + operator==(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { + typedef tuple<_TElements...> _Tp; + typedef tuple<_UElements...> _Up; + return (__tuple_compare<tuple_size<_Tp>::value - tuple_size<_Up>::value, + 0, tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u)); + } + + template<typename... _TElements, typename... _UElements> + bool + operator<(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { + typedef tuple<_TElements...> _Tp; + typedef tuple<_UElements...> _Up; + return (__tuple_compare<tuple_size<_Tp>::value - tuple_size<_Up>::value, + 0, tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u)); + } + + template<typename... _TElements, typename... _UElements> + inline bool + operator!=(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { return !(__t == __u); } + + template<typename... _TElements, typename... _UElements> + inline bool + operator>(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { return __u < __t; } + + template<typename... _TElements, typename... _UElements> + inline bool + operator<=(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { return !(__u < __t); } + + template<typename... _TElements, typename... _UElements> + inline bool + operator>=(const tuple<_TElements...>& __t, + const tuple<_UElements...>& __u) + { return !(__t < __u); } + + template<typename _Tp> + class reference_wrapper; + + // Helper which adds a reference to a type when given a reference_wrapper + template<typename _Tp> + struct __strip_reference_wrapper + { + typedef _Tp __type; + }; + + template<typename _Tp> + struct __strip_reference_wrapper<reference_wrapper<_Tp> > + { + typedef _Tp& __type; + }; + + template<typename _Tp> + struct __strip_reference_wrapper<const reference_wrapper<_Tp> > + { + typedef _Tp& __type; + }; + + template<typename... _Elements> + inline tuple<typename __strip_reference_wrapper<_Elements>::__type...> + make_tuple(_Elements... __args) + { + typedef tuple<typename __strip_reference_wrapper<_Elements>::__type...> + __result_type; + return __result_type(__args...); + } + + template<typename... _Elements> + inline tuple<_Elements&...> + tie(_Elements&... __args) + { + return tuple<_Elements&...>(__args...); + } + + // A class (and instance) which can be used in 'tie' when an element + // of a tuple is not required + struct _Swallow_assign + { + template<class _Tp> + _Swallow_assign& + operator=(const _Tp&) + { return *this; } + }; + + // TODO: Put this in some kind of shared file. + namespace + { + _Swallow_assign ignore; + }; // anonymous namespace +} +} + +#endif // _GLIBCXX_TR1_TUPLE diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/type_traits b/gcc-4.4.3/libstdc++-v3/include/tr1/type_traits new file mode 100644 index 000000000..fe28f8478 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/type_traits @@ -0,0 +1,249 @@ +// TR1 type_traits -*- C++ -*- + +// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/type_traits + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_TYPE_TRAITS +#define _GLIBCXX_TR1_TYPE_TRAITS 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <cstddef> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/type_traits> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/type_traits> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +namespace std +{ +namespace tr1 +{ +#define _DEFINE_SPEC(_Trait, _Type) \ + template<> \ + struct _Trait<_Type> \ + : public true_type { }; + + template<typename> + struct is_reference + : public false_type { }; + + template<typename _Tp> + struct is_reference<_Tp&> + : public true_type { }; + + template<typename _Tp> + struct is_pod + : public integral_constant<bool, __is_pod(_Tp) || is_void<_Tp>::value> + { }; + + template<typename _Tp> + struct has_trivial_constructor + : public integral_constant<bool, is_pod<_Tp>::value> + { }; + + template<typename _Tp> + struct has_trivial_copy + : public integral_constant<bool, is_pod<_Tp>::value> + { }; + + template<typename _Tp> + struct has_trivial_assign + : public integral_constant<bool, is_pod<_Tp>::value> + { }; + + template<typename _Tp> + struct has_trivial_destructor + : public integral_constant<bool, is_pod<_Tp>::value> + { }; + + template<typename _Tp> + struct has_nothrow_constructor + : public integral_constant<bool, is_pod<_Tp>::value> + { }; + + template<typename _Tp> + struct has_nothrow_copy + : public integral_constant<bool, is_pod<_Tp>::value> + { }; + + template<typename _Tp> + struct has_nothrow_assign + : public integral_constant<bool, is_pod<_Tp>::value> + { }; + + template<typename> + struct __is_signed_helper + : public false_type { }; + _DEFINE_SPEC(__is_signed_helper, signed char) + _DEFINE_SPEC(__is_signed_helper, short) + _DEFINE_SPEC(__is_signed_helper, int) + _DEFINE_SPEC(__is_signed_helper, long) + _DEFINE_SPEC(__is_signed_helper, long long) + + template<typename _Tp> + struct is_signed + : public integral_constant<bool, (__is_signed_helper<typename + remove_cv<_Tp>::type>::value)> + { }; + + template<typename> + struct __is_unsigned_helper + : public false_type { }; + _DEFINE_SPEC(__is_unsigned_helper, unsigned char) + _DEFINE_SPEC(__is_unsigned_helper, unsigned short) + _DEFINE_SPEC(__is_unsigned_helper, unsigned int) + _DEFINE_SPEC(__is_unsigned_helper, unsigned long) + _DEFINE_SPEC(__is_unsigned_helper, unsigned long long) + + template<typename _Tp> + struct is_unsigned + : public integral_constant<bool, (__is_unsigned_helper<typename + remove_cv<_Tp>::type>::value)> + { }; + + template<typename _Base, typename _Derived> + struct __is_base_of_helper + { + typedef typename remove_cv<_Base>::type _NoCv_Base; + typedef typename remove_cv<_Derived>::type _NoCv_Derived; + static const bool __value = (is_same<_Base, _Derived>::value + || (__is_base_of(_Base, _Derived) + && !is_same<_NoCv_Base, + _NoCv_Derived>::value)); + }; + + template<typename _Base, typename _Derived> + struct is_base_of + : public integral_constant<bool, + __is_base_of_helper<_Base, _Derived>::__value> + { }; + + template<typename _From, typename _To> + struct __is_convertible_simple + : public __sfinae_types + { + private: + static __one __test(_To); + static __two __test(...); + static _From __makeFrom(); + + public: + static const bool __value = sizeof(__test(__makeFrom())) == 1; + }; + + template<typename _Tp> + struct add_reference; + + template<typename _Tp> + struct __is_int_or_cref + { + typedef typename remove_reference<_Tp>::type __rr_Tp; + static const bool __value = (is_integral<_Tp>::value + || (is_integral<__rr_Tp>::value + && is_const<__rr_Tp>::value + && !is_volatile<__rr_Tp>::value)); + }; + + template<typename _From, typename _To, + bool = (is_void<_From>::value || is_void<_To>::value + || is_function<_To>::value || is_array<_To>::value + // This special case is here only to avoid warnings. + || (is_floating_point<typename + remove_reference<_From>::type>::value + && __is_int_or_cref<_To>::__value))> + struct __is_convertible_helper + { + // "An imaginary lvalue of type From...". + static const bool __value = (__is_convertible_simple<typename + add_reference<_From>::type, _To>::__value); + }; + + template<typename _From, typename _To> + struct __is_convertible_helper<_From, _To, true> + { static const bool __value = (is_void<_To>::value + || (__is_int_or_cref<_To>::__value + && !is_void<_From>::value)); }; + + template<typename _From, typename _To> + struct is_convertible + : public integral_constant<bool, + __is_convertible_helper<_From, _To>::__value> + { }; + + // reference modifications [4.7.2]. + template<typename _Tp> + struct remove_reference + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_reference<_Tp&> + { typedef _Tp type; }; + + // NB: Careful with reference to void. + template<typename _Tp, bool = (is_void<_Tp>::value + || is_reference<_Tp>::value)> + struct __add_reference_helper + { typedef _Tp& type; }; + + template<typename _Tp> + struct __add_reference_helper<_Tp, true> + { typedef _Tp type; }; + + template<typename _Tp> + struct add_reference + : public __add_reference_helper<_Tp> + { }; + + // other transformations [4.8]. + template<std::size_t _Len, std::size_t _Align> + struct aligned_storage + { + union type + { + unsigned char __data[_Len]; + struct __attribute__((__aligned__((_Align)))) { } __align; + }; + }; + +#undef _DEFINE_SPEC +} +} + +#endif // _GLIBCXX_TR1_TYPE_TRAITS diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/unordered_map b/gcc-4.4.3/libstdc++-v3/include/tr1/unordered_map new file mode 100644 index 000000000..316630f4c --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/unordered_map @@ -0,0 +1,61 @@ +// TR1 unordered_map -*- C++ -*- + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/unordered_map + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_UNORDERED_MAP +#define _GLIBCXX_TR1_UNORDERED_MAP 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <utility> +#include <bits/stl_algobase.h> +#include <bits/allocator.h> +#include <bits/stl_function.h> // equal_to, _Identity, _Select1st +#include <bits/stringfwd.h> +#include <tr1/type_traits> +#include <tr1/functional_hash.h> +#include <tr1/hashtable.h> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/unordered_map> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/unordered_map> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_UNORDERED_MAP diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/unordered_set b/gcc-4.4.3/libstdc++-v3/include/tr1/unordered_set new file mode 100644 index 000000000..3bd09444e --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/unordered_set @@ -0,0 +1,61 @@ +// TR1 unordered_set -*- C++ -*- + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/unordered_set + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_UNORDERED_SET +#define _GLIBCXX_TR1_UNORDERED_SET 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <utility> +#include <bits/stl_algobase.h> +#include <bits/allocator.h> +#include <bits/stl_function.h> // equal_to, _Identity, _Select1st +#include <bits/stringfwd.h> +#include <tr1/type_traits> +#include <tr1/functional_hash.h> +#include <tr1/hashtable.h> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/unordered_set> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/unordered_set> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_UNORDERED_SET diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/utility b/gcc-4.4.3/libstdc++-v3/include/tr1/utility new file mode 100644 index 000000000..0aac2b282 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/utility @@ -0,0 +1,56 @@ +// TR1 utility -*- C++ -*- + +// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/utility + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_UTILITY +#define _GLIBCXX_TR1_UTILITY 1 + +#pragma GCC system_header + +#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) +# error TR1 header cannot be included from C++0x header +#endif + +#include <bits/c++config.h> +#include <bits/stl_relops.h> +#include <bits/stl_pair.h> + +#if defined(_GLIBCXX_INCLUDE_AS_TR1) +# include <tr1_impl/utility> +#else +# define _GLIBCXX_INCLUDE_AS_TR1 +# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { +# define _GLIBCXX_END_NAMESPACE_TR1 } +# define _GLIBCXX_TR1 tr1:: +# include <tr1_impl/utility> +# undef _GLIBCXX_TR1 +# undef _GLIBCXX_END_NAMESPACE_TR1 +# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 +# undef _GLIBCXX_INCLUDE_AS_TR1 +#endif + +#endif // _GLIBCXX_TR1_UTILITY diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/wchar.h b/gcc-4.4.3/libstdc++-v3/include/tr1/wchar.h new file mode 100644 index 000000000..599604896 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/wchar.h @@ -0,0 +1,34 @@ +// TR1 wchar.h -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/wchar.h + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_WCHAR_H +#define _GLIBCXX_TR1_WCHAR_H 1 + +#include <tr1/cwchar> + +#endif // _GLIBCXX_TR1_WCHAR_H diff --git a/gcc-4.4.3/libstdc++-v3/include/tr1/wctype.h b/gcc-4.4.3/libstdc++-v3/include/tr1/wctype.h new file mode 100644 index 000000000..604948a58 --- /dev/null +++ b/gcc-4.4.3/libstdc++-v3/include/tr1/wctype.h @@ -0,0 +1,34 @@ +// TR1 wctype.h -*- C++ -*- + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file tr1/wctype.h + * This is a TR1 C++ Library header. + */ + +#ifndef _GLIBCXX_TR1_WCTYPE_H +#define _GLIBCXX_TR1_WCTYPE_H 1 + +#include <tr1/cwctype> + +#endif // _GLIBCXX_TR1_WCTYPE_H |