Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
function.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//bertini2/function_tree/roots/function.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//bertini2/function_tree/roots/function.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 bertini2/function_tree/roots/function.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) 2015 - 2021 by 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// individual authors of this file include:
23// James Collins
24// West Texas A&M University
25// Spring, Summer 2015
26//
27// silviana amethyst, university of wisconsin-eau claire
28//
29// silviana amethyst
30// UWEC
31// Spring 2018
32//
33// Created by Collins, James B. on 4/30/15.
34//
35//
36// bertini2/function_tree/roots/function.hpp: Declares the class Function.
37
44
45
46#ifndef BERTINI_FUNCTION_NODE_HPP
47#define BERTINI_FUNCTION_NODE_HPP
48
49
51
52
53
54namespace bertini {
55namespace node{
56
57
58
59 class Handle : public virtual NamedSymbol
60 {
62
63
64 public:
65
69 void print(std::ostream & target) const override;
70
71
72 Handle(std::string const& new_name);
73
74
78 Handle(const std::shared_ptr<Node> & entry, std::string const& name = "unnamed_function");
79
80
81 protected:
82
83 Handle() = default;
84
85 public:
89 void SetRoot(std::shared_ptr<Node> const& entry);
90
91
95 void EnsureNotEmpty() const;
96
97
101 void Reset() const override;
102
103
104
108 const std::shared_ptr<Node>& EntryNode() const;
109
110
114 std::shared_ptr<Node> Differentiate(std::shared_ptr<Variable> const& v = nullptr) const override;
115
119 int Degree(std::shared_ptr<Variable> const& v = nullptr) const override;
120
121
122 int Degree(VariableGroup const& vars) const override;
123
124
125
129 std::vector<int> MultiDegree(VariableGroup const& vars) const override;
130
131
132 void Homogenize(VariableGroup const& vars, std::shared_ptr<Variable> const& homvar) override;
133
134 bool IsHomogeneous(std::shared_ptr<Variable> const& v = nullptr) const override;
135
139 bool IsHomogeneous(VariableGroup const& vars) const override;
140
141
147 void precision(unsigned int prec) const override;
148
149
150
151 protected:
152
156 dbl FreshEval_d(std::shared_ptr<Variable> const& diff_variable) const override;
157
161 void FreshEval_d(dbl& evaluation_value, std::shared_ptr<Variable> const& diff_variable) const override;
162
163
167 mpfr_complex FreshEval_mp(std::shared_ptr<Variable> const& diff_variable) const override;
168
172 void FreshEval_mp(mpfr_complex& evaluation_value, std::shared_ptr<Variable> const& diff_variable) const override;
173
174
175 std::shared_ptr<Node> entry_node_ = nullptr;
176
177 private:
178
179
180
181 friend class boost::serialization::access;
182
183 template <typename Archive>
184 void serialize(Archive& ar, const unsigned version) {
185 ar & boost::serialization::base_object<NamedSymbol>(*this);
186 ar & entry_node_;
187 }
188
189 }; // class Function
190
191
192
193
194}} // namespaces
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209namespace bertini {
210namespace node{
211
217 class Function : public virtual Handle, public virtual EnableSharedFromThisVirtual<Function>
218 {
219 public:
220 BERTINI_DEFAULT_VISITABLE()
221
222 template<typename... Ts>
223 static
224 std::shared_ptr<Function> Make(Ts&& ...ts){
225 return std::shared_ptr<Function>( new Function(ts...) );
226 }
227
228 template<typename... Ts>
229 static
230 std::shared_ptr<Function> MakeInPlace(Function* ptr, Ts&& ...ts){
231 return std::shared_ptr<Function>( new(ptr) Function(ts...) );
232 }
233
234 private:
235
236 Function(std::string const& new_name);
237
238
242 Function(const std::shared_ptr<Node> & entry, std::string const& name = "unnamed_function");
243
244 public:
245
246
247
248 virtual ~Function() = default;
249
250
251
252 protected:
253
254
255 Function() = default;
256
257
258 private:
259 friend class boost::serialization::access;
260 // template<class Archive> friend void boost::serialization::load_construct_data(Archive & ar, Function * t, const unsigned int file_version);
261 // template<class Archive> friend void boost::serialization::save_construct_data(Archive & ar, const Function * t, const unsigned int file_version);
262
263 template <typename Archive>
264 void serialize(Archive& ar, const unsigned version) {
265 ar & boost::serialization::base_object<Handle>(*this);
266 }
267 };
268
269} // re: namespace node
270} // re: namespace bertini
271
272
273
274#endif
Symbols which have names are named symbols.
Definition symbol.hpp:88
const std::string & name() const
Definition symbol.cpp:45
virtual void print(std::ostream &target) const =0
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