CLHEP 2.4.7.1
C++ Class Library for High Energy Physics
LegendreExpansion.icc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id:
3#include <sstream>
4#include <cmath>
5#include <gsl/gsl_sf_legendre.h>
6#include <complex>
7#include <cstdlib>
8#include <stdexcept>
9namespace Genfun {
10
12
23
24
25 inline
27 c(new Clockwork(type,coefficients))
28 {
29
30 }
31
32
33 inline
37
38 inline
41 c(new Clockwork(right.c->type,right.c->coefficients))
42 {
43 }
44
45 inline
46 double LegendreExpansion::operator() (double x) const {
47
48 int N=c->coefficients.getLMax();
49 std::vector<double> Pk(N+1);
50 gsl_sf_legendre_Pl_array(N, x, &Pk[0]);
51 unsigned int n=N;
52 std::complex<double> P=0.0;
53 std::complex<double> I(0,1.0);
54 while (1) {
55 if (n==0) {
56 P+=c->coefficients(n)*Pk[n];
57 break;
58 }
59 else {
60 P+=c->coefficients(n)*Pk[n];
61 n--;
62 }
63 }
64
65 double retVal=0;
66 if (c->type==MAGSQ) return norm(P);
67 if (c->type==MAG) return abs(P);
68 if (c->type==REAL) return real(P);
69 if (c->type==IMAG) return imag(P);
70 if (!finite(retVal)) {
71 throw std::runtime_error("Non-finite return value in LegendreExpansion");
72 }
73 return retVal;
74 }
75
76 inline
78 return c->coefficients;
79 }
80
81} // end namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
Clockwork(LegendreExpansion::Type type, const LegendreCoefficientSet &coefficients)
LegendreExpansion(Type type, const LegendreCoefficientSet &coefficients)
const LegendreCoefficientSet & coefficientSet() const
virtual double operator()(double argument) const override
Definition Abs.hh:14