示例#1
0
文件: FFT.java 项目: xen-0/dawnsci
  private static Dataset ifft2d(final Dataset a, final int[] s, final int[] axes) {
    Dataset result = null;
    Dataset dest = null;

    PositionIterator pi;
    int[] pos;
    boolean[] hit;

    switch (a.getDtype()) {
      case Dataset.FLOAT32:
      case Dataset.COMPLEX64:
        FloatFFT_2D ffft = new FloatFFT_2D(s[0], s[1]);
        float[] fdata = null;
        result = new ComplexFloatDataset(newShape(a.getShapeRef(), s, axes));
        dest = new ComplexFloatDataset(s);
        fdata = (float[]) dest.getBuffer();
        pi = a.getPositionIterator(axes);
        pos = pi.getPos();
        hit = pi.getOmit();
        while (pi.hasNext()) {
          Arrays.fill(fdata, 0.f);
          a.copyItemsFromAxes(pos, hit, dest);
          ffft.complexInverse(fdata, true);
          result.setItemsOnAxes(pos, hit, fdata);
        }
        break;
      case Dataset.FLOAT64:
      case Dataset.COMPLEX128:
        DoubleFFT_2D dfft = new DoubleFFT_2D(s[0], s[1]);
        double[] ddata = null;
        result = new ComplexDoubleDataset(newShape(a.getShapeRef(), s, axes));
        dest = new ComplexDoubleDataset(s);
        ddata = (double[]) dest.getBuffer();
        pi = a.getPositionIterator(axes);
        pos = pi.getPos();
        hit = pi.getOmit();
        while (pi.hasNext()) {
          Arrays.fill(ddata, 0.);
          a.copyItemsFromAxes(pos, hit, dest);
          dfft.complexInverse(ddata, true);
          result.setItemsOnAxes(pos, hit, ddata);
        }
        break;
      default:
        logger.warn("Non-float dataset not yet supported");
        break;
    }

    return result;
  }