亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bch3.c

?? 通信類程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
 * File:    bch3.c
 * Title:   Encoder/decoder for binary BCH codes in C (Version 3.1)
 * Author:  Robert Morelos-Zaragoza
 * Date:    August 1994
 * Revised: June 13, 1997
 *
 * ===============  Encoder/Decoder for binary BCH codes in C =================
 *
 * Version 1:   Original program. The user provides the generator polynomial
 *              of the code (cumbersome!).
 * Version 2:   Computes the generator polynomial of the code.
 * Version 3:   No need to input the coefficients of a primitive polynomial of
 *              degree m, used to construct the Galois Field GF(2**m). The
 *              program now works for any binary BCH code of length such that:
 *              2**(m-1) - 1 < length <= 2**m - 1
 *
 * Note:        You may have to change the size of the arrays to make it work.
 *
 * The encoding and decoding methods used in this program are based on the
 * book "Error Control Coding: Fundamentals and Applications", by Lin and
 * Costello, Prentice Hall, 1983.
 *
 * Thanks to Patrick Boyle (pboyle@era.com) for his observation that 'bch2.c'
 * did not work for lengths other than 2**m-1 which led to this new version.
 * Portions of this program are from 'rs.c', a Reed-Solomon encoder/decoder
 * in C, written by Simon Rockliff (simon@augean.ua.oz.au) on 21/9/89. The
 * previous version of the BCH encoder/decoder in C, 'bch2.c', was written by
 * Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) on 5/19/92.
 *
 * NOTE:    
 *          The author is not responsible for any malfunctioning of
 *          this program, nor for any damage caused by it. Please include the
 *          original program along with these comments in any redistribution.
 *
 *  For more information, suggestions, or other ideas on implementing error
 *  correcting codes, please contact me at:
 *
 *                           Robert Morelos-Zaragoza
 *                           5120 Woodway, Suite 7036
 *                           Houston, Texas 77056
 *
 *                    email: r.morelos-zaragoza@ieee.org
 *
 * COPYRIGHT NOTICE: This computer program is free for non-commercial purposes.
 * You may implement this program for any non-commercial application. You may 
 * also implement this program for commercial purposes, provided that you
 * obtain my written permission. Any modification of this program is covered
 * by this copyright.
 *
 * == Copyright (c) 1994-7,  Robert Morelos-Zaragoza. All rights reserved.  ==
 *
 * m = order of the Galois field GF(2**m) 
 * n = 2**m - 1 = size of the multiplicative group of GF(2**m)
 * length = length of the BCH code
 * t = error correcting capability (max. no. of errors the code corrects)
 * d = 2*t + 1 = designed min. distance = no. of consecutive roots of g(x) + 1
 * k = n - deg(g(x)) = dimension (no. of information bits/codeword) of the code
 * p[] = coefficients of a primitive polynomial used to generate GF(2**m)
 * g[] = coefficients of the generator polynomial, g(x)
 * alpha_to [] = log table of GF(2**m) 
 * index_of[] = antilog table of GF(2**m)
 * data[] = information bits = coefficients of data polynomial, i(x)
 * bb[] = coefficients of redundancy polynomial x^(length-k) i(x) modulo g(x)
 * numerr = number of errors 
 * errpos[] = error positions 
 * recd[] = coefficients of the received polynomial 
 * decerror = number of decoding errors (in _message_ positions) 
 *
 */

