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

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

?? myturbo.cpp

?? 拓補碼編碼解碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
// MyTurbo.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "random.h"

const int SEED=1000;
unsigned int N=1024;
unsigned int ITERATIONS=20;
double No;

// zero mean RV with variance as given
double gaussian(double variance);
// encodes mesg into parity1, and if force it true it modifies mesg to
// force the encoder to the zero state by the last bit.
void encode(bool *mesg,bool *parity1,unsigned size, bool force);
void interleave(bool *mesg, unsigned size);
// binary addition with no carry
bool add(bool a,bool b);
void interleave(bool *mesg, unsigned size);
void deinterleave(bool *mesg, unsigned size);
void deinterleavedouble(double *mesg, unsigned size);
void interleavedouble(double *mesg, unsigned size);
void createinterleave(unsigned size);
void createencodetable();
void inttobool(unsigned state, bool *array, unsigned size);
void booltoint(bool *array, unsigned size, unsigned *state);
unsigned decode (double *channelmesg, double *parity1, double *parity2, unsigned size, bool *mesg);

unsigned *interleavearray;
unsigned *deinterleavearray;

// global information about the encoder used by the encoder and the decoder
// routine
// how many states are in the encoder (a power of 2)
unsigned numstates;
// log2(numstates)
unsigned memory;
// [2] = input, [16] = current state, tostate[2][16] = next state
unsigned *tostate[2];
// [2] = last input, [16] = current state, fromstate[2][16] = previous state
unsigned *fromstate[2];
// [2] = input, [16] = current state, output[2][16] = output of encoder
bool *output[2];
Random before;

