32#include <exprtk/exprtk.hpp>
35 static std::mutex parser_mutex;
36 static exprtk::parser<double> parser;
38 std::string expression_text;
48 explicit Expression(
unsigned,
const std::string&);
50 [[nodiscard]]
virtual uword
input_size()
const;
53 bool compile(
const std::string&);
54 static string error();
57 virtual Mat<double>
evaluate(
const Col<double>&) = 0;
60 virtual Mat<double>
gradient(
const Col<double>&) = 0;
62 void print()
override;
69 Mat<double>
evaluate(
const Col<double>&)
override;
71 Mat<double>
gradient(
const Col<double>&)
override;
82 Mat<double>
evaluate(
const Col<double>&)
override;
84 Mat<double>
gradient(
const Col<double>&)
override {
throw std::runtime_error(
"gradient is not implemented for vector expression"); }
A Expression class represents a maths expression.
Definition: Expression.h:34
Mat< double > gradient(double)
Definition: Expression.cpp:56
exprtk::expression< double > expression
Definition: Expression.h:43
bool compile(const std::string &)
Definition: Expression.cpp:45
Expression(unsigned, const std::string &)
Definition: Expression.cpp:24
static string error()
Definition: Expression.cpp:52
virtual Mat< double > gradient(const Col< double > &)=0
Mat< double > evaluate(double)
Definition: Expression.cpp:54
void print() override
Definition: Expression.cpp:58
virtual uword output_size() const
Definition: Expression.cpp:43
virtual uword input_size() const
Definition: Expression.cpp:41
Col< double > x
Definition: Expression.h:41
exprtk::symbol_table< double > symbol_table
Definition: Expression.h:45
virtual Mat< double > evaluate(const Col< double > &)=0
Definition: Expression.h:65
Mat< double > gradient(const Col< double > &) override
Definition: Expression.cpp:69
Mat< double > evaluate(const Col< double > &) override
Definition: Expression.cpp:62
Definition: Expression.h:74
uword output_size() const override
Definition: Expression.cpp:87
Mat< double > evaluate(const Col< double > &) override
Definition: Expression.cpp:89
Mat< double > gradient(const Col< double > &) override
Definition: Expression.h:84
A base Tag class.
Definition: Tag.h:38