diff options
-rw-r--r-- | libstdc++-v3/ChangeLog | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/modified_bessel_func.tcc | 62 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/10_cyl_bessel_k/airy.cc | 37 |
3 files changed, 100 insertions, 8 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index bef2e0d..b8896be 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2013-06-12 Ed Smith-Rowland <3dw4rd@verizon.net> + + PR libstdc++/56430 + * include/tr1/modified_bessel_func.tcc (__airy): Remove return + from void function. + (__gnu_cxx::__airy_ai(), __gnu_cxx::__airy_bi()): New functions. + * testsuite/tr1/5_numerical_facilities/special_functions/ + 10_cyl_bessel_k/airy.cc: New. + 2013-06-11 Ed Smith-Rowland <3dw4rd@verizon.net> Fix library literals error involving namespace __detail. diff --git a/libstdc++-v3/include/tr1/modified_bessel_func.tcc b/libstdc++-v3/include/tr1/modified_bessel_func.tcc index 3d1fb90..830bf16 100644 --- a/libstdc++-v3/include/tr1/modified_bessel_func.tcc +++ b/libstdc++-v3/include/tr1/modified_bessel_func.tcc @@ -357,12 +357,13 @@ namespace tr1 * 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. + * @param __Ai The output Airy function of the first kind. + * @param __Bi The output Airy function of the second kind. + * @param __Aip The output derivative of the Airy function + * of the first kind. + * @param __Bip The output derivative of the Airy function + * of the second kind. */ template <typename _Tp> void @@ -372,9 +373,7 @@ namespace tr1 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)) + if (__x > _Tp(0)) { _Tp __I_nu, __Ip_nu, __K_nu, __Kp_nu; @@ -432,4 +431,51 @@ namespace tr1 } } + +namespace __gnu_cxx +{ + + /** + * @brief Compute the Airy function of the first kind @f$ Ai(x) @f$. + * + * @param __x The argument of the Airy function. + * @return The Airy function of the first kind at x. + */ + template<typename _Tp> + _Tp + __airy_ai(_Tp __x) + { + if (__isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else + { + _Tp __Ai, __Bi, __Aip, __Bip; + std::tr1::__detail::__airy(__x, __Ai, __Bi, __Aip, __Bip); + return __Ai; + } + } + + + /** + * @brief Compute the Airy function of the second kind @f$ Bi(x) @f$. + * + * @param __x The argument of the Airy function. + * @return The Airy function of the second kind at x. + */ + template<typename _Tp> + _Tp + __airy_bi(_Tp __x) + { + if (__isnan(__x)) + return std::numeric_limits<_Tp>::quiet_NaN(); + else + { + _Tp __Ai, __Bi, __Aip, __Bip; + std::tr1::__detail::__airy(__x, __Ai, __Bi, __Aip, __Bip); + return __Bi; + } + } + +} // namespace __gnu_cxx + #endif // _GLIBCXX_TR1_MODIFIED_BESSEL_FUNC_TCC diff --git a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/10_cyl_bessel_k/airy.cc b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/10_cyl_bessel_k/airy.cc new file mode 100644 index 0000000..57d75e5 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/10_cyl_bessel_k/airy.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2013-02-13 Edward Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 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 +// 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. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// PR libstdc++/56430 - In __airy: return-statement with a value, +// in function returning 'void'. + +#include <tr1/cmath> + +int +test01() +{ + bool test __attribute__((unused)) = true; + double x, Ai, Bi, Aip, Bip; + x = 1.0; + std::tr1::__detail::__airy(x, Ai, Bi, Aip, Bip); + + double Ai2 = __gnu_cxx::__airy_ai(x); + double Bi2 = __gnu_cxx::__airy_bi(x); +} |