Mantid
Loading...
Searching...
No Matches
IFunctionGeneral.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 +
8
9namespace Mantid::API {
10
11Kernel::Logger IFunctionGeneral::g_log("IFunctionGeneral");
12
13void IFunctionGeneral::function(const FunctionDomain &domain, FunctionValues &values) const {
14 auto actualValuesSize = values.size();
15 auto requiredValuesSize = getValuesSize(domain);
16 if (actualValuesSize > 0 && requiredValuesSize > 0 && actualValuesSize != requiredValuesSize) {
17 throw std::runtime_error("IFunctionGeneral: values object doesn't match domain.");
18 }
19 try {
20 auto &generalDomain = dynamic_cast<const FunctionDomainGeneral &>(domain);
21 functionGeneral(generalDomain, values);
22 } catch (const std::bad_cast &) {
23 throw std::invalid_argument("Provided domain is not of type FunctionDomainGeneral.");
24 }
25}
26
28 calNumericalDeriv(domain, jacobian);
29}
30
32 if (domain.size() == 0 || getNumberDomainColumns() == 0) {
34 }
35 return domain.size() * getNumberValuesPerArgument();
36}
37
38size_t IFunctionGeneral::getDefaultDomainSize() const { return 0; }
39
40} // namespace Mantid::API
Represent a domain of a very general type.
Base class that represents the domain of a function.
virtual size_t size() const =0
Return the number of points in the domain.
A class to store values calculated by a function.
size_t size() const
Return the number of values.
static Kernel::Logger g_log
virtual size_t getNumberDomainColumns() const =0
Get number of columns that the domain must have.
virtual size_t getDefaultDomainSize() const
Get the default size of a domain.
size_t getValuesSize(const FunctionDomain &domain) const override
Get number of values for a given domain.
virtual void functionGeneral(const FunctionDomainGeneral &domain, FunctionValues &values) const =0
Provide a concrete function in an implementation that operates on a FunctionDomainGeneral.
void functionDeriv(const FunctionDomain &domain, Jacobian &jacobian) override
Derivatives of function with respect to active parameters.
virtual size_t getNumberValuesPerArgument() const =0
Get number of values per argument in the domain.
void function(const FunctionDomain &domain, FunctionValues &values) const override
Evaluates the function for all arguments in the domain.
void calNumericalDeriv(const FunctionDomain &domain, Jacobian &jacobian)
Calculate numerical derivatives.
Definition: IFunction.cpp:1031
Represents the Jacobian in IFitFunction::functionDeriv.
Definition: Jacobian.h:22