Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALInspiral 5.0.3.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALInspiralCreateFineBank.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 David Churches, Duncan Brown, Jolien Creighton, B.S. Sathyaprakash, Thomas Cokelaer
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20
21#include <stdio.h>
22#include <lal/LALInspiralBank.h>
23
24/**
25 * \author Sathyaprakash, B.S. and Churches, D. K.
26 * \brief Function to create a fine grid of templates.
27 *
28 * The fine grid algorithm is a very simple algorithm that computes a uniform
29 * grid of templates around a given coordinate point -- which can in particular be
30 * a coarse grid point -- from a knowledge of the metric at the coordinate point
31 * and the coarse and fine grid minimal matches, \f$D\tau_{0,3}\f$ and
32 * \f$d\tau_{0,3},\f$ respectively. Since \f$D\tau\f$ is not necessarily an
33 * integral multiple of \f$d\tau\f$ the rectangular fine grid about the point
34 * in question will be larger than required. The algorithm chooses templates
35 * \e symmetrically about the given coarse grid point. It does so
36 * by laying a rectangular lattice of templates with spacings
37 * \f$d\tau_0\f$ and \f$d\tau_3,\f$ in the rectangular region defined by
38 * \f$(\tau_0 - \Delta \tau_0, \tau_3 - \Delta \tau_3),\f$
39 * \f$(\tau_0 + \Delta \tau_0, \tau_3 - \Delta \tau_3),\f$
40 * \f$(\tau_0 + \Delta \tau_0, \tau_3 + \Delta \tau_3)\f$ and
41 * \f$(\tau_0 - \Delta \tau_0, \tau_3 + \Delta \tau_3),\f$
42 * where
43 * \f[\Delta\tau_0 = d\tau_0 \left [ \frac{D\tau_0}{2d\tau_0} \right ], \f]
44 * and for any \f$x\f$, \f$[x]\f$ denotes the smallest integer greater than or
45 * equal to \f$x\f$.
46 *
47 * \anchor LALInspiralBankHfine
48 * \image html LALInspiralBankHfine.png "Algorithm sketching the construction of a rectangular fine grid around a given coordinate point"
49 *
50 * The algorithm takes as input a structure of type
51 * \c InspiralFineBankIn and returns a <tt>pointer-to-a-pointer</tt>
52 * of type \c InspiralTemplateList as well as the number of fine grid
53 * templates \c int around the lattice point in question.
54 *
55 * The spacing between fine grid templates is chosen
56 * to be a constant determined by the metric at the coarse grid point; for
57 * example,
58 * \f[d\tau_0 = \sqrt{\frac{2 (1 - MM_\textrm{Fine})}{g_{00}} }.\f]
59 * Only those grid points that are within the parameter space boundary, or
60 * have the vertices of the ambiguity rectangle inside the parameter
61 * space, are kept and others are discarded.
62 *
63 * ### Algorithm ###
64 *
65 * The Fine grid algorithm works as follows:
66 * <tt>
67 * <ul>
68 * <li> From input structure extract coordinates of the grid point \f$(\tau_0^G, \tau_3^G).\f$
69 * <li> Compute coarse and fine grid spacings \f$(D\tau_0, D\tau_3)\f$ and \f$(d\tau_0, d\tau_3)\f$
70 * <li>Compute half-sides of the <i>smallest</i> symmetric rectangle about \f$(\tau_0, \tau_3)\f$:
71 * <ul>
72 * <li> \f$\Delta\tau_0 = d\tau_0 \,\mathrm{ceil}[D\tau_0/(2d\tau_0)],\f$ \f$\Delta\tau_3 = d\tau_3 \,\mathrm{ceil}[D\tau_3/(2d\tau_3)],\f$
73 * </ul>
74 * <li> Begin at \f$\tau_3 = \tau_3^G - \Delta \tau_3,\f$
75 * <li> do while (\f$\tau_3 <= \tau_3^G+\Delta \tau_3\f$)<br>
76 * {<br>
77 * <ul>
78 * <li> Begin at \f$\tau_0 = \tau_0^G - \Delta \tau_0,\f$
79 * <li> do while (\f$\tau_0 <= \tau_0^G+\Delta \tau_0\f$)<br>
80 * {<br>
81 * <ul>
82 * <li> if (\f$(\tau_0, \tau_3)\f$ is inside the parameter space)<br>
83 * {<br>
84 * <ul>
85 * <li> Add (\f$\tau_0, \tau_3\f$) to InspiralTemplateList
86 * <li> numTemplates++
87 * </ul>
88 * }<br>
89 * <li> Increment \f$\tau_0:\f$ \f$\tau_0 = \tau_0 + d\tau_0\f$
90 * </ul>
91 * }<br>
92 * <li>Increment \f$\tau_3:\f$ \f$\tau_3 = \tau_3 + d\tau_3\f$
93 * </ul>
94 * }
95 * </ul>
96 * </tt>
97 */
98void LALInspiralCreateFineBank(LALStatus *status, /**< LAL status pointer */
99 InspiralTemplateList **outlist, /**< [out] containing an array of template bank parameters */
100 INT4 *nlist, /**< [out] the number of fine bank templates around a given coarse-mesh point */
101 InspiralFineBankIn fineIn /**< [in] the parameters required to find the fine bank */
102 )
103{
104
105 REAL8 x0, x1, Dx0, Dx1, dx0, dx1, x0FineMin, x1FineMin;
106 INT4 i, j, validPars, bins0, bins1;
107 InspiralTemplate *tempPars=NULL;
108 InspiralBankParams *bankPars=NULL;
109
110
113 ASSERT ((INT4)fineIn.coarseIn.space>=0, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL);
114 ASSERT ((INT4)fineIn.coarseIn.space<=1, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL);
115 ASSERT ((REAL8)fineIn.templateList.params.t0 > 0, status, LALINSPIRALBANKH_ESIZE, LALINSPIRALBANKH_MSGESIZE);
116
117 /* set the number of fine templates generated to zero */
118 /* otherwise the LALCalloc will fail horribly, since there */
119 /* is nothing that guarantees that *nlist is a reasonable */
120 /* number when the function is called */
121 *nlist = 0;
122
123 tempPars = (InspiralTemplate *) LALCalloc(1, sizeof(InspiralTemplate));
124 bankPars = (InspiralBankParams *) LALCalloc(1, sizeof(InspiralBankParams));
125 *tempPars = fineIn.templateList.params;
126 switch (fineIn.coarseIn.space) {
127 case Tau0Tau2:
128 ASSERT (fineIn.templateList.params.t2 > 0, status, LALINSPIRALBANKH_ESIZE, LALINSPIRALBANKH_MSGESIZE);
129 bankPars->x0 = fineIn.templateList.params.t0;
130 bankPars->x1 = fineIn.templateList.params.t2;
131 break;
132 case Tau0Tau3:
133 ASSERT (fineIn.templateList.params.t3 > 0, status, LALINSPIRALBANKH_ESIZE, LALINSPIRALBANKH_MSGESIZE);
134 bankPars->x0 = fineIn.templateList.params.t0;
135 bankPars->x1 = fineIn.templateList.params.t3;
136 break;
137 default: /* JC: DEFAULT CASE ADDED HERE */
138 ABORT( status, 9999, "Default case in switch." );
139 }
140
141 LALInspiralUpdateParams(status->statusPtr,bankPars,fineIn.templateList.metric,fineIn.coarseIn.mmCoarse);
143 x0 = bankPars->x0;
144 x1 = bankPars->x1;
145 Dx0 = bankPars->dx0;
146 Dx1 = bankPars->dx1;
147
148 LALInspiralUpdateParams(status->statusPtr,bankPars,fineIn.templateList.metric,fineIn.coarseIn.mmFine);
150 dx0 = bankPars->dx0;
151 dx1 = bankPars->dx1;
152
153 bins0 = (int)(Dx0/dx0) + 1;
154 bins1 = (int)(Dx1/dx1) + 1;
155
156 x0FineMin = x0 - (float) bins0/2. * dx0;
157 x1FineMin = x1 - (float) bins1/2. * dx1;
158
159 bankPars->x1 = x1FineMin;
160 for(i=0; i<=bins1; i++) {
161 bankPars->x0 = x0FineMin;
162 for(j=0; j<=bins0; j++) {
163 LALInspiralValidTemplate(status->statusPtr, &validPars, *bankPars, fineIn.coarseIn);
165 if (validPars) {
166 LALInspiralComputeParams(status->statusPtr, tempPars, *bankPars, fineIn.coarseIn);
168/*
169 On failure realloc() returns a NULL to outlist, hence there is
170 no need to explicitly free the outlist
171*/
172 if (!(*outlist = (InspiralTemplateList*)
173 LALRealloc(*outlist, sizeof(InspiralTemplateList)*(*nlist+1)))) {
174 ABORT(status, LALINSPIRALBANKH_EMEM, LALINSPIRALBANKH_MSGEMEM);
175 outlist = NULL;
176 }
177 memset( *outlist + *nlist, 0, sizeof(InspiralTemplateList) );
178 (*outlist)[*nlist].params = *tempPars;
179 ++(*nlist);
180 }
181 bankPars->x0+=bankPars->dx0;
182 }
183 bankPars->x1+=bankPars->dx1;
184 }
185 if (tempPars!=NULL) LALFree(tempPars);
186 if (bankPars!=NULL) LALFree(bankPars);
188 RETURN (status);
189}
#define LALRealloc(p, n)
#define LALCalloc(m, n)
#define LALFree(p)
#define ABORT(statusptr, code, mesg)
#define CHECKSTATUSPTR(statusptr)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
double i
double REAL8
int32_t INT4
void LALInspiralUpdateParams(LALStatus *status, InspiralBankParams *bankParams, InspiralMetric metric, REAL8 minimalMatch)
Function to update the parameters used in creating a coarse bank based on a square lattice.
void LALInspiralCreateFineBank(LALStatus *status, InspiralTemplateList **outlist, INT4 *nlist, InspiralFineBankIn fineIn)
Function to create a fine grid of templates.
#define LALINSPIRALBANKH_ENULL
Null pointer.
void LALInspiralValidTemplate(LALStatus *status, INT4 *valid, InspiralBankParams bankParams, InspiralCoarseBankIn coarseIn)
Function which checks whether or not a given template should be kept in the template list.
void LALInspiralComputeParams(LALStatus *status, InspiralTemplate *pars, InspiralBankParams bankParams, InspiralCoarseBankIn coarseIn)
This function takes as input , and (the lower frequency of the detectors sensitivity),...
#define LALINSPIRALBANKH_ESIZE
Invalid input range.
#define LALINSPIRALBANKH_EMEM
Memory allocation failure.
@ Tau0Tau2
space of chirptimes
@ Tau0Tau3
space of chirptimes
This is a structure needed in the inner workings of the LALInspiralCreateCoarseBank code.
REAL8 x1
the second coordinate, chosen to be either or
REAL8 dx0
increment in the x0-direction
REAL8 dx1
increment in the x1-direction
REAL8 x0
the first coordinate, chosen to be always
REAL8 mmFine
Fine grid minimal match.
REAL8 mmCoarse
Coarse grid minimal match.
CoordinateSpace space
enum that decides whether to use or in constructing the template bank
Structure needed by the function LALInspiralCreateFineBank.
InspiralCoarseBankIn coarseIn
input structure that contains useful necessary parameters to construct a fine-mesh
InspiralTemplateList templateList
A list containing all the fine-mesh templates.
The inspiral waveform parameter structure containing information about the waveform to be generated.
Definition: LALInspiral.h:205
REAL8 t2
first post-Newtonian chirp time in seconds (input/output)
Definition: LALInspiral.h:295
REAL8 t3
1.5 post-Newtonian chirp time in seconds (input/output)
Definition: LALInspiral.h:296
REAL8 t0
Newtonain chirp time in seconds (input/output)
Definition: LALInspiral.h:294
A grid of inspiral templates (ie a template list).
InspiralTemplate params
Value of the parameters at the lattice point.
InspiralMetric metric
metric at the lattice point