1
1
package com .arrayfire ;
2
2
3
- import com .arrayfire .Util ;
3
+ import com .arrayfire .Index ;
4
4
5
5
public class ArrayFire extends AFLibLoader {
6
6
7
+ public static final Seq SPAN = Seq .span ();
7
8
/* ************* Algorithm ************* */
8
9
9
- // Scalar return operations
10
+
11
+ /**
12
+ * Sum all the elements in an Array, wraps {@link http://arrayfire.org/docs/group__reduce__func__sum.htm }
13
+ * @param a the array to be summed
14
+ * @return the sum
15
+ * @throws Exception
16
+ * @see Array
17
+ */
10
18
public static double sumAll (Array a ) throws Exception {
11
19
return Algorithm .sumAll (a );
12
20
}
13
21
22
+ /**
23
+ * Finds the maximum value in an array, wraps {@link http://arrayfire.org/docs/group__reduce__func__max.htm}
24
+ * @param a the input array
25
+ * @return the maximum value
26
+ * @throws Exception
27
+ * @see Array
28
+ */
14
29
public static double maxAll (Array a ) throws Exception {
15
30
return Algorithm .maxAll (a );
16
31
}
17
32
33
+ /**
34
+ * Finds the minimum value in an array, wraps {@link http://arrayfire.org/docs/group__reduce__func__min.htm}.
35
+ * @param a the input array
36
+ * @return the minimum value
37
+ * @throws Exception
38
+ * @see Array
39
+ */
18
40
public static double minAll (Array a ) throws Exception {
19
41
return Algorithm .minAll (a );
20
42
}
21
43
44
+ /**
45
+ * Finds the sum of an array across 1 dimension and stores the result in a 2nd array.
46
+ * @param res the array in which to store the result
47
+ * @param a the input array
48
+ * @param dim the dimension across which to find the sum
49
+ * @throws Exception
50
+ * @see Array
51
+ */
22
52
public static void sum (Array res , Array a , int dim ) throws Exception {
23
53
Algorithm .sum (res , a , dim );
24
54
}
25
55
56
+ /**
57
+ * Finds the maximum values of an array across 1 dimension and stores the result in a 2nd array.
58
+ * @param res the array in which to store the result.
59
+ * @param a the input array
60
+ * @param dim the dimenstion across which to find the maximum values
61
+ * @throws Exception
62
+ * @see Array
63
+ */
26
64
public static void max (Array res , Array a , int dim ) throws Exception {
27
65
Algorithm .max (res , a , dim );
28
66
}
29
67
68
+ /**
69
+ * Finds the minimum values in an array across 1 dimenstion and stores the result in a 2nd array.
70
+ * @param res the array in which to store the result
71
+ * @param a the input array
72
+ * @param dim the dimension across which to find the maximum values
73
+ * @throws Exception
74
+ * @see Array
75
+ */
30
76
public static void min (Array res , Array a , int dim ) throws Exception {
31
77
Algorithm .min (res , a , dim );
32
78
}
33
79
80
+
81
+ /**
82
+ * Finds the sum of values in an array across all dimenstion and stores the result in a 2nd array.
83
+ * @param res the array in which to store the result
84
+ * @param a the input array
85
+ * @throws Exception
86
+ * @see Array
87
+ */
34
88
public static void sum (Array res , Array a ) throws Exception {
35
89
Algorithm .sum (res , a );
36
90
}
37
91
92
+ /**
93
+ * Finds the max values in an array across all dimenstion and stores the result in a 2nd array.
94
+ * @param res the array in which to store the result
95
+ * @param a the input array
96
+ * @throws Exception
97
+ * @see Array
98
+ */
38
99
public static void max (Array res , Array a ) throws Exception {
39
100
Algorithm .max (res , a );
40
101
}
41
102
103
+ /**
104
+ * Finds the minimum values in an array across all dimenstion and stores the result in a 2nd array.
105
+ * @param res the array in which to store the result
106
+ * @param a the input array
107
+ * @throws Exception
108
+ * @see Array
109
+ */
42
110
public static void min (Array res , Array a ) throws Exception {
43
111
Algorithm .min (res , a , 0 );
44
112
}
45
113
114
+ /**
115
+ * Finds the indices of all non-zero values in an input array, wraps {@link http://arrayfire.org/docs/group__scan__func__where.htm}
116
+ * @param in the input array
117
+ * @return an array containing the indices of all non-zero values in the input array
118
+ * @throws Exception
119
+ */
120
+ public static Array where (final Array in ) throws Exception {
121
+ return Algorithm .where (in );
122
+ }
123
+
46
124
/* ************* Arith ************* */
47
125
126
+ /**
127
+ * Performs element-wise addition between 2 arrays and stores the result in another array, wraps {@link http://arrayfire.org/docs/group__arith__func__add.htm}
128
+ * @param c the resulting array
129
+ * @param a the lhs array
130
+ * @param b the rhs array
131
+ * @return the resulting array
132
+ * @throws Exception
133
+ */
48
134
public static void add (Array c , Array a , Array b ) throws Exception {
49
135
Arith .add (c , a , b );
50
136
}
51
137
138
+ /**
139
+ * Subtracts 2 arrays, storing the result in another array, wraps {@link http://arrayfire.org/docs/group__arith__func__sub.htm}
140
+ * @param c the resulting array
141
+ * @param a the lhs array
142
+ * @param b the rhs array
143
+ * @return the resulting array
144
+ * @throws Exception
145
+ */
52
146
public static void sub (Array c , Array a , Array b ) throws Exception {
53
147
Arith .sub (c , a , b );
54
148
}
55
149
150
+ /**
151
+ * Performs element-wise multiplication between 2 arrays, wraps {@link http://arrayfire.org/docs/group__arith__func__mul.htm}
152
+ * @param c the resulting array
153
+ * @param a the lhs array
154
+ * @param b the rhs array
155
+ * @return the resulting array
156
+ * @throws Exception
157
+ */
56
158
public static void mul (Array c , Array a , Array b ) throws Exception {
57
159
Arith .mul (c , a , b );
58
160
}
59
161
162
+ /**
163
+ * Divides one array by another array, wraps {@link http://arrayfire.org/docs/group__arith__func__div.htm}
164
+ * @param c the resulting array
165
+ * @param a the lhs array
166
+ * @param b the rhs array
167
+ * @return the resulting array
168
+ * @throws Exception
169
+ */
60
170
public static void div (Array c , Array a , Array b ) throws Exception {
61
171
Arith .div (c , a , b );
62
172
}
63
173
174
+ /**
175
+ * Checks if an array is less than or equal to another, wraps {@link http://arrayfire.org/docs/group__arith__func__le.htm}.
176
+ * @param c the resulting array
177
+ * @param a the lhs array
178
+ * @param b the rhs array
179
+ * @return the resulting array
180
+ * @throws Exception
181
+ */
64
182
public static void le (Array c , Array a , Array b ) throws Exception {
65
183
Arith .le (c , a , b );
66
184
}
67
185
186
+ /**
187
+ * Checks if an array is less than another, wraps {@link http://arrayfire.org/docs/group__arith__func__lt.htm}
188
+ * @param c the resulting array
189
+ * @param a the lhs array
190
+ * @param b the rhs array
191
+ * @return the resulting array
192
+ * @throws Exception
193
+ */
68
194
public static void lt (Array c , Array a , Array b ) throws Exception {
69
195
Arith .lt (c , a , b );
70
196
}
71
197
198
+ /**
199
+ * Checks if an array is greater than or equal to another, wraps {@link http://arrayfire.org/docs/group__arith__func__ge.htm}
200
+ * @param c the resulting array
201
+ * @param a the lhs array
202
+ * @param b the rhs array
203
+ * @return the resulting array
204
+ * @throws Exception
205
+ */
72
206
public static void ge (Array c , Array a , Array b ) throws Exception {
73
207
Arith .ge (c , a , b );
74
208
}
75
209
210
+ /**
211
+ * Checks if an array is greater than another, wraps {@link http://arrayfire.org/docs/group__arith__func__gt.htm}
212
+ * @param c the resulting array
213
+ * @param a the lhs array
214
+ * @param b the rhs array
215
+ * @return the resulting array
216
+ * @throws Exception
217
+ */
76
218
public static void gt (Array c , Array a , Array b ) throws Exception {
77
219
Arith .gt (c , a , b );
78
220
}
79
221
222
+ /**
223
+ * Checks if 2 input arrays are equal, wraps {@link http://arrayfire.org/docs/group__arith__func__eq.htm}
224
+ * @param c the resulting array
225
+ * @param a the lhs array
226
+ * @param b the rhs array
227
+ * @return the resulting array
228
+ * @throws Exception
229
+ */
80
230
public static void eq (Array c , Array a , Array b ) throws Exception {
81
231
Arith .eq (c , a , b );
82
232
}
83
233
234
+ /**
235
+ * Checks if 2 input arrays are not equal, wraps {@link http://arrayfire.org/docs/group__arith__func__neq.htm}
236
+ * @param c the resulting array
237
+ * @param a the lhs array
238
+ * @param b the rhs array
239
+ * @return the resulting array
240
+ * @throws Exception
241
+ */
84
242
public static void neq (Array c , Array a , Array b ) throws Exception {
85
243
Arith .neq (c , a , b );
86
244
}
@@ -491,6 +649,33 @@ static public <T> T castResult(DoubleComplex res, Class<T> type) throws Exceptio
491
649
return Statistics .castResult (res , type );
492
650
}
493
651
652
+ /* ************* Index ************* */
653
+
654
+
655
+ public static Array lookup (final Array in , final Array idx , int dim ) throws Exception {
656
+ return Index .lookup (in , idx , dim );
657
+ }
658
+
659
+ public static Array lookup (final Array in , final Array idx ) throws Exception {
660
+ return Index .lookup (in , idx , 0 );
661
+ }
662
+
663
+ public static void copy (Array dst , final Array src , Index idx0 , Index idx1 , Index idx2 , Index idx3 ) throws Exception {
664
+ Index .copy (dst , src , idx0 , idx1 , idx2 , idx3 );
665
+ }
666
+
667
+ public static void copy (Array dst , final Array src , Index idx0 , Index idx1 , Index idx2 ) throws Exception {
668
+ Index .copy (dst , src , idx0 , idx1 , idx2 , new Index ());
669
+ }
670
+
671
+ public static void copy (Array dst , final Array src , Index idx0 , Index idx1 ) throws Exception {
672
+ Index .copy (dst , src , idx0 , idx1 , new Index (), new Index ());
673
+ }
674
+
675
+ public static void copy (Array dst , final Array src , Index idx0 ) throws Exception {
676
+ Index .copy (dst , src , idx0 , new Index (), new Index (), new Index ());
677
+ }
678
+
494
679
// Utils
495
680
496
681
public static String toString (Array a , String delim ) {
@@ -505,7 +690,6 @@ public static void info() {
505
690
Util .info ();
506
691
}
507
692
508
-
509
693
// Enums
510
694
511
695
public static enum Type {
0 commit comments