tr1/cmath

Go to the documentation of this file.
00001 // TR1 cmath -*- C++ -*-
00002 
00003 // Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00030 /** @file tr1/cmath
00031  *  This is a TR1 C++ Library header. 
00032  */
00033 
00034 #ifndef _GLIBCXX_TR1_CMATH
00035 #define _GLIBCXX_TR1_CMATH 1
00036 
00037 #pragma GCC system_header
00038 
00039 #if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
00040 #  error TR1 header cannot be included from C++0x header
00041 #endif
00042 
00043 #include <cmath>
00044 
00045 #if defined(_GLIBCXX_INCLUDE_AS_TR1)
00046 #  include <tr1_impl/cmath>
00047 #else
00048 #  define _GLIBCXX_INCLUDE_AS_TR1
00049 #  define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 {
00050 #  define _GLIBCXX_END_NAMESPACE_TR1 }
00051 #  define _GLIBCXX_TR1 tr1::
00052 #  include <tr1_impl/cmath>
00053 #  undef _GLIBCXX_TR1
00054 #  undef _GLIBCXX_END_NAMESPACE_TR1
00055 #  undef _GLIBCXX_BEGIN_NAMESPACE_TR1
00056 #  undef _GLIBCXX_INCLUDE_AS_TR1
00057 #endif
00058 
00059 #include <bits/stl_algobase.h>
00060 #include <limits>
00061 #include <tr1/type_traits>
00062 
00063 #include <tr1/gamma.tcc>
00064 #include <tr1/bessel_function.tcc>
00065 #include <tr1/beta_function.tcc>
00066 #include <tr1/ell_integral.tcc>
00067 #include <tr1/exp_integral.tcc>
00068 #include <tr1/hypergeometric.tcc>
00069 #include <tr1/legendre_function.tcc>
00070 #include <tr1/modified_bessel_func.tcc>
00071 #include <tr1/poly_hermite.tcc>
00072 #include <tr1/poly_laguerre.tcc>
00073 #include <tr1/riemann_zeta.tcc>
00074 
00075 namespace std
00076 {
00077 namespace tr1
00078 {
00079   /**
00080    * @addtogroup tr1_math_spec_func Mathematical Special Functions
00081    * A collection of advanced mathematical special functions.
00082    * @{
00083    */
00084 
00085   inline float
00086   assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
00087   { return __detail::__assoc_laguerre<float>(__n, __m, __x); }
00088 
00089   inline long double
00090   assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
00091   {
00092     return __detail::__assoc_laguerre<long double>(__n, __m, __x);
00093   }
00094 
00095   ///  5.2.1.1  Associated Laguerre polynomials.
00096   template<typename _Tp>
00097     inline typename __gnu_cxx::__promote<_Tp>::__type
00098     assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
00099     {
00100       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
00101       return __detail::__assoc_laguerre<__type>(__n, __m, __x);
00102     }
00103 
00104   inline float
00105   assoc_legendref(unsigned int __l, unsigned int __m, float __x)
00106   { return __detail::__assoc_legendre_p<float>(__l, __m, __x); }
00107 
00108   inline long double
00109   assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
00110   { return __detail::__assoc_legendre_p<long double>(__l, __m, __x); }
00111 
00112   ///  5.2.1.2  Associated Legendre functions.
00113   template<typename _Tp>
00114     inline typename __gnu_cxx::__promote<_Tp>::__type
00115     assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
00116     {
00117       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
00118       return __detail::__assoc_legendre_p<__type>(__l, __m, __x);
00119     }
00120 
00121   inline float
00122   betaf(float __x, float __y)
00123   { return __detail::__beta<float>(__x, __y); }
00124 
00125   inline long double
00126   betal(long double __x, long double __y)
00127   { return __detail::__beta<long double>(__x, __y); }
00128 
00129   ///  5.2.1.3  Beta functions.
00130   template<typename _Tpx, typename _Tpy>
00131     inline typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type
00132     beta(_Tpx __x, _Tpy __y)
00133     {
00134       typedef typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type __type;
00135       return __detail::__beta<__type>(__x, __y);
00136     }
00137 
00138   inline float
00139   comp_ellint_1f(float __k)
00140   { return __detail::__comp_ellint_1<float>(__k); }
00141 
00142   inline long double
00143   comp_ellint_1l(long double __k)
00144   { return __detail::__comp_ellint_1<long double>(__k); }
00145 
00146   ///  5.2.1.4  Complete elliptic integrals of the first kind.
00147   template<typename _Tp>
00148     inline typename __gnu_cxx::__promote<_Tp>::__type
00149     comp_ellint_1(_Tp __k)
00150     {
00151       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
00152       return __detail::__comp_ellint_1<__type>(__k);
00153     }
00154 
00155   inline float
00156   comp_ellint_2f(float __k)
00157   { return __detail::__comp_ellint_2<float>(__k); }
00158 
00159   inline long double
00160   comp_ellint_2l(long double __k)
00161   { return __detail::__comp_ellint_2<long double>(__k); }
00162 
00163   ///  5.2.1.5  Complete elliptic integrals of the second kind.
00164   template<typename _Tp>
00165     inline typename __gnu_cxx::__promote<_Tp>::__type
00166     comp_ellint_2(_Tp __k)
00167     {
00168       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
00169       return __detail::__comp_ellint_2<__type>(__k);
00170     }
00171 
00172   inline float
00173   comp_ellint_3f(float __k, float __nu)
00174   { return __detail::__comp_ellint_3<float>(__k, __nu); }
00175 
00176   inline long double
00177   comp_ellint_3l(long double __k, long double __nu)
00178   { return __detail::__comp_ellint_3<long double>(__k, __nu); }
00179 
00180   ///  5.2.1.6  Complete elliptic integrals of the third kind.
00181   template<typename _Tp, typename _Tpn>
00182     inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type
00183     comp_ellint_3(_Tp __k, _Tpn __nu)
00184     {
00185       typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type;
00186       return __detail::__comp_ellint_3<__type>(__k, __nu);
00187     }
00188 
00189   inline float
00190   conf_hypergf(float __a, float __c, float __x)
00191   { return __detail::__conf_hyperg<float>(__a, __c, __x); }
00192 
00193   inline long double
00194   conf_hypergl(long double __a, long double __c, long double __x)
00195   { return __detail::__conf_hyperg<long double>(__a, __c, __x); }
00196 
00197   ///  5.2.1.7  Confluent hypergeometric functions.
00198   template<typename _Tpa, typename _Tpc, typename _Tp>
00199     inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type
00200     conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
00201     {
00202       typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type;
00203       return __detail::__conf_hyperg<__type>(__a, __c, __x);
00204     }
00205 
00206   inline float
00207   cyl_bessel_if(float __nu, float __x)
00208   { return __detail::__cyl_bessel_i<float>(__nu, __x); }
00209 
00210   inline long double
00211   cyl_bessel_il(long double __nu, long double __x)
00212   { return __detail::__cyl_bessel_i<long double>(__nu, __x); }
00213 
00214   ///  5.2.1.8  Regular modified cylindrical Bessel functions.
00215   template<typename _Tpnu, typename _Tp>
00216     inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
00217     cyl_bessel_i(_Tpnu __nu, _Tp __x)
00218     {
00219       typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
00220       return __detail::__cyl_bessel_i<__type>(__nu, __x);
00221     }
00222 
00223   inline float
00224   cyl_bessel_jf(float __nu, float __x)
00225   { return __detail::__cyl_bessel_j<float>(__nu, __x); }
00226 
00227   inline long double
00228   cyl_bessel_jl(long double __nu, long double __x)
00229   { return __detail::__cyl_bessel_j<long double>(__nu, __x); }
00230 
00231   ///  5.2.1.9  Cylindrical Bessel functions (of the first kind).
00232   template<typename _Tpnu, typename _Tp>
00233     inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
00234     cyl_bessel_j(_Tpnu __nu, _Tp __x)
00235     {
00236       typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
00237       return __detail::__cyl_bessel_j<__type>(__nu, __x);
00238     }
00239 
00240   inline float
00241   cyl_bessel_kf(float __nu, float __x)
00242   { return __detail::__cyl_bessel_k<float>(__nu, __x); }
00243 
00244   inline long double
00245   cyl_bessel_kl(long double __nu, long double __x)
00246   { return __detail::__cyl_bessel_k<long double>(__nu, __x); }
00247 
00248   ///  5.2.1.10  Irregular modified cylindrical Bessel functions.
00249   template<typename _Tpnu, typename _Tp>
00250     inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
00251     cyl_bessel_k(_Tpnu __nu, _Tp __x)
00252     {
00253       typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
00254       return __detail::__cyl_bessel_k<__type>(__nu, __x);
00255     }
00256 
00257   inline float
00258   cyl_neumannf(float __nu, float __x)
00259   { return __detail::__cyl_neumann_n<float>(__nu, __x); }
00260 
00261   inline long double
00262   cyl_neumannl(long double __nu, long double __x)
00263   { return __detail::__cyl_neumann_n<long double>(__nu, __x); }
00264 
00265   ///  5.2.1.11  Cylindrical Neumann functions.
00266   template<typename _Tpnu, typename _Tp>
00267     inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
00268     cyl_neumann(_Tpnu __nu, _Tp __x)
00269     {
00270       typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
00271       return __detail::__cyl_neumann_n<__type>(__nu, __x);
00272     }
00273 
00274   inline float
00275   ellint_1f(float __k, float __phi)
00276   { return __detail::__ellint_1<float>(__k, __phi); }
00277 
00278   inline long double
00279   ellint_1l(long double __k, long double __phi)
00280   { return __detail::__ellint_1<long double>(__k, __phi); }
00281 
00282   ///  5.2.1.12  Incomplete elliptic integrals of the first kind.
00283   template<typename _Tp, typename _Tpp>
00284     inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
00285     ellint_1(_Tp __k, _Tpp __phi)
00286     {
00287       typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
00288       return __detail::__ellint_1<__type>(__k, __phi);
00289     }
00290 
00291   inline float
00292   ellint_2f(float __k, float __phi)
00293   { return __detail::__ellint_2<float>(__k, __phi); }
00294 
00295   inline long double
00296   ellint_2l(long double __k, long double __phi)
00297   { return __detail::__ellint_2<long double>(__k, __phi); }
00298 
00299   ///  5.2.1.13  Incomplete elliptic integrals of the second kind.
00300   template<typename _Tp, typename _Tpp>
00301     inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
00302     ellint_2(_Tp __k, _Tpp __phi)
00303     {
00304       typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
00305       return __detail::__ellint_2<__type>(__k, __phi);
00306     }
00307 
00308   inline float
00309   ellint_3f(float __k, float __nu, float __phi)
00310   { return __detail::__ellint_3<float>(__k, __nu, __phi); }
00311 
00312   inline long double
00313   ellint_3l(long double __k, long double __nu, long double __phi)
00314   { return __detail::__ellint_3<long double>(__k, __nu, __phi); }
00315 
00316   ///  5.2.1.14  Incomplete elliptic integrals of the third kind.
00317   template<typename _Tp, typename _Tpn, typename _Tpp>
00318     inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type
00319     ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
00320     {
00321       typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type;
00322       return __detail::__ellint_3<__type>(__k, __nu, __phi);
00323     }
00324 
00325   inline float
00326   expintf(float __x)
00327   { return __detail::__expint<float>(__x); }
00328 
00329   inline long double
00330   expintl(long double __x)
00331   { return __detail::__expint<long double>(__x); }
00332 
00333   ///  5.2.1.15  Exponential integrals.
00334   template<typename _Tp>
00335     inline typename __gnu_cxx::__promote<_Tp>::__type
00336     expint(_Tp __x)
00337     {
00338       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
00339       return __detail::__expint<__type>(__x);
00340     }
00341 
00342   inline float
00343   hermitef(unsigned int __n, float __x)
00344   { return __detail::__poly_hermite<float>(__n, __x); }
00345 
00346   inline long double
00347   hermitel(unsigned int __n, long double __x)
00348   { return __detail::__poly_hermite<long double>(__n, __x); }
00349 
00350   ///  5.2.1.16  Hermite polynomials.
00351   template<typename _Tp>
00352     inline typename __gnu_cxx::__promote<_Tp>::__type
00353     hermite(unsigned int __n, _Tp __x)
00354     {
00355       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
00356       return __detail::__poly_hermite<__type>(__n, __x);
00357     }
00358 
00359   inline float
00360   hypergf(float __a, float __b, float __c, float __x)
00361   { return __detail::__hyperg<float>(__a, __b, __c, __x); }
00362 
00363   inline long double
00364   hypergl(long double __a, long double __b, long double __c, long double __x)
00365   { return __detail::__hyperg<long double>(__a, __b, __c, __x); }
00366 
00367   ///  5.2.1.17  Hypergeometric functions.
00368   template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
00369     inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type
00370     hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
00371     {
00372       typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type;
00373       return __detail::__hyperg<__type>(__a, __b, __c, __x);
00374     }
00375 
00376   inline float
00377   laguerref(unsigned int __n, float __x)
00378   { return __detail::__laguerre<float>(__n, __x); }
00379 
00380   inline long double
00381   laguerrel(unsigned int __n, long double __x)
00382   { return __detail::__laguerre<long double>(__n, __x); }
00383 
00384   ///  5.2.1.18  Laguerre polynomials.
00385   template<typename _Tp>
00386     inline typename __gnu_cxx::__promote<_Tp>::__type
00387     laguerre(unsigned int __n, _Tp __x)
00388     {
00389       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
00390       return __detail::__laguerre<__type>(__n, __x);
00391     }
00392 
00393   inline float
00394   legendref(unsigned int __n, float __x)
00395   { return __detail::__poly_legendre_p<float>(__n, __x); }
00396 
00397   inline long double
00398   legendrel(unsigned int __n, long double __x)
00399   { return __detail::__poly_legendre_p<long double>(__n, __x); }
00400 
00401   ///  5.2.1.19  Legendre polynomials.
00402   template<typename _Tp>
00403     inline typename __gnu_cxx::__promote<_Tp>::__type
00404     legendre(unsigned int __n, _Tp __x)
00405     {
00406       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
00407       return __detail::__poly_legendre_p<__type>(__n, __x);
00408     }
00409 
00410   inline float
00411   riemann_zetaf(float __x)
00412   { return __detail::__riemann_zeta<float>(__x); }
00413 
00414   inline long double
00415   riemann_zetal(long double __x)
00416   { return __detail::__riemann_zeta<long double>(__x); }
00417 
00418   ///  5.2.1.20  Riemann zeta function.
00419   template<typename _Tp>
00420     inline typename __gnu_cxx::__promote<_Tp>::__type
00421     riemann_zeta(_Tp __x)
00422     {
00423       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
00424       return __detail::__riemann_zeta<__type>(__x);
00425     }
00426 
00427   inline float
00428   sph_besself(unsigned int __n, float __x)
00429   { return __detail::__sph_bessel<float>(__n, __x); }
00430 
00431   inline long double
00432   sph_bessell(unsigned int __n, long double __x)
00433   { return __detail::__sph_bessel<long double>(__n, __x); }
00434 
00435   ///  5.2.1.21  Spherical Bessel functions.
00436   template<typename _Tp>
00437     inline typename __gnu_cxx::__promote<_Tp>::__type
00438     sph_bessel(unsigned int __n, _Tp __x)
00439     {
00440       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
00441       return __detail::__sph_bessel<__type>(__n, __x);
00442     }
00443 
00444   inline float
00445   sph_legendref(unsigned int __l, unsigned int __m, float __theta)
00446   { return __detail::__sph_legendre<float>(__l, __m, __theta); }
00447 
00448   inline long double
00449   sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
00450   { return __detail::__sph_legendre<long double>(__l, __m, __theta); }
00451 
00452   ///  5.2.1.22  Spherical associated Legendre functions.
00453   template<typename _Tp>
00454     inline typename __gnu_cxx::__promote<_Tp>::__type
00455     sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
00456     {
00457       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
00458       return __detail::__sph_legendre<__type>(__l, __m, __theta);
00459     }
00460 
00461   inline float
00462   sph_neumannf(unsigned int __n, float __x)
00463   { return __detail::__sph_neumann<float>(__n, __x); }
00464 
00465   inline long double
00466   sph_neumannl(unsigned int __n, long double __x)
00467   { return __detail::__sph_neumann<long double>(__n, __x); }
00468 
00469   ///  5.2.1.23  Spherical Neumann functions.
00470   template<typename _Tp>
00471     inline typename __gnu_cxx::__promote<_Tp>::__type
00472     sph_neumann(unsigned int __n, _Tp __x)
00473     {
00474       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
00475       return __detail::__sph_neumann<__type>(__n, __x);
00476     }
00477 
00478   /* @} */ // tr1_math_spec_func
00479 }
00480 }
00481 
00482 #endif // _GLIBCXX_TR1_CMATH

Generated on Fri Jan 23 20:12:10 2009 for libstdc++ by  doxygen 1.5.6