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
Kernel::Logger
IFunctionGeneral::g_log
(
"IFunctionGeneral"
);
12
13
void
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
27
void
IFunctionGeneral::functionDeriv
(
const
FunctionDomain
&domain,
Jacobian
&jacobian) {
28
calNumericalDeriv
(domain, jacobian);
29
}
30
31
size_t
IFunctionGeneral::getValuesSize
(
const
FunctionDomain
&domain)
const
{
32
if
(domain.
size
() == 0 ||
getNumberDomainColumns
() == 0) {
33
return
getDefaultDomainSize
() *
getNumberValuesPerArgument
();
34
}
35
return
domain.
size
() *
getNumberValuesPerArgument
();
36
}
37
38
size_t
IFunctionGeneral::getDefaultDomainSize
()
const
{
return
0; }
39
40
}
// 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::g_log
static Kernel::Logger g_log
Definition
IFunctionGeneral.h:53
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:38
Mantid::API::IFunctionGeneral::getValuesSize
size_t getValuesSize(const FunctionDomain &domain) const override
Get number of values for a given domain.
Definition
IFunctionGeneral.cpp:31
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:27
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:13
Mantid::API::IFunction::calNumericalDeriv
void calNumericalDeriv(const FunctionDomain &domain, Jacobian &jacobian)
Calculate numerical derivatives.
Definition
IFunction.cpp:1106
Mantid::API::Jacobian
Represents the Jacobian in IFitFunction::functionDeriv.
Definition
Jacobian.h:22
Mantid::API
Definition
AbsorptionCorrection.h:20
Generated by
1.9.8