CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

AssociatedLaguerre.cc

Go to the documentation of this file.
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 xn, unsigned int xk):
00017   _n(xn),
00018   _k(xk)
00019 {
00020   create();
00021 }
00022 
00023 AssociatedLaguerre::~AssociatedLaguerre() {
00024   delete _function;
00025 }
00026 
00027 AssociatedLaguerre::AssociatedLaguerre(const AssociatedLaguerre & right):
00028 AbsFunction(right),
00029 _n(right._n),
00030 _k(right._k)
00031 {
00032   create();
00033 }
00034 
00035 double AssociatedLaguerre::operator() (double x) const {
00036   return (*_function)(x);
00037 }
00038 
00039 unsigned int AssociatedLaguerre::n() const {
00040   return _n;
00041 }
00042 
00043 unsigned int AssociatedLaguerre::k() const {
00044   return _k;
00045 }
00046 
00047 
00048 void AssociatedLaguerre::create() {
00049   Variable     x;
00050   if (_n==0) {
00051     _function = FixedConstant(1.0).clone();
00052   }
00053   else if (_n==1) {
00054     _function = (-x + _k + 1).clone();
00055   }
00056   else {
00057     _function = ((1.0/_n)*((2*_n -1 +_k -x)*AssociatedLaguerre(_n-1,_k)
00058                          -  (_n+_k-1)*AssociatedLaguerre(_n-2,_k))).clone();
00059   }
00060 }
00061 } // namespace Genfun

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7