Пример #1
0
 /**
  * Links the user-supplied input sequence and output transform arrays. Propagates the links to
  * child DFTs.
  *
  * @param xr double[] containing the input sequence real part.
  * @param xi double[] containing the input sequence imaginary part.
  * @param Xr double[] containing the output sequence real part.
  * @param Xi double[] containing the output sequence imaginary part.
  */
 void link(double[] xr, double[] xi, double[] Xr, double[] Xi) {
   this.xr = xr;
   this.xi = xi;
   this.Xr = Xr;
   this.Xi = Xi;
   dft1.link(xr, xi, Xr, Xi);
   dft2.link(xr, xi, Xr, Xi);
   dft3.link(xr, xi, Xr, Xi);
 }
Пример #2
0
  /** Evaluates the complex DFT. */
  void evaluate() {

    double T1r, T1i, T3r, T3i;
    double Rr, Ri, Sr, Si;
    double Wr, Wi;

    dft1.evaluate();
    dft2.evaluate();
    dft3.evaluate();

    // k = 0 butterfly

    int kp = Xoffset;
    int kpN4 = kp + N4;
    int kpN2 = kpN4 + N4;
    int kp3N4 = kpN2 + N4;

    Rr = Xr[kpN2] + Xr[kp3N4];
    Ri = Xi[kpN2] + Xi[kp3N4];
    Sr = Xi[kp3N4] - Xi[kpN2];
    Si = Xr[kpN2] - Xr[kp3N4];

    Xr[kpN2] = Xr[kp] - Rr;
    Xi[kpN2] = Xi[kp] - Ri;
    Xr[kp3N4] = Xr[kpN4] + Sr;
    Xi[kp3N4] = Xi[kpN4] + Si;

    Xr[kp] += Rr;
    Xi[kp] += Ri;
    Xr[kpN4] -= Sr;
    Xi[kpN4] -= Si;

    // k = 1 through N8-1 butterflies

    int fk;

    for (int k = 1; k < N8; k++) {

      fk = f * k;
      kp = k + Xoffset;
      kpN4 = kp + N4;
      kpN2 = kpN4 + N4;
      kp3N4 = kpN2 + N4;

      // T1 = Wk*O1
      // T3 = W3k*O3

      Wr = c[fk];
      Wi = s[fk];
      T1r = Wr * Xr[kpN2] - Wi * Xi[kpN2];
      T1i = Wr * Xi[kpN2] + Wi * Xr[kpN2];
      Wr = c3[fk];
      Wi = s3[fk];
      T3r = Wr * Xr[kp3N4] - Wi * Xi[kp3N4];
      T3i = Wr * Xi[kp3N4] + Wi * Xr[kp3N4];

      // R = T1 + T3
      // S = i*(T1 - T3)

      Rr = T1r + T3r;
      Ri = T1i + T3i;
      Sr = T3i - T1i;
      Si = T1r - T3r;

      Xr[kpN2] = Xr[kp] - Rr;
      Xi[kpN2] = Xi[kp] - Ri;
      Xr[kp3N4] = Xr[kpN4] + Sr;
      Xi[kp3N4] = Xi[kpN4] + Si;

      Xr[kp] += Rr;
      Xi[kp] += Ri;
      Xr[kpN4] -= Sr;
      Xi[kpN4] -= Si;
    }

    // k = N/8 butterfly

    kp = N8 + Xoffset;
    kpN4 = kp + N4;
    kpN2 = kpN4 + N4;
    kp3N4 = kpN2 + N4;

    // T1 = Wk*O1
    // T3 = W3k*O3

    T1r = SQRT2BY2 * (Xr[kpN2] + Xi[kpN2]);
    T1i = SQRT2BY2 * (Xi[kpN2] - Xr[kpN2]);

    T3r = SQRT2BY2 * (Xi[kp3N4] - Xr[kp3N4]);
    T3i = -SQRT2BY2 * (Xi[kp3N4] + Xr[kp3N4]);

    // R = T1 + T3
    // S = i*(T1 - T3)

    Rr = T1r + T3r;
    Ri = T1i + T3i;
    Sr = T3i - T1i;
    Si = T1r - T3r;

    Xr[kpN2] = Xr[kp] - Rr;
    Xi[kpN2] = Xi[kp] - Ri;
    Xr[kp3N4] = Xr[kpN4] + Sr;
    Xi[kp3N4] = Xi[kpN4] + Si;

    Xr[kp] += Rr;
    Xi[kp] += Ri;
    Xr[kpN4] -= Sr;
    Xi[kpN4] -= Si;

    // k = N/8+1 through N/4-1 butterflies

    for (int k = N8 + 1; k < N4; k++) {

      fk = reflect - f * k;
      kp = k + Xoffset;
      kpN4 = kp + N4;
      kpN2 = kpN4 + N4;
      kp3N4 = kpN2 + N4;

      // T1 = Wk*O1
      // T3 = W3k*O3

      Wr = -s[fk];
      Wi = -c[fk];
      T1r = Wr * Xr[kpN2] - Wi * Xi[kpN2];
      T1i = Wr * Xi[kpN2] + Wi * Xr[kpN2];
      Wr = s3[fk];
      Wi = c3[fk];
      T3r = Wr * Xr[kp3N4] - Wi * Xi[kp3N4];
      T3i = Wr * Xi[kp3N4] + Wi * Xr[kp3N4];

      // R = T1 + T3
      // S = i*(T1 - T3)

      Rr = T1r + T3r;
      Ri = T1i + T3i;
      Sr = T3i - T1i;
      Si = T1r - T3r;

      Xr[kpN2] = Xr[kp] - Rr;
      Xi[kpN2] = Xi[kp] - Ri;
      Xr[kp3N4] = Xr[kpN4] + Sr;
      Xi[kp3N4] = Xi[kpN4] + Si;

      Xr[kp] += Rr;
      Xi[kp] += Ri;
      Xr[kpN4] -= Sr;
      Xi[kpN4] -= Si;
    }
  }