LALInspiralMomentsIntegrand.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 David Churches, Duncan Brown, Jolien Creighton, B.S. Sathyaprakash
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="LALInspiralMomentsIntegrandCV">
00021 Authors: Brown, D. A., and Sathyaprakash, B. S.
00022 $Id: LALInspiralMomentsIntegrand.c,v 1.10 2007/06/08 14:41:42 bema Exp $
00023 </lalVerbatim>  */
00024 
00025 #if 0
00026 <lalLaTeX>
00027 \subsection{Module \texttt{LALInspiralMomentsIntegrand.c}}
00028 
00029 \subsubsection*{Prototypes}
00030 \vspace{0.1in}
00031 \input{LALInspiralMomentsIntegrandCP}
00032 \idx{LALInspiralMomentsIntegrand()}
00033 \begin{itemize}
00034    \item \texttt{integrand,} Output, the value of the integrand
00035    \item \texttt{x,} Input, the point where the integrand is required
00036    \item \texttt{params,} Input, of type \texttt{InspiralMomentsIn} containing the details
00037    required in moments calculation
00038 \end{itemize}
00039 
00040 \subsubsection*{Description}
00041 
00042 The moments of the noise curve are defined as 
00043 \begin{equation}
00044 I(q)  \equiv S_{h}(f_{0}) \int^{f_{c}/f_{0}}_{f_{s}/f_{0}}
00045 \frac{x^{-q/3}}{S_{h}(x)} \, dx \,.  
00046 \end{equation}
00047 This function calculates the integrand of this integral, i.e.\ for a given $x$
00048 it calculates 
00049 \begin{equation}
00050 \frac{x^{-q/3}}{S_{h}(x)} \,\,.
00051 \end{equation}
00052 by interpolating the frequency series containing $S_h(f)$.
00053 
00054 \subsubsection*{Algorithm}
00055 
00056 \subsubsection*{Uses}
00057 LALDPolynomialInterpolation
00058 
00059 \subsubsection*{Notes}
00060 
00061 \vfill{\footnotesize\input{LALInspiralMomentsIntegrandCV}}
00062 
00063 </lalLaTeX>
00064 #endif
00065 
00066 #include <lal/Interpolate.h>
00067 #include <lal/LALInspiralBank.h>
00068 
00069 NRCSID(LALINSPIRALMOMENTSINTEGRANDC, "$Id: LALInspiralMomentsIntegrand.c,v 1.10 2007/06/08 14:41:42 bema Exp $");
00070 
00071 /*  <lalVerbatim file="LALInspiralMomentsIntegrandCP"> */
00072 void
00073 LALInspiralMomentsIntegrand(
00074     LALStatus  *status,
00075     REAL8      *integrand,
00076     REAL8       x,
00077     void       *params
00078     )
00079 /* </lalVerbatim> */
00080 { 
00081    InspiralMomentsIn   *integrandParams;
00082 
00083    DInterpolateOut      interpOutput;
00084    DInterpolatePar      interpParams;
00085 
00086    UINT4                numInterpPts = 4;
00087    REAL8                f[4];
00088    REAL8                fMin;
00089    REAL8                fMax;
00090    REAL8                deltaF;
00091    UINT8                freqIndex;
00092 
00093    INITSTATUS( status, "LALInspiralMomentsIntegrand", 
00094        LALINSPIRALMOMENTSINTEGRANDC );
00095    ATTATCHSTATUSPTR( status );
00096 
00097    ASSERT( params, status, 
00098        LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL );
00099 
00100    integrandParams = (InspiralMomentsIn *) params;
00101 
00102    /* check that we have a pointer to a frequency series and it has data */
00103    ASSERT( integrandParams->shf, status, 
00104        LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL );
00105    ASSERT( integrandParams->shf->data, status, 
00106        LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL );
00107    ASSERT( integrandParams->shf->data->data, status, 
00108        LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL );
00109 
00110    /* the minimum and maximum frequency where we have four points */
00111    deltaF = integrandParams->shf->deltaF;
00112    fMin = integrandParams->shf->f0 + deltaF;
00113    fMax = integrandParams->shf->f0 +
00114      ((REAL8) integrandParams->shf->data->length - 2 ) * deltaF;
00115 
00116    /* locate the nearest point in the frequency series to the desired point */
00117    if ( x <= fMin )
00118    {
00119      freqIndex = 1;
00120    }
00121    else if ( x >= fMax )
00122    {
00123      freqIndex = integrandParams->shf->data->length - 3;
00124    }
00125    else
00126    {
00127      freqIndex = (UINT8) floor( (x - integrandParams->shf->f0) / deltaF );
00128    }
00129 
00130    /* set up the frequency values for interpolation */
00131    f[0] = (REAL8)(freqIndex - 1) * deltaF;
00132    f[1] = (REAL8)(freqIndex) * deltaF;
00133    f[2] = (REAL8)(freqIndex + 1) * deltaF;
00134    f[3] = (REAL8)(freqIndex + 2) * deltaF;
00135 
00136    /* set up the interpolation parameters */
00137    interpParams.n = numInterpPts;
00138    interpParams.x = f;
00139    interpParams.y = integrandParams->shf->data->data + freqIndex - 1;
00140    
00141    /* perform the interpolation... */
00142    LALDPolynomialInterpolation( status->statusPtr, &interpOutput, x,
00143        &interpParams );
00144    CHECKSTATUSPTR( status );
00145 
00146    /* ...and check for a negative value of shf */
00147    if ( interpOutput.y < 0 )
00148    {
00149      ABORT( status, 999, "interpolation output is negative" );
00150    }
00151 
00152    /* now compute the integrand using shf */
00153    *integrand = pow( x, -(integrandParams->ndx) ) / interpOutput.y;
00154 
00155    DETATCHSTATUSPTR(status);
00156    RETURN(status);
00157 }

Generated on Mon Oct 6 02:31:46 2008 for LAL by  doxygen 1.5.2