bonjour voici un code C++/C d'une FFT.
Pouvez vous apporter tous les commentaires/Corrections/Améliorations que vous estimez necessaires, afin d'améliorer la syntaxe, rigeur, et vitesse de ce programme

merci

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
 
    void  FFT(int dir,int m,double *x)
  {
     long nn,i,i1,j,k,i2,l,l1,l2,o;
     double c1,c2,tx,ty,t1,t2,u1,u2,z;
     double y[nn];
     /* Calculate the number of points */
    nn = 1<<m;
 
    for(o=0;o<nn-1;o++){
       y[o]=0;}
 
    i2 = nn >> 1;
    j = 0;
 
   for (i=0;i<nn-1;i++) {
        if (i < j) {
            tx = x[i];
            ty = y[i];
            x[i] = x[j];
            y[i] = y[j];
            x[j] = tx;
            y[j] = ty;
            }
        k = i2;
        while (k <= j) {
            j -= k;
            k >>= 1;
        }
        j += k;
        }
        c1 = -1.0;
        c2 = 0.0;
        l2 = 1;
        for (l=0;l<m;l++) {
            l1 = l2;
            l2 <<= 1;
            u1 = 1.0;
            u2 = 0.0;
            for (j=0;j<l1;j++) {
                for (i=j;i<nn;i+=l2) {
                    i1 = i + l1;
                    t1 = u1 * x[i1] - u2 * y[i1];
                    t2 = u1 * y[i1] + u2 * x[i1];
                    x[i1] = x[i] - t1;
                    y[i1] = y[i] - t2;
                    x[i] += t1;
                    y[i] += t2;
                }
                z = u1 * c1 - u2 * c2;
                u2 = u1 * c2 + u2 * c1;
                u1 = z;
            }
        c2 = sqrt((1.0 - c1) / 2.0);
        if (dir == 1)
           c2 = -c2;
           c1 = sqrt((1.0 + c1) / 2.0);
        }
 
        for(i=0;i<pow(2,m);i++){
        cout<<x[i]<<",";}
    }