资源简介
该代码能够实现bch编码功能,很有用处,希望能够给你带来帮助
代码片段和文件信息
// ------------------------------------------------------------------------
// File: bch_bm.c
// Date: April 3 2002
// Description: An encoder/decoder for binary BCH codes
// Error correction using the BERLEKAMP-MASSEY ALGORITHM
// ------------------------------------------------------------------------
// This program is complementary material for the book:
//
// R.H. Morelos-Zaragoza The Art of Error Correcting Coding Wiley 2002.
//
// ISBN 0471 49581 6
//
// This and other programs are available at http://the-art-of-ecc.com
//
// You may use this program for academic and personal purposes only.
// If this program is used to perform simulations whose results are
// published in a journal or book please refer to the book above.
//
// The use of this program in a commercial product requires explicit
// written permission from the author. The author is not responsible or
// liable for damage or loss that may be caused by the use of this program.
//
// Copyright (c) 2002. Robert H. Morelos-Zaragoza. All rights reserved.
// ------------------------------------------------------------------------
#include
#include
int m n length k t d;
int p[21];
int alpha_to[1048576] index_of[1048576] g[548576];
int recd[1048576] data[1048576] bb[548576];
int seed;
int numerr errpos[1024] decerror = 0;
void
read_p()
/*
* Read m the degree of a primitive polynomial p(x) used to compute the
* Galois field GF(2**m). Get precomputed coefficients p[] of p(x). Read
* the code length.
*/
{
int i ninf;
printf(“\nEnter a value of m such that the code length is\n“);
printf(“2**(m-1) - 1 < length <= 2**m - 1\n\n“);
do {
printf(“Enter m (between 2 and 20): “);
scanf(“%d“ &m);
} while ( !(m>1) || !(m<21) );
for (i=1; i p[i] = 0;
p[0] = p[m] = 1;
if (m == 2) p[1] = 1;
else if (m == 3) p[1] = 1;
else if (m == 4) p[1] = 1;
else if (m == 5) p[2] = 1;
else if (m == 6) p[1] = 1;
else if (m == 7) p[1] = 1;
else if (m == 8) p[4] = p[5] = p[6] = 1;
else if (m == 9) p[4] = 1;
else if (m == 10) p[3] = 1;
else if (m == 11) p[2] = 1;
else if (m == 12) p[3] = p[4] = p[7] = 1;
else if (m == 13) p[1] = p[3] = p[4] = 1;
else if (m == 14) p[1] = p[11] = p[12] = 1;
else if (m == 15) p[1] = 1;
else if (m == 16) p[2] = p[3] = p[5] = 1;
else if (m == 17) p[3] = 1;
else if (m == 18) p[7] = 1;
else if (m == 19) p[1] = p[5] = p[6] = 1;
else if (m == 20) p[3] = 1;
printf(“p(x) = “);
n = 1;
for (i = 0; i <= m; i++) {
n *= 2;
printf(“%1d“ p[i]);
}
printf(“\n“);
n = n / 2 - 1;
ninf = (n + 1) / 2 - 1;
do {
printf(“Enter code length (%d < length <= %d): “ ninf n);
scanf(“%d“ &length);
} while ( !((length <= n)&&(length>ninf)) );
}
void
generate_gf()
/*
* Generate field GF(2*
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 15015 2009-05-25 10:39 bch\bch_bm.c
- 上一篇:opengl的立方体消隐算法
- 下一篇:c++编写病毒方法+100个病毒源码
评论
共有 条评论