项目展示分类
MATLAB算法仿真 SIMULINK仿真 FPGA工程开发 机器学习 视觉识别系统 网络开发 通信/信号处理 语音智能处理 新算法预研 信息论/编码译码 人工智能 其他项目

微信:HuangL1121
Q Q:1224848052
团队:嘉兴麦特莱博软件开发工作室
地址:嘉兴港区
 
通信/信号处理
多进制LDPC信道编译码开发|MATLAB代做
来源:本站    日期:2018/3/24    浏览量:18391  

功能描述:

LDPC编码分为随机LDPC和准循环LDPC;而准循环LDPC(QC-LDPC)码是一类具有低复杂度编码的构造码,它可以利用简单的移位寄存器完成编码,其复杂度与生成矩阵有关。所以准循环LDPC的编码中的H矩阵主要是通过对一个基础矩阵的移位扩展得到的。此外,在构造QC-LDPC的时候,通常使用的方法是进行高斯消元法进行实现的。这里,还得明确一个概念,QC-LDPC指的是你所构造的H矩阵的性质为准循环结构,而高斯消元法是指的时候构造这种准循环结构的一种方法,所以这里并不矛盾。准循环结构式相对于随机校验结构而言的。

而对于多进制的情况,这里采用的方法,由于多进制H矩阵的构造非常复杂,其最大的区别是需要从多进制伽罗达域考虑。代码中,是使用C进行计算的,这样可以进行快速得到H矩阵。

注意,多进制QC矩阵的构造有很多方法,其和二进制QC矩阵的构造是完全不同的,这里注意区别,不要和二进制的QC矩阵放在一起考虑,通常多进制所使用的方法有:

基于GF域的多进制QC-LDPC,基于加法群的多进制QC-LDPC以及基于RS码的多进制QC-LDPC。这里所采用的方法为:

基于在有限元伽罗达域GF(q)上进行准循环矩阵的构造(即代码中的C语言)。

部分内核代码:




#include

#include "mex.h"



/* Input Arguments: parameters*/

#define M_IN prhs[0]          /* number of parity checks */

#define N_IN prhs[1]          /* blocklength */

#define T_IN prhs[2]          /* mean column weight */

#define Q_IN prhs[3]          /* GF base  */

#define SEED_IN prhs[4]          /* seed for random generator */





/* Output Arguments: matrices*/

#define H_OUT plhs[0]





void mexFunction(

int nlhs,       mxArray *plhs[],

int nrhs, const mxArray *prhs[]

)

