IT++ Logo
punct_convcode.h
Go to the documentation of this file.
00001 
00029 #ifndef PUNCT_CONVCODE_H
00030 #define PUNCT_CONVCODE_H
00031 
00032 #include <itpp/base/vec.h>
00033 #include <itpp/base/mat.h>
00034 #include <itpp/base/array.h>
00035 #include <itpp/comm/convcode.h>
00036 
00037 
00038 namespace itpp
00039 {
00040 
00080 class Punctured_Convolutional_Code : public Convolutional_Code
00081 {
00082 public:
00084   Punctured_Convolutional_Code(void) : Convolutional_Code() {}
00086   virtual ~Punctured_Convolutional_Code(void) {}
00087 
00094   void set_code(const CONVOLUTIONAL_CODE_TYPE type_of_code, int inverse_rate, int constraint_length)
00095   { Convolutional_Code::set_code(type_of_code, inverse_rate, constraint_length); }
00097   void set_generator_polynomials(const ivec &gen, int constraint_length)
00098   { Convolutional_Code::set_generator_polynomials(gen, constraint_length); }
00100   ivec get_generator_polynomials() const { return gen_pol; }
00101 
00103   virtual double get_rate() const { return rate; }
00104 
00106   void set_method(const CONVOLUTIONAL_CODE_METHOD method) { Convolutional_Code::set_method(method); }
00107 
00109   void set_puncture_matrix(const bmat &pmatrix); // add test of matrix size
00111   bmat get_puncture_matrix() const { return puncture_matrix; }
00113   int get_puncture_period() const { return Period; }
00114 
00116   void init_encoder() { encoder_state = start_state; }
00117 
00119   void encode(const bvec &input, bvec &output);
00121   bvec encode(const bvec &input) { bvec output; encode(input, output); return output; }
00122 
00124   void encode_trunc(const bvec &input, bvec &output);
00126   bvec encode_trunc(const bvec &input) { bvec output; encode_trunc(input, output); return output; }
00127 
00135   void encode_tail(const bvec &input, bvec &output);
00143   bvec encode_tail(const bvec &input) { bvec output; encode_tail(input, output); return output; }
00144 
00146   void encode_tailbite(const bvec &input, bvec &output);
00148   bvec encode_tailbite(const bvec &input)
00149   { bvec output; encode_tailbite(input, output); return output; }
00150 
00151 
00153   virtual void decode(const vec &received_signal, bvec &output);
00155   virtual bvec decode(const vec &received_signal) { bvec output; decode(received_signal, output); return output; }
00156 
00157   // ------------ Hard-decision decoding is not implemented -------------------
00158   virtual void decode(const bvec &coded_bits, bvec &decoded_bits);
00159   virtual bvec decode(const bvec &coded_bits);
00160 
00162   void decode_trunc(const vec &received_signal, bvec &output);
00164   bvec decode_trunc(const vec &received_signal) { bvec output; decode_trunc(received_signal, output); return output; }
00165 
00172   void decode_tail(const vec &received_signal, bvec &output);
00179   bvec decode_tail(const vec &received_signal) { bvec output; decode_tail(received_signal, output); return output; }
00180 
00182   void decode_tailbite(const vec &received_signal, bvec &output);
00184   bvec decode_tailbite(const vec &received_signal)
00185   { bvec output; decode_tailbite(received_signal, output); return output; }
00186 
00187   /*
00188     \brief Calculate the inverse sequence
00189 
00190     Assumes that encode_tail is used in the encoding process. Returns false if there is an error in the coded sequence
00191     (not a valid codeword).
00192   */
00193   bool inverse_tail(const bvec coded_sequence, bvec &input);
00194 
00196   bool catastrophic(void);
00197 
00199   void distance_profile(ivec &dist_prof, int time, int dmax = 100000, bool reverse = false);
00200 
00217   void calculate_spectrum(Array<ivec> &spectrum, int dmax, int no_terms);
00218 
00229   void calculate_spectrum(Array<ivec> &spectrum, int time, int dmax, int no_terms, int block_length = 0);
00230 
00247   int fast(Array<ivec> &spectrum, int time, int dfree, int no_terms, int d_best_so_far = 0, bool test_catastrophic = false);
00248 
00249 protected:
00251   int weight(const int state, const int input, int time);
00253   void weight(const int state, int &w0, int &w1, int time);
00255   int weight_reverse(const int state, const int input, int time);
00257   void weight_reverse(const int state, int &w0, int &w1, int time);
00258 
00260   int Period;
00262   int total;
00264   bmat puncture_matrix;
00265 };
00266 
00267 } // namespace itpp
00268 
00269 #endif // #ifndef PUNCT_CONVCODE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SourceForge Logo

Generated on Wed Jul 27 2011 16:27:05 for IT++ by Doxygen 1.7.4