Loading...
Searching...
No Matches
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

void accept (Visitor &v) const override
 
void accept (EvalRealDoubleVisitorFinal &v) const override
 
 RealDouble (double i)
 Constructor of RealDouble class.
 
hash_t __hash__ () const override
 
bool __eq__ (const Basic &o) const override
 
int compare (const Basic &o) const override
 
bool is_positive () const override
 
bool is_negative () const override
 
double as_double () const
 
bool is_exact () const override
 
Evaluateget_eval () const override
 Get Evaluate singleton to evaluate numerically.
 
bool is_zero () const override
 
bool is_one () const override
 
bool is_minus_one () const override
 
bool is_complex () const override
 
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
 
RCP< const Numberadd (const Number &other) const override
 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
 
RCP< const Numbersub (const Number &other) const override
 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
 
RCP< const Numberrsub (const Number &other) const override
 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
 
RCP< const Numbermul (const Number &other) const override
 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
 
RCP< const Numberdiv (const Number &other) const override
 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
 
RCP< const Numberrdiv (const Number &other) const override
 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
 
RCP< const Numberpow (const Number &other) const override
 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
 
RCP< const Numberrpow (const Number &other) const override
 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
 
vec_basic get_args () const override
 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.
 
int __cmp__ (const Basic &o) const
 Comparison operator.
 
std::string __str__ () const
 
std::string dumps () const
 Returns a string of the instance serialized.
 
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
 

Additional Inherited Members

- Static Public Member Functions inherited from SymEngine::Basic
static RCP< const Basicloads (const std::string &)
 Creates an instance of a serialized string.
 

Detailed Description

RealDouble Class to hold double values.

Definition at line 19 of file real_double.h.

Constructor & Destructor Documentation

◆ RealDouble()

SymEngine::RealDouble::RealDouble ( double  i)
explicit

Constructor of RealDouble class.

Definition at line 12 of file real_double.cpp.

13{
14 SYMENGINE_ASSIGN_TYPEID()
15 this->i = i;
16}
void hash_combine(hash_t &seed, const T &v)
Definition basic-inl.h:95

Member Function Documentation

◆ __eq__()

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

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)) {
29 return this->i == s.i;
30 }
31 return false;
32}
RealDouble(double i)
Constructor of RealDouble class.

◆ __hash__()

hash_t SymEngine::RealDouble::__hash__ ( ) const
overridevirtual
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}

◆ accept() [1/2]

void SymEngine::RealDouble::accept ( EvalRealDoubleVisitorFinal v) const
overridevirtual

Implements SymEngine::Basic.

◆ accept() [2/2]

void SymEngine::RealDouble::accept ( Visitor v) const
overridevirtual

Implements SymEngine::Basic.

◆ add()

RCP< const Number > SymEngine::RealDouble::add ( const Number other) const
inlineoverridevirtual

Converts the param other appropriately and then calls addreal

Implements SymEngine::Number.

Definition at line 120 of file real_double.h.

121 {
122 if (is_a<Rational>(other)) {
124 } else if (is_a<Integer>(other)) {
126 } else if (is_a<Complex>(other)) {
128 } else if (is_a<RealDouble>(other)) {
130 } else {
131 return other.add(*this);
132 }
133 }
RCP< const Number > addreal(const Integer &other) const
Definition real_double.h:86

◆ 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 {
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 {
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
overridevirtual

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))
38 if (i == s.i)
39 return 0;
40 return i < s.i ? -1 : 1;
41}

◆ div()

RCP< const Number > SymEngine::RealDouble::div ( const Number other) const
inlineoverridevirtual

Converts the param other appropriately and then calls divreal

Reimplemented from SymEngine::Number.

Definition at line 321 of file real_double.h.

322 {
323 if (is_a<Rational>(other)) {
325 } else if (is_a<Integer>(other)) {
327 } else if (is_a<Complex>(other)) {
329 } else if (is_a<RealDouble>(other)) {
331 } else {
332 return other.rdiv(*this);
333 }
334 }
RCP< const Number > divreal(const Integer &other) const

