bpmprocess/ddc_gaussfilter_step.c

Go to the documentation of this file.
00001 
00006 #include <math.h>
00007 #include <bpm/bpm_messages.h>
00008 #include <bpm/bpm_process.h>
00009 
00025 int ddc_gaussfilter_step( double **ddc, int ns, double fs, int istart, int istop, 
00026                           double tfilter, double filtBW, double *out ) {
00027   
00028   int i;
00029   double ti, omega;
00030 
00031   if ( ! out ) {
00032     bpm_error( "Invalid pointer in gaussfilter_step(...)",
00033                __FILE__, __LINE__ );
00034     return BPM_FAILURE;
00035   }
00036   
00037   if ( istart < 0 ) {
00038     istart = 0;
00039     bpm_warning( "Setting istart to 0 in gaussfilter_step(...)", __FILE__, __LINE__ );
00040   }
00041 
00042   if ( istop > ns ) {
00043     istop = ns;
00044     bpm_warning( "Setting istop to ns in gaussfilter_step(...)", __FILE__, __LINE__ );
00045   }
00046   
00047   // reset values
00048   out[Re] = 0.;
00049   out[Im] = 0.;
00050 
00051   // convert filter bandwith from MHz to rad/usec
00052   omega = 2. * PI * filtBW;
00053 
00054   // perform one filter step between istart and istop
00055   for( i=istart; i<istop; i++ ) {
00056 
00057     if ( sample_to_time( fs, ns, i, &ti ) == BPM_FAILURE ) {
00058       bpm_error( "Unable to get time from sample in gaussfilter_step(...)",
00059                  __FILE__, __LINE__ );
00060       return BPM_FAILURE;
00061     }
00062 
00063     out[Re] += ddc[i][Re] * omega * exp( -SQR( omega * ( ti - tfilter) ) / 2. ) / sqrt( 2.*PI );
00064     out[Im] += ddc[i][Im] * omega * exp( -SQR( omega * ( ti - tfilter) ) / 2. ) / sqrt( 2.*PI );
00065 
00066   }
00067 
00068   return BPM_SUCCESS;
00069 }

Generated on Fri Nov 9 21:17:11 2007 for libbpm by  doxygen 1.5.1