static void fastFT1D(double[] real, double[] imag, int numOfPower, boolean direct)
  {
    int numOfPoint, i1, i2, j2, k2, l1, l2;
    double tr, ti, c1, c2, u1, u2, t1, t2, z;

    numOfPoint = real.length;

    /* Do the bit reversal */
    i2 = numOfPoint >> 1;
    j2 = 0;
    for (int i = 0; i < numOfPoint - 1; i++)
    {
      if (i < j2)
      {
        tr = real[i];
        ti = imag[i];
        real[i] = real[j2];
        imag[i] = imag[j2];
        real[j2] = tr;
        imag[j2] = ti;
      }
      k2 = i2;
      while (k2 <= j2)
      {
        j2 -= k2;
        k2 >>= 1;
      } 
      j2 += k2;
    }
  
    /* Compute 1D FFT */
    c1 = -1.0;
    c2 = 0.0;
    l2 = 1;
    for (int l = 0; l < numOfPower; l++)		//Loops through stages
    {
      l1 = l2;
      l2 <<= 1;
      u1 = 1.0;
      u2 = 0.0;
  
      for (int j = 0; j < l1; j++)
      {
        for (int i = j; i < numOfPoint; i += l2)
        {
          i1 = i + l1;
          t1 = u1 * real[i1] - u2 * imag[i1];
          t2 = u1 * imag[i1] + u2 * real[i1];
          real[i1] = real[i] - t1;
          imag[i1] = imag[i] - t2;
          real[i] += t1;
          imag[i] += t2;
        }
        z = u1 * c1 - u2 * c2;
        u2 = u1 * c2 + u2 * c1;
        u1 = z;
      }
      c2 = Math.sqrt((1.0 - c1) / 2.0);
      if (direct)
        c2 = -c2;
      c1 = Math.sqrt((1.0 + c1) / 2.0);
    }

    /* Scaling for forward FFT */
    if (direct)
      for (int i = 0; i < numOfPoint; i++)
      {
        real[i] /= (double)numOfPoint;
        imag[i] /= (double)numOfPoint;
      }
  }	//End of fastFT1D