Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
TriggerInterpolation.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with with program; see the file COPYING. If not, write to the
14 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
15 * MA 02110-1301 USA
16 *
17 * Copyright (C) 2012-2020 Leo Singer
18 */
19
20#include <complex.h>
21#include <stdlib.h>
22#include <gsl/gsl_errno.h>
23#include <lal/TriggerInterpolate.h>
24#include <lal/TriggerInterpolation.h>
25
26
27#define APPLY_FUNC(NAME, TYPE) \
28int XLAL ## TYPE ## Apply ## NAME ## TriggerInterpolant( \
29 NAME ## TriggerInterpolant *interp, \
30 double *tmax, \
31 TYPE *ymax, \
32 const TYPE *y) \
33{ \
34 int result; \
35 double complex ymax_full; \
36 double complex data_full[2 * interp->window + 1]; \
37 double complex *const y_full = &data_full[interp->window]; \
38 for (int i = -(int)interp->window; i <= (int)interp->window; i ++) \
39 y_full[i] = y[i]; \
40 result = XLALTriggerInterpolate ## NAME(tmax, &ymax_full, y_full, interp->window); \
41 if (result == GSL_SUCCESS) \
42 *ymax = ymax_full; \
43 return result; \
44}
45
46
47
48#define LEGACY_API(NAME) \
49struct tag ## NAME ## TriggerInterpolant { \
50 unsigned int window; \
51}; \
52\
53NAME ## TriggerInterpolant *XLALCreate ## NAME ## TriggerInterpolant(unsigned int window) \
54{ \
55 NAME ## TriggerInterpolant *interp = malloc(sizeof(NAME ## TriggerInterpolant)); \
56 if (!interp) \
57 GSL_ERROR_NULL("Failed to allocate interpolant", GSL_ENOMEM); \
58 interp->window = window; \
59 return interp; \
60} \
61\
62void XLALDestroy ## NAME ## TriggerInterpolant(NAME ## TriggerInterpolant *interp) \
63{ \
64 free(interp); \
65} \
66\
67APPLY_FUNC(NAME, COMPLEX16) \
68APPLY_FUNC(NAME, COMPLEX8) \
69APPLY_FUNC(NAME, REAL8) \
70APPLY_FUNC(NAME, REAL4)
71
72LEGACY_API(CubicSpline)
73LEGACY_API(CubicSplineAmpPhase)
74LEGACY_API(Lanczos)
75LEGACY_API(NearestNeighbor)
76LEGACY_API(QuadraticFit)
#define LEGACY_API(NAME)