c# - 1D Fast Fourier Transform -


what algorithm following?

what understand following source code is:

  1. dir direction of fft: forward=1, inverse=-1.
  2. x real part
  3. y imaginary part

what m here?

if x = {1, 1, 1, 1, 0, 0, 0, 0}, and, y = {0,0,0,0,0,0,0,0,0}, value of m?

        //inplace 1d fft         public static void fft1d(int dir, int m, ref double[] x, ref double[] y)         {             long nn, i, i1, j, k, i2, l, l1, l2;             double c1, c2, tx, ty, t1, t2, u1, u2, z;             /* calculate number of points */             nn = 1;             (i = 0; < m; i++)                 nn *= 2;             /* bit reversal */             i2 = nn >> 1;             j = 0;             (i = 0; < 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;             }             /* compute fft */             c1 = -1.0;             c2 = 0.0;             l2 = 1;             (l = 0; l < m; l++)             {                 l1 = l2;                 l2 <<= 1;                 u1 = 1.0;                 u2 = 0.0;                 (j = 0; j < l1; j++)                 {                     (i = j; < nn; += l2)                     {                         i1 = + 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 = math.sqrt((1.0 - c1) / 2.0);                 if (dir == 1)                     c2 = -c2;                 c1 = math.sqrt((1.0 + c1) / 2.0);             }             /* scaling forward transform */             if (dir == 1)             {                 (i = 0; < nn; i++)                 {                     x[i] /= (double)nn;                     y[i] /= (double)nn;                 }             }         } 

the implementation of fft have posted limited inputs of size 2m. here m indirectly specify size of fft block size. so, example x = {1,1,1,1,0,0,0,0} , y={1,1,1,1,0,0,0,0} being arrays of size 8=23, m equal 3.

note there no additional checks size of arrays x , y make sure @ least size.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -