OSDN Git Service

2008-01-31 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / tr1 / cmath
1 // TR1 cmath -*- C++ -*-
2
3 // Copyright (C) 2006, 2007 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 2, 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 // 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,
19 // USA.
20
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.
29
30 /** @file tr1/cmath
31  *  This is a TR1 C++ Library header. 
32  */
33
34 #ifndef _GLIBCXX_TR1_CMATH
35 #define _GLIBCXX_TR1_CMATH 1
36
37 #pragma GCC system_header
38
39 #if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
40 #  error TR1 header cannot be included from C++0x header
41 #endif
42
43 #include <cmath>
44
45 #if defined(_GLIBCXX_INCLUDE_AS_TR1)
46 #  include <tr1_impl/cmath>
47 #else
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>
53 #  undef _GLIBCXX_TR1
54 #  undef _GLIBCXX_END_NAMESPACE_TR1
55 #  undef _GLIBCXX_BEGIN_NAMESPACE_TR1
56 #  undef _GLIBCXX_INCLUDE_AS_TR1
57 #endif
58
59 /**
60  * @defgroup tr1_math_spec_func Mathematical Special Functions
61  * A collection of advanced mathematical special functions.
62  * @{
63  */
64 #include <bits/stl_algobase.h>
65 #include <limits>
66
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>
79
80 // namespace std::tr1
81 namespace std
82 {
83 namespace tr1
84 {
85   //  5.2.1.1  Associated Laguerre polynomials.
86   inline float
87   assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
88   { return __detail::__assoc_laguerre<float>(__n, __m, __x); }
89
90   inline long double
91   assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
92   {
93     return __detail::__assoc_laguerre<long double>(__n, __m, __x);
94   }
95
96   template<typename _Tp>
97     inline typename __gnu_cxx::__promote<_Tp>::__type
98     assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
99     {
100       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
101       return __detail::__assoc_laguerre<__type>(__n, __m, __x);
102     }
103
104   //  5.2.1.2  Associated Legendre functions.
105   inline float
106   assoc_legendref(unsigned int __l, unsigned int __m, float __x)
107   { return __detail::__assoc_legendre_p<float>(__l, __m, __x); }
108
109   inline long double
110   assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
111   { return __detail::__assoc_legendre_p<long double>(__l, __m, __x); }
112
113   template<typename _Tp>
114     inline typename __gnu_cxx::__promote<_Tp>::__type
115     assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
116     {
117       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
118       return __detail::__assoc_legendre_p<__type>(__l, __m, __x);
119     }
120
121   //  5.2.1.3  Beta functions.
122   inline float
123   betaf(float __x, float __y)
124   { return __detail::__beta<float>(__x, __y); }
125
126   inline long double
127   betal(long double __x, long double __y)
128   { return __detail::__beta<long double>(__x, __y); }
129
130   template<typename _Tpx, typename _Tpy>
131     inline typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type
132     beta(_Tpx __x, _Tpy __y)
133     {
134       typedef typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type __type;
135       return __detail::__beta<__type>(__x, __y);
136     }
137
138   //  5.2.1.4  Complete elliptic integrals of the first kind.
139   inline float
140   comp_ellint_1f(float __k)
141   { return __detail::__comp_ellint_1<float>(__k); }
142
143   inline long double
144   comp_ellint_1l(long double __k)
145   { return __detail::__comp_ellint_1<long double>(__k); }
146
147   template<typename _Tp>
148     inline typename __gnu_cxx::__promote<_Tp>::__type
149     comp_ellint_1(_Tp __k)
150     {
151       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
152       return __detail::__comp_ellint_1<__type>(__k);
153     }
154
155   //  5.2.1.5  Complete elliptic integrals of the second kind.
156   inline float
157   comp_ellint_2f(float __k)
158   { return __detail::__comp_ellint_2<float>(__k); }
159
160   inline long double
161   comp_ellint_2l(long double __k)
162   { return __detail::__comp_ellint_2<long double>(__k); }
163
164   template<typename _Tp>
165     inline typename __gnu_cxx::__promote<_Tp>::__type
166     comp_ellint_2(_Tp __k)
167     {
168       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
169       return __detail::__comp_ellint_2<__type>(__k);
170     }
171
172   //  5.2.1.6  Complete elliptic integrals of the third kind.
173   inline float
174   comp_ellint_3f(float __k, float __nu)
175   { return __detail::__comp_ellint_3<float>(__k, __nu); }
176
177   inline long double
178   comp_ellint_3l(long double __k, long double __nu)
179   { return __detail::__comp_ellint_3<long double>(__k, __nu); }
180
181   template<typename _Tp, typename _Tpn>
182     inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type
183     comp_ellint_3(_Tp __k, _Tpn __nu)
184     {
185       typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type;
186       return __detail::__comp_ellint_3<__type>(__k, __nu);
187     }
188
189   //  5.2.1.7  Confluent hypergeometric functions.
190   inline float
191   conf_hypergf(float __a, float __c, float __x)
192   { return __detail::__conf_hyperg<float>(__a, __c, __x); }
193
194   inline long double
195   conf_hypergl(long double __a, long double __c, long double __x)
196   { return __detail::__conf_hyperg<long double>(__a, __c, __x); }
197
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)
201     {
202       typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type;
203       return __detail::__conf_hyperg<__type>(__a, __c, __x);
204     }
205
206   //  5.2.1.8  Regular modified cylindrical Bessel functions.
207   inline float
208   cyl_bessel_if(float __nu, float __x)
209   { return __detail::__cyl_bessel_i<float>(__nu, __x); }
210
211   inline long double
212   cyl_bessel_il(long double __nu, long double __x)
213   { return __detail::__cyl_bessel_i<long double>(__nu, __x); }
214
215   template<typename _Tpnu, typename _Tp>
216     inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
217     cyl_bessel_i(_Tpnu __nu, _Tp __x)
218     {
219       typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
220       return __detail::__cyl_bessel_i<__type>(__nu, __x);
221     }
222
223   //  5.2.1.9  Cylindrical Bessel functions (of the first kind).
224   inline float
225   cyl_bessel_jf(float __nu, float __x)
226   { return __detail::__cyl_bessel_j<float>(__nu, __x); }
227
228   inline long double
229   cyl_bessel_jl(long double __nu, long double __x)
230   { return __detail::__cyl_bessel_j<long double>(__nu, __x); }
231
232   template<typename _Tpnu, typename _Tp>
233     inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
234     cyl_bessel_j(_Tpnu __nu, _Tp __x)
235     {
236       typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
237       return __detail::__cyl_bessel_j<__type>(__nu, __x);
238     }
239
240   //  5.2.1.10  Irregular modified cylindrical Bessel functions.
241   inline float
242   cyl_bessel_kf(float __nu, float __x)
243   { return __detail::__cyl_bessel_k<float>(__nu, __x); }
244
245   inline long double
246   cyl_bessel_kl(long double __nu, long double __x)
247   { return __detail::__cyl_bessel_k<long double>(__nu, __x); }
248
249   template<typename _Tpnu, typename _Tp>
250     inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
251     cyl_bessel_k(_Tpnu __nu, _Tp __x)
252     {
253       typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
254       return __detail::__cyl_bessel_k<__type>(__nu, __x);
255     }
256
257   //  5.2.1.11  Cylindrical Neumann functions.
258   inline float
259   cyl_neumannf(float __nu, float __x)
260   { return __detail::__cyl_neumann_n<float>(__nu, __x); }
261
262   inline long double
263   cyl_neumannl(long double __nu, long double __x)
264   { return __detail::__cyl_neumann_n<long double>(__nu, __x); }
265
266   template<typename _Tpnu, typename _Tp>
267     inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
268     cyl_neumann(_Tpnu __nu, _Tp __x)
269     {
270       typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
271       return __detail::__cyl_neumann_n<__type>(__nu, __x);
272     }
273
274   //  5.2.1.12  Incomplete elliptic integrals of the first kind.
275   inline float
276   ellint_1f(float __k, float __phi)
277   { return __detail::__ellint_1<float>(__k, __phi); }
278
279   inline long double
280   ellint_1l(long double __k, long double __phi)
281   { return __detail::__ellint_1<long double>(__k, __phi); }
282
283   template<typename _Tp, typename _Tpp>
284     inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
285     ellint_1(_Tp __k, _Tpp __phi)
286     {
287       typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
288       return __detail::__ellint_1<__type>(__k, __phi);
289     }
290
291   //  5.2.1.13  Incomplete elliptic integrals of the second kind.
292   inline float
293   ellint_2f(float __k, float __phi)
294   { return __detail::__ellint_2<float>(__k, __phi); }
295
296   inline long double
297   ellint_2l(long double __k, long double __phi)
298   { return __detail::__ellint_2<long double>(__k, __phi); }
299
300   template<typename _Tp, typename _Tpp>
301     inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
302     ellint_2(_Tp __k, _Tpp __phi)
303     {
304       typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
305       return __detail::__ellint_2<__type>(__k, __phi);
306     }
307
308   //  5.2.1.14  Incomplete elliptic integrals of the third kind.
309   inline float
310   ellint_3f(float __k, float __nu, float __phi)
311   { return __detail::__ellint_3<float>(__k, __nu, __phi); }
312
313   inline long double
314   ellint_3l(long double __k, long double __nu, long double __phi)
315   { return __detail::__ellint_3<long double>(__k, __nu, __phi); }
316
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)
320     {
321       typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type;
322       return __detail::__ellint_3<__type>(__k, __nu, __phi);
323     }
324
325   //  5.2.1.15  Exponential integrals.
326   inline float
327   expintf(float __x)
328   { return __detail::__expint<float>(__x); }
329
330   inline long double
331   expintl(long double __x)
332   { return __detail::__expint<long double>(__x); }
333
334   template<typename _Tp>
335     inline typename __gnu_cxx::__promote<_Tp>::__type
336     expint(_Tp __x)
337     {
338       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
339       return __detail::__expint<__type>(__x);
340     }
341
342   //  5.2.1.16  Hermite polynomials.
343   inline float
344   hermitef(unsigned int __n, float __x)
345   { return __detail::__poly_hermite<float>(__n, __x); }
346
347   inline long double
348   hermitel(unsigned int __n, long double __x)
349   { return __detail::__poly_hermite<long double>(__n, __x); }
350
351   template<typename _Tp>
352     inline typename __gnu_cxx::__promote<_Tp>::__type
353     hermite(unsigned int __n, _Tp __x)
354     {
355       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
356       return __detail::__poly_hermite<__type>(__n, __x);
357     }
358
359   //  5.2.1.17  Hypergeometric functions.
360   inline float
361   hypergf(float __a, float __b, float __c, float __x)
362   { return __detail::__hyperg<float>(__a, __b, __c, __x); }
363
364   inline long double
365   hypergl(long double __a, long double __b, long double __c, long double __x)
366   { return __detail::__hyperg<long double>(__a, __b, __c, __x); }
367
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)
371     {
372       typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type;
373       return __detail::__hyperg<__type>(__a, __b, __c, __x);
374     }
375
376   //  5.2.1.18  Laguerre polynomials.
377   inline float
378   laguerref(unsigned int __n, float __x)
379   { return __detail::__laguerre<float>(__n, __x); }
380
381   inline long double
382   laguerrel(unsigned int __n, long double __x)
383   { return __detail::__laguerre<long double>(__n, __x); }
384
385   template<typename _Tp>
386     inline typename __gnu_cxx::__promote<_Tp>::__type
387     laguerre(unsigned int __n, _Tp __x)
388     {
389       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
390       return __detail::__laguerre<__type>(__n, __x);
391     }
392
393   //  5.2.1.19  Legendre polynomials.
394   inline float
395   legendref(unsigned int __n, float __x)
396   { return __detail::__poly_legendre_p<float>(__n, __x); }
397
398   inline long double
399   legendrel(unsigned int __n, long double __x)
400   { return __detail::__poly_legendre_p<long double>(__n, __x); }
401
402   template<typename _Tp>
403     inline typename __gnu_cxx::__promote<_Tp>::__type
404     legendre(unsigned int __n, _Tp __x)
405     {
406       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
407       return __detail::__poly_legendre_p<__type>(__n, __x);
408     }
409
410   //  5.2.1.20  Riemann zeta function.
411   inline float
412   riemann_zetaf(float __x)
413   { return __detail::__riemann_zeta<float>(__x); }
414
415   inline long double
416   riemann_zetal(long double __x)
417   { return __detail::__riemann_zeta<long double>(__x); }
418
419   template<typename _Tp>
420     inline typename __gnu_cxx::__promote<_Tp>::__type
421     riemann_zeta(_Tp __x)
422     {
423       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
424       return __detail::__riemann_zeta<__type>(__x);
425     }
426
427   //  5.2.1.21  Spherical Bessel functions.
428   inline float
429   sph_besself(unsigned int __n, float __x)
430   { return __detail::__sph_bessel<float>(__n, __x); }
431
432   inline long double
433   sph_bessell(unsigned int __n, long double __x)
434   { return __detail::__sph_bessel<long double>(__n, __x); }
435
436   template<typename _Tp>
437     inline typename __gnu_cxx::__promote<_Tp>::__type
438     sph_bessel(unsigned int __n, _Tp __x)
439     {
440       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
441       return __detail::__sph_bessel<__type>(__n, __x);
442     }
443
444   //  5.2.1.22  Spherical associated Legendre functions.
445   inline float
446   sph_legendref(unsigned int __l, unsigned int __m, float __theta)
447   { return __detail::__sph_legendre<float>(__l, __m, __theta); }
448
449   inline long double
450   sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
451   { return __detail::__sph_legendre<long double>(__l, __m, __theta); }
452
453   template<typename _Tp>
454     inline typename __gnu_cxx::__promote<_Tp>::__type
455     sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
456     {
457       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
458       return __detail::__sph_legendre<__type>(__l, __m, __theta);
459     }
460
461   //  5.2.1.23  Spherical Neumann functions.
462   inline float
463   sph_neumannf(unsigned int __n, float __x)
464   { return __detail::__sph_neumann<float>(__n, __x); }
465
466   inline long double
467   sph_neumannl(unsigned int __n, long double __x)
468   { return __detail::__sph_neumann<long double>(__n, __x); }
469
470   template<typename _Tp>
471     inline typename __gnu_cxx::__promote<_Tp>::__type
472     sph_neumann(unsigned int __n, _Tp __x)
473     {
474       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
475       return __detail::__sph_neumann<__type>(__n, __x);
476     }
477
478   /* @} */ // group tr1_math_spec_func
479 }
480 }
481
482 #endif // _GLIBCXX_TR1_CMATH