±±¾©Ê¯ÓÍ»¯¹¤Ñ§Ôº2026ÄêÑо¿ÉúÕÐÉú½ÓÊÕµ÷¼Á¹«¸æ
²é¿´: 558  |  »Ø¸´: 4
µ±Ç°Ö»ÏÔʾÂú×ãÖ¸¶¨Ìõ¼þµÄ»ØÌû£¬µã»÷ÕâÀï²é¿´±¾»°ÌâµÄËùÓлØÌû

zhanglei22

Òø³æ (СÓÐÃûÆø)

[½»Á÷] ¡¾ÇóÖú¡¿°ïæ¿´¿´³ÌÐò£¡Ð»Ð»ÁË¡¾ÒÑÍê½á¡¿ ÒÑÓÐ2È˲ÎÓë

ÕâÊÇfftµÄ³ÌÐò ÔËÐÐÖгöÁËÎÊÌâ ²»ÖªÄĵĴíÎó
#include
#include
#include
#define N 1000
typedef struct
{
        double real;
    double img;
} complex;

void fft();          //¿ìËÙ¸µÀïÒ¶±ä»»
void initw();
void change();

void add(complex,complex,complex *);
void mul(complex,complex,complex *);
void sub(complex,complex,complex *);
void output();

complex x(N),*w;
int size_x=0;
double PI;

