SymEngine::RealDouble Class Reference

RealDouble Class to hold double values. More...

#include <real_double.h>

+ Inheritance diagram for SymEngine::RealDouble:
+ Collaboration diagram for SymEngine::RealDouble:

Public Member Functions

virtual void accept (Visitor &v) const
 
virtual void accept (EvalRealDoubleVisitorFinal &v) const
 
 RealDouble (double i)
 Constructor of RealDouble class.
 
virtual hash_t __hash__ () const
 
virtual bool __eq__ (const Basic &o) const
 
virtual int compare (const Basic &o) const
 
virtual bool is_positive () const
 
virtual bool is_negative () const
 
double as_double () const
 
virtual bool is_exact () const
 
virtual Evaluateget_eval () const
 Get Evaluate singleton to evaluate numerically.
 
virtual bool is_zero () const
 
virtual bool is_one () const
 
virtual bool is_minus_one () const
 
virtual bool is_complex () const
 
RCP< const Numberaddreal (const Integer &other) const
 
RCP< const Numberaddreal (const Rational &other) const
 
RCP< const Numberaddreal (const Complex &other) const
 
RCP< const Numberaddreal (const RealDouble &other) const
 
virtual RCP< const Numberadd (const Number &other) const
 Converts the param other appropriately and then calls addreal
 
RCP< const Numbersubreal (const Integer &other) const
 
RCP< const Numbersubreal (const Rational &other) const
 
RCP< const Numbersubreal (const Complex &other) const
 
RCP< const Numbersubreal (const RealDouble &other) const
 
virtual RCP< const Numbersub (const Number &other) const
 Converts the param other appropriately and then calls subreal
 
RCP< const Numberrsubreal (const Integer &other) const
 
RCP< const Numberrsubreal (const Rational &other) const
 
RCP< const Numberrsubreal (const Complex &other) const
 
virtual RCP< const Numberrsub (const Number &other) const
 Converts the param other appropriately and then calls subreal
 
RCP< const Numbermulreal (const Integer &other) const
 
RCP< const Numbermulreal (const Rational &other) const
 
RCP< const Numbermulreal (const Complex &other) const
 
RCP< const Numbermulreal (const RealDouble &other) const
 
virtual RCP< const Numbermul (const Number &other) const
 Converts the param other appropriately and then calls mulreal
 
RCP< const Numberdivreal (const Integer &other) const
 
RCP< const Numberdivreal (const Rational &other) const
 
RCP< const Numberdivreal (const Complex &other) const
 
RCP< const Numberdivreal (const RealDouble &other) const
 
virtual RCP< const Numberdiv (const Number &other) const
 Converts the param other appropriately and then calls divreal
 
RCP< const Numberrdivreal (const Integer &other) const
 
RCP< const Numberrdivreal (const Rational &other) const
 
RCP< const Numberrdivreal (const Complex &other) const
 
virtual RCP< const Numberrdiv (const Number &other) const
 Converts the param other appropriately and then calls divreal
 
RCP< const Numberpowreal (const Integer &other) const
 
RCP< const Numberpowreal (const Rational &other) const
 
RCP< const Numberpowreal (const Complex &other) const
 
RCP< const Numberpowreal (const RealDouble &other) const
 
virtual RCP< const Numberpow (const Number &other) const
 Converts the param other appropriately and then calls powreal
 
RCP< const Numberrpowreal (const Integer &other) const
 
RCP< const Numberrpowreal (const Rational &other) const
 
RCP< const Numberrpowreal (const Complex &other) const
 
virtual RCP< const Numberrpow (const Number &other) const
 Converts the param other appropriately and then calls powreal
 
- Public Member Functions inherited from SymEngine::Number
virtual RCP< const Basicconjugate () const
 
bool is_exact_zero () const
 
virtual vec_basic get_args () const
 Returns the list of arguments.
 
virtual bool is_perfect_power (bool is_expected=false) const
 
virtual bool nth_root (const Ptr< RCP< const Number >> &, unsigned long n) const
 
- Public Member Functions inherited from SymEngine::Basic
TypeID get_type_code () const
 
 Basic ()
 Constructor.
 
 Basic (const Basic &)=delete
 Delete the copy constructor and assignment.
 
