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

Namespaces

namespace  special_number

Classes

class  DecodingCursor
 A read position over one canonical-encoding text, with the small lexical helpers the grammar needs (literals, words, netstrings, numbers). More...
struct  DecodingContext
 The back-reference table of one decoding pass: the nodes in first-encounter order, so #<index> resolves to the node the encoder numbered index. More...
struct  EncodingContext
 Traversal state for one canonical-encoding pass: the back-reference table. More...
class  Node
 An interface for all nodes in a function tree, and for a function object as well. More...
class  SumOperator
 Represents summation and difference Operator. More...
class  NegateOperator
 The negation Operator. More...
class  MultOperator
 Multiplication and division Operator. More...
class  PowerOperator
 Operator for power functions with arbitrary expressions in the exponent and base. More...
class  IntegerPowerOperator
 This class represents the exponentiation Operator. More...
class  SqrtOperator
 Represents the square root Operator. More...
class  ExpOperator
 represents the exponential function More...
class  LogOperator
 represents the natural logarithm function More...
class  Operator
 Abstract Node type from which all Operators inherit. More...
class  UnaryOperator
 Interface for all unary Operator types. More...
class  NaryOperator
 Abstract interface for n-ary Operator types. More...
class  TrigOperator
 Abstract class for trigonometric Operator types. More...
class  SinOperator
 Provides the sine Operator. More...
class  ArcSinOperator
 Provides the inverse sine Operator. More...
class  CosOperator
 Provides the cosine Operator. More...
class  ArcCosOperator
 Provides the arc cosine Operator. More...
class  TanOperator
 Provides the tangent Operator. More...
class  ArcTanOperator
 Provides the inverse tangent Operator. More...
class  NamedExpression
 A user-named expression — the surviving, immutable entry point into a subtree. More...
class  Differential
 Provides the differential type for differentiation of expression trees. More...
class  Number
 Abstract Number type from which other Numbers derive. More...
class  Integer
 Signed real Integer storage in an expression tree. More...
class  Complex
 A complex-number literal node in an expression tree. More...
class  Rational
 The Rational number type for Bertini2 expression trees. More...
class  Symbol
 Abstract symbol class. More...
class  NameHolder
 Capability class for things which have a name. More...
class  NamedSymbol
 Symbols which have names are named symbols. More...
class  Variable
 Represents variable leaves in the function tree. More...

Typedefs

using ReinternMemo = std::map<Node const*, std::shared_ptr<Node>>
 Memo for one re-interning pass: loaded node -> its interned replacement.

Enumerations

enum class  MonomialOrder { Lex , RevLex , GrevLex }
 Pluggable monomial orders for canonicalization. More...
enum  PrintPrecedence : unsigned {
  PrecSum = 10 , PrecNegate = 15 , PrecMult = 20 , PrecPower = 30 ,
  PrecAtom = 100
}
 Operator precedence classes, used to decide parenthesization when printing. More...
enum class  PrintDialect { Classic = 0 , PythonReadable = 1 , PythonExact = 2 }
 Who a printed expression is for; selects the operator and constant spellings. More...

Functions

MonomialOrder CurrentMonomialOrder ()
 The monomial order currently used for canonicalization (session-global – it must be consistent session-wide, since it determines interned identity).
void SetMonomialOrder (MonomialOrder order)
 Set the session-wide monomial order (determines interned identity).
bool CanonicalizeByDefault ()
 Whether Sum/Mult construction canonicalizes operand order by default.
void SetCanonicalizeByDefault (bool on)
 Set whether Sum/Mult construction canonicalizes operand order by default.
bool PowerFoldByDefault ()
 Whether Mult construction flattens + power-folds (x*x -> x^2) by default.
void SetPowerFoldByDefault (bool on)
 Set whether Mult construction flattens + power-folds by default.
void CanonicalizeNaryOperands (std::vector< std::shared_ptr< Node > > &operands, std::vector< bool > &flags, bool multiplicands_first)
 Sort an n-ary operator's (operand, flag) pairs into canonical order, in place.
std::shared_ptr< Node > DecodeCanonical (DecodingCursor &cursor, DecodingContext &ctx)
 Decode one node (and everything under it) from the cursor's position.
std::shared_ptr< Node > DecodeCanonicalTree (std::string const &text)
 Decode a whole tree from its canonical encoding text (fresh context).
void EncodeCanonical (std::shared_ptr< Node > const &root, std::ostream &out, EncodingContext &ctx)
 Append the canonical encoding of the DAG rooted at root to out.
std::string CanonicalEncoding (std::shared_ptr< Node > const &root)
 The canonical encoding of a single tree as a string (fresh context).
template<typename T>
std::vector< std::shared_ptr< T > > 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 > > Find (std::vector< std::shared_ptr< const Node > > const &roots)
 The union of Find<T> across several roots (one shared traversal), sorted by name.
template<typename Archive>
void register_derived_node_types (Archive &ar)
 Register all concrete Node types with a Boost.Serialization archive.
VariableGroup GatherVariables (std::shared_ptr< const Node > const &n)
 Collect the distinct Variables appearing in a function-tree subtree.
