33 stack.emplace_back(root.
get());
34 while (!stack.empty()) {
35 auto node = stack.back();
38 for (
auto&
arg : node->args) {
40 if (
arg !=
nullptr && ++
arg->incoming_edges == 1) {
41 stack.push_back(
arg.get());
53 stack.emplace_back(root.
get());
54 while (!stack.empty()) {
55 auto node = stack.back();
58 list.emplace_back(node);
60 for (
auto&
arg : node->args) {
62 if (
arg !=
nullptr && --
arg->incoming_edges == 0) {
63 stack.push_back(
arg.get());
79 for (
auto& node : list | std::views::reverse) {
80 auto& lhs = node->args[0];
81 auto& rhs = node->args[1];
85 node->val = node->value(lhs->val, rhs->val);
87 node->val = node->value(lhs->val, 0.0);
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Returns a named argument to be used in a formatting function.
Definition base.h:2831
constexpr T * get() const noexcept
Returns the internal pointer.
Definition intrusive_shared_ptr.hpp:201
wpi::SmallVector< T > small_vector
Definition small_vector.hpp:10
Definition expression_graph.hpp:11
gch::small_vector< Expression * > topological_sort(const ExpressionPtr &root)
Generate a topological sort of an expression graph from parent to child.
Definition expression_graph.hpp:20
void update_values(const gch::small_vector< Expression * > &list)
Update the values of all nodes in this graph based on the values of their dependent nodes.
Definition expression_graph.hpp:77
@ CONSTANT
The expression is a constant.
virtual ExpressionType type() const =0
Returns the type of this expression (constant, linear, quadratic, or nonlinear).