CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // $Id: 00003 #include "CLHEP/GenericFunctions/HermitePolynomial.hh" 00004 #include "CLHEP/GenericFunctions/FixedConstant.hh" 00005 #include <assert.h> 00006 #include <cmath> 00007 00008 namespace Genfun { 00009 FUNCTION_OBJECT_IMP(HermitePolynomial) 00010 00011 HermitePolynomial::HermitePolynomial(unsigned int N) 00012 :_N(N) 00013 {} 00014 00015 HermitePolynomial::~HermitePolynomial() { 00016 } 00017 00018 HermitePolynomial::HermitePolynomial(const HermitePolynomial & right) 00019 :AbsFunction(), _N(right._N) 00020 { } 00021 00022 00023 double HermitePolynomial::operator() (double x) const { 00024 const static double h00=0.0; 00025 const static double h0=sqrt(M_PI/4.0); 00026 double p0=h00; 00027 double p1=h00; 00028 double pn=h0; 00029 for (unsigned int i=1;i<=_N;i++) { 00030 p0=p1; 00031 p1=pn; 00032 pn=x*sqrt(2.0/i)*p1-sqrt((i-1.0)/i)*p0; 00033 } 00034 return pn; 00035 } 00036 00037 unsigned int HermitePolynomial::N() const { 00038 return _N; 00039 } 00040 00041 Derivative HermitePolynomial::partial(unsigned int index) const { 00042 assert(index==0); 00043 if (_N>0) { 00044 const AbsFunction & fPrime = sqrt(2.0*_N)*HermitePolynomial(_N-1); 00045 return Derivative(& fPrime); 00046 } 00047 else { 00048 const AbsFunction & fPrime = FixedConstant(0.0); 00049 return Derivative(& fPrime); 00050 } 00051 } 00052 00053 } // namespace Genfun