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

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

?? dif_fft.c

?? 這是數字信號處理方面的一些源碼
?? C
字號:
/**********************************************************************
DIF_FFT.C - DIF FFT 測試程序

fft        基2 DIF FFT 子程序
ifft       基2 DIF IFFT 子程序
draw_image 繪圖子程序
***********************************************************************/

#include    <math.h>
#include    <stdlib.h>
#include    <stdio.h>
#include    <string.h>
#include    <conio.h>
#include    <graphics.h>

/* COMPLEX STRUCTURE */
typedef struct {
    float real, imag;
} COMPLEX;

#define    PI	(4.0*atan(1.0))

 void fft(COMPLEX *,int);
 void ifft(COMPLEX *,int);
 void draw_image(double *x,int m,char *title1,char *title2,
		char *xdis1,char *xdis2,int dis_type);

/********************************************************/
void main(void)
{
  int          i,length,m,j;
  char         title[80],tmp[20];
  double       *amp;
  double       a,tempflt;
  COMPLEX      *samp;

  m=8;
  length = 1<<m;
  amp = (double *) calloc(length+1,sizeof(double));
  samp = (COMPLEX *) calloc(length+1,sizeof(COMPLEX));
	if(!samp) {
	    printf("\nUnable to allocate complex array for fft\n");
	    exit(1);
	}

  /* Input sampling data for processing */

  printf("Waitting for sampling data...");
  for (i = 0; i < length; i++) {
      amp[i] = cos(2.0*PI*(double)i*2.0/length);
      printf("*");
  }
  for (i = 0; i < length; i++) {
     samp[i].real = amp[i]*cos(16.0*PI*(double)i*2.0/length)*amp[i];
     amp[i]= samp[i].real;
     printf("*");
  }

  strcpy(title,"The Sampling Signal Data");
  draw_image(amp,length,title,"The Magnitude","0",itoa(length,tmp,10),0);

/* Find the spectrum of the data */
  printf("Waitting for the FFT calculation...\n");
  fft(samp,m);

/* calculate magnitude */
  tempflt=0;
  for (i = 0 ; i < length ; i++) {
    tempflt  = samp[i].real * samp[i].real + samp[i].imag * samp[i].imag;
    amp[i]   = tempflt;
  }

  strcpy(title,"The Signal Freq Magnitude Result");
  draw_image(amp,length,title,"The Magnitude","0",itoa(length,tmp,10),0);

  printf("Waitting for the IFFT calculation...\n");
  ifft(samp,m);
  strcpy(title,"The IFFT Result");
  for (i=0;i<length;i++) amp[i]=samp[i].real;
  draw_image(amp,length,title,"The Magnitude","0",itoa(length,tmp,10),0);

  free(samp);
  free(amp);
}

/************************************************************************
fft - 基2 DIF FFT 子程序

輸入參數:
	 COMPLEX *x : FFT 輸入和輸出數據區指針;
	      int m : FFT 長度 ( length = 2^m );
輸出參數:
	 輸出數據放在 x 所指的輸入數據區.
	 無輸出參數.

void fft(COMPLEX *x, int m)
*************************************************************************/

