Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
72 lines (65 loc) · 1.72 KB

File metadata and controls

72 lines (65 loc) · 1.72 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* \file ComplexDouble.h
* Class for ComplexDouble built on top of Number class
*
**/
#include <symengine/complex_double.h>
namespace SymEngine
{
ComplexDouble::ComplexDouble(std::complex<double> i)
{
SYMENGINE_ASSIGN_TYPEID()
this->i = i;
}
//! Get the real part of the complex number
RCP<const Number> ComplexDouble::real_part() const
{
return real_double(i.real());
}
//! Get the imaginary part of the complex number
RCP<const Number> ComplexDouble::imaginary_part() const
{
return real_double(i.imag());
}
//! Get the conjugate of the complex number
RCP<const Basic> ComplexDouble::conjugate() const
{
double re = i.real();
double im = -i.imag();
return complex_double(std::complex<double>(re, im));
}
hash_t ComplexDouble::__hash__() const
{
hash_t seed = SYMENGINE_COMPLEX_DOUBLE;
hash_combine<double>(seed, i.real());
hash_combine<double>(seed, i.imag());
return seed;
}
bool ComplexDouble::__eq__(const Basic &o) const
{
if (is_a<ComplexDouble>(o)) {
const ComplexDouble &s = down_cast<const ComplexDouble &>(o);
return this->i == s.i;
}
return false;
}
int ComplexDouble::compare(const Basic &o) const
{
SYMENGINE_ASSERT(is_a<ComplexDouble>(o))
const ComplexDouble &s = down_cast<const ComplexDouble &>(o);
if (i == s.i)
return 0;
if (i.real() == s.i.real()) {
return i.imag() < s.i.imag() ? -1 : 1;
}
return i.real() < s.i.real() ? -1 : 1;
}
RCP<const ComplexDouble> complex_double(std::complex<double> x)
{
return make_rcp<const ComplexDouble>(x);
}
RCP<const ComplexDouble> complex_double(double real, double imag)
{
return make_rcp<const ComplexDouble>(std::complex<double>(real, imag));
}
} // namespace SymEngine
Morty Proxy This is a proxified and sanitized view of the page, visit original site.