15#include <boost/lexical_cast.hpp>
29 : m_centre(0.), m_dcentre(0.), m_fwhm(0.), m_hasNewParameterValue(false), m_cellParamValueChanged(false),
30 m_sortedProfileParameterNames(), m_unitCell(), m_unitCellSize(0.), m_parameterValid(false), mH(0), mK(0), mL(0),
31 mHKLSet(false), LATTICEINDEX(9999), HEIGHTINDEX(9999) {
34 if (peakRadius.is_initialized() && peakRadius.get() !=
s_peakRadius) {
125 std::vector<double> out(xValues.size(), 0.);
129 double max = -DBL_MAX;
131 for (
size_t i = 0; i < out.size(); ++i) {
148 std::stringstream errss;
149 errss <<
"Profile function " <<
name() <<
"cannot have (HKL) reset.";
150 throw std::runtime_error(errss.str());
157 mH =
static_cast<int>(h);
158 mK =
static_cast<int>(k);
159 mL =
static_cast<int>(l);
163 std::stringstream errmsg;
164 errmsg <<
"H = K = L = 0 is not allowed";
165 throw std::invalid_argument(errmsg.str());
173 h =
static_cast<int>(
mH);
174 k =
static_cast<int>(
mK);
175 l =
static_cast<int>(
mL);
199 return *candname != paramname;
207std::complex<double>
E1(std::complex<double>
z) {
208 std::complex<double> exp_e1;
213 if (
fabs(az) < 1.0E-8) {
215 std::complex<double> r(1.0E300, 0.0);
217 }
else if (az <= 10.0 || (rz < 0.0 && az < 20.0)) {
221 std::complex<double> r(1.0, 0.0);
223 std::complex<double> cr = r;
225 for (
size_t k = 1; k <= 150; ++k) {
227 cr = -cr * dk *
z / ((dk + 1.0) * (dk + 1.0));
229 if (abs(cr) < abs(exp_e1) * 1.0E-15) {
235 const double el = 0.5772156649015328;
236 exp_e1 = -el - log(
z) + (
z * exp_e1);
239 std::complex<double> ct0(0.0, 0.0);
240 for (
int k = 120; k > 0; --k) {
241 std::complex<double> dk(
double(k), 0.0);
242 ct0 = dk / (10.0 + dk / (
z + ct0));
245 exp_e1 = 1.0 / (
z + ct0);
246 exp_e1 = exp_e1 * exp(-
z);
247 if (rz < 0.0 &&
fabs(imag(
z)) < 1.0E-10) {
248 std::complex<double> u(0.0, 1.0);
249 exp_e1 = exp_e1 - (M_PI * u);
double value
The value of the point.
const double IGNOREDCHANGE
virtual std::string name() const =0
Returns the function's name.
virtual void setPeakRadius(const int &r)
Set peak's radius.
virtual void setMillerIndex(int h, int k, int l)
Set Miller Indicies.
virtual double height() const
Get peak's intensity.
virtual void setHeight(const double h)
Set peak's height.
double m_centre
Centre of the peak.
virtual double getMaximumValue(const std::vector< double > &xValues, size_t &indexmax) const
Get maximum value on a given set of data points.
void setParameter(size_t i, const double &value, bool explicitlySet=true) override
Override setting a new value to the i-th parameter.
virtual void getMillerIndex(int &h, int &k, int &l)
Get Miller Index from this peak.
virtual void calculateParameters(bool explicitoutput) const =0
Calculate peak parameters (alpha, beta, sigma2..)
bool m_hasNewParameterValue
Flag if any parameter value changed.
virtual double fwhm() const
Get peakl's FWHM.
double m_fwhm
Peak's FWHM.
virtual void function(std::vector< double > &out, const std::vector< double > &xValues) const =0
IPowderDiffPeakFunction()
Constructor and Destructor.
static int s_peakRadius
Local function for GSL minimizer.
std::vector< std::string > m_sortedProfileParameterNames
Peak profile parameters names in ascending order.
virtual bool hasProfileParameter(std::string paramname)
Check whether a parameter is a profile parameter.
virtual double centre() const
Overwrite IFunction base class methods.
void setParameter(size_t, const double &value, bool explicitlySet=true) override
Set i-th parameter.
double getParameter(size_t i) const override
Get i-th parameter.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::complex< double > MANTID_API_DLL E1(std::complex< double > z)
Integral for Gamma.