1 // TR1 cmath -*- C++ -*-
3 // Copyright (C) 2006, 2007, 2008 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
63 // DR 550. What should the return type of pow(float,int) be?
64 // NB: C++0x and TR1 != C++03.
66 pow(double __x, double __y)
67 { return std::pow(__x, __y); }
70 pow(float __x, float __y)
71 { return std::pow(__x, __y); }
74 pow(long double __x, long double __y)
75 { return std::pow(__x, __y); }
77 template<typename _Tp, typename _Up>
78 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
81 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
82 return std::pow(__type(__x), __type(__y));
87 #include <bits/stl_algobase.h>
89 #include <tr1/type_traits>
91 #include <tr1/gamma.tcc>
92 #include <tr1/bessel_function.tcc>
93 #include <tr1/beta_function.tcc>
94 #include <tr1/ell_integral.tcc>
95 #include <tr1/exp_integral.tcc>
96 #include <tr1/hypergeometric.tcc>
97 #include <tr1/legendre_function.tcc>
98 #include <tr1/modified_bessel_func.tcc>
99 #include <tr1/poly_hermite.tcc>
100 #include <tr1/poly_laguerre.tcc>
101 #include <tr1/riemann_zeta.tcc>
108 * @addtogroup tr1_math_spec_func Mathematical Special Functions
109 * A collection of advanced mathematical special functions.
114 assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
115 { return __detail::__assoc_laguerre<float>(__n, __m, __x); }
118 assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
120 return __detail::__assoc_laguerre<long double>(__n, __m, __x);
123 /// 5.2.1.1 Associated Laguerre polynomials.
124 template<typename _Tp>
125 inline typename __gnu_cxx::__promote<_Tp>::__type
126 assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
128 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
129 return __detail::__assoc_laguerre<__type>(__n, __m, __x);
133 assoc_legendref(unsigned int __l, unsigned int __m, float __x)
134 { return __detail::__assoc_legendre_p<float>(__l, __m, __x); }
137 assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
138 { return __detail::__assoc_legendre_p<long double>(__l, __m, __x); }
140 /// 5.2.1.2 Associated Legendre functions.
141 template<typename _Tp>
142 inline typename __gnu_cxx::__promote<_Tp>::__type
143 assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
145 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
146 return __detail::__assoc_legendre_p<__type>(__l, __m, __x);
150 betaf(float __x, float __y)
151 { return __detail::__beta<float>(__x, __y); }
154 betal(long double __x, long double __y)
155 { return __detail::__beta<long double>(__x, __y); }
157 /// 5.2.1.3 Beta functions.
158 template<typename _Tpx, typename _Tpy>
159 inline typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type
160 beta(_Tpx __x, _Tpy __y)
162 typedef typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type __type;
163 return __detail::__beta<__type>(__x, __y);
167 comp_ellint_1f(float __k)
168 { return __detail::__comp_ellint_1<float>(__k); }
171 comp_ellint_1l(long double __k)
172 { return __detail::__comp_ellint_1<long double>(__k); }
174 /// 5.2.1.4 Complete elliptic integrals of the first kind.
175 template<typename _Tp>
176 inline typename __gnu_cxx::__promote<_Tp>::__type
177 comp_ellint_1(_Tp __k)
179 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
180 return __detail::__comp_ellint_1<__type>(__k);
184 comp_ellint_2f(float __k)
185 { return __detail::__comp_ellint_2<float>(__k); }
188 comp_ellint_2l(long double __k)
189 { return __detail::__comp_ellint_2<long double>(__k); }
191 /// 5.2.1.5 Complete elliptic integrals of the second kind.
192 template<typename _Tp>
193 inline typename __gnu_cxx::__promote<_Tp>::__type
194 comp_ellint_2(_Tp __k)
196 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
197 return __detail::__comp_ellint_2<__type>(__k);
201 comp_ellint_3f(float __k, float __nu)
202 { return __detail::__comp_ellint_3<float>(__k, __nu); }
205 comp_ellint_3l(long double __k, long double __nu)
206 { return __detail::__comp_ellint_3<long double>(__k, __nu); }
208 /// 5.2.1.6 Complete elliptic integrals of the third kind.
209 template<typename _Tp, typename _Tpn>
210 inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type
211 comp_ellint_3(_Tp __k, _Tpn __nu)
213 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type;
214 return __detail::__comp_ellint_3<__type>(__k, __nu);
218 conf_hypergf(float __a, float __c, float __x)
219 { return __detail::__conf_hyperg<float>(__a, __c, __x); }
222 conf_hypergl(long double __a, long double __c, long double __x)
223 { return __detail::__conf_hyperg<long double>(__a, __c, __x); }
225 /// 5.2.1.7 Confluent hypergeometric functions.
226 template<typename _Tpa, typename _Tpc, typename _Tp>
227 inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type
228 conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
230 typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type;
231 return __detail::__conf_hyperg<__type>(__a, __c, __x);
235 cyl_bessel_if(float __nu, float __x)
236 { return __detail::__cyl_bessel_i<float>(__nu, __x); }
239 cyl_bessel_il(long double __nu, long double __x)
240 { return __detail::__cyl_bessel_i<long double>(__nu, __x); }
242 /// 5.2.1.8 Regular modified cylindrical Bessel functions.
243 template<typename _Tpnu, typename _Tp>
244 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
245 cyl_bessel_i(_Tpnu __nu, _Tp __x)
247 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
248 return __detail::__cyl_bessel_i<__type>(__nu, __x);
252 cyl_bessel_jf(float __nu, float __x)
253 { return __detail::__cyl_bessel_j<float>(__nu, __x); }
256 cyl_bessel_jl(long double __nu, long double __x)
257 { return __detail::__cyl_bessel_j<long double>(__nu, __x); }
259 /// 5.2.1.9 Cylindrical Bessel functions (of the first kind).
260 template<typename _Tpnu, typename _Tp>
261 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
262 cyl_bessel_j(_Tpnu __nu, _Tp __x)
264 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
265 return __detail::__cyl_bessel_j<__type>(__nu, __x);
269 cyl_bessel_kf(float __nu, float __x)
270 { return __detail::__cyl_bessel_k<float>(__nu, __x); }
273 cyl_bessel_kl(long double __nu, long double __x)
274 { return __detail::__cyl_bessel_k<long double>(__nu, __x); }
276 /// 5.2.1.10 Irregular modified cylindrical Bessel functions.
277 template<typename _Tpnu, typename _Tp>
278 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
279 cyl_bessel_k(_Tpnu __nu, _Tp __x)
281 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
282 return __detail::__cyl_bessel_k<__type>(__nu, __x);
286 cyl_neumannf(float __nu, float __x)
287 { return __detail::__cyl_neumann_n<float>(__nu, __x); }
290 cyl_neumannl(long double __nu, long double __x)
291 { return __detail::__cyl_neumann_n<long double>(__nu, __x); }
293 /// 5.2.1.11 Cylindrical Neumann functions.
294 template<typename _Tpnu, typename _Tp>
295 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
296 cyl_neumann(_Tpnu __nu, _Tp __x)
298 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
299 return __detail::__cyl_neumann_n<__type>(__nu, __x);
303 ellint_1f(float __k, float __phi)
304 { return __detail::__ellint_1<float>(__k, __phi); }
307 ellint_1l(long double __k, long double __phi)
308 { return __detail::__ellint_1<long double>(__k, __phi); }
310 /// 5.2.1.12 Incomplete elliptic integrals of the first kind.
311 template<typename _Tp, typename _Tpp>
312 inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
313 ellint_1(_Tp __k, _Tpp __phi)
315 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
316 return __detail::__ellint_1<__type>(__k, __phi);
320 ellint_2f(float __k, float __phi)
321 { return __detail::__ellint_2<float>(__k, __phi); }
324 ellint_2l(long double __k, long double __phi)
325 { return __detail::__ellint_2<long double>(__k, __phi); }
327 /// 5.2.1.13 Incomplete elliptic integrals of the second kind.
328 template<typename _Tp, typename _Tpp>
329 inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
330 ellint_2(_Tp __k, _Tpp __phi)
332 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
333 return __detail::__ellint_2<__type>(__k, __phi);
337 ellint_3f(float __k, float __nu, float __phi)
338 { return __detail::__ellint_3<float>(__k, __nu, __phi); }
341 ellint_3l(long double __k, long double __nu, long double __phi)
342 { return __detail::__ellint_3<long double>(__k, __nu, __phi); }
344 /// 5.2.1.14 Incomplete elliptic integrals of the third kind.
345 template<typename _Tp, typename _Tpn, typename _Tpp>
346 inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type
347 ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
349 typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type;
350 return __detail::__ellint_3<__type>(__k, __nu, __phi);
355 { return __detail::__expint<float>(__x); }
358 expintl(long double __x)
359 { return __detail::__expint<long double>(__x); }
361 /// 5.2.1.15 Exponential integrals.
362 template<typename _Tp>
363 inline typename __gnu_cxx::__promote<_Tp>::__type
366 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
367 return __detail::__expint<__type>(__x);
371 hermitef(unsigned int __n, float __x)
372 { return __detail::__poly_hermite<float>(__n, __x); }
375 hermitel(unsigned int __n, long double __x)
376 { return __detail::__poly_hermite<long double>(__n, __x); }
378 /// 5.2.1.16 Hermite polynomials.
379 template<typename _Tp>
380 inline typename __gnu_cxx::__promote<_Tp>::__type
381 hermite(unsigned int __n, _Tp __x)
383 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
384 return __detail::__poly_hermite<__type>(__n, __x);
388 hypergf(float __a, float __b, float __c, float __x)
389 { return __detail::__hyperg<float>(__a, __b, __c, __x); }
392 hypergl(long double __a, long double __b, long double __c, long double __x)
393 { return __detail::__hyperg<long double>(__a, __b, __c, __x); }
395 /// 5.2.1.17 Hypergeometric functions.
396 template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
397 inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type
398 hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
400 typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type;
401 return __detail::__hyperg<__type>(__a, __b, __c, __x);
405 laguerref(unsigned int __n, float __x)
406 { return __detail::__laguerre<float>(__n, __x); }
409 laguerrel(unsigned int __n, long double __x)
410 { return __detail::__laguerre<long double>(__n, __x); }
412 /// 5.2.1.18 Laguerre polynomials.
413 template<typename _Tp>
414 inline typename __gnu_cxx::__promote<_Tp>::__type
415 laguerre(unsigned int __n, _Tp __x)
417 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
418 return __detail::__laguerre<__type>(__n, __x);
422 legendref(unsigned int __n, float __x)
423 { return __detail::__poly_legendre_p<float>(__n, __x); }
426 legendrel(unsigned int __n, long double __x)
427 { return __detail::__poly_legendre_p<long double>(__n, __x); }
429 /// 5.2.1.19 Legendre polynomials.
430 template<typename _Tp>
431 inline typename __gnu_cxx::__promote<_Tp>::__type
432 legendre(unsigned int __n, _Tp __x)
434 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
435 return __detail::__poly_legendre_p<__type>(__n, __x);
439 riemann_zetaf(float __x)
440 { return __detail::__riemann_zeta<float>(__x); }
443 riemann_zetal(long double __x)
444 { return __detail::__riemann_zeta<long double>(__x); }
446 /// 5.2.1.20 Riemann zeta function.
447 template<typename _Tp>
448 inline typename __gnu_cxx::__promote<_Tp>::__type
449 riemann_zeta(_Tp __x)
451 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
452 return __detail::__riemann_zeta<__type>(__x);
456 sph_besself(unsigned int __n, float __x)
457 { return __detail::__sph_bessel<float>(__n, __x); }
460 sph_bessell(unsigned int __n, long double __x)
461 { return __detail::__sph_bessel<long double>(__n, __x); }
463 /// 5.2.1.21 Spherical Bessel functions.
464 template<typename _Tp>
465 inline typename __gnu_cxx::__promote<_Tp>::__type
466 sph_bessel(unsigned int __n, _Tp __x)
468 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
469 return __detail::__sph_bessel<__type>(__n, __x);
473 sph_legendref(unsigned int __l, unsigned int __m, float __theta)
474 { return __detail::__sph_legendre<float>(__l, __m, __theta); }
477 sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
478 { return __detail::__sph_legendre<long double>(__l, __m, __theta); }
480 /// 5.2.1.22 Spherical associated Legendre functions.
481 template<typename _Tp>
482 inline typename __gnu_cxx::__promote<_Tp>::__type
483 sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
485 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
486 return __detail::__sph_legendre<__type>(__l, __m, __theta);
490 sph_neumannf(unsigned int __n, float __x)
491 { return __detail::__sph_neumann<float>(__n, __x); }
494 sph_neumannl(unsigned int __n, long double __x)
495 { return __detail::__sph_neumann<long double>(__n, __x); }
497 /// 5.2.1.23 Spherical Neumann functions.
498 template<typename _Tp>
499 inline typename __gnu_cxx::__promote<_Tp>::__type
500 sph_neumann(unsigned int __n, _Tp __x)
502 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
503 return __detail::__sph_neumann<__type>(__n, __x);
506 /* @} */ // tr1_math_spec_func
510 #endif // _GLIBCXX_TR1_CMATH