libstdc++
specfun.h
Go to the documentation of this file.
1 // Mathematical Special Functions for -*- C++ -*-
2 
3 // Copyright (C) 2006-2015 Free Software Foundation, Inc.
4 //
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 3, or (at your option)
9 // any later version.
10 
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.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
25 /** @file bits/specfun.h
26  * This is an internal header file, included by other library headers.
27  * Do not attempt to use it directly. @headername{cmath}
28  */
29 
30 #ifndef _GLIBCXX_BITS_SPECFUN_H
31 #define _GLIBCXX_BITS_SPECFUN_H 1
32 
33 #pragma GCC visibility push(default)
34 
35 #include <bits/c++config.h>
36 
37 #if __STDCPP_WANT_MATH_SPEC_FUNCS__ == 0
38 # error include <cmath> and define __STDCPP_WANT_MATH_SPEC_FUNCS__
39 #endif
40 
41 #define __STDCPP_MATH_SPEC_FUNCS__ 201003L
42 
43 #include <bits/stl_algobase.h>
44 #include <limits>
45 #include <type_traits>
46 
47 #include <tr1/gamma.tcc>
48 #include <tr1/bessel_function.tcc>
49 #include <tr1/beta_function.tcc>
50 #include <tr1/ell_integral.tcc>
51 #include <tr1/exp_integral.tcc>
52 #include <tr1/hypergeometric.tcc>
53 #include <tr1/legendre_function.tcc>
54 #include <tr1/modified_bessel_func.tcc>
55 #include <tr1/poly_hermite.tcc>
56 #include <tr1/poly_laguerre.tcc>
57 #include <tr1/riemann_zeta.tcc>
58 
59 namespace std _GLIBCXX_VISIBILITY(default)
60 {
61 _GLIBCXX_BEGIN_NAMESPACE_VERSION
62 
63  /**
64  * @defgroup mathsf Mathematical Special Functions
65  * @ingroup numerics
66  *
67  * A collection of advanced mathematical special functions,
68  * defined by ISO/IEC IS 29124.
69  * @{
70  */
71 
72  // Associated Laguerre polynomials
73 
74  inline float
75  assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
76  { return __detail::__assoc_laguerre<float>(__n, __m, __x); }
77 
78  inline long double
79  assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
80  { return __detail::__assoc_laguerre<long double>(__n, __m, __x); }
81 
82  template<typename _Tp>
83  inline typename __gnu_cxx::__promote<_Tp>::__type
84  assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
85  {
86  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
87  return __detail::__assoc_laguerre<__type>(__n, __m, __x);
88  }
89 
90  // Associated Legendre functions
91 
92  inline float
93  assoc_legendref(unsigned int __l, unsigned int __m, float __x)
94  { return __detail::__assoc_legendre_p<float>(__l, __m, __x); }
95 
96  inline long double
97  assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
98  { return __detail::__assoc_legendre_p<long double>(__l, __m, __x); }
99 
100  template<typename _Tp>
101  inline typename __gnu_cxx::__promote<_Tp>::__type
102  assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
103  {
104  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
105  return __detail::__assoc_legendre_p<__type>(__l, __m, __x);
106  }
107 
108  // Beta functions
109 
110  inline float
111  betaf(float __x, float __y)
112  { return __detail::__beta<float>(__x, __y); }
113 
114  inline long double
115  betal(long double __x, long double __y)
116  { return __detail::__beta<long double>(__x, __y); }
117 
118  template<typename _Tpx, typename _Tpy>
119  inline typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type
120  beta(_Tpx __x, _Tpy __y)
121  {
122  typedef typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type __type;
123  return __detail::__beta<__type>(__x, __y);
124  }
125 
126  // Complete elliptic integrals of the first kind
127 
128  inline float
129  comp_ellint_1f(float __k)
130  { return __detail::__comp_ellint_1<float>(__k); }
131 
132  inline long double
133  comp_ellint_1l(long double __k)
134  { return __detail::__comp_ellint_1<long double>(__k); }
135 
136  template<typename _Tp>
137  inline typename __gnu_cxx::__promote<_Tp>::__type
138  comp_ellint_1(_Tp __k)
139  {
140  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
141  return __detail::__comp_ellint_1<__type>(__k);
142  }
143 
144  // Complete elliptic integrals of the second kind
145 
146  inline float
147  comp_ellint_2f(float __k)
148  { return __detail::__comp_ellint_2<float>(__k); }
149 
150  inline long double
151  comp_ellint_2l(long double __k)
152  { return __detail::__comp_ellint_2<long double>(__k); }
153 
154  template<typename _Tp>
155  inline typename __gnu_cxx::__promote<_Tp>::__type
156  comp_ellint_2(_Tp __k)
157  {
158  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
159  return __detail::__comp_ellint_2<__type>(__k);
160  }
161 
162  // Complete elliptic integrals of the third kind
163 
164  inline float
165  comp_ellint_3f(float __k, float __nu)
166  { return __detail::__comp_ellint_3<float>(__k, __nu); }
167 
168  inline long double
169  comp_ellint_3l(long double __k, long double __nu)
170  { return __detail::__comp_ellint_3<long double>(__k, __nu); }
171 
172  template<typename _Tp, typename _Tpn>
173  inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type
174  comp_ellint_3(_Tp __k, _Tpn __nu)
175  {
176  typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type;
177  return __detail::__comp_ellint_3<__type>(__k, __nu);
178  }
179 
180  // Regular modified cylindrical Bessel functions
181 
182  inline float
183  cyl_bessel_if(float __nu, float __x)
184  { return __detail::__cyl_bessel_i<float>(__nu, __x); }
185 
186  inline long double
187  cyl_bessel_il(long double __nu, long double __x)
188  { return __detail::__cyl_bessel_i<long double>(__nu, __x); }
189 
190  template<typename _Tpnu, typename _Tp>
191  inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
192  cyl_bessel_i(_Tpnu __nu, _Tp __x)
193  {
194  typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
195  return __detail::__cyl_bessel_i<__type>(__nu, __x);
196  }
197 
198  // Cylindrical Bessel functions (of the first kind)
199 
200  inline float
201  cyl_bessel_jf(float __nu, float __x)
202  { return __detail::__cyl_bessel_j<float>(__nu, __x); }
203 
204  inline long double
205  cyl_bessel_jl(long double __nu, long double __x)
206  { return __detail::__cyl_bessel_j<long double>(__nu, __x); }
207 
208  template<typename _Tpnu, typename _Tp>
209  inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
210  cyl_bessel_j(_Tpnu __nu, _Tp __x)
211  {
212  typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
213  return __detail::__cyl_bessel_j<__type>(__nu, __x);
214  }
215 
216  // Irregular modified cylindrical Bessel functions
217 
218  inline float
219  cyl_bessel_kf(float __nu, float __x)
220  { return __detail::__cyl_bessel_k<float>(__nu, __x); }
221 
222  inline long double
223  cyl_bessel_kl(long double __nu, long double __x)
224  { return __detail::__cyl_bessel_k<long double>(__nu, __x); }
225 
226  template<typename _Tpnu, typename _Tp>
227  inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
228  cyl_bessel_k(_Tpnu __nu, _Tp __x)
229  {
230  typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
231  return __detail::__cyl_bessel_k<__type>(__nu, __x);
232  }
233 
234  // Cylindrical Neumann functions
235 
236  inline float
237  cyl_neumannf(float __nu, float __x)
238  { return __detail::__cyl_neumann_n<float>(__nu, __x); }
239 
240  inline long double
241  cyl_neumannl(long double __nu, long double __x)
242  { return __detail::__cyl_neumann_n<long double>(__nu, __x); }
243 
244  template<typename _Tpnu, typename _Tp>
245  inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
246  cyl_neumann(_Tpnu __nu, _Tp __x)
247  {
248  typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
249  return __detail::__cyl_neumann_n<__type>(__nu, __x);
250  }
251 
252  // Incomplete elliptic integrals of the first kind
253 
254  inline float
255  ellint_1f(float __k, float __phi)
256  { return __detail::__ellint_1<float>(__k, __phi); }
257 
258  inline long double
259  ellint_1l(long double __k, long double __phi)
260  { return __detail::__ellint_1<long double>(__k, __phi); }
261 
262  template<typename _Tp, typename _Tpp>
263  inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
264  ellint_1(_Tp __k, _Tpp __phi)
265  {
266  typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
267  return __detail::__ellint_1<__type>(__k, __phi);
268  }
269 
270  // Incomplete elliptic integrals of the second kind
271 
272  inline float
273  ellint_2f(float __k, float __phi)
274  { return __detail::__ellint_2<float>(__k, __phi); }
275 
276  inline long double
277  ellint_2l(long double __k, long double __phi)
278  { return __detail::__ellint_2<long double>(__k, __phi); }
279 
280  template<typename _Tp, typename _Tpp>
281  inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
282  ellint_2(_Tp __k, _Tpp __phi)
283  {
284  typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
285  return __detail::__ellint_2<__type>(__k, __phi);
286  }
287 
288  // Incomplete elliptic integrals of the third kind
289 
290  inline float
291  ellint_3f(float __k, float __nu, float __phi)
292  { return __detail::__ellint_3<float>(__k, __nu, __phi); }
293 
294  inline long double
295  ellint_3l(long double __k, long double __nu, long double __phi)
296  { return __detail::__ellint_3<long double>(__k, __nu, __phi); }
297 
298  template<typename _Tp, typename _Tpn, typename _Tpp>
299  inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type
300  ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
301  {
302  typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type;
303  return __detail::__ellint_3<__type>(__k, __nu, __phi);
304  }
305 
306  // Exponential integrals
307 
308  inline float
309  expintf(float __x)
310  { return __detail::__expint<float>(__x); }
311 
312  inline long double
313  expintl(long double __x)
314  { return __detail::__expint<long double>(__x); }
315 
316  template<typename _Tp>
317  inline typename __gnu_cxx::__promote<_Tp>::__type
318  expint(_Tp __x)
319  {
320  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
321  return __detail::__expint<__type>(__x);
322  }
323 
324  // Hermite polynomials
325 
326  inline float
327  hermitef(unsigned int __n, float __x)
328  { return __detail::__poly_hermite<float>(__n, __x); }
329 
330  inline long double
331  hermitel(unsigned int __n, long double __x)
332  { return __detail::__poly_hermite<long double>(__n, __x); }
333 
334  template<typename _Tp>
335  inline typename __gnu_cxx::__promote<_Tp>::__type
336  hermite(unsigned int __n, _Tp __x)
337  {
338  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
339  return __detail::__poly_hermite<__type>(__n, __x);
340  }
341 
342  // Laguerre polynomials
343 
344  inline float
345  laguerref(unsigned int __n, float __x)
346  { return __detail::__laguerre<float>(__n, __x); }
347 
348  inline long double
349  laguerrel(unsigned int __n, long double __x)
350  { return __detail::__laguerre<long double>(__n, __x); }
351 
352  template<typename _Tp>
353  inline typename __gnu_cxx::__promote<_Tp>::__type
354  laguerre(unsigned int __n, _Tp __x)
355  {
356  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
357  return __detail::__laguerre<__type>(__n, __x);
358  }
359 
360  // Legendre polynomials
361 
362  inline float
363  legendref(unsigned int __n, float __x)
364  { return __detail::__poly_legendre_p<float>(__n, __x); }
365 
366  inline long double
367  legendrel(unsigned int __n, long double __x)
368  { return __detail::__poly_legendre_p<long double>(__n, __x); }
369 
370  template<typename _Tp>
371  inline typename __gnu_cxx::__promote<_Tp>::__type
372  legendre(unsigned int __n, _Tp __x)
373  {
374  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
375  return __detail::__poly_legendre_p<__type>(__n, __x);
376  }
377 
378  // Riemann zeta functions
379 
380  inline float
381  riemann_zetaf(float __s)
382  { return __detail::__riemann_zeta<float>(__s); }
383 
384  inline long double
385  riemann_zetal(long double __s)
386  { return __detail::__riemann_zeta<long double>(__s); }
387 
388  template<typename _Tp>
389  inline typename __gnu_cxx::__promote<_Tp>::__type
390  riemann_zeta(_Tp __s)
391  {
392  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
393  return __detail::__riemann_zeta<__type>(__s);
394  }
395 
396  // Spherical Bessel functions
397 
398  inline float
399  sph_besself(unsigned int __n, float __x)
400  { return __detail::__sph_bessel<float>(__n, __x); }
401 
402  inline long double
403  sph_bessell(unsigned int __n, long double __x)
404  { return __detail::__sph_bessel<long double>(__n, __x); }
405 
406  template<typename _Tp>
407  inline typename __gnu_cxx::__promote<_Tp>::__type
408  sph_bessel(unsigned int __n, _Tp __x)
409  {
410  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
411  return __detail::__sph_bessel<__type>(__n, __x);
412  }
413 
414  // Spherical associated Legendre functions
415 
416  inline float
417  sph_legendref(unsigned int __l, unsigned int __m, float __theta)
418  { return __detail::__sph_legendre<float>(__l, __m, __theta); }
419 
420  inline long double
421  sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
422  { return __detail::__sph_legendre<long double>(__l, __m, __theta); }
423 
424  template<typename _Tp>
425  inline typename __gnu_cxx::__promote<_Tp>::__type
426  sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
427  {
428  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
429  return __detail::__sph_legendre<__type>(__l, __m, __theta);
430  }
431 
432  // Spherical Neumann functions
433 
434  inline float
435  sph_neumannf(unsigned int __n, float __x)
436  { return __detail::__sph_neumann<float>(__n, __x); }
437 
438  inline long double
439  sph_neumannl(unsigned int __n, long double __x)
440  { return __detail::__sph_neumann<long double>(__n, __x); }
441 
442  template<typename _Tp>
443  inline typename __gnu_cxx::__promote<_Tp>::__type
444  sph_neumann(unsigned int __n, _Tp __x)
445  {
446  typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
447  return __detail::__sph_neumann<__type>(__n, __x);
448  }
449 
450  // @} group mathsf
451 
452 _GLIBCXX_END_NAMESPACE_VERSION
453 } // namespace std
454 
455 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
456 {
457 
458  // Confluent hypergeometric functions
459 
460  inline float
461  conf_hypergf(float __a, float __c, float __x)
462  { return std::__detail::__conf_hyperg<float>(__a, __c, __x); }
463 
464  inline long double
465  conf_hypergl(long double __a, long double __c, long double __x)
466  { return std::__detail::__conf_hyperg<long double>(__a, __c, __x); }
467 
468  template<typename _Tpa, typename _Tpc, typename _Tp>
469  inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type
470  conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
471  {
472  typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type;
473  return std::__detail::__conf_hyperg<__type>(__a, __c, __x);
474  }
475 
476  // Hypergeometric functions
477 
478  inline float
479  hypergf(float __a, float __b, float __c, float __x)
480  { return std::__detail::__hyperg<float>(__a, __b, __c, __x); }
481 
482  inline long double
483  hypergl(long double __a, long double __b, long double __c, long double __x)
484  { return std::__detail::__hyperg<long double>(__a, __b, __c, __x); }
485 
486  template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
487  inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type
488  hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
489  {
490  typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>
491  ::__type __type;
492  return std::__detail::__hyperg<__type>(__a, __b, __c, __x);
493  }
494 
495 } // namespace __gnu_cxx
496 
497 #pragma GCC visibility pop
498 
499 #endif // _GLIBCXX_BITS_SPECFUN_H
GNU extensions for public use.
ISO C++ entities toplevel namespace is std.