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
11void IFunctionGeneral::function(const FunctionDomain &domain, FunctionValues &values) const {
12 auto actualValuesSize = values.size();
13 auto requiredValuesSize = getValuesSize(domain);
14 if (actualValuesSize > 0 && requiredValuesSize > 0 && actualValuesSize != requiredValuesSize) {
15 throw std::runtime_error("IFunctionGeneral: values object doesn't match domain.");
16 }
17 try {
18 auto &generalDomain = dynamic_cast<const FunctionDomainGeneral &>(domain);
19 functionGeneral(generalDomain, values);
20 } catch (const std::bad_cast &) {
21 throw std::invalid_argument("Provided domain is not of type FunctionDomainGeneral.");
22 }
23}
24
26 calNumericalDeriv(domain, jacobian);
27}
28
30 if (domain.size() == 0 || getNumberDomainColumns() == 0) {
32 }
33 return domain.size() * getNumberValuesPerArgument();
34}
35
36size_t IFunctionGeneral::getDefaultDomainSize() const { return 0; }
37
38} // 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.
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.
Represents the Jacobian in IFitFunction::functionDeriv.
Definition Jacobian.h:22