ResampleTest.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Jolien Creighton, Teviet Creighton
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="ResampleTestCV">
00021 Author: Creighton, T. D.
00022 Revision: $Id: ResampleTest.c,v 1.7 2007/06/08 14:41:52 bema Exp $
00023 **************************************************** </lalVerbatim> */
00024 
00025 /********************************************************** <lalLaTeX>
00026 
00027 \providecommand{\lessim}{\stackrel{<}{\scriptstyle\sim}}
00028 
00029 \subsection{Program \texttt{ResampleTest.c}}
00030 \label{ss:ResampleTest.c}
00031 
00032 Tests the routines in \verb@Resample.h@.
00033 
00034 \subsubsection*{Usage}
00035 \begin{verbatim}
00036 ResampleTest [-d debuglevel] [-p psfile] [-t tfile] [-c n a f] [-m dec df fm]
00037 \end{verbatim}
00038 
00039 This program generates a quasiperiodic time series having a sinusoidal
00040 phase modulation, and generates a piecewise-polynomial fit to the
00041 phase function.  It then generates and applies stroboscopic resampling
00042 rules to the time series to produce a monochromatic signal.  The
00043 following option flags are accepted:
00044 \begin{itemize}
00045 \item[\texttt{-d}] Sets the global \verb@lalDebugLevel@ to the
00046 specified \verb@debuglevel@.
00047 \item[\texttt{-p}] Power spectra of the time series before and after
00048 demodulation will be written to the file \verb@psfile@.
00049 \item[\texttt{-t}] The timing difference function $(\tau-t)/\Delta t$
00050 computed in three ways (analytically, from a polynomial fit, and from
00051 the resampling rules), will be written to the file \verb@tfile@.  See
00052 below for notation.
00053 \item[\texttt{-c}] Sets parameters for the ``carrier'' signal: the
00054 number of points \verb@n@, the amplitude \verb@a@, and the frequency
00055 \verb@f@.
00056 \item[\texttt{-m}] Sets parameters for the signal modulation and
00057 resampling: the decimation factor \verb@dec@, the maximum change in
00058 signal frequency \verb@df@, and the frequency of the modulation
00059 \verb@fm@.
00060 \end{itemize}
00061 All frequencies are in units of the sampling rate, which is an
00062 arbitrary scale.  With no options, the program runs with
00063 \verb@lalDebugLevel@=0, produces no output, and uses internally
00064 \verb@#define@d signal parameters.
00065 
00066 \subsubsection*{Exit codes}
00067 ****************************************** </lalLaTeX><lalErrTable> */
00068 #define RESAMPLETESTC_ENORM 0
00069 #define RESAMPLETESTC_ESUB  1
00070 #define RESAMPLETESTC_EARG  2
00071 #define RESAMPLETESTC_EBAD  3
00072 #define RESAMPLETESTC_EFILE 4
00073 
00074 #define RESAMPLETESTC_MSGENORM "Success, normal exit"
00075 #define RESAMPLETESTC_MSGESUB  "Recursive error"
00076 #define RESAMPLETESTC_MSGEARG  "Error parsing arguments"
00077 #define RESAMPLETESTC_MSGEBAD  "Bad argument value"
00078 #define RESAMPLETESTC_MSGEFILE "Error opening or writing to output file"
00079 /******************************************** </lalErrTable><lalLaTeX>
00080 
00081 \subsubsection*{Algorithm}
00082 
00083 The modulated signal is of the form $s(t)=A\sin[\phi(t)]$, where $A$
00084 is a rather arbitrary amplitude, and $\phi(t)$ is a phase function of
00085 the form:
00086 $$
00087 \phi(t) = 2\pi f_c t + \frac{\Delta f}{f_m}\sin(2\pi f_m t) \; .
00088 $$
00089 Here $f_c$ is the average ``carrier'' frequency, $f_m$ is the
00090 frequency of the modulation, and $\Delta f$ is the maximum change in
00091 the ``instantaneous'' frequency of the signal (or, equivalently, the
00092 separation between the carrier and sidebands in the power spectral
00093 density).  The canonical (demodulated) time coordinate for this phase
00094 function is $\tau=\phi/2\pi f_c$.  The demodulation routines require
00095 quadratic fits to the function $\tau-t$ at various times $t_0$:
00096 \begin{eqnarray}
00097 \tau - t & = & \frac{(\Delta f/f_c)}{2\pi f_m}\sin(2\pi f_m t_0)
00098                 \nonumber\\
00099          & + & (\Delta f/f_c)\cos(2\pi f_m t_0)(t-t_0) \nonumber\\
00100          & - & \pi f_m (\Delta f/f_c)\sin(2\pi f_m t_0)(t-t_0)^2 \; ,
00101 \label{eq:polyco-formulae}
00102 \end{eqnarray}
00103 with residuals less than $(2/3)\pi^2 f_m^2(\Delta f/f_c)(t-t_0)^3$.
00104 We require this residual to be always less than one sample interval
00105 $\Delta t$.  This means that a piecewise-quadratic fit to the phase
00106 function must be evaluated at times $t_0$ separated by no more than:
00107 \begin{equation}
00108 \Delta t_0 \lessim \sqrt[3]{\frac{12f_c\Delta t}{\pi^2f_m^2\Delta f}}
00109         \; ,
00110 \label{eq:polyco-interval}
00111 \end{equation}
00112 noting that each piecewise fit is good for a time interval
00113 $t_0\pm\Delta t_0/2$ about each central time $t_0$.
00114 
00115 Thus to create a piecewise-polynomial fit defined by
00116 \verb@PolycoStruc@, this program simply define a set of fitting times
00117 \verb@t0[@$k$\verb@]@$=(2k+1)\Delta t_0/2$, and computes the
00118 appropriate components of \verb@polyco@ from
00119 Eq.~(\ref{eq:polyco-formulae}), above.
00120 
00121 \subsubsection*{Uses}
00122 \begin{verbatim}
00123 lalDebugLevel
00124 LALPrintError()
00125 LALSCreateVector()
00126 LALSDestroyVector()
00127 LALCreateResampleRules()
00128 LALApplyResampleRules()
00129 LALDestroyResampleRules()
00130 \end{verbatim}
00131 
00132 \subsubsection*{Notes}
00133 
00134 \vfill{\footnotesize\input{ResampleTestCV}}
00135 
00136 ******************************************************* </lalLaTeX> */
00137 
00138 #include <stdlib.h>
00139 #include <math.h>
00140 #include <lal/LALStdlib.h>
00141 #include <lal/RealFFT.h>
00142 #include <lal/AVFactories.h>
00143 #include <lal/SeqFactories.h>
00144 #include <lal/LALConstants.h>
00145 #include <lal/Resample.h>
00146 
00147 NRCSID( RESAMPLETESTC, "$Id: ResampleTest.c,v 1.7 2007/06/08 14:41:52 bema Exp $" );
00148 
00149 /* Default parameter settings. */
00150 INT4 lalDebugLevel = 0;
00151 #define NPTS 4096
00152 #define AMP 1
00153 #define FREQ 0.1
00154 #define DEC 4
00155 #define DF 0.02
00156 #define FM 0.001
00157 
00158 /* Output files for timing information. */
00159 #define OUTFILE0 "out0.dat"
00160 #define OUTFILE1 "out1.dat"
00161 #define OUTFILE2 "out2.dat"
00162 
00163 /* Other constants. */
00164 #define NPOLY 3    /* Number of polynomial coefficients (quadratic) */
00165 #define BUFFER 5.0 /* Polynomial fit covers this many seconds before
00166                       and after requested timespan */
00167 REAL8 df_f;    /* Maximum fractional change in carrier frequency */
00168 REAL8 twoPiFm; /* 2*Pi times the frequency of modulation */
00169 
00170 /* Usage format string. */
00171 #define USAGE "Usage: %s [-d debuglevel] [-p psfile] [-t tfile] [-c n a f] [-m dec df fm]\n"
00172 
00173 /* Macros for printing errors and testing subroutines. */
00174 #define ERROR( code, msg, statement )                                \
00175 if ( lalDebugLevel & LALERROR )                                      \
00176 {                                                                    \
00177   LALPrintError( "Error[0] %d: program %s, file %s, line %d, %s\n"   \
00178                  "        %s %s\n", (code), *argv, __FILE__,         \
00179                  __LINE__, RESAMPLETESTC, statement ? statement : "",\
00180                  (msg) );                                            \
00181 }                                                                    \
00182 else (void)(0)
00183 
00184 #define INFO( statement )                                            \
00185 if ( lalDebugLevel & LALINFO )                                       \
00186 {                                                                    \
00187   LALPrintError( "Info[0]: program %s, file %s, line %d, %s\n"       \
00188                  "        %s\n", *argv, __FILE__, __LINE__,          \
00189                  RESAMPLETESTC, (statement) );                       \
00190 }                                                                    \
00191 else (void)(0)
00192 
00193 #define SUB( func, statusptr )                                       \
00194 if ( (func), (statusptr)->statusCode )                               \
00195 {                                                                    \
00196   ERROR( RESAMPLETESTC_ESUB, RESAMPLETESTC_MSGESUB,                  \
00197          "Function call \"" #func "\" failed:" );                    \
00198   return RESAMPLETESTC_ESUB;                                         \
00199 }                                                                    \
00200 else (void)(0)
00201 
00202 
00203 /* A global pointer for debugging. */
00204 #ifndef NDEBUG
00205 char *lalWatch;
00206 #endif
00207 
00208 
00209 /* Local subroutines. */
00210 REAL8
00211 TDiff( REAL8 t );
00212 /* Returns the value tau-t as a function of t. */
00213 
00214 REAL8
00215 DTDiff( REAL8 t );
00216 /* Returns the derivative of tau-t as a function of t. */
00217 
00218 REAL8
00219 DDTDiff( REAL8 t );
00220 /* Returns the double derivative of tau-t as a function of t. */
00221 
00222 REAL8
00223 DDDTDiffMax( void );
00224 /* Returns the triple derivative of tau-t as a function of t,
00225    maximized over all t. */
00226 
00227 static /* const */ REAL4TimeSeries emptyREAL4TimeSeries;
00228 static /* const */ CreateVectorSequenceIn emptyCreateVectorSequenceIn;
00229 static /* const */ ResampleParamStruc emptyResampleParamStruct;
00230 
00231 int
00232 main( int argc, char **argv )
00233 {
00234   static LALStatus stat;/* Head of status list */
00235   CHAR *tfile = NULL;   /* Timing difference output filename */
00236   CHAR *psfile = NULL;  /* Power spectrum output filename */
00237   INT4 arg;
00238   UINT4 i;              /* Index counter */
00239   UINT4 n = NPTS;       /* Number of points in time series */
00240   UINT4 m = NPTS/DEC;   /* Number of points in decimated series */
00241   UINT4 dec = DEC;      /* Decimation factor */
00242   REAL4 a = AMP;        /* Amplitude of carrier wave */
00243   REAL4 f = FREQ;       /* Frequency of carrier wave */
00244   REAL4 df = DF;        /* Amplitude of frequency modulation */
00245   REAL4 fm = FM;        /* Frequency of modulation */
00246   REAL4TimeSeries input = emptyREAL4TimeSeries;  /* Modulated time series */
00247   REAL4TimeSeries output = emptyREAL4TimeSeries; /* Decimated time series */
00248   static PolycoStruc polyco;     /* Polynomial coefficient structure */
00249   ResampleRules *rules = NULL; /* Resampling rules structure */
00250 
00251   /* Parse argument list.  arg stores the current position. */
00252   arg = 1;
00253   while ( arg < argc ) {
00254     /* Parse carrier parameters option. */
00255     if ( !strcmp( argv[arg], "-c" ) ) {
00256       if ( argc > arg + 3 ) {
00257         arg++;
00258         n = atoi( argv[arg++] );
00259         a = atof( argv[arg++] );
00260         f = atof( argv[arg++] );
00261       } else {
00262         ERROR( RESAMPLETESTC_EARG, RESAMPLETESTC_MSGEARG, 0 );
00263         LALPrintError( USAGE, *argv );
00264         return RESAMPLETESTC_EARG;
00265       }
00266     }
00267     /* Parse modulation parameters option. */
00268     else if ( !strcmp( argv[arg], "-m" ) ) {
00269       if ( argc > arg + 3 ) {
00270         arg++;
00271         dec = atoi( argv[arg++] );
00272         df = atof( argv[arg++] );
00273         fm = atof( argv[arg++] );
00274       } else {
00275         ERROR( RESAMPLETESTC_EARG, RESAMPLETESTC_MSGEARG, 0 );
00276         LALPrintError( USAGE, *argv );
00277         return RESAMPLETESTC_EARG;
00278       }
00279     }
00280     /* Parse debuglevel option. */
00281     else if ( !strcmp( argv[arg], "-d" ) ) {
00282       if ( argc > arg + 1 ) {
00283         arg++;
00284         lalDebugLevel = atoi( argv[arg++] );
00285       } else {
00286         ERROR( RESAMPLETESTC_EARG, RESAMPLETESTC_MSGEARG, 0 );
00287         LALPrintError( USAGE, *argv );
00288         return RESAMPLETESTC_EARG;
00289       }
00290     }
00291     /* Parse power spectrum output option. */
00292     else if ( !strcmp( argv[arg], "-p" ) ) {
00293       if ( argc > arg + 1 ) {
00294         arg++;
00295         psfile = argv[arg++];
00296       } else {
00297         ERROR( RESAMPLETESTC_EARG, RESAMPLETESTC_MSGEARG, 0 );
00298         LALPrintError( USAGE, *argv );
00299         return RESAMPLETESTC_EARG;
00300       }
00301     }
00302     /* Parse timing difference output option. */
00303     else if ( !strcmp( argv[arg], "-t" ) ) {
00304       if ( argc > arg + 1 ) {
00305         arg++;
00306         tfile = argv[arg++];
00307       } else {
00308         ERROR( RESAMPLETESTC_EARG, RESAMPLETESTC_MSGEARG, 0 );
00309         LALPrintError( USAGE, *argv );
00310         return RESAMPLETESTC_EARG;
00311       }
00312     }
00313     /* Unrecognized option. */
00314     else {
00315       ERROR( RESAMPLETESTC_EARG, RESAMPLETESTC_MSGEARG, 0 );
00316       LALPrintError( USAGE, *argv );
00317       return RESAMPLETESTC_EARG;
00318     }
00319   } /* End of argument parsing loop. */
00320 
00321   /* Make sure that parameter values won't crash the system. */
00322   if ( n*dec*f*df*fm == 0 ) {
00323     ERROR( RESAMPLETESTC_EBAD, RESAMPLETESTC_MSGEBAD, 0 );
00324     return RESAMPLETESTC_EBAD;
00325   }
00326   m = n/dec;
00327   df_f = df/f;
00328   twoPiFm = LAL_TWOPI*fm;
00329 
00330   /* Generate modulated time series. */
00331   /* input.name = "Modulated sinusoid"; */
00332   input.deltaT = 1.0;
00333   SUB( LALSCreateVector( &stat, &(input.data), n ), &stat );
00334   {
00335     REAL4 phi_c = LAL_TWOPI*f;      /* Factor preceding tau */
00336     REAL4 *data = input.data->data; /* Generic pointer to data */
00337     for ( i=0; i < n; i++ )
00338       *(data++) = cos( phi_c*( i + TDiff( i ) ) );
00339   }
00340 
00341   /* Create polynomial coefficients. */
00342   {
00343     REAL8 t0; /* Fitting points */
00344     REAL8 dtMax = 2.0*pow( 6.0/DDDTDiffMax(), 1.0/3.0 );
00345     /* Maximum separation between fitting points */
00346     UINT4 n0 = (UINT4)( ( n + 2*BUFFER)/dtMax ) + 1;
00347     /* Number of fits required to span the desired input time */
00348     REAL4 *data1, *data2, *data3; /* Generic pointers to data */
00349     CreateVectorSequenceIn in = emptyCreateVectorSequenceIn;
00350 
00351     /* Set fields of polyco. */
00352     polyco.start.gpsSeconds = (INT4)( -BUFFER );
00353     polyco.start.gpsNanoSeconds = (INT4)
00354       ( 1.0e9*( -BUFFER - polyco.start.gpsSeconds ) );
00355     SUB( LALSCreateVector( &stat, &(polyco.tBound), n0 ), &stat );
00356     SUB( LALSCreateVector( &stat, &(polyco.t0), n0 ), &stat );
00357     in.length = n0;
00358     in.vectorLength = NPOLY;
00359     SUB( LALSCreateVectorSequence( &stat, &(polyco.polyco), &in ),
00360          &stat );
00361     memset( polyco.polyco->data, 0, in.length*in.vectorLength );
00362 
00363     /* Fill in data. */
00364     t0=0.5*dtMax-BUFFER;
00365     data1=polyco.polyco->data;
00366     data2=polyco.tBound->data;
00367     data3=polyco.t0->data;
00368     while( n0-- ) {
00369       data1[0] = TDiff( t0 );
00370       if ( NPOLY > 0 )
00371         data1[1] = DTDiff( t0 );
00372       if ( NPOLY > 1 )
00373         data1[2] = 0.5*DDTDiff( t0 );
00374       data1 += NPOLY;
00375       *(data2++) = t0 + 0.5*dtMax + BUFFER;
00376       *(data3++) = t0 + BUFFER;
00377       t0 += dtMax;
00378     }
00379   }
00380 
00381   /* Generate demodulated time series. */
00382   /* output.name = "Decimated sinusoid"; */
00383   output.deltaT = (REAL8)( dec );
00384   SUB( LALSCreateVector( &stat, &(output.data), m ), &stat );
00385   {
00386     ResampleParamStruc params = emptyResampleParamStruct;
00387     params.start.gpsSeconds = -1;
00388     params.start.gpsNanoSeconds = 0;
00389     params.stop.gpsSeconds = n + 1;
00390     params.stop.gpsNanoSeconds = 0;
00391     params.deltaT = 1.0;
00392     params.decimate = dec;
00393     SUB( LALCreateResampleRules( &stat, &rules, &polyco, &params ),
00394          &stat );
00395     SUB( LALApplyResampleRules( &stat, &output, &input, rules ),
00396          &stat );
00397   }
00398 
00399   /* Print modulation function, if requested. */
00400   if ( tfile ) {
00401     REAL4 *data0, *data1, *data2; /* Pointers to data */
00402     REAL4TimeSeries diffs0 = emptyREAL4TimeSeries;  /* Analytic timing difference */
00403     REAL4TimeSeries diffs1 = emptyREAL4TimeSeries;  /* Polynomial timing difference */
00404     REAL4TimeSeries diffs2 = emptyREAL4TimeSeries;  /* Resampled timing difference */
00405     FILE *fp = fopen( tfile, "w" ); /* Output file pointer */
00406 
00407     /* Make sure output file was created. */
00408     if ( !fp ) {
00409       ERROR( RESAMPLETESTC_EFILE, RESAMPLETESTC_MSGEFILE, 0 );
00410       return RESAMPLETESTC_EFILE;
00411     }
00412 
00413     /* Create the three time series. */
00414     diffs0.deltaT = diffs1.deltaT = diffs2.deltaT = 1.0;
00415     SUB( LALSCreateVector( &stat, &(diffs0.data), n ), &stat );
00416     SUB( LALSCreateVector( &stat, &(diffs1.data), n ), &stat );
00417     SUB( LALSCreateVector( &stat, &(diffs2.data), n ), &stat );
00418 
00419     /* Fill the three time series. */
00420     data0 = diffs0.data->data;
00421     for ( i=0; i < n; i++ )
00422       *(data0++) = TDiff( i );
00423     SUB( LALPolycoToTimingDifference( &stat, &diffs1, &polyco ),
00424          &stat );
00425     SUB( LALRulesToTimingDifference( &stat, &diffs2, rules ), &stat );
00426 
00427     /* Print the result. */
00428     i = n;
00429     data0 = diffs0.data->data;
00430     data1 = diffs1.data->data;
00431     data2 = diffs2.data->data;
00432     for ( i=0; i < n; i++ )
00433       if ( fprintf( fp, "%10i %10.3e %10.3e %10.3e\n", i, *(data0++),
00434                     *(data1++), *(data2++) ) < 44 ) {
00435         ERROR( RESAMPLETESTC_EFILE, RESAMPLETESTC_MSGEFILE, 0 );
00436         return RESAMPLETESTC_EFILE;
00437       }
00438     fclose( fp );
00439 
00440     /* Destroy the three time series. */
00441     SUB( LALSDestroyVector( &stat, &(diffs0.data) ), &stat );
00442     SUB( LALSDestroyVector( &stat, &(diffs1.data) ), &stat );
00443     SUB( LALSDestroyVector( &stat, &(diffs2.data) ), &stat );
00444   }
00445 
00446   /* Destroy polynomial coefficients and resampling rules. */
00447   SUB( LALSDestroyVectorSequence( &stat, &(polyco.polyco) ), &stat );
00448   SUB( LALSDestroyVector( &stat, &(polyco.t0) ), &stat );
00449   SUB( LALSDestroyVector( &stat, &(polyco.tBound) ), &stat );
00450   SUB( LALDestroyResampleRules( &stat, &rules ), &stat );
00451 
00452   /* Write power spectra to output file. */
00453   if ( psfile ) {
00454     REAL4 *data1, *data2;      /* Generic pointers to data */
00455     REAL4Vector *PSIn = NULL;  /* Power spectrum of input */
00456     REAL4Vector *PSOut = NULL; /* Power spectrum of output */
00457     RealFFTPlan *plan = NULL;  /* Plan for computing power spectra */
00458     FILE *fp = fopen( psfile, "w" ); /* Output file pointer */
00459 
00460     /* Make sure output file was created. */
00461     if ( !fp ) {
00462       ERROR( RESAMPLETESTC_EFILE, RESAMPLETESTC_MSGEFILE, 0 );
00463       return RESAMPLETESTC_EFILE;
00464     }
00465 
00466     /* Generate power spectrum of output. */
00467     SUB( LALCreateForwardRealFFTPlan( &stat, &plan, m, 0 ), &stat );
00468     SUB( LALSCreateVector( &stat, &PSOut, m/2 + 1 ), &stat );
00469     SUB( LALRealPowerSpectrum( &stat, PSOut, output.data, plan ),
00470          &stat );
00471     /* CHANGE BACK TO ORIGINAL NORMALIZATION -- JC */
00472     {
00473       REAL4Vector *myvector = PSOut;
00474       UINT4 mybin;
00475       for ( mybin = 1; mybin < myvector->length - 1; ++mybin )
00476         myvector->data[mybin] *= 0.5;
00477     }
00478 
00479 
00480     /* Create a new output that is a decimated but not demodulated
00481        data set, then discard the initial input. */
00482     for ( i=0, data1=input.data->data, data2=output.data->data; i < m;
00483           i++, data1+=dec, data2++ )
00484       *data2 = *data1;
00485     SUB( LALSDestroyVector( &stat, &(input.data) ), &stat );
00486 
00487     /* Generate its power spectrum, then discard time series data (and
00488        the FFT plan). */
00489     SUB( LALSCreateVector( &stat, &PSIn, m/2 + 1 ), &stat );
00490     SUB( LALRealPowerSpectrum( &stat, PSIn, output.data, plan ),
00491          &stat );
00492     SUB( LALSDestroyVector( &stat, &(output.data) ), &stat );
00493     SUB( LALDestroyRealFFTPlan( &stat, &plan ), &stat );
00494 
00495     /* Print both power spectra to the output file and close it. */
00496     data1 = PSIn->data;
00497     data2 = PSOut->data;
00498     for ( i = 0; i <= m/2; i++ )
00499       if ( fprintf( fp, "%10i %10.3e %10.3e\n", i, *(data1++),
00500                     *(data2++) ) < 33 ) {
00501         ERROR( RESAMPLETESTC_EFILE, RESAMPLETESTC_MSGEFILE, 0 );
00502         return RESAMPLETESTC_EFILE;
00503       }
00504     fclose( fp );
00505 
00506     /* Free local memory. */
00507     SUB( LALSDestroyVector( &stat, &PSIn ), &stat );
00508     SUB( LALSDestroyVector( &stat, &PSOut ), &stat );
00509   }
00510 
00511   /* Since the ``if'' branch freed the input and output time series,
00512      this needs to be repeated even if output was not requested.  (The
00513      reason for not collecting these operation after the two branches
00514      rejoined is that I wanted to keep as much memory free as possible
00515      when creating the power spectra, in case this program is run with
00516      huge datasets.) */
00517   else {
00518     SUB( LALSDestroyVector( &stat, &(input.data) ), &stat );
00519     SUB( LALSDestroyVector( &stat, &(output.data) ), &stat );
00520   }
00521 
00522   /* Test program executed successfully!  (User will have to examine
00523      the output file, if any, to determine that the algorithm achieved
00524      the correct result.) */
00525   LALCheckMemoryLeaks();
00526   INFO( RESAMPLETESTC_MSGENORM );
00527   return RESAMPLETESTC_ENORM;
00528 }
00529 
00530 
00531 REAL8
00532 TDiff( REAL8 t )
00533 {
00534   return df_f*sin( twoPiFm*t )/twoPiFm;
00535 }
00536 
00537 
00538 REAL8
00539 DTDiff( REAL8 t )
00540 {
00541   return df_f*cos( twoPiFm*t );
00542 }
00543 
00544 
00545 REAL8
00546 DDTDiff( REAL8 t )
00547 {
00548   return -df_f*twoPiFm*sin( twoPiFm*t );
00549 }
00550 
00551 
00552 REAL8
00553 DDDTDiffMax( void )
00554 {
00555   return df_f*twoPiFm*twoPiFm;
00556 }

Generated on Sun Sep 7 03:07:09 2008 for LAL by  doxygen 1.5.2