-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplex.java
More file actions
65 lines (50 loc) · 1.39 KB
/
complex.java
File metadata and controls
65 lines (50 loc) · 1.39 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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package fourier_images;
/**
*
* @author erikp
*/
public class complex {
public double real;
public double imag;
public complex() {
this.real = 0;
this.imag = 0;
}
public complex(double real, double imag) {
this.real = real;
this.imag = imag;
}
public complex(complex c) {
this.real = c.real;
this.imag = c.imag;
}
public double getReal() {
return real;
}
public void setReal(double real) {
this.real = real;
}
public double getImag() {
return imag;
}
public void setImag(double imag) {
this.imag = imag;
}
@Override
public String toString() {
return "complex{" + "real=" + real + ", imag=" + imag + '}';
}
public complex add(complex a) {
return new complex(a.real + this.real, a.imag + this.imag);
}
public complex sub(complex a) {
return new complex(this.real - a.real, this.imag - a.imag);
}
public complex mult(complex a) {
return new complex(a.real * this.real - a.imag * this.imag, a.real * this.imag + a.imag * this.real);
}
}