forked from cpp-exercises/solver-a
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolver.hpp
83 lines (70 loc) · 3.54 KB
/
solver.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <complex>
#include <iostream>
#define P_DEBUG(msg) cout << "\033[1;31m" \
<< "-DEBUG- File: " << __FILE__ << " Line: " << __LINE__ << " Message: " << msg << "\033[0m\n" \
<< endl;
#define P_INFO(msg) cout << "\033[1;36m" \
<< "-INFO- File: " << __FILE__ << " Line: " << __LINE__ << " Message: " << msg << "\033[0m\n" \
<< endl;
using namespace std;
namespace solver {
class RealVariable {
private:
double re;
public:
RealVariable() : re(0){};
RealVariable(double re) : re(re){};
RealVariable &operator*(double times);
RealVariable &operator*(const RealVariable &x);
friend RealVariable &operator*(double times, const RealVariable &x);
RealVariable &operator-(double times);
RealVariable &operator-(const RealVariable &x);
friend RealVariable &operator-(double times, const RealVariable &x);
RealVariable &operator+(double times);
RealVariable &operator+(const RealVariable &x);
friend RealVariable &operator+(double times, const RealVariable &x);
RealVariable &operator/(double times);
RealVariable &operator/(const RealVariable &x);
friend RealVariable &operator/(double times, const RealVariable &x);
RealVariable &operator==(double times);
RealVariable &operator==(const RealVariable &x);
friend RealVariable &operator==(double times, const RealVariable &x);
RealVariable &operator^(int times);
};
class ComplexVariable {
private:
double re;
double im;
public:
ComplexVariable() : re(0), im(0){};
ComplexVariable(double re, double im) : re(re), im(im){};
ComplexVariable &operator*(const ComplexVariable &x);
ComplexVariable &operator*(double times);
ComplexVariable &operator*(std::complex<double> x);
friend ComplexVariable &operator*(double times, const ComplexVariable &x);
friend ComplexVariable &operator*(std::complex<double> y, const ComplexVariable &x);
ComplexVariable &operator-(const ComplexVariable &x);
ComplexVariable &operator-(double times);
ComplexVariable &operator-(std::complex<double> x);
friend ComplexVariable &operator-(double times, const ComplexVariable &x);
friend ComplexVariable &operator-(std::complex<double> y, const ComplexVariable &x);
ComplexVariable &operator+(const ComplexVariable &x);
ComplexVariable &operator+(double times);
ComplexVariable &operator+(std::complex<double> x);
friend ComplexVariable &operator+(double times, const ComplexVariable &x);
friend ComplexVariable &operator+(std::complex<double> y, const ComplexVariable &x);
ComplexVariable &operator/(const ComplexVariable &x);
ComplexVariable &operator/(double times);
ComplexVariable &operator/(std::complex<double> x);
friend ComplexVariable &operator/(double times, const ComplexVariable &x);
friend ComplexVariable &operator/(std::complex<double> y, const ComplexVariable &x);
ComplexVariable &operator==(const ComplexVariable &x);
ComplexVariable &operator==(double times);
ComplexVariable &operator==(std::complex<double> x);
friend ComplexVariable &operator==(double times, const ComplexVariable &x);
friend ComplexVariable &operator==(std::complex<double> y, const ComplexVariable &x);
ComplexVariable &operator^(int times);
};
double solve(RealVariable &x);
std::complex<double> solve(ComplexVariable &y);
}; // namespace solver