1// -*- C++ -*- 2// $Id: 3#include "CLHEP/GenericFunctions/Variable.hh" 4#include "CLHEP/GenericFunctions/Power.hh" 5#include <gsl/gsl_sf_legendre.h> 6#include <cmath> 7#include <signal.h> 8#include <assert.h> 9 10 11namespace Genfun { 12 13FUNCTION_OBJECT_IMP(AssociatedLegendre) 14 15// This is the product n (n-2) (n-4)... 16inline double dfactorial (int n) { 17 if (n<=1) return 1.0; 18 else return n*dfactorial(n-2); 19} 20// 21inline 22AssociatedLegendre::AssociatedLegendre(unsigned int l, unsigned int m): 23 AbsFunction(), 24 _l(l), 25 _m(m) 26{ 27 assert(m<=l); 28} 29 30inline 31AssociatedLegendre::~AssociatedLegendre() { 32} 33 34inline 35AssociatedLegendre::AssociatedLegendre(const AssociatedLegendre & right): 36AbsFunction(), 37_l(right._l), 38_m(right._m) 39{ 40} 41 42inline 43unsigned int AssociatedLegendre::l() const { 44 return _l; 45} 46 47inline 48unsigned int AssociatedLegendre::m() const { 49 return _m; 50} 51 52 53inline 54double AssociatedLegendre::operator() (double x) const { 55 gsl_sf_result result; 56 int status = gsl_sf_legendre_Plm_e (_l, _m, x, &result); 57 58 if (status!=0) { 59 std::cerr << "Warning, GSL function gsl_sf_bessel_Yn_impl" 60 << " return code" << status << std::endl; 61 raise(SIGFPE); 62 } 63 return result.val; 64} 65 66} // end namespace Genfun 67