14#include <boost/tokenizer.hpp>
24 std::string varNames[] = {
"x",
"y",
"z",
"t"};
25 m_varNames.assign(varNames, varNames + m_vars.size());
26 for (
size_t i = 0; i < m_vars.size(); ++i) {
27 m_parser.DefineVar(m_varNames[i], &m_vars[i]);
65 for (
size_t i = 0; i <
m_vars.size(); ++i) {
82 for (
size_t i = 0; i <
n; ++i) {
89 }
catch (mu::Parser::exception_type &e) {
90 std::cerr <<
"Message: " << e.GetMsg() <<
"\n";
91 std::cerr <<
"Formula: " << e.GetExpr() <<
"\n";
92 std::cerr <<
"Token: " << e.GetToken() <<
"\n";
93 std::cerr <<
"Position: " << e.GetPos() <<
"\n";
94 std::cerr <<
"Errc: " << e.GetCode() <<
"\n";
111 throw std::runtime_error(
"UserFunctionMD variables are not defined");
140 for (
size_t i = 0; i <
m_vars.size(); ++i) {
143 for (
size_t i = 0; i <
nParams(); i++) {
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
#define PARALLEL_CRITICAL(name)
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
void function(const FunctionDomain &domain, FunctionValues &values) const override
std::vector< std::shared_ptr< const Mantid::Geometry::IMDDimension > > m_dimensions
dimensions used in this function in the expected order
std::map< std::string, size_t > m_dimensionIndexMap
maps dimension id to its index in m_dimensions
Attribute is a non-fitting parameter.
std::string asString() const
Returns string value if attribute is a string, throws exception otherwise.
This is an interface to an iterator of an IMDWorkspace.
virtual Mantid::Kernel::VMD getCenter() const =0
Returns the position of the center of the box pointed to.
virtual double * getParameterAddress(size_t i)
Get the address of the parameter. For use in UserFunction with mu::Parser.
std::string parameterName(size_t i) const override
Returns the name of parameter i.
void declareParameter(const std::string &name, double initValue=0, const std::string &description="") override
Declare a new parameter.
size_t nParams() const override
Total number of parameters.
static double * AddVariable(const char *varName, void *pufun)
Static callback function used by MuParser to initialize variables implicitly.
void setFormula()
Initializes the mu::Parser.
void initDimensions() override
Defining function's parameters here, ie after the workspace is set and the dimensions are known.
Attribute getAttribute(const std::string &attName) const override
Return Formula.
std::vector< std::string > m_varNames
void setAttribute(const std::string &attName, const Attribute &attr) override
Set Formula.
mu::Parser m_parser
Expression parser.
std::vector< double > m_vars
std::vector< std::string > getAttributeNames() const override
bool hasAttribute(const std::string &attName) const override
Has attribute "Formula".
double functionMD(const API::IMDIterator &r) const override
Calculate the function value at a point r in the MD workspace.
std::string to_string(const wide_integer< Bits, Signed > &n)