8000 Adding complex types FloatComplex and DoubleComplex · wcork/arrayfire-java@cf6bb8b · GitHub
[go: up one dir, main page]

Skip to content

Commit cf6bb8b

Browse files
committed
Adding complex types FloatComplex and DoubleComplex
1 parent cdd0329 commit cf6bb8b

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

com/arrayfire/DoubleComplex.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
}

com/arrayfire/FloatComplex.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
}

0 commit comments

Comments
 (0)
0