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#include "MantidAPI/Workspace.h"
11
13
14using namespace Mantid::Kernel;
15using namespace Mantid::API;
16
17// Register the algorithm into the AlgorithmFactory
18DECLARE_ALGORITHM(EvaluateFunction)
19
20//----------------------------------------------------------------------------------------------
21
22
23const std::string EvaluateFunction::name() const { return "EvaluateFunction"; }
24
26int EvaluateFunction::version() const { return 1; }
27
29const std::string EvaluateFunction::summary() const { return "Evaluate a function on a workspace."; }
30
31//----------------------------------------------------------------------------------------------
33void EvaluateFunction::initConcrete() {
34 declareProperty(std::make_unique<WorkspaceProperty<API::Workspace>>("OutputWorkspace", "", Direction::Output),
35 "An output workspace.");
36}
37
38//----------------------------------------------------------------------------------------------
40void EvaluateFunction::execConcrete() {
41
42 // Function may need some preparation.
43 m_function->setUpForFit();
44
47 m_domainCreator->createDomain(domain, values);
48
49 // Do something with the function which may depend on workspace.
50 m_domainCreator->initFunction(m_function);
51
52 // Apply any ties.
53 m_function->applyTies();
54
55 // Calculate function values.
56 m_function->function(*domain, *values);
57
58 // Gnegerate the output workspace
59 auto outputWS = m_domainCreator->createOutputWorkspace("", m_function, domain, values, "");
60
61 // Store the result.
62 setProperty("OutputWorkspace", outputWS);
63}
64
65} // namespace Mantid::CurveFitting::Algorithms
std::string name
Definition Run.cpp:60
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:547
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
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:55