A high-performance general-purpose compute library

- Main Page
- Tutorials
- 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
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;
30} af_index_t;
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
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
169 AFAPI array lookup(const array &in, const array &idx, const int dim = -1);
170
171#if AF_API_VERSION >= 31
183 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
207 AFAPI af_err af_index( af_array *out,
208 const af_array in,
209 const unsigned ndims, const af_seq* const index);
210
211
223 AFAPI af_err af_lookup( af_array *out,
224 const af_array in, const af_array indices,
225 const unsigned dim);
226
242 AFAPI af_err af_assign_seq( af_array *out,
243 const af_array lhs,
244 const unsigned ndims, const af_seq* const indices,
245 const af_array rhs);
246
262 AFAPI af_err af_index_gen( af_array *out,
263 const af_array in,
264 const dim_t ndims, const af_index_t* indices);
265
282 AFAPI af_err af_assign_gen( af_array *out,
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
298 AFAPI af_err af_create_indexers(af_index_t** indexers);
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
333 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
355 AFAPI af_err af_set_seq_param_indexer(af_index_t* indexer,
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
371 AFAPI af_err af_release_indexers(af_index_t* indexers);
372#endif
373
374#ifdef __cplusplus
375}
376#endif
af::array
A multi dimensional data container.
Definition array.h:37
af::index
Wrapper for af_index.
Definition index.h:52
af::index::index
index(const af::seq &s0)
Implicit seq converter.
af::index::index
index()
Default constructor.
af::index::index
index(const af::array &idx0)
Implicit int converter.
af::index::index
index(const af_seq &s0)
Implicit seq converter.
af::index::index
index(const index &idx0)
Copy constructor.
af::index::isspan
bool isspan() const
Returns true if the af::index represents a af::span object.
af::index::operator=
index & operator=(const index &idx0)
Assigns idx0 to this index.
af::index::~index
~index()
af::index::index
index(const int idx)
Implicit int converter.
af::index::get
const af_index_t & get() const
Gets the underlying af_index_t object.
af::seq
seq is used to create sequences for indexing af::array
Definition seq.h:46
defines.h
dim_t
long long dim_t
Definition defines.h:56
af_err
af_err
Definition defines.h:71
af_array
void * af_array
Definition defines.h:240
AFAPI
#define AFAPI
Definition defines.h:38
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_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_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_create_indexers
AFAPI af_err af_create_indexers(af_index_t **indexers)
Create an quadruple of af_index_t array.
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_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::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_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_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
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_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::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.
af_index_t
struct af_index_t af_index_t
Struct used to index an af_array.
af
Definition algorithm.h:15
af::span
AFAPI seq span
A special value representing the entire axis of an af::array.
seq.h
af_index_t
Struct used to index an af_array.
Definition index.h:22
af_index_t::arr
af_array arr
The af_array used for indexing.
Definition index.h:24
af_index_t::isSeq
bool isSeq
If true the idx value represents a seq.
Definition index.h:28
af_index_t::isBatch
bool isBatch
If true the seq object is a batch parameter.
Definition index.h:29
af_index_t::seq
af_seq seq
The af_seq used for indexing.
Definition index.h:25
af_index_t::idx
union af_index_t::@4 idx
af_seq
C-style struct to creating sequences for indexing.
Definition seq.h:20