index.h (2022-02-24 14:07:56 -0500, (build 8c2561559))
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
22typedef struct af_index_t {
23 union {
26 } idx;
27
28 bool isSeq;
29 bool isBatch;
31
32
33#if __cplusplus
34namespace af
35{
36
37class dim4;
38class array;
39class seq;
40
52class AFAPI index {
53
54 af_index_t impl;
55 public:
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
114 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
139 index & operator=(const index& idx0);
140
141#if AF_COMPILER_CXX_RVALUE_REFERENCES
147 index(index &&idx0);
154 index& operator=(index &&idx0);
155#endif
156#endif // AF_API_VERSION
157};
158
169AFAPI array lookup(const array &in, const array &idx, const int dim = -1);
170
171#if AF_API_VERSION >= 31
183AFAPI 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
194extern "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
314 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
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
367 // \returns \ref af_err error code
372#endif
373
374#ifdef __cplusplus
375}
376#endif
A multi dimensional data container.
Definition: array.h:37
Wrapper for af_index.
Definition: index.h:52
index(const af::seq &s0)
Implicit seq converter.
index()
Default constructor.
index(const af::array &idx0)
Implicit int converter.
index(const af_seq &s0)
Implicit seq converter.
index(const index &idx0)
Copy constructor.
bool isspan() const
Returns true if the af::index represents a af::span object.
index & operator=(const index &idx0)
Assigns idx0 to this index.
index(const int idx)
Implicit int converter.
const af_index_t & get() const
Gets the underlying af_index_t object.
seq is used to create sequences for indexing af::array
Definition: seq.h:46
long long dim_t
Definition: defines.h:56
af_err
Definition: defines.h:71
void * af_array
Definition: defines.h:240
#define AFAPI
Definition: defines.h:38
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.
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_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.
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.
AFAPI af_err af_create_indexers(af_index_t **indexers)
Create an quadruple of af_index_t array.
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 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
AFAPI af_err af_release_indexers(af_index_t *indexers)
Release's the memory resource used by the quadruple af_index_t array.
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
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
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 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.
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
struct af_index_t af_index_t
Struct used to index an af_array.
Definition: algorithm.h:15
AFAPI int end
A special value representing the last value of an axis.
AFAPI seq span
A special value representing the entire axis of an af::array.
Struct used to index an af_array.
Definition: index.h:22
af_array arr
The af_array used for indexing.
Definition: index.h:24
bool isSeq
If true the idx value represents a seq.
Definition: index.h:28
bool isBatch
If true the seq object is a batch parameter.
Definition: index.h:29
af_seq seq
The af_seq used for indexing.
Definition: index.h:25
union af_index_t::@4 idx
C-style struct to creating sequences for indexing.
Definition: seq.h:20