int _tmain(int argc, _TCHAR* argv[])
{
   bool *mesg;
   bool *parity1;
   bool *parity2;
   double *channelmesg;
   double *channelparity1;
   double *channelparity2;

   interleavearray = new unsigned[N];
   deinterleavearray = new unsigned[N];
   mesg = new bool[N];
   parity1 = new bool[N];
   parity2 = new bool[N];
   channelmesg = new double[N];
   channelparity1 = new double[N];
   channelparity2 = new double[N];

   // only needs to be done once
   createencodetable();

   bool firstloop=true;

   // change if you want to loop for other values of dB
   for (double dB=-8.0;dB<=-2.0;dB+=0.2)
   {
	   unsigned totalN=0;
	   unsigned totalerrors=0;
	   unsigned numiter;
      unsigned totaliter=0;
      unsigned numloops=0;

		// load the previous state
      if (firstloop)
      {
      	FILE *fp;
         char line[30];

         firstloop = false;

			if ((fp = fopen("laststate","r")) != NULL)
			{
	         fgets(line,30,fp);
	         dB = atof(line);
	         fgets(line,30,fp);
	         totalerrors = atoi(line);
	         fgets(line,30,fp);
	         totalN = atoi(line);
	         fgets(line,30,fp);
	         totaliter = atoi(line);
	         fgets(line,30,fp);
	         numloops = atoi(line);
            fclose(fp);
         }
		}

		// dB = 10*log(Eb/No) where Eb is 1
      No = 1/pow(10.0,dB/10.0);

      bool keepgoing=true;

	   do
	   {
			for (int x=0;x<N;x++)
		   	mesg[x] = before.boolrandom();  ///// can be changed

         // create a random interleaver for each decode trial
		   createinterleave(N);

		   encode(mesg,parity1,N,true);
		   interleave(mesg,N);
		   encode(mesg,parity2,N,false);
		   // deinterleave for the decoder
		   deinterleave(mesg,N);

			for (int x=0;x<N;x++)
		   {
		   	mesg[x] ? channelmesg[x] = 1.0 : channelmesg[x]=-1.0;
		      parity1[x] ? channelparity1[x]=1.0 : channelparity1[x]=-1.0;
		      parity2[x] ? channelparity2[x]=1.0 : channelparity2[x]=-1.0;
		   }

		   // add gaussian noise, mean=0, variance=No/2
			for (int x=0;x<N;x++)
		   {
		    	channelmesg[x] += gaussian(No/2);
				channelparity1[x] += gaussian(No/2);
		      channelparity2[x] += gaussian(No/2);
		   }

		   numiter = decode(channelmesg, channelparity1, channelparity2,N,mesg);

		   unsigned numerrors=0;

		   for (int x=0;x<N;x++)
		   {
		   	bool temp = channelmesg[x] == 1 ? true : false;

		      if (mesg[x] != temp)
		   		numerrors++;
		   }

	      totalerrors += numerrors;
	      totalN += N;
         totaliter += numiter;
         numloops++;

	      char name[30];

			// open a file for output
	      sprintf (name,"%dN%lfdB",N,dB);

	      FILE *fp;

	      // if file exists, we will append to it
	      fp = fopen(name,"a");

			printf ("N=%d, e=%d, totITER=%d, numITER=%d, No=%lf, tote=%d, totn=%d, dB=%lf\n",N,numerrors,ITERATIONS,numiter,No,totalerrors,totalN,dB);
         fprintf (fp,"N=%d, e=%d, totITER=%d, numITER=%d, No=%lf, tote=%d, totn=%d, dB=%lf\n",N,numerrors,ITERATIONS,numiter,No,totalerrors,totalN,dB);

	      fclose(fp);

         // save this state in case we need to start over again
         fp = fopen ("laststate","w");

			fprintf(fp,"%lf\n",dB);
         fprintf(fp,"%u\n",totalerrors);
         fprintf(fp,"%u\n",totalN);
			fprintf(fp,"%u\n",totaliter);
			fprintf(fp,"%u\n",numloops);

         fclose(fp);

			// a number of conditions for stopping the simulation for this dB value
			if (totalerrors> 1000)
         	keepgoing = false;
         else if (totalN>500000 && totalerrors > 100)
         	keepgoing = false;
         else if (totalN>1E6 && totalerrors > 10)
         	keepgoing = false;
         else if (totalN>5E6 && totalerrors > 5)
				keepgoing = false;
			else if (totalN>7.5E6 && totalerrors > 3)
				keepgoing = false;
			else if (totalN>1E7)
         	keepgoing=false;
		}
		while (keepgoing == true); // 10 million is as high as I'm willing to go
      // 1000 errors should be enough for good stats.

      // add a summary of the last run to the summary file
		FILE *fp;

      fp = fopen("summary","a");

	   printf ("dB = %lf, N=%ld, error=%ld, avgiter = %lf, interleaver size=%d, original encoder\n",dB, totalN,totalerrors,(double)totaliter/(double)numloops,N);
      fprintf(fp,"dB = %lf, N=%ld, error=%ld, avgiter = %lf, interleaver size=%d, original encoder\n",dB, totalN,totalerrors,(double)totaliter/(double)numloops,N);

	   fclose(fp);
	}

   delete interleavearray;
   delete deinterleavearray;
   delete mesg;
   delete parity1;
   delete parity2;
   delete channelmesg;
   delete channelparity1;
   delete channelparity2;

   // use repeat n code, n=3 in this case.  For large probability of error this code
   // will beat turbo code, turbo is way better for lesser probability of error
/*
	for (int x=0;x<N;x++)
   	mesg[x] = parity1[x] = parity2[x] = before.boolrandom();

	for (int x=0;x<N;x++)
   {
   	mesg[x] ? channelmesg[x] = 1.0 : channelmesg[x]=-1.0;
      parity1[x] ? channelparity1[x]=1.0 : channelparity1[x]=-1.0;
      parity2[x] ? channelparity2[x]=1.0 : channelparity2[x]=-1.0;
   }

	numerrors=0;
	// add white guassian noise
  	for (int x=0;x<N;x++)
   {
   	bool temp;

   	channelmesg[x] += gaussian(No/2);

      if (channelmesg[x] > 0)
      	temp = true;
      else
      	temp = false;

      if (mesg[x] != temp)
         numerrors++;

		channelparity1[x] += gaussian(No/2);
      channelparity2[x] += gaussian(No/2);
   }

   printf ("%ld\n",numerrors);

   numerrors=0;
   // make decisions based on majority rules
   for (int x=0;x<N;x++)
   {
   	int count=0;

		if (channelmesg[x] > 0)
      	count ++;
      else
      	count--;

      if (channelparity1[x] > 0)
      	count++;
      else
      	count--;

      if (channelparity2[x] > 0)
      	count++;
      else
      	count--;

      bool temp;

      if (count > 0)
			temp = true;
      else
      	temp = false;

      if(mesg[x] != temp)
      	numerrors ++;
   }

   printf ("%ld\n",numerrors);
*/

	return 0;

}