void fft(COMPLEX *x,int m)
{
    static COMPLEX *w;           /* used to store the w complex array */
    static int mstore = 0;       /* stores m for future reference */
    static int n = 1;            /* length of fft stored for future */

    COMPLEX u,temp,tm;
    COMPLEX *xi,*xip,*xj,*wptr;

    int i,j,k,l,le,windex;

    double arg,w_real,w_imag,wrecur_real,wrecur_imag,wtemp_real;

    if(m != mstore) {

/* free previously allocated storage and set new m */

	if(mstore != 0) free(w);
	mstore = m;
	if(m == 0) return;       /* if m=0 then done */

/* n = 2**m = fft length */

	n = 1 << m;
	le = n/2;

/* allocate the storage for w */

	w = (COMPLEX *) calloc(le-1,sizeof(COMPLEX));
	if(!w) {
	    printf("\nUnable to allocate complex W array\n");
	    exit(1);
	}

/* calculate the w values recursively */

	arg = 4.0*atan(1.0)/le;         /* PI/le calculation */
	wrecur_real = w_real = cos(arg);
	wrecur_imag = w_imag = -sin(arg);
	xj = w;
	for (j = 1 ; j < le ; j++) {
	    xj->real = (float)wrecur_real;
	    xj->imag = (float)wrecur_imag;
	    xj++;
	    wtemp_real = wrecur_real*w_real - wrecur_imag*w_imag;
	    wrecur_imag = wrecur_real*w_imag + wrecur_imag*w_real;
	    wrecur_real = wtemp_real;
	}
    }

/* start fft */

    le = n;
    windex = 1;
    for (l = 0 ; l < m ; l++) {
	le = le/2;

/* first iteration with no multiplies */

	for(i = 0 ; i < n ; i = i + 2*le) {
	    xi = x + i;
	    xip = xi + le;
	    temp.real = xi->real + xip->real;
	    temp.imag = xi->imag + xip->imag;
	    xip->real = xi->real - xip->real;
	    xip->imag = xi->imag - xip->imag;
	    *xi = temp;
	}

/* remaining iterations use stored w */

	wptr = w + windex - 1;
	for (j = 1 ; j < le ; j++) {
	    u = *wptr;
	    for (i = j ; i < n ; i = i + 2*le) {
		xi = x + i;
		xip = xi + le;
		temp.real = xi->real + xip->real;
		temp.imag = xi->imag + xip->imag;
		tm.real = xi->real - xip->real;
		tm.imag = xi->imag - xip->imag;
		xip->real = tm.real*u.real - tm.imag*u.imag;
		xip->imag = tm.real*u.imag + tm.imag*u.real;
		*xi = temp;
	    }
	    wptr = wptr + windex;
	}
	windex = 2*windex;
    }

/* rearrange data by bit reversing */

    j = 0;
    for (i = 1 ; i < (n-1) ; i++) {
	k = n/2;
	while(k <= j) {
	    j = j - k;
	    k = k/2;
	}
	j = j + k;
	if (i < j) {
	    xi = x + i;
	    xj = x + j;
	    temp = *xj;
	    *xj = *xi;
	    *xi = temp;
	}
    }
}

/************************************************************************
ifft - 基2 DIF IFFT 子程序

輸入參數:
	 COMPLEX *x : IFFT 輸入和輸出數據區指針;
	      int m : IFFT 長度 ( length = 2^m );
輸出參數:
	 輸出數據放在 x 所指的輸入數據區.
	 無輸出參數.

void ifft(COMPLEX *x, int m)
*************************************************************************/