◆ 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 {
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 {
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 }

◆ get_eval()

Evaluate & SymEngine::RealDouble::get_eval ( ) const
overridevirtual

Get Evaluate singleton to evaluate numerically.

Reimplemented from SymEngine::Number.

Definition at line 376 of file real_double.cpp.

377{
378 static EvaluateRealDouble evaluate_real_double;
380}

◆ is_complex()

bool SymEngine::RealDouble::is_complex ( ) const
inlineoverridevirtual
Returns
false

Implements SymEngine::Number.

Definition at line 78 of file real_double.h.

79 {
80 return false;
81 }

◆ is_exact()

bool SymEngine::RealDouble::is_exact ( ) const
inlineoverridevirtual
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()

bool SymEngine::RealDouble::is_minus_one ( ) const
inlineoverridevirtual
Returns
false

Implements SymEngine::Number.

Definition at line 72 of file real_double.h.

73 {
74 return false;
75 }

◆ is_negative()

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

Implements SymEngine::Number.

Definition at line 42 of file real_double.h.

43 {
44 return i < 0;
45 }

◆ is_one()

bool SymEngine::RealDouble::is_one ( ) const
inlineoverridevirtual
Returns
false

Implements SymEngine::Number.

Definition at line 66 of file real_double.h.

67 {
68 return false;
69 }

◆ is_positive()

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

Implements SymEngine::Number.

Definition at line 37 of file real_double.h.

38 {
39 return i > 0;
40 }

◆ is_zero()

bool SymEngine::RealDouble::is_zero ( ) const
inlineoverridevirtual
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 }

◆ mul()

RCP< const Number > SymEngine::RealDouble::mul ( const Number other) const
inlineoverridevirtual

Converts the param other appropriately and then calls mulreal

Implements SymEngine::Number.

Definition at line 269 of file real_double.h.

270 {
271 if (is_a<Rational>(other)) {
273 } else if (is_a<Integer>(other)) {
275 } else if (is_a<Complex>(other)) {
277 } else if (is_a<RealDouble>(other)) {
279 } else {
280 return other.mul(*this);
281 }
282 }
RCP< const Number > mulreal(const Integer &other) const

◆ 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 }
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 {
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 }

◆ pow()

RCP< const Number > SymEngine::RealDouble::pow ( const Number other) const
inlineoverridevirtual

Converts the param other appropriately and then calls powreal

Implements SymEngine::Number.

Definition at line 422 of file real_double.h.

423 {
424 if (is_a<Rational>(other)) {
426 } else if (is_a<Integer>(other)) {
428 } else if (is_a<Complex>(other)) {
430 } else if (is_a<RealDouble>(other)) {
432 } else {
433 return other.rpow(*this);
434 }
435 }
RCP< const Number > powreal(const Integer &other) const

◆ 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 {
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 }
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 }
419 }

◆ rdiv()

RCP< const Number > SymEngine::RealDouble::rdiv ( const Number other) const
inlineoverridevirtual

Converts the param other appropriately and then calls divreal

Reimplemented from SymEngine::Number.

Definition at line 365 of file real_double.h.

366 {
367 if (is_a<Rational>(other)) {
369 } else if (is_a<Integer>(other)) {
371 } else if (is_a<Complex>(other)) {
373 } else {
374 throw NotImplementedError("Not Implemented");
375 }
376 }
RCP< const Number > rdivreal(const Integer &other) const

◆ 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 }

◆ rpow()

RCP< const Number > SymEngine::RealDouble::rpow ( const Number other) const
inlineoverridevirtual

Converts the param other appropriately and then calls powreal

Implements SymEngine::Number.

Definition at line 474 of file real_double.h.

475 {
476 if (is_a<Rational>(other)) {
478 } else if (is_a<Integer>(other)) {
480 } else if (is_a<Complex>(other)) {
482 } else {
483 throw NotImplementedError("Not Implemented");
484 }
485 }
RCP< const Number > rpowreal(const Integer &other) const

◆ 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 }
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 }
460 std::pow(mp_get_d(other.as_rational_class()), i));
461 }

◆ rsub()

RCP< const Number > SymEngine::RealDouble::rsub ( const Number other) const
inlineoverridevirtual

Converts the param other appropriately and then calls subreal

Reimplemented from SymEngine::Number.

Definition at line 216 of file real_double.h.

217 {
218 if (is_a<Rational>(other)) {
220 } else if (is_a<Integer>(other)) {
222 } else if (is_a<Complex>(other)) {
224 } else {
225 throw NotImplementedError("Not Implemented");
226 }
227 }
RCP< const Number > rsubreal(const Integer &other) const

◆ 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 }

◆ sub()

RCP< const Number > SymEngine::RealDouble::sub ( const Number other) const
inlineoverridevirtual

Converts the param other appropriately and then calls subreal

Reimplemented from SymEngine::Number.

Definition at line 172 of file real_double.h.

173 {
174 if (is_a<Rational>(other)) {
176 } else if (is_a<Integer>(other)) {
178 } else if (is_a<Complex>(other)) {
180 } else if (is_a<RealDouble>(other)) {
182 } else {
183 return other.rsub(*this);
184 }
185 }
RCP< const Number > subreal(const Integer &other) const

◆ 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 {
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 {
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

◆ i

double SymEngine::RealDouble::i

Definition at line 22 of file real_double.h.

◆ 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: