forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.dox
More file actions
359 lines (244 loc) · 9.53 KB
/
Copy pathdata.dox
File metadata and controls
359 lines (244 loc) · 9.53 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/**
\addtogroup arrayfire_func
@{
\defgroup data_func_constant constant
\brief Create a array from a scalar input value
The array created has the same value at all locations
\ingroup data_mat
\ingroup arrayfire_func
=======================================================================
\defgroup data_func_pad pad
\brief Pad an array
Pad the input array using a constant or values from input along border
\ingroup data_mat
\ingroup arrayfire_func
=======================================================================
\defgroup data_func_identity identity
\brief Create an identity array with diagonal values 1
\code
array a = identity(5, 3);
// a [5 3 1 1]
// 1.0000 0.0000 0.0000
// 0.0000 1.0000 0.0000
// 0.0000 0.0000 1.0000
// 0.0000 0.0000 0.0000
// 0.0000 0.0000 0.0000
\endcode
\ingroup data_mat
\ingroup arrayfire_func
=======================================================================
\defgroup data_func_range range
\brief Creates an array with [0, n] values along the seq_dim which is tiled across other dimensions
\code
// Generates an array of [0, 4] along first dimension
array a = range(dim4(5)); // a = [0,
// 1,
// 2,
// 3,
// 4]
// Generates an array of [0, 4] along first dimension, tiled along second dimension
array b = range(dim4(5, 2)); // a = [0, 0,
// 1, 1,
// 2, 2,
// 3, 3,
// 4, 4]
// Generates an array of [0, 2] along second dimension, tiled along first dimension
array c = range(dim4(5, 3), 1); // c = [0, 1, 2,
// 0, 1, 2,
// 0, 1, 2,
// 0, 1, 2,
// 0, 1, 2]
\endcode
\ingroup data_mat
\ingroup arrayfire_func
=======================================================================
\defgroup data_func_iota iota
\brief Create an sequence [0, dims.elements() - 1] and modify to specified dimensions dims and then tile it according to tile_dims
\code
// Generate [0, 5x3 - 1] in dimensions 5, 3
array a = iota(dim4(5, 3))
// a [5 3 1 1]
// 0.0000 5.0000 10.0000
// 1.0000 6.0000 11.0000
// 2.0000 7.0000 12.0000
// 3.0000 8.0000 13.0000
// 4.0000 9.0000 14.0000
// Generate [0, 5x3 - 1] in dimensions 5, 3 and then tile once along
// dim0 and twice along dim1
array b = iota(dim4(5, 3), dim4(1, 2))
// b [5 6 1 1]
// 0.0000 5.0000 10.0000 0.0000 5.0000 10.0000
// 1.0000 6.0000 11.0000 1.0000 6.0000 11.0000
// 2.0000 7.0000 12.0000 2.0000 7.0000 12.0000
// 3.0000 8.0000 13.0000 3.0000 8.0000 13.0000
// 4.0000 9.0000 14.0000 4.0000 9.0000 14.0000
\endcode
\ingroup data_mat
\ingroup arrafire_func
=======================================================================
\defgroup data_func_diag diag
\brief Extract diagonal from a matrix when \p extract is set to true. Create a diagonal matrix from input array when \p extract is set to false
\code
// Extraction
array a = randu(dim4(4, 3));
// a [4 3 1 1]
// 0.0000 0.5328 0.6793
// 0.1315 0.2190 0.9347
// 0.7556 0.0470 0.3835
// 0.4587 0.6789 0.5194
array b = diag(a);
// b [3 1 1 1]
// 0.0000
// 0.2190
// 0.3835
array c = diag(a, 1);
// c [2 1 1 1]
// 0.5328
// 0.9347
// Creation
array a = randu(4);
// a [4 1 1 1]
// 0.0000
// 0.1315
// 0.7556
// 0.4587
array b = diag(a, 0, false);
// b [4 4 1 1]
// 0.0000 0.0000 0.0000 0.0000
// 0.0000 0.1315 0.0000 0.0000
// 0.0000 0.0000 0.7556 0.0000
// 0.0000 0.0000 0.0000 0.4587
array b = diag(a, -1, false);
// c [5 5 1 1]
// 0.0000 0.0000 0.0000 0.0000 0.0000
// 0.0000 0.0000 0.0000 0.0000 0.0000
// 0.0000 0.1315 0.0000 0.0000 0.0000
// 0.0000 0.0000 0.7556 0.0000 0.0000
// 0.0000 0.0000 0.0000 0.4587 0.0000
\endcode
\ingroup data_mat
\ingroup arrayfire_func
=======================================================================
\defgroup manip_func_join join
\brief Join up to 4 arrays along specified dimension.
Requires that all dimensions except the join dimension must be the same for all arrays.
\ingroup manip_mat
\ingroup arrayfire_func
=======================================================================
\defgroup manip_func_tile tile
\brief Repeat the contents of the input array along the specified dimensions
Creates copies of the input array and concatenates them with each other, such
that the output array will have as many copies of the input array as the user
specifies, along each dimension. In this sense, the output array is essentially
a set of "tiles", where each copy of the input array (including the original) is
a "tile" (hence the name of this function).
Given below are some examples. The input array looks like this:
\snippet test/tile.cpp ex_tile_input
Here, the input array is tiled along the first dimenson, 2 times:
\snippet test/tile.cpp ex_tile_0_2
Here, the input is tiled along the second dimension, 3 times:
\snippet test/tile.cpp ex_tile_1_3
Lastly, one can also tile along multiple dimensions simultaneously. Here, the
input is tiled 2 times in the first dimension and 3 times in the second
dimension:
\snippet test/tile.cpp ex_tile_0_2_and_1_3
\ingroup manip_mat
\ingroup arrayfire_func
=======================================================================
\defgroup manip_func_reorder reorder
\brief Reorder an array according to the specified dimensions.
Exchanges data of an array such that the requested change in dimension
is satisfied. The linear ordering of data within the array is preserved.
\code
a [2 2 3 1]
1.0000 3.0000
2.0000 4.0000
1.0000 3.0000
2.0000 4.0000
1.0000 3.0000
2.0000 4.0000
reorder(a, 1, 0, 2) [2 2 3 1] //equivalent to a transpose
1.0000 2.0000
3.0000 4.0000
1.0000 2.0000
3.0000 4.0000
1.0000 2.0000
3.0000 4.0000
reorder(a, 2, 0, 1) [3 2 2 1]
1.0000 2.0000
1.0000 2.0000
1.0000 2.0000
3.0000 4.0000
3.0000 4.0000
3.0000 4.0000
\endcode
\ingroup manip_mat
\ingroup arrayfire_func
=======================================================================
\defgroup manip_func_shift shift
\brief Circular shift slong specified dimensions
Shifts the values in a circular fashion along the specified dimesion.
\ingroup manip_mat
\ingroup arrayfire_func
=======================================================================
\defgroup manip_func_moddims moddims
\brief Modify the input dimensions without changing the data order
Simply modifies the metadata. This is a noop.
\ingroup manip_mat
\ingroup arrayfire_func
=======================================================================
\defgroup manip_func_flat flat
\brief Flatten the input to a single dimension
Simply returns the array as a vector. This is a noop.
\ingroup manip_mat
\ingroup arrayfire_func
=======================================================================
\defgroup manip_func_flip flip
\brief Flip the input along specified dimension
Mirrors the array along the specified dimensions.
\ingroup manip_mat
\ingroup arrayfire_func
=======================================================================
\defgroup data_func_lower lower
\brief Create a lower triangular matrix from input array
\ingroup data_mat
\ingroup arrayfire_func
=======================================================================
\defgroup data_func_upper upper
\brief Create a upper triangular matrix from input array
\ingroup data_mat
\ingroup arrayfire_func
=======================================================================
\defgroup data_func_select select
\brief Selects elements from two arrays based on the values of a binary
conditional array.
Creates a new array that is composed of values either from array \p a or array
\p b, based on a third conditional array. For all non-zero elements in the
conditional array, the output array will contain values from \p a. Otherwise the
output will contain values from \p b.
\snippet test/select.cpp ex_data_select
is equivalent to:
\snippet test/select.cpp ex_data_select_c
The conditional array must be a b8 typed array.
The select function can perform batched operations based on the size of each of
the inputs. The following table describes the input and output sizes for
supported batched configurations.
| Output | Condition Array | Array A | Array B |
|--------|-----------------|---------|---------|
| (M, N) | (M, 1) | (M, 1) | (M, N) |
| (M, N) | (M, 1) | (M, N) | (M, 1) |
| (M, N) | (M, 1) | (M, N) | (M, N) |
| (M, N) | (M, N) | (M, 1) | (M, N) |
| (M, N) | (M, N) | (M, 1) | (M, N) |
\ingroup manip_mat
\ingroup arrayfire_func
=======================================================================
\defgroup data_func_replace replace
\brief Replace elements of an array based on a conditional array
- Input values are retained when corresponding elements from condition array are true.
- Input values are replaced when corresponding elements from condition array are false.
\ingroup manip_mat
\ingroup arrayfire_func
=======================================================================
@}
*/