5 #include <gsl/gsl_sf_legendre.h> 11 FUNCTION_OBJECT_IMP(LegendreExpansion)
17 Clockwork(LegendreExpansion::Type type,
const LegendreCoefficientSet & coefficients):type(type),coefficients(coefficients){}
19 LegendreExpansion::Type
type;
26 LegendreExpansion::LegendreExpansion(Type type,
const LegendreCoefficientSet & coefficients):
34 LegendreExpansion::~LegendreExpansion() {
39 LegendreExpansion::LegendreExpansion(
const LegendreExpansion & right):
41 c(new Clockwork(right.c->type,right.c->coefficients))
46 double LegendreExpansion::operator() (
double x)
const {
48 int N=c->coefficients.getLMax();
49 std::vector<double> Pk(N+1);
50 gsl_sf_legendre_Pl_array(N, x, &Pk[0]);
52 std::complex<double> P=0.0;
53 std::complex<double> I(0,1.0);
56 P+=c->coefficients(n)*Pk[n];
60 P+=c->coefficients(n)*Pk[n];
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");
77 const LegendreCoefficientSet & LegendreExpansion::coefficientSet()
const {
78 return c->coefficients;
LegendreExpansion::Type type
Clockwork(LegendreExpansion::Type type, const LegendreCoefficientSet &coefficients)
LegendreCoefficientSet coefficients