IT++ Logo

channel.h

Go to the documentation of this file.
00001 
00030 #ifndef CHANNEL_H
00031 #define CHANNEL_H
00032 
00033 #include <itpp/base/math/elem_math.h>
00034 #include <itpp/base/mat.h>
00035 #include <itpp/base/array.h>
00036 #include <itpp/base/random.h>
00037 #include <itpp/signal/filter.h>
00038 
00185 namespace itpp
00186 {
00187 
00189 
00190 
00192 enum CHANNEL_PROFILE {
00193   ITU_Vehicular_A, ITU_Vehicular_B, ITU_Pedestrian_A, ITU_Pedestrian_B,
00194   COST207_RA, COST207_RA6,
00195   COST207_TU, COST207_TU6alt, COST207_TU12, COST207_TU12alt,
00196   COST207_BU, COST207_BU6alt, COST207_BU12, COST207_BU12alt,
00197   COST207_HT, COST207_HT6alt, COST207_HT12, COST207_HT12alt,
00198   COST259_TUx, COST259_RAx, COST259_HTx
00199 };
00200 
00202 enum FADING_TYPE { Independent, Static, Correlated };
00203 
00205 enum CORRELATED_METHOD { Rice_MEDS, IFFT, FIR };
00206 
00208 enum RICE_METHOD { MEDS };
00209 
00211 enum DOPPLER_SPECTRUM {
00212   Jakes = 0, J = 0, Classic = 0, C = 0,
00213   GaussI = 1, Gauss1 = 1, GI = 1, G1 = 1,
00214   GaussII = 2, Gauss2 = 2, GII = 2, G2 = 2
00215 };
00216 
00217 
00227 class Fading_Generator
00228 {
00229 public:
00231   Fading_Generator();
00233   virtual ~Fading_Generator() {}
00234 
00236   void set_LOS_power(double relative_power);
00238   virtual void set_LOS_doppler(double relative_doppler);
00240   virtual void set_time_offset(int offset);
00242   virtual void set_filter_length(int filter_length);
00244   virtual void set_norm_doppler(double norm_doppler);
00246   virtual void set_doppler_spectrum(DOPPLER_SPECTRUM spectrum);
00248   virtual void set_no_frequencies(int no_freq);
00250   virtual void set_rice_method(RICE_METHOD method);
00251 
00253   double get_LOS_power() const { return los_power; }
00255   virtual double get_LOS_doppler() const;
00257   virtual double get_time_offset() const;
00259   virtual int get_filter_length() const;
00261   virtual double get_norm_doppler() const;
00263   virtual DOPPLER_SPECTRUM get_doppler_spectrum() const;
00265   virtual int get_no_frequencies() const;
00267   virtual RICE_METHOD get_rice_method() const;
00268 
00270   virtual void shift_time_offset(int no_samples);
00271 
00273   virtual void init() = 0;
00274 
00276   virtual void generate(int no_samples, cvec &output) = 0;
00278   cvec generate(int no_samples);
00279 
00280 protected:
00281   bool init_flag; 
00282   double los_power; 
00283   double los_diffuse; 
00284   double los_direct; 
00285 };
00286 
00287 
00296 class Independent_Fading_Generator : public Fading_Generator
00297 {
00298 public:
00300   Independent_Fading_Generator() : Fading_Generator() {}
00302   virtual ~Independent_Fading_Generator() {}
00303 
00305   virtual void init() { init_flag = true; }
00306 
00307   using Fading_Generator::generate;
00308 
00310   virtual void generate(int no_samples, cvec& output);
00311 };
00312 
00313 
00323 class Static_Fading_Generator : public Fading_Generator
00324 {
00325 public:
00327   Static_Fading_Generator() : Fading_Generator() {}
00329   virtual ~Static_Fading_Generator() {}
00330 
00332   virtual void init();
00333 
00334   using Fading_Generator::generate;
00335 
00337   virtual void generate(int no_samples, cvec& output);
00338 
00339 protected:
00341   std::complex<double> static_sample;
00342 };
00343 
00344 
00357 class Correlated_Fading_Generator : public Fading_Generator
00358 {
00359 public:
00361   Correlated_Fading_Generator(double norm_doppler);
00363   virtual ~Correlated_Fading_Generator() {}
00364 
00366   virtual void set_norm_doppler(double norm_doppler);
00368   virtual void set_LOS_doppler(double relative_doppler);
00370   virtual void set_time_offset(int offset);
00371 
00373   virtual double get_norm_doppler() const { return n_dopp; }
00375   virtual double get_LOS_doppler() const { return los_dopp; }
00377   virtual double get_time_offset() const { return time_offset; }
00378 
00380   virtual void shift_time_offset(int no_samples);
00381 
00383   virtual void init() = 0;
00384 
00385   using Fading_Generator::generate;
00386 
00388   virtual void generate(int no_samples, cvec& output) = 0;
00389 
00390 protected:
00391   double n_dopp; 
00392   double los_dopp; 
00393   double time_offset; 
00394 
00396   void add_LOS(int idx, std::complex<double>& sample);
00397 };
00398 
00399 
00434 class Rice_Fading_Generator : public Correlated_Fading_Generator
00435 {
00436 public:
00438   Rice_Fading_Generator(double norm_doppler, DOPPLER_SPECTRUM spectrum = Jakes,
00439                         int no_freq = 16, RICE_METHOD method = MEDS);
00441   virtual ~Rice_Fading_Generator() {}
00442 
00444   virtual void set_doppler_spectrum(DOPPLER_SPECTRUM spectrum);
00446   virtual void set_no_frequencies(int no_freq);
00448   virtual void set_rice_method(RICE_METHOD method);
00449 
00451   virtual DOPPLER_SPECTRUM get_doppler_spectrum() const { return dopp_spectrum; }
00453   virtual int get_no_frequencies() const { return Ni; }
00455   virtual RICE_METHOD get_rice_method() const { return rice_method; }
00456 
00458   virtual void init();
00459 
00460   using Correlated_Fading_Generator::generate;
00461 
00463   virtual void generate(int no_samples, cvec &output);
00464 
00465 protected:
00466   DOPPLER_SPECTRUM dopp_spectrum; 
00467 
00468   int Ni;
00470   RICE_METHOD rice_method;
00473   vec f1, f2, c1, c2, th1, th2;
00477   double f01, f02;
00480 
00481   void init_MEDS();
00482 };
00483 
00484 
00503 class FIR_Fading_Generator : public Correlated_Fading_Generator
00504 {
00505 public:
00507   FIR_Fading_Generator(double norm_doppler, int filter_length = 500);
00509   virtual ~FIR_Fading_Generator() {}
00510 
00512   virtual void set_filter_length(int filter_length);
00514   virtual int get_filter_length() const { return fir_length; }
00515 
00517   virtual void init();
00518 
00519   using Correlated_Fading_Generator::generate;
00520 
00522   virtual void generate(int no_samples, cvec &output);
00523 
00524 protected:
00525   int fir_length; 
00526   int upsample_rate; 
00527 
00528   MA_Filter<std::complex<double>, double, std::complex<double> > fir_filter;
00529   cvec left_overs; 
00530 
00541   vec Jakes_filter(double norm_dopp, int order = 100);
00542 };
00543 
00544 
00569 class IFFT_Fading_Generator : public Correlated_Fading_Generator
00570 {
00571 public:
00573   IFFT_Fading_Generator(double norm_doppler) :
00574       Correlated_Fading_Generator(norm_doppler) {}
00576   virtual ~IFFT_Fading_Generator() {}
00577 
00579   virtual void init() { init_flag = true; }
00580 
00581   using Correlated_Fading_Generator::generate;
00582 
00584   virtual void generate(int no_samples, cvec &output);
00585 
00586 protected:
00588   void generate_Jakes(int no_samples, cvec &output);
00589 };
00590 
00591 
00663 class Channel_Specification
00664 {
00665 public:
00667   Channel_Specification(const vec &avg_power_dB = "0", const vec &delay_prof = "0");
00669   Channel_Specification(const CHANNEL_PROFILE profile);
00671   virtual ~Channel_Specification() {}
00672 
00674   void set_channel_profile(const vec &avg_power_dB, const vec &delay_prof);
00676   void set_channel_profile(const CHANNEL_PROFILE profile);
00677 
00679   void set_doppler_spectrum(DOPPLER_SPECTRUM *tap_spectrum);
00681   void set_doppler_spectrum(int tap_number, DOPPLER_SPECTRUM tap_spectrum);
00682 
00684   void set_LOS(int tap_number, double relative_power, double relative_doppler = 0.7);
00686   void set_LOS(const vec& relative_power, const vec& relative_doppler = "");
00687 
00689   void get_channel_profile(vec &avg_power_dB, vec &delay_prof) const;
00691   vec get_avg_power_dB() const { return a_prof_dB; }
00693   vec get_delay_prof() const { return d_prof; }
00695   Array<DOPPLER_SPECTRUM> get_doppler_spectrum() const { return tap_doppler_spectrum; }
00697   DOPPLER_SPECTRUM get_doppler_spectrum(int index) const;
00699   vec get_LOS_power() const { return los_power; }
00701   vec get_LOS_doppler() const { return los_dopp; }
00703   double get_LOS_power(int tap_number) const { return los_power(tap_number); }
00705   double get_LOS_doppler(int tap_number) const { return los_dopp(tap_number); }
00706 
00708   int taps() const { return N_taps; }
00709 
00711   double calc_mean_excess_delay() const;
00713   double calc_rms_delay_spread() const;
00714 
00715 protected:
00716   vec a_prof_dB; 
00717   vec d_prof; 
00718   Array<DOPPLER_SPECTRUM> tap_doppler_spectrum; 
00719   int N_taps; 
00720   vec los_power; 
00721   vec los_dopp; 
00722 };
00723 
00724 
00824 class TDL_Channel
00825 {
00826 public:
00828   TDL_Channel(const vec &avg_power_dB = "0", const ivec &delay_prof = "0");
00830   TDL_Channel(const Channel_Specification &channel_spec, double sampling_time);
00832   virtual ~TDL_Channel();
00833 
00835   void set_channel_profile(const vec &avg_power_dB, const ivec &delay_prof);
00837   void set_channel_profile_uniform(int no_taps);
00839   void set_channel_profile_exponential(int no_taps);
00841   void set_channel_profile(const Channel_Specification &channel_spec, double sampling_time);
00842 
00844   void set_correlated_method(CORRELATED_METHOD method);
00846   void set_fading_type(FADING_TYPE fading_type);
00847 
00849   void set_norm_doppler(double norm_doppler);
00850 
00852   void set_LOS(const vec& relative_power, const vec& relative_doppler = "");
00854   void set_LOS_power(const vec& relative_power);
00856   void set_LOS_doppler(const vec& relative_doppler);
00857 
00859   void set_doppler_spectrum(const DOPPLER_SPECTRUM *tap_spectrum);
00861   void set_doppler_spectrum(int tap_number, DOPPLER_SPECTRUM tap_spectrum);
00863   void set_no_frequencies(int no_freq);
00864 
00866   void set_time_offset(int offset);
00868   void shift_time_offset(int no_samples);
00869 
00871   void set_filter_length(int filter_length);
00872 
00873 
00875   int taps() const { return N_taps; }
00876 
00878   void get_channel_profile(vec &avg_power_dB, ivec &delay_prof) const;
00880   vec get_avg_power_dB() const;
00882   ivec get_delay_prof() const { return d_prof; }
00883 
00885   CORRELATED_METHOD get_correlated_method() const { return method; }
00887   FADING_TYPE get_fading_type() const { return fading_type; }
00888 
00890   double get_norm_doppler() const { return n_dopp; }
00891 
00893   vec get_LOS_power() const { return los_power; }
00895   vec get_LOS_doppler() const { return los_dopp; }
00897   double get_LOS_power(int tap_number) const { return los_power(tap_number); }
00899   double get_LOS_doppler(int tap_number) const { return los_dopp(tap_number); }
00900 
00902   int get_no_frequencies() const { return nrof_freq; }
00903 
00905   double get_time_offset() const;
00906 
00908   double calc_mean_excess_delay() const;
00910   double calc_rms_delay_spread() const;
00911 
00913   void init();
00914 
00916   void generate(int no_samples, Array<cvec> &channel_coeff);
00918   void generate(int no_samples, cmat &channel_coeff);
00919 
00921   void filter_known_channel(const cvec &input, cvec &output, const Array<cvec> &channel_coeff);
00923   void filter_known_channel(const cvec &input, cvec &output, const cmat &channel_coeff);
00924 
00926   void filter(const cvec &input, cvec &output, Array<cvec> &channel_coeff);
00928   void filter(const cvec &input, cvec &output, cmat &channel_coeff);
00930   cvec filter(const cvec &input, Array<cvec> &channel_coeff);
00932   cvec filter(const cvec &input, cmat &channel_coeff);
00934   void filter(const cvec &input, cvec &output);
00936   cvec filter(const cvec &input);
00937 
00939   void operator()(const cvec &input, cvec &output, Array<cvec> &channel_coeff);
00941   void operator()(const cvec &input, cvec &output, cmat &channel_coeff);
00943   cvec operator()(const cvec &input, Array<cvec> &channel_coeff);
00945   cvec operator()(const cvec &input, cmat &channel_coeff);
00947   cvec operator()(const cvec &input);
00948 
00950   void calc_impulse_response(const Array<cvec> &channel_coeff, Array<cvec> &impulse_response);
00951 
00953   void calc_frequency_response(const Array<cvec> &channel_coeff, Array<cvec> &frequency_response, const int fft_size);
00955   void calc_frequency_response(const cmat &channel_coeff, cmat &frequency_response, const int fft_size);
00957   double get_sampling_time() const { return discrete_Ts; }
00958 
00959 protected:
00960   bool init_flag; 
00961   vec a_prof; 
00962   ivec d_prof; 
00963   vec los_power; 
00964   vec los_dopp; 
00965   int N_taps; 
00966   double n_dopp; 
00967   FADING_TYPE fading_type; 
00968   CORRELATED_METHOD method; 
00969   Array<DOPPLER_SPECTRUM> tap_doppler_spectrum; 
00970   Array<Fading_Generator *> fading_gen; 
00971   int filter_length; 
00972   int nrof_freq; 
00973   double discrete_Ts; 
00974 
00981   void discretize(const vec &delay_profile);
00982 };
00983 
00984 
00985 
01004 class BSC
01005 {
01006 public:
01008   BSC(double in_p = 0.0) : u(0.0, 1.0) { p = in_p; };
01010   void set_prob(double in_p) { p = in_p; };
01012   double get_prob() const { return p; };
01014   bvec operator()(const bvec &input);
01015 private:
01016   Uniform_RNG u;
01017   double p;
01018 };
01019 
01020 
01021 
01055 class AWGN_Channel
01056 {
01057 public:
01059   AWGN_Channel(double noisevar = 0.0): sigma(std::sqrt(noisevar)) {}
01061   void set_noise(double noisevar) { sigma = std::sqrt(noisevar); }
01063   double get_noise() const { return sqr(sigma); }
01065   cvec operator()(const cvec &input);
01067   vec operator()(const vec &input);
01068 private:
01069   Complex_Normal_RNG rng_cn;
01070   Normal_RNG rng_n;
01071   double sigma;
01072 };
01073 
01075 
01076 } // namespace itpp
01077 
01078 #endif // #ifndef CHANNEL_H
SourceForge Logo

Generated on Thu Apr 23 20:07:45 2009 for IT++ by Doxygen 1.5.8