43 for (
j = 0;
j <
n;
j++) {
47 for (
i = 0;
i <
K;
i++) {
62 for (
j = 0;
j <
n;
j++) {
66 for (
i = 0;
i <
K;
i++) {
83 for (
j = 0;
j <
n;
j++) {
87 for (
i = 0;
i <
m;
i++) {
104 for (
j = 0;
j <
n;
j++) {
108 for (
i = 0;
i <
m;
i++) {
129 for (
j = 0;
j <
n;
j++) {
130 for (p = 0; p <
Period; p++)
158 int nn = 0,
i, p = 0,
j;
160 for (
i = 0;
i <
int(output.size() /
n);
i++) {
161 for (
j = 0;
j <
n;
j++) {
163 output(
nn) = output(
i *
n +
j);
176 int nn = 0,
i, p = 0,
j;
178 for (
i = 0;
i <
int(output.size() /
n);
i++) {
179 for (
j = 0;
j <
n;
j++) {
181 output(
nn) = output(
i *
n +
j);
194 int nn = 0,
i, p = 0,
j;
196 for (
i = 0;
i <
int(output.size() /
n);
i++) {
197 for (
j = 0;
j <
n;
j++) {
199 output(
nn) = output(
i *
n +
j);
212 it_error(
"Punctured_Convolutional_Code::decode(bvec, bvec); hard-decision decoding is not implemented");
217 it_error(
"Punctured_Convolutional_Code::decode(bvec, bvec); hard-decision decoding is not implemented");
255 for (
j = 0;
j <
n;
j++) {
263 it_warning(
"Punctured_Convolutional_Code::decode(): Improper length of "
264 "the received punctured block, dummy bits have been added");
305 for (
j = 0;
j <
n;
j++) {
313 it_warning(
"Punctured_Convolutional_Code::decode_tail(): Improper length "
314 "of the received punctured block, dummy bits have been added");
356 for (
j = 0;
j <
n;
j++) {
364 it_warning(
"Punctured_Convolutional_Code::decode_tailbite(): Improper "
365 "length of the received punctured block, dummy bits have been "
404bool Punctured_Convolutional_Code::inverse_tail(
const bvec
coded_sequence, bvec &input)
421 for (
j = 0;
j <
n;
j++) {
430 if (coded_sequence.mid(prev_pos, no_symbols) == zero_output.left(no_symbols)) {
432 state = zero_state >> 1;
434 else if (coded_sequence.mid(prev_pos, no_symbols) == one_output.left(no_symbols)) {
436 state = one_state >> 1;
441 prev_pos += no_symbols;
459 int start,
S,
W0,
W1, S0, S1, pos, t = 0;
462 for (pos = 0; pos <
Period; pos++) {
463 for (start = 0; start < (1 <<
m); start++) {
469 if (t > (1 <<
m) *
Period) {
return true; }
474 if ((
W0 == 0) && (S0 == start) && (((pos + t + 1) %
Period) == pos)) {
return true; }
475 if ((
W0 == 0) && (S0 == 0) && (
S != 0)) {
return true; }
476 if ((S0 != 0) && (
W0 == 0)) {
486 if ((
W1 == 0) && (S1 == start) && (((pos + t + 1) %
Period) == pos)) {
return true; }
492 if (
W0 > 0)
goto stack;
493 if ((
W0 == 0) && (S0 == start) && (((pos + t + 1) %
Period) == pos)) {
return true; }
494 if ((
W0 == 0) && (S0 == 0) && (
S != 0)) {
return true; }
529 W =
weight(0, 1, start_time);
568 if (t ==
m)
goto stack;
583 if (t ==
m)
goto stack;
608 for (
j = 0;
j <
K;
j++) {
743 for (
int pos = 0; pos <
Period; pos++) {
801 for (s =
s_start; s < (1 <<
m); s++) {
int size() const
Returns the number of data elements in the array object.
void set_size(int n, bool copy=false)
Resizing an Array<T>.
double rate
The rate of the code.
int next_state(const int instate, const int input)
Next state from instate given the input.
void encode_tailbite(const bvec &input, bvec &output)
Encode an input binary vector using tailbiting.
void encode_tail(const bvec &input, bvec &output)
Encoding that starts and ends in the zero state.
virtual void decode_tailbite(const vec &received_signal, bvec &output)
Decode a block of encoded data where encode_tailbite has been used.
virtual void decode_tail(const vec &received_signal, bvec &output)
Decode a block of encoded data where encode_tail has been used.
void encode_trunc(const bvec &input, bvec &output)
Encode a binary vector starting from the previous encoder state.
int n
Number of generators.
int m
Memory of the encoder.
ivec gen_pol_rev
Generator polynomials for the reverse code.
virtual void decode_trunc(const vec &received_signal, bvec &output)
Viterbi decoding using truncation of memory (default = 5*K)
CONVOLUTIONAL_CODE_METHOD cc_method
encoding and decoding method
bvec xor_int_table
Auxilary table used by the codec.
ivec gen_pol
Generator polynomials.
int fast(Array< ivec > &spectrum, int time, int dfree, int no_terms, int d_best_so_far=0, bool test_catastrophic=false)
Cederwall's fast algorithm.
void decode_trunc(const vec &received_signal, bvec &output)
Viterbi decoding using truncation of memory (default = 5*K)
int weight_reverse(const int state, const int input, int time)
Weight of the reverse code from state with input (0 or 1) at transition time.
void encode_trunc(const bvec &input, bvec &output)
Encode a binary vector of inputs starting from state set by the set_state function.
void encode(const bvec &input, bvec &output)
Encode a binary vector of inputs using specified method.
bmat puncture_matrix
The puncture matrix (n rows and Period columns)
void calculate_spectrum(Array< ivec > &spectrum, int dmax, int no_terms)
Calculate spectrum.
void encode_tailbite(const bvec &input, bvec &output)
Encode a binary vector of inputs using tailbiting.
int total
The number of "1" in the puncture matrix.
void decode_tailbite(const vec &received_signal, bvec &output)
Decode a block of encoded data where encode_tailbite has been used. Tries all start states.
void distance_profile(ivec &dist_prof, int time, int dmax=100000, bool reverse=false)
Calculate distance profile. If reverse = true calculate for the reverse code instead.
int weight(const int state, const int input, int time)
The weight of path from state with input (0 or 1) at transition time.
void decode_tail(const vec &received_signal, bvec &output)
Decode a block of encoded data where encode_tail has been used.
bool catastrophic(void)
Check if the code is catastrophic. Returns true if catastrophic.
void encode_tail(const bvec &input, bvec &output)
Encoding that begins and ends in the zero state.
int Period
The puncture period (i.e. the number of columns in the puncture matrix)
virtual void decode(const vec &received_signal, bvec &output)
Viterbi decoding using specified method.
void set_puncture_matrix(const bmat &pmatrix)
Set puncture matrix (size n*Period)
Binary arithmetic (boolean) class.
#define it_error_if(t, s)
Abort if t is true.
#define it_error(s)
Abort unconditionally.
#define it_warning(s)
Display a warning message.
Vec< T > reverse(const Vec< T > &in)
Reverse the input vector.
vec spectrum(const vec &v, int nfft, int noverlap)
Power spectrum calculation.
Mat< bin > bmat
bin matrix
Mat< Num_T > elem_mult(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Element wise multiplication of two matrices.
Definitions of a Binary Punctured Convolutional Encoder class.