void createencodetable()
{
	bool *boolstate;
   bool *newstate;

	numstates = 16;
   memory = 4;

   // create arrays used by encode and decode
   output[0] = new bool[numstates];
   output[1] = new bool[numstates];
   fromstate[0] = new unsigned[numstates];
   fromstate[1] = new unsigned[numstates];
   tostate[0] = new unsigned[numstates];
   tostate[1] = new unsigned[numstates];

   boolstate = new bool[memory];
   newstate = new bool[memory];

	for (unsigned input=0;input<2;input++)
		for (unsigned intstate=0;intstate<numstates;intstate++)
      {
      	bool boolinput = (input == 0) ? false : true;

			inttobool(intstate,boolstate,memory);

			// calculate output due to the input
			output[input][intstate] = add(boolinput,boolstate[0]);
			output[input][intstate] = add(output[input][intstate],boolstate[3]);
			output[input][intstate] = add(output[input][intstate],boolstate[1]);
			output[input][intstate] = add(output[input][intstate],boolstate[2]);
			output[input][intstate] = add(output[input][intstate],boolstate[3]);

			// calculate new states
			newstate[3] = boolstate[2];
	     	newstate[2] = boolstate[1];
			newstate[1] = boolstate[0];
         newstate[0] = add(add(boolinput,boolstate[0]),boolstate[3]);
         // from s' to s
      	booltoint (newstate,memory,&tostate[input][intstate]);
         // from s to s'
         fromstate[input][tostate[input][intstate]] = intstate;
      }

   delete boolstate;
   delete newstate;
}


/*
void createencodetable()
{
	numstates = 128;
   memory = 7;

   // create arrays used by encode and decode
   output[0] = new bool[numstates];
   output[1] = new bool[numstates];
   fromstate[0] = new unsigned[numstates];
   fromstate[1] = new unsigned[numstates];
   tostate[0] = new unsigned[numstates];
   tostate[1] = new unsigned[numstates];

   yesno[0] = new bool[numstates];
   yesno[1] = new bool[numstates];

   bool *yesno[2];
   Random r;

	for (unsigned input=0;input<2;input++)
		for (unsigned intstate=0;intstate<numstates;intstate++)
			yesno[input][intstate] = false;

	for (unsigned input=0;input<2;input++)
		for (unsigned intstate=0;intstate<numstates;intstate++)
      {
      	bool output
         unsigned nextstate;

      	do
         {
         	output = r.boolrandom();
            nextstate=r.longrandom();
         }
         while(yesno[input][nextstate] == true);

         yesno[input][nextstate]=false;

	while (done < 2*numstates)
   {
   	bool input = a.boolrandom();
      unsigned state = a.unsignedrandom(numstates);

      if(yesno[input][state] == false)
      {
      	yesno[input][state] = true;
         done++;
         tostate[input]




	for (unsigned input=0;input<2;input++)
		for (unsigned intstate=0;intstate<numstates;intstate++)
      {
      	bool boolinput = (input == 0) ? false : true;

			inttobool(intstate,boolstate,memory);

			// calculate output due to the input
			output[input][intstate] = add(boolinput,boolstate[0]);
			output[input][intstate] = add(output[input][intstate],boolstate[3]);
			output[input][intstate] = add(output[input][intstate],boolstate[1]);
			output[input][intstate] = add(output[input][intstate],boolstate[2]);
			output[input][intstate] = add(output[input][intstate],boolstate[3]);

			// calculate new states
			newstate[3] = boolstate[2];
	     	newstate[2] = boolstate[1];
			newstate[1] = boolstate[0];
         newstate[0] = add(add(boolinput,boolstate[0]),boolstate[3]);
         // from s' to s
      	booltoint (newstate,memory,&tostate[input][intstate]);
         // from s to s'
         fromstate[input][tostate[input][intstate]] = intstate;
      }

   delete boolstate;
   delete newstate;
}
*/

