-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplex.h
More file actions
71 lines (64 loc) · 2.44 KB
/
complex.h
File metadata and controls
71 lines (64 loc) · 2.44 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef complex_H_INCLUDED
#define complex_H_INCLUDED
#include <iostream>
#include <math.h>
#include <string.h>
//tolerance is used in calculations like inverse and gram-shmidt ,gauss
//this is sufficient for gram-shmidt since it requires a percision
const long double tolerance =1e-32;
//check_tolerance is for is_identity , is_zero , aka every function starting with is_
//modify this the way you want
const long double check_tolerance =1e-6;
using namespace std ;
const long double to_deg =180/M_PI;
const long double to_rad = M_PI/180 ;
class complex{
private:
long double re,im ;
public:
complex(long double _re=0,long double _im=0);
complex(int);
complex(const complex&);
long double get_re(void)const;
long double get_im(void)const;
~complex();
complex operator+(const complex&)const ;
complex operator-(const complex&)const ;
complex operator*(const complex&)const ;
complex operator/(const complex&)const ;
void operator=(const long double & val);
void operator+=(const complex&) ;
void operator-=(const complex&) ;
void operator*=(const complex&) ;
void operator/=(const complex&) ;
void operator^=(const long double &power);
complex operator*(const long double &)const ;
complex operator/(const long double &)const ;
void operator*=(const long double &) ;
void operator/=(const long double &) ;
complex operator^(const long double &) const ;
long double theta(void)const;
bool operator>(const complex&)const;
bool operator<(const complex&)const;
bool operator==(const complex&)const;
void operator=(const complex&) ;
bool operator!=(const complex&)const;
friend std::ostream& operator<<(std::ostream& os, const complex& c);
};
string to_string(complex&);
long double abs(const complex&);
// General template function for all non-complex types
complex conjugate(const complex& val);
unsigned char conjugate(const unsigned char &val);
char conjugate(const char &val);
unsigned int conjugate(const unsigned int &val);
int conjugate(const int &val);
float conjugate(const float &val);
double conjugate(const double &val);
long double conjugate(const long double &val);
unsigned long conjugate(const unsigned long &val);
long conjugate(const long &val);
long long conjugate(const long long &val);
unsigned long long conjugate(const unsigned long long &val);
complex pow(const complex &c,int power);
#endif