![]() |
Vulpes
0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
|
Compiles and evaluates a scalar math expression at runtime. More...
#include <expression_parser.hpp>
Public Member Functions | |
| template<typename... Args> | |
| ExpressionParser (const char *expression, Args &&... args) | |
| Compile an expression given as a C string. | |
| template<typename... Args> | |
| ExpressionParser (const std::string &expression, Args &&... args) | |
| Compile an expression given as a std::string. | |
| double | evaluate (const double *data) const |
| Evaluate the compiled expression against a data buffer. | |
Private Member Functions | |
| template<typename... Args> | |
| void | init (const char *expression, Args &&... args) |
| Register variables and compile the expression. | |
Private Attributes | |
| mathpresso::Context | m_context |
| mathpresso::Expression | m_expr |
Compiles and evaluates a scalar math expression at runtime.
Wraps mathpresso to compile a textual expression referencing exactly N named double variables, then evaluate it repeatedly against raw data buffers without re-parsing.
| N | Number of variables the expression depends on. |
|
inlineexplicit |
Compile an expression given as a C string.
| Args | Pack of variable names (convertible to std::string_view), must contain exactly N names. |
| expression | The math expression to compile. |
| args | Names of the N variables referenced by expression, in the order they appear in the data buffer passed to evaluate(). |
| std::runtime_error | if compilation fails. |
|
inlineexplicit |
Compile an expression given as a std::string.
| Args | Pack of variable names (convertible to std::string_view), must contain exactly N names. |
| expression | The math expression to compile. |
| args | Names of the N variables referenced by expression, in the order they appear in the data buffer passed to evaluate(). |
| std::runtime_error | if compilation fails. |
|
inline |
Evaluate the compiled expression against a data buffer.
| data | Pointer to N contiguous doubles, one per variable, in the order given to the constructor. |
|
inlineprivate |
Register variables and compile the expression.
| Args | Pack of variable names, must contain exactly N names. |
| expression | The math expression to compile. |
| args | Names of the N variables referenced by expression. |
| std::runtime_error | if compilation fails. |
|
private |
|
private |