SymEngine::ComplexDouble Class Reference

Complex Double Class to hold std::complex<double> values. More...

#include <complex_double.h>

+ Inheritance diagram for SymEngine::ComplexDouble:
+ Collaboration diagram for SymEngine::ComplexDouble:

Public Member Functions

void accept (Visitor &v) const override
 
void accept (EvalRealDoubleVisitorFinal &v) const override
 
 ComplexDouble (std::complex< double > i)
 Constructor of ComplexDouble class.
 
hash_t __hash__ () const override
 
bool __eq__ (const Basic &o) const override
 
int compare (const Basic &o) const override
 
RCP< const Numberreal_part () const override
 Get the real part of the complex number.
 
RCP< const Numberimaginary_part () const override
 Get the imaginary part of the complex number.
 
RCP< const Basicconjugate () const override
 Get the conjugate of the complex number.
 
bool is_positive () const override
 
bool is_negative () const override
 
bool is_complex () const override
 
std::complex< double > as_complex_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
 
RCP< const Numberaddcomp (const Integer &other) const
 
RCP< const Numberaddcomp (const Rational &other) const
 
RCP< const Numberaddcomp (const Complex &other) const
 
RCP< const Numberaddcomp (const RealDouble &other) const
 
RCP< const Numberaddcomp (const ComplexDouble &other) const
 
RCP< const Numberadd (const Number &other) const override
 Converts the param other appropriately and then calls addcomp
 
RCP< const Numbersubcomp (const Integer &other) const
 
RCP< const Numbersubcomp (const Rational &other) const
 
RCP< const Numbersubcomp (const Complex &other) const
 
RCP< const Numbersubcomp (const RealDouble &other) const
 
RCP< const Numbersubcomp (const ComplexDouble &other) const
 
RCP< const Numbersub (const Number &other) const override
 Converts the param other appropriately and then calls subcomp
 
RCP< const Numberrsubcomp (const Integer &other) const
 
RCP< const Numberrsubcomp (const Rational &other) const
 
RCP< const Numberrsubcomp (const Complex &other) const
 
RCP< const Numberrsubcomp (const RealDouble &other) const
 
RCP< const Numberrsub (const Number &other) const override
 Converts the param other appropriately and then calls subcomp
 
RCP< const Numbermulcomp (const Integer &other) const
 
RCP< const Numbermulcomp (const Rational &other) const
 
RCP< const Numbermulcomp (const Complex &other) const
 
RCP< const Numbermulcomp (const RealDouble &other) const
 
RCP< const Numbermulcomp (const ComplexDouble &other) const
 
RCP< const Numbermul (const Number &other) const override
 Converts the param other appropriately and then calls mulcomp
 
RCP< const Numberdivcomp (const Integer &other) const
 
RCP< const Numberdivcomp (const Rational &other) const
 
RCP< const Numberdivcomp (const Complex &other) const
 
RCP< const Numberdivcomp (const RealDouble &other) const
 
RCP< const Numberdivcomp (const ComplexDouble &other) const
 
RCP< const Numberdiv (const Number &other) const override
 Converts the param other appropriately and then calls divcomp
 
RCP< const Numberrdivcomp (const Integer &other) const
 
RCP< const Numberrdivcomp (const Rational &other) const
 
RCP< const Numberrdivcomp (const Complex &other) const
 
RCP< const Numberrdivcomp (const RealDouble &other) const
 
RCP< const Numberrdiv (const Number &other) const override
 Converts the param other appropriately and then calls divcomp
 
RCP< const Numberpowcomp (const Integer &other) const
 
RCP< const Numberpowcomp (const Rational &other) const
 
RCP< const Numberpowcomp (const Complex &other) const
 
RCP< const Numberpowcomp (const RealDouble &other) const
 
RCP< const Numberpowcomp (const ComplexDouble &other) const
 
RCP< const Numberpow (const Number &other) const override
 Converts the param other appropriately and then calls powcomp
 
RCP< const Numberrpowcomp (const Integer &other) const
 
RCP< const Numberrpowcomp (const Rational &other) const
 
RCP< const Numberrpowcomp (const Complex &other) const
 
RCP< const Numberrpowcomp (const RealDouble &other) const
 
RCP< const Numberrpow (const Number &other) const override
 Converts the param other appropriately and then calls powcomp
 
