📄 errlocp.c
字号:
/*============================================================================ * Syntax: [sigma, err] = errlocp(syndrome, t, tp, pow_dim, err, type_flag) * ERRLOCP Computes the error-location polynomial. * [SIGMA, ERR] = ERRLOCP(SYNDROME, T, TP, ERR, FLAG) computes the * error-location polynomial from length 2*T input vector SYNDROME. * T is the error-correction capability. Tp is the complete tuple list * of all elements in GF(2^M). POW_DIM = 2^M-1, which is the dimension * of GF(2^M). ERR contains the error information in the computation. * FLAG indicates the method to be used in the computation. * FLAG = 1, uses normal method. * FLAG = 0, use simplified method. The simplified method can be * used for binary code only. * * Warning: This function does not provide error-check. Make sure * the parameters are signed correctly. * *============================================================================ * Jun Wu, The Mathworks, Inc. * Dec-10, 1995 * * Copyright (c) 1995-96 by The MAthWorks, Inc. * All Rights Reserved * $Revision: 1.1 $ $Date: 1996/04/01 18:13:51 $ *========================================================================== */#include <math.h>#include "mex.h"#include "gflib.c"void mexFunction(int nlhs, Matrix *plhs[], int nrhs, Matrix *prhs[]){ int i, t, np, mp, pow_dim, prim, Flag, err_In[1], len_Out[1]; int *syndr, *pp, *Iwork, *pNum, *pInv, *sigma_Out; double *sigma, *errOut, *syndrome, *T, *p, *Pow_dim, *err, *flag; syndrome = mxGetPr(prhs[0]); T = mxGetPr(prhs[1]); p = mxGetPr(prhs[2]); Pow_dim = mxGetPr(prhs[3]); err = mxGetPr(prhs[4]); flag = mxGetPr(prhs[5]); np = mxGetM(prhs[2]); mp = mxGetN(prhs[2]); if ( nrhs < 6 || *T < 0 || *Pow_dim < np-1 || *err<0 || *flag<0 || mxGetM(prhs[0])*mxGetN(prhs[0])<2*(*T) ){ mexErrMsgTxt("Not Correct Input Argument! Input again!"); return; } /* converting the type of variables to integer.*/ t = (int)*T; Flag = (int)*flag; err_In[0] = (int)*err; pow_dim = (int)*Pow_dim; syndr = (int *)mxCalloc(2*t,sizeof(int)); len_Out[0] = 0; for(i=0; i<2*t; i++) syndr[i] = (int) syndrome[i]; pp = (int *)mxCalloc(np*mp,sizeof(int)); for(i=0; i<np*mp; i++) pp[i] = (int) p[i]; /* set up a integer working space (int *)Iwork for functions. */ if( Flag ){ t=2*t; Iwork = (int *)mxCalloc((2+mp)*np+5*(t+2)+(t+5)*(t+1), sizeof(int)); } else { Iwork = (int *)mxCalloc((2+mp)*np+5*(t+2)+(t+5)*(t+1), sizeof(int)); } pNum = Iwork; pInv = Iwork + np; prim = 2; pNumInv(pp, np, mp, prim, pNum, pInv, pInv+np); if ( Flag ){ sigma_Out = Iwork+(2+mp)*np; errlocp1(syndr,t,pNum,pInv,pow_dim,err_In,sigma_Out+(t+1),sigma_Out,len_Out); }else{ sigma_Out = Iwork+(2+mp)*np; errlocp0(syndr,t,pNum,pInv,pow_dim,err_In,sigma_Out+(t+1),sigma_Out,len_Out); } /* output parameters list */ sigma = mxGetPr(plhs[0] = mxCreateFull(1, len_Out[0], 0)); for(i=0; i < len_Out[0]; i++) sigma[i] = (double)sigma_Out[i]; errOut = mxGetPr(plhs[1] = mxCreateFull(1, 1, 0)); if ( err_In[0] != 0 ) errOut[0] = 1; else errOut[0] = 0; return;}/*--end of errlocp.c--*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -