87#include <lal/LALStdlib.h>
89#include <lal/AVFactories.h>
90#include <lal/SeqFactories.h>
91#include <lal/LALInspiralBank.h>
92#include <lal/LALNoiseModels.h>
93#include <lal/MatrixUtils.h>
94#include <lal/FindChirpPTF.h>
97#define UNUSED __attribute__ ((unused))
119 REAL4 sqrtoftwo = sqrt(2.0);
120 REAL4 onebysqrtoftwo = 1.0 / sqrtoftwo;
121 REAL4 onebysqrtofsix = 1.0 / sqrt(6.0);
154 REAL8FFTPlan *fwdPlan;
155 REAL8FFTPlan *revPlan;
161 REAL8 initdelta = 0.001;
162 REAL8 tolerance = 0.001;
204 for (
i = 0;
i < 5; ++
i )
209 Qtilde[
i].
data = PTFQtilde->
data + (
i * (
N / 2 + 1)) ;
213 for ( j = 0; j <
N; ++j )
224 Q[0].data[j] = omega_2_3 * onebysqrtoftwo * ( cos(2 * phi) * ( e1x * e1x +
225 e2y * e2y - e2x * e2x - e1y * e1y ) + 2 * sin(2 * phi) *
226 ( e1x * e2x - e1y * e2y ));
227 Q[1].data[j] = omega_2_3 * sqrtoftwo * ( cos(2 * phi) * ( e1x * e1y -
228 e2x * e2y ) + sin(2 * phi) * ( e1x * e2y + e1y * e2x ));
229 Q[2].data[j] = omega_2_3 * sqrtoftwo * ( cos(2 * phi) * ( e1x * e1z -
230 e2x * e2z ) + sin(2 * phi) * ( e1x * e2z + e1z * e2x ));
231 Q[3].data[j] = omega_2_3 * sqrtoftwo * ( cos(2 * phi) * ( e1y * e1z -
232 e2y * e2z ) + sin(2 * phi) * ( e1y * e2z + e1z * e2y ));
233 Q[4].data[j] = omega_2_3 * onebysqrtofsix * ( cos(2 * phi) *
234 ( 2 * e2z * e2z - 2 * e1z * e1z + e1x * e1x + e1y * e1y -
235 e2x * e2x - e2y * e2y ) + 2 * sin(2 * phi) * ( e1x * e2x +
236 e1y * e2y - 2 * e1z * e2z ));
240 for (
i = 0;
i < 5; ++
i )
246 P[0] = -(1 + cos(Theta) * cos(Theta)) * cos(2 * Phi) * cos(Psi)
247 + 2 * cos(Theta) * sin(2 * Phi) * sin(Psi);
248 P[1] = - 2 * cos(Theta) * cos(2 * Phi) * sin(Psi)
249 -(1 + cos(Theta) * cos(Theta)) * sin(2 * Phi) * cos(Psi);
250 P[2] = 2 * sin(Theta) * (-sin(Phi) * sin(Psi) + cos(Theta) * cos(Phi) * cos(Psi));
251 P[3] = 2 * sin(Theta) * ( cos(Phi) * sin(Psi) + cos(Theta) * sin(Phi) * cos(Psi));
252 P[4] = 3 * sin(Theta) * sin(Theta) * cos(Psi);
255 PdTh[0] = -(1 - sin(2 * Theta)) * cos(2 * Phi) * cos(Psi)
256 - 2 * sin(Theta) * sin(2 * Phi) * sin(Psi);
257 PdTh[1] = 2 * sin(Theta) * cos(2 * Phi) * sin(Psi)
258 -(1 - sin(2 * Theta)) * sin(2 * Phi) * cos(Psi);
259 PdTh[2] = 2 * cos(Theta) * (-sin(Phi) * sin(Psi) - sin(Theta) * cos(Phi) * cos(Psi));
260 PdTh[3] = 2 * cos(Theta) * ( cos(Phi) * sin(Psi) - sin(Theta) * sin(Phi) * cos(Psi));
261 PdTh[4] = 3 * sin(2 * Theta) * cos(Psi);
264 PdPh[0] = - 2 * (1 + cos(Theta) * cos(Theta)) * sin(2 * Phi) * cos(Psi)
265 + 4 * cos(Theta) * cos(2 * Phi) * sin(Psi);
266 PdPh[1] = 4 * cos(Theta) * sin(2 * Phi) * sin(Psi)
267 - 2 * (1 + cos(Theta) * cos(Theta)) * cos(2 * Phi) * cos(Psi);
268 PdPh[2] = 2 * sin(Theta) * (-cos(Phi) * sin(Psi) - cos(Theta) * sin(Phi) * cos(Psi));
269 PdPh[3] = 2 * sin(Theta) * (-sin(Phi) * sin(Psi) + cos(Theta) * cos(Phi) * cos(Psi));
273 PdPs[0] = (1 + cos(Theta) * cos(Theta)) * cos(2 * Phi) * sin(Psi)
274 + 2 * cos(Theta) * sin(2 * Phi) * cos(Psi);
275 PdPs[1] = - 2 * cos(Theta) * cos(2 * Phi) * cos(Psi)
276 + (1 + cos(Theta) * cos(Theta)) * sin(2 * Phi) * sin(Psi);
277 PdPs[2] = 2 * sin(Theta) * (-sin(Phi) * cos(Psi) - cos(Theta) * cos(Phi) * sin(Psi));
278 PdPs[3] = 2 * sin(Theta) * ( cos(Phi) * cos(Psi) - cos(Theta) * sin(Phi) * sin(Psi));
279 PdPs[4] = - 3 * sin(Theta) * sin(Theta) * sin(Psi);
286 for (k = 0; k <
N / 2 + 1; ++k)
288 fsig0->
data[k] = 0.0;
289 fsig1->
data[k] = 0.0;
290 for (
i = 0;
i < 5; ++
i)
298 for (k = 0; k <
N / 2 + 1; ++k)
300 fsig->
data[k] =
crect( cos(phi0) * creal(fsig0->
data[k]) + sin(phi0) * creal(fsig1->
data[k]), cos(phi0) * cimag(fsig0->
data[k]) + sin(phi0) * cimag(fsig1->
data[k]) );
308 for (k = 0; k <
N / 2 + 1; ++k)
313 derivs->
data[
N/2+1+k] =
crect( - sin(phi0) * creal(fsig0->
data[k]) + cos(phi0) * creal(fsig1->
data[k]), - sin(phi0) * cimag(fsig0->
data[k]) + cos(phi0) * cimag(fsig1->
data[k]) );
315 derivs->
data[
N+2+k] = 0.0;
316 for (
i = 0;
i < 5; ++
i)
321 derivs->
data[3*
N/2+3+k] = 0.0;
322 for (
i = 0;
i < 5; ++
i)
327 derivs->
data[2*
N+4+k] = 0.0;
328 for (
i = 0;
i < 5; ++
i)
335 for (
i = 5;
i < 9; ++
i)
340 fprintf( stderr,
"XLALInspiralComputePTFDeriv failed\n" );
343 for (k = 0; k <
N / 2 + 1; ++k)
345 derivs->
data[
i*(
N/2+1)+k] =
crect( cos(phi0) * creal(intrinsicderiv->
data[k]) + sin(phi0) * cimag(intrinsicderiv->
data[k]), cos(phi0) * cimag(intrinsicderiv->
data[k]) - sin(phi0) * creal(intrinsicderiv->
data[k]) );
347 derivs->
data[
i*(
N/2+1)] =
crect( (cos(phi0) + sin(phi0)) * creal(intrinsicderiv->
data[0]), (cos(phi0) + sin(phi0)) * cimag(intrinsicderiv->
data[0]) );
348 derivs->
data[
i*(
N/2+1)+
N/2] =
crect( (cos(phi0) + sin(phi0)) * creal(intrinsicderiv->
data[
N / 2]), (cos(phi0) + sin(phi0)) * cimag(intrinsicderiv->
data[
N / 2]) );
352 derivsfile = fopen(
"myderivs.dat",
"w" );
354 if( derivsfile != NULL )
356 for (j = 0; j <
N / 2 + 1; ++j)
358 fprintf( derivsfile,
"%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n",
359 creal(derivs->
data[j]), cimag(derivs->
data[j]),
360 creal(derivs->
data[(
N / 2 + 1) + j]), cimag(derivs->
data[(
N / 2 + 1) + j]),
361 creal(derivs->
data[2 * (
N / 2 + 1) + j]), cimag(derivs->
data[2 * (
N / 2 + 1) + j]),
362 creal(derivs->
data[3 * (
N / 2 + 1) + j]), cimag(derivs->
data[3 * (
N / 2 + 1) + j]),
363 creal(derivs->
data[4 * (
N / 2 + 1) + j]), cimag(derivs->
data[4 * (
N / 2 + 1) + j]),
364 creal(derivs->
data[5 * (
N / 2 + 1) + j]), cimag(derivs->
data[5 * (
N / 2 + 1) + j]),
365 creal(derivs->
data[6 * (
N / 2 + 1) + j]), cimag(derivs->
data[6 * (
N / 2 + 1) + j]),
366 creal(derivs->
data[7 * (
N / 2 + 1) + j]), cimag(derivs->
data[7 * (
N / 2 + 1) + j]),
367 creal(derivs->
data[8 * (
N / 2 + 1) + j]), cimag(derivs->
data[8 * (
N / 2 + 1) + j]));
377 for (k = 0; k <
N / 2 + 1; ++k)
380 invpsd->
data[k] = 0.;
385 for (
i = 0;
i < 9; ++
i)
387 for (j = 0; j <
i + 1; ++j)
389 for (k = 0; k <
N / 2 + 1; ++k)
391 tempnormtilde->
data[k] =
crect( ( creal(derivs->
data[
i * (
N/2+1) + k]) * creal(derivs->
data[j * (
N/2+1) + k]) + cimag(derivs->
data[
i * (
N/2+1) + k]) * cimag(derivs->
data[j * (
N/2+1) + k])) * invpsd->
data[k], ( cimag(derivs->
data[
i * (
N/2+1) + k]) * creal(derivs->
data[j * (
N/2+1) + k]) - creal(derivs->
data[
i * (
N/2+1) + k]) * cimag(derivs->
data[j * (
N/2+1) + k])) * invpsd->
data[k] );
395 fullmetric->
data[
i * (
i + 1) / 2 + j] = 4.0 * tempnorm->
data[0];
399 wavenorm = fullmetric->
data[2];
400 for (
i = 0;
i < 45; ++
i)
402 fullmetric->
data[
i] /= wavenorm;
406 for (
i = 0;
i < 5; ++
i)
408 for (j = 0; j <
i + 1; ++j)
410 ExtExt_matrix->
data[ 5 *
i + j] = ExtExt_matrix->
data[ 5 * j +
i] =
411 fullmetric->
data[
i * (
i + 1) / 2 + j];
424 for (
i = 5;
i < 9; ++
i)
426 for (j = 5; j <
i + 1; ++j)
428 IntInt_matrix->
data[ 4 * (
i-5) + j - 5] = IntInt_matrix->
data[ 4 * (j-5) +
i - 5]=
429 fullmetric->
data[
i * (
i + 1) / 2 + j];
434 for (
i = 5;
i < 9; ++
i)
436 for (j = 0; j < 5; ++j)
438 IntExt_matrix->
data[ 5 * (
i-5) + j] = fullmetric->
data[
i * (
i + 1) / 2 + j];
450 for (
i = 0;
i < 5; ++
i)
452 for (j=0; j < 4; ++j)
454 IntExt_transp->
data[ 4 *
i + j] = IntExt_matrix->
data[ j * 5 +
i];
474 for (
i = 0;
i < 4; ++
i )
476 for ( j = 0; j <
i + 1; ++j )
478 params->Gamma[
i * (
i + 1) / 2 + j] = metric->
Gamma[
i * (
i + 1) / 2 + j] =
479 IntInt_matrix->
data[
i * 4 + j] - matrix_4_x_4->
data[
i * 4 + j];
526 REAL8 sqrtoftwo = sqrt(2.0);
527 REAL8 onebysqrtoftwo = 1.0 / sqrtoftwo;
528 REAL8 onebysqrtofsix = 1.0 / sqrt(6.0);
557 REAL8FFTPlan *fwdPlan;
574 for (
i = 0;
i < 5; ++
i )
583 for ( j = 0; j <
N; ++j )
594 Q[0].data[j] = omega_2_3 * onebysqrtoftwo * ( cos(2 * phi) * ( e1x * e1x +
595 e2y * e2y - e2x * e2x - e1y * e1y ) + 2 * sin(2 * phi) *
596 ( e1x * e2x - e1y * e2y ));
597 Q[1].data[j] = omega_2_3 * sqrtoftwo * ( cos(2 * phi) * ( e1x * e1y -
598 e2x * e2y ) + sin(2 * phi) * ( e1x * e2y + e1y * e2x ));
599 Q[2].data[j] = omega_2_3 * sqrtoftwo * ( cos(2 * phi) * ( e1x * e1z -
600 e2x * e2z ) + sin(2 * phi) * ( e1x * e2z + e1z * e2x ));
601 Q[3].data[j] = omega_2_3 * sqrtoftwo * ( cos(2 * phi) * ( e1y * e1z -
602 e2y * e2z ) + sin(2 * phi) * ( e1y * e2z + e1z * e2y ));
603 Q[4].data[j] = omega_2_3 * onebysqrtofsix * ( cos(2 * phi) *
604 ( 2 * e2z * e2z - 2 * e1z * e1z + e1x * e1x + e1y * e1y -
605 e2x * e2x - e2y * e2y ) + 2 * sin(2 * phi) * ( e1x * e2x +
606 e1y * e2y - 2 * e1z * e2z ));
608 Qp[0].
data[j] = omega_2_3 * onebysqrtoftwo * ( - sin(2 * phi) * ( e1x * e1x +
609 e2y * e2y - e2x * e2x - e1y * e1y ) + 2 * cos(2 * phi) *
610 ( e1x * e2x - e1y * e2y ));
611 Qp[1].
data[j] = omega_2_3 * sqrtoftwo * ( - sin(2 * phi) * ( e1x * e1y -
612 e2x * e2y ) + cos(2 * phi) * ( e1x * e2y + e1y * e2x ));
613 Qp[2].
data[j] = omega_2_3 * sqrtoftwo * ( - sin(2 * phi) * ( e1x * e1z -
614 e2x * e2z ) + cos(2 * phi) * ( e1x * e2z + e1z * e2x ));
615 Qp[3].
data[j] = omega_2_3 * sqrtoftwo * ( - sin(2 * phi) * ( e1y * e1z -
616 e2y * e2z ) + cos(2 * phi) * ( e1y * e2z + e1z * e2y ));
617 Qp[4].
data[j] = omega_2_3 * onebysqrtofsix * ( - sin(2 * phi) *
618 ( 2 * e2z * e2z - 2 * e1z * e1z + e1x * e1x + e1y * e1y -
619 e2x * e2x - e2y * e2y ) + 2 * cos(2 * phi) * ( e1x * e2x +
620 e1y * e2y - 2 * e1z * e2z ));
624 P[0] = -(1 + cos(Theta) * cos(Theta)) * cos(2 * Phi) * cos(Psi)
625 + 2 * cos(Theta) * sin(2 * Phi) * sin(Psi);
626 P[1] = - 2 * cos(Theta) * cos(2 * Phi) * sin(Psi)
627 -(1 + cos(Theta) * cos(Theta)) * sin(2 * Phi) * cos(Psi);
628 P[2] = 2 * sin(Theta) * (-sin(Phi) * sin(Psi) + cos(Theta) * cos(Phi) * cos(Psi));
629 P[3] = 2 * sin(Theta) * ( cos(Phi) * sin(Psi) + cos(Theta) * sin(Phi) * cos(Psi));
630 P[4] = 3 * sin(Theta) * sin(Theta) * cos(Psi);
634 for ( j = 0; j <
N; ++j )
636 ptfwave->
data[j] = P[0] * (
Q[0].data[j] * cos(phi0) + Qp[0].
data[j] * sin(phi0) )
637 + P[1] * (
Q[1].
data[j] * cos(phi0) + Qp[1].
data[j] * sin(phi0) )
638 + P[2] * (
Q[2].
data[j] * cos(phi0) + Qp[2].
data[j] * sin(phi0) )
639 + P[3] * (
Q[3].
data[j] * cos(phi0) + Qp[3].
data[j] * sin(phi0) )
640 + P[4] * (
Q[4].
data[j] * cos(phi0) + Qp[4].
data[j] * sin(phi0) );
689 UINT4 clen, plen, mlen;
710 REAL8FFTPlan *fwdPlan;
711 REAL8FFTPlan *revPlan;
714 REAL8 reldelta = initdelta;
716 REAL8 relderivdiff = 1.0;
719 REAL8 powerderivdiff;
751 fprintf( stderr,
"XLALInspiralComputePTFWaveform failed\n" );
757 while (relderivdiff > tolerance && iter < maxiter + 1)
762 absdelta = totalMass * reldelta;
763 pparams.
totalMass = totalMass + absdelta;
764 mparams.
totalMass = totalMass - absdelta;
767 absdelta =
params->eta * reldelta;
768 pparams.
eta = eta + absdelta;
769 mparams.
eta = eta - absdelta;
773 pparams.
chi = chi + absdelta;
774 mparams.
chi = chi - absdelta;
778 pparams.
kappa = kappa + absdelta;
779 mparams.
kappa = kappa - absdelta;
782 fprintf( stdout,
"XLALInspiralComputePTFWDeriv failed\n" );
804 fprintf( stderr,
"XLALInspiralComputePTFWaveform failed\n" );
814 memmove(pwavenew->
data + dlen, pwavenew->
data, (
N - dlen) *
sizeof(
REAL8));
815 memset(pwavenew->
data, 0, dlen *
sizeof(
REAL8));
819 memmove(pwavenew->
data, pwavenew->
data - dlen, (
N + dlen) *
sizeof(
REAL8));
820 memset(pwavenew->
data + (
N + dlen), 0, (- dlen) *
sizeof(
REAL8));
825 memmove(mwavenew->
data + dlen, mwavenew->
data, (
N - dlen) *
sizeof(
REAL8));
826 memset(mwavenew->
data, 0, dlen *
sizeof(
REAL8));
830 memmove(mwavenew->
data, mwavenew->
data - dlen, (
N + dlen) *
sizeof(
REAL8));
831 memset(mwavenew->
data + (
N + dlen), 0, (- dlen) *
sizeof(
REAL8));
837 for (j = 0; j <
N; ++j)
839 wavederivnew->
data[j] =
840 (pwavenew->
data[j]/2 - mwavenew->
data[j]/2) / absdelta;
841 wavederivdiff->
data[j] = wavederivnew->
data[j];
842 wavederivold->
data[j] = wavederivnew->
data[j];
843 pwaveold2->
data[j] = pwavenew->
data[j];
844 mwaveold2->
data[j] = mwavenew->
data[j];
845 pwaveold->
data[j] = pwavenew->
data[j];
846 mwaveold->
data[j] = mwavenew->
data[j];
851 for (j = 0; j <
N; ++j)
853 wavederivnew->
data[j] =
854 (- pwaveold->
data[j] / 12 + 2 * pwavenew->
data[j] / 3
855 - 2 * mwavenew->
data[j] / 3 + mwaveold->
data[j] / 12) / absdelta;
856 wavederivdiff->
data[j] = wavederivnew->
data[j] - wavederivold->
data[j];
857 wavederivold->
data[j] = wavederivnew->
data[j];
858 pwaveold2->
data[j] = pwaveold->
data[j];
859 mwaveold2->
data[j] = mwaveold->
data[j];
860 pwaveold->
data[j] = pwavenew->
data[j];
861 mwaveold->
data[j] = mwavenew->
data[j];
884 for (k = 0; k <
N/2 + 1; ++k)
890 derivpowertilde->
data[k] =
crect( (creal(derivtilde->
data[k]) * creal(derivtilde->
data[k]) +cimag(derivtilde->
data[k]) * cimag(derivtilde->
data[k])) * invpsd, 0 );
891 derivdiffpowertilde->
data[k] =
crect( (creal(derivdifftilde->
data[k]) * creal(derivdifftilde->
data[k]) +cimag(derivdifftilde->
data[k]) * cimag(derivdifftilde->
data[k])) * invpsd, 0 );
898 powerderiv = 4.0 * wavederiv_2->
data[0];
899 powerderivdiff = 4.0 * wavederivdiff_2->
data[0];
901 relderivdiff = powerderivdiff / powerderiv;
903 if (relderivdiff < tolerance)
905 for (k = 0; k <
N / 2 + 1; ++k)
907 Wderiv->
data[k] = derivtilde->
data[k];
void REPORTSTATUS(LALStatus *status)
void LALInspiralParameterCalc(LALStatus *status, InspiralTemplate *params)
void XLALDestroyREAL8Array(REAL8Array *)
REAL8Array * XLALCreateREAL8ArrayL(UINT4,...)
REAL8VectorSequence * XLALCreateREAL8VectorSequence(UINT4 length, UINT4 veclen)
void XLALDestroyCOMPLEX16VectorSequence(COMPLEX16VectorSequence *vecseq)
void XLALDestroyREAL4VectorSequence(REAL4VectorSequence *vecseq)
void XLALDestroyVectorSequence(REAL4VectorSequence *vecseq)
void XLALDestroyREAL8VectorSequence(REAL8VectorSequence *vecseq)
REAL4VectorSequence * XLALCreateREAL4VectorSequence(UINT4 length, UINT4 veclen)
COMPLEX16VectorSequence * XLALCreateCOMPLEX16VectorSequence(UINT4 length, UINT4 veclen)
REAL4VectorSequence * XLALCreateVectorSequence(UINT4 length, UINT4 veclen)
void LALDMatrixInverse(LALStatus *stat, REAL8 *det, REAL8Array *matrix, REAL8Array *inverse)
INT4 XLALFindChirpPTFWaveform(REAL4Vector *PTFphi, REAL4Vector *PTFomega_2_3, REAL4VectorSequence *PTFe1, REAL4VectorSequence *PTFe2, InspiralTemplate *InspTmplt, REAL8 deltaT)
@ totalMassAndEta
total mass and symmetric mass ratio
INT4 XLALInspiralComputePTFIntrinsicMetric(InspiralMetric *metric, REAL8Vector *fullmetric, REAL8FrequencySeries *psd, InspiralTemplate *params)
INT4 XLALInspiralComputePTFWaveform(REAL8Vector *ptfwave, InspiralTemplate *params)
INT4 XLALInspiralComputePTFWDeriv(COMPLEX16Vector *Wderiv, REAL8FrequencySeries *psd, InspiralTemplate *params, INT4 paramid, REAL8 initdelta, REAL8 tolerance)
void LALDMatrixMultiply(LALStatus *, REAL8Array *out, REAL8Array *in1, REAL8Array *in2)
void LALDMatrixTranspose(LALStatus *, REAL8Array *out, REAL8Array *in1)
int XLALREAL8ForwardFFT(COMPLEX16Vector *output, const REAL8Vector *input, const REAL8FFTPlan *plan)
int XLALREAL8ReverseFFT(REAL8Vector *output, const COMPLEX16Vector *input, const REAL8FFTPlan *plan)
void XLALDestroyREAL8FFTPlan(REAL8FFTPlan *plan)
REAL8FFTPlan * XLALCreateReverseREAL8FFTPlan(UINT4 size, int measurelvl)
REAL8FFTPlan * XLALCreateForwardREAL8FFTPlan(UINT4 size, int measurelvl)
REAL4Vector * XLALCreateREAL4Vector(UINT4 length)
void XLALDestroyVector(REAL4Vector *vector)
void XLALDestroyREAL4Vector(REAL4Vector *vector)
REAL4Vector * XLALCreateVector(UINT4 length)
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
COMPLEX16Vector * XLALCreateCOMPLEX16Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
void XLALDestroyCOMPLEX16Vector(COMPLEX16Vector *vector)
Structure to store metric at various points the signal manifold.
REAL4 Gamma[10]
3d metric co-efficients in coordinates; Gamma[6] is a vector that stores the upper triangular part o...
The inspiral waveform parameter structure containing information about the waveform to be generated.
REAL8 eta
symmetric mass ratio (input/output)
REAL8 totalMass
total mass of the binary in solar mass (input/output)
REAL8 tC
total chirp time seconds (output)
InputMasses massChoice
The pair of (mass) parameters given (see structure defining this member for more details) (input)
REAL8 chi
dimensionless spin of black hole (ie mass1)
REAL8 kappa
cosine of angle between spin of mass1 and orb ang mom