1 #include <lal/LALSimIMR.h>
2 #include <lal/LALSimInspiral.h>
4 #include <lal/TimeSeries.h>
6 #include <lal/LALAdaptiveRungeKuttaIntegrator.h>
7 #include <lal/SphericalHarmonics.h>
8 #include <lal/LALSimSphHarmMode.h>
10 #include <lal/LALDict.h>
12 #include <gsl/gsl_sf_gamma.h>
13 #include <gsl/gsl_matrix.h>
14 #include <gsl/gsl_poly.h>
15 #include <gsl/gsl_spline.h>
16 #include <gsl/gsl_roots.h>
17 #include <gsl/gsl_deriv.h>
35 REAL8 fourthOrderCoeffs[5][5] = {
36 {-25./12., 4., -3., 4./3., -1./4.},
37 {-1./4., -5./6., 3./2., -1./2., 1./12.},
38 {1./12., -2./3., 0, 2./3., -1./12.},
39 {-1./12., 1./2., -3./2., 5./6., 1./4.},
40 {1./4., -4./3., 3., -4., 25./12.}
47 h = fabs(XVec->
data[0] - XVec->
data[1]);
52 for (
i = 0;
i <= vecLength-1;
i++)
56 for (j = 0; j <= 4; j++)
58 derivativeVec->
data[
i] += (
59 fourthOrderCoeffs[0][j] * YVec->
data[j]
65 for (j = 0; j <= 4; j++)
67 derivativeVec->
data[
i] += (
68 fourthOrderCoeffs[1][j] * YVec->
data[j]
72 else if (
i == vecLength-2)
74 for (j = 0; j <= 4; j++)
76 derivativeVec->
data[
i] += (
77 fourthOrderCoeffs[3][j] * YVec->
data[
i+j-3]
81 else if (
i == vecLength-1)
83 for (j = 0; j <= 4; j++)
85 derivativeVec->
data[
i] += (
86 fourthOrderCoeffs[4][j] * YVec->
data[
i+j-4]
92 for (j = 0; j <= 4; j++)
94 derivativeVec->
data[
i] += (
95 fourthOrderCoeffs[2][j] * YVec->
data[
i+j-2]
100 derivativeVec->
data[
i] /= h;
120 REAL8 secondOrderCoeffs[3][3] = {
131 h = fabs(XVec->
data[0] - XVec->
data[1]);
136 for (
i = 0;
i <= vecLength-1;
i++)
140 for (j = 0; j <= 2; j++)
142 derivativeVec->
data[
i] += (
143 secondOrderCoeffs[0][j] * YVec->
data[j]
147 else if (
i == vecLength-1)
149 for (j = 0; j <= 2; j++)
151 derivativeVec->
data[
i] += (
152 secondOrderCoeffs[2][j] * YVec->
data[
i+j-2]
158 for (j = 0; j <= 2; j++)
160 derivativeVec->
data[
i] += (
161 secondOrderCoeffs[1][j] * YVec->
data[
i+j-1]
166 derivativeVec->
data[
i] /= h;
186 REAL8 sixthOrderCoeffs[7][7] = {
187 {-49./20., 6., -15./2., 20./3., -15./4., 6./5., -1./6.},
188 {-1./6., -77./60., 5./2., -5./3., 5./6., -1./4., 1./30.},
189 {1./30., -2./5., -7./12., 4./3., -1./2., 2./15., -1./60.},
190 {-1./60., 3./20., -3./4., 0, 3./4., -3./20., 1./60.},
191 {1./60., -2./15., 1./2., -4./3., 7./12., 2./5., -1./30.},
192 {-1./30., 1./4., -5./6., 5./3., -5./2., 77./60., 1./6.},
193 {1./6., -6./5., 15./4., -20./3., 15./2., -6., 49./20.}
201 h = fabs(XVec->
data[0] - XVec->
data[1]);
206 for (
i = 0;
i <= vecLength-1;
i++)
210 for (j = 0; j <= 6; j++)
212 derivativeVec->
data[
i] += (
213 sixthOrderCoeffs[0][j] * YVec->
data[j]
219 for (j = 0; j <= 6; j++)
221 derivativeVec->
data[
i] += (
222 sixthOrderCoeffs[1][j] * YVec->
data[j]
228 for (j = 0; j <= 6; j++)
230 derivativeVec->
data[
i] += (
231 sixthOrderCoeffs[2][j] * YVec->
data[j]
235 else if (
i == vecLength-3)
237 for (j = 0; j <= 6; j++)
239 derivativeVec->
data[
i] += (
240 sixthOrderCoeffs[4][j] * YVec->
data[
i+j-4]
244 else if (
i == vecLength-2)
246 for (j = 0; j <= 6; j++)
248 derivativeVec->
data[
i] += (
249 sixthOrderCoeffs[5][j] * YVec->
data[
i+j-5]
253 else if (
i == vecLength-1)
255 for (j = 0; j <= 6; j++)
257 derivativeVec->
data[
i] += (
258 sixthOrderCoeffs[6][j] * YVec->
data[
i+j-6]
264 for (j = 0; j <= 6; j++)
266 derivativeVec->
data[
i] += (
267 sixthOrderCoeffs[3][j] * YVec->
data[
i+j-3]
272 derivativeVec->
data[
i] /= h;
292 REAL8 eightOrderCoeffs[9][9] = {
293 {-761./280., 8., -14., 56./3., -35./2., 56./5., -14./3., 8./7., -1./8.},
294 {-1./8., -223./140., 7./2., -7./2., 35./12., -7./4., 7./10., -1./6., 1./56.},
295 {1./56., -2./7., -19./20., 2., -5./4., 2./3., -1./4., 2./35., -1./168.},
296 {-1./168., 1./14., -1./2., -9./20., 5./4., -1./2., 1./6., -1./28., 1./280.},
297 {1./280., -4./105., 1./5., -4./5., 0, 4./5., -1./5., 4./105., -1./280.},
298 {-1./280., 1./28., -1./6., 1./2., -5./4., 9./20., 1./2., -1./14., 1./168.},
299 {1./168., -2./35., 1./4., -2./3., 5./4., -2., 19./20., 2./7., -1./56.},
300 {-1./56., 1./6., -7./10., 7./4., -35./12., 7./2., -7./2., 223./140., 1./8.},
301 {1./8., -8./7., 14./3., -56./5., 35./2., -56./3., 14., -8., 761./280.}
309 h = fabs(XVec->
data[0] - XVec->
data[1]);
314 for (
i = 0;
i <= vecLength-1;
i++)
318 for (j = 0; j <= 8; j++)
320 derivativeVec->
data[
i] += (
321 eightOrderCoeffs[0][j] * YVec->
data[j]
327 for (j = 0; j <= 8; j++)
329 derivativeVec->
data[
i] += (
330 eightOrderCoeffs[1][j] * YVec->
data[j]
336 for (j = 0; j <= 8; j++)
338 derivativeVec->
data[
i] += (
339 eightOrderCoeffs[2][j] * YVec->
data[j]
345 for (j = 0; j <= 8; j++)
347 derivativeVec->
data[
i] += (
348 eightOrderCoeffs[3][j] * YVec->
data[j]
352 else if (
i == vecLength-4)
354 for (j = 0; j <= 8; j++)
356 derivativeVec->
data[
i] += (
357 eightOrderCoeffs[5][j] * YVec->
data[
i+j-5]
361 else if (
i == vecLength-3)
363 for (j = 0; j <= 8; j++)
365 derivativeVec->
data[
i] += (
366 eightOrderCoeffs[6][j] * YVec->
data[
i+j-6]
370 else if (
i == vecLength-2)
372 for (j = 0; j <= 8; j++)
374 derivativeVec->
data[
i] += (
375 eightOrderCoeffs[7][j] * YVec->
data[
i+j-7]
379 else if (
i == vecLength-1)
381 for (j = 0; j <= 8; j++)
383 derivativeVec->
data[
i] += (
384 eightOrderCoeffs[8][j] * YVec->
data[
i+j-8]
390 for (j = 0; j <= 8; j++)
392 derivativeVec->
data[
i] += (
393 eightOrderCoeffs[4][j] * YVec->
data[
i+j-4]
398 derivativeVec->
data[
i] /= h;
427 REAL8 *X0, *X1, *X2, *X3;
428 REAL8 *Y0, *Y1, *Y2, *Y3;
431 const REAL8 oo12 = 0.08333333333333333;
435 for (
i=1;
i < vecLength+1;
i++)
442 XVecExt->
data[vecLength+1] = XVec->
data[vecLength-4];
445 YVecExt->
data[vecLength+1] = YVec->
data[vecLength-4];
447 X0 = &XVecExt->
data[0];
448 X1 = &XVecExt->
data[1];
449 X2 = &XVecExt->
data[2];
450 X3 = &XVecExt->
data[3];
452 Y0 = &YVecExt->
data[0];
453 Y1 = &YVecExt->
data[1];
454 Y2 = &YVecExt->
data[2];
455 Y3 = &YVecExt->
data[3];
457 for (
i=0;
i < vecLength-1;
i++)
465 g = 0.5 * (Y1[
i]+Y2[
i]);
469 c * b * (2 *
c + b) * (
c + b) *
d
470 -
a *
c * (
c -
a) * (2 *
c + 2 *
a + 3 * b) *
e
471 -
a * b * (2 *
a + b) * (
a + b) * h
472 ) / (
a *
c * (
a + b) * (
c + b) * (
c +
a + b))
474 integralVec->
data[
i+1] = integralVec->
data[
i] + z;
int XLALFDDerivative1Order6(REAL8Vector *XVec, REAL8Vector *YVec, REAL8Vector *derivativeVec)
Function which calculates the 6-order first finite difference derivative of a numerical function.
int XLALFDDerivative1Order2(REAL8Vector *XVec, REAL8Vector *YVec, REAL8Vector *derivativeVec)
Function which calculates the 2-order first finite difference derivative of a numerical function.
int XLALFDDerivative1Order4(REAL8Vector *XVec, REAL8Vector *YVec, REAL8Vector *derivativeVec)
Function which calculates the 4-order first finite difference derivative of a numerical function.
int XLALCumulativeIntegral3(REAL8Vector *XVec, REAL8Vector *YVec, REAL8Vector *integralVec)
Function which calculates the 3-order cumulative derivative of a numerical function.
int XLALFDDerivative1Order8(REAL8Vector *XVec, REAL8Vector *YVec, REAL8Vector *derivativeVec)
Function which calculates the 8-order first finite difference derivative of a numerical function.
static vector d(const double L_norm, const double J_norm, const vector roots)
Internal function that returns the coefficients "d_0", "d_2" and "d_4" from 1703.03967 corresponding ...
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)