- Public Member Functions inherited from SymEngine::ComplexBase
bool is_re_zero () const
 
- Public Member Functions inherited from SymEngine::Number
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. More...
 
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

std::complex< double > i
 
- Data Fields inherited from SymEngine::Basic
TypeID type_code_
 

Static Public Attributes

static const TypeID type_code_id = SYMENGINE_COMPLEX_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

Complex Double Class to hold std::complex<double> values.

Definition at line 15 of file complex_double.h.

Member Function Documentation

◆ __eq__()

bool SymEngine::ComplexDouble::__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 41 of file complex_double.cpp.

42 {
43  if (is_a<ComplexDouble>(o)) {
44  const ComplexDouble &s = down_cast<const ComplexDouble &>(o);
45  return this->i == s.i;
46  }
47  return false;
48 }
ComplexDouble(std::complex< double > i)
Constructor of ComplexDouble class.

◆ __hash__()

hash_t SymEngine::ComplexDouble::__hash__ ( ) const
overridevirtual
Returns
size of the hash

Implements SymEngine::Basic.

Definition at line 33 of file complex_double.cpp.

34 {
35  hash_t seed = SYMENGINE_COMPLEX_DOUBLE;
36  hash_combine<double>(seed, i.real());
37  hash_combine<double>(seed, i.imag());
38  return seed;
39 }
T imag(T... args)
T real(T... args)

◆ addcomp() [1/5]

RCP<const Number> SymEngine::ComplexDouble::addcomp ( const Complex other) const
inline

Add ComplexDoubles

Parameters
otherof type Complex

Definition at line 108 of file complex_double.h.

109  {
110  return make_rcp<const ComplexDouble>(
111  i
112  + std::complex<double>(mp_get_d(other.real_),
113  mp_get_d(other.imaginary_)));
114  }

◆ addcomp() [2/5]

RCP<const Number> SymEngine::ComplexDouble::addcomp ( const ComplexDouble other) const
inline

Add ComplexDoubles

Parameters
otherof type ComplexDouble

Definition at line 127 of file complex_double.h.

128  {
129  return make_rcp<const ComplexDouble>(i + other.i);
130  }

◆ addcomp() [3/5]

RCP<const Number> SymEngine::ComplexDouble::addcomp ( const Integer other) const
inline

Add ComplexDoubles

Parameters
otherof type Integer

Definition at line 90 of file complex_double.h.

91  {
92  return make_rcp<const ComplexDouble>(
93  i + mp_get_d(other.as_integer_class()));
94  }

◆ addcomp() [4/5]

RCP<const Number> SymEngine::ComplexDouble::addcomp ( const Rational other) const
inline

Add ComplexDoubles

Parameters
otherof type Rational

Definition at line 99 of file complex_double.h.

100  {
101  return make_rcp<const ComplexDouble>(
102  i + mp_get_d(other.as_rational_class()));
103  }

◆ addcomp() [5/5]

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

Add ComplexDoubles

Parameters
otherof type RealDouble

Definition at line 119 of file complex_double.h.

120  {
121  return make_rcp<const ComplexDouble>(i + other.i);
122  }

◆ as_complex_double()

std::complex<double> SymEngine::ComplexDouble::as_complex_double ( ) const
inline
Returns
self as a double

Definition at line 56 of file complex_double.h.

57  {
58  return i;
59  }

◆ compare()

int SymEngine::ComplexDouble::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 50 of file complex_double.cpp.

51 {
52  SYMENGINE_ASSERT(is_a<ComplexDouble>(o))
53  const ComplexDouble &s = down_cast<const ComplexDouble &>(o);
54  if (i == s.i)
55  return 0;
56  if (i.real() == s.i.real()) {
57  return i.imag() < s.i.imag() ? -1 : 1;
58  }
59  return i.real() < s.i.real() ? -1 : 1;
60 }

◆ divcomp() [1/5]

RCP<const Number> SymEngine::ComplexDouble::divcomp ( const Complex other) const
inline

Divide ComplexDoubles

Parameters
otherof type Complex

Definition at line 350 of file complex_double.h.

351  {
352  return make_rcp<const ComplexDouble>(
353  i
354  / std::complex<double>(mp_get_d(other.real_),
355  mp_get_d(other.imaginary_)));
356  }

