void VesuvioResolution::function1D(double *out, const double *xValues,
                                   const size_t nData) const {
    std::vector<double> outVec(static_cast<int>(nData), 0);
    const std::vector<double> xValuesVec(xValues, xValues + nData);
    voigtApprox(outVec, xValuesVec, 0, 1, m_lorentzFWHM, m_resolutionSigma);
    std::copy(outVec.begin(), outVec.end(), out);
}
/**
 * Convenience wrapper for voigtApprox. This version uses the cached values of
 * the widths
 * @param voigt [Out] Output values (vector is expected to be of the correct
 * size
 * @param xValues Input coordinates
 * @param lorentzPos LorentzPos parameter
 * @param lorentzAmp LorentzAmp parameter
 */
void VesuvioResolution::voigtApprox(std::vector<double> &voigt,
                                    const std::vector<double> &xValues,
                                    const double lorentzPos,
                                    const double lorentzAmp) const {
    voigtApprox(voigt, xValues, lorentzPos, lorentzAmp, m_lorentzFWHM,
                m_resolutionSigma);
}
    /**
     * Uses a Gaussian approximation for the mass and convolutes it with the Voigt
     * instrument resolution function
     * @param result An pre-sized output vector that should be filled with the results
     * @param lorentzFWHM The lorentz width for the resolution
     * @param resolutionFWHM The sum-squared value of the resolution errors
     */
    void GaussianComptonProfile::massProfile(std::vector<double> & result,const double lorentzFWHM, const double resolutionFWHM) const
    {
      double lorentzPos(0.0), gaussWidth(getParameter(0)), amplitude(getParameter(1));
      double gaussFWHM = std::sqrt(std::pow(resolutionFWHM,2) + std::pow(2.0*STDDEV_TO_HWHM*gaussWidth,2));

      const auto & yspace = ySpace();

      // Gaussian already folded into Voigt
      voigtApprox(result, yspace, lorentzPos, amplitude, lorentzFWHM, gaussFWHM);
      std::vector<double> voigtDiffResult(yspace.size());
      voigtApproxDiff(voigtDiffResult, yspace, lorentzPos, amplitude, lorentzFWHM, gaussFWHM);

      const auto & modq = modQ();
      const size_t nData(result.size());
      for(size_t j = 0; j < nData; ++j)
      {
        const double factor = std::pow(gaussWidth,4.0)/(3.0*modq[j]);
        result[j] -= factor*voigtDiffResult[j];
      }
    }