- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

index.h
Go to the documentation of this file.
1 /*******************************************************
2 * Copyright (c) 2014, ArrayFire
3 * All rights reserved.
4 *
5 * This file is distributed under 3-clause BSD license.
6 * The complete license agreement can be obtained at:
7 * http://arrayfire.com/licenses/BSD-3-Clause
8 ********************************************************/
9
10 #pragma once
11 #include <af/defines.h>
12 #include <af/seq.h>
13
23 typedef struct af_index_t{
24 union {
25 af_array arr;
26 af_seq seq;
27 } idx;
28
29 bool isSeq;
30 bool isBatch;
31 } af_index_t;
32
33
34 #if __cplusplus
35 namespace af
36 {
37
38 class dim4;
39 class array;
40 class seq;
41
52 class AFAPI index {
53
54 af_index_t impl;
55 public:
59 index();
60 ~index();
61
71 index(const int idx);
72
82 index(const af::seq& s0);
83
93 index(const af_seq& s0);
94
104 index(const af::array& idx0);
105
106 #if AF_API_VERSION >= 31
107 index(const index& idx0);
115 #endif
116
122 bool isspan() const;
123
129 const af_index_t& get() const;
130
131 #if AF_API_VERSION >= 31
132 index & operator=(const index& idx0);
140
141 #if __cplusplus > 199711L
142 index(index &&idx0);
154 index& operator=(index &&idx0);
155 #endif
156 #endif // AF_API_VERSION
157 };
158
169
170 AFAPI array lookup(const array &in, const array &idx, const int dim = -1);
171
172 #if AF_API_VERSION >= 31
173
185 AFAPI void copy(array &dst, const array &src,
186 const index &idx0,
187 const index &idx1 = span,
188 const index &idx2 = span,
189 const index &idx3 = span);
190 #endif
191
192 }
193 #endif
194
195 #ifdef __cplusplus
196 extern "C" {
197 #endif
198
209
210 AFAPI af_err af_index( af_array *out,
211 const af_array in,
212 const unsigned ndims, const af_seq* const index);
213
214
226
227 AFAPI af_err af_lookup( af_array *out,
228 const af_array in, const af_array indices,
229 const unsigned dim);
230
246
247 AFAPI af_err af_assign_seq( af_array *out,
248 const af_array lhs,
249 const unsigned ndims, const af_seq* const indices,
250 const af_array rhs);
251
267 AFAPI af_err af_index_gen( af_array *out,
268 const af_array in,
269 const dim_t ndims, const af_index_t* indices);
270
287 AFAPI af_err af_assign_gen( af_array *out,
288 const af_array lhs,
289 const dim_t ndims, const af_index_t* indices,
290 const af_array rhs);
291
292 #ifdef __cplusplus
293 }
294 #endif
af
Definition: algorithm.h:14
af_index_t::seq
af_seq seq
The af_seq used for indexing.
Definition: index.h:26
seq.h
af::array
A multi dimensional data container.
Definition: array.h:27
af_assign_seq
AFAPI af_err af_assign_seq(af_array *out, const af_array lhs, const unsigned ndims, const af_seq *const indices, const af_array rhs)
Copy and write values in the locations specified by the sequences.
af_index_t::idx
union af_index_t::@0 idx
af_index_t
Struct used while indexing af_array.
Definition: index.h:23
af_index_gen
AFAPI af_err af_index_gen(af_array *out, const af_array in, const dim_t ndims, const af_index_t *indices)
Indexing an array using af_seq, or af_array.
af_err
af_err
Definition: defines.h:67
af::span
AFAPI seq span
af::seq
Definition: seq.h:25
af_index_t::isSeq
bool isSeq
If true the idx value represents a seq.
Definition: index.h:29
defines.h
af::lookup
AFAPI array lookup(const array &in, const array &idx, const int dim=-1)
Lookup the values of input array based on index.
dim_t
long long dim_t
Definition: defines.h:50
af_index_t::isBatch
bool isBatch
If true the seq object is a batch parameter.
Definition: index.h:30
af::index
Wrapper for af_index.
Definition: index.h:52
AFAPI
#define AFAPI
Definition: defines.h:31
af_assign_gen
AFAPI af_err af_assign_gen(af_array *out, const af_array lhs, const dim_t ndims, const af_index_t *indices, const af_array rhs)
Assignment of an array using af_seq, or af_array.
af_seq
Definition: seq.h:13
af::copy
AFAPI void copy(array &dst, const array &src, const index &idx0, const index &idx1=span, const index &idx2=span, const index &idx3=span)
Copy the values of an input array based on index.
af_index_t::arr
af_array arr
The af_array used for indexing.
Definition: index.h:25
afcl::array
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:136
af_index_t
struct af_index_t af_index_t
Struct used while indexing af_array.
af_lookup
AFAPI af_err af_lookup(af_array *out, const af_array in, const af_array indices, const unsigned dim)
Lookup the values of input array based on index.
af_array
void * af_array
Definition: defines.h:187
af_index
AFAPI af_err af_index(af_array *out, const af_array in, const unsigned ndims, const af_seq *const index)
Lookup the values of input array based on sequences.