◆ divcomp() [2/5]

RCP<const Number> SymEngine::ComplexDouble::divcomp ( const ComplexDouble other) const
inline

Divide ComplexDoubles

Parameters
otherof type ComplexDouble

Definition at line 369 of file complex_double.h.

370  {
371  return make_rcp<const ComplexDouble>(i / other.i);
372  }

◆ divcomp() [3/5]

RCP<const Number> SymEngine::ComplexDouble::divcomp ( const Integer other) const
inline

Divide ComplexDoubles

Parameters
otherof type Integer

Definition at line 332 of file complex_double.h.

333  {
334  return make_rcp<const ComplexDouble>(
335  i / mp_get_d(other.as_integer_class()));
336  }

◆ divcomp() [4/5]

RCP<const Number> SymEngine::ComplexDouble::divcomp ( const Rational other) const
inline

Divide ComplexDoubles

Parameters
otherof type Rational

Definition at line 341 of file complex_double.h.

342  {
343  return make_rcp<const ComplexDouble>(
344  i / mp_get_d(other.as_rational_class()));
345  }

◆ divcomp() [5/5]

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

Divide ComplexDoubles

Parameters
otherof type RealDouble

Definition at line 361 of file complex_double.h.

362  {
363  return make_rcp<const ComplexDouble>(i / other.i);
364  }

◆ is_complex()

bool SymEngine::ComplexDouble::is_complex ( ) const
inlineoverridevirtual
Returns
true

Implements SymEngine::Number.

Definition at line 51 of file complex_double.h.

52  {
53  return true;
54  }

◆ is_exact()

bool SymEngine::ComplexDouble::is_exact ( ) const
inlineoverridevirtual
Returns
false

Reimplemented from SymEngine::Number.

Definition at line 62 of file complex_double.h.

63  {
64  return false;
65  }

◆ is_minus_one()

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

Implements SymEngine::Number.

Definition at line 82 of file complex_double.h.

83  {
84  return false;
85  }

◆ is_negative()

bool SymEngine::ComplexDouble::is_negative ( ) const
inlineoverridevirtual
Returns
false

Implements SymEngine::Number.

Definition at line 46 of file complex_double.h.

47  {
48  return false;
49  }

◆ is_one()

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

Implements SymEngine::Number.

Definition at line 76 of file complex_double.h.

77  {
78  return false;
79  }

◆ is_positive()

bool SymEngine::ComplexDouble::is_positive ( ) const
inlineoverridevirtual
Returns
false

Implements SymEngine::Number.

Definition at line 40 of file complex_double.h.

41  {
42  return false;
43  }

◆ is_zero()

bool SymEngine::ComplexDouble::is_zero ( ) const
inlineoverridevirtual
Returns
true if equal to 0

Implements SymEngine::Number.

Definition at line 70 of file complex_double.h.

71  {
72  return i == 0.0;
73  }

◆ mulcomp() [1/5]

RCP<const Number> SymEngine::ComplexDouble::mulcomp ( const Complex other) const
inline

Multiply ComplexDoubles

Parameters
otherof type Complex

Definition at line 287 of file complex_double.h.

288  {
289  return make_rcp<const ComplexDouble>(
290  i
291  * std::complex<double>(mp_get_d(other.real_),
292  mp_get_d(other.imaginary_)));
293  }

◆ mulcomp() [2/5]

RCP<const Number> SymEngine::ComplexDouble::mulcomp ( const ComplexDouble other) const
inline

Multiply ComplexDoubles

Parameters
otherof type ComplexDouble

Definition at line 306 of file complex_double.h.

307  {
308  return make_rcp<const ComplexDouble>(i * other.i);
309  }

◆ mulcomp() [3/5]

RCP<const Number> SymEngine::ComplexDouble::mulcomp ( const Integer other) const
inline

Multiply ComplexDoubles

Parameters
otherof type Integer

Definition at line 269 of file complex_double.h.

270  {
271  return make_rcp<const ComplexDouble>(
272  i * mp_get_d(other.as_integer_class()));
273  }

◆ mulcomp() [4/5]

RCP<const Number> SymEngine::ComplexDouble::mulcomp ( const Rational other) const
inline

Multiply ComplexDoubles

Parameters
otherof type Rational

Definition at line 278 of file complex_double.h.