Basicoperator= (const Basic &)=delete
 Assignment operator in continuation with above.
 
 Basic (Basic &&)=delete
 Delete the move constructor and assignment.
 
Basicoperator= (Basic &&)=delete
 Assignment operator in continuation with above.
 
hash_t hash () const
 
bool __neq__ (const Basic &o) const
 true if this is not equal to o. More...
 
int __cmp__ (const Basic &o) const
 Comparison operator.
 
std::string __str__ () const
 
RCP< const Basicsubs (const map_basic_basic &subs_dict) const
 Substitutes 'subs_dict' into 'self'.
 
RCP< const Basicxreplace (const map_basic_basic &subs_dict) const
 
virtual RCP< const Basicexpand_as_exp () const
 expands the special function in terms of exp function
 
RCP< const Basicdiff (const RCP< const Symbol > &x, bool cache=true) const
 
- Public Member Functions inherited from SymEngine::EnableRCPFromThis< Basic >
RCP< Basicrcp_from_this ()
 Get RCP<T> pointer to self (it will cast the pointer to T)
 
RCP< const Basicrcp_from_this () const
 Get RCP<const T> pointer to self (it will cast the pointer to const T)
 
RCP< const T2 > rcp_from_this_cast () const
 Get RCP<T2> pointer to self (it will cast the pointer to T2)
 
unsigned int use_count () const
 

Data Fields

double i
 
- Data Fields inherited from SymEngine::Basic
TypeID type_code_
 

Static Public Attributes

static const TypeID type_code_id = SYMENGINE_REAL_DOUBLE
 

Detailed Description

RealDouble Class to hold double values.

Definition at line 19 of file real_double.h.

Member Function Documentation

◆ __eq__()

bool SymEngine::RealDouble::__eq__ ( const Basic o) const
virtual

Equality comparator

Parameters
o- Object to be compared with
Returns
whether the 2 objects are equal

Implements SymEngine::Basic.

Definition at line 25 of file real_double.cpp.

26 {
27  if (is_a<RealDouble>(o)) {
28  const RealDouble &s = down_cast<const RealDouble &>(o);
29  return this->i == s.i;
30  }
31  return false;
32 }
RealDouble(double i)
Constructor of RealDouble class.
Definition: real_double.cpp:12

◆ __hash__()

hash_t SymEngine::RealDouble::__hash__ ( ) const
virtual
Returns
size of the hash

Implements SymEngine::Basic.

Definition at line 18 of file real_double.cpp.

19 {
20  hash_t seed = SYMENGINE_REAL_DOUBLE;
21  hash_combine<double>(seed, i);
22  return seed;
23 }

◆ addreal() [1/4]

RCP<const Number> SymEngine::RealDouble::addreal ( const Complex other) const
inline

Add RealDoubles

Parameters
otherof type Complex

Definition at line 104 of file real_double.h.

105  {
106  return number(i
107  + std::complex<double>(mp_get_d(other.real_),
108  mp_get_d(other.imaginary_)));
109  }

◆ addreal() [2/4]

RCP<const Number> SymEngine::RealDouble::addreal ( const Integer other) const
inline

Add RealDoubles

Parameters
otherof type Integer

Definition at line 86 of file real_double.h.

87  {
88  return make_rcp<const RealDouble>(i
89  + mp_get_d(other.as_integer_class()));
90  }

◆ addreal() [3/4]

RCP<const Number> SymEngine::RealDouble::addreal ( const Rational other) const
inline

Add RealDoubles

Parameters
otherof type Rational

Definition at line 95 of file real_double.h.

96  {
97  return make_rcp<const RealDouble>(
98  i + mp_get_d(other.as_rational_class()));
99  }

◆ addreal() [4/4]

RCP<const Number> SymEngine::RealDouble::addreal ( const RealDouble other) const
inline

Add RealDoubles

Parameters
otherof type RealDouble

Definition at line 114 of file real_double.h.

115  {
116  return make_rcp<const RealDouble>(i + other.i);
117  }

◆ as_double()

