打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
DataMatrix编码3
        DataMatrixECC200采用Reed-Solomon纠错编码来为其提供纠错能力。RS编码的目标是计算出纠错码字,参考表http://blog.sina.com.cn/s/blog_4572df4e01019vhd.html来确定纠错码字的长度,考虑数据码字:6667 68 69 70 142 12956(“ABCDE12”通过ASCII编码),长度为8,则纠错码字长度为10,表示为RS(n,k)=RS(18, 8)。   设C(x)为数据码

  E(x)为纠错码字
,G(x)为生成多项式,则:
   

   由RS检验码生成多项式的一般形式为:
,则有:  

X分别取值
,得到方程组:
  

   然后用通过高斯消除法计算出E(x)={75 145 5546 20 95 253 237 62 111},最终生成18位码字{66 67 68 69 70 142 129 56 75 14555 46 20 95 253 237 62 111}。

算法如下:
int GfAdd(int a, int b){
  return  a ^ b;
}
//a * b
int GfMult(int a, int b){
   return (a == 0 || b == 0) ? 0: alphaTo[(expOf[a] + expOf[b]) % nn];
}
// a * alpha^b
int GfMult2(int a, int b){
   return a== 0 ? 0 :alphaTo[(expOf[a] + b) % nn];
}
// a/b
int GfDiv(int a, int b) {
    if( a==0)return 0;
    if( a==b)return 1;
    returnexpOf[a] > expOf[b] ?
    alphaTo[expOf[a] - expOf[b] ] : alphaTo[ nn + expOf[a] - expOf[b] ] ;
}
void gaussion(){
    int total =18;
    int data =8;
    int error =10;
    int* codes =new int[total];
    int* errors= new int[error];
    int* polys =new int[error*error];

    int i, j, k,d;       
    codes[0] =66;
    codes[1] =67;
    codes[2] =68;
    codes[3] =69;
    codes[4] =70;
    codes[5] =142;
    codes[6] =129;
    codes[7] =56;

    for(i=0;i       //sum of each polynomial
       int sum = 0;
       for( j=0;j           sum = GfAdd( sum, GfMult2( codes[j], (total-1-j)*(i+1) ) );
       errors[i] = sum;
       //polynomial matrix
       int index = i*error;
       for( j=0;j           polys[index+j] = alphaTo[j*(i+1)];
    }
    //gaussionelimination
    for(i=0;i       //diagonal postion
       d = i*error+i;
       int diagonal = polys[d];
       //diagonal --> 1
       int index = i*error;
       for( j=0;j           polys[index+j] = GfDiv( polys[index+j], diagonal );
       errors[i] = GfDiv( errors[i], diagonal );
       //otherrows - thisrow
       for( k=0;k           if( k!=i ){//another row
               int index2 = k*error;
               int coefficient = polys[index2+i];
               //each column( polynomial[k] = polynomial[k] -polynomial[i]*coefficient )
               for( int m=0;m                   polys[index2+m] = GfAdd( polys[index2+m], GfMult(coefficient,polys[index+m]) );
               }
               errors[k] =GfAdd( errors[k], GfMult(coefficient, errors[i]));
           }
       }
    }
    //errors--> codes
    for(j=data++,i=error-1;i>=0;i-- )
       codes[j++] = errors[i];
}



本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Base64编码解码C语言实现
Erasure code
Estimating BER in Broadband Designs | EE Times
科普&图集:神圣几何学概况(44张)
以后别写程序了,65个源码网站奉献给大家
unicode编码转换gb2312编码
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服