-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcomplex.h
More file actions
54 lines (39 loc) · 1.34 KB
/
complex.h
File metadata and controls
54 lines (39 loc) · 1.34 KB
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
#ifndef COMPLEX_H
#define COMPLEX_H
#include "ddobject.h"
#include "vector.h"
#include <complex>
namespace dd {
class Complex : public DdObject, public std::complex<double> {
#define COMPLEX_NAME "Complex"
public:
static const Complex i;
Complex(const double & real, const double & imag) :
std::complex<double>(real, imag) { }
Complex(const std::complex<double> & comp) :
Complex(comp.real(), comp.imag()) { }
Complex(const Vector<2> & vec);
template <typename T>
Complex operator*(const T & val) const {
return static_cast<std::complex<double>>(*this) * val;
}
template <typename T>
Complex operator+(const T & val) const {
return static_cast<std::complex<double>>(*this) + val;
}
template <typename T>
Complex operator-(const T & val) const {
return (*this) + (-val);
}
template <typename T>
Complex operator/(const T & val) const {
return static_cast<std::complex<double>>(*this) / val;
}
Complex operator-() const;
double abs() const;
Complex conjugate() const;
virtual string typeName() const { return COMPLEX_NAME; }
static string staticTypeName() { return COMPLEX_NAME; }
};
}
#endif // COMPLEX_H