实现卷积码编码和BCJR译码。
以下是实现该算法的代码:
convolution.h
#define EDGE_NUM 8
#define INF 0x3fffff
#define CONV_CODE_RATE 0.5
#define LL 1000
#include <iostream>
struct edge {
int left;
int right;
int input;
int output;
};
static int next_state[8][2] = { { 0, 2 },
{ 2, 0 },
{ 4, 6 },
{ 6, 4 },
{ 5, 7 },
{ 7, 5 },
{ 1, 3 },
{ 3, 1 } };
static int output[8][2] = { { 0, 11 },
{ 0, 11 },
{ 0, 11 },
{ 0, 11 },
{ 1, 10 },
{ 1, 10 },
{ 1, 10 },
{ 1, 10 } };
static edge trans_M[16];
static int cost_matrix[LL + 2][EDGE_NUM];
static int prestate[LL + 2][EDGE_NUM];
static int decoding_seq[LL + 2];
static int encode_con[2 * LL + 2];
void ini_edge();
int* encode_convolution(int* source, int len);
int *convolution_decoing(int* received_seq, int seq_length);
convolution.cpp
#include"convolution.h"
#include<iostream>
using namespace std;
void ini_edge() {
for (int i = 0; i < 16; i++) {
trans_M[i].left = i / 2;
trans_M[i].r