31#ifndef BERTINI_OPERATOR_ARITHMETIC_HPP
32#define BERTINI_OPERATOR_ARITHMETIC_HPP
74 virtual ~SumOperator() = default;
81 template<typename... Ts>
83 std::shared_ptr<SumOperator>
Make(Ts&& ...ts){
84 return std::static_pointer_cast<SumOperator>(
Intern(std::shared_ptr<Node>(
new SumOperator(ts...) )));
88 SumOperator(
const std::shared_ptr<Node> & s,
bool add_or_sub)
93 SumOperator(
const std::shared_ptr<Node> & left,
const std::shared_ptr<Node> & right)
101 SumOperator(
const std::shared_ptr<Node> & left,
bool add_or_sub_left,
const std::shared_ptr<Node> & right,
bool add_or_sub_right)
111 explicit SumOperator(std::vector<std::pair<std::shared_ptr<Node>,
bool>>
const& terms)
113 for (
auto const& t : terms)
144 signs_.push_back(
true);
154 signs_.push_back(sign);
161 void print(std::ostream & target)
const override;
174 std::shared_ptr<Node>
Differentiate(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
179 int Degree(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
191 const auto&
GetSigns()
const{
return this-> signs_;}
202 bool IsHomogeneous(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
226 std::vector<bool> signs_;
230 SumOperator() =
default;
234 template <
typename Archive>
235 void serialize(Archive& ar,
const unsigned ) {
236 ar & boost::serialization::base_object<NaryOperator>(*
this);
241 void PrecisionChangeSpecific(
unsigned prec)
const override
243 temp_mp_.precision(prec);
276 template<
typename... Ts>
278 std::shared_ptr<NegateOperator>
Make(Ts&& ...ts){
279 return std::static_pointer_cast<NegateOperator>(
Intern(std::shared_ptr<Node>(
new NegateOperator(ts...) )));
297 void print(std::ostream & target)
const override;
308 std::shared_ptr<Node>
Differentiate(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
311 int Degree(std::shared_ptr<Variable>
const& v =
nullptr)
const override
323 bool IsHomogeneous(std::shared_ptr<Variable>
const& v =
nullptr)
const override
333 return operand_->IsHomogeneous(vars);
345 NegateOperator() =
default;
349 template <
typename Archive>
350 void serialize(Archive& ar,
const unsigned ) {
351 ar & boost::serialization::base_object<UnaryOperator>(*
this);
357 inline std::shared_ptr<Node>
operator-(
const std::shared_ptr<Node> & rhs)
389 template<typename... Ts>
391 std::shared_ptr<MultOperator>
Make(Ts&& ...ts){
392 return std::static_pointer_cast<MultOperator>(
Intern(std::shared_ptr<Node>(
new MultOperator(ts...) )));
406 MultOperator(std::shared_ptr<Node>
const& left, std::shared_ptr<Node>
const& right)
414 MultOperator(
const std::shared_ptr<Node> & left,
bool mult_or_div_left,
const std::shared_ptr<Node> & right,
bool mult_or_div_right)
423 explicit MultOperator(std::vector<std::pair<std::shared_ptr<Node>,
bool>>
const& factors)
425 for (
auto const& f : factors)
441 mult_or_div_.push_back(
true);
451 mult_or_div_.push_back(mult);
458 void print(std::ostream & target)
const override;
468 std::shared_ptr<Node>
Differentiate(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
473 int Degree(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
488 bool IsHomogeneous(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
522 std::vector<bool> mult_or_div_;
529 template <
typename Archive>
530 void serialize(Archive& ar,
const unsigned ) {
531 ar & boost::serialization::base_object<NaryOperator>(*
this);
535 void PrecisionChangeSpecific(
unsigned prec)
const override
537 temp_mp_.precision(prec);
569 template<typename... Ts>
571 std::shared_ptr<PowerOperator>
Make(Ts&& ...ts){
572 return std::static_pointer_cast<PowerOperator>(
Intern(std::shared_ptr<Node>(
new PowerOperator(ts...) )));
577 PowerOperator(
const std::shared_ptr<Node> & new_base,
const std::shared_ptr<Node> & new_exponent) : base_(new_base), exponent_(new_exponent)
594 exponent_ = new_exponent;
612 void print(std::ostream & target)
const override;
624 std::shared_ptr<Node>
Differentiate(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
629 int Degree(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
644 bool IsHomogeneous(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
667 PowerOperator() =
default;
669 std::shared_ptr<Node> base_;
670 std::shared_ptr<Node> exponent_;
679 template <
typename Archive>
680 void serialize(Archive& ar,
const unsigned ) {
681 ar & boost::serialization::base_object<Operator>(*
this);
723 void print(std::ostream & target) const override;
752 std::shared_ptr<Node>
Differentiate(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
757 int Degree(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
762 bool IsHomogeneous(std::shared_ptr<Variable>
const& v =
nullptr)
const override
773 return operand_->IsHomogeneous(vars);
781 template<
typename... Ts>
783 std::shared_ptr<IntegerPowerOperator>
Make(Ts&& ...ts){
784 return std::static_pointer_cast<IntegerPowerOperator>(
Intern(std::shared_ptr<Node>(
new IntegerPowerOperator(ts...) )));
807 IntegerPowerOperator() =
default;
814 template <
typename Archive>
815 void serialize(Archive& ar,
const unsigned ) {
816 ar & boost::serialization::base_object<UnaryOperator>(*
this);
852 template<
typename... Ts>
854 std::shared_ptr<SqrtOperator>
Make(Ts&& ...ts){
855 return std::static_pointer_cast<SqrtOperator>(
Intern(std::shared_ptr<Node>(
new SqrtOperator(ts...) )));
869 void print(std::ostream & target)
const override;
875 std::shared_ptr<Node>
Differentiate(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
887 SqrtOperator() =
default;
891 template <
typename Archive>
892 void serialize(Archive& ar,
const unsigned ) {
893 ar & boost::serialization::base_object<UnaryOperator>(*
this);
900 inline std::shared_ptr<Node>
sqrt(
const std::shared_ptr<Node> & N)
924 template<typename... Ts>
926 std::shared_ptr<ExpOperator>
Make(Ts&& ...ts){
927 return std::static_pointer_cast<ExpOperator>(
Intern(std::shared_ptr<Node>(
new ExpOperator(ts...) )));
939 void print(std::ostream & target)
const override;
945 std::shared_ptr<Node>
Differentiate(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
955 ExpOperator() =
default;
958 template <
typename Archive>
959 void serialize(Archive& ar,
const unsigned ) {
960 ar & boost::serialization::base_object<UnaryOperator>(*
this);
981 template<typename... Ts>
983 std::shared_ptr<LogOperator>
Make(Ts&& ...ts){
984 return std::static_pointer_cast<LogOperator>(
Intern(std::shared_ptr<Node>(
new LogOperator(ts...) )));
996 void print(std::ostream & target)
const override;
1002 std::shared_ptr<Node>
Differentiate(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
1012 LogOperator() =
default;
1015 template <
typename Archive>
1016 void serialize(Archive& ar,
const unsigned ) {
1017 ar & boost::serialization::base_object<UnaryOperator>(*
this);
1027 inline std::shared_ptr<Node>
exp(
const std::shared_ptr<Node> & N)
1033 inline std::shared_ptr<Node>
log(
const std::shared_ptr<Node> & N)
1039 inline std::shared_ptr<Node>
pow(
const std::shared_ptr<Node> & N,
const std::shared_ptr<Node> & p)
1045 inline std::shared_ptr<Node>
pow(std::shared_ptr<Node>
const& base,
int power)
1051 std::shared_ptr<Node>
pow(
const std::shared_ptr<Node> & N,
double p) =
delete;
1057 inline std::shared_ptr<Node>
pow(
const std::shared_ptr<Node> & N,
real_mp p)
1100 std::shared_ptr<Node>
SimplifiedSum(std::vector<std::pair<std::shared_ptr<Node>,
bool>>
const& terms);
1112 std::shared_ptr<Node>
SimplifiedMult(std::vector<std::pair<std::shared_ptr<Node>,
bool>>
const& factors);
1133 inline std::shared_ptr<Node>&
operator+=(std::shared_ptr<Node> & lhs,
const std::shared_ptr<Node> & rhs)
1145 inline std::shared_ptr<Node>
operator+(std::shared_ptr<Node> lhs,
const std::shared_ptr<Node> & rhs)
1175 inline std::shared_ptr<Node>
operator+(std::shared_ptr<Node> lhs,
int rhs)
1181 inline std::shared_ptr<Node>
operator+(
int lhs, std::shared_ptr<Node> rhs)
1220 inline std::shared_ptr<Node>&
operator-=(std::shared_ptr<Node> & lhs,
const std::shared_ptr<Node> & rhs)
1229 inline std::shared_ptr<Node>
operator-(std::shared_ptr<Node> lhs,
const std::shared_ptr<Node> & rhs)
1259 inline std::shared_ptr<Node>
operator-(std::shared_ptr<Node> lhs,
int rhs)
1265 inline std::shared_ptr<Node>
operator-(
int lhs, std::shared_ptr<Node> rhs)
1300 inline std::shared_ptr<Node>
operator*=(std::shared_ptr<MultOperator> & lhs,
const std::shared_ptr<Node> & rhs)
1302 lhs->AddOperand(rhs);
1332 inline std::shared_ptr<Node>
operator*(std::shared_ptr<Node> lhs,
int rhs)
1338 inline std::shared_ptr<Node>
operator*(
int lhs, std::shared_ptr<Node> rhs)
1373 inline std::shared_ptr<Node>&
operator*=(std::shared_ptr<Node> & lhs,
const std::shared_ptr<Node> & rhs)
1381 inline std::shared_ptr<Node>
operator*(std::shared_ptr<Node> lhs,
const std::shared_ptr<Node> & rhs)
1397 inline std::shared_ptr<Node>&
operator/=(std::shared_ptr<Node> & lhs,
const std::shared_ptr<Node> & rhs)
1420 inline std::shared_ptr<Node>
operator/=(std::shared_ptr<MultOperator> & lhs,
const std::shared_ptr<Node> & rhs)
1422 lhs->AddOperand(rhs,
false);
1429 inline std::shared_ptr<Node>
operator/(std::shared_ptr<Node> lhs,
const std::shared_ptr<Node> & rhs)
1459 inline std::shared_ptr<Node>
operator/(std::shared_ptr<Node> lhs,
int rhs)
1465 inline std::shared_ptr<Node>
operator/(
int lhs, std::shared_ptr<Node> rhs)
Canonical ordering of commutative-operator operands (reorder-only).
static std::shared_ptr< Complex > Make(Ts &&...ts)
Construct (and intern) a Complex node.
Definition number.hpp:313
represents the exponential function
Definition arithmetic.hpp:914
std::shared_ptr< Node > Subs(SubstitutionMap const &substitutions) const override
Symbolically substitute variables, returning a NEW tree.
static std::shared_ptr< ExpOperator > Make(Ts &&...ts)
Construct (and intern) a ExpOperator node.
Definition arithmetic.hpp:926
void print(std::ostream &target) const override
Virtual method for printing Nodes to arbitrary output streams.
std::shared_ptr< Node > Homogenized(VariableGroup const &vars, std::shared_ptr< Variable > const &homvar) const override
Homogenize a tree, returning a NEW homogenized tree (functional / non-mutating).
std::shared_ptr< Node > Differentiate(std::shared_ptr< Variable > const &v=nullptr) const override
Differentiates the exponential function.
virtual ~ExpOperator()=default
friend class boost::serialization::access
Definition arithmetic.hpp:956
std::shared_ptr< Node > Simplified() const override
Functionally simplify this tree, returning a NEW simplified tree.
This class represents the exponentiation Operator.
Definition arithmetic.hpp:709
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 oth...
Definition arithmetic.hpp:762
bool IsHomogeneous(VariableGroup const &vars) const override
Check for homogeneity, with respect to a variable group.
Definition arithmetic.hpp:771
void print(std::ostream &target) const override
polymorphic method for printing to an arbitrary stream.
int Degree(std::shared_ptr< Variable > const &v=nullptr) const override
Compute the degree of a node.
std::shared_ptr< Node > Differentiate(std::shared_ptr< Variable > const &v=nullptr) const override
Differentiate.
int exponent() const
Get the exponent.
Definition arithmetic.hpp:743
std::shared_ptr< Node > Subs(SubstitutionMap const &substitutions) const override
Symbolically substitute variables, returning a NEW tree.
int Degree(VariableGroup const &vars) const override
Compute the overall degree with respect to a variable group.
std::shared_ptr< Node > Homogenized(VariableGroup const &vars, std::shared_ptr< Variable > const &homvar) const override
Homogenize a tree, returning a NEW homogenized tree (functional / non-mutating).
std::size_t HashImpl() const override
Compute this node's structural hash.
static std::shared_ptr< IntegerPowerOperator > Make(Ts &&...ts)
Construct (and intern) a IntegerPowerOperator node.
Definition arithmetic.hpp:783
void set_exponent(int exp)
Set the integer exponent of an integer power operator.
Definition arithmetic.hpp:734
friend class boost::serialization::access
Definition arithmetic.hpp:812
bool IsSame(Node const &other) const override
Order-sensitive structural equality, shallow given interned children.
unsigned Precedence() const override
The printing precedence of this node, deciding parenthesization.
Definition arithmetic.hpp:725
std::shared_ptr< Node > Simplified() const override
Functionally simplify this tree, returning a NEW simplified tree.
virtual ~IntegerPowerOperator()=default
static std::shared_ptr< Integer > Make(Ts &&...ts)
Construct (and intern) a Integer node.
Definition number.hpp:198
represents the natural logarithm function
Definition arithmetic.hpp:971
std::shared_ptr< Node > Differentiate(std::shared_ptr< Variable > const &v=nullptr) const override
Differentiates the exponential function.
static std::shared_ptr< LogOperator > Make(Ts &&...ts)
Construct (and intern) a LogOperator node.
Definition arithmetic.hpp:983
std::shared_ptr< Node > Homogenized(VariableGroup const &vars, std::shared_ptr< Variable > const &homvar) const override
Homogenize a tree, returning a NEW homogenized tree (functional / non-mutating).
virtual ~LogOperator()=default
void print(std::ostream &target) const override
Virtual method for printing Nodes to arbitrary output streams.
std::shared_ptr< Node > Simplified() const override
Functionally simplify this tree, returning a NEW simplified tree.
friend class boost::serialization::access
Definition arithmetic.hpp:1013
std::shared_ptr< Node > Subs(SubstitutionMap const &substitutions) const override
Symbolically substitute variables, returning a NEW tree.
Multiplication and division Operator.
Definition arithmetic.hpp:379
void AddOperand(std::shared_ptr< Node > child, bool mult)
Add a factor; pass the bool to choose multiply (true) or divide (false).
Definition arithmetic.hpp:448
const auto & GetMultOrDiv() const
Get the indicator for which operation is being performed.
Definition arithmetic.hpp:501
void print(std::ostream &target) const override
overridden method for printing to an output stream
bool IsHomogeneous(VariableGroup const &vars) const override
Check for homogeneity, with respect to a variable group.
std::shared_ptr< Node > Simplified() const override
Functionally simplify this tree, returning a NEW simplified tree.
std::size_t HashImpl() const override
Compute this node's structural hash.
int Degree(std::shared_ptr< Variable > const &v=nullptr) const override
Compute the degree of a node.
std::shared_ptr< Node > Differentiate(std::shared_ptr< Variable > const &v=nullptr) const override
Differentiates using the product rule.
unsigned Precedence() const override
The printing precedence of this node, deciding parenthesization.
Definition arithmetic.hpp:460
std::shared_ptr< Node > Subs(SubstitutionMap const &substitutions) const override
Symbolically substitute variables, returning a NEW tree.
virtual ~MultOperator()=default
void AddOperand(std::shared_ptr< Node > child) override
Add an operand (child) onto this operator.
Definition arithmetic.hpp:438
int Degree(VariableGroup const &vars) const override
Compute the overall degree with respect to a variable group.
std::vector< int > MultiDegreeImpl(VariableGroup const &vars) const override
Compute the multidegree with respect to a variable group.
friend class boost::serialization::access
Definition arithmetic.hpp:527
std::shared_ptr< Node > Homogenized(VariableGroup const &vars, std::shared_ptr< Variable > const &homvar) const override
Homogenize a tree, returning a NEW homogenized tree (functional / non-mutating).
bool IsSame(Node const &other) const override
Order-sensitive structural equality, shallow given interned children.
static std::shared_ptr< MultOperator > Make(Ts &&...ts)
Construct (and intern) a MultOperator node.
Definition arithmetic.hpp:391
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 oth...
std::vector< std::shared_ptr< Node > > operands_
Change the precision of this variable-precision tree node.
Definition operator.hpp:194
virtual void AddOperand(std::shared_ptr< Node > n)
Add an operand (child) onto this operator.
NaryOperator()
Definition operator.hpp:197
The negation Operator.
Definition arithmetic.hpp:271
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 oth...
Definition arithmetic.hpp:323
std::shared_ptr< Node > Subs(SubstitutionMap const &substitutions) const override
Symbolically substitute variables, returning a NEW tree.
int Degree(VariableGroup const &vars) const override
Degree in a variable group: negation preserves its operand's degree.
Definition arithmetic.hpp:318
bool IsHomogeneous(VariableGroup const &vars) const override
Check for homogeneity, with respect to a variable group.
Definition arithmetic.hpp:331
static std::shared_ptr< NegateOperator > Make(Ts &&...ts)
Construct (and intern) a NegateOperator node.
Definition arithmetic.hpp:278
std::shared_ptr< Node > Differentiate(std::shared_ptr< Variable > const &v=nullptr) const override
Returns negative of derivative of child.
virtual ~NegateOperator()=default
void print(std::ostream &target) const override
Print to an arbitrary ostream.
std::shared_ptr< Node > Homogenized(VariableGroup const &vars, std::shared_ptr< Variable > const &homvar) const override
Homogenize a tree, returning a NEW homogenized tree (functional / non-mutating).
friend class boost::serialization::access
Definition arithmetic.hpp:347
unsigned Precedence() const override
The printing precedence of this node, deciding parenthesization.
Definition arithmetic.hpp:299
int Degree(std::shared_ptr< Variable > const &v=nullptr) const override
Degree in one variable: negation preserves its operand's degree.
Definition arithmetic.hpp:311
std::shared_ptr< Node > Simplified() const override
Functionally simplify this tree, returning a NEW simplified tree.
An interface for all nodes in a function tree, and for a function object as well.
Definition node.hpp:114
Abstract Node type from which all Operators inherit.
Definition operator.hpp:48
Operator for power functions with arbitrary expressions in the exponent and base.
Definition arithmetic.hpp:559
std::shared_ptr< Node > Subs(SubstitutionMap const &substitutions) const override
Symbolically substitute variables, returning a NEW tree.
virtual ~PowerOperator()=default
std::shared_ptr< Node > Simplified() const override
Functionally simplify this tree, returning a NEW simplified tree.
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 oth...
std::size_t HashImpl() const override
Compute this node's structural hash.
std::shared_ptr< Node > GetExponent() const
Definition arithmetic.hpp:604
std::shared_ptr< Node > Homogenized(VariableGroup const &vars, std::shared_ptr< Variable > const &homvar) const override
Homogenize a tree, returning a NEW homogenized tree (functional / non-mutating).
void SetExponent(std::shared_ptr< Node > new_exponent)
Set the exponent of the power.
Definition arithmetic.hpp:592
void SetBase(std::shared_ptr< Node > new_base)
Set the base of the power.
Definition arithmetic.hpp:586
static std::shared_ptr< PowerOperator > Make(Ts &&...ts)
Construct (and intern) a PowerOperator node.
Definition arithmetic.hpp:571
unsigned Precedence() const override
The printing precedence of this node, deciding parenthesization.
Definition arithmetic.hpp:614
std::shared_ptr< Node > GetBase() const
Definition arithmetic.hpp:598
std::vector< int > MultiDegreeImpl(VariableGroup const &vars) const override
Compute the multidegree with respect to a variable group.
int Degree(std::shared_ptr< Variable > const &v=nullptr) const override
Compute the degree of a node.
bool IsHomogeneous(VariableGroup const &vars) const override
Check for homogeneity, with respect to a variable group.
std::shared_ptr< Node > Differentiate(std::shared_ptr< Variable > const &v=nullptr) const override
Differentiates with the power rule.
void print(std::ostream &target) const override
Virtual method for printing Nodes to arbitrary output streams.
int Degree(VariableGroup const &vars) const override
Compute the overall degree with respect to a variable group.
friend class boost::serialization::access
Definition arithmetic.hpp:676
bool IsSame(Node const &other) const override
Order-sensitive structural equality, shallow given interned children.
static std::shared_ptr< Rational > Make(Ts &&...ts)
Construct (and intern) a Rational node.
Definition number.hpp:496
Represents the square root Operator.
Definition arithmetic.hpp:847
std::shared_ptr< Node > Simplified() const override
Functionally simplify this tree, returning a NEW simplified tree.
std::shared_ptr< Node > Homogenized(VariableGroup const &vars, std::shared_ptr< Variable > const &homvar) const override
Homogenize a tree, returning a NEW homogenized tree (functional / non-mutating).
std::shared_ptr< Node > Subs(SubstitutionMap const &substitutions) const override
Symbolically substitute variables, returning a NEW tree.
std::shared_ptr< Node > Differentiate(std::shared_ptr< Variable > const &v=nullptr) const override
Differentiates the square root function.
virtual ~SqrtOperator()=default
friend class boost::serialization::access
Definition arithmetic.hpp:889
static std::shared_ptr< SqrtOperator > Make(Ts &&...ts)
Construct (and intern) a SqrtOperator node.
Definition arithmetic.hpp:854
void print(std::ostream &target) const override
Virtual method for printing Nodes to arbitrary output streams.
Represents summation and difference Operator.
Definition arithmetic.hpp:70
std::shared_ptr< Node > Differentiate(std::shared_ptr< Variable > const &v=nullptr) const override
Return SumOperator whose children are derivatives of the children, omitted as possible.
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 oth...
bool IsHomogeneous(VariableGroup const &vars) const override
Check for homogeneity, with respect to a variable group.
std::shared_ptr< Node > Homogenized(VariableGroup const &vars, std::shared_ptr< Variable > const &homvar) const override
Homogenize a sum, with respect to a variable group, and using a homogenizing variable.
std::size_t HashImpl() const override
Compute this node's structural hash.
void AddOperand(std::shared_ptr< Node > child, bool sign)
Definition arithmetic.hpp:151
unsigned Precedence() const override
The printing precedence of this node, deciding parenthesization.
Definition arithmetic.hpp:163
SumOperator & operator-=(const std::shared_ptr< Node > &rhs)
Subtract a term in place (operand added with negative sign).
Definition arithmetic.hpp:128
int Degree(VariableGroup const &vars) const override
Compute the overall degree with respect to a variable group.
static std::shared_ptr< SumOperator > Make(Ts &&...ts)
Construct (and intern) a SumOperator node.
Definition arithmetic.hpp:83
void AddOperand(std::shared_ptr< Node > child) override
Definition arithmetic.hpp:141
std::vector< int > MultiDegreeImpl(VariableGroup const &vars) const override
Compute the multidegree with respect to a variable group.
SumOperator & operator+=(const std::shared_ptr< Node > &rhs)
Add a term in place (operand added with positive sign).
Definition arithmetic.hpp:121
std::shared_ptr< Node > Simplified() const override
Functionally simplify this tree, returning a NEW simplified tree.
bool IsSame(Node const &other) const override
Order-sensitive structural equality, shallow given interned children.
int Degree(std::shared_ptr< Variable > const &v=nullptr) const override
Compute the degree of a node.
friend class boost::serialization::access
Definition arithmetic.hpp:232
void print(std::ostream &target) const override
Method for printing to output stream.
const auto & GetSigns() const
Definition arithmetic.hpp:191
std::shared_ptr< Node > Subs(SubstitutionMap const &substitutions) const override
Symbolically substitute variables, returning a NEW tree.
Interface for all unary Operator types.
Definition operator.hpp:74
std::shared_ptr< Node > operand_
The single child (operand) of the unary operator.
Definition operator.hpp:136
UnaryOperator(const std::shared_ptr< Node > &n)
Construct a unary operator over a single operand node.
Definition operator.hpp:78
Represents variable leaves in the function tree.
Definition variable.hpp:48
Provides the differential Node class.
Forward declarations for types in the node:: namespace.
Definition canonical.hpp:56
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.
Definition arithmetic.hpp:1220
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 > & operator/=(std::shared_ptr< Node > &lhs, const std::shared_ptr< Node > &rhs)
Build a quotient expression-tree node from its operands.
Definition arithmetic.hpp:1397
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.
Definition arithmetic.hpp:1145
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.
Definition arithmetic.hpp:1429
std::shared_ptr< Node > log(const std::shared_ptr< Node > &N)
Build a natural-logarithm expression-tree node.
Definition arithmetic.hpp:1033
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 > Intern(std::shared_ptr< Node > const &candidate)
Hash-cons a freshly-built node: return an existing structurally-equal node if one is live,...
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.
Definition arithmetic.hpp:1300
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.
Definition arithmetic.hpp:1133
@ PrecNegate
Definition node.hpp:98
@ PrecPower
Definition node.hpp:100
@ PrecMult
Definition node.hpp:99
@ PrecSum
Definition node.hpp:97
std::shared_ptr< Node > SimplifiedNegate(std::shared_ptr< Node > const &n)
Negation that never builds junk: -0 stays 0.
std::shared_ptr< Node > sqrt(const std::shared_ptr< Node > &N)
Build a square-root expression-tree node.
Definition arithmetic.hpp:900
std::shared_ptr< Node > operator*(std::shared_ptr< Node > lhs, real_mp const &rhs)
Build a product expression-tree node from its operands.
Definition arithmetic.hpp:1308
std::shared_ptr< Node > exp(const std::shared_ptr< Node > &N)
Build an exponential (e raised to the node) expression-tree node.
Definition arithmetic.hpp:1027
std::shared_ptr< Node > pow(const std::shared_ptr< Node > &N, const std::shared_ptr< Node > &p)
Build a power expression-tree node.
Definition arithmetic.hpp:1039
std::shared_ptr< Node > operator-(const std::shared_ptr< Node > &rhs)
Build a difference expression-tree node from its operands.
Definition arithmetic.hpp:357
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.
Definition algorithm_builder.hpp:36
std::complex< double > complex_dbl
The double-precision complex number type.
Definition double_extensions.hpp:47
boost::multiprecision::number< boost::multiprecision::backends::gmp_int, boost::multiprecision::et_on > mpz_int
The arbitrary-precision integer type.
Definition mpfr_extensions.hpp:54
std::map< std::string, std::shared_ptr< node::Node > > SubstitutionMap
A substitution request for Node::Subs: variable name -> the node to put in its place.
Definition node.hpp:72
std::vector< std::shared_ptr< node::Variable > > VariableGroup
An ordered group of variables (the unit of homogenization / variable grouping).
Definition node.hpp:69
bmp::number< mpc_complex_backend< 0 >, bmp::et_on > complex_mp
The arbitrary-precision complex number type.
Definition mpfr_complex.hpp:58
boost::multiprecision::number< boost::multiprecision::mpfr_float_backend< 0 >, boost::multiprecision::et_on > real_mp
The arbitrary-precision real number type.
Definition mpfr_extensions.hpp:53
boost::multiprecision::number< boost::multiprecision::backends::gmp_rational, boost::multiprecision::et_on > mpq_rational
The exact rational number type.
Definition mpfr_extensions.hpp:55
Defines the abstract Node base class.
Provides the Number Node types, including Rational, Complex, and Integer.
Provides the abstract Operator Node type.
Provides the special numbers , , 1, 2, 0, as Nodes.
Provides the Variable Node class.
#define BERTINI_DEFAULT_VISITABLE()
macro for classes which want default Accept implementation, having nothing fancy to do when accepting...
Definition visitable.hpp:121