@Override
  public void terminate(PointCollector collector) throws Exception {
    int n = list.size();
    DoubleFFT_1D fft = new DoubleFFT_1D(n);
    // each data point count for 2 double values (re and im)
    double[] a = new double[2 * n];
    for (int i = 0; i < n; i++) {
      a[2 * i] = list.get(i);
      a[2 * i + 1] = 0;
    }
    fft.complexForward(a);
    if (compressed) {
      fftutil.outputCompressed(collector, a);
    } else {
      fftutil.outputUncompressed(collector, a);
    }
  }
This function does Fast Fourier Transform for input series.
library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFFFT.java