279  {
280  return make_rcp<const ComplexDouble>(
281  i * mp_get_d(other.as_rational_class()));
282  }

◆ mulcomp() [5/5]

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

Multiply ComplexDoubles

Parameters
otherof type RealDouble

Definition at line 298 of file complex_double.h.

299  {
300  return make_rcp<const ComplexDouble>(i * other.i);
301  }

◆ powcomp() [1/5]

RCP<const Number> SymEngine::ComplexDouble::powcomp ( const Complex other) const
inline

Raise ComplexDouble to power other

Parameters
otherof type Complex

Definition at line 466 of file complex_double.h.

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

◆ powcomp() [2/5]

RCP<const Number> SymEngine::ComplexDouble::powcomp ( const ComplexDouble other) const
inline

Raise ComplexDouble to power other

Parameters
otherof type ComplexDouble

Definition at line 484 of file complex_double.h.

485  {
486  return make_rcp<const ComplexDouble>(
487  (std::complex<double>)std::pow(i, other.i));
488  }

◆ powcomp() [3/5]

RCP<const Number> SymEngine::ComplexDouble::powcomp ( const Integer other) const
inline

Raise ComplexDouble to power other

Parameters
otherof type Integer

Definition at line 448 of file complex_double.h.

449  {
450  return make_rcp<const ComplexDouble>((std::complex<double>)std::pow(
451  i, mp_get_d(other.as_integer_class())));
452  }

◆ powcomp() [4/5]

RCP<const Number> SymEngine::ComplexDouble::powcomp ( const Rational other) const
inline

Raise ComplexDouble to power other

Parameters
otherof type Rational

Definition at line 457 of file complex_double.h.

458  {
459  return make_rcp<const ComplexDouble>((std::complex<double>)std::pow(
460  i, mp_get_d(other.as_rational_class())));
461  }

◆ powcomp() [5/5]

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

Raise ComplexDouble to power other

Parameters
otherof type RealDouble

Definition at line 475 of file complex_double.h.

476  {
477  return make_rcp<const ComplexDouble>(
478  (std::complex<double>)std::pow(i, other.i));
479  }

◆ rdivcomp() [1/4]

RCP<const Number> SymEngine::ComplexDouble::rdivcomp ( const Complex other) const
inline

Divide ComplexDoubles

Parameters
otherof type Complex

Definition at line 413 of file complex_double.h.

414  {
415  return make_rcp<const ComplexDouble>(
416  std::complex<double>(mp_get_d(other.real_),
417  mp_get_d(other.imaginary_))
418  / i);
419  }

◆ rdivcomp() [2/4]

RCP<const Number> SymEngine::ComplexDouble::rdivcomp ( const Integer other) const
inline

Divide ComplexDoubles

Parameters
otherof type Integer

Definition at line 395 of file complex_double.h.

396  {
397  return make_rcp<const ComplexDouble>(mp_get_d(other.as_integer_class())
398  / i);
399  }

◆ rdivcomp() [3/4]

RCP<const Number> SymEngine::ComplexDouble::rdivcomp ( const Rational other) const
inline

Divide ComplexDoubles

Parameters
otherof type Rational

Definition at line 404 of file complex_double.h.

405  {
406  return make_rcp<const ComplexDouble>(mp_get_d(other.as_rational_class())
407  / i);
408  }

◆ rdivcomp() [4/4]

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

Divide ComplexDoubles

Parameters
otherof type RealDouble

Definition at line 424 of file complex_double.h.

425  {
426  return make_rcp<const ComplexDouble>(other.i / i);
427  }

◆ rpowcomp() [1/4]

RCP<const Number> SymEngine::ComplexDouble::rpowcomp ( const Complex other) const
inline

Raise other to power ComplexDouble

Parameters
otherof type Complex

Definition at line 529 of file complex_double.h.

530  {
531  return make_rcp<const ComplexDouble>((std::complex<double>)std::pow(
532  std::complex<double>(mp_get_d(other.real_),
533  mp_get_d(other.imaginary_)),
534  i));
535  }

◆ rpowcomp() [2/4]

RCP<const Number> SymEngine::ComplexDouble::rpowcomp ( const Integer other) const
inline

Raise other to power ComplexDouble

Parameters
otherof type Integer

Definition at line 511 of file complex_double.h.

