CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
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 $
3#include "CLHEP/GenericFunctions/AssociatedLaguerre.hh"
4#include "CLHEP/GenericFunctions/Variable.hh"
5#include "CLHEP/GenericFunctions/FixedConstant.hh"
6
7namespace Genfun {
8FUNCTION_OBJECT_IMP(AssociatedLaguerre)
9
10// This is the product n (n-2) (n-4)...
11inline double factorial (int n) {
12 if (n<=1) return 1.0;
13 else return n*factorial(n-1);
14}
15
16AssociatedLaguerre::AssociatedLaguerre(unsigned int xn, unsigned int xk):
17 _n(xn),
18 _k(xk)
19{
20 create();
21}
22
24 delete _function;
25}
26
28AbsFunction(right),
29_n(right._n),
30_k(right._k)
31{
32 create();
33}
34
35double AssociatedLaguerre::operator() (double x) const {
36 return (*_function)(x);
37}
38
39unsigned int AssociatedLaguerre::n() const {
40 return _n;
41}
42
43unsigned int AssociatedLaguerre::k() const {
44 return _k;
45}
46
47
48void 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)
Definition: AbsFunction.hh:149
virtual AbsFunction * clone() const =0
virtual double operator()(double argument) const override
AssociatedLaguerre(unsigned int n, unsigned int k)
Definition: Abs.hh:14
double factorial(int n)