SpecFuncMathMore.cxx

Go to the documentation of this file.
00001 // @(#)root/mathmore:$Id: SpecFuncMathMore.cxx 37160 2010-12-01 21:52:04Z moneta $
00002 // Authors: L. Moneta, A. Zsenei   08/2005 
00003 
00004 // Authors: Andras Zsenei & Lorenzo Moneta   06/2005 
00005 
00006 /**********************************************************************
00007  *                                                                    *
00008  * Copyright (c) 2005 , LCG ROOT MathLib Team                         *
00009  *                                                                    *
00010  *                                                                    *
00011  **********************************************************************/
00012 
00013 #include <cmath>
00014 
00015 #ifndef PI
00016 #define PI       3.14159265358979323846264338328      /* pi */
00017 #endif
00018 
00019 
00020 #include "gsl/gsl_sf_bessel.h"
00021 #include "gsl/gsl_sf_legendre.h"
00022 #include "gsl/gsl_sf_laguerre.h"
00023 #include "gsl/gsl_sf_hyperg.h"
00024 #include "gsl/gsl_sf_ellint.h"
00025 //#include "gsl/gsl_sf_gamma.h"
00026 #include "gsl/gsl_sf_expint.h"
00027 #include "gsl/gsl_sf_zeta.h"
00028 #include "gsl/gsl_sf_airy.h"
00029 #include "gsl/gsl_sf_coupling.h"
00030 
00031 
00032 namespace ROOT {
00033 namespace Math {
00034 
00035 
00036 
00037 
00038 // [5.2.1.1] associated Laguerre polynomials
00039 // (26.x.12)
00040 
00041 double assoc_laguerre(unsigned n, double m, double x) {
00042    
00043    return gsl_sf_laguerre_n(n, m, x);
00044    
00045 }
00046 
00047 
00048 
00049 // [5.2.1.2] associated Legendre functions
00050 // (26.x.8)
00051 
00052 double assoc_legendre(unsigned l, unsigned m, double x) {
00053    // add  (-1)^m
00054    return (m%2 == 0) ? gsl_sf_legendre_Plm(l, m, x) : -gsl_sf_legendre_Plm(l, m, x);
00055    
00056 }
00057 
00058 
00059 
00060 
00061 
00062 // [5.2.1.4] (complete) elliptic integral of the first kind
00063 // (26.x.15.2) 
00064 
00065 double comp_ellint_1(double k) {
00066    
00067    return gsl_sf_ellint_Kcomp(k, GSL_PREC_DOUBLE);
00068    
00069 }
00070 
00071 
00072 
00073 // [5.2.1.5] (complete) elliptic integral of the second kind
00074 // (26.x.16.2)
00075 
00076 double comp_ellint_2(double k) {
00077    
00078    return gsl_sf_ellint_Ecomp(k, GSL_PREC_DOUBLE);
00079    
00080 }
00081 
00082 
00083 
00084 // [5.2.1.6] (complete) elliptic integral of the third kind
00085 // (26.x.17.2)
00086 /**
00087 
00088 There are two different definitions used for the elliptic
00089 integral of the third kind:
00090 
00091 P(\phi,k,n) = \int_0^\phi dt 1/((1 + nu \sin^2(t))\sqrt(1 - k^2 \sin^2(t)))
00092 
00093 and
00094 
00095 P(\phi,k,n) = \int_0^\phi dt 1/((1 - nu \sin^2(t))\sqrt(1 - k^2 \sin^2(t)))
00096 
00097 the former is adopted by
00098 
00099 - GSL 
00100      http://www.gnu.org/software/gsl/manual/gsl-ref_7.html#SEC95
00101 
00102 - Planetmath
00103      http://planetmath.org/encyclopedia/EllipticIntegralsAndJacobiEllipticFunctions.html
00104 
00105 - CERNLIB
00106      http://wwwasdoc.web.cern.ch/wwwasdoc/shortwrupsdir/c346/top.html
00107 
00108    while the latter is used by
00109 
00110 - Abramowitz and Stegun
00111 
00112 - Mathematica
00113      http://mathworld.wolfram.com/EllipticIntegraloftheThirdKind.html
00114 
00115 - C++ standard
00116      http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1687.pdf
00117 
00118    in order to be C++ compliant, we decided to use the latter, hence the 
00119    change of the sign in the function call to GSL.
00120 
00121    */
00122 
00123 double comp_ellint_3(double n, double k) {
00124    
00125    return gsl_sf_ellint_P(PI/2.0, k, -n, GSL_PREC_DOUBLE);
00126    
00127 }
00128 
00129 
00130 
00131 // [5.2.1.7] confluent hypergeometric functions
00132 // (26.x.14)
00133 
00134 double conf_hyperg(double a, double b, double z) {
00135    
00136    return gsl_sf_hyperg_1F1(a, b, z);
00137    
00138 }
00139 
00140 //  confluent hypergeometric functions of second type
00141 
00142 double conf_hypergU(double a, double b, double z) {
00143    
00144    return gsl_sf_hyperg_U(a, b, z);
00145    
00146 }
00147 
00148 
00149 
00150 // [5.2.1.8] regular modified cylindrical Bessel functions
00151 // (26.x.4.1)
00152 
00153 double cyl_bessel_i(double nu, double x) {
00154    
00155    return gsl_sf_bessel_Inu(nu, x);
00156    
00157 }
00158 
00159 
00160 
00161 // [5.2.1.9] cylindrical Bessel functions (of the first kind)
00162 // (26.x.2)
00163 
00164 double cyl_bessel_j(double nu, double x) {
00165    
00166    return gsl_sf_bessel_Jnu(nu, x);
00167    
00168 }
00169 
00170 
00171 
00172 // [5.2.1.10] irregular modified cylindrical Bessel functions
00173 // (26.x.4.2)
00174 
00175 double cyl_bessel_k(double nu, double x) {
00176    
00177    return gsl_sf_bessel_Knu(nu, x);
00178    
00179 }
00180 
00181 
00182 
00183 // [5.2.1.11] cylindrical Neumann functions;
00184 // cylindrical Bessel functions (of the second kind)
00185 // (26.x.3)
00186 
00187 double cyl_neumann(double nu, double x) {
00188    
00189    return gsl_sf_bessel_Ynu(nu, x);
00190    
00191 }
00192 
00193 
00194 
00195 // [5.2.1.12] (incomplete) elliptic integral of the first kind
00196 // phi in radians
00197 // (26.x.15.1) 
00198 
00199 double ellint_1(double k, double phi) {
00200    
00201    return gsl_sf_ellint_F(phi, k, GSL_PREC_DOUBLE);
00202    
00203 }
00204 
00205 
00206 
00207 // [5.2.1.13] (incomplete) elliptic integral of the second kind
00208 // phi in radians
00209 // (26.x.16.1)
00210 
00211 double ellint_2(double k, double phi) {
00212    
00213    return gsl_sf_ellint_E(phi, k, GSL_PREC_DOUBLE);
00214    
00215 }
00216 
00217 
00218 
00219 // [5.2.1.14] (incomplete) elliptic integral of the third kind
00220 // phi in radians
00221 // (26.x.17.1)
00222 /**
00223 
00224 There are two different definitions used for the elliptic
00225 integral of the third kind:
00226 
00227 P(\phi,k,n) = \int_0^\phi dt 1/((1 + nu \sin^2(t))\sqrt(1 - k^2 \sin^2(t)))
00228 
00229 and
00230 
00231 P(\phi,k,n) = \int_0^\phi dt 1/((1 - nu \sin^2(t))\sqrt(1 - k^2 \sin^2(t)))
00232 
00233 the former is adopted by
00234 
00235 - GSL 
00236      http://www.gnu.org/software/gsl/manual/gsl-ref_7.html#SEC95
00237 
00238 - Planetmath
00239      http://planetmath.org/encyclopedia/EllipticIntegralsAndJacobiEllipticFunctions.html
00240 
00241 - CERNLIB
00242      http://wwwasdoc.web.cern.ch/wwwasdoc/shortwrupsdir/c346/top.html
00243 
00244    while the latter is used by
00245 
00246 - Abramowitz and Stegun
00247 
00248 - Mathematica
00249      http://mathworld.wolfram.com/EllipticIntegraloftheThirdKind.html
00250 
00251 - C++ standard
00252      http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1687.pdf
00253 
00254    in order to be C++ compliant, we decided to use the latter, hence the 
00255    change of the sign in the function call to GSL.
00256 
00257    */
00258 
00259 double ellint_3(double n, double k, double phi) {
00260    
00261    return gsl_sf_ellint_P(phi, k, -n, GSL_PREC_DOUBLE);
00262    
00263 }
00264 
00265 
00266 
00267 // [5.2.1.15] exponential integral
00268 // (26.x.20)
00269 
00270 double expint(double x) {
00271    
00272    return gsl_sf_expint_Ei(x);
00273    
00274 }
00275 
00276 
00277 
00278 // [5.2.1.16] Hermite polynomials
00279 // (26.x.10)
00280 
00281 //double hermite(unsigned n, double x) {
00282 //}
00283 
00284 
00285 
00286 
00287 // [5.2.1.17] hypergeometric functions
00288 // (26.x.13) 
00289 
00290 double hyperg(double a, double b, double c, double x) {
00291    
00292    return gsl_sf_hyperg_2F1(a, b, c, x);
00293    
00294 }
00295 
00296 
00297 
00298 // [5.2.1.18] Laguerre polynomials
00299 // (26.x.11)
00300 
00301 double laguerre(unsigned n, double x) {
00302    return gsl_sf_laguerre_n(n, 0, x);
00303 }
00304 
00305 
00306 
00307 
00308 // [5.2.1.19] Legendre polynomials
00309 // (26.x.7)
00310 
00311 double legendre(unsigned l, double x) {
00312    
00313    return gsl_sf_legendre_Pl(l, x);
00314    
00315 }
00316 
00317 
00318 
00319 // [5.2.1.20] Riemann zeta function
00320 // (26.x.22)
00321 
00322 double riemann_zeta(double x) {
00323    
00324    return gsl_sf_zeta(x);
00325    
00326 }
00327 
00328 
00329 
00330 // [5.2.1.21] spherical Bessel functions of the first kind
00331 // (26.x.5)
00332 
00333 double sph_bessel(unsigned n, double x) {
00334    
00335    return gsl_sf_bessel_jl(n, x);
00336    
00337 }
00338 
00339 
00340 
00341 // [5.2.1.22] spherical associated Legendre functions
00342 // (26.x.9) ??????????
00343 
00344 double sph_legendre(unsigned l, unsigned m, double theta) {
00345 
00346    return gsl_sf_legendre_sphPlm(l, m, std::cos(theta));
00347 
00348 }
00349 
00350 
00351 
00352 
00353 // [5.2.1.23] spherical Neumann functions
00354 // (26.x.6)
00355 
00356 double sph_neumann(unsigned n, double x) {
00357    
00358    return gsl_sf_bessel_yl(n, x);
00359    
00360 } 
00361 
00362 // Airy function Ai
00363 
00364 double airy_Ai(double x) {
00365    
00366    return gsl_sf_airy_Ai(x, GSL_PREC_DOUBLE);
00367    
00368 } 
00369 
00370 // Airy function Bi
00371 
00372 double airy_Bi(double x) {
00373    
00374    return gsl_sf_airy_Bi(x, GSL_PREC_DOUBLE);
00375    
00376 }
00377 
00378 // Derivative of the Airy function Ai
00379 
00380 double airy_Ai_deriv(double x) {
00381    
00382    return gsl_sf_airy_Ai_deriv(x, GSL_PREC_DOUBLE);
00383    
00384 }
00385 
00386 // Derivative of the Airy function Bi
00387 
00388 double airy_Bi_deriv(double x) {
00389    
00390    return gsl_sf_airy_Bi_deriv(x, GSL_PREC_DOUBLE);
00391    
00392 }
00393 
00394 // s-th zero of the Airy function Ai
00395 
00396 double airy_zero_Ai(unsigned int s) {
00397    
00398    return gsl_sf_airy_zero_Ai(s);
00399    
00400 }
00401 
00402 // s-th zero of the Airy function Bi
00403 
00404 double airy_zero_Bi(unsigned int s) {
00405    
00406    return gsl_sf_airy_zero_Bi(s);
00407    
00408 }
00409 
00410 // s-th zero of the derivative of the Airy function Ai
00411 
00412 double airy_zero_Ai_deriv(unsigned int s) {
00413    
00414    return gsl_sf_airy_zero_Ai_deriv(s);
00415    
00416 }
00417 
00418 // s-th zero of the derivative of the Airy function Bi
00419 
00420 double airy_zero_Bi_deriv(unsigned int s) {
00421    
00422    return gsl_sf_airy_zero_Bi_deriv(s);
00423    
00424 }
00425 
00426 // wigner coefficient 
00427 
00428 double wigner_3j(int ja, int jb, int jc, int ma, int mb, int mc) {
00429    return gsl_sf_coupling_3j(ja,jb,jc,ma,mb,mc);
00430 }
00431 
00432 double wigner_6j(int ja, int jb, int jc, int jd, int je, int jf) { 
00433    return gsl_sf_coupling_6j(ja,jb,jc,jd,je,jf);
00434 }
00435 
00436 double wigner_9j(int ja, int jb, int jc, int jd, int je, int jf, int jg, int jh, int ji) { 
00437    return gsl_sf_coupling_9j(ja,jb,jc,jd,je,jf,jg,jh,ji);
00438 }
00439 
00440 } // namespace Math
00441 } // namespace ROOT

Generated on Tue Jul 5 14:34:57 2011 for ROOT_528-00b_version by  doxygen 1.5.1