-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcomplex.h
executable file
·102 lines (82 loc) · 2.42 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* complex.h
* Author: Michael F. Hutt
* Jan. 1999
*
* Copyright (c) 1999 Michael F. Hutt
* Released under the MIT License
*
* Reference: Advanced Engineering Mathematics, by Erwin Kreyszig
* Seventh Edition, 1993, John Wiley & Sons, Inc.
*
*/
#ifndef _COMPLEX_H_
#define _COMPLEX_H_
#include <iostream>
#include <cmath>
#define PI acos(-1)
// define Complex class
//=========================================================================
class Complex {
private:
double real,imag;
public:
Complex(void); // default constructor
Complex(double r);
Complex(double r, double i);
double re(void);
friend double re(Complex z);
double im(void);
friend double im(Complex z);
Complex conj(void);
friend Complex conj(Complex z);
double abs(void);
friend double abs(Complex z);
double arg(void);
friend double arg(Complex z);
double norm(void);
friend double norm(Complex z);
Complex operator+(Complex z);
Complex operator+(double a);
friend Complex operator+(double a, Complex z);
Complex operator-(Complex a);
Complex operator-(double a);
friend Complex operator-(double a, Complex z);
friend Complex operator-(Complex z);
Complex operator*(Complex z);
Complex operator*(double a);
friend Complex operator*(double a, Complex z);
Complex operator/(Complex a);
Complex operator/(double a);
friend Complex operator/(double a, Complex z);
const Complex& operator+=(const Complex& z);
const Complex& operator-=(const Complex& z);
int operator==(Complex z);
friend Complex sqrt(Complex z);
friend Complex log(Complex z);
friend Complex exp(Complex z);
friend Complex pow(Complex z, double c);
friend Complex sin(Complex z);
friend Complex cos(Complex z);
friend Complex tan(Complex z);
friend Complex sec(Complex z);
friend Complex csc(Complex z);
friend Complex cot(Complex z);
friend Complex sinh(Complex z);
friend Complex cosh(Complex z);
friend Complex tanh(Complex z);
friend Complex sech(Complex z);
friend Complex csch(Complex z);
friend Complex coth(Complex z);
friend Complex asin(Complex z);
friend Complex acos(Complex z);
friend Complex atan(Complex z);
friend Complex asinh(Complex z);
friend Complex acosh(Complex z);
friend Complex atanh(Complex z);
friend std::ostream& operator<<(std::ostream& stream, Complex z);
Complex rnd(int precision);
friend Complex rnd(Complex z, int precision);
};
#endif