double SymEngine::RealDouble::as_double ( ) const
inline
Returns
self as a double

Definition at line 47 of file real_double.h.

48  {
49  return i;
50  }

◆ compare()

int SymEngine::RealDouble::compare ( const Basic o) const
virtual

Returns -1, 0, 1 for this < o, this == o, this > o. This method is used when you want to sort things like x+y+z into canonical order. This function assumes that o is the same type as this. Use __cmp__ if you want general comparison.

Implements SymEngine::Basic.

Definition at line 34 of file real_double.cpp.

35 {
36  SYMENGINE_ASSERT(is_a<RealDouble>(o))
37  const RealDouble &s = down_cast<const RealDouble &>(o);
38  if (i == s.i)
39  return 0;
40  return i < s.i ? -1 : 1;
41 }

◆ divreal() [1/4]

RCP<const Number> SymEngine::RealDouble::divreal ( const Complex other) const
inline

Divide RealDoubles

Parameters
otherof type Complex

Definition at line 305 of file real_double.h.

306  {
307  return number(i
308  / std::complex<double>(mp_get_d(other.real_),
309  mp_get_d(other.imaginary_)));
310  }

◆ divreal() [2/4]

RCP<const Number> SymEngine::RealDouble::divreal ( const Integer other) const
inline

Divide RealDoubles

Parameters
otherof type Integer

Definition at line 287 of file real_double.h.

288  {
289  return make_rcp<const RealDouble>(i
290  / mp_get_d(other.as_integer_class()));
291  }

◆ divreal() [3/4]

RCP<const Number> SymEngine::RealDouble::divreal ( const Rational other) const
inline

Divide RealDoubles

Parameters
otherof type Rational

Definition at line 296 of file real_double.h.

297  {
298  return make_rcp<const RealDouble>(
299  i / mp_get_d(other.as_rational_class()));
300  }

◆ divreal() [4/4]

RCP<const Number> SymEngine::RealDouble::divreal ( const RealDouble other) const
inline

Divide RealDoubles

Parameters
otherof type RealDouble

Definition at line 315 of file real_double.h.

316  {
317  return make_rcp<const RealDouble>(i / other.i);
318  }

◆ is_complex()

virtual bool SymEngine::RealDouble::is_complex ( ) const
inlinevirtual
Returns
false

Implements SymEngine::Number.

Definition at line 78 of file real_double.h.

79  {
80  return false;
81  }

◆ is_exact()

virtual bool SymEngine::RealDouble::is_exact ( ) const
inlinevirtual
Returns
true if this number is an exact number

Reimplemented from SymEngine::Number.

Definition at line 52 of file real_double.h.

53  {
54  return false;
55  }

◆ is_minus_one()

virtual bool SymEngine::RealDouble::is_minus_one ( ) const
inlinevirtual
Returns
false

Implements SymEngine::Number.

Definition at line 72 of file real_double.h.

73  {
74  return false;
75  }

◆ is_negative()

virtual bool SymEngine::RealDouble::is_negative ( ) const
inlinevirtual
Returns
true if negative

Implements SymEngine::Number.

Definition at line 42 of file real_double.h.

43  {
44  return i < 0;
45  }

◆ is_one()

virtual bool SymEngine::RealDouble::is_one ( ) const
inlinevirtual
Returns
false

Implements SymEngine::Number.

Definition at line 66 of file real_double.h.

67  {
68  return false;
69  }

◆ is_positive()

virtual bool SymEngine::RealDouble::is_positive ( ) const
inlinevirtual
Returns
true if positive

Implements SymEngine::Number.

Definition at line 37 of file real_double.h.

38  {
39  return i > 0;
40  }

◆ is_zero()

virtual bool SymEngine::RealDouble::is_zero ( ) const
inlinevirtual
Returns
true when equals to 0

Implements SymEngine::Number.

Definition at line 60 of file real_double.h.

61  {
62  return this->i == 0.0;
63  }

◆ mulreal() [1/4]

RCP<const Number> SymEngine::RealDouble::mulreal ( const Complex other) const
inline

Multiply RealDoubles

Parameters
otherof type Complex

