/usr/include/CLHEP/GenericFunctions/LegendreExpansion.icc is in libclhep-dev 2.1.4.1+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | // -*- C++ -*-
// $Id:
#include <sstream>
#include <cmath>
#include <gsl/gsl_sf_legendre.h>
#include <complex>
#include <cstdlib>
#include <stdexcept>
namespace Genfun {
FUNCTION_OBJECT_IMP(LegendreExpansion)
class LegendreExpansion::Clockwork {
public:
Clockwork(LegendreExpansion::Type type, const LegendreCoefficientSet & coefficients):type(type),coefficients(coefficients){}
LegendreExpansion::Type type;
LegendreCoefficientSet coefficients;
};
inline
LegendreExpansion::LegendreExpansion(Type type, const LegendreCoefficientSet & coefficients):
c(new Clockwork(type,coefficients))
{
}
inline
LegendreExpansion::~LegendreExpansion() {
delete c;
}
inline
LegendreExpansion::LegendreExpansion(const LegendreExpansion & right):
AbsFunction(),
c(new Clockwork(right.c->type,right.c->coefficients))
{
}
inline
double LegendreExpansion::operator() (double x) const {
int N=c->coefficients.getLMax();
std::vector<double> Pk(N+1);
gsl_sf_legendre_Pl_array(N, x, &Pk[0]);
unsigned int n=N;
std::complex<double> P=0.0;
std::complex<double> I(0,1.0);
while (1) {
if (n==0) {
P+=c->coefficients(n)*Pk[n];
break;
}
else {
P+=c->coefficients(n)*Pk[n];
n--;
}
}
double retVal=0;
if (c->type==MAGSQ) return norm(P);
if (c->type==MAG) return abs(P);
if (c->type==REAL) return real(P);
if (c->type==IMAG) return imag(P);
if (!finite(retVal)) {
throw std::runtime_error("Non-finite return value in LegendreExpansion");
}
return retVal;
}
inline
const LegendreCoefficientSet & LegendreExpansion::coefficientSet() const {
return c->coefficients;
}
} // end namespace Genfun
|