-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathUtil.java
More file actions
34 lines (29 loc) · 876 Bytes
/
Util.java
File metadata and controls
34 lines (29 loc) · 876 Bytes
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
package com.arrayfire;
class Util extends ArrayFire {
public native static void info();
public static String toString(Array a, String delim) {
String ret_txt = "";
try {
float[] fary = Data.getFloatArray(a);
for (int k = 0; k < fary.length - 1; ++k) {
String temp = Float.toString(fary[k]) + delim;
ret_txt += temp;
}
ret_txt += Float.toString(fary[fary.length - 1]);
} catch (Exception e) {
ret_txt = "Failed to convert to string";
}
return ret_txt;
}
public static float[] toFloatArray(String text, String delim) {
String[] list = text.split(delim);
float[] ret_ary = new float[list.length];
for (int k = 0; k < list.length; ++k) {
ret_ary[k] = Float.parseFloat(list[k]);
}
return ret_ary;
}
public static int signbit(double x) {
return x < 0 ? -1 : 0;
}
}