IT++ Logo
channel.h
Go to the documentation of this file.
1 
29 #ifndef CHANNEL_H
30 #define CHANNEL_H
31 
32 #include <iostream>
34 #include <itpp/base/mat.h>
35 #include <itpp/base/array.h>
36 #include <itpp/base/random.h>
37 #include <itpp/signal/filter.h>
38 #include <itpp/itexports.h>
39 
186 namespace itpp
187 {
188 
190 
191 
194  ITU_Vehicular_A, ITU_Vehicular_B, ITU_Pedestrian_A, ITU_Pedestrian_B,
195  COST207_RA, COST207_RA6,
196  COST207_TU, COST207_TU6alt, COST207_TU12, COST207_TU12alt,
197  COST207_BU, COST207_BU6alt, COST207_BU12, COST207_BU12alt,
198  COST207_HT, COST207_HT6alt, COST207_HT12, COST207_HT12alt,
199  COST259_TUx, COST259_RAx, COST259_HTx
200 };
201 
203 enum FADING_TYPE { Independent, Static, Correlated };
204 
206 enum CORRELATED_METHOD { Rice_MEDS, IFFT, FIR };
207 
209 enum RICE_METHOD { MEDS };
210 
213  Jakes = 0, J = 0, Classic = 0, C = 0,
214  GaussI = 1, Gauss1 = 1, GI = 1, G1 = 1,
215  GaussII = 2, Gauss2 = 2, GII = 2, G2 = 2
216 };
217 
218 
228 class ITPP_EXPORT Fading_Generator
229 {
230 public:
234  virtual ~Fading_Generator() {}
235 
237  void set_LOS_power(double relative_power);
239  virtual void set_LOS_doppler(double relative_doppler);
241  virtual void set_time_offset(int offset);
243  virtual void set_filter_length(int filter_length);
245  virtual void set_norm_doppler(double norm_doppler);
247  virtual void set_doppler_spectrum(DOPPLER_SPECTRUM spectrum);
249  virtual void set_no_frequencies(int no_freq);
251  virtual void set_rice_method(RICE_METHOD method);
252 
254  double get_LOS_power() const { return los_power; }
256  virtual double get_LOS_doppler() const;
258  virtual double get_time_offset() const;
260  virtual int get_filter_length() const;
262  virtual double get_norm_doppler() const;
264  virtual DOPPLER_SPECTRUM get_doppler_spectrum() const;
266  virtual int get_no_frequencies() const;
268  virtual RICE_METHOD get_rice_method() const;
269 
271  virtual void shift_time_offset(int no_samples);
272 
274  virtual void init() = 0;
275 
277  virtual void generate(int no_samples, cvec &output) = 0;
279  cvec generate(int no_samples);
280 
281 protected:
282  bool init_flag;
283  double los_power;
284  double los_diffuse;
285  double los_direct;
286 };
287 
289 
290 #if (!defined(_MSC_VER) || (defined(_MSC_VER) && defined (ITPP_SHARED_LIB)))
291 //define two input stream operators for data types involved
292 //otherwise explicit instantiation of Array is impossible
293 inline std::istream& operator>>(std::istream& is, Fading_Generator* &pfg)
294 {
295  void* p; is>>p;
296  if(is) pfg = (Fading_Generator*)p;
297  return is;
298 }
299 
300 inline std::istream& operator>>(std::istream& is, DOPPLER_SPECTRUM& sp)
301 {
302  int val; is>>val;
303  if(!is) return is;
304  if(val > 0 && val <= G2) sp = (DOPPLER_SPECTRUM)val;
305  else is.setstate(std::ios_base::failbit);
306  return is;
307 }
308 
309 //MSVC explicitly instantiate required template while building the shared library
310 template class ITPP_EXPORT Array<DOPPLER_SPECTRUM>;
311 template class ITPP_EXPORT Array<Fading_Generator*>;
312 #endif
313 
315 
325 {
326 public:
331 
333  virtual void init() { init_flag = true; }
334 
336 
338  virtual void generate(int no_samples, cvec& output);
339 };
340 
341 
351 class ITPP_EXPORT Static_Fading_Generator : public Fading_Generator
352 {
353 public:
358 
360  virtual void init();
361 
363 
365  virtual void generate(int no_samples, cvec& output);
366 
367 protected:
369  double static_sample_re; double static_sample_im;
370 };
371 
372 
386 {
387 public:
389  Correlated_Fading_Generator(double norm_doppler);
392 
394  virtual void set_norm_doppler(double norm_doppler);
396  virtual void set_LOS_doppler(double relative_doppler);
398  virtual void set_time_offset(int offset);
399 
401  virtual double get_norm_doppler() const { return n_dopp; }
403  virtual double get_LOS_doppler() const { return los_dopp; }
405  virtual double get_time_offset() const { return time_offset; }
406 
408  virtual void shift_time_offset(int no_samples);
409 
411  virtual void init() = 0;
412 
414 
416  virtual void generate(int no_samples, cvec& output) = 0;
417 
418 protected:
419  double n_dopp;
420  double los_dopp;
421  double time_offset;
422 
424  void add_LOS(int idx, std::complex<double>& sample);
425 };
426 
427 
463 {
464 public:
466  Rice_Fading_Generator(double norm_doppler, DOPPLER_SPECTRUM spectrum = Jakes,
467  int no_freq = 16, RICE_METHOD method = MEDS);
470 
472  virtual void set_doppler_spectrum(DOPPLER_SPECTRUM spectrum);
474  virtual void set_no_frequencies(int no_freq);
476  virtual void set_rice_method(RICE_METHOD method);
477 
479  virtual DOPPLER_SPECTRUM get_doppler_spectrum() const { return dopp_spectrum; }
481  virtual int get_no_frequencies() const { return Ni; }
483  virtual RICE_METHOD get_rice_method() const { return rice_method; }
484 
486  virtual void init();
487 
489 
491  virtual void generate(int no_samples, cvec &output);
492 
493 protected:
495 
496  int Ni;
501  vec f1, f2, c1, c2, th1, th2;
505  double f01, f02;
508 
509  void init_MEDS();
510 };
511 
512 
532 {
533 public:
535  FIR_Fading_Generator(double norm_doppler, int filter_length = 500);
538 
540  virtual void set_filter_length(int filter_length);
542  virtual int get_filter_length() const { return fir_length; }
543 
545  virtual void init();
546 
548 
550  virtual void generate(int no_samples, cvec &output);
551 
552 protected:
555 
556  MA_Filter<std::complex<double>, double, std::complex<double> > fir_filter;
557  cvec left_overs;
558 
569  vec Jakes_filter(double norm_dopp, int order = 100);
570 };
571 
572 
598 {
599 public:
601  IFFT_Fading_Generator(double norm_doppler) :
602  Correlated_Fading_Generator(norm_doppler) {}
605 
607  virtual void init() { init_flag = true; }
608 
610 
612  virtual void generate(int no_samples, cvec &output);
613 
614 protected:
616  void generate_Jakes(int no_samples, cvec &output);
617 };
618 
619 
691 class ITPP_EXPORT Channel_Specification
692 {
693 public:
695  Channel_Specification(const vec &avg_power_dB = "0", const vec &delay_prof = "0");
697  Channel_Specification(const CHANNEL_PROFILE profile);
700 
702  void set_channel_profile(const vec &avg_power_dB, const vec &delay_prof);
704  void set_channel_profile(const CHANNEL_PROFILE profile);
705 
707  void set_doppler_spectrum(DOPPLER_SPECTRUM *tap_spectrum);
709  void set_doppler_spectrum(int tap_number, DOPPLER_SPECTRUM tap_spectrum);
710 
712  void set_LOS(int tap_number, double relative_power, double relative_doppler = 0.7);
714  void set_LOS(const vec& relative_power, const vec& relative_doppler = "");
715 
717  void get_channel_profile(vec &avg_power_dB, vec &delay_prof) const;
719  vec get_avg_power_dB() const { return a_prof_dB; }
721  vec get_delay_prof() const { return d_prof; }
723  Array<DOPPLER_SPECTRUM> get_doppler_spectrum() const { return tap_doppler_spectrum; }
725  DOPPLER_SPECTRUM get_doppler_spectrum(int index) const;
727  vec get_LOS_power() const { return los_power; }
729  vec get_LOS_doppler() const { return los_dopp; }
731  double get_LOS_power(int tap_number) const { return los_power(tap_number); }
733  double get_LOS_doppler(int tap_number) const { return los_dopp(tap_number); }
734 
736  int taps() const { return N_taps; }
737 
739  double calc_mean_excess_delay() const;
741  double calc_rms_delay_spread() const;
742 
743 protected:
744  vec a_prof_dB;
745  vec d_prof;
747  int N_taps;
748  vec los_power;
749  vec los_dopp;
750 };
751 
752 
852 class ITPP_EXPORT TDL_Channel
853 {
854 public:
856  TDL_Channel(const vec &avg_power_dB = "0", const ivec &delay_prof = "0");
858  TDL_Channel(const Channel_Specification &channel_spec, double sampling_time);
860  virtual ~TDL_Channel();
861 
863  void set_channel_profile(const vec &avg_power_dB, const ivec &delay_prof);
865  void set_channel_profile_uniform(int no_taps);
867  void set_channel_profile_exponential(int no_taps);
869  void set_channel_profile(const Channel_Specification &channel_spec, double sampling_time);
870 
872  void set_correlated_method(CORRELATED_METHOD method);
874  void set_fading_type(FADING_TYPE fading_type);
875 
877  void set_norm_doppler(double norm_doppler);
878 
880  void set_LOS(const vec& relative_power, const vec& relative_doppler = "");
882  void set_LOS_power(const vec& relative_power);
884  void set_LOS_doppler(const vec& relative_doppler);
885 
887  void set_doppler_spectrum(const DOPPLER_SPECTRUM *tap_spectrum);
889  void set_doppler_spectrum(int tap_number, DOPPLER_SPECTRUM tap_spectrum);
891  void set_no_frequencies(int no_freq);
892 
894  void set_time_offset(int offset);
896  void shift_time_offset(int no_samples);
897 
899  void set_filter_length(int filter_length);
900 
901 
903  int taps() const { return N_taps; }
904 
906  void get_channel_profile(vec &avg_power_dB, ivec &delay_prof) const;
908  vec get_avg_power_dB() const;
910  ivec get_delay_prof() const { return d_prof; }
911 
913  CORRELATED_METHOD get_correlated_method() const { return method; }
915  FADING_TYPE get_fading_type() const { return fading_type; }
916 
918  double get_norm_doppler() const { return n_dopp; }
919 
921  vec get_LOS_power() const { return los_power; }
923  vec get_LOS_doppler() const { return los_dopp; }
925  double get_LOS_power(int tap_number) const { return los_power(tap_number); }
927  double get_LOS_doppler(int tap_number) const { return los_dopp(tap_number); }
928 
930  int get_no_frequencies() const { return nrof_freq; }
931 
933  double get_time_offset() const;
934 
936  double calc_mean_excess_delay() const;
938  double calc_rms_delay_spread() const;
939 
941  void init();
942 
944  void generate(int no_samples, Array<cvec> &channel_coeff);
946  void generate(int no_samples, cmat &channel_coeff);
947 
949  void filter_known_channel(const cvec &input, cvec &output, const Array<cvec> &channel_coeff);
951  void filter_known_channel(const cvec &input, cvec &output, const cmat &channel_coeff);
952 
954  void filter(const cvec &input, cvec &output, Array<cvec> &channel_coeff);
956  void filter(const cvec &input, cvec &output, cmat &channel_coeff);
958  cvec filter(const cvec &input, Array<cvec> &channel_coeff);
960  cvec filter(const cvec &input, cmat &channel_coeff);
962  void filter(const cvec &input, cvec &output);
964  cvec filter(const cvec &input);
965 
967  void operator()(const cvec &input, cvec &output, Array<cvec> &channel_coeff);
969  void operator()(const cvec &input, cvec &output, cmat &channel_coeff);
971  cvec operator()(const cvec &input, Array<cvec> &channel_coeff);
973  cvec operator()(const cvec &input, cmat &channel_coeff);
975  cvec operator()(const cvec &input);
976 
978  void calc_impulse_response(const Array<cvec> &channel_coeff, Array<cvec> &impulse_response);
979 
981  void calc_frequency_response(const Array<cvec> &channel_coeff, Array<cvec> &frequency_response, const int fft_size);
983  void calc_frequency_response(const cmat &channel_coeff, cmat &frequency_response, const int fft_size);
985  double get_sampling_time() const { return discrete_Ts; }
986 
987 protected:
988  bool init_flag;
989  vec a_prof;
990  ivec d_prof;
991  vec los_power;
992  vec los_dopp;
993  int N_taps;
994  double n_dopp;
1001  double discrete_Ts;
1002 
1009  void discretize(const vec &delay_profile);
1010 };
1011 
1012 
1013 
1032 class ITPP_EXPORT BSC
1033 {
1034 public:
1036  BSC(double in_p = 0.0) : u(0.0, 1.0) { p = in_p; };
1038  void set_prob(double in_p) { p = in_p; };
1040  double get_prob() const { return p; };
1042  bvec operator()(const bvec &input);
1043 private:
1044  Uniform_RNG u;
1045  double p;
1046 };
1047 
1048 
1049 
1083 class ITPP_EXPORT AWGN_Channel
1084 {
1085 public:
1087  AWGN_Channel(double noisevar = 0.0): sigma(std::sqrt(noisevar)) {}
1089  void set_noise(double noisevar) { sigma = std::sqrt(noisevar); }
1091  double get_noise() const { return sqr(sigma); }
1093  cvec operator()(const cvec &input);
1095  vec operator()(const vec &input);
1096 private:
1097  Complex_Normal_RNG rng_cn;
1098  Normal_RNG rng_n;
1099  double sigma;
1100 };
1101 
1103 
1104 } // namespace itpp
1105 
1106 #endif // #ifndef CHANNEL_H
SourceForge Logo

Generated on Sat May 25 2013 16:32:20 for IT++ by Doxygen 1.8.2