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

AssociatedLaguerre.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: AssociatedLaguerre.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
6 
7 namespace Genfun {
8 FUNCTION_OBJECT_IMP(AssociatedLaguerre)
9 
10 // This is the product n (n-2) (n-4)...
11 inline double factorial (int n) {
12  if (n<=1) return 1.0;
13  else return n*factorial(n-1);
14 }
15 
16 AssociatedLaguerre::AssociatedLaguerre(unsigned int xn, unsigned int xk):
17  _n(xn),
18  _k(xk)
19 {
20  create();
21 }
22 
24  delete _function;
25 }
26 
28 AbsFunction(right),
29 _n(right._n),
30 _k(right._k)
31 {
32  create();
33 }
34 
35 double AssociatedLaguerre::operator() (double x) const {
36  return (*_function)(x);
37 }
38 
39 unsigned int AssociatedLaguerre::n() const {
40  return _n;
41 }
42 
43 unsigned int AssociatedLaguerre::k() const {
44  return _k;
45 }
46 
47 
48 void AssociatedLaguerre::create() {
49  Variable x;
50  if (_n==0) {
51  _function = FixedConstant(1.0).clone();
52  }
53  else if (_n==1) {
54  _function = (-x + _k + 1).clone();
55  }
56  else {
57  _function = ((1.0/_n)*((2*_n -1 +_k -x)*AssociatedLaguerre(_n-1,_k)
58  - (_n+_k-1)*AssociatedLaguerre(_n-2,_k))).clone();
59  }
60 }
61 } // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
virtual AbsFunction * clone() const =0
virtual double operator()(double argument) const
AssociatedLaguerre(unsigned int n, unsigned int k)
double factorial(int n)