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 
00188 
00189 
00191   enum CHANNEL_PROFILE {
00192     ITU_Vehicular_A, ITU_Vehicular_B, ITU_Pedestrian_A, ITU_Pedestrian_B,
00193     COST207_RA, COST207_RA6,
00194     COST207_TU, COST207_TU6alt, COST207_TU12, COST207_TU12alt,
00195     COST207_BU, COST207_BU6alt, COST207_BU12, COST207_BU12alt,
00196     COST207_HT, COST207_HT6alt, COST207_HT12, COST207_HT12alt,
00197     COST259_TUx, COST259_RAx, COST259_HTx
00198   };
00199 
00201   enum FADING_TYPE { Independent, Static, Correlated };
00202 
00204   enum CORRELATED_METHOD { Rice_MEDS, IFFT, FIR };
00205 
00207   enum RICE_METHOD { MEDS };
00208 
00210   enum DOPPLER_SPECTRUM {
00211     Jakes = 0, J = 0, Classic = 0, C = 0,
00212     GaussI = 1, Gauss1 = 1, GI = 1, G1 = 1,
00213     GaussII = 2, Gauss2 = 2, GII = 2, G2 = 2
00214   };
00215 
00216 
00226   class Fading_Generator {
00227   public:
00229     Fading_Generator();
00231     virtual ~Fading_Generator() {}
00232 
00234     void set_LOS_power(double relative_power);
00236     virtual void set_LOS_doppler(double relative_doppler);
00238     virtual void set_time_offset(int offset);
00240     virtual void set_filter_length(int filter_length);
00242     virtual void set_norm_doppler(double norm_doppler);
00244     virtual void set_doppler_spectrum(DOPPLER_SPECTRUM spectrum);
00246     virtual void set_no_frequencies(int no_freq);
00248     virtual void set_rice_method(RICE_METHOD method);
00249 
00251     double get_LOS_power() const { return los_power; }
00253     virtual double get_LOS_doppler() const;
00255     virtual double get_time_offset() const;
00257     virtual int get_filter_length() const;
00259     virtual double get_norm_doppler() const;
00261     virtual DOPPLER_SPECTRUM get_doppler_spectrum() const;
00263     virtual int get_no_frequencies() const;
00265     virtual RICE_METHOD get_rice_method() const;
00266 
00268     virtual void shift_time_offset(int no_samples);
00269 
00271     virtual void init() = 0;
00272 
00274     virtual void generate(int no_samples, cvec &output) = 0;
00276     cvec generate(int no_samples);
00277 
00278   protected:
00279     bool init_flag; 
00280     double los_power; 
00281     double los_diffuse; 
00282     double los_direct; 
00283   };
00284 
00285 
00294   class Independent_Fading_Generator : public Fading_Generator {
00295   public:
00297     Independent_Fading_Generator() : Fading_Generator() {}
00299     virtual ~Independent_Fading_Generator() {}
00300 
00302     virtual void init() { init_flag = true; }
00303 
00304     using Fading_Generator::generate;
00305 
00307     virtual void generate(int no_samples, cvec& output);
00308   };
00309 
00310 
00320   class Static_Fading_Generator : public Fading_Generator {
00321   public:
00323     Static_Fading_Generator() : Fading_Generator() {}
00325     virtual ~Static_Fading_Generator() {}
00326 
00328     virtual void init();
00329 
00330     using Fading_Generator::generate;
00331 
00333     virtual void generate(int no_samples, cvec& output);
00334 
00335   protected:
00337     std::complex<double> static_sample;
00338   };
00339 
00340 
00353   class Correlated_Fading_Generator : public Fading_Generator {
00354   public:
00356     Correlated_Fading_Generator(double norm_doppler);
00358     virtual ~Correlated_Fading_Generator() {}
00359 
00361     virtual void set_norm_doppler(double norm_doppler);
00363     virtual void set_LOS_doppler(double relative_doppler);
00365     virtual void set_time_offset(int offset);
00366 
00368     virtual double get_norm_doppler() const { return n_dopp; }
00370     virtual double get_LOS_doppler() const { return los_dopp; }
00372     virtual double get_time_offset() const { return time_offset; }
00373 
00375     virtual void shift_time_offset(int no_samples);
00376 
00378     virtual void init() = 0;
00379 
00380     using Fading_Generator::generate;
00381 
00383     virtual void generate(int no_samples, cvec& output) = 0;
00384 
00385   protected:
00386     double n_dopp; 
00387     double los_dopp; 
00388     double time_offset; 
00389 
00391     void add_LOS(int idx, std::complex<double>& sample);
00392   };
00393 
00394 
00429   class Rice_Fading_Generator : public Correlated_Fading_Generator {
00430   public:
00432     Rice_Fading_Generator(double norm_doppler, DOPPLER_SPECTRUM spectrum = Jakes,
00433                           int no_freq = 16, RICE_METHOD method = MEDS);
00435     virtual ~Rice_Fading_Generator() {}
00436 
00438     virtual void set_doppler_spectrum(DOPPLER_SPECTRUM spectrum);
00440     virtual void set_no_frequencies(int no_freq);
00442     virtual void set_rice_method(RICE_METHOD method);
00443 
00445     virtual DOPPLER_SPECTRUM get_doppler_spectrum() const { return dopp_spectrum; }
00447     virtual int get_no_frequencies() const { return Ni; }
00449     virtual RICE_METHOD get_rice_method() const { return rice_method; }
00450 
00452     virtual void init();
00453 
00454     using Correlated_Fading_Generator::generate;
00455 
00457     virtual void generate(int no_samples, cvec &output);
00458 
00459   protected:
00460     DOPPLER_SPECTRUM dopp_spectrum; 
00461 
00462     int Ni;
00464     RICE_METHOD rice_method;
00467     vec f1, f2, c1, c2, th1, th2;
00471     double f01, f02;
00474 
00475     void init_MEDS();
00476   };
00477 
00478 
00497   class FIR_Fading_Generator : public Correlated_Fading_Generator {
00498   public:
00500     FIR_Fading_Generator(double norm_doppler, int filter_length = 500);
00502     virtual ~FIR_Fading_Generator() {}
00503 
00505     virtual void set_filter_length(int filter_length);
00507     virtual int get_filter_length() const { return fir_length; }
00508 
00510     virtual void init();
00511 
00512     using Correlated_Fading_Generator::generate;
00513 
00515     virtual void generate(int no_samples, cvec &output);
00516 
00517   protected:
00518     int fir_length; 
00519     int upsample_rate; 
00520 
00521     MA_Filter<std::complex<double>, double, std::complex<double> > fir_filter;
00522     cvec left_overs; 
00523 
00534     vec Jakes_filter(double norm_dopp, int order = 100);
00535   };
00536 
00537 
00562   class IFFT_Fading_Generator : public Correlated_Fading_Generator {
00563   public:
00565     IFFT_Fading_Generator(double norm_doppler) :
00566       Correlated_Fading_Generator(norm_doppler) {}
00568     virtual ~IFFT_Fading_Generator() {}
00569 
00571     virtual void init() { init_flag = true; }
00572 
00573     using Correlated_Fading_Generator::generate;
00574 
00576     virtual void generate(int no_samples, cvec &output);
00577 
00578   protected:
00580     void generate_Jakes(int no_samples, cvec &output);
00581   };
00582 
00583 
00655   class Channel_Specification {
00656   public:
00658     Channel_Specification(const vec &avg_power_dB = "0", const vec &delay_prof = "0");
00660     Channel_Specification(const CHANNEL_PROFILE profile);
00662     virtual ~Channel_Specification() {}
00663 
00665     void set_channel_profile(const vec &avg_power_dB, const vec &delay_prof);
00667     void set_channel_profile(const CHANNEL_PROFILE profile);
00668 
00670     void set_doppler_spectrum(DOPPLER_SPECTRUM *tap_spectrum);
00672     void set_doppler_spectrum(int tap_number, DOPPLER_SPECTRUM tap_spectrum);
00673 
00675     void set_LOS(int tap_number, double relative_power, double relative_doppler = 0.7);
00677     void set_LOS(const vec& relative_power, const vec& relative_doppler = "");
00678 
00680     void get_channel_profile(vec &avg_power_dB, vec &delay_prof) const;
00682     vec get_avg_power_dB() const { return a_prof_dB; }
00684     vec get_delay_prof() const { return d_prof; }
00686     Array<DOPPLER_SPECTRUM> get_doppler_spectrum() const { return tap_doppler_spectrum; }
00688     DOPPLER_SPECTRUM get_doppler_spectrum(int index) const;
00690     vec get_LOS_power() const { return los_power; }
00692     vec get_LOS_doppler() const { return los_dopp; }
00694     double get_LOS_power(int tap_number) const { return los_power(tap_number); }
00696     double get_LOS_doppler(int tap_number) const { return los_dopp(tap_number); }
00697 
00699     int taps() const { return N_taps; }
00700 
00702     double calc_mean_excess_delay() const;
00704     double calc_rms_delay_spread() const;
00705 
00706   protected:
00707     vec a_prof_dB; 
00708     vec d_prof; 
00709     Array<DOPPLER_SPECTRUM> tap_doppler_spectrum; 
00710     int N_taps; 
00711     vec los_power; 
00712     vec los_dopp; 
00713   };
00714 
00715 
00815   class TDL_Channel {
00816   public:
00818     TDL_Channel(const vec &avg_power_dB = "0", const ivec &delay_prof = "0");
00820     TDL_Channel(const Channel_Specification &channel_spec, double sampling_time);
00822     virtual ~TDL_Channel();
00823 
00825     void set_channel_profile(const vec &avg_power_dB, const ivec &delay_prof);
00827     void set_channel_profile_uniform(int no_taps);
00829     void set_channel_profile_exponential(int no_taps);
00831     void set_channel_profile(const Channel_Specification &channel_spec, double sampling_time);
00832 
00834     void set_correlated_method(CORRELATED_METHOD method);
00836     void set_fading_type(FADING_TYPE fading_type);
00837 
00839     void set_norm_doppler(double norm_doppler);
00840 
00842     void set_LOS(const vec& relative_power, const vec& relative_doppler = "");
00844     void set_LOS_power(const vec& relative_power);
00846     void set_LOS_doppler(const vec& relative_doppler);
00847 
00849     void set_doppler_spectrum(const DOPPLER_SPECTRUM *tap_spectrum);
00851     void set_doppler_spectrum(int tap_number, DOPPLER_SPECTRUM tap_spectrum);
00853     void set_no_frequencies(int no_freq);
00854 
00856     void set_time_offset(int offset);
00858     void shift_time_offset(int no_samples);
00859 
00861     void set_filter_length(int filter_length);
00862 
00863 
00865     int taps() const { return N_taps; }
00866 
00868     void get_channel_profile(vec &avg_power_dB, ivec &delay_prof) const;
00870     vec get_avg_power_dB() const;
00872     ivec get_delay_prof() const { return d_prof; }
00873 
00875     CORRELATED_METHOD get_correlated_method() const { return method; }
00877     FADING_TYPE get_fading_type() const { return fading_type; }
00878 
00880     double get_norm_doppler() const { return n_dopp; }
00881 
00883     vec get_LOS_power() const { return los_power; }
00885     vec get_LOS_doppler() const { return los_dopp; }
00887     double get_LOS_power(int tap_number) const { return los_power(tap_number); }
00889     double get_LOS_doppler(int tap_number) const { return los_dopp(tap_number); }
00890 
00892     int get_no_frequencies() const { return nrof_freq; }
00893 
00895     double get_time_offset() const;
00896 
00898     double calc_mean_excess_delay() const;
00900     double calc_rms_delay_spread() const;
00901 
00903     void init();
00904 
00906     void generate(int no_samples, Array<cvec> &channel_coeff);
00908     void generate(int no_samples, cmat &channel_coeff);
00909 
00911     void filter_known_channel(const cvec &input, cvec &output, const Array<cvec> &channel_coeff);
00913     void filter_known_channel(const cvec &input, cvec &output, const cmat &channel_coeff);
00914 
00916     void filter(const cvec &input, cvec &output, Array<cvec> &channel_coeff);
00918     void filter(const cvec &input, cvec &output, cmat &channel_coeff);
00920     cvec filter(const cvec &input, Array<cvec> &channel_coeff);
00922     cvec filter(const cvec &input, cmat &channel_coeff);
00924     void filter(const cvec &input, cvec &output);
00926     cvec filter(const cvec &input);
00927 
00929     void operator()(const cvec &input, cvec &output, Array<cvec> &channel_coeff);
00931     void operator()(const cvec &input, cvec &output, cmat &channel_coeff);
00933     cvec operator()(const cvec &input, Array<cvec> &channel_coeff);
00935     cvec operator()(const cvec &input, cmat &channel_coeff);
00937     cvec operator()(const cvec &input);
00938 
00940     void calc_impulse_response(const Array<cvec> &channel_coeff, Array<cvec> &impulse_response);
00941 
00943     void calc_frequency_response(const Array<cvec> &channel_coeff, Array<cvec> &frequency_response, const int fft_size);
00945     void calc_frequency_response(const cmat &channel_coeff, cmat &frequency_response, const int fft_size);
00947     double get_sampling_time() const { return discrete_Ts; }
00948 
00949   protected:
00950     bool init_flag; 
00951     vec a_prof; 
00952     ivec d_prof; 
00953     vec los_power; 
00954     vec los_dopp; 
00955     int N_taps; 
00956     double n_dopp; 
00957     FADING_TYPE fading_type; 
00958     CORRELATED_METHOD method; 
00959     Array<DOPPLER_SPECTRUM> tap_doppler_spectrum; 
00960     Array<Fading_Generator *> fading_gen; 
00961     int filter_length; 
00962     int nrof_freq; 
00963     double discrete_Ts; 
00964 
00971     void discretize(const vec &delay_profile);
00972   };
00973 
00974 
00975 
00994   class BSC {
00995   public:
00997     BSC(double in_p=0.0) : u(0.0, 1.0) { p = in_p; };
00999       void set_prob(double in_p) { p = in_p; };
01001       double get_prob() const { return p; };
01003       bvec operator()(const bvec &input);
01004   private:
01005       Uniform_RNG u;
01006       double p;
01007   };
01008 
01009 
01010 
01044   class AWGN_Channel {
01045   public:
01047     AWGN_Channel(double noisevar = 0.0): sigma(std::sqrt(noisevar)) {}
01049     void set_noise(double noisevar) { sigma = std::sqrt(noisevar); }
01051     double get_noise() const { return sqr(sigma); }
01053     cvec operator()(const cvec &input);
01055     vec operator()(const vec &input);
01056   private:
01057     Complex_Normal_RNG rng_cn;
01058     Normal_RNG rng_n;
01059     double sigma;
01060   };
01061 
01063 
01064 } // namespace itpp
01065 
01066 #endif // #ifndef CHANNEL_H
SourceForge Logo

Generated on Sat Apr 19 10:42:05 2008 for IT++ by Doxygen 1.5.5