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

HermitePolynomial.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id:
5 #include <assert.h>
6 #include <cmath>
7 
8 namespace Genfun {
9 FUNCTION_OBJECT_IMP(HermitePolynomial)
10 
12 :_N(N)
13 {}
14 
16 }
17 
19  :AbsFunction(), _N(right._N)
20 { }
21 
22 
23 double 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 
37 unsigned int HermitePolynomial::N() const {
38  return _N;
39 }
40 
41 Derivative 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)
unsigned int N() const
Derivative partial(unsigned int) const
HermitePolynomial(unsigned int N)
virtual double operator()(double argument) const
incomplete * p0