Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
bertini::node::Node Class Referenceabstract

Abstract base class for the Bertini hybrid-precision (double-multiple) expression tree. More...

#include <node.hpp>

Inheritance diagram for bertini::node::Node:
[legend]
Collaboration diagram for bertini::node::Node:
[legend]

Public Member Functions

virtual int Degree (std::shared_ptr< Variable > const &v=nullptr) const =0
 
virtual int Degree (VariableGroup const &vars) const =0
 
virtual std::shared_ptr< Node > Differentiate (std::shared_ptr< Variable > const &v=nullptr) const =0
 Compute the derivative with respect to a single variable.
 
virtual unsigned EliminateOnes ()=0
 A transform function, which eliminates nodes from the tree.
 
virtual unsigned EliminateZeros ()=0
 A transform function, which eliminates nodes from the tree.
 
template<typename T>
T Eval (std::shared_ptr< Variable > const &diff_variable=nullptr) const
 
template<typename T>
void EvalInPlace (T &eval_value, std::shared_ptr< Variable > const &diff_variable=nullptr) const
 
virtual void Homogenize (VariableGroup const &vars, std::shared_ptr< Variable > const &homvar)=0
 
virtual bool IsHomogeneous (std::shared_ptr< Variable > const &v=nullptr) const =0
 
virtual bool IsHomogeneous (VariableGroup const &vars) const =0
 
bool IsPolynomial (std::shared_ptr< Variable > const &v=nullptr) const
 
bool IsPolynomial (VariableGroup const &v) const
 
virtual std::vector< int > MultiDegree (VariableGroup const &vars) const =0
 
virtual void precision (unsigned int prec) const =0
 
virtual void print (std::ostream &target) const =0
 
virtual unsigned ReduceDepth ()
 A mutating function which finds ways to reduce the depth of the tree.
 
virtual void Reset () const =0
 

Protected Member Functions

virtual void FreshEval_d (dbl &evaluation_value, std::shared_ptr< Variable > const &) const =0
 
virtual dbl FreshEval_d (std::shared_ptr< Variable > const &) const =0
 
virtual void FreshEval_mp (mpfr_complex &evaluation_value, std::shared_ptr< Variable > const &) const =0
 
virtual mpfr_complex FreshEval_mp (std::shared_ptr< Variable > const &) const =0
 
void ResetStoredValues () const
 

Friends

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

Additional Inherited Members

- Static Protected Member Functions inherited from bertini::VisitableBase< RetT, CatchAll >
template<typename T>
static VisitReturnType AcceptBase (T &visited, VisitorBase &guest)
 Abstract method for how to accept a visitor.
 

Detailed Description

Abstract base class for the Bertini hybrid-precision (double-multiple) expression tree.

An interface for all nodes in a function tree, and for a function object as well. Almost all methods that will be called on a node must be declared in this class. The main evaluation method is defined in this class.

Bertini function trees are created using std::shared_ptr's to Node base class, generally.

Member Function Documentation

◆ Degree() [1/2]

virtual int bertini::node::Node::Degree ( std::shared_ptr< Variable > const & v = nullptr) const
pure virtual

Compute the degree, optionally with respect to a single variable.

Parameters
vShared pointer to variable with respect to which you want to compute the degree of the Node.
Returns
The degree. Will be negative if the Node is non-polynomial.

Implemented in bertini::node::Differential, bertini::node::DiffLinear, bertini::node::ExpOperator, bertini::node::IntegerPowerOperator, bertini::node::LinearProduct, bertini::node::LogOperator, bertini::node::MultOperator, bertini::node::Number, bertini::node::PowerOperator, bertini::node::SqrtOperator, bertini::node::SumOperator, bertini::node::TrigOperator, bertini::node::UnaryOperator, and bertini::node::Variable.

◆ Degree() [2/2]

virtual int bertini::node::Node::Degree ( VariableGroup const & vars) const
pure virtual

Compute the overall degree with respect to a variable group.

Parameters
varsA group of variables.
Returns
The degree. Will be negative if the Node is non-polynomial.

Implemented in bertini::node::Differential, bertini::node::DiffLinear, bertini::node::LinearProduct, bertini::node::MultOperator, bertini::node::Number, bertini::node::PowerOperator, bertini::node::SumOperator, bertini::node::UnaryOperator, and bertini::node::Variable.

◆ Differentiate()

virtual std::shared_ptr< Node > bertini::node::Node::Differentiate ( std::shared_ptr< Variable > const & v = nullptr) const
pure virtual

◆ EliminateOnes()

virtual unsigned bertini::node::Node::EliminateOnes ( )
pure virtual

A transform function, which eliminates nodes from the tree.

A better implementation of this would use a generic Transform. If you know how to do this, please rewrite the Nodes so they can transform to our whim, and submit a PR.

Returns
The number of nodes eliminated
See also
EliminateZeros

