LAL  7.5.0.1-89842e6
NearestNeighborTriggerInterpolantTest.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  NearestNeighborTriggerInterpolant *interp = XLALCreateNearestNeighborTriggerInterpolant(0);
32  if (!interp)
33  exit(EXIT_FAILURE);
34 
35  {
36  const COMPLEX16 y[] = {1+2*I};
37  COMPLEX16 ymax;
38 
39  result = XLALCOMPLEX16ApplyNearestNeighborTriggerInterpolant(interp, &tmax, &ymax, y);
40  if (result)
41  exit(EXIT_FAILURE);
42 
43  if (tmax != 0)
44  exit(EXIT_FAILURE);
45  if (creal(ymax) != 1)
46  exit(EXIT_FAILURE);
47  if (cimag(ymax) != 2)
48  exit(EXIT_FAILURE);
49  }
50 
51  {
52  const COMPLEX8 y[] = {1+2*I};
53  COMPLEX8 ymax;
54 
55  result = XLALCOMPLEX8ApplyNearestNeighborTriggerInterpolant(interp, &tmax, &ymax, y);
56  if (result)
57  exit(EXIT_FAILURE);
58 
59  if (tmax != 0)
60  exit(EXIT_FAILURE);
61  if (crealf(ymax) != 1)
62  exit(EXIT_FAILURE);
63  if (cimagf(ymax) != 2)
64  exit(EXIT_FAILURE);
65  }
66 
67  {
68  const REAL8 y[] = {1};
69  REAL8 ymax;
70 
71  result = XLALREAL8ApplyNearestNeighborTriggerInterpolant(interp, &tmax, &ymax, y);
72  if (result)
73  exit(EXIT_FAILURE);
74 
75  if (tmax != 0)
76  exit(EXIT_FAILURE);
77  if (ymax != 1)
78  exit(EXIT_FAILURE);
79  }
80 
81  {
82  const REAL4 y[] = {1};
83  REAL4 ymax;
84 
85  result = XLALREAL4ApplyNearestNeighborTriggerInterpolant(interp, &tmax, &ymax, y);
86  if (result)
87  exit(EXIT_FAILURE);
88 
89  if (tmax != 0)
90  exit(EXIT_FAILURE);
91  if (ymax != 1)
92  exit(EXIT_FAILURE);
93  }
94 
96  exit(EXIT_SUCCESS);
97 }
int main(__attribute__((unused)) int argc, __attribute__((unused)) char **argv)
int XLALCOMPLEX16ApplyNearestNeighborTriggerInterpolant(__attribute__((unused)) NearestNeighborTriggerInterpolant *interp, double *t, COMPLEX16 *y, const COMPLEX16 *data)
#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).
NearestNeighborTriggerInterpolant * XLALCreateNearestNeighborTriggerInterpolant(unsigned int window)
Constructor.
int XLALREAL4ApplyNearestNeighborTriggerInterpolant(NearestNeighborTriggerInterpolant *interp, double *tmax, REAL4 *ymax, const REAL4 *y)
int XLALREAL8ApplyNearestNeighborTriggerInterpolant(NearestNeighborTriggerInterpolant *interp, double *tmax, REAL8 *ymax, const REAL8 *y)
int XLALCOMPLEX8ApplyNearestNeighborTriggerInterpolant(NearestNeighborTriggerInterpolant *interp, double *tmax, COMPLEX8 *ymax, const COMPLEX8 *y)
void XLALDestroyNearestNeighborTriggerInterpolant(NearestNeighborTriggerInterpolant *interp)
Destructor.