LALInspiralCreateFineBank.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 David Churches, Duncan Brown, Jolien Creighton, B.S. Sathyaprakash, Thomas Cokelaer
00003 *
00004 *  This program is free software; you can redistribute it and/or modify
00005 *  it under the terms of the GNU General Public License as published by
00006 *  the Free Software Foundation; either version 2 of the License, or
00007 *  (at your option) any later version.
00008 *
00009 *  This program is distributed in the hope that it will be useful,
00010 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 *  GNU General Public License for more details.
00013 *
00014 *  You should have received a copy of the GNU General Public License
00015 *  along with with program; see the file COPYING. If not, write to the
00016 *  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00017 *  MA  02111-1307  USA
00018 */
00019 
00020 /*  <lalVerbatim file="LALInspiralCreateFineBankCV">
00021 Author: Sathyaprakash, B.S. and Churches, D. K. 
00022 $Id: LALInspiralCreateFineBank.c,v 1.16 2007/06/08 14:41:42 bema Exp $
00023 </lalVerbatim>  */
00024 
00025 /*  <lalLaTeX>
00026 
00027 \subsection{Module \texttt{LALInspiralCreateFineBank.c}}
00028 
00029 Function to create a fine grid of templates.
00030 
00031 \subsubsection*{Prototypes}
00032 \vspace{0.1in}
00033 \input{LALInspiralCreateFineBankCP}
00034 \idx{LALInspiralCreateFineBank()}
00035 \begin{itemize}
00036    \item \texttt{outlist,} Output, containing an array of template bank parameters 
00037    \item \texttt{nlist,} Output, the number of fine bank templates around a given coarse-mesh point
00038    \item \texttt{fineIn,} Input, the parameters required to find the fine bank
00039 \end{itemize}
00040 
00041 \subsubsection*{Description}
00042 
00043 The fine grid algorithm is a very simple algorithm that computes a uniform
00044 grid of templates around a given coordinate point -- which can in particular be 
00045 a coarse grid point -- from a knowledge of the metric at the coordinate point
00046 and the coarse and fine grid minimal matches, $D\tau_{0,3}$ and
00047 $d\tau_{0,3},$ respectively. Since $D\tau$ is not necessarily an
00048 integral multiple of $d\tau$ the rectangular fine grid about the point
00049 in question will be larger than required. The algorithm chooses templates
00050 {\it symmetrically} about the given coarse grid point. It does so
00051 by laying a rectangular lattice of templates with spacings 
00052 $d\tau_0$ and $d\tau_3,$ in the rectangular region defined by 
00053 $(\tau_0 - \Delta \tau_0, \tau_3 - \Delta \tau_3),$
00054 $(\tau_0 + \Delta \tau_0, \tau_3 - \Delta \tau_3),$
00055 $(\tau_0 + \Delta \tau_0, \tau_3 + \Delta \tau_3)$ and
00056 $(\tau_0 - \Delta \tau_0, \tau_3 + \Delta \tau_3),$
00057 where 
00058 $$\Delta\tau_0 = d\tau_0 \left [ \frac{D\tau_0}{2d\tau_0} \right ], $$
00059 and for any $x$, $[x]$ denotes the smallest integer greater than or
00060 equal to $x$.
00061 \begin{figure}[h]
00062 \centering\includegraphics[angle=-90,width=4.5 true in]{LALInspiralBankHfine}
00063 \caption{Algorithm sketching the construction of a rectangular fine grid around a given coordinate point.}
00064 \label{fig:fine}
00065 \end{figure}
00066 The algorithm takes as input a structure of type 
00067 \texttt{InspiralFineBankIn} and returns a \texttt{pointer-to-a-pointer} 
00068 of type \texttt{InspiralTemplateList} as well as the number of fine grid
00069 templates \texttt {int} around the lattice point in question.
00070 
00071 The spacing between fine grid templates is chosen
00072 to be a constant determined by the metric at the coarse grid point; for
00073 example, 
00074 $$d\tau_0 = \sqrt{\frac{2 (1 - MM_{\rm Fine})}{g_{00}} }.$$
00075 Only those grid points that are within the parameter space boundary, or
00076 have the vertices of the ambiguity rectangle inside the parameter
00077 space, are kept and others are discarded.
00078  
00079 \subsubsection*{Algorithm}
00080 
00081 The Fine grid algorithm works as follows:
00082 \begin{obeylines}
00083 \texttt{
00084 \hskip 1 true cm From input structure extract coordinates of the grid point $(\tau_0^G, \tau_3^G).$
00085 \hskip 1 true cm Compute coarse and fine grid spacings $(D\tau_0, D\tau_3)$ and $(d\tau_0, d\tau_3)$
00086 \hskip 1 true cm Compute half-sides of the {\it smallest} symmetric rectangle about $(\tau_0, \tau_3)$: 
00087 \hskip 2 true cm $\Delta\tau_0 =  d\tau_0 {\it ceil}[D\tau_0/(2d\tau_0)],$ $\Delta\tau_3 =  d\tau_3 {\it ceil}[D\tau_3/(2d\tau_3)],$
00088 \hskip 1 true cm Begin at $\tau_3 = \tau_3^G - \Delta \tau_3,$ 
00089 \hskip 1 true cm do while ($\tau_3 <= \tau_3^G+\Delta \tau_3$)
00090 \hskip 1 true cm \{
00091 \hskip 2 true cm Begin at $\tau_0 = \tau_0^G - \Delta \tau_0,$ 
00092 \hskip 2 true cm do while ($\tau_0 <= \tau_0^G+\Delta \tau_0$)
00093 \hskip 2 true cm \{
00094 \hskip 3 true cm if ($(\tau_0, \tau_3)$ is inside the parameter space)
00095 \hskip 3 true cm \{
00096 \hskip 4 true cm Add ($\tau_0, \tau_3$) to InspiralTemplateList
00097 \hskip 4 true cm numTemplates++
00098 \hskip 3 true cm \}
00099 \hskip 3 true cm Increment $\tau_0:$ $\tau_0 = \tau_0 + d\tau_0$ 
00100 \hskip 2 true cm \}
00101 \hskip 2 true cm Increment $\tau_3:$ $\tau_3 = \tau_3 + d\tau_3$ 
00102 \hskip 1 true cm \}
00103 }
00104 \end{obeylines}
00105 
00106 \subsubsection*{Uses}
00107 \begin{verbatim}
00108 LALInspiralComputeParams()
00109 LALInspiralUpdateParams()
00110 LALInspiralValidTemplate()
00111 \end{verbatim}
00112 
00113 \subsubsection*{Notes}
00114 
00115 \vfill{\footnotesize\input{LALInspiralCreateFineBankCV}}
00116 
00117 </lalLaTeX>  */
00118 
00119 #include <stdio.h>
00120 #include <lal/LALInspiralBank.h>
00121 
00122 NRCSID (LALINSPIRALCREATEFINEBANKC, "$Id: LALInspiralCreateFineBank.c,v 1.16 2007/06/08 14:41:42 bema Exp $");
00123 
00124 /*  <lalVerbatim file="LALInspiralCreateFineBankCP"> */
00125 
00126 void LALInspiralCreateFineBank(LALStatus            *status,  
00127                                InspiralTemplateList **outlist,
00128                                INT4                 *nlist,
00129                                InspiralFineBankIn   fineIn)
00130 { /* </lalVerbatim> */
00131  
00132   REAL8 x0, x1, Dx0, Dx1, dx0, dx1, x0FineMin, x1FineMin, x0FineMax, x1FineMax;     
00133   INT4  i, j, validPars, bins0, bins1; 
00134   InspiralTemplate   *tempPars=NULL;  
00135   InspiralBankParams *bankPars=NULL;
00136 
00137 
00138   INITSTATUS (status, "LALInspiralCreateFineBank", LALINSPIRALCREATEFINEBANKC);
00139   ATTATCHSTATUSPTR(status);
00140   ASSERT ((INT4)fineIn.coarseIn.space>=0,  status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL);
00141   ASSERT ((INT4)fineIn.coarseIn.space<=1,  status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL);
00142   ASSERT ((REAL8)fineIn.templateList.params.t0 > 0, status, LALINSPIRALBANKH_ESIZE, LALINSPIRALBANKH_MSGESIZE);
00143 
00144   /* set the number of fine templates generated to zero      */
00145   /* otherwise the LALCalloc will fail horribly, since there */
00146   /* is nothing that guarantees that *nlist is a reasonable  */
00147   /* number when the function is called                      */
00148   *nlist = 0;
00149 
00150   tempPars = (InspiralTemplate *) LALCalloc(1, sizeof(InspiralTemplate));
00151   bankPars = (InspiralBankParams *) LALCalloc(1, sizeof(InspiralBankParams));
00152   *tempPars = fineIn.templateList.params;
00153   switch (fineIn.coarseIn.space) {
00154     case Tau0Tau2:
00155       ASSERT (fineIn.templateList.params.t2 > 0, status, LALINSPIRALBANKH_ESIZE, LALINSPIRALBANKH_MSGESIZE);
00156       bankPars->x0 = fineIn.templateList.params.t0;
00157       bankPars->x1 = fineIn.templateList.params.t2;
00158       break;
00159     case Tau0Tau3:
00160       ASSERT (fineIn.templateList.params.t3 > 0, status, LALINSPIRALBANKH_ESIZE, LALINSPIRALBANKH_MSGESIZE);
00161       bankPars->x0 = fineIn.templateList.params.t0;
00162       bankPars->x1 = fineIn.templateList.params.t3;
00163       break;
00164     default: /* JC: DEFAULT CASE ADDED HERE */ 
00165       ABORT( status, 9999, "Default case in switch." );
00166   }
00167 
00168   LALInspiralUpdateParams(status->statusPtr,bankPars,fineIn.templateList.metric,fineIn.coarseIn.mmCoarse); 
00169   CHECKSTATUSPTR(status);
00170   x0 = bankPars->x0;
00171   x1 = bankPars->x1;
00172   Dx0 = bankPars->dx0;
00173   Dx1 = bankPars->dx1;
00174 
00175   LALInspiralUpdateParams(status->statusPtr,bankPars,fineIn.templateList.metric,fineIn.coarseIn.mmFine); 
00176   CHECKSTATUSPTR(status);
00177   dx0 = bankPars->dx0;
00178   dx1 = bankPars->dx1;
00179 
00180   bins0 = (int)(Dx0/dx0) + 1;
00181   bins1 = (int)(Dx1/dx1) + 1;
00182 
00183   x0FineMin = x0 - (float) bins0/2. * dx0;
00184   x0FineMax = x0 + (float) bins0/2. * dx0;
00185   x1FineMin = x1 - (float) bins1/2. * dx1;
00186   x1FineMax = x1 + (float) bins1/2. * dx1;
00187 
00188   bankPars->x1 = x1FineMin;
00189   for(i=0; i<=bins1; i++) {
00190      bankPars->x0 = x0FineMin;
00191      for(j=0; j<=bins0; j++) {
00192        LALInspiralValidTemplate(status->statusPtr, &validPars, *bankPars, fineIn.coarseIn);
00193        CHECKSTATUSPTR(status);
00194        if (validPars) {
00195          LALInspiralComputeParams(status->statusPtr, tempPars, *bankPars, fineIn.coarseIn);
00196          CHECKSTATUSPTR(status);
00197 /*  
00198     On failure realloc() returns a NULL to outlist, hence there is
00199     no need to explicitly free the outlist 
00200 */
00201          if (!(*outlist = (InspiralTemplateList*) 
00202             LALRealloc(*outlist, sizeof(InspiralTemplateList)*(*nlist+1)))) {
00203             ABORT(status, LALINSPIRALBANKH_EMEM, LALINSPIRALBANKH_MSGEMEM);
00204             outlist = NULL;
00205          }
00206          memset( *outlist + *nlist, 0, sizeof(InspiralTemplateList) );
00207          (*outlist)[*nlist].params = *tempPars;
00208          ++(*nlist); 
00209        }
00210        bankPars->x0+=bankPars->dx0;
00211      }   
00212      bankPars->x1+=bankPars->dx1;
00213   }
00214   if (tempPars!=NULL) LALFree(tempPars);
00215   if (bankPars!=NULL) LALFree(bankPars);
00216   DETATCHSTATUSPTR(status);
00217   RETURN (status);
00218 }
00219 

Generated on Sat Sep 6 03:07:10 2008 for LAL by  doxygen 1.5.2