00001 00030 #ifndef PUNCT_CONVCODE_H 00031 #define PUNCT_CONVCODE_H 00032 00033 #include <itpp/base/vec.h> 00034 #include <itpp/base/mat.h> 00035 #include <itpp/base/array.h> 00036 #include <itpp/comm/convcode.h> 00037 00038 00039 namespace itpp 00040 { 00041 00081 class Punctured_Convolutional_Code : public Convolutional_Code 00082 { 00083 public: 00085 Punctured_Convolutional_Code(void) : Convolutional_Code() {} 00087 virtual ~Punctured_Convolutional_Code(void) {} 00088 00095 void set_code(const CONVOLUTIONAL_CODE_TYPE type_of_code, int inverse_rate, int constraint_length) 00096 { Convolutional_Code::set_code(type_of_code, inverse_rate, constraint_length); } 00098 void set_generator_polynomials(const ivec &gen, int constraint_length) 00099 { Convolutional_Code::set_generator_polynomials(gen, constraint_length); } 00101 ivec get_generator_polynomials() const { return gen_pol; } 00102 00104 virtual double get_rate() const { return rate; } 00105 00107 void set_method(const CONVOLUTIONAL_CODE_METHOD method) { Convolutional_Code::set_method(method); } 00108 00110 void set_puncture_matrix(const bmat &pmatrix); // add test of matrix size 00112 bmat get_puncture_matrix() const { return puncture_matrix; } 00114 int get_puncture_period() const { return Period; } 00115 00117 void init_encoder() { encoder_state = start_state; } 00118 00120 void encode(const bvec &input, bvec &output); 00122 bvec encode(const bvec &input) { bvec output; encode(input, output); return output; } 00123 00125 void encode_trunc(const bvec &input, bvec &output); 00127 bvec encode_trunc(const bvec &input) { bvec output; encode_trunc(input, output); return output; } 00128 00136 void encode_tail(const bvec &input, bvec &output); 00144 bvec encode_tail(const bvec &input) { bvec output; encode_tail(input, output); return output; } 00145 00147 void encode_tailbite(const bvec &input, bvec &output); 00149 bvec encode_tailbite(const bvec &input) 00150 { bvec output; encode_tailbite(input, output); return output; } 00151 00152 00154 virtual void decode(const vec &received_signal, bvec &output); 00156 virtual bvec decode(const vec &received_signal) { bvec output; decode(received_signal, output); return output; } 00157 00158 // ------------ Hard-decision decoding is not implemented ------------------- 00159 virtual void decode(const bvec &coded_bits, bvec &decoded_bits); 00160 virtual bvec decode(const bvec &coded_bits); 00161 00163 void decode_trunc(const vec &received_signal, bvec &output); 00165 bvec decode_trunc(const vec &received_signal) { bvec output; decode_trunc(received_signal, output); return output; } 00166 00173 void decode_tail(const vec &received_signal, bvec &output); 00180 bvec decode_tail(const vec &received_signal) { bvec output; decode_tail(received_signal, output); return output; } 00181 00183 void decode_tailbite(const vec &received_signal, bvec &output); 00185 bvec decode_tailbite(const vec &received_signal) 00186 { bvec output; decode_tailbite(received_signal, output); return output; } 00187 00188 /* 00189 \brief Calculate the inverse sequence 00190 00191 Assumes that encode_tail is used in the encoding process. Returns false if there is an error in the coded sequence 00192 (not a valid codeword). 00193 */ 00194 bool inverse_tail(const bvec coded_sequence, bvec &input); 00195 00197 bool catastrophic(void); 00198 00200 void distance_profile(ivec &dist_prof, int time, int dmax = 100000, bool reverse = false); 00201 00218 void calculate_spectrum(Array<ivec> &spectrum, int dmax, int no_terms); 00219 00230 void calculate_spectrum(Array<ivec> &spectrum, int time, int dmax, int no_terms, int block_length = 0); 00231 00248 int fast(Array<ivec> &spectrum, int time, int dfree, int no_terms, int d_best_so_far = 0, bool test_catastrophic = false); 00249 00250 protected: 00252 int weight(const int state, const int input, int time); 00254 void weight(const int state, int &w0, int &w1, int time); 00256 int weight_reverse(const int state, const int input, int time); 00258 void weight_reverse(const int state, int &w0, int &w1, int time); 00259 00261 int Period; 00263 int total; 00265 bmat puncture_matrix; 00266 }; 00267 00268 } // namespace itpp 00269 00270 #endif // #ifndef PUNCT_CONVCODE_H
Generated on Fri May 1 11:09:17 2009 for IT++ by Doxygen 1.5.8