Mantid
Loading...
Searching...
No Matches
EvaluateFunction.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 +
10
12
13using namespace Mantid::Kernel;
14using namespace Mantid::API;
15
16// Register the algorithm into the AlgorithmFactory
17DECLARE_ALGORITHM(EvaluateFunction)
18
19//----------------------------------------------------------------------------------------------
20
21
22const std::string EvaluateFunction::name() const { return "EvaluateFunction"; }
23
25int EvaluateFunction::version() const { return 1; }
26
28const std::string EvaluateFunction::summary() const { return "Evaluate a function on a workspace."; }
29
30//----------------------------------------------------------------------------------------------
32void EvaluateFunction::initConcrete() {
33 declareProperty(std::make_unique<WorkspaceProperty<API::Workspace>>("OutputWorkspace", "", Direction::Output),
34 "An output workspace.");
35}
36
37//----------------------------------------------------------------------------------------------
39void EvaluateFunction::execConcrete() {
40
41 // Function may need some preparation.
42 m_function->setUpForFit();
43
46 m_domainCreator->createDomain(domain, values);
47
48 // Do something with the function which may depend on workspace.
49 m_domainCreator->initFunction(m_function);
50
51 // Apply any ties.
52 m_function->applyTies();
53
54 // Calculate function values.
55 m_function->function(*domain, *values);
56
57 // Gnegerate the output workspace
58 auto outputWS = m_domainCreator->createOutputWorkspace("", m_function, domain, values, "");
59
60 // Store the result.
61 setProperty("OutputWorkspace", outputWS);
62}
63
64} // namespace Mantid::CurveFitting::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
A property class for workspaces.
Evaluate a function (1D or MD) on a domain of an input workspace and save the result in the output wo...
std::shared_ptr< API::IDomainCreator > m_domainCreator
Pointer to a domain creator.
std::shared_ptr< API::IFunction > m_function
Pointer to the fitting function.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
std::shared_ptr< FunctionValues > FunctionValues_sptr
typedef for a shared pointer
std::shared_ptr< FunctionDomain > FunctionDomain_sptr
typedef for a shared pointer
STL namespace.
@ Output
An output workspace.
Definition: Property.h:54