8 #if defined __cplusplus
29 if( Legendre == NULL )
return( NULL );
34 for( l = 0; l <= Legendre->
maxOrder; l++ ) Legendre->
Cls[l] = Cls[l];
43 if( maxOrder < 0 ) maxOrder = -1;
46 if( initialSize < ( maxOrder + 1 ) ) initialSize = maxOrder + 1;
85 Legendre->
Cls = (
double *)
nfu_realloc( size *
sizeof(
double ), Legendre->
Cls ); }
88 if( ( Legendre->
allocated > 2 * size ) || forceSmallerResize ) {
89 Legendre->
Cls = (
double *)
nfu_realloc( size *
sizeof(
double ), Legendre->
Cls ); }
94 if( Legendre->
Cls == NULL ) {
122 if( ( l < 0 ) || ( l > Legendre->
maxOrder ) ) {
126 return( Legendre->
Cls[l] );
140 Legendre->
Cls[l] = Cl;
153 for( l = 0; l <= Legendre->
maxOrder; l++ ) Legendre->
Cls[l] /= norm;
166 if( ( mu >= -1. ) && ( mu <= 1. ) ) {
178 double Pl_minus1, Pl, Pl_plus1;
209 for( l_ = 0, twoL_plus1 = 1; l_ < l; l_++, twoL_plus1 += 2 ) {
212 Pl_plus1 = ( twoL_plus1 * mu * Pl - l_ * Pl_minus1 ) / ( l_ + 1 );
223 void *argList = (
void *) Legendre;
229 if( n > 249 ) n = 249;
232 for( i = 1; i <
n; i++ ) xs[i] = xs[i-1] + dx;
254 double mu1, mu2,
f1,
f2, Cl, Cls[1] = { 0 }, integral;
271 if( ( Legendre =
nf_Legendre_new( maxOrder + 1, -1, Cls, status ) ) == NULL )
return( NULL );
274 for( l = 0; l <= maxOrder; l++ ) {
277 for( i = 1, Cl = 0; i <
n; i++ ) {
304 *f = ( args->
f1 * ( args->
mu2 - mu ) + args->
f2 * ( mu - args->
mu1 ) ) / ( args->
mu2 - args->
mu1 );
309 #if defined __cplusplus
nf_Legendre * nf_Legendre_new(int initialSize, int maxOrder, double *Cls, nfu_status *status)
#define nf_Legendre_maxMaxOrder
nfu_status nf_Legendre_setCl(nf_Legendre *Legendre, int l, double Cl)
ptwXYPoints * ptwXY_createFromFunction(int n, double *xs, ptwXY_createFromFunction_callback func, void *argList, double accuracy, int checkForRoots, int biSectionMax, nfu_status *status)
static nfu_status nf_Legendre_from_ptwXY_callback(double mu, double *f, void *argList)
int64_t ptwXY_length(ptwXYPoints *ptwXY)
nfu_status nf_Legendre_release(nf_Legendre *nfL)
nfu_status nf_Legendre_reallocateCls(nf_Legendre *Legendre, int size, int forceSmallerResize)
#define nf_Legendre_sizeIncrement
nf_Legendre * nf_Legendre_clone(nf_Legendre *nfL, nfu_status *status)
nfu_status nf_Legendre_setup(nf_Legendre *nfL, int initialSize, int maxOrder)
int nf_Legendre_maxOrder(nf_Legendre *Legendre)
double nf_Legendre_PofL_atMu(int l, double mu)
nfu_status nf_Legendre_normalize(nf_Legendre *Legendre)
ptwXYPoints * nf_Legendre_to_ptwXY(nf_Legendre *nfL, double accuracy, int biSectionMax, int checkForRoots, nfu_status *status)
nf_Legendre * nf_Legendre_free(nf_Legendre *nfL)
enum nfu_status_e nfu_status
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
static nfu_status nf_Legendre_to_ptwXY2(double mu, double *P, void *argList)
nfu_status ptwXY_getXYPairAtIndex(ptwXYPoints *ptwXY, int64_t index, double *x, double *y)
double nf_Legendre_getCl(nf_Legendre *Legendre, int l, nfu_status *status)
nfu_status nf_Legendre_GaussianQuadrature(int degree, double x1, double x2, nf_Legendre_GaussianQuadrature_callback func, void *argList, double *integral)
void * nfu_realloc(size_t size, void *old)
double nf_Legendre_evauluateAtMu(nf_Legendre *nfL, double mu, nfu_status *status)
void * nfu_malloc(size_t size)
#define nf_Legendre_minMaxOrder
nfu_status ptwXY_getStatus(ptwXYPoints *ptwXY)
nf_Legendre * nf_Legendre_from_ptwXY(ptwXYPoints *ptwXY, int maxOrder, nfu_status *status)
int nf_Legendre_allocated(nf_Legendre *Legendre)