512  {
513  return make_rcp<const ComplexDouble>((std::complex<double>)std::pow(
514  mp_get_d(other.as_integer_class()), i));
515  }

◆ rpowcomp() [3/4]

RCP<const Number> SymEngine::ComplexDouble::rpowcomp ( const Rational other) const
inline

Raise other to power ComplexDouble

Parameters
otherof type Rational

Definition at line 520 of file complex_double.h.

521  {
522  return make_rcp<const ComplexDouble>((std::complex<double>)std::pow(
523  mp_get_d(other.as_rational_class()), i));
524  }

◆ rpowcomp() [4/4]

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

Raise other to power ComplexDouble

Parameters
otherof type RealDouble

Definition at line 540 of file complex_double.h.

541  {
542  return make_rcp<const ComplexDouble>(
543  (std::complex<double>)std::pow(other.i, i));
544  }

◆ rsubcomp() [1/4]

RCP<const Number> SymEngine::ComplexDouble::rsubcomp ( const Complex other) const
inline

Subtract ComplexDoubles

Parameters
otherof type Complex

Definition at line 234 of file complex_double.h.

235  {
236  return make_rcp<const ComplexDouble>(
237  -i
238  + std::complex<double>(mp_get_d(other.real_),
239  mp_get_d(other.imaginary_)));
240  }

◆ rsubcomp() [2/4]

RCP<const Number> SymEngine::ComplexDouble::rsubcomp ( const Integer other) const
inline

Subtract ComplexDoubles

Parameters
otherof type Integer

Definition at line 216 of file complex_double.h.

217  {
218  return make_rcp<const ComplexDouble>(mp_get_d(other.as_integer_class())
219  - i);
220  }

◆ rsubcomp() [3/4]

RCP<const Number> SymEngine::ComplexDouble::rsubcomp ( const Rational other) const
inline

Subtract ComplexDoubles

Parameters
otherof type Rational

Definition at line 225 of file complex_double.h.

226  {
227  return make_rcp<const ComplexDouble>(mp_get_d(other.as_rational_class())
228  - i);
229  }

◆ rsubcomp() [4/4]

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

Subtract ComplexDoubles

Parameters
otherof type RealDouble

Definition at line 245 of file complex_double.h.

246  {
247  return make_rcp<const ComplexDouble>(other.i - i);
248  }

◆ subcomp() [1/5]

RCP<const Number> SymEngine::ComplexDouble::subcomp ( const Complex other) const
inline

Subtract ComplexDoubles

Parameters
otherof type Complex

Definition at line 171 of file complex_double.h.

172  {
173  return make_rcp<const ComplexDouble>(
174  i
175  - std::complex<double>(mp_get_d(other.real_),
176  mp_get_d(other.imaginary_)));
177  }

◆ subcomp() [2/5]

RCP<const Number> SymEngine::ComplexDouble::subcomp ( const ComplexDouble other) const
inline

Subtract ComplexDoubles

Parameters
otherof type ComplexDouble

Definition at line 190 of file complex_double.h.

191  {
192  return make_rcp<const ComplexDouble>(i - other.i);
193  }

◆ subcomp() [3/5]

RCP<const Number> SymEngine::ComplexDouble::subcomp ( const Integer other) const
inline

Subtract ComplexDoubles

Parameters
otherof type Integer

Definition at line 153 of file complex_double.h.

154  {
155  return make_rcp<const ComplexDouble>(
156  i - mp_get_d(other.as_integer_class()));
157  }

◆ subcomp() [4/5]

RCP<const Number> SymEngine::ComplexDouble::subcomp ( const Rational other) const
inline

Subtract ComplexDoubles

Parameters
otherof type Rational

Definition at line 162 of file complex_double.h.

163  {
164  return make_rcp<const ComplexDouble>(
165  i - mp_get_d(other.as_rational_class()));
166  }

◆ subcomp() [5/5]

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

Subtract ComplexDoubles

Parameters
otherof type RealDouble

Definition at line 182 of file complex_double.h.

183  {
184  return make_rcp<const ComplexDouble>(i - other.i);
185  }

Field Documentation

◆ type_code_id

const TypeID SymEngine::ComplexDouble::type_code_id = SYMENGINE_COMPLEX_DOUBLE
static

Type_code_id shared by all instances

Definition at line 21 of file complex_double.h.


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