23#include <lal/LALError.h>
24#include <lal/AVFactories.h>
25#include <lal/ComplexFFT.h>
26#include <lal/XLALError.h>
27#include <lal/FrequencySeries.h>
28#include <lal/LALInspiralSBankOverlap.h>
32#define CHECK_OOM(ptr, msg) if (!(ptr)) { XLALPrintError((msg)); XLAL_ERROR_NULL(XLAL_ENOMEM); }
40 CHECK_OOM(workspace_cache,
"unable to allocate workspace\n");
41 return workspace_cache;
47 if (workspace_cache[k].
n) {
53 free(workspace_cache);
58 lalAbortHook(
"%s: Zero size workspace requested\n", __func__);
63 WS *ptr = workspace_cache;
65 if (ptr->
n ==
n)
return ptr;
66 if (++ptr - workspace_cache >
MAX_NUM_WS)
return NULL;
88 for (;k < size; ++k) {
89 const float ar = crealf(
a[k]);
90 const float br = crealf(b[k]);
91 const float ai = cimagf(
a[k]);
92 const float bi = cimagf(b[k]);
93 __real__ out[k] = ar * br + ai * bi;
94 __imag__ out[k] = ar * -bi + ai * br;
99 const REAL8 re = crealf(
x);
104 const REAL8 re = crealf(
x);
105 const REAL8 im = cimagf(
x);
106 return re * re + im * im;
111 const double dy = 0.5 * (yp1 - ym1);
112 const double d2y = 2. *
y - ym1 - yp1;
113 return y + 0.5 * dy * dy / d2y;
124 size_t n = 2 * (min_len - 1);
149 if (max == 0.)
return 0.;
153 if (argmax == 0 || argmax == (ssize_t)
n - 1)
160 return 4. * inj->
deltaF * sqrt(result);
173 size_t n = 2 * (min_len - 1);
196 return 4. * inj->
deltaF * max;
215 size_t n = 2 * (min_len - 1);
244 fprintf(stderr,
"DANGER WILL ROBINSON: CODE IS BROKEN!!\n");
255 COMPLEX8 ratio = hcdata[k] / hpdata[k];
256 REAL8 ratio_real = creal(ratio);
257 REAL8 ratio_imag = cimag(ratio);
258 REAL8 beta = 2 * ratio_real;
259 REAL8 alpha = ratio_real * ratio_real + ratio_imag * ratio_imag;
261 sqroot += beta * (beta -
delta * (1 +
alpha));
262 sqroot = sqrt(sqroot);
264 brckt = brckt / denom;
265 REAL8 det_stat_sq =
abs2(hpdata[k]) * brckt;
267 if (det_stat_sq > max) {
272 if (max == 0.)
return 0.;
282 return 4. * proposal->
deltaF * sqrt(max);
292 size_t n = 2 * (min_len - 1);
317 REAL8 denom = 1. - (hphccorr*hphccorr);
320 fprintf(stderr,
"DANGER WILL ROBINSON: CODE IS BROKEN!!\n");
333 det_stat_sq = creal(hpdata[k])*creal(hpdata[k]);
334 det_stat_sq += creal(hcdata[k])*creal(hcdata[k]);
335 det_stat_sq -= 2*creal(hpdata[k])*creal(hcdata[k])*hphccorr;
337 det_stat_sq = det_stat_sq / denom;
339 if (det_stat_sq > max) {
344 if (max == 0.)
return 0.;
355 return 4. * proposal->
deltaF * sqrt(max);
void(* lalAbortHook)(const char *,...)
REAL8 XLALInspiralSBankComputeRealMatch(const COMPLEX8FrequencySeries *inj, const COMPLEX8FrequencySeries *tmplt, WS *workspace_cache)
static void multiply_conjugate(COMPLEX8 *restrict out, COMPLEX8 *a, COMPLEX8 *b, const size_t size)
static double abs_real(const COMPLEX8 x)
#define CHECK_OOM(ptr, msg)
static double vector_peak_interp(const double ym1, const double y, const double yp1)
REAL8 XLALInspiralSBankComputeMatch(const COMPLEX8FrequencySeries *inj, const COMPLEX8FrequencySeries *tmplt, WS *workspace_cache)
REAL8 XLALInspiralSBankComputeMatchMaxSkyLocNoPhase(const COMPLEX8FrequencySeries *hp, const COMPLEX8FrequencySeries *hc, const REAL8 hphccorr, const COMPLEX8FrequencySeries *proposal, WS *workspace_cache1, WS *workspace_cache2)
WS * XLALCreateSBankWorkspaceCache(void)
static WS * get_workspace(WS *workspace_cache, const size_t n)
void XLALDestroySBankWorkspaceCache(WS *workspace_cache)
REAL8 XLALInspiralSBankComputeMatchMaxSkyLoc(const COMPLEX8FrequencySeries *hp, const COMPLEX8FrequencySeries *hc, const REAL8 hphccorr, const COMPLEX8FrequencySeries *proposal, WS *workspace_cache1, WS *workspace_cache2)
static double abs2(const COMPLEX8 x)
static double double delta
COMPLEX8FFTPlan * XLALCreateReverseCOMPLEX8FFTPlan(UINT4 size, int measurelvl)
int XLALCOMPLEX8VectorFFT(COMPLEX8Vector *_LAL_RESTRICT_ output, const COMPLEX8Vector *_LAL_RESTRICT_ input, const COMPLEX8FFTPlan *plan)
void XLALDestroyCOMPLEX8FFTPlan(COMPLEX8FFTPlan *plan)
COMPLEX8Vector * XLALCreateCOMPLEX8Vector(UINT4 length)
void XLALDestroyCOMPLEX8Vector(COMPLEX8Vector *vector)
#define XLAL_ERROR_REAL8(...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1