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 #include <bpm/bpm_wf.h>
00011
00018 int add_amplnoise( double amplnoise, complexwf_t *IF ) {
00019
00020
00021 int i;
00022 double mag, phase;
00023 complex_t c;
00024 complexwf_t *noise = complexwf( IF->ns, IF->fs );
00025
00026 if ( ! IF ) {
00027 bpm_error( "Invalid pointer arguments in add_amplnoise(...)",
00028 __FILE__, __LINE__ );
00029 return BPM_FAILURE;
00030 }
00031
00032 for ( i = 0; i < IF->ns; i++ ) {
00033
00034 mag = nr_rangauss( 0, amplnoise );
00035 phase = nr_ranuniform( 0, 2*PI );
00036 c.re = mag * cos (phase);
00037 c.im = mag * sin (phase);
00038 IF->wf[i] = c_sum( IF->wf[i], c );
00039
00040 }
00041
00042 complexwf_delete( noise );
00043
00044 return BPM_SUCCESS;
00045 }
00046
00047