Class Dune::XT::Functions::internal::MathExpressionEngine

class Dune::XT::Functions::internal::MathExpressionEngine

Parses and evaluates mathematical expression strings that depend on named variables.

This is a thin, deliberately non-templated wrapper around the third-party ExprTk parser. By operating on double only, the heavy ExprTk header stays confined to a single translation unit (engine.cc), hidden behind a pimpl. The templated MathExpressionBase / DynamicMathExpressionBase wrappers convert their field types to/from double and delegate the actual parsing and evaluation here.

Supported operators and functions mirror the previously bundled parser: + - * / ^, sin, cos, tan, exp, log (alias ln), sqrt, abs, asin, acos, atan and the constant pi (plus the additional functionality ExprTk provides).

Note

Implicit multiplication by juxtaposition is supported, e.g. “x[0]t” means “x[0]*t”, “x[0]2” means “x[0]2” and “sin(t)(x)” means “sin(t)(x)”. An explicit * is still recommended for readability.

Method Dune::XT::Functions::internal::MathExpressionEngine::operator=

MathExpressionEngine &Dune::XT::Functions::internal::MathExpressionEngine::operator=(const MathExpressionEngine&) = delete

No documentation provided.

Method Dune::XT::Functions::internal::MathExpressionEngine::variables

const std::vector<std::string> &Dune::XT::Functions::internal::MathExpressionEngine::variables() const

No documentation provided.

Method Dune::XT::Functions::internal::MathExpressionEngine::expressions

const std::vector<std::string> &Dune::XT::Functions::internal::MathExpressionEngine::expressions() const

No documentation provided.

Method Dune::XT::Functions::internal::MathExpressionEngine::evaluate

void Dune::XT::Functions::internal::MathExpressionEngine::evaluate(const double *values, std::size_t num_values, double *results, std::size_t num_results) const

Evaluate all expressions for the given variable values.

values holds one entry per variable (in the order given to the constructor) and results one entry per expression.

Note

Not thread-safe: callers must serialize access (the wrappers hold a mutex), matching the behavior of the previously bundled parser.

Constructor Dune::XT::Functions::internal::MathExpressionEngine::MathExpressionEngine

Dune::XT::Functions::internal::MathExpressionEngine::MathExpressionEngine(std::vector<std::string> variables, std::vector<std::string> expressions)

Parse expressions, each depending on the given named variables.

Variable names may contain a bracketed integer index (e.g. “x[0]”, “mu[1]”) or a trailing underscore (e.g. “t_”), neither of which ExprTk accepts as an identifier; they are transparently remapped to internal placeholder identifiers before compilation.

:throws Common::Exceptions::wrong_input_given: if an expression cannot be parsed.

Constructor Dune::XT::Functions::internal::MathExpressionEngine::MathExpressionEngine

Dune::XT::Functions::internal::MathExpressionEngine::MathExpressionEngine(const MathExpressionEngine&) = delete

No documentation provided.

Destructor Dune::XT::Functions::internal::MathExpressionEngine::~MathExpressionEngine

Dune::XT::Functions::internal::MathExpressionEngine::~MathExpressionEngine()

No documentation provided.

Field Dune::XT::Functions::internal::MathExpressionEngine::impl_

std::unique_ptr<Impl> Dune::XT::Functions::internal::MathExpressionEngine::impl_

No documentation provided.