Definition at line 253 of file real_double.h.

254  {
255  return number(i
256  * std::complex<double>(mp_get_d(other.real_),
257  mp_get_d(other.imaginary_)));
258  }

◆ mulreal() [2/4]

RCP<const Number> SymEngine::RealDouble::mulreal ( const Integer other) const
inline

Multiply RealDoubles

Parameters
otherof type Integer

Definition at line 232 of file real_double.h.

233  {
234  if (other.is_zero()) {
235  return zero;
236  }
237  return make_rcp<const RealDouble>(i
238  * mp_get_d(other.as_integer_class()));
239  }

◆ mulreal() [3/4]

RCP<const Number> SymEngine::RealDouble::mulreal ( const Rational other) const
inline

Multiply RealDoubles

Parameters
otherof type Rational

Definition at line 244 of file real_double.h.

245  {
246  return make_rcp<const RealDouble>(
247  i * mp_get_d(other.as_rational_class()));
248  }

◆ mulreal() [4/4]

RCP<const Number> SymEngine::RealDouble::mulreal ( const RealDouble other) const
inline

Multiply RealDoubles

Parameters
otherof type RealDouble

Definition at line 263 of file real_double.h.

264  {
265  return make_rcp<const RealDouble>(i * other.i);
266  }

◆ powreal() [1/4]

RCP<const Number> SymEngine::RealDouble::powreal ( const Complex other) const
inline

Raise RealDouble to power other

Parameters
otherof type Complex

Definition at line 403 of file real_double.h.

404  {
405  return number(
406  std::pow(i, std::complex<double>(mp_get_d(other.real_),
407  mp_get_d(other.imaginary_))));
408  }
T pow(T... args)

◆ powreal() [2/4]

RCP<const Number> SymEngine::RealDouble::powreal ( const Integer other) const
inline

Raise RealDouble to power other

Parameters
otherof type Integer

Definition at line 381 of file real_double.h.

382  {
383  return make_rcp<const RealDouble>(
384  std::pow(i, mp_get_d(other.as_integer_class())));
385  }

◆ powreal() [3/4]

RCP<const Number> SymEngine::RealDouble::powreal ( const Rational other) const
inline

Raise RealDouble to power other

Parameters
otherof type Rational

Definition at line 390 of file real_double.h.

391  {
392  if (i < 0) {
393  return number(std::pow(std::complex<double>(i),
394  mp_get_d(other.as_rational_class())));
395  }
396  return make_rcp<const RealDouble>(
397  std::pow(i, mp_get_d(other.as_rational_class())));
398  }

◆ powreal() [4/4]

RCP<const Number> SymEngine::RealDouble::powreal ( const RealDouble other) const
inline

Raise RealDouble to power other

Parameters
otherof type RealDouble

Definition at line 413 of file real_double.h.

414  {
415  if (i < 0) {
416  return number(std::pow(std::complex<double>(i), other.i));
417  }
418  return make_rcp<const RealDouble>(std::pow(i, other.i));
419  }

◆ rdivreal() [1/3]

RCP<const Number> SymEngine::RealDouble::rdivreal ( const Complex other) const
inline

Divide RealDoubles

Parameters
otherof type Complex

Definition at line 357 of file real_double.h.

358  {
359  return number(std::complex<double>(mp_get_d(other.real_),
360  mp_get_d(other.imaginary_))
361  / i);
362  }

◆ rdivreal() [2/3]

RCP<const Number> SymEngine::RealDouble::rdivreal ( const Integer other) const
inline

Divide RealDoubles

Parameters
otherof type Integer

Definition at line 339 of file real_double.h.

340  {
341  return make_rcp<const RealDouble>(mp_get_d(other.as_integer_class())
342  / i);
343  }

◆ rdivreal() [3/3]

RCP<const Number> SymEngine::RealDouble::rdivreal ( const Rational other) const
inline

Divide RealDoubles

Parameters
otherof type Rational

Definition at line 348 of file real_double.h.

349  {
350  return make_rcp<const RealDouble>(mp_get_d(other.as_rational_class())
351  / i);
352  }

◆ rpowreal() [1/3]