Implemented in bertini::node::ArcCosOperator, bertini::node::ArcSinOperator, bertini::node::ArcTanOperator, bertini::node::CosOperator, bertini::node::ExpOperator, bertini::node::IntegerPowerOperator, bertini::node::LinearProduct, bertini::node::LogOperator, bertini::node::MultOperator, bertini::node::NegateOperator, bertini::node::PowerOperator, bertini::node::SinOperator, bertini::node::SqrtOperator, bertini::node::SumOperator, bertini::node::Symbol, and bertini::node::TanOperator.

◆ EliminateZeros()

virtual unsigned bertini::node::Node::EliminateZeros ( )
pure virtual

A transform function, which eliminates nodes from the tree.

A better implementation of this would use a generic Transform. If you know how to do this, please rewrite the Nodes so they can transform to our whim, and submit a PR.

Returns
The number of nodes eliminated
See also
EliminateOnes

Implemented in bertini::node::LinearProduct, bertini::node::NegateOperator, bertini::node::SqrtOperator, bertini::node::SumOperator, and bertini::node::Symbol.

◆ Eval()

template<typename T>
T bertini::node::Node::Eval ( std::shared_ptr< Variable > const & diff_variable = nullptr) const
inline

Evaluate the node. If flag false, just return value, if flag true run the specific FreshEval of the node, then set flag to false.

Template type is type of value you want returned.

Returns
The value of the node.
Template Parameters
TThe number type for return. Must be one of the types stored in the Node class, currently dbl and mpfr_complex.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EvalInPlace()

template<typename T>
void bertini::node::Node::EvalInPlace ( T & eval_value,
std::shared_ptr< Variable > const & diff_variable = nullptr ) const

Evaluate the node in place. If flag false, just return value, if flag true run the specific FreshEval of the node, then set flag to false.

Template type is type of value you want returned.

Returns
The value of the node.
Template Parameters
TThe number type for return. Must be one of the types stored in the Node class, currently dbl and mpfr_complex.
Here is the caller graph for this function:

◆ FreshEval_d() [1/2]

virtual void bertini::node::Node::FreshEval_d ( dbl & evaluation_value,
std::shared_ptr< Variable > const &  ) const
protectedpure virtual

Overridden code for specific node types, for how to evaluate themselves. Called from the wrapper EvalInPlace<>() call from Node, if so required (by resetting, etc).

If we had the ability to use template virtual functions, we would have. However, this is impossible with current C++ without using experimental libraries, so we have two copies – because there are two number types for Nodes, dbl and mpfr_complex.

Implemented in bertini::node::ArcCosOperator, bertini::node::ArcSinOperator, bertini::node::ArcTanOperator, bertini::node::CosOperator, bertini::node::Differential, bertini::node::DiffLinear, bertini::node::ExpOperator, bertini::node::IntegerPowerOperator, bertini::node::LinearProduct, bertini::node::LogOperator, bertini::node::MultOperator, bertini::node::NegateOperator, bertini::node::PowerOperator, bertini::node::SinOperator, bertini::node::SqrtOperator, bertini::node::SumOperator, bertini::node::TanOperator, and bertini::node::Variable.

◆ FreshEval_d() [2/2]

virtual dbl bertini::node::Node::FreshEval_d ( std::shared_ptr< Variable > const & ) const
protectedpure virtual

Overridden code for specific node types, for how to evaluate themselves. Called from the wrapper Eval<>() call from Node, if so required (by resetting, etc).

If we had the ability to use template virtual functions, we would have. However, this is impossible with current C++ without using experimental libraries, so we have two copies – because there are two number types for Nodes, dbl and mpfr_complex.

Implemented in bertini::node::ArcCosOperator, bertini::node::ArcSinOperator, bertini::node::ArcTanOperator, bertini::node::CosOperator, bertini::node::Differential, bertini::node::DiffLinear, bertini::node::ExpOperator, bertini::node::IntegerPowerOperator, bertini::node::LinearProduct, bertini::node::LogOperator, bertini::node::MultOperator, bertini::node::NegateOperator, bertini::node::PowerOperator, bertini::node::SinOperator, bertini::node::SqrtOperator, bertini::node::SumOperator, bertini::node::TanOperator, and bertini::node::Variable.

◆ FreshEval_mp() [1/2]

virtual void bertini::node::Node::FreshEval_mp ( mpfr_complex & evaluation_value,
std::shared_ptr< Variable > const &  ) const
protectedpure virtual

Overridden code for specific node types, for how to evaluate themselves. Called from the wrapper Eval<>() call from Node, if so required (by resetting, etc).

If we had the ability to use template virtual functions, we would have. However, this is impossible with current C++ without using experimental libraries, so we have two copies – because there are two number types for Nodes, dbl and mpfr_complex.

Implemented in bertini::node::ArcCosOperator, bertini::node::ArcSinOperator, bertini::node::ArcTanOperator, bertini::node::CosOperator, bertini::node::Differential, bertini::node::DiffLinear, bertini::node::ExpOperator, bertini::node::IntegerPowerOperator, bertini::node::LinearProduct, bertini::node::LogOperator, bertini::node::MultOperator, bertini::node::NegateOperator, bertini::node::PowerOperator, bertini::node::SinOperator, bertini::node::SqrtOperator, bertini::node::SumOperator, bertini::node::TanOperator, and bertini::node::Variable.

