📄 bchcore.c
字号:
/*============================================================================ * Syntax: [msg, err, ccode] = bchcore(code, pow_dim, dim, k, t, tp) *BCHCORE The core part of the BCH decode. * [MSG, ERR, CCODE] = BCHCORE(CODE, POW_DIM, DIM, K, T, TP) decodes * a BCH code, in which CODE is a code word row vector, with its column * size being POW_DIM. POW_DIM equals 2^DIM -1. K is the message length, * T is the error correction capability. TP is a complete list of the * elements in GF(2^DIM). * * This function is can share the information between a SIMULINK file and * MATLAB functions. It is not designed to be called directly. There is * no error check in order to eliminate overhead. *============================================================================ * Original designed by Wes Wang, * Jun Wu, The Mathworks, Inc. * Dec-12, 1995 * * Copyright (c) 1995-96 by The MAthWorks, Inc. * All Rights Reserved * $Revision: 1.1 $ $Date: 1996/04/01 18:13:45 $ *========================================================================== */#include <math.h>#include "mex.h"#include "gflib.c"void mexFunction(int nlhs, Matrix *plhs[], int nrhs, Matrix *prhs[]){ int i, np, mp; int pow_dim, dim, k, t; int *code, *pp, *ccode, *err, *Iwork; double *Msg, *Err, *CCode; np = mxGetM(prhs[5]); mp = mxGetN(prhs[5]); pow_dim = (int)mxGetPr(prhs[1])[0]; code = (int *)mxCalloc(pow_dim,sizeof(int)); for(i=0; i<pow_dim; i++) code[i] = (int)mxGetPr(prhs[0])[i]; dim = (int)mxGetPr(prhs[2])[0]; k = (int)mxGetPr(prhs[3])[0]; t = mxGetPr(prhs[4])[0]; pp = (int *)mxCalloc(np*mp,sizeof(int)); for(i=0; i<np*mp; i++) pp[i] = (int)mxGetPr(prhs[5])[i]; /* set up a integer working space (int *)Iwork. */ Iwork = (int *)mxCalloc( (2+dim)*(2*pow_dim+1)+t*t+15*t+17, sizeof(int)); ccode= (int *)mxCalloc(pow_dim,sizeof(int)); err = Iwork; bchcore(code,pow_dim,dim,k,t,pp,Iwork+1,err,ccode); Msg = mxGetPr(plhs[0] = mxCreateFull(1, k, 0)); Err = mxGetPr(plhs[1] = mxCreateFull(1, 1, 0)); CCode = mxGetPr(plhs[2] = mxCreateFull(1, pow_dim, 0)); for(i=0; i < pow_dim; i++) CCode[i] = (double)ccode[i]; for(i=pow_dim-k; i < pow_dim; i++) Msg[i-pow_dim+k] = CCode[i]; Err[0] = (double)err[0]; return;}/* end of bchcore.c */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -