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 {
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 
111  bool isspan() const;
112 
118  const af_index_t& get() const;
119 };
120 
131 
132 AFAPI array lookup(const array &in, const array &idx, const int dim = -1);
133 
134 }
135 #endif
136 
137 #ifdef __cplusplus
138 extern "C" {
139 #endif
140 
151 
153  const af_array in,
154  const unsigned ndims, const af_seq* const index);
155 
156 
168 
170  const af_array in, const af_array indices,
171  const unsigned dim);
172 
188 
190  const af_array lhs,
191  const unsigned ndims, const af_seq* const indices,
192  const af_array rhs);
193 
210  const af_array in,
211  const dim_t ndims, const af_index_t* indices);
212 
230  const af_array lhs,
231  const dim_t ndims, const af_index_t* indices,
232  const af_array rhs);
233 
234 #ifdef __cplusplus
235 }
236 #endif
Definition: algorithm.h:14
af_seq seq
The af_seq used for indexing.
Definition: index.h:26
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.
A multi dimensional data container.
Definition: array.h:27
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.
AFAPI array lookup(const array &in, const array &idx, const int dim=-1)
Lookup the values of input array based on index.
union af_index_t::@0 idx
Struct used while indexing af_array.
Definition: index.h:23
af_err
Definition: defines.h:58
Definition: seq.h:25
bool isSeq
If true the idx value represents a seq.
Definition: index.h:29
long long dim_t
Definition: defines.h:50
bool isBatch
If true the seq object is a batch parameter.
Definition: index.h:30
Wrapper for af_index.
Definition: index.h:52
#define AFAPI
Definition: defines.h:31
Definition: seq.h:13
af_array arr
The af_array used for indexing.
Definition: index.h:25
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:105
struct af_index_t af_index_t
Struct used while indexing af_array.
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.
void * af_array
Definition: defines.h:172
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.
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.