Commit a180a3a7 authored by Joseph Boudreau's avatar Joseph Boudreau
Browse files

added *normalized* hermite polynomials

parent 925ec4b4
// -*- C++ -*-
// $Id:
//---------------------Hermite----------------------------------------------//
// //
// Class HermitePolynomial. (Hermite polynomials) //
// Joe Boudreau, October 2012 //
// //
//--------------------------------------------------------------------------//
#ifndef HermitePolynomial_h_
#define HermitePolynomial_h_ 1
#include "CLHEP/GenericFunctions/AbsFunction.hh"
#include "CLHEP/GenericFunctions/Parameter.hh"
namespace Genfun {
/**
* @author
* @ingroup genfun
*/
class HermitePolynomial : public AbsFunction {
FUNCTION_OBJECT_DEF(HermitePolynomial)
public:
// Constructor
HermitePolynomial(unsigned int N);
// Copy constructor
HermitePolynomial(const HermitePolynomial &right);
// Destructor
virtual ~HermitePolynomial();
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
// Get the integer variable N
unsigned int N() const;
// Derivative.
Derivative partial (unsigned int) const;
// Does this function have an analytic derivative?
virtual bool hasAnalyticDerivative() const {return true;}
private:
// It is illegal to assign a Hermite Polynomial
const HermitePolynomial & operator=(const HermitePolynomial &right);
// Here is the sigma
unsigned int _N;
};
} // namespace Genfun
#endif
......@@ -79,6 +79,7 @@ pkginclude_HEADERS = \
Gamma.hh \
Gaussian.hh \
GenericFunctions.hh \
HermitePolynomial.hh \
IncompleteGamma.hh \
InterpolatingPolynomial.hh \
KroneckerDelta.hh \
......
// -*- C++ -*-
// $Id:
#include "CLHEP/GenericFunctions/HermitePolynomial.hh"
#include "CLHEP/GenericFunctions/FixedConstant.hh"
#include <assert.h>
#include <cmath>
namespace Genfun {
FUNCTION_OBJECT_IMP(HermitePolynomial)
HermitePolynomial::HermitePolynomial(unsigned int N)
:_N(N)
{}
HermitePolynomial::~HermitePolynomial() {
}
HermitePolynomial::HermitePolynomial(const HermitePolynomial & right)
:AbsFunction(), _N(right._N)
{ }
double HermitePolynomial::operator() (double x) const {
const static double h00=0.0;
const static double h0=sqrt(M_PI/4.0);
double p0=h00;
double p1=h00;
double pn=h0;
for (unsigned int i=1;i<=_N;i++) {
p0=p1;
p1=pn;
pn=x*sqrt(2.0/i)*p1-sqrt((i-1.0)/i)*p0;
}
return pn;
}
unsigned int HermitePolynomial::N() const {
return _N;
}
Derivative HermitePolynomial::partial(unsigned int index) const {
assert(index==0);
if (_N>0) {
const AbsFunction & fPrime = sqrt(2.0*_N)*HermitePolynomial(_N-1);
return Derivative(& fPrime);
}
else {
const AbsFunction & fPrime = FixedConstant(0.0);
return Derivative(& fPrime);
}
}
} // namespace Genfun
......@@ -55,6 +55,7 @@ libCLHEP_GenericFunctions_@VERSION@_a_SOURCES = \
Gamma.cc \
GammaDistribution.cc \
Gaussian.cc \
HermitePolynomial.cc \
IncompleteGamma.cc \
InterpolatingPolynomial.cc \
KroneckerDelta.cc \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment