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 n, unsigned int k):
17  _n(n),
18  _k(k)
19 {
20  create();
21 }
22 
24  delete _function;
25 }
26 
28 _n(right._n),
29 _k(right._k)
30 {
31  create();
32 }
33 
34 double AssociatedLaguerre::operator() (double x) const {
35  return (*_function)(x);
36 }
37 
38 unsigned int AssociatedLaguerre::n() const {
39  return _n;
40 }
41 
42 unsigned int AssociatedLaguerre::k() const {
43  return _k;
44 }
45 
46 
47 void AssociatedLaguerre::create() {
48  Variable x;
49  if (_n==0) {
50  _function = FixedConstant(1.0).clone();
51  }
52  else if (_n==1) {
53  _function = (-x + _k + 1).clone();
54  }
55  else {
56  _function = ((1.0/_n)*((2*_n -1 +_k -x)*AssociatedLaguerre(_n-1,_k)
57  - (_n+_k-1)*AssociatedLaguerre(_n-2,_k))).clone();
58  }
59 }
60 } // namespace Genfun