forked from arrayfire/arrayfire-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtil.java
More file actions
29 lines (25 loc) · 840 Bytes
/
Util.java
File metadata and controls
29 lines (25 loc) · 840 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
package com.arrayfire;
public class Util {
public static String toString(Array a, String delim) {
String ret_txt="";
try {
float[] fary = a.getFloatArray();
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;
}
}