◆ FreshEval_mp() [2/2]

virtual mpfr_complex bertini::node::Node::FreshEval_mp ( std::shared_ptr< Variable > const & ) const
protectedpure virtual

Overridden code for specific node types, for how to evaluate themselves. Called from the wrapper Eval<>() call from Node, if so required (by resetting, etc).

If we had the ability to use template virtual functions, we would have. However, this is impossible with current C++ without using experimental libraries, so we have two copies – because there are two number types for Nodes, dbl and mpfr_complex.

Implemented in bertini::node::ArcCosOperator, bertini::node::ArcSinOperator, bertini::node::ArcTanOperator, bertini::node::CosOperator, bertini::node::Differential, bertini::node::DiffLinear, bertini::node::ExpOperator, bertini::node::IntegerPowerOperator, bertini::node::LinearProduct, bertini::node::LogOperator, bertini::node::MultOperator, bertini::node::NegateOperator, bertini::node::PowerOperator, bertini::node::SinOperator, bertini::node::SqrtOperator, bertini::node::SumOperator, bertini::node::TanOperator, and bertini::node::Variable.

◆ Homogenize()

virtual void bertini::node::Node::Homogenize ( VariableGroup const & vars,
std::shared_ptr< Variable > const & homvar )
pure virtual

Homogenize a tree, inputting 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.

Parameters
homvarThe homogenizing variable, which is multiplied against terms with degree deficiency with repect to other terms.
varsA group of variables, with respect to which you wish to homogenize.

Implemented in bertini::node::Differential, bertini::node::DiffLinear, bertini::node::LinearProduct, bertini::node::MultOperator, bertini::node::Number, bertini::node::PowerOperator, bertini::node::SumOperator, bertini::node::UnaryOperator, and bertini::node::Variable.

◆ IsHomogeneous() [1/2]

virtual bool bertini::node::Node::IsHomogeneous ( std::shared_ptr< Variable > const & v = nullptr) const
pure virtual

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.

Returns
True if it is homogeneous, false if not.

Implemented in bertini::node::Differential, bertini::node::DiffLinear, bertini::node::IntegerPowerOperator, bertini::node::LinearProduct, bertini::node::MultOperator, bertini::node::NegateOperator, bertini::node::Number, bertini::node::PowerOperator, bertini::node::SumOperator, bertini::node::UnaryOperator, and bertini::node::Variable.

◆ IsHomogeneous() [2/2]

virtual bool bertini::node::Node::IsHomogeneous ( VariableGroup const & vars) const
pure virtual

◆ IsPolynomial() [1/2]

bool bertini::node::Node::IsPolynomial ( std::shared_ptr< Variable > const & v = nullptr) const

Check if a Node is polynomial – it has degree at least 0. Negative degrees indicate non-polynomial.

Returns
True if it is polynomial, false if not.

◆ IsPolynomial() [2/2]

bool bertini::node::Node::IsPolynomial ( VariableGroup const & v) const

Check if a Node is polynomial – it has degree at least 0. Negative degrees indicate non-polynomial.

Returns
True if it is polynomial, false if not.

◆ MultiDegree()

virtual std::vector< int > bertini::node::Node::MultiDegree ( VariableGroup const & vars) const
pure virtual

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.

Implemented in bertini::node::Differential, bertini::node::DiffLinear, bertini::node::LinearProduct, bertini::node::MultOperator, bertini::node::Number, bertini::node::PowerOperator, bertini::node::SumOperator, bertini::node::UnaryOperator, and bertini::node::Variable.

◆ precision()

virtual void bertini::node::Node::precision ( unsigned int prec) const
pure virtual

Change the precision of this variable-precision tree node.

Parameters
precthe number of digits to change precision to.

Implemented in bertini::node::Differential, bertini::node::DiffLinear, bertini::node::LinearProduct, bertini::node::NaryOperator, bertini::node::Number, bertini::node::PowerOperator, bertini::node::UnaryOperator, and bertini::node::Variable.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print()

◆ ReduceDepth()

virtual unsigned bertini::node::Node::ReduceDepth ( )
virtual

A mutating function which finds ways to reduce the depth of the tree.

Note
The default implementation is empty, and does literally nothing.

Reimplemented in bertini::node::MultOperator, and bertini::node::SumOperator.

◆ Reset()

virtual void bertini::node::Node::Reset ( ) const
pure virtual

◆ ResetStoredValues()

void bertini::node::Node::ResetStoredValues ( ) const
protected

Set the stored values for the Node to indicate a fresh eval on the next pass. This is so that Nodes which are referred to more than once, are only evaluated once. The first evaluation is fresh, and then the indicator for fresh/stored is set to stored. Subsequent evaluation calls simply return the stored number.

Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const Node & N )
friend

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


The documentation for this class was generated from the following file: