Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
SpecFuncMathMore.cxx
Go to the documentation of this file.
1// @(#)root/mathmore:$Id$
2// Authors: L. Moneta, A. Zsenei 08/2005
3
4// Authors: Andras Zsenei & Lorenzo Moneta 06/2005
5
6/**********************************************************************
7 * *
8 * Copyright (c) 2005 , LCG ROOT MathLib Team *
9 * *
10 * *
11 **********************************************************************/
12
13#include <cmath>
14
15#ifndef PI
16#define PI 3.14159265358979323846264338328 /* pi */
17#endif
18
19
20#include "gsl/gsl_sf_bessel.h"
21#include "gsl/gsl_sf_legendre.h"
22#include "gsl/gsl_sf_lambert.h"
23#include "gsl/gsl_sf_laguerre.h"
24#include "gsl/gsl_sf_hyperg.h"
25#include "gsl/gsl_sf_ellint.h"
26//#include "gsl/gsl_sf_gamma.h"
27#include "gsl/gsl_sf_expint.h"
28#include "gsl/gsl_sf_zeta.h"
29#include "gsl/gsl_sf_airy.h"
30#include "gsl/gsl_sf_coupling.h"
31#include "gsl/gsl_sf_psi.h"
32
33
34namespace ROOT {
35namespace Math {
36
37
38
39
40// [5.2.1.1] associated Laguerre polynomials
41// (26.x.12)
42
43double assoc_laguerre(unsigned n, double m, double x) {
44
45 return gsl_sf_laguerre_n(n, m, x);
46
47}
48
49
50
51// [5.2.1.2] associated Legendre functions
52// (26.x.8)
53
54double assoc_legendre(unsigned l, unsigned m, double x) {
55 // add (-1)^m
56 return (m%2 == 0) ? gsl_sf_legendre_Plm(l, m, x) : -gsl_sf_legendre_Plm(l, m, x);
57
58}
59
60// Shortcut for RooFit to call the gsl legendre functions without the branches in the above implementation.
61namespace internal{
62 double legendre(unsigned l, unsigned m, double x) {
63 return gsl_sf_legendre_Plm(l, m, x);
64 }
65}
66
67
68// [5.2.1.4] (complete) elliptic integral of the first kind
69// (26.x.15.2)
70
71double comp_ellint_1(double k) {
72
73 return gsl_sf_ellint_Kcomp(k, GSL_PREC_DOUBLE);
74
75}
76
77
78
79// [5.2.1.5] (complete) elliptic integral of the second kind
80// (26.x.16.2)
81
82double comp_ellint_2(double k) {
83
84 return gsl_sf_ellint_Ecomp(k, GSL_PREC_DOUBLE);
85
86}
87
88
89
90// [5.2.1.6] (complete) elliptic integral of the third kind
91// (26.x.17.2)
92/**
93Complete elliptic integral of the third kind.
94
95There are two different definitions used for the elliptic
96integral of the third kind:
97
98\f[
99P(\phi,k,n) = \int_0^\phi \frac{dt}{(1 + n \sin^2{t})\sqrt{1 - k^2 \sin^2{t}}}
100\f]
101
102and
103
104\f[
105P(\phi,k,n) = \int_0^\phi \frac{dt}{(1 - n \sin^2{t})\sqrt{1 - k^2 \sin^2{t}}}
106\f]
107
108the former is adopted by
109
110- GSL
111 http://www.gnu.org/software/gsl/manual/gsl-ref_7.html#SEC95
112
113- Planetmath
114 http://planetmath.org/encyclopedia/EllipticIntegralsAndJacobiEllipticFunctions.html
115
116- CERNLIB
117 https://cern-tex.web.cern.ch/cern-tex/shortwrupsdir/c346/top.html
118
119 while the latter is used by
120
121- Abramowitz and Stegun
122
123- Mathematica
124 http://mathworld.wolfram.com/EllipticIntegraloftheThirdKind.html
125
126- C++ standard
127 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1687.pdf
128
129 in order to be C++ compliant, we decided to use the latter, hence the
130 change of the sign in the function call to GSL.
131
132 */
133
134double comp_ellint_3(double n, double k) {
135
136 return gsl_sf_ellint_P(PI/2.0, k, -n, GSL_PREC_DOUBLE);
137
138}
139
140
141
142// [5.2.1.7] confluent hypergeometric functions
143// (26.x.14)
144
145double conf_hyperg(double a, double b, double z) {
146
147 return gsl_sf_hyperg_1F1(a, b, z);
148
149}
150
151// confluent hypergeometric functions of second type
152
153double conf_hypergU(double a, double b, double z) {
154
155 return gsl_sf_hyperg_U(a, b, z);
156
157}
158
159
160
161// [5.2.1.8] regular modified cylindrical Bessel functions
162// (26.x.4.1)
163
164double cyl_bessel_i(double nu, double x) {
165
166 return gsl_sf_bessel_Inu(nu, x);
167
168}
169
170
171
172// [5.2.1.9] cylindrical Bessel functions (of the first kind)
173// (26.x.2)
174
175double cyl_bessel_j(double nu, double x) {
176
177 return gsl_sf_bessel_Jnu(nu, x);
178
179}
180
181
182
183// [5.2.1.10] irregular modified cylindrical Bessel functions
184// (26.x.4.2)
185
186double cyl_bessel_k(double nu, double x) {
187
188 return gsl_sf_bessel_Knu(nu, x);
189
190}
191
192
193
194// [5.2.1.11] cylindrical Neumann functions;
195// cylindrical Bessel functions (of the second kind)
196// (26.x.3)
197
198double cyl_neumann(double nu, double x) {
199
200 return gsl_sf_bessel_Ynu(nu, x);
201
202}
203
204
205
206// [5.2.1.12] (incomplete) elliptic integral of the first kind
207// phi in radians
208// (26.x.15.1)
209
210double ellint_1(double k, double phi) {
211
212 return gsl_sf_ellint_F(phi, k, GSL_PREC_DOUBLE);
213
214}
215
216
217
218// [5.2.1.13] (incomplete) elliptic integral of the second kind
219// phi in radians
220// (26.x.16.1)
221
222double ellint_2(double k, double phi) {
223
224 return gsl_sf_ellint_E(phi, k, GSL_PREC_DOUBLE);
225
226}
227
228
229
230// [5.2.1.14] (incomplete) elliptic integral of the third kind
231// phi in radians
232// (26.x.17.1)
233/**
234
235Incomplete elliptic integral of the third kind.
236
237There are two different definitions used for the elliptic
238integral of the third kind:
239
240\f[
241P(\phi,k,n) = \int_0^\phi \frac{dt}{(1 + n \sin^2{t})\sqrt{1 - k^2 \sin^2{t}}}
242\f]
243
244and
245
246\f[
247P(\phi,k,n) = \int_0^\phi \frac{dt}{(1 - n \sin^2{t})\sqrt{1 - k^2 \sin^2{t}}}
248\f]
249
250the former is adopted by
251
252- GSL
253 http://www.gnu.org/software/gsl/manual/gsl-ref_7.html#SEC95
254
255- Planetmath
256 http://planetmath.org/encyclopedia/EllipticIntegralsAndJacobiEllipticFunctions.html
257
258- CERNLIB
259 https://cern-tex.web.cern.ch/cern-tex/shortwrupsdir/c346/top.html
260
261 while the latter is used by
262
263- Abramowitz and Stegun
264
265- Mathematica
266 http://mathworld.wolfram.com/EllipticIntegraloftheThirdKind.html
267
268- C++ standard
269 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1687.pdf
270
271 in order to be C++ compliant, we decided to use the latter, hence the
272 change of the sign in the function call to GSL.
273
274 */
275
276double ellint_3(double n, double k, double phi) {
277
278 return gsl_sf_ellint_P(phi, k, -n, GSL_PREC_DOUBLE);
279
280}
281
282
283
284// [5.2.1.15] exponential integral
285// (26.x.20)
286
287double expint(double x) {
288
289 return gsl_sf_expint_Ei(x);
290
291}
292
293
294// Generalization of expint(x)
295//
296double expint_n(int n, double x) {
297
298 return gsl_sf_expint_En(n, x);
299
300}
301
302
303
304// [5.2.1.16] Hermite polynomials
305// (26.x.10)
306
307//double hermite(unsigned n, double x) {
308//}
309
310
311
312
313// [5.2.1.17] hypergeometric functions
314// (26.x.13)
315
316double hyperg(double a, double b, double c, double x) {
317
318 return gsl_sf_hyperg_2F1(a, b, c, x);
319
320}
321
322
323
324// [5.2.1.18] Laguerre polynomials
325// (26.x.11)
326
327double laguerre(unsigned n, double x) {
328 return gsl_sf_laguerre_n(n, 0, x);
329}
330
331
332// Lambert W function on branch 0
333
334double lambert_W0(double x) {
335 return gsl_sf_lambert_W0(x);
336}
337
338
339// Lambert W function on branch -1
340
341double lambert_Wm1(double x) {
342 return gsl_sf_lambert_Wm1(x);
343}
344
345
346// [5.2.1.19] Legendre polynomials
347// (26.x.7)
348
349double legendre(unsigned l, double x) {
350
351 return gsl_sf_legendre_Pl(l, x);
352
353}
354
355
356
357// [5.2.1.20] Riemann zeta function
358// (26.x.22)
359
360double riemann_zeta(double x) {
361
362 return gsl_sf_zeta(x);
363
364}
365
366
367
368// [5.2.1.21] spherical Bessel functions of the first kind
369// (26.x.5)
370
371double sph_bessel(unsigned n, double x) {
372
373 return gsl_sf_bessel_jl(n, x);
374
375}
376
377
378
379// [5.2.1.22] spherical associated Legendre functions
380// (26.x.9) ??????????
381
382double sph_legendre(unsigned l, unsigned m, double theta) {
383
384 return gsl_sf_legendre_sphPlm(l, m, std::cos(theta));
385
386}
387
388
389
390
391// [5.2.1.23] spherical Neumann functions
392// (26.x.6)
393
394double sph_neumann(unsigned n, double x) {
395
396 return gsl_sf_bessel_yl(n, x);
397
398}
399
400// Airy function Ai
401
402double airy_Ai(double x) {
403
404 return gsl_sf_airy_Ai(x, GSL_PREC_DOUBLE);
405
406}
407
408// Airy function Bi
409
410double airy_Bi(double x) {
411
412 return gsl_sf_airy_Bi(x, GSL_PREC_DOUBLE);
413
414}
415
416// Derivative of the Airy function Ai
417
418double airy_Ai_deriv(double x) {
419
420 return gsl_sf_airy_Ai_deriv(x, GSL_PREC_DOUBLE);
421
422}
423
424// Derivative of the Airy function Bi
425
426double airy_Bi_deriv(double x) {
427
428 return gsl_sf_airy_Bi_deriv(x, GSL_PREC_DOUBLE);
429
430}
431
432// s-th zero of the Airy function Ai
433
434double airy_zero_Ai(unsigned int s) {
435
436 return gsl_sf_airy_zero_Ai(s);
437
438}
439
440// s-th zero of the Airy function Bi
441
442double airy_zero_Bi(unsigned int s) {
443
444 return gsl_sf_airy_zero_Bi(s);
445
446}
447
448// s-th zero of the derivative of the Airy function Ai
449
450double airy_zero_Ai_deriv(unsigned int s) {
451
452 return gsl_sf_airy_zero_Ai_deriv(s);
453
454}
455
456// s-th zero of the derivative of the Airy function Bi
457
458double airy_zero_Bi_deriv(unsigned int s) {
459
460 return gsl_sf_airy_zero_Bi_deriv(s);
461
462}
463
464// wigner coefficient
465
466double wigner_3j(int ja, int jb, int jc, int ma, int mb, int mc) {
467 return gsl_sf_coupling_3j(ja,jb,jc,ma,mb,mc);
468}
469
470double wigner_6j(int ja, int jb, int jc, int jd, int je, int jf) {
471 return gsl_sf_coupling_6j(ja,jb,jc,jd,je,jf);
472}
473
474double wigner_9j(int ja, int jb, int jc, int jd, int je, int jf, int jg, int jh, int ji) {
475 return gsl_sf_coupling_9j(ja,jb,jc,jd,je,jf,jg,jh,ji);
476}
477
478// Psi (Digamma) Function.
479
480double digamma(double x)
481{
482 return gsl_sf_psi(x);
483}
484
485} // namespace Math
486} // namespace ROOT
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define PI
double airy_Bi(double x)
Calculates the Airy function Bi.
double legendre(unsigned l, double x)
Calculates the Legendre polynomials.
double expint(double x)
Calculates the exponential integral.
double riemann_zeta(double x)
Calculates the Riemann zeta function.
double ellint_1(double k, double phi)
Calculates the incomplete elliptic integral of the first kind.
double cyl_neumann(double nu, double x)
Calculates the (cylindrical) Bessel functions of the second kind (also called irregular (cylindrical)...
double sph_legendre(unsigned l, unsigned m, double theta)
Computes the spherical (normalized) associated Legendre polynomials, or spherical harmonic without az...
double wigner_3j(int two_ja, int two_jb, int two_jc, int two_ma, int two_mb, int two_mc)
Calculates the Wigner 3j coupling coefficients.
double comp_ellint_1(double k)
Calculates the complete elliptic integral of the first kind.
double comp_ellint_3(double n, double k)
Calculates the complete elliptic integral of the third kind.
double expint_n(int n, double x)
double conf_hypergU(double a, double b, double z)
Calculates the confluent hypergeometric functions of the second kind, known also as Kummer function o...
double airy_Ai_deriv(double x)
Calculates the derivative of the Airy function Ai.
double wigner_9j(int two_ja, int two_jb, int two_jc, int two_jd, int two_je, int two_jf, int two_jg, int two_jh, int two_ji)
Calculates the Wigner 9j coupling coefficients.
double assoc_laguerre(unsigned n, double m, double x)
Computes the generalized Laguerre polynomials for .
double digamma(double x)
double ellint_3(double n, double k, double phi)
Calculates the complete elliptic integral of the third kind.
double airy_Ai(double x)
Calculates the Airy function Ai.
double airy_zero_Bi_deriv(unsigned int s)
Calculates the zeroes of the derivative of the Airy function Bi.
double lambert_W0(double x)
Calculates the Lambert W function on branch 0.
double conf_hyperg(double a, double b, double z)
Calculates the confluent hypergeometric functions of the first kind.
double hyperg(double a, double b, double c, double x)
Calculates Gauss' hypergeometric function.
double airy_zero_Ai_deriv(unsigned int s)
Calculates the zeroes of the derivative of the Airy function Ai.
double sph_neumann(unsigned n, double x)
Calculates the spherical Bessel functions of the second kind (also called irregular spherical Bessel ...
double airy_zero_Bi(unsigned int s)
Calculates the zeroes of the Airy function Bi.
double lambert_Wm1(double x)
Calculates the Lambert W function on branch -1.
double laguerre(unsigned n, double x)
Calculates the Laguerre polynomials.
double sph_bessel(unsigned n, double x)
Calculates the spherical Bessel functions of the first kind (also called regular spherical Bessel fun...
double wigner_6j(int two_ja, int two_jb, int two_jc, int two_jd, int two_je, int two_jf)
Calculates the Wigner 6j coupling coefficients.
double comp_ellint_2(double k)
Calculates the complete elliptic integral of the second kind.
double cyl_bessel_k(double nu, double x)
Calculates the modified Bessel functions of the second kind (also called irregular modified (cylindri...
double airy_Bi_deriv(double x)
Calculates the derivative of the Airy function Bi.
double cyl_bessel_i(double nu, double x)
Calculates the modified Bessel function of the first kind (also called regular modified (cylindrical)...
double cyl_bessel_j(double nu, double x)
Calculates the (cylindrical) Bessel functions of the first kind (also called regular (cylindrical) Be...
double airy_zero_Ai(unsigned int s)
Calculates the zeroes of the Airy function Ai.
double ellint_2(double k, double phi)
Calculates the complete elliptic integral of the second kind.
double assoc_legendre(unsigned l, unsigned m, double x)
Computes the associated Legendre polynomials.
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Namespace for new Math classes and functions.
double legendre(unsigned l, unsigned m, double x)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4