00001 00034 #ifndef CHANNEL_H 00035 #define CHANNEL_H 00036 00037 #include <itpp/base/vec.h> 00038 #include <itpp/base/mat.h> 00039 #include <itpp/base/array.h> 00040 #include <itpp/base/random.h> 00041 #include <itpp/base/filter.h> 00042 00043 00044 namespace itpp { 00045 00166 vec jake_filter(double NormFDopp, int order = 100); 00167 00172 enum DOPPLER_SPECTRUM {Jakes=0,J=0,Classic=0,C=0, GaussI=1,GI=1,G1=1, GaussII=2,GII=2,G2=2, Rice=3,R=3}; 00173 00178 enum RICE_METHOD {MEDS}; 00179 00185 enum FADING_GENERATION_METHOD {IFFT, FIR, Rice_MEDS}; 00186 00191 enum CHANNEL_PROFILE {ITU_Vehicular_A, ITU_Vehicular_B, ITU_Pedestrian_A, ITU_Pedestrian_B, 00192 COST207_RA, COST207_RA6, 00193 COST207_TU, COST207_TU6alt, COST207_TU12, COST207_TU12alt, 00194 COST207_BU, COST207_BU6alt, COST207_BU12, COST207_BU12alt, 00195 COST207_HT, COST207_HT6alt, COST207_HT12, COST207_HT12alt, 00196 COST259_TUx, COST259_RAx, COST259_HTx}; 00197 00221 class Fading_Generator { 00222 public: 00223 Fading_Generator(const double norm_doppler=0.0, const DOPPLER_SPECTRUM spectrum=Jakes); 00224 virtual ~Fading_Generator(){ } 00225 00227 void set_norm_doppler(const double norm_doppler); 00229 void set_doppler_spectrum(const DOPPLER_SPECTRUM spectrum); 00231 void set_LOS(const double relative_power, const double relative_doppler); 00232 00234 double get_norm_doppler() { return n_dopp; } 00236 DOPPLER_SPECTRUM get_doppler_spectrum() { return dopp_spectrum; } 00238 double get_LOS_power() { return los_power; } 00240 double get_LOS_doppler() { return los_dopp; } 00241 00243 virtual void init() = 0; 00244 00246 virtual void generate(const int no_samples, cvec &output) = 0; 00248 cvec generate(const int no_samples); 00249 00251 virtual void generate(const int no_samples, const int upsampling_factor, cvec &output) = 0; 00253 cvec generate(const int no_samples, const int upsampling_factor); 00254 00256 void shift_time_offset(const int no_samples); 00257 00258 protected: 00259 DOPPLER_SPECTRUM dopp_spectrum; // doppler spectrum 00260 double n_dopp; // normalized doppler 00261 double los_dopp; // relative doppler on LOS-component 00262 double los_power; // Relative power of LOS component compared to diffuse component = Rice factor < 1 00263 bool init_flag; // signals if generator is initialized or not 00264 double time_offset; // time offset in samples (the time state in the generator, not used in the filter method other than for LOS) 00265 void generate_zero_doppler(const int no_samples, cvec &output); // generate fading for n_dopp == 0.0 00266 void generate_zero_doppler(const int no_samples, const int upsampling_factor, cvec &output); // generate fading for n_dopp == 0.0 00267 }; 00268 00301 class Rice_Fading_Generator : public Fading_Generator { 00302 public: 00304 Rice_Fading_Generator(const double norm_doppler = 0.0, const DOPPLER_SPECTRUM spectrum = Jakes, 00305 const int no_freq = 16, const RICE_METHOD method=MEDS); 00307 virtual ~Rice_Fading_Generator(){ } 00308 00310 void set_no_frequencies(const int no_freq); 00312 void set_method(const RICE_METHOD method); 00314 int get_no_frequencies(); 00316 RICE_METHOD get_method(); 00317 00319 virtual void init(); 00320 00322 void set_time_offset(const int offset); 00324 double get_time_offset(); 00325 00327 virtual void generate(const int no_samples, cvec &output); 00329 virtual void generate(const int no_samples, const int upsampling_factor, cvec &output); 00330 00332 //virtual cvec generate(const int no_samples); 00333 00334 protected: 00335 int Ni; 00336 RICE_METHOD rice_method; 00337 vec f1, f2, c1, c2, th1, th2; // doppler frequencies, amplitudes and phases (need to be initialized) 00338 00340 void init_MEDS(); 00341 }; 00342 00367 class FIR_Fading_Generator : public Fading_Generator { 00368 public: 00369 // Set normalized dopper, doppler spectrum, length of FIR filter and calculation method 00370 FIR_Fading_Generator(const double norm_doppler = 0.0, const DOPPLER_SPECTRUM spectrum = Jakes, const int filter_length = 500); 00371 // Destructor 00372 virtual ~FIR_Fading_Generator(){ } 00373 00375 void set_filter_length(const int filter_length); 00377 int get_filter_length(); 00378 00380 virtual void init(); 00381 00383 virtual void generate(const int no_samples, cvec &output); 00385 virtual void generate(const int no_samples, const int upsampling_factor, cvec &output); 00387 //virtual cvec generate(const int no_samples); 00388 00389 protected: 00390 int fir_length; // size of FIR filter 00391 int upsample_rate; // upsampling rate for linear interpolation 00392 MA_Filter<std::complex<double>, double, std::complex<double> > fir_filter; 00393 cvec left_overs; // left-overs from upsampling 00394 }; 00395 00422 class IFFT_Fading_Generator : public Fading_Generator { 00423 public: 00424 // Set normalized dopper, doppler spectrum, length of FIR filter and calculation method 00425 IFFT_Fading_Generator(const double norm_doppler = 0.0, const DOPPLER_SPECTRUM spectrum = Jakes); 00426 // Destructor 00427 virtual ~IFFT_Fading_Generator(){ } 00428 00430 virtual void init(); 00431 00433 virtual void generate(const int no_samples, cvec &output); 00435 virtual void generate(const int no_samples, const int upsampling_factor, cvec &output); 00437 //virtual cvec generate(const int no_samples); 00438 00439 protected: 00441 void generate_Jakes(const int no_samples, cvec &output); 00442 00443 }; 00444 00519 class Channel_Specification { 00520 public: 00521 00523 Channel_Specification(const vec &avg_power_dB="0", const vec &delay_prof="0"); 00525 Channel_Specification(const CHANNEL_PROFILE profile); 00527 virtual ~Channel_Specification() { } 00528 00530 void set_channel_profile(const vec &avg_power_dB="0", const vec &delay_prof="0"); 00532 void set_channel_profile(const CHANNEL_PROFILE profile); 00533 00535 void set_doppler_spectrum(DOPPLER_SPECTRUM *tap_spectrum); 00537 void set_doppler_spectrum(const int tap_number, DOPPLER_SPECTRUM tap_spectrum); 00538 00542 void set_LOS(const double relative_power, const double relative_doppler); 00543 00545 void get_channel_profile(vec &avg_power_dB, vec &delay_prof); 00546 00548 vec get_avg_power_dB(); 00550 vec get_delay_prof(); 00552 DOPPLER_SPECTRUM get_doppler_spectrum(const int index); 00554 double get_LOS_power(); 00556 double get_LOS_doppler(); 00557 00559 int taps() { return N_taps; } 00560 00562 double calc_mean_excess_delay(); 00564 double calc_rms_delay_spread(); 00565 00567 bool is_discrete() { return discrete; } 00569 double get_discrete_Ts() { return discrete_Ts; } 00570 00572 void discretize(const double Ts); 00573 00574 protected: 00575 vec a_prof_dB, d_prof; 00576 Array<DOPPLER_SPECTRUM> tap_doppler_spectrum; // doppler spectrum for each tap 00577 int N_taps; 00578 double los_dopp; // doppler on LOS-component 00579 double los_power; // power on LOS-component 00580 bool discrete; // true if channel profile has been dicretized 00581 double discrete_Ts; // the sample time of discretization 00582 }; 00583 00584 00585 00670 class TDL_Channel { 00671 public: 00673 TDL_Channel(const double norm_doppler=0.0, const vec &avg_power_dB="0", const ivec &delay_prof="0"); 00675 TDL_Channel(Channel_Specification &channel_spec); 00677 virtual ~TDL_Channel(); 00678 00680 void set_channel_profile(const vec &avg_power_dB="0", const ivec &delay_prof="0"); 00682 void set_channel_profile_uniform(const int no_taps); 00684 void set_channel_profile_exponential(int no_taps); 00686 void set_channel_profile(Channel_Specification &channel_spec); 00687 00689 void set_norm_doppler(const double norm_doppler); 00691 void set_doppler_spectrum(DOPPLER_SPECTRUM *tap_spectrum); 00692 00694 void set_LOS(const double relative_power, const double norm_doppler); 00695 00697 void set_generation_method(const FADING_GENERATION_METHOD method=Rice_MEDS); 00698 00700 int taps() { return N_taps; } 00702 void get_channel_profile(vec &avg_power_dB, ivec &delay_prof); 00704 vec get_avg_power_dB(); 00706 ivec get_delay_prof(); 00708 double get_norm_doppler(); 00710 double get_LOS_power(); 00712 double get_LOS_doppler(); 00714 FADING_GENERATION_METHOD get_generation_method(); 00715 00717 double calc_mean_excess_delay(); 00719 double calc_rms_delay_spread(); 00720 00722 void init(); 00723 00725 virtual void generate(const int no_samples, Array<cvec> &channel_coeff); 00727 virtual void generate(const int no_samples, cmat &channel_coeff); 00729 virtual void generate(const int no_samples, const int upsampling_factor, Array<cvec> &channel_coeff); 00731 virtual void generate(const int no_samples, const int upsampling_factor, cmat &channel_coeff); 00732 00734 void shift_time_offset(const int no_samples); 00735 00737 void filter_known_channel(const cvec &input, cvec &output, const Array<cvec> &channel_coeff); 00739 void filter_known_channel(const cvec &input, cvec &output, const cmat &channel_coeff); 00740 00742 void filter(const cvec &input, cvec &output, Array<cvec> &channel_coeff); 00744 void filter(const cvec &input, cvec &output, cmat &channel_coeff); 00746 cvec filter(const cvec &input, Array<cvec> &channel_coeff); 00748 cvec filter(const cvec &input, cmat &channel_coeff); 00750 void filter(const cvec &input, cvec &output); 00752 cvec filter(const cvec &input); 00753 00755 void operator()(const cvec &input, cvec &output, Array<cvec> &channel_coeff); 00757 void operator()(const cvec &input, cvec &output, cmat &channel_coeff); 00759 cvec operator()(const cvec &input, Array<cvec> &channel_coeff); 00761 cvec operator()(const cvec &input, cmat &channel_coeff); 00763 cvec operator()(const cvec &input); 00764 00766 void calc_impulse_response(const Array<cvec> &channel_coeff, Array<cvec> &impulse_response); 00767 00769 void calc_frequency_response(const Array<cvec> &channel_coeff, Array<cvec> &frequency_response, const int fft_size); 00771 void calc_frequency_response(const cmat &channel_coeff, cmat &frequency_response, const int fft_size); 00772 00773 00774 protected: 00775 vec a_prof; // average amplitude of each tap 00776 ivec d_prof; // delay in samples for each tap 00777 int N_taps; // number of taps 00778 double n_dopp; // normalized doppler 00779 double los_dopp; // doppler on LOS-component 00780 double los_power; // power on LOS-component 00781 Array<DOPPLER_SPECTRUM> tap_doppler_spectrum; // doppler spectrum for each tap 00782 Array<Fading_Generator *> fading_gen; // fading generators 00783 FADING_GENERATION_METHOD method; // generation method 00784 bool init_flag; // Channel ready to produce data 00785 }; 00786 00787 00788 00807 class BSC { 00808 public: 00810 BSC(double in_p=0.0) : u(0.0, 1.0) { p = in_p; }; 00812 void set_prob(double in_p) { p = in_p; }; 00814 double get_prob() const { return p; }; 00816 bvec operator()(const bvec &input); 00817 private: 00818 Uniform_RNG u; 00819 double p; 00820 }; 00821 00822 00823 00857 class AWGN_Channel { 00858 public: 00860 AWGN_Channel(double noisevar = 0.0) { sigma = std::sqrt(noisevar); } 00862 void set_noise(double noisevar) { sigma = std::sqrt(noisevar); } 00864 double get_noise() { return sqr(sigma); } 00866 cvec operator()(const cvec &input); 00868 vec operator()(const vec &input); 00869 protected: 00871 double sigma; 00872 }; 00873 00874 00875 00876 } // namespace itpp 00877 00878 #endif // #ifndef CHANNEL_H
Generated on Fri Jun 8 00:37:34 2007 for IT++ by Doxygen 1.5.2