31#ifndef BERTINI_FUNCTION_TREE_VARIABLE_HPP
32#define BERTINI_FUNCTION_TREE_VARIABLE_HPP
54 template<
typename... Ts>
56 std::shared_ptr<Variable>
Make(Ts&& ...ts){
57 return std::static_pointer_cast<Variable>(
Intern(std::shared_ptr<Node>(
new Variable(ts...) )));
73 std::size_t h =
typeid(Variable).hash_code();
79 auto o =
dynamic_cast<Variable const*
>(&other);
80 return o &&
name() == o->name();
85 explicit operator std::string(){
return name();}
92 std::shared_ptr<Node>
Differentiate(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
109 int Degree(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
117 bool IsHomogeneous(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
131 template <
typename Archive>
132 void serialize(Archive& ar,
const unsigned ) {
133 ar & boost::serialization::base_object<NamedSymbol>(*
this);
NamedSymbol(const std::string &new_name)
Parameterized constructor, sets the name of the symbol.
const std::string & name() const
Get the name of the named symbol.
An interface for all nodes in a function tree, and for a function object as well.
Definition node.hpp:114
static void HashCombine(std::size_t &seed, std::size_t value)
Combine an extra value into a running hash (boost::hash_combine recipe).
Definition node.hpp:384
int Degree(VariableGroup const &vars) const override
Compute the overall degree with respect to a variable group.
bool IsHomogeneous(VariableGroup const &vars) const override
Check for homogeneity, with respect to a variable group.
int Degree(std::shared_ptr< Variable > const &v=nullptr) const override
Compute the degree with respect to a single variable.
std::shared_ptr< Node > Differentiate(std::shared_ptr< Variable > const &v=nullptr) const override
Differentiates a variable.
virtual ~Variable()=default
std::shared_ptr< Node > Subs(SubstitutionMap const &substitutions) const override
Substitutes this variable: if its name is a key in substitutions, returns the associated replacement ...
friend class boost::serialization::access
Definition variable.hpp:129
static std::shared_ptr< Variable > Make(Ts &&...ts)
Construct (and intern) a Variable node.
Definition variable.hpp:56
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.
Definition variable.hpp:71
bool IsSame(Node const &other) const override
Order-sensitive structural equality, shallow given interned children.
Definition variable.hpp:77
std::vector< int > MultiDegreeImpl(VariableGroup const &vars) const override
Per-node-type multidegree.
Provides the differential Node class.
Definition canonical.hpp:56
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,...
Definition algorithm_builder.hpp:36
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
Defines the abstract Symbol and NamedSymbol classes,.
#define BERTINI_DEFAULT_VISITABLE()
macro for classes which want default Accept implementation, having nothing fancy to do when accepting...
Definition visitable.hpp:121