Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / libstdc++-v3 / include / tr1 / bessel_function.tcc
index b525ebc..20481b8 100644 (file)
@@ -1,7 +1,6 @@
 // Special functions -*- C++ -*-
 
-// Copyright (C) 2006, 2007, 2008, 2009, 2010
-// Free Software Foundation, Inc.
+// Copyright (C) 2006-2013 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
@@ -87,8 +86,8 @@ namespace tr1
      */
     template <typename _Tp>
     void
-    __gamma_temme(const _Tp __mu,
-                   _Tp & __gam1, _Tp & __gam2, _Tp & __gampl, _Tp & __gammi)
+    __gamma_temme(_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);
@@ -125,7 +124,7 @@ namespace tr1
      */
     template <typename _Tp>
     void
-    __bessel_jn(const _Tp __nu, const _Tp __x,
+    __bessel_jn(_Tp __nu, _Tp __x,
                 _Tp & __Jnu, _Tp & __Nnu, _Tp & __Jpnu, _Tp & __Npnu)
     {
       if (__x == _Tp(0))
@@ -350,11 +349,8 @@ namespace tr1
      */
     template <typename _Tp>
     void
-    __cyl_bessel_jn_asymp(const _Tp __nu, const _Tp __x,
-                          _Tp & __Jnu, _Tp & __Nnu)
+    __cyl_bessel_jn_asymp(_Tp __nu, _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);
@@ -371,6 +367,8 @@ namespace tr1
       const _Tp __c = std::cos(__chi);
       const _Tp __s = std::sin(__chi);
 
+      const _Tp __coef = std::sqrt(_Tp(2)
+                             / (__numeric_constants<_Tp>::__pi() * __x));
       __Jnu = __coef * (__c * __P - __s * __Q);
       __Nnu = __coef * (__s * __P + __c * __Q);
 
@@ -407,9 +405,11 @@ namespace tr1
      */
     template <typename _Tp>
     _Tp
-    __cyl_bessel_ij_series(const _Tp __nu, const _Tp __x, const _Tp __sgn,
-                           const unsigned int __max_iter)
+    __cyl_bessel_ij_series(_Tp __nu, _Tp __x, _Tp __sgn,
+                           unsigned int __max_iter)
     {
+      if (__x == _Tp(0))
+       return __nu == _Tp(0) ? _Tp(1) : _Tp(0);
 
       const _Tp __x2 = __x / _Tp(2);
       _Tp __fact = __nu * std::log(__x2);
@@ -451,7 +451,7 @@ namespace tr1
      */
     template<typename _Tp>
     _Tp
-    __cyl_bessel_j(const _Tp __nu, const _Tp __x)
+    __cyl_bessel_j(_Tp __nu, _Tp __x)
     {
       if (__nu < _Tp(0) || __x < _Tp(0))
         std::__throw_domain_error(__N("Bad argument "
@@ -493,7 +493,7 @@ namespace tr1
      */
     template<typename _Tp>
     _Tp
-    __cyl_neumann_n(const _Tp __nu, const _Tp __x)
+    __cyl_neumann_n(_Tp __nu, _Tp __x)
     {
       if (__nu < _Tp(0) || __x < _Tp(0))
         std::__throw_domain_error(__N("Bad argument "
@@ -530,7 +530,7 @@ namespace tr1
      */
     template <typename _Tp>
     void
-    __sph_bessel_jn(const unsigned int __n, const _Tp __x,
+    __sph_bessel_jn(unsigned int __n, _Tp __x,
                     _Tp & __j_n, _Tp & __n_n, _Tp & __jp_n, _Tp & __np_n)
     {
       const _Tp __nu = _Tp(__n) + _Tp(0.5L);
@@ -565,7 +565,7 @@ namespace tr1
      */
     template <typename _Tp>
     _Tp
-    __sph_bessel(const unsigned int __n, const _Tp __x)
+    __sph_bessel(unsigned int __n, _Tp __x)
     {
       if (__x < _Tp(0))
         std::__throw_domain_error(__N("Bad argument "
@@ -603,7 +603,7 @@ namespace tr1
      */
     template <typename _Tp>
     _Tp
-    __sph_neumann(const unsigned int __n, const _Tp __x)
+    __sph_neumann(unsigned int __n, _Tp __x)
     {
       if (__x < _Tp(0))
         std::__throw_domain_error(__N("Bad argument "