transformShuffled method

List<Float64List> transformShuffled (Float64List complArray, String groupDelay, int swapMode)

Computes the discrete FFT of a complex array in place. complArray = the complex values of the array. The array is order in the form real value 0, imag value 0, real value 1, imag value 1,... Throws if the length is not a power of 2. Returns the result: The result is again complex. The real part is the array stored under index 0 of the returned List, the imaginary part corresponds to index 1. The resulting array values are scaled relatively (non absolute values). groupDelay = a double in String format. In some measurement time data, the actual data do not start at 0, but groupDelay later, in terms of complex points. For such types of data the FFT would produce a "phase shifted" result (see function phascor below). This phase shift is accounted for if groupDelay is chosen not be zero but according to the measurement. swapMode = one of FT_SWAP_MODE_NO, FT_SWAP_MODE_FULL, FT_SWAP_MODE_HALF. These modes are needed depending on how the data to be transformed were sampled on a measurement device, e.g. a spectrometer. FT_SWAP_MODE_NO: no special effect FT_SWAP_MODE_FULL: 1) every other complex points is negated before th transform. 2) The order of the real data points is reversed after transform. The same is done for the imaginary data points. FT_SWAP_MODE_HALF: The order of the first half of the real data points, and of the seconds half of the real data points is reversed after transform. The same is applied to the imaginary data points.

Implementation

static List<Float64List> transformShuffled(
    Float64List complArray, String groupDelay, int swapMode) {
  // reim in new, shuffledArray remains unchanged.
  List<Float64List> reim = Array1D.unshuffle(complArray);

  // negation of every other (complex) point needed
  // e.g. data with bruker groupDelay -1, but DECIM and DSPFVS > 0
  if (swapMode == FT_SWAP_MODE_FULL) {
    for (int i = 0; i < reim[0].length; i += 2) {
      reim[0][i + 1] = -reim[0][i + 1];
      reim[1][i + 1] = -reim[1][i + 1];
    }
  }

  transform(reim[0], reim[1]); // in-place transform of complex data

  if (groupDelay != null && double.parse(groupDelay) > 0) {
    phascor(reim[0], reim[1], 0, double.parse(groupDelay) * 360); // orig
  }

  // e.g. data with  groupDelay -1, but DECIM and DSPFVS > 0
  if (swapMode == FT_SWAP_MODE_FULL) {
    Array1D.swap(reim[0]);
    Array1D.swap(reim[1]);
  } else if (swapMode == FT_SWAP_MODE_HALF) {
    // e.g. data with bruker groupDelay > 0,
    Array1D.swapHalf(reim[0]);
    Array1D.swapHalf(reim[1]);
  }
  return reim;
}