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;
296  is >> p;
297  if(is) pfg = (Fading_Generator*)p;
298  return is;
299 }
300 
301 inline std::istream& operator>>(std::istream& is, DOPPLER_SPECTRUM& sp)
302 {
303  int val;
304  is >> val;
305  if(!is) return is;
306  if(val > 0 && val <= G2) sp = (DOPPLER_SPECTRUM)val;
307  else is.setstate(std::ios_base::failbit);
308  return is;
309 }
310 
311 //MSVC explicitly instantiate required template while building the shared library
312 #ifdef _WIN32
313 template class ITPP_EXPORT Array<DOPPLER_SPECTRUM>;
314 template class ITPP_EXPORT Array<Fading_Generator*>;
315 #endif
316 #endif
317 
319 
329 {
330 public:
335 
337  virtual void init() { init_flag = true; }
338 
340 
342  virtual void generate(int no_samples, cvec& output);
343 };
344 
345 
355 class ITPP_EXPORT Static_Fading_Generator : public Fading_Generator
356 {
357 public:
362 
364  virtual void init();
365 
367 
369  virtual void generate(int no_samples, cvec& output);
370 
371 protected:
374  double static_sample_im;
375 };
376 
377 
391 {
392 public:
394  Correlated_Fading_Generator(double norm_doppler);
397 
399  virtual void set_norm_doppler(double norm_doppler);
401  virtual void set_LOS_doppler(double relative_doppler);
403  virtual void set_time_offset(int offset);
404 
406  virtual double get_norm_doppler() const { return n_dopp; }
408  virtual double get_LOS_doppler() const { return los_dopp; }
410  virtual double get_time_offset() const { return time_offset; }
411 
413  virtual void shift_time_offset(int no_samples);
414 
416  virtual void init() = 0;
417 
419 
421  virtual void generate(int no_samples, cvec& output) = 0;
422 
423 protected:
424  double n_dopp;
425  double los_dopp;
426  double time_offset;
427 
429  void add_LOS(int idx, std::complex<double>& sample);
430 };
431 
432 
468 {
469 public:
471  Rice_Fading_Generator(double norm_doppler, DOPPLER_SPECTRUM spectrum = Jakes,
472  int no_freq = 16, RICE_METHOD method = MEDS);
475 
477  virtual void set_doppler_spectrum(DOPPLER_SPECTRUM spectrum);
479  virtual void set_no_frequencies(int no_freq);
481  virtual void set_rice_method(RICE_METHOD method);
482 
484  virtual DOPPLER_SPECTRUM get_doppler_spectrum() const { return dopp_spectrum; }
486  virtual int get_no_frequencies() const { return Ni; }
488  virtual RICE_METHOD get_rice_method() const { return rice_method; }
489 
491  virtual void init();
492 
494 
496  virtual void generate(int no_samples, cvec &output);
497 
498 protected:
500 
501  int Ni;
506  vec f1, f2, c1, c2, th1, th2;
510  double f01, f02;
513 
514  void init_MEDS();
515 };
516 
517 
537 {
538 public:
540  FIR_Fading_Generator(double norm_doppler, int filter_length = 500);
543 
545  virtual void set_filter_length(int filter_length);
547  virtual int get_filter_length() const { return fir_length; }
548 
550  virtual void init();
551 
553 
555  virtual void generate(int no_samples, cvec &output);
556 
557 protected:
560 
561  MA_Filter<std::complex<double>, double, std::complex<double> > fir_filter;
562  cvec left_overs;
563 
574  vec Jakes_filter(double norm_dopp, int order = 100);
575 };
576 
577 
603 {
604 public:
606  IFFT_Fading_Generator(double norm_doppler) :
607  Correlated_Fading_Generator(norm_doppler) {}
610 
612  virtual void init() { init_flag = true; }
613 
615 
617  virtual void generate(int no_samples, cvec &output);
618 
619 protected:
621  void generate_Jakes(int no_samples, cvec &output);
622 };
623 
624 
696 class ITPP_EXPORT Channel_Specification
697 {
698 public:
700  Channel_Specification(const vec &avg_power_dB = "0", const vec &delay_prof = "0");
702  Channel_Specification(const CHANNEL_PROFILE profile);
705 
707  void set_channel_profile(const vec &avg_power_dB, const vec &delay_prof);
709  void set_channel_profile(const CHANNEL_PROFILE profile);
710 
712  void set_doppler_spectrum(DOPPLER_SPECTRUM *tap_spectrum);
714  void set_doppler_spectrum(int tap_number, DOPPLER_SPECTRUM tap_spectrum);
715 
717  void set_LOS(int tap_number, double relative_power, double relative_doppler = 0.7);
719  void set_LOS(const vec& relative_power, const vec& relative_doppler = "");
720 
722  void get_channel_profile(vec &avg_power_dB, vec &delay_prof) const;
724  vec get_avg_power_dB() const { return a_prof_dB; }
726  vec get_delay_prof() const { return d_prof; }
728  Array<DOPPLER_SPECTRUM> get_doppler_spectrum() const { return tap_doppler_spectrum; }
730  DOPPLER_SPECTRUM get_doppler_spectrum(int index) const;
732  vec get_LOS_power() const { return los_power; }
734  vec get_LOS_doppler() const { return los_dopp; }
736  double get_LOS_power(int tap_number) const { return los_power(tap_number); }
738  double get_LOS_doppler(int tap_number) const { return los_dopp(tap_number); }
739 
741  int taps() const { return N_taps; }
742 
744  double calc_mean_excess_delay() const;
746  double calc_rms_delay_spread() const;
747 
748 protected:
749  vec a_prof_dB;
750  vec d_prof;
752  int N_taps;
753  vec los_power;
754  vec los_dopp;
755 };
756 
757 
857 class ITPP_EXPORT TDL_Channel
858 {
859 public:
861  TDL_Channel(const vec &avg_power_dB = "0", const ivec &delay_prof = "0");
863  TDL_Channel(const Channel_Specification &channel_spec, double sampling_time);
865  virtual ~TDL_Channel();
866 
868  void set_channel_profile(const vec &avg_power_dB, const ivec &delay_prof);
870  void set_channel_profile_uniform(int no_taps);
872  void set_channel_profile_exponential(int no_taps);
874  void set_channel_profile(const Channel_Specification &channel_spec, double sampling_time);
875 
877  void set_correlated_method(CORRELATED_METHOD method);
879  void set_fading_type(FADING_TYPE fading_type);
880 
882  void set_norm_doppler(double norm_doppler);
883 
885  void set_LOS(const vec& relative_power, const vec& relative_doppler = "");
887  void set_LOS_power(const vec& relative_power);
889  void set_LOS_doppler(const vec& relative_doppler);
890 
892  void set_doppler_spectrum(const DOPPLER_SPECTRUM *tap_spectrum);
894  void set_doppler_spectrum(int tap_number, DOPPLER_SPECTRUM tap_spectrum);
896  void set_no_frequencies(int no_freq);
897 
899  void set_time_offset(int offset);
901  void shift_time_offset(int no_samples);
902 
904  void set_filter_length(int filter_length);
905 
906 
908  int taps() const { return N_taps; }
909 
911  void get_channel_profile(vec &avg_power_dB, ivec &delay_prof) const;
913  vec get_avg_power_dB() const;
915  ivec get_delay_prof() const { return d_prof; }
916 
918  CORRELATED_METHOD get_correlated_method() const { return method; }
920  FADING_TYPE get_fading_type() const { return fading_type; }
921 
923  double get_norm_doppler() const { return n_dopp; }
924 
926  vec get_LOS_power() const { return los_power; }
928  vec get_LOS_doppler() const { return los_dopp; }
930  double get_LOS_power(int tap_number) const { return los_power(tap_number); }
932  double get_LOS_doppler(int tap_number) const { return los_dopp(tap_number); }
933 
935  int get_no_frequencies() const { return nrof_freq; }
936 
938  double get_time_offset() const;
939 
941  double calc_mean_excess_delay() const;
943  double calc_rms_delay_spread() const;
944 
946  void init();
947 
949  void generate(int no_samples, Array<cvec> &channel_coeff);
951  void generate(int no_samples, cmat &channel_coeff);
952 
954  void filter_known_channel(const cvec &input, cvec &output, const Array<cvec> &channel_coeff);
956  void filter_known_channel(const cvec &input, cvec &output, const cmat &channel_coeff);
957 
959  void filter(const cvec &input, cvec &output, Array<cvec> &channel_coeff);
961  void filter(const cvec &input, cvec &output, cmat &channel_coeff);
963  cvec filter(const cvec &input, Array<cvec> &channel_coeff);
965  cvec filter(const cvec &input, cmat &channel_coeff);
967  void filter(const cvec &input, cvec &output);
969  cvec filter(const cvec &input);
970 
972  void operator()(const cvec &input, cvec &output, Array<cvec> &channel_coeff);
974  void operator()(const cvec &input, cvec &output, cmat &channel_coeff);
976  cvec operator()(const cvec &input, Array<cvec> &channel_coeff);
978  cvec operator()(const cvec &input, cmat &channel_coeff);
980  cvec operator()(const cvec &input);
981 
983  void calc_impulse_response(const Array<cvec> &channel_coeff, Array<cvec> &impulse_response);
984 
986  void calc_frequency_response(const Array<cvec> &channel_coeff, Array<cvec> &frequency_response, const int fft_size);
988  void calc_frequency_response(const cmat &channel_coeff, cmat &frequency_response, const int fft_size);
990  double get_sampling_time() const { return discrete_Ts; }
991 
992 protected:
993  bool init_flag;
994  vec a_prof;
995  ivec d_prof;
996  vec los_power;
997  vec los_dopp;
998  int N_taps;
999  double n_dopp;
1006  double discrete_Ts;
1007 
1014  void discretize(const vec &delay_profile);
1015 };
1016 
1017 
1018 
1037 class ITPP_EXPORT BSC
1038 {
1039 public:
1041  BSC(double in_p = 0.0) : u(0.0, 1.0) { p = in_p; };
1043  void set_prob(double in_p) { p = in_p; };
1045  double get_prob() const { return p; };
1047  bvec operator()(const bvec &input);
1048 private:
1049  Uniform_RNG u;
1050  double p;
1051 };
1052 
1053 
1054 
1088 class ITPP_EXPORT AWGN_Channel
1089 {
1090 public:
1092  AWGN_Channel(double noisevar = 0.0): sigma(std::sqrt(noisevar)) {}
1094  void set_noise(double noisevar) { sigma = std::sqrt(noisevar); }
1096  double get_noise() const { return sqr(sigma); }
1098  cvec operator()(const cvec &input);
1100  vec operator()(const vec &input);
1101 private:
1102  Complex_Normal_RNG rng_cn;
1103  Normal_RNG rng_n;
1104  double sigma;
1105 };
1106 
1108 
1109 } // namespace itpp
1110 
1111 #endif // #ifndef CHANNEL_H
SourceForge Logo

Generated on Sat Jul 6 2013 10:54:22 for IT++ by Doxygen 1.8.2