#include <math.h>
#include <stdio.h>

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("bch3: An encoder/decoder for binary BCH codes\n");
	printf("Copyright (c) 1994-7. Robert Morelos-Zaragoza.\n");
	printf("This program is free, please read first the copyright notice.\n");
	printf("\nFirst, enter 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<m; 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**m) from the irreducible polynomial p(X) with
 * coefficients in p[0]..p[m].
 *
 * Lookup tables:
 *   index->polynomial form: alpha_to[] contains j=alpha^i;
 *   polynomial form -> index form:	index_of[j=alpha^i] = i
 *
 * alpha=2 is the primitive element of GF(2**m) 
 */
{
	register int    i, mask;

	mask = 1;
	alpha_to[m] = 0;
	for (i = 0; i < m; i++) {
		alpha_to[i] = mask;
		index_of[alpha_to[i]] = i;
		if (p[i] != 0)
			alpha_to[m] ^= mask;
		mask <<= 1;
	}
	index_of[alpha_to[m]] = m;
	mask >>= 1;
	for (i = m + 1; i < n; i++) {
		if (alpha_to[i - 1] >= mask)
		  alpha_to[i] = alpha_to[m] ^ ((alpha_to[i - 1] ^ mask) << 1);
		else
		  alpha_to[i] = alpha_to[i - 1] << 1;
		index_of[alpha_to[i]] = i;
	}
	index_of[0] = -1;
}


void 
gen_poly()
/*
 * Compute the generator polynomial of a binary BCH code. Fist generate the
 * cycle sets modulo 2**m - 1, cycle[][] =  (i, 2*i, 4*i, ..., 2^l*i). Then
 * determine those cycle sets that contain integers in the set of (d-1)
 * consecutive integers {1..(d-1)}. The generator polynomial is calculated
 * as the product of linear factors of the form (x+alpha^i), for every i in
 * the above cycle sets.
 */
{
	register int	ii, jj, ll, kaux;
	register int	test, aux, nocycles, root, noterms, rdncy;
	int             cycle[1024][21], size[1024], min[1024], zeros[1024];

	/* Generate cycle sets modulo n, n = 2**m - 1 */
	cycle[0][0] = 0;
	size[0] = 1;
	cycle[1][0] = 1;
	size[1] = 1;
	jj = 1;			/* cycle set index */
	if (m > 9)  {
		printf("Computing cycle sets modulo %d\n", n);
		printf("(This may take some time)...\n");
	}
	do {
		/* Generate the jj-th cycle set */
		ii = 0;
		do {
			ii++;
			cycle[jj][ii] = (cycle[jj][ii - 1] * 2) % n;
			size[jj]++;
			aux = (cycle[jj][ii] * 2) % n;
		} while (aux != cycle[jj][0]);
		/* Next cycle set representative */
		ll = 0;
		do {
			ll++;
			test = 0;
			for (ii = 1; ((ii <= jj) && (!test)); ii++)	
			/* Examine previous cycle sets */
			  for (kaux = 0; ((kaux < size[ii]) && (!test)); kaux++)
			     if (ll == cycle[ii][kaux])
			        test = 1;
		} while ((test) && (ll < (n - 1)));
		if (!(test)) {
			jj++;	/* next cycle set index */
			cycle[jj][0] = ll;
			size[jj] = 1;
		}
	} while (ll < (n - 1));
	nocycles = jj;		/* number of cycle sets modulo n */

	printf("Enter the error correcting capability, t: ");
	scanf("%d", &t);

	d = 2 * t + 1;

	/* Search for roots 1, 2, ..., d-1 in cycle sets */
	kaux = 0;
	rdncy = 0;
	for (ii = 1; ii <= nocycles; ii++) {
		min[kaux] = 0;
		test = 0;
		for (jj = 0; ((jj < size[ii]) && (!test)); jj++)
			for (root = 1; ((root < d) && (!test)); root++)
				if (root == cycle[ii][jj])  {
					test = 1;
					min[kaux] = ii;
				}
		if (min[kaux]) {
			rdncy += size[min[kaux]];
			kaux++;
		}
	}
	noterms = kaux;
	kaux = 1;
	for (ii = 0; ii < noterms; ii++)
		for (jj = 0; jj < size[min[ii]]; jj++) {
			zeros[kaux] = cycle[min[ii]][jj];
			kaux++;
		}

	k = length - rdncy;

    if (k<0)
      {
         printf("Parameters invalid!\n");
         exit(0);
      }

	printf("This is a (%d, %d, %d) binary BCH code\n", length, k, d);

	/* Compute the generator polynomial */
	g[0] = alpha_to[zeros[1]];
	g[1] = 1;		/* g(x) = (X + zeros[1]) initially */
	for (ii = 2; ii <= rdncy; ii++) {
	  g[ii] = 1;
	  for (jj = ii - 1; jj > 0; jj--)
	    if (g[jj] != 0)
	      g[jj] = g[jj - 1] ^ alpha_to[(index_of[g[jj]] + zeros[ii]) % n];
	    else
	      g[jj] = g[jj - 1];
	  g[0] = alpha_to[(index_of[g[0]] + zeros[ii]) % n];
	}
	printf("Generator polynomial:\ng(x) = ");
	for (ii = 0; ii <= rdncy; ii++) {
	  printf("%d", g[ii]);
	  if (ii && ((ii % 50) == 0))
	    printf("\n");
	}
	printf("\n");
}


void 
encode_bch()
/*
 * Compute redundacy bb[], the coefficients of b(x). The redundancy
 * polynomial b(x) is the remainder after dividing x^(length-k)*data(x)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区三区不卡在线观看 | 国产成人免费在线视频| 亚洲美女在线国产| 最新中文字幕一区二区三区 | 色综合天天综合色综合av| 国产一区二区成人久久免费影院| 日韩一区精品视频| 午夜精品福利一区二区三区av| 亚洲国产一区二区三区青草影视| 亚洲免费观看高清| 午夜精品国产更新| 精品一区二区三区香蕉蜜桃| 国内精品免费**视频| 国产精一区二区三区| 国产成人精品影视| 色哟哟精品一区| 欧美老女人在线| 久久这里只有精品视频网| 精品久久久久久久久久久久久久久| 日韩精品一区二区三区视频| 久久天天做天天爱综合色| 中文字幕中文字幕一区二区 | 日韩一区二区免费在线电影| 精品久久久久久久久久久久久久久久久| 久久成人精品无人区| 国产一区二区三区四区在线观看| 成人一区二区三区在线观看| 91欧美一区二区| 欧美一级精品在线| 日本一区二区视频在线观看| 亚洲蜜臀av乱码久久精品蜜桃| 午夜电影网亚洲视频| 国产麻豆一精品一av一免费| av不卡免费电影| 日韩欧美色电影| 中文字幕在线播放不卡一区| 性做久久久久久免费观看欧美| 狠狠v欧美v日韩v亚洲ⅴ| 99精品1区2区| 久久新电视剧免费观看| 亚洲一区自拍偷拍| 国产激情91久久精品导航| 欧美体内she精高潮| 久久久久久久综合日本| 婷婷一区二区三区| 99精品在线观看视频| 欧美成人女星排行榜| 一区二区三区自拍| 国产成人午夜99999| 7777精品伊人久久久大香线蕉完整版| 久久精子c满五个校花| 水野朝阳av一区二区三区| 99久久免费精品| 久久久久久久久蜜桃| 蜜桃一区二区三区在线| 欧美日韩一本到| 亚洲乱码精品一二三四区日韩在线| 久久99久久99小草精品免视看| 欧美性大战久久久久久久蜜臀| 国产精品灌醉下药二区| 韩国三级中文字幕hd久久精品| 欧美精品乱码久久久久久按摩| 亚洲另类春色国产| 成人av电影免费在线播放| 久久久91精品国产一区二区三区| 美脚の诱脚舐め脚责91 | 奇米色777欧美一区二区| 色婷婷精品大视频在线蜜桃视频| 国产精品久久久一本精品| 国产 欧美在线| 久久久久久一二三区| 激情综合色综合久久综合| 日韩三级视频在线看| 免费的成人av| 日韩你懂的在线观看| 久久99国产精品久久99果冻传媒| 69堂国产成人免费视频| 青青草原综合久久大伊人精品优势| 精品视频全国免费看| 亚洲一区二区综合| 51午夜精品国产| 蜜臀av一区二区| 久久久久久久久久电影| 国产成人精品一区二区三区四区| 欧美激情一区二区三区蜜桃视频| 国产v综合v亚洲欧| 成人欧美一区二区三区小说| 一本色道**综合亚洲精品蜜桃冫| 洋洋av久久久久久久一区| 欧美伊人久久大香线蕉综合69| 亚洲一二三专区| 日韩精品一区二区三区蜜臀| 国产电影一区二区三区| 18成人在线视频| 欧美精品久久久久久久多人混战 | 中文字幕成人网| 91网站最新地址| 亚洲成av人综合在线观看| 欧美一区二区三区系列电影| 国模少妇一区二区三区| 国产精品成人免费| 欧美丰满高潮xxxx喷水动漫| 国产一区二区三区免费在线观看| 欧美韩国日本综合| 欧美日韩中文字幕一区二区| 经典一区二区三区| 亚洲私人黄色宅男| 日韩三级伦理片妻子的秘密按摩| 国产v综合v亚洲欧| 丝袜美腿亚洲综合| 国产精品女人毛片| 91精品免费观看| 色综合一个色综合| 国产乱淫av一区二区三区| 有码一区二区三区| 国产婷婷色一区二区三区 | 免费看精品久久片| 综合在线观看色| 欧美成人vr18sexvr| 一本在线高清不卡dvd| 国产在线一区二区综合免费视频| 一区二区三区国产精华| 国产日韩精品一区二区三区在线| 欧美精品1区2区3区| 99国产精品久久久久久久久久久 | 99麻豆久久久国产精品免费| 秋霞电影网一区二区| 亚洲与欧洲av电影| 国产精品美女久久久久久2018 | 亚洲少妇30p| 欧美一区二区日韩一区二区| 色综合天天综合网天天看片| 国产成人精品影视| 国内国产精品久久| 美女脱光内衣内裤视频久久影院| 一区二区三区免费观看| 国产日产欧美一区| 精品国产污污免费网站入口| 欧美色区777第一页| 色悠久久久久综合欧美99| 成人91在线观看| 成人永久看片免费视频天堂| 国产一区二区调教| 久久99国产精品麻豆| 久久国产麻豆精品| 国精产品一区一区三区mba视频| 日本大胆欧美人术艺术动态| 香蕉加勒比综合久久| 五月婷婷激情综合| 日韩精品成人一区二区三区| 五月综合激情网| 日韩av在线免费观看不卡| 午夜成人免费视频| 青青青伊人色综合久久| 蜜臀91精品一区二区三区| 毛片一区二区三区| 狠狠网亚洲精品| 国产经典欧美精品| 成人综合在线观看| k8久久久一区二区三区| 91久久精品一区二区三区| 欧美日韩精品一区视频| 91精品国产全国免费观看| 日韩欧美精品在线视频| 久久久久久久久久久久久久久99| 久久精品视频免费| 亚洲日本乱码在线观看| 亚洲高清不卡在线| 久久精品国产精品青草| 国产成人精品影视| 91亚洲国产成人精品一区二三| 在线视频一区二区三| 欧美一激情一区二区三区| 久久伊人中文字幕| 最新国产成人在线观看| 日韩精品久久理论片| 国产成人精品三级| 91国产福利在线| 日韩欧美卡一卡二| 综合激情网...| 日韩av一级片| www.亚洲人| 91精品婷婷国产综合久久竹菊| 久久久午夜精品理论片中文字幕| 中文字幕欧美三区| 爽好久久久欧美精品| 高清不卡在线观看av| 欧美在线播放高清精品| 2020国产精品自拍| 一区二区三区在线高清| 极品少妇一区二区| 欧美亚洲一区二区三区四区| 欧美精品一区视频| 亚洲已满18点击进入久久| 国产高清不卡二三区| 欧美欧美午夜aⅴ在线观看| 欧美国产激情二区三区 | 国产精品网曝门| 免费国产亚洲视频| 色国产精品一区在线观看|