void ifft(x,m)
    COMPLEX *x;
    int m;
{
    static COMPLEX *w;           /* used to store the w complex array */
    static int mstore = 0;       /* stores m for future reference */
    static int n = 1;            /* length of ifft stored for future */

    COMPLEX u,temp,tm;
    COMPLEX *xi,*xip,*xj,*wptr;

    int i,j,k,l,le,windex;

    double arg,w_real,w_imag,wrecur_real,wrecur_imag,wtemp_real;
    float scale;

    if(m != mstore) {

/* free previously allocated storage and set new m */

	if(mstore != 0) free(w);
	mstore = m;
	if(m == 0) return;       /* if m=0 then done */

/* n = 2**m = inverse fft length */

	n = 1 << m;
	le = n/2;

/* allocate the storage for w */

	w = (COMPLEX *) calloc(le-1,sizeof(COMPLEX));
	if(!w) {
	    printf("\nUnable to allocate complex W array\n");
	    exit(1);
	}

/* calculate the w values recursively */

	arg = 4.0*atan(1.0)/le;         /* PI/le calculation */
	wrecur_real = w_real = cos(arg);
	wrecur_imag = w_imag = sin(arg);  /* opposite sign from fft */
	xj = w;
	for (j = 1 ; j < le ; j++) {
	    xj->real = (float)wrecur_real;
	    xj->imag = (float)wrecur_imag;
	    xj++;
	    wtemp_real = wrecur_real*w_real - wrecur_imag*w_imag;
	    wrecur_imag = wrecur_real*w_imag + wrecur_imag*w_real;
	    wrecur_real = wtemp_real;
	}
    }

/* start inverse fft */

    le = n;
    windex = 1;
    for (l = 0 ; l < m ; l++) {
	le = le/2;

/* first iteration with no multiplies */

	for(i = 0 ; i < n ; i = i + 2*le) {
	    xi = x + i;
	    xip = xi + le;
	    temp.real = xi->real + xip->real;
	    temp.imag = xi->imag + xip->imag;
	    xip->real = xi->real - xip->real;
	    xip->imag = xi->imag - xip->imag;
	    *xi = temp;
	}

/* remaining iterations use stored w */

	wptr = w + windex - 1;
	for (j = 1 ; j < le ; j++) {
	    u = *wptr;
	    for (i = j ; i < n ; i = i + 2*le) {
		xi = x + i;
		xip = xi + le;
		temp.real = xi->real + xip->real;
		temp.imag = xi->imag + xip->imag;
		tm.real = xi->real - xip->real;
		tm.imag = xi->imag - xip->imag;
		xip->real = tm.real*u.real - tm.imag*u.imag;
		xip->imag = tm.real*u.imag + tm.imag*u.real;
		*xi = temp;
	    }
	    wptr = wptr + windex;
	}
	windex = 2*windex;
    }

/* rearrange data by bit reversing */

    j = 0;
    for (i = 1 ; i < (n-1) ; i++) {
	k = n/2;
	while(k <= j) {
	    j = j - k;
	    k = k/2;
	}
	j = j + k;
	if (i < j) {
	    xi = x + i;
	    xj = x + j;
	    temp = *xj;
	    *xj = *xi;
	    *xi = temp;
	}
    }

/* scale all results by 1/n */
    scale = (float)(1.0/n);
    for(i = 0 ; i < n ; i++) {
	x->real = scale*x->real;
	x->imag = scale*x->imag;
	x++;
    }
}

