There are several ways of referencing values. ArrayFire uses parenthesis for subscripted referencing instead of the traditional square bracket notation. Indexing is zero-based, i.e. the first element is at index zero (A(0)
). Indexing can be done with mixtures of:
See Indexing for the full listing.
float b_host[] = {0,1,2,3,4,5,6,7,8,9};
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.
Definition: opencl.h:329
#define af_print(...)
Definition: util.h:141
You can set values in an array:
A.row(0) = -1;
A(seq(3)) = 3.1415;
@ s32
32-bit signed integral values
Definition: defines.h:201
@ f32
32-bit floating point values
Definition: defines.h:196
array constant(T val, const dim4 &dims, const dtype ty=(af_dtype) dtype_traits< T >::ctype)
AFAPI array randu(const dim4 &dims, const dtype ty=f32)
Use one array to reference into another.
float h_inds[] = {0, 4, 2, 1};
array inds(1, 4, h_inds);
B(inds) = -1;