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

virtual void accept (Visitor &v) const
 
virtual void accept (EvalRealDoubleVisitorFinal &v) const
 
 ComplexDouble (std::complex< double > i)
 Constructor of ComplexDouble class.
 
virtual hash_t __hash__ () const
 
virtual bool __eq__ (const Basic &o) const
 
virtual int compare (const Basic &o) const
 
virtual RCP< const Numberreal_part () const
 Get the real part of the complex number.
 
virtual RCP< const Numberimaginary_part () const
 Get the imaginary part of the complex number.
 
virtual RCP< const Basicconjugate () const
 Get the conjugate of the complex number.
 
virtual bool is_positive () const
 
virtual bool is_negative () const
 
virtual bool is_complex () const
 
std::complex< double > as_complex_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
 
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
 
virtual RCP< const Numberadd (const Number &other) const
 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
 
virtual RCP< const Numbersub (const Number &other) const
 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
 
virtual RCP< const Numberrsub (const Number &other) const
 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
 
virtual RCP< const Numbermul (const Number &other) const
 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
 
virtual RCP< const Numberdiv (const Number &other) const
 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
 
virtual RCP< const Numberrdiv (const Number &other) const
 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
 
virtual RCP< const Numberpow (const Number &other) const
 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
 
virtual RCP< const Numberrpow (const Number &other) const
 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
 
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

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
 

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
virtual

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
virtual
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
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 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()

virtual bool SymEngine::ComplexDouble::is_complex ( ) const
inlinevirtual
Returns
true

Implements SymEngine::Number.

Definition at line 51 of file complex_double.h.

52  {
53  return true;
54  }

◆ is_exact()

virtual bool SymEngine::ComplexDouble::is_exact ( ) const
inlinevirtual
Returns
false

Reimplemented from SymEngine::Number.

Definition at line 62 of file complex_double.h.

63  {
64  return false;
65  }

◆ is_minus_one()

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

Implements SymEngine::Number.

Definition at line 82 of file complex_double.h.

83  {
84  return false;
85  }

◆ is_negative()

virtual bool SymEngine::ComplexDouble::is_negative ( ) const
inlinevirtual
Returns
false

Implements SymEngine::Number.

Definition at line 46 of file complex_double.h.

47  {
48  return false;
49  }

◆ is_one()

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

Implements SymEngine::Number.

Definition at line 76 of file complex_double.h.

77  {
78  return false;
79  }

◆ is_positive()

virtual bool SymEngine::ComplexDouble::is_positive ( ) const
inlinevirtual
Returns
false

Implements SymEngine::Number.

Definition at line 40 of file complex_double.h.

41  {
42  return false;
43  }

◆ is_zero()

virtual bool SymEngine::ComplexDouble::is_zero ( ) const
inlinevirtual
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: