Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

punct_convcode.h

Go to the documentation of this file.
00001 // 
00002 // SPUC - Signal processing using C++ - A DSP library
00003 /*---------------------------------------------------------------------------*
00004  *                                   IT++                                    *
00005  *---------------------------------------------------------------------------*
00006  * Copyright (c) 1995-2002 by Tony Ottosson, Thomas Eriksson, Pål Frenger,   *
00007  * Tobias Ringström, and Jonas Samuelsson.                                   *
00008  *                                                                           *
00009  * Permission to use, copy, modify, and distribute this software and its     *
00010  * documentation under the terms of the GNU General Public License is hereby *
00011  * granted. No representations are made about the suitability of this        *
00012  * software for any purpose. It is provided "as is" without expressed or     *
00013  * implied warranty. See the GNU General Public License for more details.    *
00014  *---------------------------------------------------------------------------*/
00015 
00026 #ifndef __punct_convcode_h
00027 #define __punct_convcode_h
00028 
00029 #include "convcode.h"
00030 #include <vector.h>
00031 #include <matrix.h>
00032 #include <array.h>
00033 namespace SPUC {
00072 class Punctured_Convolutional_Code : protected Convolutional_Code {
00073  public:
00075   Punctured_Convolutional_Code(void) : Convolutional_Code() {}
00077   virtual ~Punctured_Convolutional_Code(void) {}
00078   
00085   void set_code(string type_of_code, int inverse_rate, int constraint_length)
00086     { Convolutional_Code::set_code(type_of_code, inverse_rate, constraint_length); }
00088   void set_generator_polynomials(const ivec &gen, int constraint_length)
00089     { Convolutional_Code::set_generator_polynomials(gen, constraint_length); }
00091   ivec get_generator_polynomials(void) { return gen_pol; }
00093   double get_rate(void) { return rate; }
00094   
00096   void set_puncture_matrix(const bmat &pmatrix); // add test of matrix size
00098   bmat get_puncture_matrix(void) { return puncture_matrix; }
00100   int get_puncture_period(void) { return Period; }
00101   
00103   void init_encoder() { encoder_state = start_state; }
00104   
00106   void encode(const bvec &input, bvec &output);
00108   bvec encode(const bvec &input) { bvec output; encode(input, output); return output; }
00109   
00117   void encode_tail(const bvec &input, bvec &output);
00125   bvec encode_tail(const bvec &input) { bvec output; encode_tail(input, output); return output; }
00126   
00128   void decode(const vec &received_signal, bvec &output);
00130   bvec decode(const vec &received_signal) { bvec output; decode(received_signal, output); return output; }
00131   
00138   void decode_tail(const vec &received_signal, bvec &output);
00145   bvec decode_tail(const vec &received_signal) { bvec output; decode_tail(received_signal, output); return output; }
00146   
00147   /*
00148     \brief Calculate the inverse sequence
00149     
00150     Assumes that encode_tail is used in the encoding process. Returns false if there is an error in the coded sequence 
00151     (not a valid codeword).
00152   */
00153   bool inverse_tail(const bvec coded_sequence, bvec &input);
00154   
00156   bool catastrophic(void);
00157   
00159   void distance_profile(llvec &dist_prof, int time, int dmax = 100000, bool reverse = false);
00160   
00175   void calculate_spectrum(Array<llvec> &spectrum, int dmax, int no_terms);
00176   
00177   // Calculate spectrum. Suitable when calculating many terms in the spectra. Breadth first search.
00178   // void calculate_spectrum(Array<llvec> &spectrum, int time, int dmax, int no_terms);
00179   
00190   void calculate_spectrum(Array<llvec> &spectrum, int time, int dmax, int no_terms, int block_length=0);
00191   
00206   int fast(Array<llvec> &spectrum, int time, int dfree, int no_terms, int d_best_so_far = 0, bool test_catastrophic = false);
00207   
00208  protected:
00210   int weight(const int state, const int input, int time);
00212   void weight(const int state, int &w0, int &w1, int time);
00214   int weight_reverse(const int state, const int input, int time);
00216   void weight_reverse(const int state, int &w0, int &w1, int time);
00217 
00219   int Period;
00221   bmat puncture_matrix;
00222 };
00223 }
00224 #endif // __punct_convcode_h

Generated on Fri Sep 16 11:02:20 2005 for spuc by  doxygen 1.4.4