Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
differential.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//differential.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//differential.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with differential.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
22// differential.hpp: Declares the class SpecialNumber.
23
30
31#ifndef BERTINI_NODE_DIFFERENTIAL_HPP
32#define BERTINI_NODE_DIFFERENTIAL_HPP
33
34#include <memory>
38
39
40
41namespace bertini {
42namespace node{
43 class Variable;
44
45
51 class Differential : public NamedSymbol
52 {
53 public:
55
56
57
58 template<typename... Ts>
59 static
60 std::shared_ptr<Differential> Make(Ts&& ...ts){
61 return std::static_pointer_cast<Differential>(Intern(std::shared_ptr<Node>( new Differential(ts...) )));
62 }
63
64
65 private:
69 Differential(std::shared_ptr<const Variable> diff_variable, std::string var_name);
70
71 public:
72
73
74
76 const std::shared_ptr<const Variable>& GetVariable() const;
77
78
79 void print(std::ostream & target) const override;
80
81
82
86 std::shared_ptr<Node> Differentiate(std::shared_ptr<Variable> const& v = nullptr) const override;
87
88 virtual ~Differential() = default;
89
90
91
92
96 int Degree(std::shared_ptr<Variable> const& v = nullptr) const override;
97
98 int Degree(VariableGroup const& vars) const override;
99
100 std::vector<int> MultiDegreeImpl(VariableGroup const& vars) const override;
101
102 bool IsHomogeneous(std::shared_ptr<Variable> const& v = nullptr) const override;
103
107 bool IsHomogeneous(VariableGroup const& vars) const override;
108
109
115
116
117 protected:
118 // This should never be called for a Differential. Only for Jacobians.
119
120
121
122
123
124
125
126 private:
127 Differential() = default;
128 std::shared_ptr<const Variable> differential_variable_;
129
130
132
133 template<class Archive>
134 void save(Archive & ar, const unsigned int /*version*/) const
135 {
136 ar & boost::serialization::base_object<NamedSymbol>(*this);
137 ar & differential_variable_;
138 // ar & const_cast<std::shared_ptr<const Variable> >(differential_variable_);
139 }
140
141 template<class Archive>
142 void load(Archive & ar, const unsigned int /*version*/)
143 {
144 ar & boost::serialization::base_object<NamedSymbol>(*this);
145 ar & std::const_pointer_cast<Variable>(differential_variable_);
146 }
147
148 // BOOST_SERIALIZATION_SPLIT_MEMBER()
149
150 };
151
152} // re: namespace node
153} // re: namespace bertini
154
155#endif
Provides the differential type for differentiation of expression trees.
Definition differential.hpp:52
bool IsHomogeneous(VariableGroup const &vars) const override
Check for homogeneity, 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 oth...
int Degree(std::shared_ptr< Variable > const &v=nullptr) const override
Compute the degree with respect to a single variable.
std::vector< int > MultiDegreeImpl(VariableGroup const &vars) const override
Per-node-type multidegree.
int Degree(VariableGroup const &vars) const override
Compute the overall degree with respect to a variable group.
virtual ~Differential()=default
const std::shared_ptr< const Variable > & GetVariable() const
static std::shared_ptr< Differential > Make(Ts &&...ts)
Construct (and intern) a Differential node.
Definition differential.hpp:60
std::shared_ptr< Node > Differentiate(std::shared_ptr< Variable > const &v=nullptr) const override
Differentiates a number.
friend class boost::serialization::access
Definition differential.hpp:131
void print(std::ostream &target) const override
Virtual method for printing Nodes to arbitrary output streams.
NamedSymbol(const std::string &new_name)
Parameterized constructor, sets the name of the symbol.
Represents variable leaves in the function tree.
Definition variable.hpp:48
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::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 Node base class.
Provides the Number Node types, including Rational, Complex, and Integer.
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