28namespace func_sketch::expressions {
32 const Number parameter_as_number = parameter;
34 evaluate(expression, parameter_as_number, result_as_number);
36 [&result](
const auto& value) {
37 using ValueType = std::decay_t<
decltype(value)>;
38 if constexpr (std::is_same_v<ValueType, Complex>) {
39 result = std::real(value);
41 result =
static_cast<Real>(value);
49 std::visit([¶meter, &result](
50 const auto& expr) {
evaluate(expr, parameter, result); },
56 result = expression.
value;
82 std::vector<Number> argument_values;
83 argument_values.reserve(expression.
arguments.size());
84 for (
const auto& argument : expression.
arguments) {
86 evaluate(*argument, parameter, argument_value);
87 argument_values.push_back(argument_value);
89 expression.
function(argument_values, result);
static void evaluate(const Expression &expression, Number parameter, Number &result)
Evaluate an expression.
static void operator()(const Expression &expression, Real parameter, Real &result)
Evaluate an expression.
const VariantType & as_variant() const
Get the expression as variant.
Definitions of common types.
double Real
Type of real numbers in this project.
std::variant< Integer, Real, Complex > Number
Type of numbers.
Definition of ExpressionEvaluator class.
Struct of binary expressions.
Expression * right
Right-hand-side expression.
math::BinaryOperator operator_object
Operator.
Expression * left
Left-hand-side expression.
Struct of constant expressions.
Struct of function call expressions.
std::vector< Expression * > arguments
Arguments.
math::MathFunction function
Function.
Struct of parameter expressions.
Struct of unary expressions.
math::UnaryOperator operator_object
Operator.
Expression * target
Target expression.