CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
HermitePolynomial.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id:
3#include "CLHEP/GenericFunctions/HermitePolynomial.hh"
4#include "CLHEP/GenericFunctions/FixedConstant.hh"
5#include <assert.h>
6#include <cmath>
7
8namespace Genfun {
9FUNCTION_OBJECT_IMP(HermitePolynomial)
10
12:_N(N)
13{}
14
16}
17
19 :AbsFunction(), _N(right._N)
20{ }
21
22
23double HermitePolynomial::operator() (double x) const {
24 const static double h00=0.0;
25 const static double h0=sqrt(M_PI/4.0);
26 double p0=h00;
27 double p1=h00;
28 double pn=h0;
29 for (unsigned int i=1;i<=_N;i++) {
30 p0=p1;
31 p1=pn;
32 pn=x*sqrt(2.0/i)*p1-sqrt((i-1.0)/i)*p0;
33 }
34 return pn;
35}
36
37unsigned int HermitePolynomial::N() const {
38 return _N;
39}
40
41Derivative HermitePolynomial::partial(unsigned int index) const {
42 assert(index==0);
43 if (_N>0) {
44 const AbsFunction & fPrime = sqrt(2.0*_N)*HermitePolynomial(_N-1);
45 return Derivative(& fPrime);
46 }
47 else {
48 const AbsFunction & fPrime = FixedConstant(0.0);
49 return Derivative(& fPrime);
50 }
51}
52
53} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
Definition: AbsFunction.hh:149
virtual double operator()(double argument) const override
unsigned int N() const
Derivative partial(unsigned int) const override
HermitePolynomial(unsigned int N)
Definition: Abs.hh:14
FunctionNoop Derivative
Definition: AbsFunction.hh:42