IT++ Logo Newcom Logo

punct_convcode.h

Go to the documentation of this file.
00001 
00033 #ifndef PUNCT_CONVCODE_H
00034 #define PUNCT_CONVCODE_H
00035 
00036 #include <itpp/base/vec.h>
00037 #include <itpp/base/mat.h>
00038 #include <itpp/base/array.h>
00039 #include <itpp/comm/convcode.h>
00040 
00041 
00042 namespace itpp {
00043 
00083   class Punctured_Convolutional_Code : public Convolutional_Code {
00084   public:
00086     Punctured_Convolutional_Code(void) : Convolutional_Code() {}
00088     virtual ~Punctured_Convolutional_Code(void) {}
00089 
00096     void set_code(const CONVOLUTIONAL_CODE_TYPE type_of_code, int inverse_rate, int constraint_length)
00097       { Convolutional_Code::set_code(type_of_code, inverse_rate, constraint_length); }
00099     void set_generator_polynomials(const ivec &gen, int constraint_length)
00100       { Convolutional_Code::set_generator_polynomials(gen, constraint_length); }
00102     ivec get_generator_polynomials(void) { return gen_pol; }
00103 
00105     virtual double get_rate(void) { return rate; }
00106 
00108     void set_method(const CONVOLUTIONAL_CODE_METHOD method) { Convolutional_Code::set_method(method); }
00109 
00111     void set_puncture_matrix(const bmat &pmatrix); // add test of matrix size
00113     bmat get_puncture_matrix(void) { return puncture_matrix; }
00115     int get_puncture_period(void) { return Period; }
00116 
00118     void init_encoder() { encoder_state = start_state; }
00119 
00121     void encode(const bvec &input, bvec &output);
00123     bvec encode(const bvec &input) { bvec output; encode(input, output); return output; }
00124 
00126     void encode_trunc(const bvec &input, bvec &output);
00128     bvec encode_trunc(const bvec &input) { bvec output; encode_trunc(input, output); return output; }
00129 
00137     void encode_tail(const bvec &input, bvec &output);
00145     bvec encode_tail(const bvec &input) { bvec output; encode_tail(input, output); return output; }
00146 
00148     void encode_tailbite(const bvec &input, bvec &output);
00150     bvec encode_tailbite(const bvec &input)
00151       { bvec output; encode_tailbite(input, output); return output; }
00152 
00153 
00155     virtual void decode(const vec &received_signal, bvec &output);
00157     virtual bvec decode(const vec &received_signal) { bvec output; decode(received_signal, output); return output; }
00158 
00159     // ------------ Hard-decision decoding is not implemented -------------------
00160     virtual void decode(const bvec &coded_bits, bvec &decoded_bits);
00161     virtual bvec decode(const bvec &coded_bits);
00162 
00164     void decode_trunc(const vec &received_signal, bvec &output);
00166     bvec decode_trunc(const vec &received_signal) { bvec output; decode_trunc(received_signal, output); return output; }
00167 
00174     void decode_tail(const vec &received_signal, bvec &output);
00181     bvec decode_tail(const vec &received_signal) { bvec output; decode_tail(received_signal, output); return output; }
00182 
00184     void decode_tailbite(const vec &received_signal, bvec &output);
00186     bvec decode_tailbite(const vec &received_signal)
00187       { bvec output; decode_tailbite(received_signal, output); return output; }
00188 
00189     /*
00190       \brief Calculate the inverse sequence
00191 
00192       Assumes that encode_tail is used in the encoding process. Returns false if there is an error in the coded sequence
00193       (not a valid codeword).
00194     */
00195     bool inverse_tail(const bvec coded_sequence, bvec &input);
00196 
00198     bool catastrophic(void);
00199 
00201     void distance_profile(ivec &dist_prof, int time, int dmax = 100000, bool reverse = false);
00202     //void distance_profile(llvec &dist_prof, int time, int dmax = 100000, bool reverse = false);
00203 
00220     void calculate_spectrum(Array<ivec> &spectrum, int dmax, int no_terms);
00221     //void calculate_spectrum(Array<llvec> &spectrum, int dmax, int no_terms);
00222 
00223     // Calculate spectrum. Suitable when calculating many terms in the spectra. Breadth first search.
00224     // void calculate_spectrum(Array<llvec> &spectrum, int time, int dmax, int no_terms);
00225 
00236     void calculate_spectrum(Array<ivec> &spectrum, int time, int dmax, int no_terms, int block_length=0);
00237     //void calculate_spectrum(Array<llvec> &spectrum, int time, int dmax, int no_terms, int block_length=0);
00238 
00255     int fast(Array<ivec> &spectrum, int time, int dfree, int no_terms, int d_best_so_far = 0, bool test_catastrophic = false);
00256     //int fast(Array<llvec> &spectrum, int time, int dfree, int no_terms, int d_best_so_far = 0, bool test_catastrophic = false);
00257 
00258   protected:
00260     int weight(const int state, const int input, int time);
00262     void weight(const int state, int &w0, int &w1, int time);
00264     int weight_reverse(const int state, const int input, int time);
00266     void weight_reverse(const int state, int &w0, int &w1, int time);
00267 
00269     int Period;
00271     int total;
00273     bmat puncture_matrix;
00274   };
00275 
00276 } // namespace itpp
00277 
00278 #endif // #ifndef PUNCT_CONVCODE_H
SourceForge Logo

Generated on Thu Apr 19 14:23:58 2007 for IT++ by Doxygen 1.4.6