-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomplex.h
77 lines (45 loc) · 1.6 KB
/
complex.h
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
73
74
75
76
77
#ifndef COMPLEX_H
#define COMPLEX_H
#include <iostream>
#include <string>
#include <math.h>
#define PI 3.14159265359
#define Range 0.0005 //Made up precision range it'll convert any no. in a period of (2*Range) around any integer to intger --> -1.00045=-1
using namespace std;
class complex //we always deal with real and imaginary out side the class for simplicity
{
private:
float real, img; //we don't need magnitude & phase for every member (memory)
public: //only (void) print will work so to choose bet. precision, range, auto choose your print
complex();
complex(float R, float I);
void operator= (complex scnd);
void operator+=(complex scnd);
void operator-=(complex scnd);
void operator*=(complex scnd);
void operator/=(complex scnd);
bool operator==(complex scnd)const;
bool operator!=(complex scnd)const;
complex operator+(complex scnd)const;
complex operator-(complex scnd)const;
complex operator*(complex scnd)const;
complex operator/(complex scnd)const;
complex operator^(float powr)const;
void set_real(float realIn);
void set_img(float imgIn);
float get_real(void)const;
float get_imaginary(void)const;
float get_phase(char format)const;
float get_magnitude(void)const;
void print(void)const;
void print(int null)const;
void conjugate(complex var);
int divide(complex first, complex second);
complex p_r(float magnitude, float phase)const;
complex cconjugate(void)const;
bool has_NaN(void)const;
private: //not used
complex r_p();
complex p_r();
};
#endif