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

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

?? bch4836.c.txt

?? 通信類程序
?? TXT
字號:
/*
 * File:    bch4836.c 
 * Author:  Robert Morelos-Zaragoza
 *
 * %%%%%%%%%%% Encoder/Decoder for a (48, 36, 5) binary BCH code %%%%%%%%%%%%%
 *
 *	This code is used in control channels for cellular TDMA in the U.S.A.
 *
 *	In this specific case, there is no need to use the Berlekamp-Massey
 *	algorithm, since the error locator polynomial is of at most degree 2.
 *	Instead, we simply solve by hand two simultaneous equations to give
 * 	the coefficients of the error locator polynomial in the case of two 
 *	errors. In the case of one error, the location is given by the first
 *	syndrome.
 *
 *	This program derivates from the original bch2.c, which was written
 *	to simulate the encoding/decoding of primitive binary BCH codes.
 *	Part of this program is adapted from a Reed-Solomon encoder/decoder
 *	program,  'rs.c', to the binary case. 
 *
 *	rs.c by Simon Rockliff, University of Adelaide, 21/9/89 
 *	bch2.c by Robert Morelos-Zaragoza, University of Hawaii, 5/19/92 
 *
 * 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 1994 (c) Robert Morelos-Zaragoza. All rights reserved. %%%%%
 *
 * m = order of the field GF(2**6) = 6
 * n = 2**6 - 1 - 15 = 48 = length 
 * t = 2 = error correcting capability 
 * d = 2*t + 1 = 5 = designed minimum distance 
 * k = n - deg(g(x)) = 36 = dimension 
 * p[] = coefficients of primitive polynomial used to generate GF(2**6)
 * g[] = coefficients of generator polynomial, g(x)
 * alpha_to [] = log table of GF(2**6) 
 * index_of[] = antilog table of GF(2**6)
 * data[] = coefficients of data polynomial, i(x)
 * bb[] = coefficients of redundancy polynomial ( x**(12) i(x) ) modulo g(x)
 * numerr = number of errors 
 * errpos[] = error positions 
 * recd[] = coefficients of received polynomial 
 * decerror = number of decoding errors (in MESSAGE positions) 
 *
 */

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

int             m = 6, n = 63, k = 36, t = 2, d = 5;
int				length = 48;
int             p[7];		/* irreducible polynomial */
int             alpha_to[64], index_of[64], g[13];
int             recd[48], data[36], bb[13];
int             numerr, errpos[64], decerror = 0;
int             seed;


void 
read_p()
/* Primitive polynomial of degree 6 */
{
	register int    i;
    p[0] = p[1] = p[6] = 1; p[2] = p[3] = p[4] = p[5] =0;
}


