getValueAt method

double getValueAt (List<double> x)
override

Returns the value of this mixed Gauss-Lorentz shape at the n-dimensional point x. Throws Exception if the dimension of x is not in accordance with the parameters specified at shape construction time.

Implementation

double getValueAt(List<double> x) {
  if (dim != x.length) {
    throw "Illegal dimension. Should be $dim";
  }

  double voigt = 1.0;
  double lorentz = 0.0, gauss = 0.0, factor = 0.0;
  for (int i = 0; i < dim; i++) {
    factor = (x[i] - c[i]) / (1.0 * w[i]); // stored widths are half-widths
    factor *= factor;

    lorentz = m[i] / (1 + fLorentz * factor);
    // speed up: only compute exp() if no pure Lorentzian (0 <= m[i] <= 1
    if ((1 - m[i]) > 0.001) {
      gauss = (1 - m[i]) * math.exp(-fGauss * factor);
      voigt *= lorentz + gauss;
    } else {
      voigt *= lorentz;
    }
  }
  voigt *= a;
  return voigt;
}