19#include <lal/LALInspiral.h>
24 REAL8 xabs = fabs(creal(z));
25 REAL8 yabs = fabs(cimag(z));
37 return log(max) + 0.5 * log1p(
u *
u);
42 int j = amp->
length-1, jstep, jstepThird, k;
43 int nfilters = 0, decimationFactor = 1;
44 double phase_tdot, phase_ddot, phase_dot;
63 phase_ddot = (phase->
data[j-2] - 2.0 * phase->
data[j-1] + phase->
data[j]) / (2.0 *
LAL_PI);
64 phase_tdot = (phase->
data[j-3] - 3.0 * phase->
data[j-2] + 3.0 * phase->
data[j-1] - phase->
data[j]) / (2.0*
LAL_PI);
65 phase_ddot = fabs(phase_ddot);
66 phase_tdot = fabs(phase_tdot);
68 if (phase_ddot < 0 || phase_ddot > 8*epsilon){
73 jstep = (int) fabs(floor(sqrt(2.0 * epsilon / fabs(phase_ddot))+0.5));
74 jstepThird = (int) fabs(floor(pow(6.0 * epsilon / fabs(phase_tdot),1./3)+0.5));
76 jstepThird = abs(jstepThird);
79 if(jstep > jstepThird && jstepThird >0){
85 k = (int ) floor((
double ) j -
alpha * (double ) jstep + 0.5);
88 k = (int ) floor((
double ) j -
alpha * (double ) jstep + 0.5);
101 if (k > (
int) amp->
length-3) {
102 phase_dot = (11.0/6.0*phase->
data[k] - 3.0*phase->
data[k-1] + 1.5*phase->
data[k-2] - 1.0/3.0*phase->
data[k-3]);
105 phase_dot = (-phase->
data[k+2] + 8 * (phase->
data[k+1] - phase->
data[k-1]) + phase->
data[k-2]) / 12.0;
108 decimationFactor = ((int ) pow(2.0,-ceil(log(2.0*padding*phase_dot/(2.0*
LAL_PI))/log(2.0))));
109 if (decimationFactor < 1 ) decimationFactor = 1;
118 (*a1)->data[nfilters-1] =
cpolar((
double) exp(-beta / ((
double) jstep)), -phase_dot);
119 (*b0)->data[nfilters-1] =
cpolar(amp->
data[k], phase->
data[k] + phase_dot * ((
double) (j - k)) );
120 (*delay)->data[nfilters-1] = amp->
length - 1 - j;
135 int length, numFilters;
137 complex
double *a1_last;
138 complex
double *a1f = (complex
double *) a1->
data;
139 complex
double *b0f = (complex
double *)
b0->data;
140 int *delayf = delay->
data;
145 memset(response->
data, 0,
sizeof(complex
double) * response->
length);
148 for (a1_last = a1f + numFilters; a1f < a1_last; a1f++)
151 length = (int) (logf(1
e-13))/(logf(cabs(*a1f)));
153 int maxlength = response->
length - *delayf;
154 if (length > maxlength)
157 complex
double *response_data = (complex
double *) &response->
data[*delayf];
158 complex
double *response_data_last;
160 for (response_data_last = response_data + length; response_data < response_data_last; response_data++ )
173 double loga1, arga1,
pf;
180 pf = 2.0 *
LAL_PI * ((double ) j) / ((double ) jmax);
181 scl =
cpolar(0.5, -
pf * ((
double ) (jmax - delay)));
184 ftconj = conj(
b0) /
crect(-loga1, arga1 -
pf);
186 *hfcos = scl * (ft + ftconj);
187 *hfsin = scl * (ft - ftconj);
201 for (j = 0; j < psd->
length; j++)
204 for (k = 0; k < a1->
length; k++)
209 *ip += cabs(hA) * cabs(hA) / (psd->
data[j] * ((double ) psd->
length)) * 1.0;
int XLALInspiralGenerateIIRSetFourierTransform(int j, int jmax, COMPLEX16 a1, COMPLEX16 b0, INT4 delay, COMPLEX16 *hfcos, COMPLEX16 *hfsin)
int XLALInspiralCalculateIIRSetInnerProduct(COMPLEX16Vector *a1, COMPLEX16Vector *b0, INT4Vector *delay, REAL8Vector *psd, double *ip)
static REAL8 clogabs(COMPLEX16 z)
int XLALInspiralGenerateIIRSet(REAL8Vector *amp, REAL8Vector *phase, double epsilon, double alpha, double beta, double padding, COMPLEX16Vector **a1, COMPLEX16Vector **b0, INT4Vector **delay)
int XLALInspiralIIRSetResponse(COMPLEX16Vector *a1, COMPLEX16Vector *b0, INT4Vector *delay, COMPLEX16Vector *response)
INT4Vector * XLALResizeINT4Vector(INT4Vector *vector, UINT4 length)
INT4Vector * XLALCreateINT4Vector(UINT4 length)
COMPLEX16Vector * XLALCreateCOMPLEX16Vector(UINT4 length)
COMPLEX16Vector * XLALResizeCOMPLEX16Vector(COMPLEX16Vector *vector, UINT4 length)