44#ifndef BERTINI_NODE_NUMBER_HPP
45#define BERTINI_NODE_NUMBER_HPP
70 void Reset()
const override;
84 int Degree(std::shared_ptr<Variable>
const& v =
nullptr)
const override
95 int Degree(VariableGroup
const& vars)
const override
107 std::vector<int>
MultiDegree(VariableGroup
const& vars)
const override
109 return std::vector<int>(vars.size(), 0);
117 void Homogenize(VariableGroup
const& vars, std::shared_ptr<Variable>
const& homvar)
override
127 bool IsHomogeneous(std::shared_ptr<Variable>
const& v =
nullptr)
const override
146 void precision(
unsigned int prec)
const override;
151 std::shared_ptr<Node>
Differentiate(std::shared_ptr<Variable>
const& v =
nullptr)
const override;
156 friend class boost::serialization::access;
158 template <
typename Archive>
159 void serialize(Archive& ar,
const unsigned version) {
160 ar & boost::serialization::base_object<Symbol>(*
this);
172 class Integer :
public virtual Number,
public virtual EnableSharedFromThisVirtual<Integer>
179 Integer(Integer
const&) =
default;
181 ~Integer() =
default;
186 void print(std::ostream & target)
const override;
188 template<
typename... Ts>
190 std::shared_ptr<Integer> Make(Ts&& ...ts){
191 return std::shared_ptr<Integer>(
new Integer(ts...) );
199 Integer(
int val) : true_value_(val)
203 Integer(mpz_int val) : true_value_(val)
207 Integer(std::string
const& val) : true_value_(val)
213 dbl FreshEval_d(std::shared_ptr<Variable>
const& diff_variable)
const override;
215 void FreshEval_d(dbl& evaluation_value, std::shared_ptr<Variable>
const& diff_variable)
const override;
218 mpfr_complex FreshEval_mp(std::shared_ptr<Variable>
const& diff_variable)
const override;
220 void FreshEval_mp(mpfr_complex& evaluation_value, std::shared_ptr<Variable>
const& diff_variable)
const override;
225 friend class boost::serialization::access;
229 template <
typename Archive>
230 void serialize(Archive& ar,
const unsigned version) {
231 ar & boost::serialization::base_object<Number>(*
this);
249 class Float :
public virtual Number,
public virtual EnableSharedFromThisVirtual<Float>
252 BERTINI_DEFAULT_VISITABLE()
262 void print(std::ostream & target)
const override;
265 template<
typename... Ts>
267 std::shared_ptr<Float> Make(Ts&& ...ts){
268 return std::shared_ptr<Float>(
new Float(ts...) );
276 Float(mpfr_complex
const& val) : highest_precision_value_(val)
280 Float(mpfr_float
const& rval, mpfr_float
const& ival = 0) : highest_precision_value_(rval,ival)
284 Float(std::string
const& val) : highest_precision_value_(val)
288 Float(std::string
const& rval, std::string
const& ival) : highest_precision_value_(rval,ival)
291 dbl FreshEval_d(std::shared_ptr<Variable>
const& diff_variable)
const override;
293 void FreshEval_d(dbl& evaluation_value, std::shared_ptr<Variable>
const& diff_variable)
const override;
296 mpfr_complex FreshEval_mp(std::shared_ptr<Variable>
const& diff_variable)
const override;
298 void FreshEval_mp(mpfr_complex& evaluation_value, std::shared_ptr<Variable>
const& diff_variable)
const override;
301 mpfr_complex highest_precision_value_;
303 friend class boost::serialization::access;
305 template <
typename Archive>
306 void serialize(Archive& ar,
const unsigned version) {
307 ar & boost::serialization::base_object<Number>(*
this);
308 ar &
const_cast<mpfr_complex &
>(highest_precision_value_);
322 class Rational :
public virtual Number,
public virtual EnableSharedFromThisVirtual<Rational>
325 BERTINI_DEFAULT_VISITABLE()
327 using mpq_rational = bertini::mpq_rational;
332 Rational(
int,
int) =
delete;
334 ~Rational() =
default;
341 template<
unsigned long Digits = 50>
353 template<
int Digits = 50>
360 void print(std::ostream & target)
const override;
366 template<
typename... Ts>
368 std::shared_ptr<Rational> Make(Ts&& ...ts){
369 return std::shared_ptr<Rational>(
new Rational(ts...) );
376 Rational(
int val) : true_value_real_(val), true_value_imag_(0)
380 Rational(
int val_real_numerator,
int val_real_denomenator,
381 int val_imag_numerator,
int val_imag_denomenator)
383 true_value_real_(val_real_numerator,val_real_denomenator), true_value_imag_(val_imag_numerator,val_imag_denomenator)
387 Rational(std::string val) : true_value_real_(val), true_value_imag_(0)
391 Rational(std::string val_real, std::string val_imag) : true_value_real_(val_real), true_value_imag_(val_imag)
395 Rational(mpq_rational
const& val_real, mpq_rational
const& val_imag = 0) : true_value_real_(val_real), true_value_imag_(val_imag)
400 dbl FreshEval_d(std::shared_ptr<Variable>
const& diff_variable)
const override;
402 void FreshEval_d(dbl& evaluation_value, std::shared_ptr<Variable>
const& diff_variable)
const override;
405 mpfr_complex FreshEval_mp(std::shared_ptr<Variable>
const& diff_variable)
const override;
407 void FreshEval_mp(mpfr_complex& evaluation_value, std::shared_ptr<Variable>
const& diff_variable)
const override;
410 mpq_rational true_value_real_, true_value_imag_;
411 Rational() =
default;
412 friend class boost::serialization::access;
414 template <
typename Archive>
415 void serialize(Archive& ar,
const unsigned version) {
416 ar & boost::serialization::base_object<Number>(*
this);
417 ar &
const_cast<mpq_rational &
>(true_value_real_);
418 ar &
const_cast<mpq_rational &
>(true_value_imag_);
void print(std::ostream &target) const override
Definition number.cpp:97
void print(std::ostream &target) const override
Definition number.cpp:62
Abstract Number type from which other Numbers derive.
Definition number.hpp:63
std::vector< int > MultiDegree(VariableGroup const &vars) const override
Get the multidegree of this node.
Definition number.hpp:107
int Degree(std::shared_ptr< Variable > const &v=nullptr) const override
Get the degree of this node.
Definition number.hpp:84
bool IsHomogeneous(std::shared_ptr< Variable > const &v=nullptr) const override
Is this node homogeneous?
Definition number.hpp:127
void Reset() const override
Definition number.cpp:36
void Homogenize(VariableGroup const &vars, std::shared_ptr< Variable > const &homvar) override
Homogenize this node.
Definition number.hpp:117
int Degree(VariableGroup const &vars) const override
Get the degree of this node.
Definition number.hpp:95
std::shared_ptr< Node > Differentiate(std::shared_ptr< Variable > const &v=nullptr) const override
Differentiate a number.
Definition number.cpp:50
bool IsHomogeneous(VariableGroup const &vars) const override
Definition number.hpp:135
The Rational number type for Bertini2 expression trees.
Definition number.hpp:323
void print(std::ostream &target) const override
Definition number.cpp:131
static Rational Rand()
Get a random complex rational node. Numerator and denominator will have about 50 digits.
Definition number.hpp:343
static Rational RandReal()
Get a random real rational node. Numerator and denominator will have about 50 digits.
Definition number.hpp:355
Abstract symbol class.
Definition symbol.hpp:57
mpq_rational RandomRat()
Definition random.hpp:61
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