CLHEP 2.0.4.7 Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // $Id: AssociatedLaguerre.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $ 00003 #include "CLHEP/GenericFunctions/AssociatedLaguerre.hh" 00004 #include "CLHEP/GenericFunctions/Variable.hh" 00005 #include "CLHEP/GenericFunctions/FixedConstant.hh" 00006 00007 namespace Genfun { 00008 FUNCTION_OBJECT_IMP(AssociatedLaguerre) 00009 00010 // This is the product n (n-2) (n-4)... 00011 inline double factorial (int n) { 00012 if (n<=1) return 1.0; 00013 else return n*factorial(n-1); 00014 } 00015 00016 AssociatedLaguerre::AssociatedLaguerre(unsigned int n, unsigned int k): 00017 _n(n), 00018 _k(k) 00019 { 00020 create(); 00021 } 00022 00023 AssociatedLaguerre::~AssociatedLaguerre() { 00024 delete _function; 00025 } 00026 00027 AssociatedLaguerre::AssociatedLaguerre(const AssociatedLaguerre & right): 00028 _n(right._n), 00029 _k(right._k) 00030 { 00031 create(); 00032 } 00033 00034 double AssociatedLaguerre::operator() (double x) const { 00035 return (*_function)(x); 00036 } 00037 00038 unsigned int AssociatedLaguerre::n() const { 00039 return _n; 00040 } 00041 00042 unsigned int AssociatedLaguerre::k() const { 00043 return _k; 00044 } 00045 00046 00047 void AssociatedLaguerre::create() { 00048 Variable x; 00049 if (_n==0) { 00050 _function = FixedConstant(1.0).clone(); 00051 } 00052 else if (_n==1) { 00053 _function = (-x + _k + 1).clone(); 00054 } 00055 else { 00056 _function = ((1.0/_n)*((2*_n -1 +_k -x)*AssociatedLaguerre(_n-1,_k) 00057 - (_n+_k-1)*AssociatedLaguerre(_n-2,_k))).clone(); 00058 } 00059 } 00060 } // namespace Genfun