Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
variable.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//include/bertini2/function_tree/symbols/variable.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//include/bertini2/function_tree/symbols/variable.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 include/bertini2/function_tree/symbols/variable.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) 2015 - 2023 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// Created by Collins, James B. on 4/30/15.
30//
31//
32// include/bertini2/function_tree/symbols/variable.hpp: Declares the class Variable.
33
34
41#ifndef BERTINI_FUNCTION_TREE_VARIABLE_HPP
42#define BERTINI_FUNCTION_TREE_VARIABLE_HPP
43
46
47
48namespace bertini {
49namespace node{
58 class Variable : public virtual NamedSymbol, public virtual EnableSharedFromThisVirtual<Variable>
59 {
60 public:
61 BERTINI_DEFAULT_VISITABLE()
62
63
64 template<typename... Ts>
65 static
66 std::shared_ptr<Variable> Make(Ts&& ...ts){
67 return std::shared_ptr<Variable>( new Variable(ts...) );
68 }
69
70 private:
71 Variable(std::string new_name);
72
73 public:
74
75
76 virtual ~Variable() = default;
77
78
79
80 explicit operator std::string(){return name();}
81
82
83
84 // This sets the value for the variable
85 template <typename T>
86 void set_current_value(T const& val);
87
91 template <typename T>
92 void SetToNan();
93
97 template <typename T>
98 void SetToRand();
99
103 template <typename T>
104 void SetToRandUnit();
105
109 std::shared_ptr<Node> Differentiate(std::shared_ptr<Variable> const& v = nullptr) const override;
110
111 void Reset() const override;
112
118 int Degree(std::shared_ptr<Variable> const& v = nullptr) const override;
119
120
121 int Degree(VariableGroup const& vars) const override;
122
123 std::vector<int> MultiDegree(VariableGroup const& vars) const override;
124
125
126 void Homogenize(VariableGroup const& vars, std::shared_ptr<Variable> const& homvar) override;
127
128 bool IsHomogeneous(std::shared_ptr<Variable> const& v = nullptr) const override;
129
133 bool IsHomogeneous(VariableGroup const& vars) const override;
134
135
141 void precision(unsigned int prec) const override;
142
143 protected:
144
145 // Return current value of the variable.
146 dbl FreshEval_d(std::shared_ptr<Variable> const& diff_variable) const override;
147
148 void FreshEval_d(dbl& evaluation_value, std::shared_ptr<Variable> const& diff_variable) const override;
149
150
151 mpfr_complex FreshEval_mp(std::shared_ptr<Variable> const& diff_variable) const override;
152
153 void FreshEval_mp(mpfr_complex& evaluation_value, std::shared_ptr<Variable> const& diff_variable) const override;
154
155 Variable();
156 private:
157
158 friend class boost::serialization::access;
159
160 template <typename Archive>
161 void serialize(Archive& ar, const unsigned version) {
162 ar & boost::serialization::base_object<NamedSymbol>(*this);
163 }
164
165 };
166
167
168
169
170} // re: namespace node
171} // re: namespace bertini
172
173
174
175
176#endif
NamedSymbol(const std::string &new_name)
Definition symbol.cpp:54
const std::string & name() const
Definition symbol.cpp:45
void Homogenize(VariableGroup const &vars, std::shared_ptr< Variable > const &homvar) override
Definition variable.cpp:146
void Reset() const override
Definition variable.cpp:102
void precision(unsigned int prec) const override
Definition variable.cpp:170
int Degree(std::shared_ptr< Variable > const &v=nullptr) const override
Definition variable.cpp:109
dbl FreshEval_d(std::shared_ptr< Variable > const &diff_variable) const override
Definition variable.cpp:178
mpfr_complex FreshEval_mp(std::shared_ptr< Variable > const &diff_variable) const override
Definition variable.cpp:189
std::shared_ptr< Node > Differentiate(std::shared_ptr< Variable > const &v=nullptr) const override
Definition variable.cpp:94
void SetToRandUnit()
Changes the value of the variable to be a random complex number, of magnitude 1.
Definition variable.cpp:87
void SetToRand()
Changes the value of the variable to be a random complex number.
Definition variable.cpp:78
void SetToNan()
Changes the value of the variable to be not-a-number.
Definition variable.cpp:68
std::vector< int > MultiDegree(VariableGroup const &vars) const override
Definition variable.cpp:134
bool IsHomogeneous(std::shared_ptr< Variable > const &v=nullptr) const override
Definition variable.cpp:151
Provides the differential Node class.
Defines the abstract Symbol and NamedSymbol classes,.