{

short **M_list, **N_list, *M_target;

double *pp,*sr,*s,*ss;

int N,M,q,i,j,k,nzmax,*irs,*jcs,l,

tr,tm,tc,done,redo,tmp,regime,tr_max,t_max, m_low;

float t;

long seed;

void adjust(int *, int *, int *, int *);

unsigned int K2,M2;

char c;

mxArray *arg_in[2], *arg_out[1]; /* to call rand generator of Matlab*/



/* Check for proper number of arguments */

if (nrhs != 5) {

mexErrMsgTxt("GENERATE requires five input arguments.");

} else if (nlhs > 1) {

mexErrMsgTxt("GENERATE requires one output argument.");

}



pp = mxGetPr(N_IN);    N = (int) (*pp);

pp = mxGetPr(M_IN);    M = (int) (*pp);

pp = mxGetPr(T_IN);    t = (float) (*pp);

pp = mxGetPr(Q_IN);    q = (int) (*pp);

pp = mxGetPr(SEED_IN); seed = (int) (*pp);





arg_in[0] = mxCreateString("state");

arg_in[1] = mxCreateDoubleMatrix(1, 1, mxREAL);

s = mxGetPr(arg_in[1]);

s[0] = seed; /* this will be used to call rand*/



/* initialize random generator */

mexCallMATLAB(0, NULL, 2, arg_in, "rand"); /* rand('state',seed) */

s[0] = 1; /* use s to store "1"*/



t_max=(int)ceil(t);

M_list=(short **)mxMalloc(N*sizeof(short *));

M_target=(short *)mxMalloc(M*sizeof(short *));

N_list=(short **)mxMalloc(M*sizeof(short *));

for(i=0;i
M_list[i]=(short *)mxMalloc((t_max+1)*sizeof(short));

}

i=0;



K2=0;

if(t<3){

K2=ceil((double)N*(3-t));

if(K2>M)

mexErrMsgTxt("GENERATE: Can't have more than M weight 2 columns.");

j=2;

done=0;

for(i=0;!done;i++){

M2=floor((double)M/(double)j);

if((M2*(j-1))>=K2) done=1;

j*=2;

}

M2*=(j/4);

}

/*

* i contains number of identity blocks we'll need.... */

tr=((short)floor((double)(t*N)/(double)M));



if (i>tr){

tr_max=i;



done=0;

k=1;

j=floor((double)t*N)-2*K2; /* Number of ones left to distribute */

for(i=0;!done;i++){

/* (M-2*M2) rows will be empty after identity blocks */

j-=((M-2*M2)+(2*M2*(k-1))/k);

if(j<0) {

done=1;

}

else {

k*=2;

}

}

tr=i-1;

tm=M+j;

}

else {

/* This is easier! */

tr_max=tr+1;

tm=(int)floor((((double)t*N)/(double)M-tr)*M +0.5);

}

tc=M-tm;

for(i=0;i
N_list[i]=(short *)mxMalloc((tr_max+1)*sizeof(short));

}

for(i=0;i
N_list[i][0]=0;

}



regime=0;



j=M2;

k=0;

i=0;

while(i
for(;(i-k)
M_list[i][0]=2;

M_list[i][1]=i;

M_list[i][2]=i+j;

N_list[i][0]++;

if(N_list[i][0]==tr) adjust(&tm,&tr,&tc,®ime);

N_list[i][N_list[i][0]]=i;

N_list[i+j][0]++;

if(N_list[i+j][0]==tr) adjust(&tm,&tr,&tc,®ime);

N_list[i+j][N_list[i+j][0]]=i;

}

k=i;

j/=2;

}



/* Now fill the unsystematic columns, ensuring weight per row as even as poss. */

i=K2;

if(K2==0){

/* Fill low weight columns */

for(i=0;i<(int)(N*(t_max-t)+0.5);i++){

for(k=1;k<=(int)floor(t);k++){

done=0;

do {

mexCallMATLAB(1, arg_out,1 , &arg_in[1], "rand"); /* ss = rand(1) */

ss = mxGetPr(arg_out[0]);

j=(short)floor(M*ss[0]);

mexCallMATLAB(1, arg_out,1 , &arg_in[1], "rand");

ss = mxGetPr(arg_out[0]);

if((ss[0])<(1-(double)N_list[j][0]/(double)tr)) {

done=1;

for(l=1;l
}

} while(!done);

N_list[j][0]++;

N_list[j][N_list[j][0]]=i;

if(N_list[j][0]==tr) adjust(&tm,&tr,&tc,®ime);

M_list[i][k]=j;

}

M_list[i][0]=k-1;

}

}

redo=1;

for(;i
fprintf(stderr,"%d\r",i);

for(k=1;k<=t_max;k++){

done=0;

do {

/* find the lowest weight rows, and fill one of them */

if(redo){

l=tr_max;

for(j=0;j
m_low=0;

for(j=0;j
}

mexCallMATLAB(1, arg_out,1 , &arg_in[1], "rand");

ss = mxGetPr(arg_out[0]);

j=M_target[tmp=(short)floor(m_low*ss[0])];

/* if(ss[0]<(1-(double)N_list[j][0]/(double)tr)) {*/

done=1;

for(l=1;l
if(done==1){

if(m_low==1) redo=1;

else {

for(;tmp<(m_low-1);tmp++) M_target[tmp]=M_target[tmp+1];

m_low--;

redo=0;

}

}

/* }*/



} while(!done);

N_list[j][0]++;

N_list[j][N_list[j][0]]=i;

if(N_list[j][0]==tr) adjust(&tm,&tr,&tc,®ime);

M_list[i][k]=j;

}

M_list[i][0]=k-1;

}

tr=((short)ceil((double)(3*N-K2)/(double)M));





for(i=0;i
mxFree(N_list[i]);

}

mxFree(N_list);





/* done generating H matrix - positions only */





/* Allocate space for sparse matrix */

nzmax=0; for(j=0 ; j
mexPrintf("%d \n",nzmax);



if (N>nzmax){

nzmax=N;

}

plhs[0] = mxCreateSparse(M,N,nzmax,mxREAL);

sr  = mxGetPr(plhs[0]);

irs = mxGetIr(plhs[0]);  /* row */

jcs = mxGetJc(plhs[0]);  /* column */



k = 0;

for (j=0; (j
jcs[j] = k;

for (i=1; (i<=M_list[j][0] ); i++) {

mexCallMATLAB(1, arg_out,1 , &arg_in[1], "rand"); /* ss = rand(q) */

ss = mxGetPr(arg_out[0]);

sr[k] = floor(1 + ss[0]*(q-1));

irs[k] = M_list[j][i];

k++;

}

}

jcs[N] = k;







for(i=0;i
mxFree(M_list[i]);

}

mxFree(M_list);



return;

}







void adjust(int *tm, int *tr, int *tc, int *regime){

switch(*regime){

case 0:

(*tc)--;

if((*tc)==0){

*regime=1;

(*tr)++;

}

break;

case 1:

(*tm)--;

if((*tm)==0){

*regime=2;

(*tr)--;

}

break;

}

}






   上一篇: 高性能人物跟踪监控设备研制|FPGA代做|MATLAB代做    下一篇:    
   相关阅读
· 基于FPGA的高精度DDS设计和测试 2022/9/30
· MATLAB代做-217维特比译码的FPGA实现 2021/2/11
· MATLAB代做-高精度物体轮廓提取算法 2020/2/16
· 正式承接人工智能相关项目课题以及各类研究型科研任务 2019/12/20
· MATLAB代做-基于深度卷积神经网络的图像去噪方法 2019/10/30
· MATLAB代做-高密度人员检测算法的仿真 2019/8/29
· matlab专业代做★深度学习-人工智能在自动驾驶中的应 2019/8/17
· MATLAB代做|FPGA代做-FPGA击败GPU和GP 2019/8/3
· FPGA代做|MATLAB代做★【转】OPEN AI L 2019/7/28
· matlab专业代做★【转】仿生蚂蚁机器人面世,分工协力 2019/7/13
Copyright 2017-2024 © 嘉兴麦特莱博软件开发工作室
  • 网站备案号:浙ICP备18008591号-1