diff options
author | Edward Smith-Rowland <emsr@gcc.gnu.org> | 2018-05-07 16:02:46 +0000 |
---|---|---|
committer | Edward Smith-Rowland <emsr@gcc.gnu.org> | 2018-05-07 16:02:46 +0000 |
commit | b118dfdb6d5ad68c8ff70ea517928c37ebb1fa11 (patch) | |
tree | 83049b9daf6d6b066967bde3dc602ef4d22faa49 /libstdc++-v3/include | |
parent | c69c7d0381fb310ddc9635a2bf9a474ba2c73cf9 (diff) | |
download | gcc-b118dfdb6d5ad68c8ff70ea517928c37ebb1fa11.zip gcc-b118dfdb6d5ad68c8ff70ea517928c37ebb1fa11.tar.gz gcc-b118dfdb6d5ad68c8ff70ea517928c37ebb1fa11.tar.bz2 |
Revert 20001.
From-SVN: r260002
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/bits/random.tcc | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/std/complex | 65 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/bessel_function.tcc | 44 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/legendre_function.tcc | 29 |
4 files changed, 84 insertions, 58 deletions
diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc index 6db900c..f398150 100644 --- a/libstdc++-v3/include/bits/random.tcc +++ b/libstdc++-v3/include/bits/random.tcc @@ -2408,7 +2408,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __v = __v * __v * __v; __u = __aurng(); } - while (__u > result_type(1.0) - 0.331 * __n * __n * __n * __n + while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n && (std::log(__u) > (0.5 * __n * __n + __a1 * (1.0 - __v + std::log(__v))))); @@ -2429,7 +2429,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __v = __v * __v * __v; __u = __aurng(); } - while (__u > result_type(1.0) - 0.331 * __n * __n * __n * __n + while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n && (std::log(__u) > (0.5 * __n * __n + __a1 * (1.0 - __v + std::log(__v))))); diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 2e2c2c0..54f2b9d 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -70,7 +70,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Return phase angle of @a z. template<typename _Tp> _Tp arg(const complex<_Tp>&); /// Return @a z magnitude squared. - template<typename _Tp> _Tp norm(const complex<_Tp>&); + template<typename _Tp> _Tp _GLIBCXX_CONSTEXPR norm(const complex<_Tp>&); /// Return complex conjugate of @a z. template<typename _Tp> complex<_Tp> conj(const complex<_Tp>&); @@ -322,7 +322,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION //@{ /// Return new complex value @a x plus @a y. template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __x; @@ -331,7 +331,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator+(const complex<_Tp>& __x, const _Tp& __y) { complex<_Tp> __r = __x; @@ -340,7 +340,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator+(const _Tp& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __y; @@ -352,7 +352,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION //@{ /// Return new complex value @a x minus @a y. template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __x; @@ -361,7 +361,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator-(const complex<_Tp>& __x, const _Tp& __y) { complex<_Tp> __r = __x; @@ -370,7 +370,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator-(const _Tp& __x, const complex<_Tp>& __y) { complex<_Tp> __r(__x, -__y.imag()); @@ -382,7 +382,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION //@{ /// Return new complex value @a x times @a y. template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator*(const complex<_Tp>& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __x; @@ -391,7 +391,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Tp> - inline complex<_Tp> + inline _GLIBCXX_CONSTEXPR complex<_Tp> operator*(const complex<_Tp>& __x, const _Tp& __y) { complex<_Tp> __r = __x; @@ -400,7 +400,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator*(const _Tp& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __y; @@ -412,7 +412,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION //@{ /// Return new complex value @a x divided by @a y. template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __x; @@ -421,7 +421,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator/(const complex<_Tp>& __x, const _Tp& __y) { complex<_Tp> __r = __x; @@ -430,7 +430,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator/(const _Tp& __x, const complex<_Tp>& __y) { complex<_Tp> __r = __x; @@ -441,30 +441,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Return @a x. template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator+(const complex<_Tp>& __x) { return __x; } /// Return complex negation of @a x. template<typename _Tp> - inline complex<_Tp> + _GLIBCXX_CONSTEXPR inline complex<_Tp> operator-(const complex<_Tp>& __x) { return complex<_Tp>(-__x.real(), -__x.imag()); } //@{ /// Return true if @a x is equal to @a y. template<typename _Tp> - inline _GLIBCXX_CONSTEXPR bool + _GLIBCXX_CONSTEXPR inline bool operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) { return __x.real() == __y.real() && __x.imag() == __y.imag(); } template<typename _Tp> - inline _GLIBCXX_CONSTEXPR bool + _GLIBCXX_CONSTEXPR inline bool operator==(const complex<_Tp>& __x, const _Tp& __y) { return __x.real() == __y && __x.imag() == _Tp(); } template<typename _Tp> - inline _GLIBCXX_CONSTEXPR bool + _GLIBCXX_CONSTEXPR inline bool operator==(const _Tp& __x, const complex<_Tp>& __y) { return __x == __y.real() && _Tp() == __y.imag(); } //@} @@ -472,17 +472,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION //@{ /// Return false if @a x is equal to @a y. template<typename _Tp> - inline _GLIBCXX_CONSTEXPR bool + _GLIBCXX_CONSTEXPR inline bool operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) { return __x.real() != __y.real() || __x.imag() != __y.imag(); } template<typename _Tp> - inline _GLIBCXX_CONSTEXPR bool + _GLIBCXX_CONSTEXPR inline bool operator!=(const complex<_Tp>& __x, const _Tp& __y) { return __x.real() != __y || __x.imag() != _Tp(); } template<typename _Tp> - inline _GLIBCXX_CONSTEXPR bool + _GLIBCXX_CONSTEXPR inline bool operator!=(const _Tp& __x, const complex<_Tp>& __y) { return __x != __y.real() || _Tp() != __y.imag(); } //@} @@ -658,7 +658,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct _Norm_helper { template<typename _Tp> - static inline _Tp _S_do_it(const complex<_Tp>& __z) + static _GLIBCXX_CONSTEXPR inline _Tp _S_do_it(const complex<_Tp>& __z) { const _Tp __x = __z.real(); const _Tp __y = __z.imag(); @@ -670,7 +670,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct _Norm_helper<true> { template<typename _Tp> - static inline _Tp _S_do_it(const complex<_Tp>& __z) + static _GLIBCXX_CONSTEXPR inline _Tp _S_do_it(const complex<_Tp>& __z) { _Tp __res = std::abs(__z); return __res * __res; @@ -678,7 +678,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template<typename _Tp> - inline _Tp + _GLIBCXX_CONSTEXPR inline _Tp norm(const complex<_Tp>& __z) { return _Norm_helper<__is_floating<_Tp>::__value @@ -1866,7 +1866,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return _Tp(); } template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type + _GLIBCXX_CONSTEXPR inline typename __gnu_cxx::__promote<_Tp>::__type norm(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; @@ -1905,10 +1905,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Forward declarations. // DR 781. - template<typename _Tp> std::complex<_Tp> proj(const std::complex<_Tp>&); + template<typename _Tp> + _GLIBCXX_CONSTEXPR std::complex<_Tp> proj(const std::complex<_Tp>&); template<typename _Tp> - std::complex<_Tp> + _GLIBCXX_CONSTEXPR std::complex<_Tp> __complex_proj(const std::complex<_Tp>& __z) { const _Tp __den = (__z.real() * __z.real() @@ -1919,25 +1920,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #if _GLIBCXX_USE_C99_COMPLEX - inline __complex__ float + _GLIBCXX_CONSTEXPR inline __complex__ float __complex_proj(__complex__ float __z) { return __builtin_cprojf(__z); } - inline __complex__ double + _GLIBCXX_CONSTEXPR inline __complex__ double __complex_proj(__complex__ double __z) { return __builtin_cproj(__z); } - inline __complex__ long double + _GLIBCXX_CONSTEXPR inline __complex__ long double __complex_proj(const __complex__ long double& __z) { return __builtin_cprojl(__z); } template<typename _Tp> - inline std::complex<_Tp> + _GLIBCXX_CONSTEXPR inline std::complex<_Tp> proj(const std::complex<_Tp>& __z) { return __complex_proj(__z.__rep()); } #else template<typename _Tp> - inline std::complex<_Tp> + _GLIBCXX_CONSTEXPR inline std::complex<_Tp> proj(const std::complex<_Tp>& __z) { return __complex_proj(__z); } #endif diff --git a/libstdc++-v3/include/tr1/bessel_function.tcc b/libstdc++-v3/include/tr1/bessel_function.tcc index 26c66ca..1ae88a3 100644 --- a/libstdc++-v3/include/tr1/bessel_function.tcc +++ b/libstdc++-v3/include/tr1/bessel_function.tcc @@ -353,21 +353,47 @@ namespace tr1 * @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). + * + * Adapted for libstdc++ from GNU GSL version 2.4 specfunc/bessel_j.c + * Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003 Gerard Jungman */ template <typename _Tp> void __cyl_bessel_jn_asymp(_Tp __nu, _Tp __x, _Tp & __Jnu, _Tp & __Nnu) { 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 __8x = _Tp(8) * __x; + + _Tp __P = _Tp(0); + _Tp __Q = _Tp(0); + + _Tp k = _Tp(0); + _Tp __term = _Tp(1); + + int __epsP = 0; + int __epsQ = 0; + + _Tp __eps = std::numeric_limits<_Tp>::epsilon(); + + do + { + __term *= (k == 0) ? _Tp(1) : -(__mu - (2 * k - 1) * (2 * k - 1)) / (k * __8x); + __epsP = std::abs(__term) < std::abs(__eps * __P); + __P += __term; + + k++; + + __term *= (__mu - (2 * k - 1) * (2 * k - 1)) / (k * __8x); + __epsQ = std::abs(__term) < std::abs(__eps * __Q); + __Q += __term; + + if (__epsP && __epsQ && k > __nu / 2.) + break; + + k++; + } + while (k < 1000); + const _Tp __chi = __x - (__nu + _Tp(0.5L)) * __numeric_constants<_Tp>::__pi_2(); diff --git a/libstdc++-v3/include/tr1/legendre_function.tcc b/libstdc++-v3/include/tr1/legendre_function.tcc index a07d83a..e2d1880 100644 --- a/libstdc++-v3/include/tr1/legendre_function.tcc +++ b/libstdc++-v3/include/tr1/legendre_function.tcc @@ -65,7 +65,7 @@ namespace tr1 namespace __detail { /** - * @brief Return the Legendre polynomial by recursion on degree + * @brief Return the Legendre polynomial by recursion on order * @f$ l @f$. * * The Legendre function of @f$ l @f$ and @f$ x @f$, @@ -74,7 +74,7 @@ namespace tr1 * P_l(x) = \frac{1}{2^l l!}\frac{d^l}{dx^l}(x^2 - 1)^{l} * @f] * - * @param l The degree of the Legendre polynomial. @f$l >= 0@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> @@ -127,19 +127,16 @@ namespace tr1 * P_l^m(x) = (1 - x^2)^{m/2}\frac{d^m}{dx^m}P_l(x) * @f] * - * @param l The degree of the associated Legendre function. + * @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$. - * @param phase The phase of the associated Legendre function. - * Use -1 for the Condon-Shortley phase convention. */ template<typename _Tp> _Tp - __assoc_legendre_p(unsigned int __l, unsigned int __m, _Tp __x, - _Tp __phase = _Tp{+1}) + __assoc_legendre_p(unsigned int __l, unsigned int __m, _Tp __x) { if (__x < _Tp(-1) || __x > _Tp(+1)) @@ -163,7 +160,7 @@ namespace tr1 _Tp __fact = _Tp(1); for (unsigned int __i = 1; __i <= __m; ++__i) { - __p_mm *= __phase * __fact * __root; + __p_mm *= -__fact * __root; __fact += _Tp(2); } } @@ -208,10 +205,8 @@ namespace tr1 * 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$. - * @note Unlike the case for __assoc_legendre_p the Condon-Shortley - * phase factor @f$ (-1)^m @f$ is present here. * - * @param l The degree of the spherical associated Legendre function. + * @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$. @@ -270,15 +265,19 @@ namespace tr1 const _Tp __lnpre_val = -_Tp(0.25L) * __numeric_constants<_Tp>::__lnpi() + _Tp(0.5L) * (__lnpoch + __m * __lncirc); - const _Tp __sr = std::sqrt((_Tp(2) + _Tp(1) / __m) - / (_Tp(4) * __numeric_constants<_Tp>::__pi())); + _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; + { + return __y_mm; + } else if (__l == __m + 1) - return __y_mp1m; + { + return __y_mp1m; + } else { _Tp __y_lm = _Tp(0); |