-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCmpx.hpp
64 lines (52 loc) · 1.85 KB
/
Cmpx.hpp
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
#ifndef _CMPX_H_
#define _CMPX_H_
#include <stdio.h>
#include "mydefs.hpp"
class Cmpx {
// data members
private:
fptype re; // z = re + j*im
fptype im;
public:
// constructors
HOSTDEVICE Cmpx();
HOSTDEVICE Cmpx(const fptype x, const fptype y);
// member functions
// get functions
HOSTDEVICE inline fptype get_re() const { return re; }
HOSTDEVICE inline fptype get_im() const { return im; }
HOSTDEVICE fptype get_mag() const;
HOSTDEVICE fptype get_ang() const;
// set functions
// Cmpx& set_re(const fptype x);
// Cmpx& set_im(const fptype x);
// complex number operations
HOSTDEVICE inline Cmpx conjugate() const { return Cmpx(re, -im); }
// overloaded operators
HOSTDEVICE void operator+=(const Cmpx &z);
HOSTDEVICE void operator-=(const Cmpx &z);
HOSTDEVICE void operator*=(const Cmpx &z);
HOSTDEVICE void operator/=(const Cmpx &z);
HOSTDEVICE void operator*=(const fptype k);
// Cmpx& operator+=(const Cmpx &z);
// Cmpx& operator-=(const Cmpx &z);
// Cmpx& operator*=(const Cmpx &z);
// Cmpx& operator/=(const Cmpx &z);
// Cmpx& operator*=(const fptype k);
// inline Cmpx operator+(const Cmpx &z) const { Cmpx z1 = *this; return z1 += z; }
// inline Cmpx operator+(const Cmpx &z) const { return Cmpx(*this) += z; }
// inline Cmpx operator-(const Cmpx &z) const { return Cmpx(*this) -= z; }
// inline Cmpx operator*(const Cmpx &z) const { return Cmpx(*this) *= z; }
// inline Cmpx operator/(const Cmpx &z) const { return Cmpx(*this) /= z; }
// inline Cmpx operator*(const fptype k) const { return Cmpx(*this) *= k; }
// print methods
HOST char* polar() const;
HOST char* cartesian() const;
};
// inline Cmpx operator*(const fptype k, const Cmpx z) {
// return z * k;
// }
#ifdef __CUDACC__
#include "Cmpx.cu"
#endif
#endif // #ifndef _CMPX_H_