int main()
{
        int i,method;
        void fft();
        void initw();
        void change();
    void add(complex,complex,complex *);
    void mul(complex,complex,complex *);
    void sub(complex,complex,complex *);
    void divi(complex,complex,complex *);

        PI=atan(1)*4;
        printf("please input the size of x:\n";
        scanf("%d",&size_x);
        printf("please input the date in x(N):\n";
        for(i=0;i         scanf("%lf%lf",&x.real,&x.img);
        initw();
        output();
        return 0;
}

void fft()
{
        int i=0,j=0,k=0,l=0;
        complex up,down,product;
        change();
        for(i=0;i         {
                l=1<                 for(j=0;j                 {
                        for(k=0;k                         {
                                mul(x[j+k+l],w[size_x*k/2/l],&product);
                                add(x[j+k],product,&up);
                                sub(x[j+k],product,&down);
                                x[j+k]=up;
                                x[j+k+l]=down;
                        }
                }
        }
}

void initw()
{
        int i;
        w=(complex *)malloc(sizeof(complex)*size_x);
        for(i=0;i         {
                w.real=cos(2*PI/size_x*i);
                w.img=-1*sin(2*PI/size_x*i);
        }
}

void change()
{
        complex temp;
        unsigned short i=0,j=0,k=0;
        double t;
        for(i=0;i         {
                k=1;j=0;
                t=(log(size_x)/log(2));
                while((t--)>0)
                {j=j<<1;j|=(k&1);k=k>>1;}
                if(j>1)
                {temp=x;x=x[j];x[j]=temp;}
        }
}

void output()
{
        int i;
        printf("the result are as follows \n";
        for(i=0;i         {
                printf("%.4f",x.real);
                if(x.img>=0.0001)
                        printf("+%.4f\n",x.img);
                else if(fabs(x.img)<0.0001)
                        printf("\n";
                else printf("%.4f\n",x.img);
        }
}

void add(complex a,complex b,complex *c)
{
        c->real=a.real+b.real;
        c->img=a.img+b.img;
}

void mul(complex a,complex b,complex *c)
{
        c->real=a.real*b.real-a.img*b.img;
        c->img=a.real*b.img+a.img*b.real;
}

void sub(complex a,complex b,complex *c)
{
        c->real=a.real-b.real;
        c->img=a.img-b.img;
}

[ Last edited by ÓàÔó³É on 2010-6-2 at 16:23 ]
»Ø¸´´ËÂ¥

» ²ÂÄãϲ»¶

» ±¾Ö÷ÌâÏà¹Ø¼ÛÖµÌùÍÆ¼ö£¬¶ÔÄúͬÑùÓаïÖú:

ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

zhanglei22

Òø³æ (СÓÐÃûÆø)

ßÀ~ ·¢ÏÖÁË Êý×鶨Òå³ö´íÁË Ð»Ð»ÁË
5Â¥2010-06-02 14:57:36
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
²é¿´È«²¿ 5 ¸ö»Ø´ð

magic7004

½ð³æ (Ö°Òµ×÷¼Ò)

¡ï
resonant(½ð±Ò+1):¸Ðл²ÎÓë¡£ 2010-06-01 15:04:01
zhanglei22(½ð±Ò+5): 2010-06-02 14:57:45
ÔΣ¬Â¥Ö÷ÖÁÉÙҪ˵һÏÂÊÇʲôÑùµÄ´íÎó°É

ÊDZàÒë²»¹ý£¬»¹ÊÇÔËÐÐʱ±ÀÀ££¬»¹ÊǼÆËã½á¹û²»¶Ô£¿
Èç¹ûÊÇǰÁ½¸öµÄ»°£¬Ë³±ã°Ñ´íÎóÐÅÏ¢Ò²Ìù³öÀ´
Èç¹ûÊǺóÒ»¸öµÄ»°£¬¶®FFTµÄÀ´°É£¬ÎÒÖ»¶®C£¬²»¶®¼ÆËã
Á÷Ã¥²»¿ÉÅ£¬¿ÉŵÄÊÇÁ÷Ã¥ÓÐÎÄ»¯£¬ÓÐÎÄ»¯ÓÖBHµÄÁ÷Ã¥ÎÞµÐ~~£¡
2Â¥2010-06-01 14:36:21
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

zhanglei22

Òø³æ (СÓÐÃûÆø)

ompiling...
fft.cpp
D:\vc\FFT\fft.cpp(22) : error C2440: 'initializing' : cannot convert from 'const int' to 'complex'
        No constructor could take the source type, or constructor overload resolution was ambiguous
D:\vc\FFT\fft.cpp(42) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(42) : error C2228: left of '.real' must have class/struct/union type
D:\vc\FFT\fft.cpp(42) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(42) : error C2228: left of '.img' must have class/struct/union type
D:\vc\FFT\fft.cpp(60) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(61) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(62) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(63) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(64) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(93) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(93) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(93) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(93) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(103) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(103) : error C2228: left of '.real' must have class/struct/union type
D:\vc\FFT\fft.cpp(104) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(104) : error C2228: left of '.img' must have class/struct/union type
D:\vc\FFT\fft.cpp(105) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(105) : error C2228: left of '.img' must have class/struct/union type
D:\vc\FFT\fft.cpp(106) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(106) : error C2228: left of '.img' must have class/struct/union type
D:\vc\FFT\fft.cpp(108) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\vc\FFT\fft.cpp(108) : error C2228: left of '.img' must have class/struct/union type
Ö´ÐÐ cl.exe ʱ³ö´í.

FFT.exe - 1 error(s), 0 warning(s)
Õâ¸ö´íÎó£¡
4Â¥2010-06-02 14:44:12
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[¿¼ÑÐ] ÉúÎïѧ308·ÖÇóµ÷¼Á£¨Ò»Ö¾Ô¸»ª¶«Ê¦´ó£© +3 ÏàÐűػá¹ââÍòÕ 2026-04-02 3/150 2026-04-03 09:57 by Çóµ÷¼Ázz
[¿¼ÑÐ] 320Çóµ÷¼Á +4 Õñ¡ªTZ 2026-04-02 4/200 2026-04-03 09:56 by ºÎÔø¼¸ºÎ
[¿¼ÑÐ] ×Ü·Ö328ÉúÎïÓëÒ½Ò©¿¼ÊýѧÇóµ÷¼Á +5 aaadim 2026-04-02 5/250 2026-04-03 09:51 by À¶ÔÆË¼Óê
[¿¼ÑÐ] 326Çóµ÷¼Á +3 9ahye 2026-04-02 4/200 2026-04-03 08:43 by Jaylen.
[¿¼ÑÐ] 322Çóµ÷¼Á£ºÒ»Ö¾Ô¸ºþÄÏ´óѧ ²ÄÁÏÓ뻯¹¤£¨085600£©£¬ÒѹýÁù¼¶¡£ +12 XXСµË 2026-03-29 13/650 2026-04-02 21:39 by °ÙÁéͯ888
[¿¼ÑÐ] ÇóÉúÎïѧµ÷¼Á +10 15172915737 2026-04-01 10/500 2026-04-02 18:53 by ŶŶàŹþ
[¿¼ÑÐ] 318Çóµ÷¼Á£¬¼ÆËã²ÄÁÏ·½Ïò +10 Îüß÷Óк¦óÏÃü 2026-04-01 11/550 2026-04-02 16:29 by oooqiao
[¿¼ÑÐ] ũѧ¿¼ÑÐÇóµ÷¼Á +3 dkdkxm 2026-04-01 3/150 2026-04-02 16:04 by wangjagri
[¿¼ÑÐ] 0805Çóµ÷¼Á +8 ÊÇË®·Ö 2026-03-31 8/400 2026-04-02 10:46 by guanxin1001
[¿¼ÑÐ] ¿¼Ñе÷¼Á +12 Amber00 2026-03-31 12/600 2026-04-02 09:04 by sanrepian
[¿¼ÑÐ] ÉúÎïѧ327£¬Çóµ÷¼Á +5 ÊéÉϵÄ÷×Ó 2026-04-01 6/300 2026-04-02 06:47 by ilovexiaobin
[¿¼ÑÐ] 08¹¤¿Æ275·ÖÇóµ÷¼Á +13 AaAa7420 2026-03-31 13/650 2026-04-02 06:19 by 286640313
[¿¼ÑÐ] 333Çóµ÷¼Á +4 °¢¿ÆÒÝ 2026-03-31 4/200 2026-04-01 09:11 by jp9609
[¿¼ÑÐ] 352·Ö-085602-Ò»Ö¾Ô¸985 +6 º£Äɰٴ¨Ly 2026-03-29 6/300 2026-03-31 21:06 by yuq
[¿¼ÑÐ] 282Çóµ÷¼Á ²»Ìôרҵ ÇóÊÕÁô +4 Yam. 2026-03-30 5/250 2026-03-31 14:41 by ÍõÁÁ_´óÁ¬Ò½¿Æ´ó
[¿¼ÑÐ] 085404 22408 315·Ö +5 zhuangyan123 2026-03-31 6/300 2026-03-31 13:48 by limeifeng
[¿¼ÑÐ] Ò»Ö¾Ô¸Õã½­´óѧ¹¤¿Æ¶¯Á¦¹¤³Ì370,ÊýÒ»121,רҵ¿Î135£¬ÏÖÔÚÄÜÈ¥ÄÄÀï +3 080700µ÷¼Á 2026-03-30 4/200 2026-03-31 12:00 by KLMY666
[¿¼ÑÐ] 298Çóµ÷¼Á +3 ÖÖÊ¥´Í 2026-03-29 3/150 2026-03-29 12:06 by longlotian
[¿¼ÑÐ] 356Çóµ÷¼Á +4 gysy?s?a 2026-03-28 4/200 2026-03-29 10:32 by ÌÆãå¶ù
[¿¼ÑÐ] Ò»Ö¾Ô¸ÄϾ©º½¿Õº½Ìì´óѧ²ÄÁÏѧ˶Çóµ÷¼Á +3 @taotao 2026-03-28 3/150 2026-03-28 10:26 by JourneyLucky
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û