void inttobool(unsigned state, bool *array, unsigned size)
{
	for (unsigned x=0;x<size;x++)
   {
   	unsigned next = state >> 1;

		if ((next << 1) == state)
      	array[x] = false;
      else
      	array[x] = true;

      state = next;
   }
}

void booltoint(bool *array, unsigned size, unsigned *state)
{
	*state = 0;

   for (int x=0;x<size;x++)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99视频一区二区| 亚洲国产视频在线| 亚洲制服丝袜av| 色综合色综合色综合色综合色综合 | 午夜激情综合网| 中文一区在线播放| 欧美精品一区二区三区一线天视频| 91免费版在线| av网站一区二区三区| 国产揄拍国内精品对白| 91精品欧美综合在线观看最新| 亚洲免费av网站| 日本久久一区二区三区| 午夜久久久影院| 欧美精品欧美精品系列| 欧美刺激午夜性久久久久久久| 日韩电影在线免费看| 制服.丝袜.亚洲.中文.综合| 国产91丝袜在线观看| 欧美疯狂性受xxxxx喷水图片| 色综合咪咪久久| 欧美三级日韩在线| 日韩视频免费观看高清完整版 | 国产精品每日更新| eeuss鲁一区二区三区| 亚洲免费观看高清在线观看| 一级精品视频在线观看宜春院| 色综合久久天天综合网| 人人狠狠综合久久亚洲| 中文字幕中文乱码欧美一区二区 | 成人av中文字幕| 日韩福利电影在线观看| 欧美一区二区三区影视| 欧美一卡二卡三卡四卡| 欧美精品一区在线观看| 中文字幕第一区二区| 在线观看91视频| 欧美成人乱码一区二区三区| 国产精品家庭影院| 免费观看在线综合| 亚洲欧美日本韩国| 欧美欧美午夜aⅴ在线观看| 一本久道中文字幕精品亚洲嫩| 蜜臀a∨国产成人精品| 夜夜精品浪潮av一区二区三区| 精品国产成人在线影院| 欧美日韩国产综合一区二区 | 日本vs亚洲vs韩国一区三区 | 亚洲综合视频网| 午夜伊人狠狠久久| 一本大道av一区二区在线播放| 91精品综合久久久久久| 亚洲欧美日韩成人高清在线一区| 精品综合免费视频观看| 欧美人与z0zoxxxx视频| 亚洲精品乱码久久久久久日本蜜臀| av电影在线不卡| 久久美女高清视频 | 日韩美女视频一区| 欧美激情一区二区三区在线| 精品av久久707| 欧美变态口味重另类| 欧美精品一区二区在线播放| 懂色一区二区三区免费观看| 色婷婷精品久久二区二区蜜臂av| 国产精品少妇自拍| 中文字幕av一区二区三区高| 欧美精品v国产精品v日韩精品| 欧美精品一区二区三| 视频在线观看一区| 欧美日韩国产另类不卡| 亚洲综合免费观看高清完整版 | 精品婷婷伊人一区三区三| 中文成人av在线| 国产精品久久久久久久蜜臀 | 国产成人综合网站| www.欧美.com| 欧美精品电影在线播放| 久久综合九色综合欧美就去吻 | 91丨porny丨中文| 日日夜夜精品视频免费| 精品一区二区三区久久| 一区二区三区视频在线看| 91玉足脚交白嫩脚丫在线播放| 国产精品国产三级国产普通话三级| 91亚洲男人天堂| 天天亚洲美女在线视频| 久久先锋影音av鲁色资源| 成人av在线一区二区三区| 性做久久久久久久久| 精品国产免费人成电影在线观看四季| 精品国产乱码久久久久久图片| 欧美激情一区二区三区不卡| 日韩国产精品大片| 色综合色狠狠天天综合色| 国产精品久久看| 国产精品自拍网站| 日韩欧美中文字幕公布| 性做久久久久久免费观看| 成人午夜视频在线| 亚洲国产精品二十页| 国产精品亚洲视频| 97久久精品人人做人人爽50路| 国产精品88888| 国产精品看片你懂得| 制服丝袜激情欧洲亚洲| 色偷偷88欧美精品久久久| 国产盗摄一区二区三区| 青青草97国产精品免费观看 | 蜜桃在线一区二区三区| 在线免费亚洲电影| 亚洲精品精品亚洲| 91网站视频在线观看| 日韩一区有码在线| 欧美日韩国产大片| 久久aⅴ国产欧美74aaa| 91麻豆精品国产综合久久久久久| 亚洲成在线观看| 欧美日韩国产影片| 美女在线观看视频一区二区| 丰满岳乱妇一区二区三区| 亚洲综合丁香婷婷六月香| 国产精品久久久久久久久免费相片 | 丁香亚洲综合激情啪啪综合| 国产乱码精品一区二区三| 福利91精品一区二区三区| eeuss影院一区二区三区| 99久久夜色精品国产网站| 在线观看亚洲精品| 麻豆国产精品777777在线| 中文成人综合网| 免费成人美女在线观看| 国产精品狼人久久影院观看方式| 欧美丰满美乳xxx高潮www| 丁香婷婷综合激情五月色| 亚洲午夜激情网页| 2020日本不卡一区二区视频| 91搞黄在线观看| 国产成人亚洲综合a∨婷婷图片| 欧美三级日韩三级| 99精品视频一区二区三区| 中文字幕在线观看不卡| 在线观看av不卡| 久久久五月婷婷| 亚洲免费观看在线视频| 久久精品久久精品| 色婷婷久久久亚洲一区二区三区 | 黄色精品一二区| 欧日韩精品视频| 久久人人爽爽爽人久久久| 另类欧美日韩国产在线| 欧美视频你懂的| 一本色道久久综合精品竹菊| 国产一区三区三区| 欧美va亚洲va在线观看蝴蝶网| 欧美在线观看一区二区| 在线视频国产一区| 日本道免费精品一区二区三区| 色综合久久久久久久| 91免费国产在线| 一本一道综合狠狠老| 色94色欧美sute亚洲线路一ni| 一区二区三区成人在线视频| 中文字幕日韩精品一区| 亚洲色图另类专区| 久久青草欧美一区二区三区| 午夜免费欧美电影| 亚洲人成网站色在线观看| 国产高清久久久| 久久九九久久九九| 国产精品888| 日本一区二区电影| 国产福利精品一区二区| 欧美精品一区二区三区很污很色的| 日韩av不卡一区二区| 欧美日韩一区不卡| 欧美一级午夜免费电影| 26uuu亚洲综合色欧美| 亚洲精品菠萝久久久久久久| 日韩高清一区在线| 成人久久视频在线观看| 欧美丰满美乳xxx高潮www| 亚洲国产精品ⅴa在线观看| 一区二区三区不卡在线观看| 国内精品久久久久影院薰衣草 | 欧美区在线观看| 久久精品日产第一区二区三区高清版| 欧美高清在线视频| 亚洲成人av电影在线| 一区二区三区免费在线观看| 91蝌蚪porny九色| 亚洲午夜日本在线观看| 免费观看一级欧美片| 中文在线一区二区| 欧美日韩日日摸| 国产一区二区三区免费观看| 中文字幕一区二区三区色视频| 欧美高清视频不卡网| 日本一区免费视频| 欧美日韩国产一二三|