LAL  7.5.0.1-89842e6
QuadraticFitTriggerInterpolantTest.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 Leo Singer
18  */
19 
20 
21 #include <complex.h>
22 #include <stdlib.h>
23 
24 #include <lal/TriggerInterpolation.h>
25 
26 int main(__attribute__ ((unused)) int argc, __attribute__ ((unused)) char **argv)
27 {
28  int result;
29  double tmax;
30 
31  QuadraticFitTriggerInterpolant *interp = XLALCreateQuadraticFitTriggerInterpolant(2);
32  if (!interp)
33  exit(EXIT_FAILURE);
34 
35  {
36  const COMPLEX16 y[] = {0, 3, 4, 3, 0};
37  COMPLEX16 ymax;
38 
39  result = XLALCOMPLEX16ApplyQuadraticFitTriggerInterpolant(interp, &tmax, &ymax, &y[2]);
40  if (result)
41  exit(EXIT_FAILURE);
42 
43  if (tmax != 0)
44  exit(EXIT_FAILURE);
45  if (creal(ymax) != 4)
46  exit(EXIT_FAILURE);
47  if (cimag(ymax) != 0)
48  exit(EXIT_FAILURE);
49  }
50 
51  {
52  const COMPLEX8 y[] = {0, 3, 4, 3, 0};
53  COMPLEX8 ymax;
54 
55  result = XLALCOMPLEX8ApplyQuadraticFitTriggerInterpolant(interp, &tmax, &ymax, &y[2]);
56  if (result)
57  exit(EXIT_FAILURE);
58 
59  if (tmax != 0)
60  exit(EXIT_FAILURE);
61  if (crealf(ymax) != 4)
62  exit(EXIT_FAILURE);
63  if (cimagf(ymax) != 0)
64  exit(EXIT_FAILURE);
65  }
66 
67  {
68  const REAL8 y[] = {0, 3, 4, 3, 0};
69  REAL8 ymax;
70 
71  result = XLALREAL8ApplyQuadraticFitTriggerInterpolant(interp, &tmax, &ymax, &y[2]);
72  if (result)
73  exit(EXIT_FAILURE);
74 
75  if (tmax != 0)
76  exit(EXIT_FAILURE);
77  if (ymax != 4)
78  exit(EXIT_FAILURE);
79  }
80 
81  {
82  const REAL4 y[] = {0, 3, 4, 3, 0};
83  REAL4 ymax;
84 
85  result = XLALREAL4ApplyQuadraticFitTriggerInterpolant(interp, &tmax, &ymax, &y[2]);
86  if (result)
87  exit(EXIT_FAILURE);
88 
89  if (tmax != 0)
90  exit(EXIT_FAILURE);
91  if (ymax != 4)
92  exit(EXIT_FAILURE);
93  }
94 
96  exit(EXIT_SUCCESS);
97 }
int main(__attribute__((unused)) int argc, __attribute__((unused)) char **argv)
#define __attribute__(x)
Definition: getdate.c:146
double complex COMPLEX16
Double-precision floating-point complex number (16 bytes total)
double REAL8
Double precision real floating-point number (8 bytes).
float complex COMPLEX8
Single-precision floating-point complex number (8 bytes total)
float REAL4
Single precision real floating-point number (4 bytes).
int XLALREAL8ApplyQuadraticFitTriggerInterpolant(QuadraticFitTriggerInterpolant *interp, double *tmax, REAL8 *ymax, const REAL8 *y)
int XLALCOMPLEX16ApplyQuadraticFitTriggerInterpolant(QuadraticFitTriggerInterpolant *interp, double *t, COMPLEX16 *y, const COMPLEX16 *data)
Perform interpolation using the allocated workspace.
int XLALCOMPLEX8ApplyQuadraticFitTriggerInterpolant(QuadraticFitTriggerInterpolant *interp, double *tmax, COMPLEX8 *ymax, const COMPLEX8 *y)
void XLALDestroyQuadraticFitTriggerInterpolant(QuadraticFitTriggerInterpolant *interp)
Destructor.
QuadraticFitTriggerInterpolant * XLALCreateQuadraticFitTriggerInterpolant(unsigned int window)
Constructor.
int XLALREAL4ApplyQuadraticFitTriggerInterpolant(QuadraticFitTriggerInterpolant *interp, double *tmax, REAL4 *ymax, const REAL4 *y)