/************************************************************************
draw_image - 將輸入數據的幅度畫出圖形。該函數可自動調整顯示的比例, 使圖形
	     充滿整個屏幕。

輸入參數: double *x    -   輸入數據序列的指針;
	  int m        -   輸入數據序列的長度;
	  char *title1 -   顯示圖形的上標題字符串指針;
	  char *xdis1  -   X 坐標左邊顯示標題字符串指針.
	  char *title2 -   顯示圖形的左標題字符串指針.
	  char *xdis2  -   X 坐標右邊顯示標題字符串指針.
	  int dis_type -   顯示類型, 0:連線 1:直線.
輸出參數: 無
*************************************************************************/
void draw_image(double *x,int m,char *title1,char *title2,
		char *xdis1,char *xdis2,int dis_type)
{
 int gdriver=DETECT, gmode,errorcode;
 int i,scx,scy,y0,signa,signb;
 int style, userpat;
 int start_x=40,start_y=40,end_x=10,end_y=60;
 long tlen;
 double ys,xs,ym;
 char dis[40];
 /*initializes the graphics mode */
 initgraph(&gdriver,&gmode,"");
 errorcode=graphresult();
 if (errorcode != grOk) {
    printf("Graphics error: %s\n",grapherrormsg(errorcode));
    printf("Press any key to halt!\n");
    getch();
    exit(1);
 }
 scx=getmaxx();
 scy=getmaxy();
 ym=1.e-90;
 signa=0;
 signb=0;

 for(i=0;i<m;i++) {
    if ((*(x+i)>0)&&(*(x+i)>ym))  ym = *(x+i);
    if ((*(x+i)<0)&&(- *(x+i)>ym))  ym = - *(x+i);
 }
 for(i=0;i<m;i++)  {
    if (*(x+i)>fabs(ym/20)) signa=1;
    if (*(x+i)<-fabs(ym/20)) signb=1;
 }
 if ((signa==1)&&(signb==1)) ys=(double)((scy - start_y - end_y)>>1)/ym;
 else ys=(double)((scy - start_y - end_y)/ym);
 xs=(double)(scx - start_x - end_x)/m;
 y0=((scy - start_y - end_y)>>1)+start_y;

 /* draw the frame */

 setcolor(LIGHTGREEN);
 rectangle(start_x-1,start_y-20,scx-end_x+1,scy-end_y+20);

 setcolor(DARKGRAY);
 /* select the line style */
 style=DASHED_LINE;
 userpat = 1;
 setlinestyle(style, userpat, 1);
 /* a user defined line pattern */
 /* binary: "0000000000000001"  */
 for(i=0;i<=10;i++)
    line(start_x,start_y+(scy-start_y-end_y)*i/10,scx-end_x,start_y+(scy-start_y-end_y)*i/10);
 for(i=0;i<=10;i++)
    line(start_x+(scx-start_x-end_x)*i/10,start_y,start_x+(scx-start_x-end_x)*i/10,scy-end_y);
 setcolor(GREEN);
 style=SOLID_LINE;
 userpat = 1;
 setlinestyle(style, userpat, 1);
 rectangle(start_x,start_y,scx-end_x,scy-end_y);
 setcolor(YELLOW);
 for(i=0;i<=10;i++)
    line(start_x,start_y+(scy-start_y-end_y)*i/10,start_x+5,start_y+(scy-start_y-end_y)*i/10);
 for(i=0;i<=10;i++)
    line(start_x+(scx-start_x-end_x)*i/10,scy-end_y+15,start_x+(scx-start_x-end_x)*i/10,scy-end_y+20);
 settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
 setcolor(YELLOW);
 if((signa==1)&&(signb==0)) {
    strcpy(dis,"0");
    outtextxy(start_x+2,scy-end_y+4,dis);
    gcvt(ym,5,dis);
    outtextxy(start_x+1,start_y-10,dis);
    outtextxy(start_x-10,scy-end_y+24,xdis1);
    outtextxy(scx-2-strlen(xdis2)*8,scy-end_y+24,xdis2);
 }
 else if((signb==1)&&(signa==0)) {
    strcpy(dis,"0");
    outtextxy(start_x+2,start_y-10,dis);
    gcvt(ym,5,dis);
    outtextxy(start_x+2,scy-end_y+4,"-");
    outtextxy(start_x+10,scy-end_y+4,dis);
    outtextxy(start_x-10,scy-end_y+24,xdis1);
    outtextxy(scx-2-strlen(xdis2)*8,scy-end_y+24,xdis2);
 }
 else {
    line(start_x,y0,scx-end_x,y0);
    strcpy(dis,"0");
    outtextxy(start_x-10,y0,dis);
    gcvt(ym,5,dis);
    outtextxy(start_x+2,start_y-10,dis);
    outtextxy(start_x+2,scy-end_y+4,"-");
    outtextxy(start_x+10,scy-end_y+4,dis);
    outtextxy(start_x-10,scy-end_y+24,xdis1);
    outtextxy(scx-2-strlen(xdis2)*8,scy-end_y+24,xdis2);
 }
 strcpy(dis,"Press any key to continue...");
 setcolor(LIGHTRED);
 outtextxy((scx-28*8)>>1,scy-16,dis);

 settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
 tlen=strlen(title1);
 if ((tlen<<4)<scx) {
    setcolor(LIGHTGREEN);
    outtextxy((start_x+scx-end_x-(tlen<<4))>>1,start_y-40,title1);
 }

 settextstyle(DEFAULT_FONT,VERT_DIR,1);
 tlen=strlen(title2);
 if ((tlen<<4)<scy) {
    setcolor(LIGHTGREEN);
    outtextxy(start_x-20,(scy-end_y-(tlen<<3))>>1,title2);
 }
 /*draw the amplitude image*/
 setcolor(WHITE);
 if((signa==1)&&(signb==0)) y0=scy-end_y;
 else if((signb==1)&&(signa==0)) y0=start_y;
 if (dis_type == 0) {
    for(i=0;i<m-1;i++)
      line(xs*i+start_x,y0-*(x+i)*ys,xs*(i+1)+start_x,y0-*(x+i+1)*ys);
 }
 else if (dis_type == 1) {
    for(i=0;i<=m;i++)
      line(xs*i+start_x,y0-*(x+i)*ys,xs*i+start_x,y0);
 }
 getch();
 closegraph();
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕字幕中文在线中不卡视频| 成人av免费在线观看| 国产最新精品精品你懂的| 国产白丝精品91爽爽久久| 在线观看视频一区二区| 精品国产91久久久久久久妲己| 国产精品剧情在线亚洲| 亚洲福中文字幕伊人影院| 狠狠色丁香婷婷综合久久片| 99精品视频在线观看| 欧美蜜桃一区二区三区| 欧美极品少妇xxxxⅹ高跟鞋| 亚洲国产综合视频在线观看| 国产乱淫av一区二区三区| 一本大道久久a久久综合| 日韩精品在线一区二区| 亚洲乱码国产乱码精品精98午夜 | 欧美日韩国产小视频在线观看| 精品日韩一区二区| 亚洲激情五月婷婷| 国内精品久久久久影院一蜜桃| 在线一区二区三区四区| 国产网站一区二区| 日韩高清不卡一区二区| 91一区在线观看| 精品国产污污免费网站入口| 亚洲成av人片在线观看| 99麻豆久久久国产精品免费 | 国产精品自拍在线| 欧美日韩国产一二三| 亚洲欧洲精品成人久久奇米网| 美女国产一区二区三区| 欧美私人免费视频| 国产精品不卡一区二区三区| 久久国产精品99久久人人澡| 欧美日韩一卡二卡三卡 | 欧美中文字幕不卡| 日本一区二区电影| 激情图区综合网| 在线播放91灌醉迷j高跟美女| 亚洲欧洲成人精品av97| 国产原创一区二区| 91精品国产综合久久久久久漫画| 日韩毛片高清在线播放| 国产91精品一区二区麻豆网站| 91精品国产入口| 亚洲午夜一区二区三区| 99国产精品久久| 久久久国产精品不卡| 精品影院一区二区久久久| 欧美肥大bbwbbw高潮| 一区二区三区毛片| 99视频超级精品| 国产精品无遮挡| 国产尤物一区二区| 精品国产不卡一区二区三区| 蜜桃一区二区三区在线| 91精品国产入口| 婷婷开心久久网| 在线播放/欧美激情| 五月激情综合色| 欧美精品一二三四| 午夜精品久久久久久| 欧美少妇bbb| 亚洲国产cao| 欧美亚洲国产bt| 亚洲自拍都市欧美小说| 日本精品一级二级| 亚洲精品一二三四区| 91香蕉视频污在线| 一区二区三区四区视频精品免费| 91丨porny丨中文| 亚洲激情av在线| 在线观看91视频| 婷婷久久综合九色综合伊人色| 51午夜精品国产| 精品一区二区综合| 国产午夜精品福利| 成人高清视频免费观看| 亚洲四区在线观看| 日本道在线观看一区二区| 一区二区成人在线| 欧美乱妇15p| 黄网站免费久久| 日本一区二区免费在线| 99视频在线精品| 亚洲午夜免费电影| 欧美精品乱码久久久久久按摩| 奇米精品一区二区三区在线观看一| 日韩欧美专区在线| 国产九九视频一区二区三区| 国产精品久久久久久久久久久免费看 | 欧美综合色免费| 亚洲成人tv网| 精品99一区二区| 成人激情综合网站| 亚洲天堂av老司机| 欧美夫妻性生活| 国产美女精品人人做人人爽| 成人免费在线视频| 欧美日韩美女一区二区| 韩国v欧美v日本v亚洲v| 亚洲欧洲三级电影| 777xxx欧美| 国产成人午夜电影网| 亚洲男人的天堂网| 欧美一区二区视频在线观看2020| 激情综合网av| 亚洲精品菠萝久久久久久久| 制服丝袜亚洲精品中文字幕| 国产激情一区二区三区桃花岛亚洲| 中文字幕一区在线观看视频| 欧美精品aⅴ在线视频| 国产老肥熟一区二区三区| 曰韩精品一区二区| 亚洲精品一区在线观看| 色婷婷亚洲婷婷| 久久er精品视频| 亚洲丝袜自拍清纯另类| 日韩三级高清在线| www.色综合.com| 蜜桃精品视频在线观看| 国产精品伦一区二区三级视频| 欧美日韩一卡二卡三卡 | 国产精品国产成人国产三级| 欧美色中文字幕| 粉嫩av一区二区三区在线播放| 亚洲综合激情另类小说区| 久久综合色综合88| 欧美视频自拍偷拍| 国产美女娇喘av呻吟久久| 亚洲福利一区二区三区| 中国色在线观看另类| 91精品在线免费| 99精品久久只有精品| 精品一区二区三区视频| 亚洲午夜在线电影| 国产精品盗摄一区二区三区| 欧美一级艳片视频免费观看| 日本精品裸体写真集在线观看| 国产一区二区女| 日本女优在线视频一区二区| 一区二区三区在线视频免费观看| 国产婷婷一区二区| 日韩一级完整毛片| 欧美性生活一区| 91丨porny丨国产入口| 国产精品中文有码| 久久精品国内一区二区三区| 亚洲成人动漫在线观看| 夜夜嗨av一区二区三区网页| 国产精品毛片久久久久久| 精品少妇一区二区三区日产乱码 | 极品美女销魂一区二区三区免费| 亚洲高清免费视频| 亚洲女人小视频在线观看| 国产视频一区二区在线观看| 欧美一区二区在线免费观看| 欧美色倩网站大全免费| 欧洲av一区二区嗯嗯嗯啊| 成人av网址在线观看| 国产精品一区二区果冻传媒| 久久国产精品一区二区| 青青草成人在线观看| 亚瑟在线精品视频| 亚洲国产一区二区三区| 亚洲乱码国产乱码精品精98午夜| 国产精品久久久久一区二区三区| 国产午夜精品理论片a级大结局| 亚洲精品在线三区| 精品成人免费观看| 26uuu精品一区二区| 精品电影一区二区| 久久综合九色综合97婷婷女人| 精品少妇一区二区三区在线播放| 日韩视频一区在线观看| 欧美不卡一区二区三区四区| 欧美一区二区三区四区久久| 6080yy午夜一二三区久久| 欧美一区二区三区日韩视频| 91精品国产综合久久精品性色 | 精品中文字幕一区二区小辣椒 | 欧美国产一区二区在线观看| 国产视频一区不卡| 国产女人18水真多18精品一级做| 国产欧美日韩在线| 亚洲国产精品v| 自拍偷拍国产精品| 亚洲免费视频中文字幕| 亚洲精品高清在线| 五月婷婷久久丁香| 久久激五月天综合精品| 激情深爱一区二区| 国产91精品久久久久久久网曝门| 国产1区2区3区精品美女| av网站免费线看精品| 欧美在线视频你懂得| 在线播放中文一区| 久久综合色一综合色88| 国产精品久久久久久福利一牛影视|