RCP<const Number> SymEngine::RealDouble::rpowreal ( const Complex other) const
inline

Raise other to power RealDouble

Parameters
otherof type Complex

Definition at line 466 of file real_double.h.

467  {
468  return number(std::pow(std::complex<double>(mp_get_d(other.real_),
469  mp_get_d(other.imaginary_)),
470  i));
471  }

◆ rpowreal() [2/3]

RCP<const Number> SymEngine::RealDouble::rpowreal ( const Integer other) const
inline

Raise other to power RealDouble

Parameters
otherof type Integer

Definition at line 440 of file real_double.h.

441  {
442  if (other.is_negative()) {
443  return number(std::pow(mp_get_d(other.as_integer_class()),
445  }
446  return make_rcp<const RealDouble>(
447  std::pow(mp_get_d(other.as_integer_class()), i));
448  }

◆ rpowreal() [3/3]

RCP<const Number> SymEngine::RealDouble::rpowreal ( const Rational other) const
inline

Raise other to power RealDouble

Parameters
otherof type Rational

Definition at line 453 of file real_double.h.

454  {
455  if (other.is_negative()) {
456  return number(std::pow(std::complex<double>(i),
457  mp_get_d(other.as_rational_class())));
458  }
459  return make_rcp<const RealDouble>(
460  std::pow(mp_get_d(other.as_rational_class()), i));
461  }

◆ rsubreal() [1/3]

RCP<const Number> SymEngine::RealDouble::rsubreal ( const Complex other) const
inline

Subtract RealDoubles

Parameters
otherof type Complex

Definition at line 208 of file real_double.h.

209  {
210  return number(-i
211  + std::complex<double>(mp_get_d(other.real_),
212  mp_get_d(other.imaginary_)));
213  }

◆ rsubreal() [2/3]

RCP<const Number> SymEngine::RealDouble::rsubreal ( const Integer other) const
inline

Subtract RealDoubles

Parameters
otherof type Integer

Definition at line 190 of file real_double.h.

191  {
192  return make_rcp<const RealDouble>(mp_get_d(other.as_integer_class())
193  - i);
194  }

◆ rsubreal() [3/3]

RCP<const Number> SymEngine::RealDouble::rsubreal ( const Rational other) const
inline

Subtract RealDoubles

Parameters
otherof type Rational

Definition at line 199 of file real_double.h.

200  {
201  return make_rcp<const RealDouble>(mp_get_d(other.as_rational_class())
202  - i);
203  }

◆ subreal() [1/4]

RCP<const Number> SymEngine::RealDouble::subreal ( const Complex other) const
inline

Subtract RealDoubles

Parameters
otherof type Complex

Definition at line 156 of file real_double.h.

157  {
158  return number(i
159  - std::complex<double>(mp_get_d(other.real_),
160  mp_get_d(other.imaginary_)));
161  }

◆ subreal() [2/4]

RCP<const Number> SymEngine::RealDouble::subreal ( const Integer other) const
inline

Subtract RealDoubles

Parameters
otherof type Integer

Definition at line 138 of file real_double.h.

139  {
140  return make_rcp<const RealDouble>(i
141  - mp_get_d(other.as_integer_class()));
142  }

◆ subreal() [3/4]

RCP<const Number> SymEngine::RealDouble::subreal ( const Rational other) const
inline

Subtract RealDoubles

Parameters
otherof type Rational

Definition at line 147 of file real_double.h.

148  {
149  return make_rcp<const RealDouble>(
150  i - mp_get_d(other.as_rational_class()));
151  }

◆ subreal() [4/4]

RCP<const Number> SymEngine::RealDouble::subreal ( const RealDouble other) const
inline

Subtract RealDoubles

Parameters
otherof type RealDouble

Definition at line 166 of file real_double.h.

167  {
168  return make_rcp<const RealDouble>(i - other.i);
169  }

Field Documentation

◆ type_code_id

const TypeID SymEngine::RealDouble::type_code_id = SYMENGINE_REAL_DOUBLE
static

Type_code_id shared by all instances

Definition at line 25 of file real_double.h.


The documentation for this class was generated from the following files: