1 // TR1 cmath -*- C++ -*-
3 // Copyright (C) 2006, 2007 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
31 * This is a TR1 C++ Library header.
34 #ifndef _GLIBCXX_TR1_CMATH
35 #define _GLIBCXX_TR1_CMATH 1
37 #pragma GCC system_header
39 #if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
40 # error TR1 header cannot be included from C++0x header
45 #if defined(_GLIBCXX_INCLUDE_AS_TR1)
46 # include <tr1_impl/cmath>
48 # define _GLIBCXX_INCLUDE_AS_TR1
49 # define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 {
50 # define _GLIBCXX_END_NAMESPACE_TR1 }
51 # define _GLIBCXX_TR1 tr1::
52 # include <tr1_impl/cmath>
54 # undef _GLIBCXX_END_NAMESPACE_TR1
55 # undef _GLIBCXX_BEGIN_NAMESPACE_TR1
56 # undef _GLIBCXX_INCLUDE_AS_TR1
60 * @defgroup tr1_math_spec_func Mathematical Special Functions
61 * A collection of advanced mathematical special functions.
64 #include <bits/stl_algobase.h>
67 #include <tr1/type_traits>
68 #include <tr1/gamma.tcc>
69 #include <tr1/bessel_function.tcc>
70 #include <tr1/beta_function.tcc>
71 #include <tr1/ell_integral.tcc>
72 #include <tr1/exp_integral.tcc>
73 #include <tr1/hypergeometric.tcc>
74 #include <tr1/legendre_function.tcc>
75 #include <tr1/modified_bessel_func.tcc>
76 #include <tr1/poly_hermite.tcc>
77 #include <tr1/poly_laguerre.tcc>
78 #include <tr1/riemann_zeta.tcc>
85 // 5.2.1.1 Associated Laguerre polynomials.
87 assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
88 { return __detail::__assoc_laguerre<float>(__n, __m, __x); }
91 assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
93 return __detail::__assoc_laguerre<long double>(__n, __m, __x);
96 template<typename _Tp>
97 inline typename __gnu_cxx::__promote<_Tp>::__type
98 assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
100 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
101 return __detail::__assoc_laguerre<__type>(__n, __m, __x);
104 // 5.2.1.2 Associated Legendre functions.
106 assoc_legendref(unsigned int __l, unsigned int __m, float __x)
107 { return __detail::__assoc_legendre_p<float>(__l, __m, __x); }
110 assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
111 { return __detail::__assoc_legendre_p<long double>(__l, __m, __x); }
113 template<typename _Tp>
114 inline typename __gnu_cxx::__promote<_Tp>::__type
115 assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
117 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
118 return __detail::__assoc_legendre_p<__type>(__l, __m, __x);
121 // 5.2.1.3 Beta functions.
123 betaf(float __x, float __y)
124 { return __detail::__beta<float>(__x, __y); }
127 betal(long double __x, long double __y)
128 { return __detail::__beta<long double>(__x, __y); }
130 template<typename _Tpx, typename _Tpy>
131 inline typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type
132 beta(_Tpx __x, _Tpy __y)
134 typedef typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type __type;
135 return __detail::__beta<__type>(__x, __y);
138 // 5.2.1.4 Complete elliptic integrals of the first kind.
140 comp_ellint_1f(float __k)
141 { return __detail::__comp_ellint_1<float>(__k); }
144 comp_ellint_1l(long double __k)
145 { return __detail::__comp_ellint_1<long double>(__k); }
147 template<typename _Tp>
148 inline typename __gnu_cxx::__promote<_Tp>::__type
149 comp_ellint_1(_Tp __k)
151 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
152 return __detail::__comp_ellint_1<__type>(__k);
155 // 5.2.1.5 Complete elliptic integrals of the second kind.
157 comp_ellint_2f(float __k)
158 { return __detail::__comp_ellint_2<float>(__k); }
161 comp_ellint_2l(long double __k)
162 { return __detail::__comp_ellint_2<long double>(__k); }
164 template<typename _Tp>
165 inline typename __gnu_cxx::__promote<_Tp>::__type
166 comp_ellint_2(_Tp __k)
168 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
169 return __detail::__comp_ellint_2<__type>(__k);
172 // 5.2.1.6 Complete elliptic integrals of the third kind.
174 comp_ellint_3f(float __k, float __nu)
175 { return __detail::__comp_ellint_3<float>(__k, __nu); }
178 comp_ellint_3l(long double __k, long double __nu)
179 { return __detail::__comp_ellint_3<long double>(__k, __nu); }
181 template<typename _Tp, typename _Tpn>
182 inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type
183 comp_ellint_3(_Tp __k, _Tpn __nu)
185 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type;
186 return __detail::__comp_ellint_3<__type>(__k, __nu);
189 // 5.2.1.7 Confluent hypergeometric functions.
191 conf_hypergf(float __a, float __c, float __x)
192 { return __detail::__conf_hyperg<float>(__a, __c, __x); }
195 conf_hypergl(long double __a, long double __c, long double __x)
196 { return __detail::__conf_hyperg<long double>(__a, __c, __x); }
198 template<typename _Tpa, typename _Tpc, typename _Tp>
199 inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type
200 conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
202 typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type;
203 return __detail::__conf_hyperg<__type>(__a, __c, __x);
206 // 5.2.1.8 Regular modified cylindrical Bessel functions.
208 cyl_bessel_if(float __nu, float __x)
209 { return __detail::__cyl_bessel_i<float>(__nu, __x); }
212 cyl_bessel_il(long double __nu, long double __x)
213 { return __detail::__cyl_bessel_i<long double>(__nu, __x); }
215 template<typename _Tpnu, typename _Tp>
216 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
217 cyl_bessel_i(_Tpnu __nu, _Tp __x)
219 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
220 return __detail::__cyl_bessel_i<__type>(__nu, __x);
223 // 5.2.1.9 Cylindrical Bessel functions (of the first kind).
225 cyl_bessel_jf(float __nu, float __x)
226 { return __detail::__cyl_bessel_j<float>(__nu, __x); }
229 cyl_bessel_jl(long double __nu, long double __x)
230 { return __detail::__cyl_bessel_j<long double>(__nu, __x); }
232 template<typename _Tpnu, typename _Tp>
233 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
234 cyl_bessel_j(_Tpnu __nu, _Tp __x)
236 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
237 return __detail::__cyl_bessel_j<__type>(__nu, __x);
240 // 5.2.1.10 Irregular modified cylindrical Bessel functions.
242 cyl_bessel_kf(float __nu, float __x)
243 { return __detail::__cyl_bessel_k<float>(__nu, __x); }
246 cyl_bessel_kl(long double __nu, long double __x)
247 { return __detail::__cyl_bessel_k<long double>(__nu, __x); }
249 template<typename _Tpnu, typename _Tp>
250 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
251 cyl_bessel_k(_Tpnu __nu, _Tp __x)
253 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
254 return __detail::__cyl_bessel_k<__type>(__nu, __x);
257 // 5.2.1.11 Cylindrical Neumann functions.
259 cyl_neumannf(float __nu, float __x)
260 { return __detail::__cyl_neumann_n<float>(__nu, __x); }
263 cyl_neumannl(long double __nu, long double __x)
264 { return __detail::__cyl_neumann_n<long double>(__nu, __x); }
266 template<typename _Tpnu, typename _Tp>
267 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
268 cyl_neumann(_Tpnu __nu, _Tp __x)
270 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
271 return __detail::__cyl_neumann_n<__type>(__nu, __x);
274 // 5.2.1.12 Incomplete elliptic integrals of the first kind.
276 ellint_1f(float __k, float __phi)
277 { return __detail::__ellint_1<float>(__k, __phi); }
280 ellint_1l(long double __k, long double __phi)
281 { return __detail::__ellint_1<long double>(__k, __phi); }
283 template<typename _Tp, typename _Tpp>
284 inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
285 ellint_1(_Tp __k, _Tpp __phi)
287 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
288 return __detail::__ellint_1<__type>(__k, __phi);
291 // 5.2.1.13 Incomplete elliptic integrals of the second kind.
293 ellint_2f(float __k, float __phi)
294 { return __detail::__ellint_2<float>(__k, __phi); }
297 ellint_2l(long double __k, long double __phi)
298 { return __detail::__ellint_2<long double>(__k, __phi); }
300 template<typename _Tp, typename _Tpp>
301 inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
302 ellint_2(_Tp __k, _Tpp __phi)
304 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
305 return __detail::__ellint_2<__type>(__k, __phi);
308 // 5.2.1.14 Incomplete elliptic integrals of the third kind.
310 ellint_3f(float __k, float __nu, float __phi)
311 { return __detail::__ellint_3<float>(__k, __nu, __phi); }
314 ellint_3l(long double __k, long double __nu, long double __phi)
315 { return __detail::__ellint_3<long double>(__k, __nu, __phi); }
317 template<typename _Tp, typename _Tpn, typename _Tpp>
318 inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type
319 ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
321 typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type;
322 return __detail::__ellint_3<__type>(__k, __nu, __phi);
325 // 5.2.1.15 Exponential integrals.
328 { return __detail::__expint<float>(__x); }
331 expintl(long double __x)
332 { return __detail::__expint<long double>(__x); }
334 template<typename _Tp>
335 inline typename __gnu_cxx::__promote<_Tp>::__type
338 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
339 return __detail::__expint<__type>(__x);
342 // 5.2.1.16 Hermite polynomials.
344 hermitef(unsigned int __n, float __x)
345 { return __detail::__poly_hermite<float>(__n, __x); }
348 hermitel(unsigned int __n, long double __x)
349 { return __detail::__poly_hermite<long double>(__n, __x); }
351 template<typename _Tp>
352 inline typename __gnu_cxx::__promote<_Tp>::__type
353 hermite(unsigned int __n, _Tp __x)
355 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
356 return __detail::__poly_hermite<__type>(__n, __x);
359 // 5.2.1.17 Hypergeometric functions.
361 hypergf(float __a, float __b, float __c, float __x)
362 { return __detail::__hyperg<float>(__a, __b, __c, __x); }
365 hypergl(long double __a, long double __b, long double __c, long double __x)
366 { return __detail::__hyperg<long double>(__a, __b, __c, __x); }
368 template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
369 inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type
370 hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
372 typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type;
373 return __detail::__hyperg<__type>(__a, __b, __c, __x);
376 // 5.2.1.18 Laguerre polynomials.
378 laguerref(unsigned int __n, float __x)
379 { return __detail::__laguerre<float>(__n, __x); }
382 laguerrel(unsigned int __n, long double __x)
383 { return __detail::__laguerre<long double>(__n, __x); }
385 template<typename _Tp>
386 inline typename __gnu_cxx::__promote<_Tp>::__type
387 laguerre(unsigned int __n, _Tp __x)
389 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
390 return __detail::__laguerre<__type>(__n, __x);
393 // 5.2.1.19 Legendre polynomials.
395 legendref(unsigned int __n, float __x)
396 { return __detail::__poly_legendre_p<float>(__n, __x); }
399 legendrel(unsigned int __n, long double __x)
400 { return __detail::__poly_legendre_p<long double>(__n, __x); }
402 template<typename _Tp>
403 inline typename __gnu_cxx::__promote<_Tp>::__type
404 legendre(unsigned int __n, _Tp __x)
406 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
407 return __detail::__poly_legendre_p<__type>(__n, __x);
410 // 5.2.1.20 Riemann zeta function.
412 riemann_zetaf(float __x)
413 { return __detail::__riemann_zeta<float>(__x); }
416 riemann_zetal(long double __x)
417 { return __detail::__riemann_zeta<long double>(__x); }
419 template<typename _Tp>
420 inline typename __gnu_cxx::__promote<_Tp>::__type
421 riemann_zeta(_Tp __x)
423 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
424 return __detail::__riemann_zeta<__type>(__x);
427 // 5.2.1.21 Spherical Bessel functions.
429 sph_besself(unsigned int __n, float __x)
430 { return __detail::__sph_bessel<float>(__n, __x); }
433 sph_bessell(unsigned int __n, long double __x)
434 { return __detail::__sph_bessel<long double>(__n, __x); }
436 template<typename _Tp>
437 inline typename __gnu_cxx::__promote<_Tp>::__type
438 sph_bessel(unsigned int __n, _Tp __x)
440 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
441 return __detail::__sph_bessel<__type>(__n, __x);
444 // 5.2.1.22 Spherical associated Legendre functions.
446 sph_legendref(unsigned int __l, unsigned int __m, float __theta)
447 { return __detail::__sph_legendre<float>(__l, __m, __theta); }
450 sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
451 { return __detail::__sph_legendre<long double>(__l, __m, __theta); }
453 template<typename _Tp>
454 inline typename __gnu_cxx::__promote<_Tp>::__type
455 sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
457 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
458 return __detail::__sph_legendre<__type>(__l, __m, __theta);
461 // 5.2.1.23 Spherical Neumann functions.
463 sph_neumannf(unsigned int __n, float __x)
464 { return __detail::__sph_neumann<float>(__n, __x); }
467 sph_neumannl(unsigned int __n, long double __x)
468 { return __detail::__sph_neumann<long double>(__n, __x); }
470 template<typename _Tp>
471 inline typename __gnu_cxx::__promote<_Tp>::__type
472 sph_neumann(unsigned int __n, _Tp __x)
474 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
475 return __detail::__sph_neumann<__type>(__n, __x);
478 /* @} */ // group tr1_math_spec_func
482 #endif // _GLIBCXX_TR1_CMATH