6 #ifndef SYMENGINE_COMPLEX_DOUBLE_H
7 #define SYMENGINE_COMPLEX_DOUBLE_H
9 #include <symengine/real_double.h>
10 #include <symengine/symengine_exception.h>
33 RCP<const Number>
real_part()
const override;
37 RCP<const Basic>
conjugate()
const override;
92 return make_rcp<const ComplexDouble>(
101 return make_rcp<const ComplexDouble>(
110 return make_rcp<const ComplexDouble>(
113 mp_get_d(other.imaginary_)));
121 return make_rcp<const ComplexDouble>(i + other.i);
129 return make_rcp<const ComplexDouble>(i + other.i);
133 RCP<const Number>
add(
const Number &other)
const override
135 if (is_a<Rational>(other)) {
136 return addcomp(down_cast<const Rational &>(other));
137 }
else if (is_a<Integer>(other)) {
138 return addcomp(down_cast<const Integer &>(other));
139 }
else if (is_a<Complex>(other)) {
140 return addcomp(down_cast<const Complex &>(other));
141 }
else if (is_a<RealDouble>(other)) {
142 return addcomp(down_cast<const RealDouble &>(other));
143 }
else if (is_a<ComplexDouble>(other)) {
144 return addcomp(down_cast<const ComplexDouble &>(other));
146 return other.
add(*
this);
155 return make_rcp<const ComplexDouble>(
164 return make_rcp<const ComplexDouble>(
173 return make_rcp<const ComplexDouble>(
176 mp_get_d(other.imaginary_)));
184 return make_rcp<const ComplexDouble>(i - other.i);
192 return make_rcp<const ComplexDouble>(i - other.i);
196 RCP<const Number>
sub(
const Number &other)
const override
198 if (is_a<Rational>(other)) {
199 return subcomp(down_cast<const Rational &>(other));
200 }
else if (is_a<Integer>(other)) {
201 return subcomp(down_cast<const Integer &>(other));
202 }
else if (is_a<Complex>(other)) {
203 return subcomp(down_cast<const Complex &>(other));
204 }
else if (is_a<RealDouble>(other)) {
205 return subcomp(down_cast<const RealDouble &>(other));
206 }
else if (is_a<ComplexDouble>(other)) {
207 return subcomp(down_cast<const ComplexDouble &>(other));
209 return other.rsub(*
this);
236 return make_rcp<const ComplexDouble>(
239 mp_get_d(other.imaginary_)));
247 return make_rcp<const ComplexDouble>(other.i - i);
253 if (is_a<Rational>(other)) {
254 return rsubcomp(down_cast<const Rational &>(other));
255 }
else if (is_a<Integer>(other)) {
256 return rsubcomp(down_cast<const Integer &>(other));
257 }
else if (is_a<Complex>(other)) {
258 return rsubcomp(down_cast<const Complex &>(other));
259 }
else if (is_a<RealDouble>(other)) {
260 return rsubcomp(down_cast<const RealDouble &>(other));
262 throw NotImplementedError(
"Not Implemented");
271 return make_rcp<const ComplexDouble>(
280 return make_rcp<const ComplexDouble>(
289 return make_rcp<const ComplexDouble>(
292 mp_get_d(other.imaginary_)));
300 return make_rcp<const ComplexDouble>(i * other.i);
308 return make_rcp<const ComplexDouble>(i * other.i);
312 RCP<const Number>
mul(
const Number &other)
const override
314 if (is_a<Rational>(other)) {
315 return mulcomp(down_cast<const Rational &>(other));
316 }
else if (is_a<Integer>(other)) {
317 return mulcomp(down_cast<const Integer &>(other));
318 }
else if (is_a<Complex>(other)) {
319 return mulcomp(down_cast<const Complex &>(other));
320 }
else if (is_a<RealDouble>(other)) {
321 return mulcomp(down_cast<const RealDouble &>(other));
322 }
else if (is_a<ComplexDouble>(other)) {
323 return mulcomp(down_cast<const ComplexDouble &>(other));
325 return other.
mul(*
this);
334 return make_rcp<const ComplexDouble>(
343 return make_rcp<const ComplexDouble>(
352 return make_rcp<const ComplexDouble>(
355 mp_get_d(other.imaginary_)));
363 return make_rcp<const ComplexDouble>(i / other.i);
371 return make_rcp<const ComplexDouble>(i / other.i);
375 RCP<const Number>
div(
const Number &other)
const override
377 if (is_a<Rational>(other)) {
378 return divcomp(down_cast<const Rational &>(other));
379 }
else if (is_a<Integer>(other)) {
380 return divcomp(down_cast<const Integer &>(other));
381 }
else if (is_a<Complex>(other)) {
382 return divcomp(down_cast<const Complex &>(other));
383 }
else if (is_a<RealDouble>(other)) {
384 return divcomp(down_cast<const RealDouble &>(other));
385 }
else if (is_a<ComplexDouble>(other)) {
386 return divcomp(down_cast<const ComplexDouble &>(other));
388 return other.rdiv(*
this);
415 return make_rcp<const ComplexDouble>(
417 mp_get_d(other.imaginary_))
426 return make_rcp<const ComplexDouble>(other.i / i);
432 if (is_a<Rational>(other)) {
433 return rdivcomp(down_cast<const Rational &>(other));
434 }
else if (is_a<Integer>(other)) {
435 return rdivcomp(down_cast<const Integer &>(other));
436 }
else if (is_a<Complex>(other)) {
437 return rdivcomp(down_cast<const Complex &>(other));
438 }
else if (is_a<RealDouble>(other)) {
439 return rdivcomp(down_cast<const RealDouble &>(other));
441 throw NotImplementedError(
"Not Implemented");
470 mp_get_d(other.imaginary_))));
477 return make_rcp<const ComplexDouble>(
486 return make_rcp<const ComplexDouble>(
491 RCP<const Number>
pow(
const Number &other)
const override
493 if (is_a<Rational>(other)) {
494 return powcomp(down_cast<const Rational &>(other));
495 }
else if (is_a<Integer>(other)) {
496 return powcomp(down_cast<const Integer &>(other));
497 }
else if (is_a<Complex>(other)) {
498 return powcomp(down_cast<const Complex &>(other));
499 }
else if (is_a<RealDouble>(other)) {
500 return powcomp(down_cast<const RealDouble &>(other));
501 }
else if (is_a<ComplexDouble>(other)) {
502 return powcomp(down_cast<const ComplexDouble &>(other));
504 return other.rpow(*
this);
533 mp_get_d(other.imaginary_)),
542 return make_rcp<const ComplexDouble>(
549 if (is_a<Rational>(other)) {
550 return rpowcomp(down_cast<const Rational &>(other));
551 }
else if (is_a<Integer>(other)) {
552 return rpowcomp(down_cast<const Integer &>(other));
553 }
else if (is_a<Complex>(other)) {
554 return rpowcomp(down_cast<const Complex &>(other));
555 }
else if (is_a<RealDouble>(other)) {
556 return rpowcomp(down_cast<const RealDouble &>(other));
558 throw NotImplementedError(
"Not Implemented");
564 RCP<const ComplexDouble> complex_double(
double real,
double imag);
#define IMPLEMENT_TYPEID(SYMENGINE_ID)
Inline members and functions.
The lowest unit of symbolic representation.
ComplexBase Class for deriving all complex classes.
Complex Double Class to hold std::complex<double> values.
RCP< const Number > subcomp(const RealDouble &other) const
RCP< const Number > rdivcomp(const Rational &other) const
bool __eq__(const Basic &o) const override
RCP< const Number > addcomp(const Complex &other) const
RCP< const Number > addcomp(const Integer &other) const
RCP< const Number > rpowcomp(const Complex &other) const
RCP< const Number > sub(const Number &other) const override
Converts the param other appropriately and then calls subcomp
RCP< const Number > rsubcomp(const RealDouble &other) const
RCP< const Number > mulcomp(const RealDouble &other) const
RCP< const Number > rdivcomp(const Complex &other) const
RCP< const Number > mulcomp(const ComplexDouble &other) const
RCP< const Number > powcomp(const Integer &other) const
RCP< const Number > mul(const Number &other) const override
Converts the param other appropriately and then calls mulcomp
std::complex< double > as_complex_double() const
RCP< const Number > subcomp(const Integer &other) const
int compare(const Basic &o) const override
RCP< const Number > div(const Number &other) const override
Converts the param other appropriately and then calls divcomp
RCP< const Number > rsubcomp(const Rational &other) const
RCP< const Basic > conjugate() const override
Get the conjugate of the complex number.
RCP< const Number > powcomp(const Complex &other) const
RCP< const Number > rpowcomp(const Rational &other) const
RCP< const Number > addcomp(const ComplexDouble &other) const
RCP< const Number > rdivcomp(const Integer &other) const
bool is_positive() const override
bool is_negative() const override
RCP< const Number > rpowcomp(const Integer &other) const
RCP< const Number > rpowcomp(const RealDouble &other) const
RCP< const Number > subcomp(const Complex &other) const
bool is_zero() const override
RCP< const Number > addcomp(const RealDouble &other) const
RCP< const Number > subcomp(const ComplexDouble &other) const
hash_t __hash__() const override
RCP< const Number > rsubcomp(const Integer &other) const
RCP< const Number > mulcomp(const Integer &other) const
RCP< const Number > rdiv(const Number &other) const override
Converts the param other appropriately and then calls divcomp
RCP< const Number > real_part() const override
Get the real part of the complex number.
RCP< const Number > powcomp(const Rational &other) const
RCP< const Number > divcomp(const ComplexDouble &other) const
RCP< const Number > subcomp(const Rational &other) const
RCP< const Number > rdivcomp(const RealDouble &other) const
bool is_exact() const override
ComplexDouble(std::complex< double > i)
Constructor of ComplexDouble class.
RCP< const Number > divcomp(const Rational &other) const
RCP< const Number > divcomp(const RealDouble &other) const
RCP< const Number > powcomp(const RealDouble &other) const
RCP< const Number > add(const Number &other) const override
Converts the param other appropriately and then calls addcomp
RCP< const Number > rsubcomp(const Complex &other) const
RCP< const Number > rsub(const Number &other) const override
Converts the param other appropriately and then calls subcomp
RCP< const Number > rpow(const Number &other) const override
Converts the param other appropriately and then calls powcomp
bool is_complex() const override
RCP< const Number > divcomp(const Complex &other) const
Evaluate & get_eval() const override
Get Evaluate singleton to evaluate numerically.
RCP< const Number > imaginary_part() const override
Get the imaginary part of the complex number.
RCP< const Number > divcomp(const Integer &other) const
RCP< const Number > pow(const Number &other) const override
Converts the param other appropriately and then calls powcomp
bool is_one() const override
RCP< const Number > mulcomp(const Complex &other) const
bool is_minus_one() const override
RCP< const Number > powcomp(const ComplexDouble &other) const
RCP< const Number > mulcomp(const Rational &other) const
RCP< const Number > addcomp(const Rational &other) const
A class that will evaluate functions numerically.
const integer_class & as_integer_class() const
Convert to integer_class.
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.
RealDouble Class to hold double values.
Main namespace for SymEngine package.