bpmsimulation/add_amplnoise.c

Go to the documentation of this file.
00001 
00006 #include <bpm/bpm_messages.h>
00007 #include <bpm/bpm_simulation.h>
00008 #include <bpm/bpm_rf.h>
00009 #include <bpm/bpm_nr.h>
00010 
00020 int add_amplnoise( double amplnoise, double *IF_Re, double *IF_Im ) {
00021 
00022 
00023   int i;
00024   double mag, phase;
00025 
00026   if ( ! IF_Re || ! IF_Im ) {
00027     bpm_error( "Invalid pointer arguments in add_amplnoise(...)", 
00028                __FILE__, __LINE__ );
00029     return BPM_FAILURE;
00030   }
00031 
00032   for ( i = 0; i < rf_nsamples; i++ ) {
00033 
00034     mag = nr_rangauss( 0, amplnoise );
00035     phase = nr_ranuniform( 0, 2 * PI );
00036 
00037     IF_Re[i] += mag * cos (phase);
00038     IF_Im[i] += mag * sin (phase);
00039 
00040   }
00041 
00042   return BPM_SUCCESS;
00043 }
00044 
00045 // end of file

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