void 
generate_gf()
/*
 * generate GF(2**m) from the irreducible polynomial p(X) 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 generator polynomial of BCH code of length = 48, redundancy = 12
 * (OK, this is not very efficient, but we only do it once, right? :)
 */
{
	register int    ii, jj, ll, kaux;
	int             test, aux, nocycles, root, noterms, rdncy;
	int             cycle[13][7], size[13], min[13], zeros[13];
	/* Generate cycle sets modulo 63 */
	cycle[0][0] = 0; size[0] = 1;
	cycle[1][0] = 1; size[1] = 1;
	jj = 1;			/* cycle set index */
	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 */
	/* Search for roots 1, 2, ..., d-1 in cycle sets */
	kaux = 0;
	rdncy = 0;
	for (ii = 1; ii <= nocycles; ii++) {
		min[kaux] = 0;
		for (jj = 0; jj < size[ii]; jj++)
			for (root = 1; root < d; root++)
				if (root == cycle[ii][jj])
					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++;
		}
	printf("This is a (%d, %d, %d) binary BCH code\n", length, k, d);
	/* Compute 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("g(x) = ");
	for (ii = 0; ii <= rdncy; ii++) {
	  printf("%d", g[ii]);
	  if (ii && ((ii % 70) == 0))
	    printf("\n");
	}
	printf("\n");
}


void 
encode_bch()
/* 
 * Calculate redundant bits bb[], codeword is c(X) = data(X)*X**(n-k)+ bb(X)
 */
{
	register int    i, j;
	register int    feedback;
	for (i = 0; i < length - k; i++)
		bb[i] = 0;
	for (i = k - 1; i >= 0; i--) {
		feedback = data[i] ^ bb[length - k - 1];
		if (feedback != 0) {
			for (j = length - k - 1; j > 0; j--)
				if (g[j] != 0)
					bb[j] = bb[j - 1] ^ feedback;
				else
					bb[j] = bb[j - 1];
			bb[0] = g[0] && feedback;
		} else {
			for (j = length - k - 1; j > 0; j--)
				bb[j] = bb[j - 1];
			bb[0] = 0;
		};
	};
};


void 
decode_bch()
/*
 * We do not need the Berlekamp algorithm to decode.
 * We solve before hand two equations in two variables.
 */
{
	register int    i, j, q;
	int             elp[3], s[5], s3;
	int             count = 0, syn_error = 0;
	int             loc[3], err[3], reg[3];
	int				aux;
	/* first form the syndromes */
	printf("s[] = (");
	for (i = 1; i <= 4; i++) {
		s[i] = 0;
		for (j = 0; j < length; j++)
			if (recd[j] != 0)
				s[i] ^= alpha_to[(i * j) % n];
		if (s[i] != 0)
			syn_error = 1;	/* set flag if non-zero syndrome */
							/* NOTE: If only error detection is needed,
							 * then exit the program here...
							 */
		/* convert syndrome from polynomial form to index form  */
		s[i] = index_of[s[i]];
		printf("%3d ", s[i]);
	};
	printf(")\n");
	if (syn_error) {	/* If there are errors, try to correct them */
		if (s[1] != -1) {
			s3 = (s[1] * 3) % n;
			if ( s[3] == s3 )  /* Was it a single error ? */
				{
				printf("One error at %d\n", s[1]);
				recd[s[1]] ^= 1;		/* Yes: Correct it */
				}
			else {				/* Assume two errors occurred and solve
								 * for the coefficients of sigma(x), the
								 * error locator polynomail
								 */
                if (s[3] != -1)
                  aux = alpha_to[s3] ^ alpha_to[s[3]];
                else
                  aux = alpha_to[s3];

				elp[0] = 0;
				elp[1] = (s[2] - index_of[aux] + n) % n;
				elp[2] = (s[1] - index_of[aux] + n) % n;
				printf("sigma(x) = ");
				for (i = 0; i <= 2; i++)
					printf("%3d ", elp[i]);
				printf("\n");
				printf("Roots: ");
				/* find roots of the error location polynomial */
				for (i = 1; i <= 2; i++)
					reg[i] = elp[i];
				count = 0;
				for (i = 1; i <= 63; i++) { /* Chien search */
					q = 1;
					for (j = 1; j <= 2; j++)
						if (reg[j] != -1) {
							reg[j] = (reg[j] + j) % n;
							q ^= alpha_to[reg[j]];
						}
					if (!q) {	/* store error location number indices */
						loc[count] = i % n;
						count++;
						printf("%3d ", (i%n));
					}
				}
				printf("\n");
				if (count == 2)	
				/* no. roots = degree of elp hence 2 errors */
					for (i = 0; i < 2; i++)
						recd[loc[i]] ^= 1;
				else	/* Cannot solve: Error detection */
					printf("incomplete decoding\n");
				}
			}
		else if (s[2] != -1) /* Error detection */
			printf("incomplete decoding\n");
	}
}


main()
{
	int             i;
	read_p();				/* read generator polynomial g(x) */
	generate_gf();			/* generate the Galois Field GF(2**m) */
	gen_poly();				/* Compute the generator polynomial of BCH code */

	seed = 1;
	srandom(seed);
	/* Randomly generate DATA */
	for (i = 0; i < k; i++)
		data[i] = (random() & 67108864) >> 26;

	/* ENCODE */
	encode_bch();			/* encode data */
 
	for (i = 0; i < length - k; i++)
		recd[i] = bb[i];	/* first (length-k) bits are redundancy */
	for (i = 0; i < k; i++)
		recd[i + length - k] = data[i];	/* last k bits are data */
	printf("c(x) = ");
	for (i = 0; i < length; i++) {
		printf("%1d", recd[i]);
		if (i && ((i % 70) == 0))
			printf("\n");
	}
	printf("\n");

	/* ERRORS */
    printf("Enter the number of errors and their positions: ");
    scanf("%d", &numerr);
	for (i = 0; i < numerr; i++)
		{
		scanf("%d", &errpos[i]);
		recd[errpos[i]] ^= 1;
		}
	printf("r(x) = ");
	for (i = 0; i < length; i++)
		printf("%1d", recd[i]);
	printf("\n");

    /* DECODE */
	decode_bch();
	/*
	 * print out original and decoded data
	 */
	printf("Results:\n");
	printf("original data  = ");
	for (i = 0; i < k; i++)
		printf("%1d", data[i]);
	printf("\nrecovered data = ");
	for (i = length - k; i < length; i++)
		printf("%1d", recd[i]);
	printf("\n");
	/* decoding errors: we compare only the data portion */
	for (i = length - k; i < length; i++)
		if (data[i - length + k] != recd[i])
			decerror++;
	if (decerror)
		printf("%d message decoding errors\n", decerror);
	else
		printf("Succesful decoding\n");
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧洲三级电影| 99精品视频一区二区三区| 国产亚洲一区二区三区四区 | 波多野结衣在线一区| 亚洲成av人片一区二区梦乃| 久久久久国产精品麻豆 | 久久精品夜色噜噜亚洲a∨| 欧美一区二区日韩一区二区| 国产乱妇无码大片在线观看| 天天影视涩香欲综合网| 国产精品美女视频| 精品少妇一区二区三区视频免付费| 97aⅴ精品视频一二三区| 国产麻豆精品一区二区| 丝袜诱惑制服诱惑色一区在线观看 | 久久久91精品国产一区二区三区| 欧美色综合久久| 不卡影院免费观看| 狠狠色丁香婷婷综合久久片| 视频在线观看国产精品| 亚洲精品乱码久久久久| 国产精品国产三级国产普通话三级| 欧美xxxx在线观看| 欧美精品777| 在线观看91视频| 99国产欧美另类久久久精品| 国产成人一区在线| 国内精品嫩模私拍在线| 久久国产精品99久久人人澡| 美腿丝袜一区二区三区| 香蕉久久夜色精品国产使用方法 | 欧美一级片在线看| 欧美日韩三级视频| 欧美亚洲一区二区在线| 欧美色区777第一页| 亚洲18色成人| 久久99国产精品成人| 国产精品超碰97尤物18| 欧美日韩精品一区二区在线播放| 国产专区欧美精品| 亚洲男人的天堂在线aⅴ视频| 欧美一区二区三区婷婷月色 | 欧美高清激情brazzers| 欧美疯狂做受xxxx富婆| 日韩精彩视频在线观看| 亚洲综合激情网| 亚洲制服丝袜av| 亚洲高清免费在线| 亚洲一区在线观看网站| 亚洲一区二区三区中文字幕| 亚洲成年人网站在线观看| 久久天堂av综合合色蜜桃网| 亚洲精品一线二线三线无人区| 日韩精品专区在线| 久久综合精品国产一区二区三区| 久久久久久亚洲综合影院红桃| 欧美经典三级视频一区二区三区| 国产精品丝袜久久久久久app| 亚洲日本va午夜在线电影| 亚洲欧美日韩在线| 调教+趴+乳夹+国产+精品| 日韩国产成人精品| 国产在线观看免费一区| 成人精品视频.| 一本色道久久综合亚洲91| 欧美在线三级电影| 日韩精品中文字幕一区| 26uuu国产一区二区三区| 国产精品欧美一区喷水| 亚洲一区二区三区三| 日韩不卡手机在线v区| 国产美女精品一区二区三区| 波多野结衣一区二区三区| 欧美伊人久久久久久久久影院| 91麻豆精品国产91久久久使用方法| 日韩精品一区二区三区在线观看| 日本91福利区| 亚洲伦理在线精品| 日韩高清不卡一区二区| 国产精品白丝jk白祙喷水网站| 东方欧美亚洲色图在线| 欧美日韩一区二区欧美激情| 2019国产精品| 一区二区视频在线| 久久狠狠亚洲综合| 99久久精品99国产精品| 日韩欧美亚洲一区二区| 中文字幕一区二区三区不卡在线 | 日韩激情在线观看| 国产精品一线二线三线精华| 欧美在线影院一区二区| 国产欧美精品在线观看| 亚洲123区在线观看| 成人99免费视频| 日韩你懂的电影在线观看| 有坂深雪av一区二区精品| 精品午夜久久福利影院| 在线免费一区三区| 亚洲国产成人自拍| 美女视频网站久久| 欧美一区二区在线免费播放| 国产成人综合精品三级| 欧美情侣在线播放| 国产精品美女一区二区在线观看| 美洲天堂一区二卡三卡四卡视频 | 国产三级精品三级| 亚洲一区二区欧美激情| 福利一区二区在线| 91精品麻豆日日躁夜夜躁| av电影天堂一区二区在线| 日韩一区二区三区免费看| 最近日韩中文字幕| 从欧美一区二区三区| 精品美女被调教视频大全网站| 一区二区欧美国产| 99精品久久99久久久久| 久久久久久黄色| 久久精品久久精品| 56国语精品自产拍在线观看| 亚洲综合在线免费观看| 成人一区二区三区在线观看 | av午夜一区麻豆| 久久综合九色综合欧美亚洲| 久久精品免费观看| 日韩一区二区免费在线观看| 午夜视频一区在线观看| 欧美在线观看一区二区| 一区二区三区在线观看视频| 成年人午夜久久久| 国产精品每日更新在线播放网址| 东方aⅴ免费观看久久av| 久久久不卡网国产精品一区| 韩国毛片一区二区三区| 日韩一级高清毛片| 日本色综合中文字幕| 欧美一区二区免费视频| 七七婷婷婷婷精品国产| 欧美一区二区三区色| 理论电影国产精品| 久久老女人爱爱| 国产美女av一区二区三区| 欧美tickling网站挠脚心| 狠狠色伊人亚洲综合成人| 久久久久久亚洲综合| 丰满放荡岳乱妇91ww| 中文字幕视频一区| 色婷婷久久久综合中文字幕| 尤物视频一区二区| 欧美亚洲国产怡红院影院| 亚洲午夜视频在线观看| 欧美日韩在线播放| 丝袜脚交一区二区| 91精品国产91综合久久蜜臀| 麻豆freexxxx性91精品| www国产成人免费观看视频 深夜成人网| 日本欧美在线观看| 欧美自拍丝袜亚洲| 三级一区在线视频先锋| 精品久久久影院| 国产成a人亚洲精品| 日韩理论片在线| 欧美日韩久久一区二区| 精品在线亚洲视频| 欧美国产日本韩| 一区二区高清在线| 中文字幕一区二区三中文字幕| 国产一区二区三区日韩| 床上的激情91.| 国产成人精品一区二区三区网站观看| 亚洲成人第一页| 一卡二卡三卡日韩欧美| 悠悠色在线精品| 亚洲福利视频一区二区| 一区二区三区色| 性做久久久久久| 日韩激情av在线| 国产剧情一区在线| 91丨九色丨黑人外教| 亚洲国产精品尤物yw在线观看| 狠狠色丁香久久婷婷综| 成年人国产精品| 日韩欧美在线一区二区三区| 国产suv精品一区二区三区| 中文字幕欧美三区| 日产欧产美韩系列久久99| 久久一区二区三区国产精品| 久久er精品视频| 精品一区二区三区av| 久久97超碰国产精品超碰| 成人夜色视频网站在线观看| 成年人国产精品| 欧美三级午夜理伦三级中视频| 色视频成人在线观看免| 91麻豆精品国产| 久久久九九九九| 亚洲综合清纯丝袜自拍| 国产在线精品视频| 欧美三级日韩三级| 一区二区三区蜜桃网| 天堂va蜜桃一区二区三区 |