Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
find.hpp File Reference

Discover named nodes of a given kind in a function tree (sympy's find). More...

#include <memory>
#include <vector>
#include "bertini2/function_tree/forward_declares.hpp"
Include dependency graph for find.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  bertini
namespace  bertini::node

Functions

template<typename T>
std::vector< std::shared_ptr< T > > bertini::node::Find (std::shared_ptr< const Node > const &n)
 All distinct nodes of kind T in the subtree rooted at n, sorted by name.
template<typename T>
std::vector< std::shared_ptr< T > > bertini::node::Find (std::vector< std::shared_ptr< const Node > > const &roots)
 The union of Find<T> across several roots (one shared traversal), sorted by name.

Detailed Description

Discover named nodes of a given kind in a function tree (sympy's find).

Find<T>(root) returns the distinct nodes of kind T appearing anywhere in the tree, de-duplicated by identity and sorted by name. It is the general form of the old GatherVariables: Find<Variable> are the solve-variables, Find<NamedExpression> the named subexpressions (a = x^2+y^2), Find<...> the core's named symbols. Descent uses only public child accessors, so every operator subtype is handled via its base, and it descends through Handle/NamedExpression into the wrapped expression.

The definitions live in find.cpp with explicit instantiations (one per kind we discover), to keep this traversal out of every translation unit.