index.h (2020-07-07 17:43:34 +0530, (build 218dd2c99))
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  * https://arrayfire.com/licenses/BSD-3-Clause
8  ********************************************************/
9 
10 #pragma once
11 #include <af/defines.h>
12 #include <af/seq.h>
13 
22 typedef struct af_index_t {
23  union {
24  af_array arr;
25  af_seq seq;
26  } idx;
27 
28  bool isSeq;
29  bool isBatch;
31 
32 
33 #if __cplusplus
34 namespace af
35 {
36 
37 class dim4;
38 class array;
39 class seq;
40 
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 AF_COMPILER_CXX_RVALUE_REFERENCES
142  index(index &&idx0);
154  index& operator=(index &&idx0);
155 #endif
156 #endif // AF_API_VERSION
157 };
158 
169 AFAPI array lookup(const array &in, const array &idx, const int dim = -1);
170 
171 #if AF_API_VERSION >= 31
172 AFAPI void copy(array &dst, const array &src,
184  const index &idx0,
185  const index &idx1 = span,
186  const index &idx2 = span,
187  const index &idx3 = span);
188 #endif
189 
190 }
191 #endif
192 
193 #ifdef __cplusplus
194 extern "C" {
195 #endif
196 
208  const af_array in,
209  const unsigned ndims, const af_seq* const index);
210 
211 
224  const af_array in, const af_array indices,
225  const unsigned dim);
226 
243  const af_array lhs,
244  const unsigned ndims, const af_seq* const indices,
245  const af_array rhs);
246 
263  const af_array in,
264  const dim_t ndims, const af_index_t* indices);
265 
283  const af_array lhs,
284  const dim_t ndims, const af_index_t* indices,
285  const af_array rhs);
286 
287 #if AF_API_VERSION >= 32
299 #endif
300 
301 #if AF_API_VERSION >= 32
302  AFAPI af_err af_set_array_indexer(af_index_t* indexer, const af_array idx, const dim_t dim);
315 #endif
316 
317 #if AF_API_VERSION >= 32
318  AFAPI af_err af_set_seq_indexer(af_index_t* indexer, const af_seq* idx,
334  const dim_t dim, const bool is_batch);
335 #endif
336 
337 #if AF_API_VERSION >= 32
356  const double begin, const double end, const double step,
357  const dim_t dim, const bool is_batch);
358 #endif
359 
360 #if AF_API_VERSION >= 32
361  // \returns \ref af_err error code
372 #endif
373 
374 #ifdef __cplusplus
375 }
376 #endif
af_set_seq_param_indexer
AFAPI af_err af_set_seq_param_indexer(af_index_t *indexer, const double begin, const double end, const double step, const dim_t dim, const bool is_batch)
set dim to given indexer af_array idx
af_create_indexers
AFAPI af_err af_create_indexers(af_index_t **indexers)
Create an quadruple of af_index_t array.
af::index::index
index(const af::seq &s0)
Implicit seq converter.
af::seq
seq is used to create sequences for indexing af::array
Definition: seq.h:46
dim_t
long long dim_t
Definition: defines.h:56
af::index::index
index()
Default constructor.
af::lookup
AFAPI array lookup(const array &in, const array &idx, const int dim=-1)
Lookup the values of an input array by indexing with another array.
AFAPI
#define AFAPI
Definition: defines.h:38
af::array
A multi dimensional data container.
Definition: array.h:35
af
Definition: algorithm.h:15
af_index_t
Struct used to index an af_array.
Definition: index.h:22
af::index::index
index(const af_seq &s0)
Implicit seq converter.
af_index_t::idx
union af_index_t::@4 idx
af_index_t::isSeq
bool isSeq
If true the idx value represents a seq.
Definition: index.h:35
af_array
void * af_array
Definition: defines.h:240
af_index_t::isBatch
bool isBatch
If true the seq object is a batch parameter.
Definition: index.h:36
af::index::get
const af_index_t & get() const
Gets the underlying af_index_t object.
af::index::index
index(const af::array &idx0)
Implicit int converter.
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::index
Wrapper for af_index.
Definition: index.h:52
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
struct af_index_t af_index_t
Struct used to index an af_array.
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_index_t::seq
af_seq seq
The af_seq used for indexing.
Definition: index.h:39
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:327
af_index_t::arr
af_array arr
The af_array used for indexing.
Definition: index.h:38
af::span
AFAPI seq span
A special value representing the entire axis of an af::array.
seq.h
af::index::~index
~index()
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::isspan
bool isspan() const
Returns true if the af::index represents a af::span object.
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 an input array by indexing with another array.
af_release_indexers
AFAPI af_err af_release_indexers(af_index_t *indexers)
Release's the memory resource used by the quadruple af_index_t array.
af_err
af_err
Definition: defines.h:71
defines.h
af::index::index
index(const int idx)
Implicit int converter.
af_set_seq_indexer
AFAPI af_err af_set_seq_indexer(af_index_t *indexer, const af_seq *idx, const dim_t dim, const bool is_batch)
set dim to given indexer af_array idx
af::end
AFAPI int end
A special value representing the last value of an axis.
af_seq
C-style struct to creating sequences for indexing.
Definition: seq.h:20
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.
af_set_array_indexer
AFAPI af_err af_set_array_indexer(af_index_t *indexer, const af_array idx, const dim_t dim)
set dim to given indexer af_array idx