±±¾©Ê¯ÓÍ»¯¹¤Ñ§Ôº2026ÄêÑо¿ÉúÕÐÉú½ÓÊÕµ÷¼Á¹«¸æ
²é¿´: 563  |  »Ø¸´: 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

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

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µÄ»ØÌû
²é¿´È«²¿ 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

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

ßÀ~ ·¢ÏÖÁË Êý×鶨Òå³ö´íÁË Ð»Ð»ÁË
5Â¥2010-06-02 14:57:36
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[¿¼ÑÐ] ¹¤¿Æ341·Öµ÷¼Á +3 Âå¶àÂÞ 2026-04-03 3/150 2026-04-03 14:20 by 1753564080
[¿¼ÑÐ] 324Çóµ÷¼Á +12 ÏëÉÏѧÇóµ÷ 2026-04-02 12/600 2026-04-03 11:15 by linyelide
[¿¼ÑÐ] 070300»¯Ñ§Çóµ÷¼Á +10 Æð¸öÃûÕ¦ÕâôÄÑ 2026-03-27 11/550 2026-04-03 10:24 by macy2011
[¿¼ÑÐ] Ò»Ö¾Ô¸ÏÃÃÅ´óѧ²ÄÁϹ¤³Ìר˶354ÕÒµ÷¼Á£¡£¡£¡ +8 ±´ß±µ±µ 2026-03-30 8/400 2026-04-03 09:41 by hypershenger
[¿¼ÑÐ] Ò»Ö¾Ô¸Î人Àí¹¤0856£¬³õÊÔ334 +3 26¿¼ÑвÄÁÏ 2026-04-02 3/150 2026-04-02 21:22 by dongzh2009
[¿¼ÑÐ] 285Çóµ÷¼Á +14 AZMK 2026-04-02 14/700 2026-04-02 15:54 by ÉϾÅÌìÀ¿Ô£¨ºÃÔ
[¿¼ÑÐ] Ò»Ö¾Ô¸Äϲý´óѧ324Çóµ÷¼Á +12 hanamiko 2026-04-01 12/600 2026-04-02 14:51 by 5896
[¿¼ÑÐ] 283Çóµ÷¼Á +3 jiouuu 2026-04-02 4/200 2026-04-02 14:08 by ßÕßÕßÕßÉßÉßÉ
[¿¼ÑÐ] 261ÇóBÇøµ÷¼Á +5 Ã÷×С¤ 2026-04-01 7/350 2026-04-02 11:17 by ×Þξξ
[¿¼ÑÐ] Çóµ÷¼Á£¬Ò»Ö¾Ô¸ ÄϾ©º½¿Õº½Ìì´óѧ £¬080500²ÄÁÏ¿ÆÑ§Ó빤³Ìѧ˶£¬×Ü·Ö289·Ö +11 @taotao 2026-03-29 11/550 2026-04-02 10:04 by realme321
[¿¼ÑÐ] 377Çóµ÷¼Á +3 RASKIN 2026-04-02 3/150 2026-04-02 09:45 by zzchen2000
[¿¼ÑÐ] 265Çóµ÷¼Á +11 yelck 2026-04-01 12/600 2026-04-01 19:12 by 549790059
[¿¼ÑÐ] µ÷¼Á +3 ºÃºÃ¶ÁÊé¡£ 2026-04-01 3/150 2026-04-01 17:06 by zhouyuwinner
[¿¼ÑÐ] 08¹¤¿Æ275Çóµ÷¼Á£¬¿É¿ç¿¼¡£ +5 AaAa7420 2026-03-31 5/250 2026-04-01 15:21 by 159357hjz
[¿¼ÑÐ] 0856µ÷¼Á +7 ÇúÌýóÞ 2026-03-30 7/350 2026-04-01 08:51 by JourneyLucky
[¿¼ÑÐ] ¿¼Ñе÷¼ÁÇóÖú +7 13287130938 2026-03-31 7/350 2026-03-31 16:39 by 690616278
[¿¼ÑÐ] ÇóÊÕÁô +8 1943443204 2026-03-28 8/400 2026-03-31 15:00 by -ÃÔÁË·°¡Â·
[¿¼ÑÐ] Çóµ÷¼Á +7 Çà´º²ÃΪÈý½Ø 2026-03-29 7/350 2026-03-30 13:14 by laoshidan
[¿¼ÑÐ] 279Çóµ÷¼Á +4 µûÎèÇáÈÆ 2026-03-29 4/200 2026-03-29 09:45 by laoshidan
[¿¼ÑÐ] 356Çóµ÷¼Á +3 gysy?s?a 2026-03-28 3/150 2026-03-29 00:33 by 544594351
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û