|
| | TrigOperator (const std::shared_ptr< Node > &N) |
| | Construct a trigonometric operator over a single operand node.
|
| virtual | ~TrigOperator ()=default |
| std::size_t | HashImpl () const override |
| | Compute this node's structural hash.
|
| bool | IsSame (Node const &other) const override |
| | Order-sensitive structural equality, shallow given interned children.
|
| void | SetOperand (std::shared_ptr< Node > n) |
| | Set the single child (operand) of this unary operator.
|
| std::shared_ptr< Node > | Operand () const |
| int | Degree (std::shared_ptr< Variable > const &v=nullptr) const override |
| | Degree with respect to one variable (all variables when v is null).
|
| int | Degree (VariableGroup const &vars) const override |
| | Degree with respect to a variable group, by the same rule as the one-variable form.
|
| std::vector< int > | MultiDegreeImpl (VariableGroup const &vars) const override |
| | Compute the multidegree with respect to a variable group.
|
| bool | IsHomogeneous (std::shared_ptr< Variable > const &v=nullptr) const override |
| | Check for homogeneity, absolutely with respect to all variables, including path variables and all other variable types, or with respect to a single varaible, if passed.
|
| bool | IsHomogeneous (VariableGroup const &vars) const override |
| | Check for homogeneity, with respect to a variable group.
|
| virtual std::shared_ptr< Node > | Simplified () const |
| | Functionally simplify this tree, returning a NEW simplified tree.
|
| virtual std::shared_ptr< Node > | Subs (SubstitutionMap const &substitutions) const |
| | Symbolically substitute variables, returning a NEW tree.
|
| virtual void | print (std::ostream &target) const =0 |
| | Virtual method for printing Nodes to arbitrary output streams.
|
| virtual unsigned | Precedence () const |
| | The printing precedence of this node, deciding parenthesization.
|
| virtual bool | IsLiteralZero () const |
| | Is this node the literal constant 0?
|
| virtual bool | IsLiteralOne () const |
| | Is this node the literal constant 1?
|
| std::size_t | Hash () const |
| | Memoized structural hash of this node.
|
| std::shared_ptr< const void > | EvalProgram () const |
| | Opaque, lazily-populated cache of a compiled evaluator for this expression.
|
| void | SetEvalProgram (std::shared_ptr< const void > p) const |
| | Stash a compiled evaluator for this expression (type-erased; see EvalProgram()).
|
| virtual std::shared_ptr< Node > | Differentiate (std::shared_ptr< Variable > const &v=nullptr) const =0 |
| | Compute the derivative with respect to a single variable.
|
| std::shared_ptr< Node > | Differentiate (std::shared_ptr< Variable > const &v, unsigned count) const |
| | Differentiate repeatedly with respect to a single variable.
|
| std::shared_ptr< Node > | Differentiate (VariableGroup const &vars) const |
| | Differentiate with respect to each variable in a group, in sequence.
|
| std::vector< int > | MultiDegree (VariableGroup const &vars) const |
| | Compute the multidegree with respect to a variable group.
|
| virtual std::shared_ptr< Node > | Homogenized (VariableGroup const &vars, std::shared_ptr< Variable > const &homvar) const |
| | Homogenize a tree, returning a NEW homogenized tree (functional / non-mutating).
|
| bool | IsPolynomial (std::shared_ptr< Variable > const &v=nullptr) const |
| | Check if a Node is polynomial – it has degree at least 0.
|
| bool | IsPolynomial (VariableGroup const &v) const |
| | Check if a Node is polynomial – it has degree at least 0.
|
| virtual VisitReturnType | Accept (VisitorBase &)=0 |
| | Accept a visitor (dispatch to the visitor's Visit for this concrete type).
|
Abstract class for trigonometric Operator types.
Abstract class for trigonometric Operator types.
| virtual std::shared_ptr< Node > bertini::node::Node::Homogenized |
( |
VariableGroup const & | vars, |
|
|
std::shared_ptr< Variable > const & | homvar ) const |
|
virtualinherited |
Homogenize a tree, returning a NEW homogenized tree (functional / non-mutating).
Input a variable group holding the non-homogeneous variables, and the new homogenizing variable. The homvar may be an element of the variable group, that's perfectly ok.
The input tree is never modified; degree-deficient summands are padded with powers of homvar in a freshly-built tree (so a throw on a non-polynomial term can't leave a half-homogenized tree behind). The default (leaves, and anything with nothing to homogenize) returns the node unchanged.
- Parameters
-
| homvar | The homogenizing variable, which is multiplied against terms with degree deficiency with repect to other terms. |
| vars | A group of variables, with respect to which you wish to homogenize. |
- Returns
- A homogenized tree (possibly the same node, if nothing changed).
Reimplemented in bertini::node::ArcCosOperator, bertini::node::ArcSinOperator, bertini::node::ArcTanOperator, bertini::node::CosOperator, bertini::node::ExpOperator, bertini::node::IntegerPowerOperator, bertini::node::LogOperator, bertini::node::MultOperator, bertini::node::NamedExpression, bertini::node::NegateOperator, bertini::node::PowerOperator, bertini::node::SinOperator, bertini::node::SqrtOperator, bertini::node::SumOperator, and bertini::node::TanOperator.
| std::vector< int > bertini::node::Node::MultiDegree |
( |
VariableGroup const & | vars | ) |
const |
|
inherited |
Compute the multidegree with respect to a variable group.
This is for homogenization, and testing for homogeneity.
- Returns
- A vector containing the degrees. Negative entries indicate non-polynomiality. Compute the multidegree with respect to a variable group.
DAG-AWARE: this is a non-virtual wrapper that memoizes by node identity FOR THE DURATION OF ONE TOP-LEVEL CALL, so a shared subtree is visited once however many times it is reached. The per-type work lives in MultiDegreeImpl.
Why it exists (b2#417): the node graph is hash-consed, so a small DAG can stand for an enormous expansion – measured, a 46-node expression whose printed form is 196 KB. A plain recursive walk visits the TREE, so it costs O(expansion) where the structure is O(DAG). CanonicalizeNaryOperands calls this for every operand of every n-ary construction, which is how a 46-node expression came to cost 13 ms to multiply by a variable, and how a cofactor expansion inside a deflation stage came to run for hours with a DAG that never exceeded 1102 nodes.
Caching the RESULT between calls does not fix this and was measured 29% SLOWER – filling such a cache costs the same walk it is trying to avoid, so it only pays from a node's second mention. The memo has to be inside the traversal, which is what this is.
| virtual std::shared_ptr< Node > bertini::node::Node::Simplified |
( |
| ) |
const |
|
virtualinherited |
Functionally simplify this tree, returning a NEW simplified tree.
Non-mutating successor to the in-place EliminateZeros / EliminateOnes / ReduceDepth machinery (ADR-0011, issue 251). The input tree is never modified; a fresh simplified tree is returned, built through the SimplifiedSum / SimplifiedMult / SimplifiedNegate factories so that literal zeros/ones vanish and exact constants fold. The default (leaves, and any node with nothing to simplify) returns the node unchanged – structural sharing preserved.
- Returns
- A simplified tree (possibly the same node, if nothing simplified).
Reimplemented in bertini::node::ArcCosOperator, bertini::node::ArcSinOperator, bertini::node::ArcTanOperator, bertini::node::CosOperator, bertini::node::ExpOperator, bertini::node::IntegerPowerOperator, bertini::node::LogOperator, bertini::node::MultOperator, bertini::node::NegateOperator, bertini::node::PowerOperator, bertini::node::SinOperator, bertini::node::SqrtOperator, bertini::node::SumOperator, and bertini::node::TanOperator.
| virtual std::shared_ptr< Node > bertini::node::Node::Subs |
( |
SubstitutionMap const & | substitutions | ) |
const |
|
virtualinherited |
Symbolically substitute variables, returning a NEW tree.
Replaces each Variable leaf named in substitutions with its associated node, functionally (the input tree is never modified). Substitution is simultaneous and single-pass: a leaf is replaced at most once and the replacement is not itself descended into, so {x:y, y:z} maps x+y to y+z (no cascade) and the order of the map is irrelevant. A variable absent from the map is left unchanged. The result is rebuilt through the simplifying factories (like differentiation), so constants fold. The default (leaves with nothing to replace) returns the node unchanged – structural sharing preserved.
Only Variable leaves are matched (variable -> node substitution); substituting into a Jacobian tree containing Differentials is not supported.
- Parameters
-
| substitutions | A map from variable name to the node to put in that variable's place. |
- Returns
- The substituted tree (possibly the same node, if nothing matched).
Reimplemented in bertini::node::ArcCosOperator, bertini::node::ArcSinOperator, bertini::node::ArcTanOperator, bertini::node::CosOperator, bertini::node::ExpOperator, bertini::node::IntegerPowerOperator, bertini::node::LogOperator, bertini::node::MultOperator, bertini::node::NamedExpression, bertini::node::NegateOperator, bertini::node::PowerOperator, bertini::node::SinOperator, bertini::node::SqrtOperator, bertini::node::SumOperator, bertini::node::TanOperator, and bertini::node::Variable.