VariableGroup GatherVariables (std::vector< std::shared_ptr< Node > > const &functions)
 Collect the distinct Variables appearing across a collection of expressions.
std::ostream & operator<< (std::ostream &out, const Node &N)
 a single layer of indirection, though which to call the overridden virtual print() method which must be defined for each non-abstract Node type.
std::ostream & operator<< (std::ostream &out, const std::shared_ptr< Node > &N)
 Stream insertion for a Node pointer: dispatches to the node's virtual print().
std::string PrintIn (Node const &N, PrintDialect dialect)
 Print a tree in one dialect (see print_dialect.hpp).
std::string PrintClassic (Node const &N)
 The Bertini 1 spelling of a tree: ^ for powers, (re+im*I) for complex constants, every constant with all its digits.
std::string PrintPython (Node const &N, bool exact)
 The Python spelling of a tree: ** for powers.
std::shared_ptr< Node > Intern (std::shared_ptr< Node > const &candidate)
 Hash-cons a freshly-built node: return an existing structurally-equal node if one is live, otherwise register and return this one.
std::shared_ptr< Node > operator- (const std::shared_ptr< Node > &rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > sqrt (const std::shared_ptr< Node > &N)
 Build a square-root expression-tree node.
std::shared_ptr< Node > exp (const std::shared_ptr< Node > &N)
 Build an exponential (e raised to the node) expression-tree node.
std::shared_ptr< Node > log (const std::shared_ptr< Node > &N)
 Build a natural-logarithm expression-tree node.
std::shared_ptr< Node > pow (const std::shared_ptr< Node > &N, const std::shared_ptr< Node > &p)
 Build a power expression-tree node.
std::shared_ptr< Node > pow (std::shared_ptr< Node > const &base, int power)
 Build a power expression-tree node.
std::shared_ptr< Node > pow (const std::shared_ptr< Node > &N, double p)=delete
 Build a power expression-tree node.
std::shared_ptr< Node > pow (const std::shared_ptr< Node > &N, complex_dbl p)=delete
 Build a power expression-tree node.
std::shared_ptr< Node > pow (const std::shared_ptr< Node > &N, real_mp p)
 Build a power expression-tree node.
std::shared_ptr< Node > pow (const std::shared_ptr< Node > &N, complex_mp p)
 Build a power expression-tree node.
std::shared_ptr< Node > pow (const std::shared_ptr< Node > &N, mpq_rational const &p)
 Build a power expression-tree node.
std::shared_ptr< Node > SimplifiedNegate (std::shared_ptr< Node > const &n)
 Negation that never builds junk: -0 stays 0.
std::shared_ptr< Node > SimplifiedSum (std::vector< std::pair< std::shared_ptr< Node >, bool > > const &terms)
 Build a sum from (term, add_or_sub) pairs, omitting literal zeros.
std::shared_ptr< Node > SimplifiedMult (std::vector< std::pair< std::shared_ptr< Node >, bool > > const &factors)
 Build a product from (factor, mult_or_div) pairs, simplified.
std::shared_ptr< Node > & operator+= (std::shared_ptr< Node > &lhs, const std::shared_ptr< Node > &rhs)
 Build a sum expression-tree node from its operands.
std::shared_ptr< Node > operator+ (std::shared_ptr< Node > lhs, const std::shared_ptr< Node > &rhs)
 Build a sum expression-tree node from its operands.
std::shared_ptr< Node > operator+ (std::shared_ptr< Node > lhs, real_mp const &rhs)
 Build a sum expression-tree node from its operands.
std::shared_ptr< Node > operator+ (std::shared_ptr< Node > lhs, complex_mp const &rhs)
 Build a sum expression-tree node from its operands.
std::shared_ptr< Node > operator+ (real_mp const &lhs, std::shared_ptr< Node > rhs)
 Build a sum expression-tree node from its operands.
std::shared_ptr< Node > operator+ (complex_mp const &lhs, std::shared_ptr< Node > rhs)
 Build a sum expression-tree node from its operands.
std::shared_ptr< Node > operator+ (std::shared_ptr< Node > lhs, int rhs)
 Build a sum expression-tree node from its operands.
std::shared_ptr< Node > operator+ (int lhs, std::shared_ptr< Node > rhs)
 Build a sum expression-tree node from its operands.
std::shared_ptr< Node > operator+ (std::shared_ptr< Node > lhs, mpz_int const &rhs)
 Build a sum expression-tree node from its operands.
std::shared_ptr< Node > operator+ (mpz_int const &lhs, std::shared_ptr< Node > rhs)
 Build a sum expression-tree node from its operands.
std::shared_ptr< Node > operator+ (std::shared_ptr< Node > lhs, mpq_rational const &rhs)
 Build a sum expression-tree node from its operands.
std::shared_ptr< Node > operator+ (mpq_rational const &lhs, std::shared_ptr< Node > rhs)
 Build a sum expression-tree node from its operands.
std::shared_ptr< Node > & operator-= (std::shared_ptr< Node > &lhs, const std::shared_ptr< Node > &rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > operator- (std::shared_ptr< Node > lhs, const std::shared_ptr< Node > &rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > operator- (std::shared_ptr< Node > lhs, real_mp const &rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > operator- (real_mp const &lhs, std::shared_ptr< Node > rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > operator- (std::shared_ptr< Node > lhs, complex_mp const &rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > operator- (complex_mp const &lhs, std::shared_ptr< Node > rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > operator- (std::shared_ptr< Node > lhs, int rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > operator- (int lhs, std::shared_ptr< Node > rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > operator- (std::shared_ptr< Node > lhs, mpz_int const &rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > operator- (mpz_int const &lhs, std::shared_ptr< Node > rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > operator- (std::shared_ptr< Node > lhs, mpq_rational const &rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > operator- (mpq_rational const &lhs, std::shared_ptr< Node > rhs)
 Build a difference expression-tree node from its operands.
std::shared_ptr< Node > operator*= (std::shared_ptr< MultOperator > &lhs, const std::shared_ptr< Node > &rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > operator* (std::shared_ptr< Node > lhs, real_mp const &rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > operator* (std::shared_ptr< Node > lhs, complex_mp const &rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > operator* (real_mp const &lhs, std::shared_ptr< Node > rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > operator* (complex_mp const &lhs, std::shared_ptr< Node > rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > operator* (std::shared_ptr< Node > lhs, int rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > operator* (int lhs, std::shared_ptr< Node > rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > operator* (std::shared_ptr< Node > lhs, mpz_int const &rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > operator* (mpz_int const &lhs, std::shared_ptr< Node > rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > operator* (std::shared_ptr< Node > lhs, mpq_rational const &rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > operator* (mpq_rational const &lhs, std::shared_ptr< Node > rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > & operator*= (std::shared_ptr< Node > &lhs, const std::shared_ptr< Node > &rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > operator* (std::shared_ptr< Node > lhs, const std::shared_ptr< Node > &rhs)
 Build a product expression-tree node from its operands.
std::shared_ptr< Node > & operator/= (std::shared_ptr< Node > &lhs, const std::shared_ptr< Node > &rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > operator/= (std::shared_ptr< MultOperator > &lhs, const std::shared_ptr< Node > &rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > operator/ (std::shared_ptr< Node > lhs, const std::shared_ptr< Node > &rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > operator/ (std::shared_ptr< Node > lhs, real_mp rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > operator/ (std::shared_ptr< Node > lhs, complex_mp rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > operator/ (real_mp lhs, std::shared_ptr< Node > rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > operator/ (complex_mp lhs, std::shared_ptr< Node > rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > operator/ (std::shared_ptr< Node > lhs, int rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > operator/ (int lhs, std::shared_ptr< Node > rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > operator/ (std::shared_ptr< Node > lhs, mpz_int const &rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > operator/ (mpz_int const &lhs, std::shared_ptr< Node > rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > operator/ (std::shared_ptr< Node > lhs, mpq_rational const &rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > operator/ (mpq_rational const &lhs, std::shared_ptr< Node > rhs)
 Build a quotient expression-tree node from its operands.
std::shared_ptr< Node > sin (const std::shared_ptr< Node > &N)
 Build a sine expression-tree node.
std::shared_ptr< Node > asin (const std::shared_ptr< Node > &N)
 Build a arcsine expression-tree node.
std::shared_ptr< Node > cos (const std::shared_ptr< Node > &N)
 Build a cosine expression-tree node.
std::shared_ptr< Node > acos (const std::shared_ptr< Node > &N)
 Build a arccosine expression-tree node.
std::shared_ptr< Node > tan (const std::shared_ptr< Node > &N)
 Build a tangent expression-tree node.
std::shared_ptr< Node > atan (const std::shared_ptr< Node > &N)
 Build a arctangent expression-tree node.
int PrintDialectSlot ()
 The stream-state slot the dialect is kept in (allocated once per process).
PrintDialect DialectOf (std::ios_base &stream)
 The dialect a stream prints in; Classic unless SetDialect was called on it.
void SetDialect (std::ios_base &stream, PrintDialect dialect)
 Choose the dialect everything subsequently printed to stream is written in.
char const * PowerSymbol (PrintDialect dialect)
 The power operator in a dialect: ^ for Bertini 1, ** for Python.
std::shared_ptr< Node > Reintern (std::shared_ptr< Node > const &root, ReinternMemo &memo)
 Rebuild the DAG rooted at root through the interning factories (memoized, post-order), returning the canonical interned equivalent.
std::shared_ptr< Node > Reintern (std::shared_ptr< Node > const &root)
 Convenience overload with a private memo (single-root use).
std::shared_ptr< NamedExpression > Named (std::shared_ptr< Node > const &expr, std::string const &name)
 Give an expression a name: Named(x*x + y*y, "a").
std::shared_ptr< Node > Pi ()
 Construct a shared pointer to $\pi$.
std::shared_ptr< Node > E ()
 Construct a shared pointer to $e$.
std::shared_ptr< Node > I ()
 Construct a shared pointer to $i$.
std::shared_ptr< Node > Two ()
 Construct a shared pointer to $2$.
std::shared_ptr< Node > One ()
 Construct a shared pointer to $1$.
std::shared_ptr< Node > Zero ()
 Construct a shared pointer to $0$.

Typedef Documentation

◆ ReinternMemo

using bertini::node::ReinternMemo = std::map<Node const*, std::shared_ptr<Node>>

Memo for one re-interning pass: loaded node -> its interned replacement.

Share one memo across all roots of a loaded object (e.g. a whole System), so cross-root sharing in the archive is preserved in the rebuilt DAG.

Enumeration Type Documentation

◆ MonomialOrder

enum class bertini::node::MonomialOrder
strong

Pluggable monomial orders for canonicalization.

The default is deferred; GrevLex (the usual computational-algebra default, and graded => degree-descending, matching how polynomials are conventionally written) is the placeholder.

Enumerator
Lex 
RevLex 
GrevLex 

◆ PrintDialect

enum class bertini::node::PrintDialect
strong

Who a printed expression is for; selects the operator and constant spellings.

Enumerator
Classic 

Bertini 1 input: ^, (re+im*I), all digits.

PythonReadable 

Python str: **, the same constant shapes, readable first.

PythonExact 

Python repr: **, exact constant spellings that eval rebuilds at full precision.

◆ PrintPrecedence

Operator precedence classes, used to decide parenthesization when printing.

Higher binds tighter. A child is wrapped in parentheses only when its precedence is too low for the position it is printed in; leaves and self-delimiting nodes (function calls like sin(...), complex pairs) are atoms and never wrapped. Negative literal constants report PrecNegate so they parenthesize exactly where a Negate node would.

Enumerator
PrecSum 
PrecNegate 
PrecMult 
PrecPower 
PrecAtom 

Function Documentation

◆ acos()

std::shared_ptr< Node > bertini::node::acos ( const std::shared_ptr< Node > & N)
inline

Build a arccosine expression-tree node.

◆ asin()

std::shared_ptr< Node > bertini::node::asin ( const std::shared_ptr< Node > & N)
inline

Build a arcsine expression-tree node.

◆ atan()

std::shared_ptr< Node > bertini::node::atan ( const std::shared_ptr< Node > & N)
inline

Build a arctangent expression-tree node.

◆ CanonicalEncoding()

std::string bertini::node::CanonicalEncoding ( std::shared_ptr< Node > const & root)

The canonical encoding of a single tree as a string (fresh context).

Parameters
rootThe root of the (interned) expression DAG to encode.
Returns
The canonical encoding text.

◆ CanonicalizeByDefault()

bool bertini::node::CanonicalizeByDefault ( )

Whether Sum/Mult construction canonicalizes operand order by default.

(Per-expression opt-out is a future refinement; for now this is the session switch.)

◆ CanonicalizeNaryOperands()

void bertini::node::CanonicalizeNaryOperands ( std::vector< std::shared_ptr< Node > > & operands,
std::vector< bool > & flags,
bool multiplicands_first )

Sort an n-ary operator's (operand, flag) pairs into canonical order, in place.

Parameters
operandsthe operator's operands (mutated into canonical order)
flagsthe parallel signs (Sum) or multiply/divide flags (Mult), reordered in tandem
multiplicands_firstfor a Mult, keep flag==true (multiplicands) ahead of flag==false (divisors), so a divisor never ends up first (the eval path expects a leading multiplicand). Pass false for a Sum (the +/- sign does not affect term order).

No-op when canonicalization is disabled or there are fewer than two operands. Called from the Sum/Mult constructors, so the node is canonical before Make() interns it.

◆ cos()

std::shared_ptr< Node > bertini::node::cos ( const std::shared_ptr< Node > & N)
inline

Build a cosine expression-tree node.

◆ CurrentMonomialOrder()

MonomialOrder bertini::node::CurrentMonomialOrder ( )

The monomial order currently used for canonicalization (session-global – it must be consistent session-wide, since it determines interned identity).

◆ DecodeCanonical()

std::shared_ptr< Node > bertini::node::DecodeCanonical ( DecodingCursor & cursor,
DecodingContext & ctx )

Decode one node (and everything under it) from the cursor's position.

Parameters
cursorThe read position; on return it sits just past the node's closing parenthesis (or past a back-reference).
ctxThe back-reference table shared across the encoding unit.
Returns
The rebuilt, interned node.

Throws std::runtime_error on any byte that does not fit the grammar, on an unknown node kind, and on a back-reference to an index not yet encountered.

◆ DecodeCanonicalTree()

std::shared_ptr< Node > bertini::node::DecodeCanonicalTree ( std::string const & text)

Decode a whole tree from its canonical encoding text (fresh context).

The entire text must be one node: trailing bytes are an error.

Parameters
textThe canonical encoding, as CanonicalEncoding(root) produced it.
Returns
The rebuilt, interned node.

◆ DialectOf()

PrintDialect bertini::node::DialectOf ( std::ios_base & stream)
inline

The dialect a stream prints in; Classic unless SetDialect was called on it.

◆ E()

std::shared_ptr< Node > bertini::node::E ( )

Construct a shared pointer to $e$.

◆ EncodeCanonical()

void bertini::node::EncodeCanonical ( std::shared_ptr< Node > const & root,
std::ostream & out,
EncodingContext & ctx )

Append the canonical encoding of the DAG rooted at root to out.

Parameters
rootThe root of the (interned) expression DAG to encode.
outThe stream the encoding is appended to.
ctxThe back-reference table; share one context across all roots of an encoding unit, so cross-root sharing encodes deterministically.

Throws on a node kind unknown to the encoder (fail loud: an unencodable node must never silently produce a digest).

◆ exp()

std::shared_ptr< Node > bertini::node::exp ( const std::shared_ptr< Node > & N)
inline

Build an exponential (e raised to the node) expression-tree node.

◆ Find() [1/2]

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.

◆ Find() [2/2]

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.

◆ GatherVariables() [1/2]

VariableGroup bertini::node::GatherVariables ( std::shared_ptr< const Node > const & n)

Collect the distinct Variables appearing in a function-tree subtree.

Traverses the tree non-intrusively, via the public child accessors of the operator and root node types. The returned group is de-duplicated (by node identity) and ordered alphabetically by Variable name.

Parameters
nThe root of the subtree to scan. May be null, in which case an empty group is returned.
Returns
A VariableGroup of the distinct variables found, sorted by name.

◆ GatherVariables() [2/2]

VariableGroup bertini::node::GatherVariables ( std::vector< std::shared_ptr< Node > > const & functions)

Collect the distinct Variables appearing across a collection of expressions.

The union of the variables of each expression, de-duplicated (by node identity) and ordered alphabetically by Variable name. This is what the function-list System constructor uses to auto-build a single variable group.

Parameters
functionsThe expressions to scan.
Returns
A VariableGroup of the distinct variables found, sorted by name.

◆ I()

std::shared_ptr< Node > bertini::node::I ( )

Construct a shared pointer to $i$.

◆ Intern()

std::shared_ptr< Node > bertini::node::Intern ( std::shared_ptr< Node > const & candidate)

Hash-cons a freshly-built node: return an existing structurally-equal node if one is live, otherwise register and return this one.

The intern table is a process-global, weak (self-cleaning) map keyed by Node::Hash() and disambiguated by Node::IsSame(). Every Make() routes its just-constructed node through here, so structurally-equal subtrees collapse to a single shared object (hash-consing). On a hit the just-built candidate is discarded. Nodes whose IsSame() is identity (e.g. Variable, Function, Pi, E) never match, so they pass through unchanged – no special-casing.

Thread note: guarded by a mutex, contended only during single-threaded authoring. Deserialization constructs nodes WITHOUT going through Make/Intern; whatever holds the loaded nodes re-interns them as the last step of its load (System and Slice do, ADR-0068), so nothing a caller receives is outside this table.

◆ log()

std::shared_ptr< Node > bertini::node::log ( const std::shared_ptr< Node > & N)
inline

Build a natural-logarithm expression-tree node.

◆ Named()

std::shared_ptr< NamedExpression > bertini::node::Named ( std::shared_ptr< Node > const & expr,
std::string const & name )
inline

Give an expression a name: Named(x*x + y*y, "a").

The result prints as a and evaluates to the expression; it is hash-consed by (expression, name).

◆ One()

std::shared_ptr< Node > bertini::node::One ( )

Construct a shared pointer to $1$.

◆ operator*() [1/11]

std::shared_ptr< Node > bertini::node::operator* ( complex_mp const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a product expression-tree node from its operands.

◆ operator*() [2/11]

std::shared_ptr< Node > bertini::node::operator* ( int lhs,
std::shared_ptr< Node > rhs )
inline

Build a product expression-tree node from its operands.

◆ operator*() [3/11]

std::shared_ptr< Node > bertini::node::operator* ( mpq_rational const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a product expression-tree node from its operands.

◆ operator*() [4/11]

std::shared_ptr< Node > bertini::node::operator* ( mpz_int const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a product expression-tree node from its operands.

◆ operator*() [5/11]

std::shared_ptr< Node > bertini::node::operator* ( real_mp const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a product expression-tree node from its operands.

◆ operator*() [6/11]

std::shared_ptr< Node > bertini::node::operator* ( std::shared_ptr< Node > lhs,
complex_mp const & rhs )
inline

Build a product expression-tree node from its operands.

◆ operator*() [7/11]

std::shared_ptr< Node > bertini::node::operator* ( std::shared_ptr< Node > lhs,
const std::shared_ptr< Node > & rhs )
inline

Build a product expression-tree node from its operands.

◆ operator*() [8/11]

std::shared_ptr< Node > bertini::node::operator* ( std::shared_ptr< Node > lhs,
int rhs )
inline

Build a product expression-tree node from its operands.

◆ operator*() [9/11]

std::shared_ptr< Node > bertini::node::operator* ( std::shared_ptr< Node > lhs,
mpq_rational const & rhs )
inline

Build a product expression-tree node from its operands.

◆ operator*() [10/11]

std::shared_ptr< Node > bertini::node::operator* ( std::shared_ptr< Node > lhs,
mpz_int const & rhs )
inline

Build a product expression-tree node from its operands.

◆ operator*() [11/11]

std::shared_ptr< Node > bertini::node::operator* ( std::shared_ptr< Node > lhs,
real_mp const & rhs )
inline

Build a product expression-tree node from its operands.

◆ operator*=() [1/2]

std::shared_ptr< Node > bertini::node::operator*= ( std::shared_ptr< MultOperator > & lhs,
const std::shared_ptr< Node > & rhs )
inline

Build a product expression-tree node from its operands.

◆ operator*=() [2/2]

std::shared_ptr< Node > & bertini::node::operator*= ( std::shared_ptr< Node > & lhs,
const std::shared_ptr< Node > & rhs )
inline

Build a product expression-tree node from its operands.

Like-factor power-folding (x*x -> x^2, x^a*x^b -> x^(a+b)) and nested-product flattening live centrally in CanonicalizeNaryOperands (called by the MultOperator constructor), so every product-building route – not just this adjacent binary one – gets normalized.

◆ operator+() [1/11]

std::shared_ptr< Node > bertini::node::operator+ ( complex_mp const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a sum expression-tree node from its operands.

◆ operator+() [2/11]

std::shared_ptr< Node > bertini::node::operator+ ( int lhs,
std::shared_ptr< Node > rhs )
inline

Build a sum expression-tree node from its operands.

◆ operator+() [3/11]

std::shared_ptr< Node > bertini::node::operator+ ( mpq_rational const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a sum expression-tree node from its operands.

◆ operator+() [4/11]

std::shared_ptr< Node > bertini::node::operator+ ( mpz_int const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a sum expression-tree node from its operands.

◆ operator+() [5/11]

std::shared_ptr< Node > bertini::node::operator+ ( real_mp const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a sum expression-tree node from its operands.

◆ operator+() [6/11]

std::shared_ptr< Node > bertini::node::operator+ ( std::shared_ptr< Node > lhs,
complex_mp const & rhs )
inline

Build a sum expression-tree node from its operands.

◆ operator+() [7/11]

std::shared_ptr< Node > bertini::node::operator+ ( std::shared_ptr< Node > lhs,
const std::shared_ptr< Node > & rhs )
inline

Build a sum expression-tree node from its operands.

◆ operator+() [8/11]

std::shared_ptr< Node > bertini::node::operator+ ( std::shared_ptr< Node > lhs,
int rhs )
inline

Build a sum expression-tree node from its operands.

◆ operator+() [9/11]

std::shared_ptr< Node > bertini::node::operator+ ( std::shared_ptr< Node > lhs,
mpq_rational const & rhs )
inline

Build a sum expression-tree node from its operands.

◆ operator+() [10/11]

std::shared_ptr< Node > bertini::node::operator+ ( std::shared_ptr< Node > lhs,
mpz_int const & rhs )
inline

Build a sum expression-tree node from its operands.

◆ operator+() [11/11]

std::shared_ptr< Node > bertini::node::operator+ ( std::shared_ptr< Node > lhs,
real_mp const & rhs )
inline

Build a sum expression-tree node from its operands.

◆ operator+=()

std::shared_ptr< Node > & bertini::node::operator+= ( std::shared_ptr< Node > & lhs,
const std::shared_ptr< Node > & rhs )
inline

Build a sum expression-tree node from its operands.

◆ operator-() [1/12]

std::shared_ptr< Node > bertini::node::operator- ( complex_mp const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a difference expression-tree node from its operands.

◆ operator-() [2/12]

std::shared_ptr< Node > bertini::node::operator- ( const std::shared_ptr< Node > & rhs)
inline

Build a difference expression-tree node from its operands.

◆ operator-() [3/12]

std::shared_ptr< Node > bertini::node::operator- ( int lhs,
std::shared_ptr< Node > rhs )
inline

Build a difference expression-tree node from its operands.

◆ operator-() [4/12]

std::shared_ptr< Node > bertini::node::operator- ( mpq_rational const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a difference expression-tree node from its operands.

◆ operator-() [5/12]

std::shared_ptr< Node > bertini::node::operator- ( mpz_int const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a difference expression-tree node from its operands.

◆ operator-() [6/12]

std::shared_ptr< Node > bertini::node::operator- ( real_mp const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a difference expression-tree node from its operands.

◆ operator-() [7/12]

std::shared_ptr< Node > bertini::node::operator- ( std::shared_ptr< Node > lhs,
complex_mp const & rhs )
inline

Build a difference expression-tree node from its operands.

◆ operator-() [8/12]

std::shared_ptr< Node > bertini::node::operator- ( std::shared_ptr< Node > lhs,
const std::shared_ptr< Node > & rhs )
inline

Build a difference expression-tree node from its operands.

◆ operator-() [9/12]

std::shared_ptr< Node > bertini::node::operator- ( std::shared_ptr< Node > lhs,
int rhs )
inline

Build a difference expression-tree node from its operands.

◆ operator-() [10/12]

std::shared_ptr< Node > bertini::node::operator- ( std::shared_ptr< Node > lhs,
mpq_rational const & rhs )
inline

Build a difference expression-tree node from its operands.

◆ operator-() [11/12]

std::shared_ptr< Node > bertini::node::operator- ( std::shared_ptr< Node > lhs,
mpz_int const & rhs )
inline

Build a difference expression-tree node from its operands.

◆ operator-() [12/12]

std::shared_ptr< Node > bertini::node::operator- ( std::shared_ptr< Node > lhs,
real_mp const & rhs )
inline

Build a difference expression-tree node from its operands.

◆ operator-=()

std::shared_ptr< Node > & bertini::node::operator-= ( std::shared_ptr< Node > & lhs,
const std::shared_ptr< Node > & rhs )
inline

Build a difference expression-tree node from its operands.

◆ operator/() [1/11]

std::shared_ptr< Node > bertini::node::operator/ ( complex_mp lhs,
std::shared_ptr< Node > rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator/() [2/11]

std::shared_ptr< Node > bertini::node::operator/ ( int lhs,
std::shared_ptr< Node > rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator/() [3/11]

std::shared_ptr< Node > bertini::node::operator/ ( mpq_rational const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator/() [4/11]

std::shared_ptr< Node > bertini::node::operator/ ( mpz_int const & lhs,
std::shared_ptr< Node > rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator/() [5/11]

std::shared_ptr< Node > bertini::node::operator/ ( real_mp lhs,
std::shared_ptr< Node > rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator/() [6/11]

std::shared_ptr< Node > bertini::node::operator/ ( std::shared_ptr< Node > lhs,
complex_mp rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator/() [7/11]

std::shared_ptr< Node > bertini::node::operator/ ( std::shared_ptr< Node > lhs,
const std::shared_ptr< Node > & rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator/() [8/11]

std::shared_ptr< Node > bertini::node::operator/ ( std::shared_ptr< Node > lhs,
int rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator/() [9/11]

std::shared_ptr< Node > bertini::node::operator/ ( std::shared_ptr< Node > lhs,
mpq_rational const & rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator/() [10/11]

std::shared_ptr< Node > bertini::node::operator/ ( std::shared_ptr< Node > lhs,
mpz_int const & rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator/() [11/11]

std::shared_ptr< Node > bertini::node::operator/ ( std::shared_ptr< Node > lhs,
real_mp rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator/=() [1/2]

std::shared_ptr< Node > bertini::node::operator/= ( std::shared_ptr< MultOperator > & lhs,
const std::shared_ptr< Node > & rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator/=() [2/2]

std::shared_ptr< Node > & bertini::node::operator/= ( std::shared_ptr< Node > & lhs,
const std::shared_ptr< Node > & rhs )
inline

Build a quotient expression-tree node from its operands.

◆ operator<<() [1/2]

std::ostream & bertini::node::operator<< ( std::ostream & out,
const Node & N )
inline

a single layer of indirection, though which to call the overridden virtual print() method which must be defined for each non-abstract Node type.

◆ operator<<() [2/2]

std::ostream & bertini::node::operator<< ( std::ostream & out,
const std::shared_ptr< Node > & N )
inline

Stream insertion for a Node pointer: dispatches to the node's virtual print().

◆ Pi()

std::shared_ptr< Node > bertini::node::Pi ( )

Construct a shared pointer to $\pi$.

◆ pow() [1/7]

std::shared_ptr< Node > bertini::node::pow ( const std::shared_ptr< Node > & N,
complex_dbl p )
delete

Build a power expression-tree node.

◆ pow() [2/7]

std::shared_ptr< Node > bertini::node::pow ( const std::shared_ptr< Node > & N,
complex_mp p )
inline

Build a power expression-tree node.

◆ pow() [3/7]

std::shared_ptr< Node > bertini::node::pow ( const std::shared_ptr< Node > & N,
const std::shared_ptr< Node > & p )
inline

Build a power expression-tree node.

◆ pow() [4/7]

std::shared_ptr< Node > bertini::node::pow ( const std::shared_ptr< Node > & N,
double p )
delete

Build a power expression-tree node.

◆ pow() [5/7]

std::shared_ptr< Node > bertini::node::pow ( const std::shared_ptr< Node > & N,
mpq_rational const & p )
inline

Build a power expression-tree node.

◆ pow() [6/7]

std::shared_ptr< Node > bertini::node::pow ( const std::shared_ptr< Node > & N,
real_mp p )
inline

Build a power expression-tree node.

◆ pow() [7/7]

std::shared_ptr< Node > bertini::node::pow ( std::shared_ptr< Node > const & base,
int power )
inline

Build a power expression-tree node.

◆ PowerFoldByDefault()

bool bertini::node::PowerFoldByDefault ( )

Whether Mult construction flattens + power-folds (x*x -> x^2) by default.

Session-global A/B switch (like the monomial order, it determines interned identity, so it must be consistent session-wide). ON by default; turning it off recovers the pre-fold canonical form (sort-only) – used to measure the fold's impact and to demonstrate before/after tapes.

◆ PowerSymbol()

char const * bertini::node::PowerSymbol ( PrintDialect dialect)
inline

The power operator in a dialect: ^ for Bertini 1, ** for Python.

◆ PrintClassic()

std::string bertini::node::PrintClassic ( Node const & N)
inline

The Bertini 1 spelling of a tree: ^ for powers, (re+im*I) for complex constants, every constant with all its digits.

What the classic parser reads back.

◆ PrintDialectSlot()

int bertini::node::PrintDialectSlot ( )
inline

The stream-state slot the dialect is kept in (allocated once per process).

◆ PrintIn()

std::string bertini::node::PrintIn ( Node const & N,
PrintDialect dialect )
inline

Print a tree in one dialect (see print_dialect.hpp).

Parameters
NThe tree to print.
dialectWho the text is for.
Returns
The printed expression.

◆ PrintPython()

std::string bertini::node::PrintPython ( Node const & N,
bool exact )
inline

The Python spelling of a tree: ** for powers.

Parameters
NThe tree to print.
exactFalse for str (readable; the same constant shapes as Classic), true for repr (constant spellings eval rebuilds at full precision in the bertini namespace).
Returns
The printed expression.

◆ register_derived_node_types()

template<typename Archive>
void bertini::node::register_derived_node_types ( Archive & ar)

Register all concrete Node types with a Boost.Serialization archive.

◆ Reintern() [1/2]

std::shared_ptr< Node > bertini::node::Reintern ( std::shared_ptr< Node > const & root)

Convenience overload with a private memo (single-root use).

Parameters
rootThe root to re-intern.
Returns
The interned equivalent.

◆ Reintern() [2/2]

std::shared_ptr< Node > bertini::node::Reintern ( std::shared_ptr< Node > const & root,
ReinternMemo & memo )

Rebuild the DAG rooted at root through the interning factories (memoized, post-order), returning the canonical interned equivalent.

Parameters
rootThe (typically just-deserialized) root to re-intern.
memoThe pass's memo; share it across the roots of one loaded object.
Returns
The interned equivalent (a live pre-existing node when one matches).

Throws on a node kind unknown to the rebuilder (fail loud – an unrebuildable node must never silently remain un-interned).

◆ SetCanonicalizeByDefault()

void bertini::node::SetCanonicalizeByDefault ( bool on)

Set whether Sum/Mult construction canonicalizes operand order by default.

◆ SetDialect()

void bertini::node::SetDialect ( std::ios_base & stream,
PrintDialect dialect )
inline

Choose the dialect everything subsequently printed to stream is written in.

◆ SetMonomialOrder()

void bertini::node::SetMonomialOrder ( MonomialOrder order)

Set the session-wide monomial order (determines interned identity).

◆ SetPowerFoldByDefault()

void bertini::node::SetPowerFoldByDefault ( bool on)

Set whether Mult construction flattens + power-folds by default.

◆ SimplifiedMult()

std::shared_ptr< Node > bertini::node::SimplifiedMult ( std::vector< std::pair< std::shared_ptr< Node >, bool > > const & factors)

Build a product from (factor, mult_or_div) pairs, simplified.

A multiplied literal zero collapses the whole product to 0; literal ones are dropped; literal Integer/Rational constants (real-valued) are folded together exactly (no Complex folding – precision semantics stay untouched). A literal zero DIVISOR is left in place, keeping the division by zero visible. A single surviving multiplied factor is returned unwrapped. Builds fresh nodes; the factor nodes are shared, never modified.

◆ SimplifiedNegate()

std::shared_ptr< Node > bertini::node::SimplifiedNegate ( std::shared_ptr< Node > const & n)

Negation that never builds junk: -0 stays 0.

Builds a fresh node; never modifies the input.

◆ SimplifiedSum()

std::shared_ptr< Node > bertini::node::SimplifiedSum ( std::vector< std::pair< std::shared_ptr< Node >, bool > > const & terms)

Build a sum from (term, add_or_sub) pairs, omitting literal zeros.

Empty after pruning -> Integer 0; a single added term is returned unwrapped; a single subtracted term is negated. Builds fresh nodes; the term nodes are shared, never modified. Used by differentiation so derivative trees come out already simplified.

◆ sin()

std::shared_ptr< Node > bertini::node::sin ( const std::shared_ptr< Node > & N)
inline

Build a sine expression-tree node.

◆ sqrt()

std::shared_ptr< Node > bertini::node::sqrt ( const std::shared_ptr< Node > & N)
inline

Build a square-root expression-tree node.

◆ tan()

std::shared_ptr< Node > bertini::node::tan ( const std::shared_ptr< Node > & N)
inline

Build a tangent expression-tree node.

◆ Two()

std::shared_ptr< Node > bertini::node::Two ( )

Construct a shared pointer to $2$.

◆ Zero()

std::shared_ptr< Node > bertini::node::Zero ( )

Construct a shared pointer to $0$.