IT++ Logo
punct_convcode.h
Go to the documentation of this file.
1 
29 #ifndef PUNCT_CONVCODE_H
30 #define PUNCT_CONVCODE_H
31 
32 #include <itpp/base/vec.h>
33 #include <itpp/base/mat.h>
34 #include <itpp/base/array.h>
35 #include <itpp/comm/convcode.h>
36 #include <itpp/itexports.h>
37 
38 namespace itpp
39 {
40 
81 {
82 public:
87 
94  void set_code(const CONVOLUTIONAL_CODE_TYPE type_of_code, int inverse_rate, int constraint_length)
95  { Convolutional_Code::set_code(type_of_code, inverse_rate, constraint_length); }
97  void set_generator_polynomials(const ivec &gen, int constraint_length)
98  { Convolutional_Code::set_generator_polynomials(gen, constraint_length); }
100  ivec get_generator_polynomials() const { return gen_pol; }
101 
103  virtual double get_rate() const { return rate; }
104 
107 
109  void set_puncture_matrix(const bmat &pmatrix); // add test of matrix size
111  bmat get_puncture_matrix() const { return puncture_matrix; }
113  int get_puncture_period() const { return Period; }
114 
116  void init_encoder() { encoder_state = start_state; }
117 
119  void encode(const bvec &input, bvec &output);
121  bvec encode(const bvec &input) { bvec output; encode(input, output); return output; }
122 
124  void encode_trunc(const bvec &input, bvec &output);
126  bvec encode_trunc(const bvec &input) { bvec output; encode_trunc(input, output); return output; }
127 
135  void encode_tail(const bvec &input, bvec &output);
143  bvec encode_tail(const bvec &input) { bvec output; encode_tail(input, output); return output; }
144 
146  void encode_tailbite(const bvec &input, bvec &output);
148  bvec encode_tailbite(const bvec &input)
149  { bvec output; encode_tailbite(input, output); return output; }
150 
151 
153  virtual void decode(const vec &received_signal, bvec &output);
155  virtual bvec decode(const vec &received_signal) { bvec output; decode(received_signal, output); return output; }
156 
157  // ------------ Hard-decision decoding is not implemented -------------------
158  virtual void decode(const bvec &coded_bits, bvec &decoded_bits);
159  virtual bvec decode(const bvec &coded_bits);
160 
162  void decode_trunc(const vec &received_signal, bvec &output);
164  bvec decode_trunc(const vec &received_signal) { bvec output; decode_trunc(received_signal, output); return output; }
165 
172  void decode_tail(const vec &received_signal, bvec &output);
179  bvec decode_tail(const vec &received_signal) { bvec output; decode_tail(received_signal, output); return output; }
180 
182  void decode_tailbite(const vec &received_signal, bvec &output);
184  bvec decode_tailbite(const vec &received_signal)
185  { bvec output; decode_tailbite(received_signal, output); return output; }
186 
187  /*
188  \brief Calculate the inverse sequence
189 
190  Assumes that encode_tail is used in the encoding process. Returns false if there is an error in the coded sequence
191  (not a valid codeword).
192  */
193  bool inverse_tail(const bvec coded_sequence, bvec &input);
194 
196  bool catastrophic(void);
197 
199  void distance_profile(ivec &dist_prof, int time, int dmax = 100000, bool reverse = false);
200 
217  void calculate_spectrum(Array<ivec> &spectrum, int dmax, int no_terms);
218 
229  void calculate_spectrum(Array<ivec> &spectrum, int time, int dmax, int no_terms, int block_length = 0);
230 
247  int fast(Array<ivec> &spectrum, int time, int dfree, int no_terms, int d_best_so_far = 0, bool test_catastrophic = false);
248 
249 protected:
251  int weight(const int state, const int input, int time);
253  void weight(const int state, int &w0, int &w1, int time);
255  int weight_reverse(const int state, const int input, int time);
257  void weight_reverse(const int state, int &w0, int &w1, int time);
258 
260  int Period;
262  int total;
265 };
266 
267 } // namespace itpp
268 
269 #endif // #ifndef PUNCT_CONVCODE_H
SourceForge Logo

Generated on Sat May 25 2013 16:32:21 for IT++ by Doxygen 1.8.2