Mantid
Loading...
Searching...
No Matches
IFunction1DAdapter.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 +
9
10#define PY_ARRAY_UNIQUE_SYMBOL API_ARRAY_API
11#define NO_IMPORT_ARRAY
12#include <numpy/arrayobject.h>
13
14//-----------------------------------------------------------------------------
15// IFunction1D definition
16//-----------------------------------------------------------------------------
18using namespace boost::python;
19
25 : API::ParamFunction(), API::IFunction1D(), IFunctionAdapter(self, "function1D", "functionDeriv1D") {}
26
33void IFunction1DAdapter::function1D(double *out, const double *xValues, const size_t nData) const {
34 evaluateFunction(out, xValues, nData);
35}
36
41boost::python::object IFunction1DAdapter::function1D(const boost::python::object &xvals) const {
42 return callMethodNoCheck<object, object>(getSelf(), "function1D", xvals);
43}
44
53void IFunction1DAdapter::functionDeriv1D(API::Jacobian *out, const double *xValues, const size_t nData) {
55 evaluateDerivative(out, xValues, nData);
56 } else {
57 Base::functionDeriv1D(out, xValues, nData);
58 }
59}
60} // namespace Mantid::PythonInterface
This is a specialization of IFunction for functions of one real argument.
Definition: IFunction1D.h:43
virtual void functionDeriv1D(Jacobian *jacobian, const double *xValues, const size_t nData)
Derivatives of function with respect to active parameters.
Definition: IFunction1D.cpp:82
Represents the Jacobian in IFitFunction::functionDeriv.
Definition: Jacobian.h:22
Implements the part of IFunction interface dealing with parameters.
Definition: ParamFunction.h:33
IFunction1DAdapter(PyObject *self)
A constructor that looks like a Python init method.
void functionDeriv1D(API::Jacobian *out, const double *xValues, const size_t nData) override
Derivatives of function with respect to active parameters (C++ override)
void function1D(double *out, const double *xValues, const size_t nData) const override
Translates between the C++ signature & the Python signature called by Fit.
Provides a layer to hook into the protected functions of IFunction.
void evaluateFunction(double *out, const double *xValues, const size_t nData) const
Evaluate the function by calling the overridden method.
void evaluateDerivative(API::Jacobian *out, const double *xValues, const size_t nData) const
Evaluate the derivative by calling the overridden method.