CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
Main Page
Namespaces
Classes
Files
File List
File Members
GenericFunctions
src
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
8
namespace
Genfun {
9
FUNCTION_OBJECT_IMP
(HermitePolynomial)
10
11
HermitePolynomial
::
HermitePolynomial
(
unsigned
int
N)
12
:_N(N)
13
{}
14
15
HermitePolynomial::~HermitePolynomial
() {
16
}
17
18
HermitePolynomial::HermitePolynomial
(
const
HermitePolynomial
& right)
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
Generated on Mon May 6 2013 04:04:10 for CLHEP by
1.8.1.2