File tree Expand file tree Collapse file tree 2 files changed +88
-0
lines changed Expand file tree Collapse file tree 2 files changed +88
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .arrayfire ;
2
+
3
+ public class DoubleComplex {
4
+ private double real ;
5
+ private double imag ;
6
+
7
+ public double real () {
8
+ return real ;
9
+ }
10
+
11
+ public double imag () {
12
+ return imag ;
13
+ }
14
+
15
+ public void set (double re , double im ) {
16
+ real = re ;
17
+ imag = im ;
18
+ }
19
+
20
+ public void setReal (double re ) {
21
+ real = re ;
22
+ }
23
+
24
+ public void setImag (double im ) {
25
+ imag = im ;
26
+ }
27
+
28
+ public DoubleComplex (double re , double im ) {
29
+ set (re , im );
30
+ }
31
+
32
+ public DoubleComplex () {
33
+ set (0 , 0 );
34
+ }
35
+
36
+ public String toString () {
37
+ String str = String .valueOf (real );
38
+
39
+ if (imag < 0 ) str = str + " - " ;
40
+ else str = str + " + " ;
41
+
42
+ return str + String .valueOf (Math .abs (imag )) + "i" ;
43
+ }
44
+ }
Original file line number Diff line number Diff line change
1
+ package com .arrayfire ;
2
+
3
+ public class FloatComplex {
4
+ private float real ;
5
+ private float imag ;
6
+
7
+ public float real () {
8
+ return real ;
9
+ }
10
+
11
+ public float imag () {
12
+ return imag ;
13
+ }
14
+
15
+ public void set (float re , float im ) {
16
+ real = re ;
17
+ imag = im ;
18
+ }
19
+
20
+ public void setReal (float re ) {
21
+ real = re ;
22
+ }
23
+
24
+ public void setImag (float im ) {
25
+ imag = im ;
26
+ }
27
+
28
+ public FloatComplex (float re , float im ) {
29
+ set (re , im );
30
+ }
31
+
32
+ public FloatComplex () {
33
+ set (0 , 0 );
34
+ }
35
+
36
+ public String toString () {
37
+ String str = String .valueOf (real );
38
+
39
+ if (imag < 0 ) str = str + " - " ;
40
+ else str = str + " + " ;
41
+
42
+ return str + String .valueOf (Math .abs (imag )) + "i" ;
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments