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

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

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

ÊÇ ³ÌÐò´íÎó
3Â¥2010-06-02 14:43:06
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢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µÄ»ØÌû

zhanglei22

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

ßÀ~ ·¢ÏÖÁË Êý×鶨Òå³ö´íÁË Ð»Ð»ÁË
5Â¥2010-06-02 14:57:36
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
Ïà¹Ø°æ¿éÌø×ª ÎÒÒª¶©ÔÄÂ¥Ö÷ zhanglei22 µÄÖ÷Ìâ¸üÐÂ
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[¿¼ÑÐ] Ò»Ö¾Ô¸½­ÄÏ´óѧ085501»úе¹¤³Ìר˶326·Ö£¬±¾¿Æ¼Ñľ˹´óѧ +3 ¹ËÈô¸¡Éú 2026-04-03 6/300 2026-04-03 13:43 by wangpping
[¿¼ÑÐ] »¯Ñ§308·Öµ÷¼Á +19 ÄãºÃÃ÷ÌìÄãºÃ 2026-03-30 20/1000 2026-04-03 11:34 by rjnabociow
[¿¼ÑÐ] 295Çóµ÷¼Á +7 Ô¸ÂÃ;ÓÀԶ̹Ȼ 2026-04-02 7/350 2026-04-03 08:22 by fangshan711
[¿¼ÑÐ] Ò»Ö¾Ô¸»ªÖÐũҵ071010£¬×Ü·Ö320Çóµ÷¼Á +6 À§À§À§À§À¤À¤ 2026-04-02 6/300 2026-04-02 21:28 by dongzh2009
[¿¼ÑÐ] 085602»¯¹¤Çóµ÷¼Á£¨331·Ö£© +9 111@127 2026-03-30 9/450 2026-04-02 20:00 by dick_runner
[¿¼ÑÐ] 318Çóµ÷¼Á£¬¼ÆËã²ÄÁÏ·½Ïò +10 Îüß÷Óк¦óÏÃü 2026-04-01 11/550 2026-04-02 16:29 by oooqiao
[¿¼ÑÐ] 285Çóµ÷¼Á +14 AZMK 2026-04-02 14/700 2026-04-02 15:54 by ÉϾÅÌìÀ¿Ô£¨ºÃÔ
[¿¼ÑÐ] ²ÄÁϹ¤³Ì322·Ö +8 ¹þ¹þ¹þºðºðºð¹þ 2026-04-01 8/400 2026-04-02 11:53 by 3041
[¿¼ÑÐ] 070300»¯Ñ§Çóµ÷¼Á +14 С»ÆÑ¼±¦ 2026-03-30 14/700 2026-04-02 10:07 by oooqiao
[¿¼ÑÐ] 279Çóµ÷¼Á +6 ѧ¶øË¼ÙâÖª 2026-04-01 6/300 2026-04-02 09:16 by vgtyfty
[¿¼ÑÐ] 086000ÉúÎïÓëÒ½Ò©298µ÷¼ÁÇóÖú +4 ÔªÔªÇàÇà 2026-03-31 6/300 2026-04-01 11:13 by syh9288
[¿¼ÑÐ] Çóµ÷¼Á£ºÒ»Ö¾Ô¸£ºÄϾ©´óѧ רҵ£º0705 ×Ü·Ö320 £¬±¾¿Æ985£¬ËÄÁù¼¶Òѹý +3 lfy760306 2026-03-31 3/150 2026-04-01 01:57 by Creta
[¿¼ÑÐ] 085601Ó¢¶þÊý¶þÇóµ÷¼Á ×Ü·Ö325 +4 Óຽº½ 2026-03-31 4/200 2026-03-31 17:38 by ÌÆãå¶ù
[¿¼ÑÐ] Çóµ÷¼Á ÉúÎïѧ 377·Ö +6 zzll03 2026-03-31 6/300 2026-03-31 17:33 by ÌÆãå¶ù
[¿¼ÑÐ] Ó¢Ò»ÊýÒ»×Ü·Ö334Çóµ÷¼Á +4 ³ÂÑôÀ¤ 2026-03-31 4/200 2026-03-31 14:22 by ¼Çʱ¾2026
[¿¼ÑÐ] 081200-11408-276ѧ˶Çóµ÷¼Á +4 ´Þwj 2026-03-31 4/200 2026-03-31 11:56 by jp9609
[¿¼ÑÐ] ÄϾ©´óѧ»¯Ñ§µ÷¼Á +11 ¾°Ëæ·ç 2026-03-29 16/800 2026-03-31 10:14 by herarysara
[¿¼ÑÐ] 332Çó92µ÷¼Á +8 ½¶½¶123 2026-03-28 8/400 2026-03-29 10:46 by ÖÜè÷µ¤
[¿¼ÑÐ] Çóµ÷¼Á +7 ÕùÈ¡¾Åµã˯ 2026-03-28 8/400 2026-03-28 21:07 by ÕùÈ¡¾Åµã˯
[¿¼ÑÐ] ҩѧ105500Çóµ÷¼Á +3 Ssun¡£¡£ 2026-03-28 3/150 2026-03-28 11:24 by lxf170613
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û