6 #ifndef SYMENGINE_REAL_DOUBLE_H
7 #define SYMENGINE_REAL_DOUBLE_H
10 #include <symengine/symengine_exception.h>
16 RCP<const Number> number(
double x);
62 return this->i == 0.0;
88 return make_rcp<const RealDouble>(i
97 return make_rcp<const RealDouble>(
108 mp_get_d(other.imaginary_)));
116 return make_rcp<const RealDouble>(i + other.i);
120 RCP<const Number>
add(
const Number &other)
const override
122 if (is_a<Rational>(other)) {
123 return addreal(down_cast<const Rational &>(other));
124 }
else if (is_a<Integer>(other)) {
125 return addreal(down_cast<const Integer &>(other));
126 }
else if (is_a<Complex>(other)) {
127 return addreal(down_cast<const Complex &>(other));
128 }
else if (is_a<RealDouble>(other)) {
129 return addreal(down_cast<const RealDouble &>(other));
131 return other.
add(*
this);
140 return make_rcp<const RealDouble>(i
149 return make_rcp<const RealDouble>(
160 mp_get_d(other.imaginary_)));
168 return make_rcp<const RealDouble>(i - other.i);
172 RCP<const Number>
sub(
const Number &other)
const override
174 if (is_a<Rational>(other)) {
175 return subreal(down_cast<const Rational &>(other));
176 }
else if (is_a<Integer>(other)) {
177 return subreal(down_cast<const Integer &>(other));
178 }
else if (is_a<Complex>(other)) {
179 return subreal(down_cast<const Complex &>(other));
180 }
else if (is_a<RealDouble>(other)) {
181 return subreal(down_cast<const RealDouble &>(other));
183 return other.rsub(*
this);
212 mp_get_d(other.imaginary_)));
218 if (is_a<Rational>(other)) {
219 return rsubreal(down_cast<const Rational &>(other));
220 }
else if (is_a<Integer>(other)) {
221 return rsubreal(down_cast<const Integer &>(other));
222 }
else if (is_a<Complex>(other)) {
223 return rsubreal(down_cast<const Complex &>(other));
225 throw NotImplementedError(
"Not Implemented");
237 return make_rcp<const RealDouble>(i
246 return make_rcp<const RealDouble>(
257 mp_get_d(other.imaginary_)));
265 return make_rcp<const RealDouble>(i * other.i);
269 RCP<const Number>
mul(
const Number &other)
const override
271 if (is_a<Rational>(other)) {
272 return mulreal(down_cast<const Rational &>(other));
273 }
else if (is_a<Integer>(other)) {
274 return mulreal(down_cast<const Integer &>(other));
275 }
else if (is_a<Complex>(other)) {
276 return mulreal(down_cast<const Complex &>(other));
277 }
else if (is_a<RealDouble>(other)) {
278 return mulreal(down_cast<const RealDouble &>(other));
280 return other.
mul(*
this);
289 return make_rcp<const RealDouble>(i
298 return make_rcp<const RealDouble>(
309 mp_get_d(other.imaginary_)));
317 return make_rcp<const RealDouble>(i / other.i);
321 RCP<const Number>
div(
const Number &other)
const override
323 if (is_a<Rational>(other)) {
324 return divreal(down_cast<const Rational &>(other));
325 }
else if (is_a<Integer>(other)) {
326 return divreal(down_cast<const Integer &>(other));
327 }
else if (is_a<Complex>(other)) {
328 return divreal(down_cast<const Complex &>(other));
329 }
else if (is_a<RealDouble>(other)) {
330 return divreal(down_cast<const RealDouble &>(other));
332 return other.rdiv(*
this);
360 mp_get_d(other.imaginary_))
367 if (is_a<Rational>(other)) {
368 return rdivreal(down_cast<const Rational &>(other));
369 }
else if (is_a<Integer>(other)) {
370 return rdivreal(down_cast<const Integer &>(other));
371 }
else if (is_a<Complex>(other)) {
372 return rdivreal(down_cast<const Complex &>(other));
374 throw NotImplementedError(
"Not Implemented");
383 return make_rcp<const RealDouble>(
396 return make_rcp<const RealDouble>(
407 mp_get_d(other.imaginary_))));
418 return make_rcp<const RealDouble>(
std::pow(i, other.i));
422 RCP<const Number>
pow(
const Number &other)
const override
424 if (is_a<Rational>(other)) {
425 return powreal(down_cast<const Rational &>(other));
426 }
else if (is_a<Integer>(other)) {
427 return powreal(down_cast<const Integer &>(other));
428 }
else if (is_a<Complex>(other)) {
429 return powreal(down_cast<const Complex &>(other));
430 }
else if (is_a<RealDouble>(other)) {
431 return powreal(down_cast<const RealDouble &>(other));
433 return other.rpow(*
this);
446 return make_rcp<const RealDouble>(
459 return make_rcp<const RealDouble>(
469 mp_get_d(other.imaginary_)),
476 if (is_a<Rational>(other)) {
477 return rpowreal(down_cast<const Rational &>(other));
478 }
else if (is_a<Integer>(other)) {
479 return rpowreal(down_cast<const Integer &>(other));
480 }
else if (is_a<Complex>(other)) {
481 return rpowreal(down_cast<const Complex &>(other));
483 throw NotImplementedError(
"Not Implemented");
488 RCP<const RealDouble> real_double(
double x);
#define IMPLEMENT_TYPEID(SYMENGINE_ID)
Inline members and functions.
The lowest unit of symbolic representation.
A class that will evaluate functions numerically.
bool is_negative() const override
const integer_class & as_integer_class() const
Convert to integer_class.
bool is_zero() const override
virtual RCP< const Number > mul(const Number &other) const =0
Multiplication.
virtual RCP< const Number > add(const Number &other) const =0
Addition.
const rational_class & as_rational_class() const
Convert to rational_class.
bool is_negative() const override
RealDouble Class to hold double values.
bool is_minus_one() const override
RCP< const Number > addreal(const RealDouble &other) const
RCP< const Number > powreal(const Rational &other) const
RCP< const Number > divreal(const Complex &other) const
RCP< const Number > rdiv(const Number &other) const override
Converts the param other appropriately and then calls divreal
RCP< const Number > mulreal(const Complex &other) const
RCP< const Number > mulreal(const Integer &other) const
bool is_zero() const override
RCP< const Number > powreal(const Complex &other) const
RCP< const Number > rpowreal(const Rational &other) const
hash_t __hash__() const override
bool is_one() const override
RCP< const Number > mulreal(const Rational &other) const
Evaluate & get_eval() const override
Get Evaluate singleton to evaluate numerically.
RCP< const Number > divreal(const Integer &other) const
RCP< const Number > rsub(const Number &other) const override
Converts the param other appropriately and then calls subreal
RCP< const Number > subreal(const Integer &other) const
bool is_positive() const override
RCP< const Number > rpowreal(const Complex &other) const
bool __eq__(const Basic &o) const override
RCP< const Number > subreal(const Complex &other) const
RCP< const Number > div(const Number &other) const override
Converts the param other appropriately and then calls divreal
RCP< const Number > rsubreal(const Rational &other) const
RCP< const Number > addreal(const Integer &other) const
RCP< const Number > addreal(const Complex &other) const
RCP< const Number > rpowreal(const Integer &other) const
RCP< const Number > rpow(const Number &other) const override
Converts the param other appropriately and then calls powreal
RCP< const Number > rdivreal(const Rational &other) const
RCP< const Number > add(const Number &other) const override
Converts the param other appropriately and then calls addreal
RCP< const Number > mulreal(const RealDouble &other) const
RCP< const Number > divreal(const RealDouble &other) const
int compare(const Basic &o) const override
RCP< const Number > sub(const Number &other) const override
Converts the param other appropriately and then calls subreal
RCP< const Number > addreal(const Rational &other) const
RCP< const Number > rsubreal(const Complex &other) const
RCP< const Number > pow(const Number &other) const override
Converts the param other appropriately and then calls powreal
bool is_negative() const override
bool is_complex() const override
RCP< const Number > rdivreal(const Complex &other) const
RCP< const Number > powreal(const Integer &other) const
RCP< const Number > rdivreal(const Integer &other) const
RCP< const Number > subreal(const RealDouble &other) const
RCP< const Number > mul(const Number &other) const override
Converts the param other appropriately and then calls mulreal
RCP< const Number > powreal(const RealDouble &other) const
RCP< const Number > rsubreal(const Integer &other) const
RCP< const Number > subreal(const Rational &other) const
bool is_exact() const override
RealDouble(double i)
Constructor of RealDouble class.
RCP< const Number > divreal(const Rational &other) const
Main namespace for SymEngine package.