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 
00305     virtual void generate(int no_samples, cvec& output);
00306   };
00307 
00308 
00318   class Static_Fading_Generator : public Fading_Generator {
00319   public:
00321     Static_Fading_Generator() : Fading_Generator() {}
00323     virtual ~Static_Fading_Generator() {}
00324 
00326     virtual void init();
00327 
00329     virtual void generate(int no_samples, cvec& output);
00330 
00331   protected:
00333     std::complex<double> static_sample;
00334   };
00335 
00336 
00349   class Correlated_Fading_Generator : public Fading_Generator {
00350   public:
00352     Correlated_Fading_Generator(double norm_doppler);
00354     virtual ~Correlated_Fading_Generator() {}
00355 
00357     virtual void set_norm_doppler(double norm_doppler);
00359     virtual void set_LOS_doppler(double relative_doppler);
00361     virtual void set_time_offset(int offset);
00362 
00364     virtual double get_norm_doppler() const { return n_dopp; }
00366     virtual double get_LOS_doppler() const { return los_dopp; }
00368     virtual double get_time_offset() const { return time_offset; }
00369 
00371     virtual void shift_time_offset(int no_samples);
00372 
00374     virtual void init() = 0;
00375 
00377     virtual void generate(int no_samples, cvec& output) = 0;
00378 
00379   protected:
00380     double n_dopp; 
00381     double los_dopp; 
00382     double time_offset; 
00383 
00385     void add_LOS(int idx, std::complex<double>& sample);
00386   };
00387 
00388 
00423   class Rice_Fading_Generator : public Correlated_Fading_Generator {
00424   public:
00426     Rice_Fading_Generator(double norm_doppler, DOPPLER_SPECTRUM spectrum = Jakes,
00427         int no_freq = 16, RICE_METHOD method = MEDS);
00429     virtual ~Rice_Fading_Generator() {}
00430 
00432     virtual void set_doppler_spectrum(DOPPLER_SPECTRUM spectrum);
00434     virtual void set_no_frequencies(int no_freq);
00436     virtual void set_rice_method(RICE_METHOD method);
00437 
00439     virtual DOPPLER_SPECTRUM get_doppler_spectrum() const { return dopp_spectrum; }
00441     virtual int get_no_frequencies() const { return Ni; }
00443     virtual RICE_METHOD get_rice_method() const { return rice_method; }
00444 
00446     virtual void init();
00447 
00449     virtual void generate(int no_samples, cvec &output);
00450 
00451   protected:
00452     DOPPLER_SPECTRUM dopp_spectrum; 
00453 
00454     int Ni;
00456     RICE_METHOD rice_method;
00459     vec f1, f2, c1, c2, th1, th2;
00463     double f01, f02;
00466 
00467     void init_MEDS();
00468   };
00469 
00470 
00489   class FIR_Fading_Generator : public Correlated_Fading_Generator {
00490   public:
00492     FIR_Fading_Generator(double norm_doppler, int filter_length = 500);
00494     virtual ~FIR_Fading_Generator() {}
00495 
00497     virtual void set_filter_length(int filter_length);
00499     virtual int get_filter_length() const { return fir_length; }
00500 
00502     virtual void init();
00503 
00505     virtual void generate(int no_samples, cvec &output);
00506 
00507   protected:
00508     int fir_length; 
00509     int upsample_rate; 
00510 
00511     MA_Filter<std::complex<double>, double, std::complex<double> > fir_filter;
00512     cvec left_overs; 
00513 
00524     vec Jakes_filter(double norm_dopp, int order = 100);
00525   };
00526 
00527 
00552   class IFFT_Fading_Generator : public Correlated_Fading_Generator {
00553   public:
00555     IFFT_Fading_Generator(double norm_doppler) :
00556       Correlated_Fading_Generator(norm_doppler) {}
00558     virtual ~IFFT_Fading_Generator() {}
00559 
00561     virtual void init() { init_flag = true; }
00562 
00564     virtual void generate(int no_samples, cvec &output);
00565 
00566   protected:
00568     void generate_Jakes(int no_samples, cvec &output);
00569   };
00570 
00571 
00643   class Channel_Specification {
00644   public:
00646     Channel_Specification(const vec &avg_power_dB = "0", const vec &delay_prof = "0");
00648     Channel_Specification(const CHANNEL_PROFILE profile);
00650     virtual ~Channel_Specification() {}
00651 
00653     void set_channel_profile(const vec &avg_power_dB, const vec &delay_prof);
00655     void set_channel_profile(const CHANNEL_PROFILE profile);
00656 
00658     void set_doppler_spectrum(DOPPLER_SPECTRUM *tap_spectrum);
00660     void set_doppler_spectrum(int tap_number, DOPPLER_SPECTRUM tap_spectrum);
00661 
00663     void set_LOS(int tap_number, double relative_power, double relative_doppler = 0.7);
00665     void set_LOS(const vec& relative_power, const vec& relative_doppler = "");
00666 
00668     void get_channel_profile(vec &avg_power_dB, vec &delay_prof) const;
00670     vec get_avg_power_dB() const { return a_prof_dB; }
00672     vec get_delay_prof() const { return d_prof; }
00674     Array<DOPPLER_SPECTRUM> get_doppler_spectrum() const { return tap_doppler_spectrum; }
00676     DOPPLER_SPECTRUM get_doppler_spectrum(int index) const;
00678     vec get_LOS_power() const { return los_power; }
00680     vec get_LOS_doppler() const { return los_dopp; }
00682     double get_LOS_power(int tap_number) const { return los_power(tap_number); }
00684     double get_LOS_doppler(int tap_number) const { return los_dopp(tap_number); }
00685 
00687     int taps() const { return N_taps; }
00688 
00690     double calc_mean_excess_delay() const;
00692     double calc_rms_delay_spread() const;
00693 
00694   protected:
00695     vec a_prof_dB; 
00696     vec d_prof; 
00697     Array<DOPPLER_SPECTRUM> tap_doppler_spectrum; 
00698     int N_taps; 
00699     vec los_power; 
00700     vec los_dopp; 
00701   };
00702 
00703 
00803   class TDL_Channel {
00804   public:
00806     TDL_Channel(const vec &avg_power_dB = "0", const ivec &delay_prof = "0");
00808     TDL_Channel(const Channel_Specification &channel_spec, double sampling_time);
00810     virtual ~TDL_Channel();
00811 
00813     void set_channel_profile(const vec &avg_power_dB, const ivec &delay_prof);
00815     void set_channel_profile_uniform(int no_taps);
00817     void set_channel_profile_exponential(int no_taps);
00819     void set_channel_profile(const Channel_Specification &channel_spec, double sampling_time);
00820 
00822     void set_correlated_method(CORRELATED_METHOD method);
00824     void set_fading_type(FADING_TYPE fading_type);
00825 
00827     void set_norm_doppler(double norm_doppler);
00828 
00830     void set_LOS(const vec& relative_power, const vec& relative_doppler = "");
00832     void set_LOS_power(const vec& relative_power);
00834     void set_LOS_doppler(const vec& relative_doppler);
00835 
00837     void set_doppler_spectrum(const DOPPLER_SPECTRUM *tap_spectrum);
00839     void set_doppler_spectrum(int tap_number, DOPPLER_SPECTRUM tap_spectrum);
00841     void set_no_frequencies(int no_freq);
00842 
00844     void set_time_offset(int offset);
00846     void shift_time_offset(int no_samples);
00847 
00849     void set_filter_length(int filter_length);
00850 
00851 
00853     int taps() const { return N_taps; }
00854 
00856     void get_channel_profile(vec &avg_power_dB, ivec &delay_prof) const;
00858     vec get_avg_power_dB() const;
00860     ivec get_delay_prof() const { return d_prof; }
00861 
00863     CORRELATED_METHOD get_correlated_method() const { return method; }
00865     FADING_TYPE get_fading_type() const { return fading_type; }
00866 
00868     double get_norm_doppler() const { return n_dopp; }
00869 
00871     vec get_LOS_power() const { return los_power; }
00873     vec get_LOS_doppler() const { return los_dopp; }
00875     double get_LOS_power(int tap_number) const { return los_power(tap_number); }
00877     double get_LOS_doppler(int tap_number) const { return los_dopp(tap_number); }
00878 
00880     int get_no_frequencies() const { return nrof_freq; }
00881 
00883     double get_time_offset() const;
00884 
00886     double calc_mean_excess_delay() const;
00888     double calc_rms_delay_spread() const;
00889 
00891     void init();
00892 
00894     void generate(int no_samples, Array<cvec> &channel_coeff);
00896     void generate(int no_samples, cmat &channel_coeff);
00897 
00899     void filter_known_channel(const cvec &input, cvec &output, const Array<cvec> &channel_coeff);
00901     void filter_known_channel(const cvec &input, cvec &output, const cmat &channel_coeff);
00902 
00904     void filter(const cvec &input, cvec &output, Array<cvec> &channel_coeff);
00906     void filter(const cvec &input, cvec &output, cmat &channel_coeff);
00908     cvec filter(const cvec &input, Array<cvec> &channel_coeff);
00910     cvec filter(const cvec &input, cmat &channel_coeff);
00912     void filter(const cvec &input, cvec &output);
00914     cvec filter(const cvec &input);
00915 
00917     void operator()(const cvec &input, cvec &output, Array<cvec> &channel_coeff);
00919     void operator()(const cvec &input, cvec &output, cmat &channel_coeff);
00921     cvec operator()(const cvec &input, Array<cvec> &channel_coeff);
00923     cvec operator()(const cvec &input, cmat &channel_coeff);
00925     cvec operator()(const cvec &input);
00926 
00928     void calc_impulse_response(const Array<cvec> &channel_coeff, Array<cvec> &impulse_response);
00929 
00931     void calc_frequency_response(const Array<cvec> &channel_coeff, Array<cvec> &frequency_response, const int fft_size);
00933     void calc_frequency_response(const cmat &channel_coeff, cmat &frequency_response, const int fft_size);
00935     double get_sampling_time() const { return discrete_Ts; }
00936 
00937   protected:
00938     bool init_flag; 
00939     vec a_prof; 
00940     ivec d_prof; 
00941     vec los_power; 
00942     vec los_dopp; 
00943     int N_taps; 
00944     double n_dopp; 
00945     FADING_TYPE fading_type; 
00946     CORRELATED_METHOD method; 
00947     Array<DOPPLER_SPECTRUM> tap_doppler_spectrum; 
00948     Array<Fading_Generator *> fading_gen; 
00949     int filter_length; 
00950     int nrof_freq; 
00951     double discrete_Ts; 
00952 
00959     void discretize(const vec &delay_profile);
00960   };
00961 
00962 
00963 
00982   class BSC {
00983   public:
00985     BSC(double in_p=0.0) : u(0.0, 1.0) { p = in_p; };
00987       void set_prob(double in_p) { p = in_p; };
00989       double get_prob() const { return p; };
00991       bvec operator()(const bvec &input);
00992   private:
00993       Uniform_RNG u;
00994       double p;
00995   };
00996 
00997 
00998 
01032   class AWGN_Channel {
01033   public:
01035     AWGN_Channel(double noisevar = 0.0): sigma(std::sqrt(noisevar)) {}
01037     void set_noise(double noisevar) { sigma = std::sqrt(noisevar); }
01039     double get_noise() const { return sqr(sigma); }
01041     cvec operator()(const cvec &input);
01043     vec operator()(const vec &input);
01044   private:
01045     Complex_Normal_RNG rng_cn;
01046     Normal_RNG rng_n;
01047     double sigma;
01048   };
01049 
01051 
01052 } // namespace itpp
01053 
01054 #endif // #ifndef CHANNEL_H
SourceForge Logo

Generated on Sun Sep 14 18:54:53 2008 for IT++ by Doxygen 1.5.6