22 _ptr_st =
static_cast<void *
>(pst);
27 static exprtk::rtl::io::println<real> println;
28 st.add_function(
"println", println);
30 for (
auto &[k,
v] : _vars)
31 st.add_variable(k,
v);
33 for (
auto &[k,
v] : _varVecs)
34 st.add_vector(k,
v.data(),
v.size());
38 _ptr_exp =
static_cast<void *
>(pexp);
40 exp.register_symbol_table(st);
44 _ptr_parser =
static_cast<void *
>(pparser);
46 auto compile_ok = parser.compile(expr, exp);
47 std::string error_info = parser.error() +
"\n";
48 for (
size_t i = 0; i < parser.error_count(); i++)
50 auto err = parser.get_error(i);
52 fmt::format(
"Error [{}], at [{}]\n", i,
err.token.position) +
53 fmt::format(
"\tType: {}\n", exprtk::parser_error::to_str(
err.mode)) +
54 fmt::format(
"\tMsg: {}\n",
err.diagnostic));
58 "exprtk compiling of === \n" +
60 "\n=== failed: " + error_info);
75 delete static_cast<parser_t *
>(_ptr_parser);
76 _ptr_parser =
nullptr;
#define DNDS_assert(expr)
Debug-only assertion (compiled out when DNDS_NDEBUG is defined). Prints the expression + file/line + ...
#define DNDS_check_throw_info(expr, info)
Same as DNDS_check_throw but attaches a user-supplied info message to the thrown std::runtime_error.
Precompiled-header include of the exprtk expression library. Used only by ExprtkWrapper....
Runtime mathematical expression compiler and evaluator wrapping exprtk.
real Evaluate()
Evaluate the compiled expression with the current variable values.
void Compile(const std::string &expr)
Compile expr. Throws (via DNDS_check_throw) on parse error.
bool Compiled() const
Whether Compile has been called and the expression parsed successfully.
void Clear()
Release the compiled expression and parser. Must be called before re-binding variables.
the host side operators are provided as implemented
exprtk::parser< real > parser_t
exprtk::symbol_table< real > symbol_table_t
exprtk::expression< real > expression_t
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
Eigen::Matrix< real, 5, 1 > v