├── README.md ├── README.txt ├── W.m ├── Wn.m ├── awgn_noise.m ├── check.mat ├── crc_bound_cal.m ├── crc_check.m ├── crc_gen.m ├── decoder.m ├── decoder_list.m ├── decoder_list_crc.m ├── decoder_list_crc_layer.m ├── decoder_list_crc_layer_new.m ├── decoder_list_crc_layer_new_ver1.m ├── decoder_list_crc_layer_ver1.m ├── decoder_tree.m ├── decoder_tree_crc.m ├── draw.m ├── encoder.m ├── f.m ├── f2.cpp ├── f2.mexw64 ├── f_minus.m ├── f_plus.m ├── get_PHI_INV_chart.cpp ├── get_PHI_INV_chart.mexw64 ├── get_awgn_Pb.m ├── get_awgn_bhattacharyya.m ├── get_bec_bhattacharyya.m ├── get_punc_awgn_Pb.m ├── harq_decoder.m ├── harq_decoder_sc.m ├── harq_decoder_sc_test.m ├── infoBitComparison.m ├── llr.m ├── llr_new.m ├── logAPP.m ├── logAPP1.c ├── logAPP1.mexw64 ├── logAPPBase.m ├── logAPP_base.m ├── lr_new.m ├── phi_inv_in_out_chart.mat ├── polarcode_awgn.m ├── polarcode_awgn_list_crc.m ├── polarcode_awgn_list_crc_layer_multi_path.m ├── polarcode_awgn_list_crc_layer_new_multi_path.m ├── polarcode_awgn_list_crc_layer_new_single_path.m ├── polarcode_awgn_list_crc_layer_single_path.m ├── polarcode_awgn_punc_harq.m ├── polarcode_awgn_tree.m ├── polarcode_sc_crc_harq.m ├── polarcode_sc_harq.m ├── polarcode_sc_punc_harq.m ├── polarcode_scl_crc_harq.m ├── polarcode_scl_punc_harq.m ├── rev_shuffle.m └── www.m /README.md: -------------------------------------------------------------------------------- 1 | # PolarCodesMatLab 2 | Polar Codes MatLab 3 | 4 | Code on my master thesis 5 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/README.txt -------------------------------------------------------------------------------- /W.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/W.m -------------------------------------------------------------------------------- /Wn.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/Wn.m -------------------------------------------------------------------------------- /awgn_noise.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/awgn_noise.m -------------------------------------------------------------------------------- /check.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/check.mat -------------------------------------------------------------------------------- /crc_bound_cal.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/crc_bound_cal.m -------------------------------------------------------------------------------- /crc_check.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/crc_check.m -------------------------------------------------------------------------------- /crc_gen.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/crc_gen.m -------------------------------------------------------------------------------- /decoder.m: -------------------------------------------------------------------------------- 1 | function [u_hat,free_index]=decoder(y,Z,k,b,var) 2 | %译码函数 3 | %输入y为信道输出,Z为信道Bhattacharyya矩阵,k为信息长度,b为frozenbit的值,var为噪声方差/功率 4 | 5 | N=length(y); %码长N 6 | [Zw,index]=sort(Z,'descend'); %信道Bhattacharyya参数排序 7 | frozen_index=index(1:N-k); %frozenbit位置 8 | free_index=index(N-k+1:N); %信息比特位置 9 | 10 | isfrozen(frozen_index)=1; %frozenbit标记 11 | isfrozen(free_index)=0; %信息比特 12 | 13 | 14 | u_hat(1:N)=0; 15 | for i=1:N 16 | if isfrozen(i)==1; 17 | u_hat(i)=b; 18 | else 19 | h=llr(y,u_hat,N,i,var); 20 | if h>=1 21 | u_hat(i)=0; 22 | else 23 | u_hat(i)=1; 24 | end 25 | end 26 | end 27 | 28 | end 29 | 30 | 31 | -------------------------------------------------------------------------------- /decoder_list.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/decoder_list.m -------------------------------------------------------------------------------- /decoder_list_crc.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/decoder_list_crc.m -------------------------------------------------------------------------------- /decoder_list_crc_layer.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/decoder_list_crc_layer.m -------------------------------------------------------------------------------- /decoder_list_crc_layer_new.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/decoder_list_crc_layer_new.m -------------------------------------------------------------------------------- /decoder_list_crc_layer_new_ver1.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/decoder_list_crc_layer_new_ver1.m -------------------------------------------------------------------------------- /decoder_list_crc_layer_ver1.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/decoder_list_crc_layer_ver1.m -------------------------------------------------------------------------------- /decoder_tree.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/decoder_tree.m -------------------------------------------------------------------------------- /decoder_tree_crc.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/decoder_tree_crc.m -------------------------------------------------------------------------------- /draw.m: -------------------------------------------------------------------------------- 1 | snr=(1.5:0.25:2.5) 2 | nol=[0.028 0.0113 0.003 3.3e-4 0.22e-3] 3 | la=[0.024 0.007 0.002 0.9e-3 0.11e-3] 4 | semilogy(snr,nol,'-r+',snr,la,'-b*') -------------------------------------------------------------------------------- /encoder.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/encoder.m -------------------------------------------------------------------------------- /f.m: -------------------------------------------------------------------------------- 1 | function y=f(x) 2 | %alpha=-0.4527; 3 | %beta=0.0218; 4 | %gama=0.86; 5 | 6 | 7 | 8 | 9 | 10 | if x<10 11 | y=exp(-0.4527*x^0.86+0.0218); 12 | else 13 | if x>=10 14 | y=0.5*(sqrt(pi/x).*exp(-x/4)*(1-3/x)+sqrt(pi/x).*exp(-x/4)*(1+1/(7*x))); 15 | end 16 | end 17 | 18 | 19 | end 20 | 21 | 22 | -------------------------------------------------------------------------------- /f2.cpp: -------------------------------------------------------------------------------- 1 | extern "C" 2 | { 3 | #include 4 | #include 5 | #include 6 | } 7 | #include 8 | #include 9 | 10 | int compare (const void * kp, const void * vp); 11 | static const double ALFA=-0.4527; 12 | static const double BETA= 0.0218; 13 | static const double GAMA= 0.86; 14 | static const double PI= 3.1415926535897932384626433832795; 15 | 16 | double Phi(double x) 17 | { 18 | //assert x>0 19 | assert(x>=0); 20 | 21 | if(x<=10) { 22 | return exp(ALFA*pow(x,GAMA)+BETA); 23 | } 24 | else if(x>10) { 25 | return sqrt(PI/x)*exp(-x/4)*(1+1/(14*x)-3/(2*x)); 26 | } 27 | } 28 | 29 | double Phi_inv(double y, double* phi_inv_in, double *phi_inv_out,int PHI_SAMPLE_LENGTH, int PHI_SAMPLE_RANGE) 30 | { 31 | assert(y>=0); 32 | 33 | double * pItem; 34 | int index; 35 | pItem = (double*) bsearch (&y, phi_inv_in, PHI_SAMPLE_LENGTH, sizeof (double), compare); 36 | index = pItem-phi_inv_in; 37 | return (pItem!=NULL) ? (phi_inv_out[index]): PHI_SAMPLE_RANGE; 38 | } 39 | 40 | int compare (const void * kp, const void * vp) 41 | { 42 | //key is the item I want to search 43 | double key = *(const double*)kp; 44 | const double *vec = (const double*)vp; 45 | 46 | ////////////////////////////////////////////////// 47 | // vec[-1] vec[0] vec[1] 48 | // | | | 49 | // | | 50 | // (vec[-1]+vec[0])/2.0 (vec[0]+vec[1])/2.0 51 | ////////////////////////////////////////////////// 52 | if (key > (vec[0]+vec[1])/2.0) 53 | return 1; 54 | else if (key < (vec[-1]+vec[0])/2.0) 55 | return -1; 56 | else 57 | return 0; 58 | } 59 | 60 | void mexFunction(int nlhs,mxArray *plhs[], int nrhs, const mxArray * prhs[]) 61 | { 62 | //input parameters:function_input, phi_inv_in, phi_inv_out, sample_length, sample_range 63 | double input=mxGetScalar(prhs[0]); 64 | double *phi_inv_in=mxGetPr(prhs[1]); 65 | double *phi_inv_out=mxGetPr(prhs[2]); 66 | int PHI_SAMPLE_LENGTH = mxGetScalar(prhs[3]); 67 | double PHI_SAMPLE_RANGE = mxGetScalar(prhs[4]); 68 | plhs[0]=mxCreateDoubleMatrix(1,1,mxREAL); 69 | double *result=mxGetPr(plhs[0]); 70 | 71 | //*result=Phi_inv(Phi(input), phi_inv_in, phi_inv_out, PHI_SAMPLE_LENGTH, PHI_SAMPLE_RANGE); 72 | 73 | *result=Phi_inv(1-pow((1-Phi(input)), 2), phi_inv_in, phi_inv_out, PHI_SAMPLE_LENGTH, PHI_SAMPLE_RANGE); 74 | 75 | } -------------------------------------------------------------------------------- /f2.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/f2.mexw64 -------------------------------------------------------------------------------- /f_minus.m: -------------------------------------------------------------------------------- 1 | function res=f_minus(alpha, beta) 2 | %%log-likelihood calculation uses this function 3 | 4 | res=sign(alpha) * sign(beta) * min( abs(alpha), abs(beta) ); 5 | -------------------------------------------------------------------------------- /f_plus.m: -------------------------------------------------------------------------------- 1 | function res=f_plus(alpha, beta, u) 2 | %%function used in log-likelihood calculation 3 | 4 | res = sign(-2*u+1) *alpha+beta; 5 | 6 | end 7 | -------------------------------------------------------------------------------- /get_PHI_INV_chart.cpp: -------------------------------------------------------------------------------- 1 | extern "C" 2 | { 3 | #include 4 | #include 5 | #include 6 | } 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | static const double ALFA=-0.4527; 14 | static const double BETA= 0.0218; 15 | static const double GAMA= 0.86; 16 | static const double PI= 3.1415926535897932384626433832795; 17 | 18 | 19 | 20 | double Phi(double x) 21 | { 22 | //assert x>0 23 | assert(x>=0); 24 | 25 | if(x<=10) { 26 | return exp(ALFA*pow(x,GAMA)+BETA); 27 | } 28 | else if(x>10) { 29 | return sqrt(PI/x)*exp(-x/4)*(1+1/(14*x)-3/(2*x)); 30 | } 31 | } 32 | /* 33 | double Phi_inv(double y, double phi_inv_in) 34 | { 35 | assert(y>=0); 36 | 37 | double * pItem; 38 | int index; 39 | pItem = (double*) bsearch (&y, phi_inv_in, PHI_SAMPLE_LENGTH, sizeof (double), compare); 40 | index = pItem-phi_inv_in; 41 | return (pItem!=NULL) ? (phi_inv_out[index]): PHI_SAMPLE_RANGE; 42 | } 43 | */ 44 | /* 45 | int compare (const void * kp, const void * vp) 46 | { 47 | //key is the item I want to search 48 | double key = *(const double*)kp; 49 | const double *vec = (const double*)vp; 50 | 51 | ////////////////////////////////////////////////// 52 | // vec[-1] vec[0] vec[1] 53 | // | | | 54 | // | | 55 | // (vec[-1]+vec[0])/2.0 (vec[0]+vec[1])/2.0 56 | ////////////////////////////////////////////////// 57 | if (key > (vec[0]+vec[1])/2.0) 58 | return 1; 59 | else if (key < (vec[-1]+vec[0])/2.0) 60 | return -1; 61 | else 62 | return 0; 63 | } 64 | */ 65 | void mexFunction(int nlhs,mxArray *plhs[], int nrhs, const mxArray * prhs[]) 66 | { 67 | //parameters are PHI_SAMPLE_LENGTH, PHI_SAMPLE_RANGE 68 | int PHI_SAMPLE_LENGTH = mxGetScalar(prhs[0]); 69 | double PHI_SAMPLE_RANGE = mxGetScalar(prhs[1]); 70 | double PHI_SAMPLE_STEP = PHI_SAMPLE_RANGE/PHI_SAMPLE_LENGTH; 71 | plhs[0]=mxCreateDoubleMatrix(1,PHI_SAMPLE_LENGTH,mxREAL); 72 | plhs[1]=mxCreateDoubleMatrix(1,PHI_SAMPLE_LENGTH,mxREAL); 73 | double *phi_inv_in=mxGetPr(plhs[0]); 74 | double *phi_inv_out=mxGetPr(plhs[1]); 75 | 76 | for (int i=0;(PHI_SAMPLE_RANGE-i*PHI_SAMPLE_STEP)>0;i++) 77 | { 78 | phi_inv_out[i]=PHI_SAMPLE_RANGE-i*PHI_SAMPLE_STEP; 79 | phi_inv_in[i]=Phi(phi_inv_out[i]); 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /get_PHI_INV_chart.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/get_PHI_INV_chart.mexw64 -------------------------------------------------------------------------------- /get_awgn_Pb.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/get_awgn_Pb.m -------------------------------------------------------------------------------- /get_awgn_bhattacharyya.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/get_awgn_bhattacharyya.m -------------------------------------------------------------------------------- /get_bec_bhattacharyya.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/get_bec_bhattacharyya.m -------------------------------------------------------------------------------- /get_punc_awgn_Pb.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/get_punc_awgn_Pb.m -------------------------------------------------------------------------------- /harq_decoder.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/harq_decoder.m -------------------------------------------------------------------------------- /harq_decoder_sc.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/harq_decoder_sc.m -------------------------------------------------------------------------------- /harq_decoder_sc_test.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/harq_decoder_sc_test.m -------------------------------------------------------------------------------- /infoBitComparison.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/infoBitComparison.m -------------------------------------------------------------------------------- /llr.m: -------------------------------------------------------------------------------- 1 | function L=llr(y,u_hat,N,i,var) 2 | %函数用来计算最大似然比,函数使用的递归的思路 3 | %参数y,为译码器输入,u_hat为前面的译码结果,N为码长,i为当前要计算的译码输出编号 4 | 5 | if N~=1 %没有满足递归终止条件,递归继续 6 | if mod(i,2)==1 %i为奇数时 7 | 8 | uoe=mod(u_hat(1:2:i-1)+u_hat(2:2:i-1),2); %i~=1时 9 | ue=u_hat(2:2:i-1); 10 | % L=(llr(y(1:N/2),uoe,N/2,(i+1)/2,var)*llr(y(N/2+1:N),ue,N/2,(i+1)/2,var)+1)/(llr(y(1:N/2),uoe,N/2,(i+1)/2,var)+llr(y(N/2+1:N),ue,N/2,(i+1)/2,var)); 11 | L=f_minus( llr(y(1:N/2),uoe,N/2,(i+1)/2,var), llr(y(N/2+1:N),ue,N/2,(i+1)/2,var) ); 12 | % if L>100 13 | % L=100; 14 | % else 15 | % if L<1/100 16 | % L=1/100; 17 | % end 18 | % end 19 | 20 | else %i为偶数时 21 | uoe=mod(u_hat(1:2:i-2)+u_hat(2:2:i-2),2); 22 | ue=u_hat(2:2:i-2); 23 | % L=llr(y(1:N/2),uoe,N/2,i/2,var)^(1-2*u_hat(i-1))*llr(y(N/2+1:N),ue,N/2,i/2,var); 24 | L=f_plus(llr(y(1:N/2),uoe,N/2,i/2,var), llr(y(N/2+1:N),ue,N/2,i/2,var), u_hat(i-1)); 25 | % if L>100 26 | % L=100; 27 | % else 28 | % if L<1/100 29 | % L=1/100; 30 | % end 31 | % end 32 | end 33 | else 34 | L=-2*y/var; 35 | 36 | end 37 | 38 | 39 | end 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /llr_new.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/llr_new.m -------------------------------------------------------------------------------- /logAPP.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/logAPP.m -------------------------------------------------------------------------------- /logAPP1.c: -------------------------------------------------------------------------------- 1 | #include "mex.h" 2 | #include "malloc.h" 3 | #include "math.h" 4 | #define PI 3.1415926 5 | #define MAX(a,b) ((a>b)?a:b) 6 | #define ABS(x) (x>=0?x:-x) 7 | 8 | //double maxStar(double x,double y); //max* 9 | //double logAPP(double y[],int u_hat[],int ui,int N,int i,double var);//logAPP 10 | double W(double y,int x,double var) 11 | { 12 | return(sqrt(1/(2*PI*var))*exp((y+1-2*x)*(y+1-2*x)/(-2*var))); 13 | } 14 | 15 | double maxStar(double x,double y) 16 | { 17 | double z; 18 | z=MAX(x,y)+log(1+exp(-ABS((x-y)))); 19 | return(z); 20 | } 21 | 22 | double logAPPbase(double y,int x,double var) 23 | { 24 | return(log(W(y,x,var)/(W(y,0,var)+W(y,1,var)))); 25 | } 26 | 27 | double logAPP(double y[],int u_hat[],int ui,int N,int i,double var) 28 | { 29 | double M=0,M0=0,M1=0;//M is the output, M0 and M1 are middle parameters 30 | int *uoe; 31 | int *ue; 32 | int ii;// 33 | if(N!=2) 34 | { 35 | if(i%2==1) 36 | { 37 | if(i==1) 38 | { 39 | M0=logAPP(y,u_hat,ui,N/2,i,var)+logAPP(y+N/2,u_hat,0,N/2,i,var); 40 | M1=logAPP(y,u_hat,ui^1,N/2,i,var)+logAPP(y+N/2,u_hat,1,N/2,i,var); 41 | M=maxStar(M0,M1); 42 | } 43 | else 44 | 45 | { 46 | uoe=(int *)mxCalloc((i-1)/2,sizeof(int)); 47 | ue=(int *)mxCalloc((i-1)/2,sizeof(int)); 48 | for(ii=0;ii<=(i-1)/2-1;ii++) 49 | { 50 | uoe[ii]=u_hat[2*ii]^u_hat[2*ii+1]; 51 | ue[ii]=u_hat[2*ii+1]; 52 | } 53 | 54 | M0=logAPP(y,uoe,ui,N/2,(i+1)/2,var)+logAPP(y+N/2,ue,0,N/2,(i+1)/2,var); 55 | M1=logAPP(y,uoe,ui^1,N/2,(i+1)/2,var)+logAPP(y+N/2,ue,1,N/2,(i+1)/2,var); 56 | M=maxStar(M0,M1); 57 | mxFree(uoe); 58 | mxFree(ue); 59 | } 60 | } 61 | else 62 | { 63 | uoe=(int *)mxCalloc((i-2)/2,sizeof(int)); 64 | ue=(int *)mxCalloc((i-2)/2,sizeof(int)); 65 | for(ii=0;ii<=((i-2)/2-1);ii++) 66 | { 67 | uoe[ii]=u_hat[2*ii]^u_hat[2*ii+1]; 68 | ue[ii]=u_hat[2*ii+1]; 69 | } 70 | 71 | M=logAPP(y,uoe,u_hat[i-2]^ui,N/2,i/2,var)+logAPP(y+N/2,ue,ui,N/2,i/2,var); 72 | mxFree(uoe); 73 | mxFree(ue); 74 | } 75 | 76 | } 77 | else 78 | { 79 | if(i==1) 80 | { 81 | M0=logAPPbase(y[0],ui,var)+logAPPbase(y[1],0,var); 82 | M1=logAPPbase(y[0],ui^1,var)+logAPPbase(y[1],1,var); 83 | M=maxStar(M0,M1); 84 | } 85 | else 86 | { 87 | M=logAPPbase(y[0],u_hat[0]^ui,var)+logAPPbase(y[1],ui,var); 88 | } 89 | } 90 | return(M); 91 | } 92 | 93 | 94 | 95 | void mexFunction(int nlhs,mxArray *plhs[], int nrhs, const mxArray * prhs[]) 96 | { 97 | double *y; //received vector of the channel, pointer 98 | double *u_hat; //last (i-1) decoded bits, pointer 99 | int ui; //assumed value of i th decoded bites, value 100 | int N; //length of the code, value 101 | int i; //the number of the current bit, value 102 | double var; //the variance of the gaussian noise, value 103 | double *M; //the output 104 | int *u_hat_int; //the interger of the u_hat, because u_hat is double 105 | int ii; //u_hat transfer counter 106 | 107 | 108 | y=mxGetPr(prhs[0]); // 109 | u_hat=mxGetPr(prhs[1]); // 110 | ui=mxGetScalar(prhs[2]); // 111 | N=mxGetScalar(prhs[3]); // 112 | i=mxGetScalar(prhs[4]); // 113 | var=mxGetScalar(prhs[5]); // 114 | 115 | plhs[0]=mxCreateDoubleMatrix(1,1,mxREAL); 116 | M=mxGetPr(plhs[0]); 117 | 118 | u_hat_int=mxCalloc(i-1,sizeof(int)); 119 | for(ii=0;ii<=i-1;ii++) 120 | { 121 | u_hat_int[ii]=(int)u_hat[ii]; 122 | } 123 | 124 | *M=logAPP(y,u_hat_int,ui,N,i,var); // 125 | //mxFree(u_hat_int); 126 | } 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /logAPP1.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/logAPP1.mexw64 -------------------------------------------------------------------------------- /logAPPBase.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/logAPPBase.m -------------------------------------------------------------------------------- /logAPP_base.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/logAPP_base.m -------------------------------------------------------------------------------- /lr_new.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/lr_new.m -------------------------------------------------------------------------------- /phi_inv_in_out_chart.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/phi_inv_in_out_chart.mat -------------------------------------------------------------------------------- /polarcode_awgn.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_awgn.m -------------------------------------------------------------------------------- /polarcode_awgn_list_crc.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_awgn_list_crc.m -------------------------------------------------------------------------------- /polarcode_awgn_list_crc_layer_multi_path.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_awgn_list_crc_layer_multi_path.m -------------------------------------------------------------------------------- /polarcode_awgn_list_crc_layer_new_multi_path.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_awgn_list_crc_layer_new_multi_path.m -------------------------------------------------------------------------------- /polarcode_awgn_list_crc_layer_new_single_path.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_awgn_list_crc_layer_new_single_path.m -------------------------------------------------------------------------------- /polarcode_awgn_list_crc_layer_single_path.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_awgn_list_crc_layer_single_path.m -------------------------------------------------------------------------------- /polarcode_awgn_punc_harq.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_awgn_punc_harq.m -------------------------------------------------------------------------------- /polarcode_awgn_tree.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_awgn_tree.m -------------------------------------------------------------------------------- /polarcode_sc_crc_harq.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_sc_crc_harq.m -------------------------------------------------------------------------------- /polarcode_sc_harq.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_sc_harq.m -------------------------------------------------------------------------------- /polarcode_sc_punc_harq.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_sc_punc_harq.m -------------------------------------------------------------------------------- /polarcode_scl_crc_harq.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_scl_crc_harq.m -------------------------------------------------------------------------------- /polarcode_scl_punc_harq.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/polarcode_scl_punc_harq.m -------------------------------------------------------------------------------- /rev_shuffle.m: -------------------------------------------------------------------------------- 1 | function y=rev_shuffle(x) 2 | N=length(x); 3 | if N==1 4 | y=x; 5 | else 6 | y(1:N/2)=x(1:2:N); 7 | y(N/2+1:N)=x(2:2:N); 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /www.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fantasua/PolarCodesMatLab/3a77d338acd26cb143556773721806413a4fe3d6/www.m --------------------------------------------------------------------------------