Mantid
Loading...
Searching...
No Matches
Framework
API
src
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 +
7
#include "
MantidAPI/IFunctionGeneral.h
"
8
9
namespace
Mantid::API
{
10
11
void
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
25
void
IFunctionGeneral::functionDeriv
(
const
FunctionDomain
&domain,
Jacobian
&jacobian) {
26
calNumericalDeriv
(domain, jacobian);
27
}
28
29
size_t
IFunctionGeneral::getValuesSize
(
const
FunctionDomain
&domain)
const
{
30
if
(domain.
size
() == 0 ||
getNumberDomainColumns
() == 0) {
31
return
getDefaultDomainSize
() *
getNumberValuesPerArgument
();
32
}
33
return
domain.
size
() *
getNumberValuesPerArgument
();
34
}
35
36
size_t
IFunctionGeneral::getDefaultDomainSize
()
const
{
return
0; }
37
38
}
// namespace Mantid::API
IFunctionGeneral.h
Mantid::API::FunctionDomainGeneral
Represent a domain of a very general type.
Definition
FunctionDomainGeneral.h:21
Mantid::API::FunctionDomain
Base class that represents the domain of a function.
Definition
FunctionDomain.h:31
Mantid::API::FunctionDomain::size
virtual size_t size() const =0
Return the number of points in the domain.
Mantid::API::FunctionValues
A class to store values calculated by a function.
Definition
FunctionValues.h:25
Mantid::API::FunctionValues::size
size_t size() const
Return the number of values.
Definition
FunctionValues.h:32
Mantid::API::IFunctionGeneral::getNumberDomainColumns
virtual size_t getNumberDomainColumns() const =0
Get number of columns that the domain must have.
Mantid::API::IFunctionGeneral::getDefaultDomainSize
virtual size_t getDefaultDomainSize() const
Get the default size of a domain.
Definition
IFunctionGeneral.cpp:36
Mantid::API::IFunctionGeneral::getValuesSize
size_t getValuesSize(const FunctionDomain &domain) const override
Get number of values for a given domain.
Definition
IFunctionGeneral.cpp:29
Mantid::API::IFunctionGeneral::functionGeneral
virtual void functionGeneral(const FunctionDomainGeneral &domain, FunctionValues &values) const =0
Provide a concrete function in an implementation that operates on a FunctionDomainGeneral.
Mantid::API::IFunctionGeneral::functionDeriv
void functionDeriv(const FunctionDomain &domain, Jacobian &jacobian) override
Derivatives of function with respect to active parameters.
Definition
IFunctionGeneral.cpp:25
Mantid::API::IFunctionGeneral::getNumberValuesPerArgument
virtual size_t getNumberValuesPerArgument() const =0
Get number of values per argument in the domain.
Mantid::API::IFunctionGeneral::function
void function(const FunctionDomain &domain, FunctionValues &values) const override
Evaluates the function for all arguments in the domain.
Definition
IFunctionGeneral.cpp:11
Mantid::API::IFunction::calNumericalDeriv
void calNumericalDeriv(const FunctionDomain &domain, Jacobian &jacobian)
Calculate numerical derivatives.
Definition
IFunction.cpp:1113
Mantid::API::Jacobian
Represents the Jacobian in IFitFunction::functionDeriv.
Definition
Jacobian.h:22
Mantid::API
Definition
AbsorptionCorrection.h:20
Generated by
1.9.8