Mantid
Loading...
Searching...
No Matches
EndErfc.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7//----------------------------------------------------------------------
8// Includes
9//----------------------------------------------------------------------
12#include <cmath>
13#include <gsl/gsl_sf_erf.h>
14
16
17using namespace CurveFitting;
18
19using namespace Kernel;
20
21using namespace API;
22
23DECLARE_FUNCTION(EndErfc)
24
25void EndErfc::init() {
26 declareParameter("A", 2000.0, "Half value at minus infinity minus half value at plus infinity");
27 declareParameter("B", 50.0, "Mid x value");
28 declareParameter("C", 6.0, "Width parameter");
29 declareParameter("D", 0.0, "Minimum value - must not be negative");
30}
31
32void EndErfc::function1D(double *out, const double *xValues, const size_t nData) const {
33 const double gA = getParameter("A");
34 const double gB = getParameter("B");
35 const double gC = getParameter("C");
36 const double gD = getParameter("D");
37
38 for (size_t i = 0; i < nData; i++) {
39 double x = xValues[i];
40 out[i] = gA * gsl_sf_erfc((gB - x) / gC) + gD;
41 }
42
43 if (gA < 0) {
44 for (size_t i = 0; i < nData; i++) {
45 out[i] = -2 * gA;
46 }
47 }
48}
49
50void EndErfc::setActiveParameter(size_t i, double value) {
51 size_t j = i;
52
53 if (parameterName(j) == "D" && value < 0.0)
54 setParameter(j, 0.0, false); // Don't let D become negative
55 else
56 setParameter(j, value, false);
57}
58
59} // namespace Mantid::CurveFitting::Functions
double value
The value of the point.
Definition: FitMW.cpp:51
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
void setParameter(size_t, const double &value, bool explicitlySet=true) override
Set i-th parameter.
std::string parameterName(size_t i) const override
Returns the name of parameter i.
double getParameter(size_t i) const override
Get i-th parameter.
Provide Errore function erfc()for calibrating the end of a tube.
Definition: EndErfc.h:26
void setActiveParameter(size_t i, double value) override
overwrite IFunction base class methods
Definition: EndErfc.cpp:50
void function1D(double *out, const double *xValues, const size_t nData) const override
Function you want to fit to.
Definition: EndErfc.cpp:32