expMult method

void expMult (Float64List array, double a, bool isComplex, String groupDelay)

This is an in-place pointwise multiplication of an array with an exponential function ("em=exponential multiply"): arrayi = arrayi * exp(ai), i=0,..,array.length-1. The exponential is computed recursively: em(0) = 1, em(i+1) = exp(a) * em(i). If isComplex is true, array is considered as a sequence of complex points, re,im,re,im, ... where re (real) and im (imaginary) are on the same scale: arrayi = arrayi * exp(ai), i=0,..,(array.length-1)/2, i += 2; or equivalently: arrayi+1 = arrayi * exp(a), i=0,..,array.length-1.

groupDelay is the value for t=0 given in complex data points. See FFT.transformShuffled for details. Exponential mult. will only start from this delay on if not null. a defines the exponential decay and is application dependent, for example: a = -PILBAQ/(td - 1) (for complex data, set a=2*a), where LB is the "line broading", given in Hertz, e.g. 0.5, for time signals which would yield this line broadening after Fourier transform. In this case AQ would be the length of the time signal in seconds, and td the "time domain size", i.e. array.length.

Implementation

static void expMult(
    Float64List array, double a, bool isComplex, String groupDelay) {
  int i = 0;
  if (groupDelay != null && double.parse(groupDelay) > 0) {
    i = double.parse(groupDelay).round();
  }

  double emi = 1.0;
  double fact = math.exp(a);
  if (isComplex) {
    i *= 2;
    while (true) {
      emi *= fact;
      if (i + 2 >= array.length) break;
      array[i + 2] = array[i + 2] * emi;

      if (i + 3 >= array.length) break;
      array[i + 3] = array[i + 3] * emi;
      i += 2;
    }
  } else {
    while (true) {
      emi *= fact;
      if (i + 1 >= array.length) break;
      array[i + 1] = array[i + 1] * emi;

      i += 1;
    }
  }
}