data.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
13#ifdef __cplusplus
14#include <af/dim4.hpp>
15#include <af/traits.hpp>
16namespace af
17{
18 class array;
19
30 template<typename T>
31 array constant(T val, const dim4 &dims, const dtype ty=(af_dtype)dtype_traits<T>::ctype);
32
43 template<typename T>
45
56 template<typename T>
57 array constant(T val, const dim_t d0, const dim_t d1, const af_dtype ty=(af_dtype)dtype_traits<T>::ctype);
58
70 template<typename T>
71 array constant(T val, const dim_t d0, const dim_t d1, const dim_t d2, const af_dtype ty=(af_dtype)dtype_traits<T>::ctype);
72
85 template<typename T>
86 array constant(T val, const dim_t d0, const dim_t d1, const dim_t d2, const dim_t d3, const af_dtype ty=(af_dtype)dtype_traits<T>::ctype);
87
96 AFAPI array identity(const dim4 &dims, const dtype ty=f32);
97
106 AFAPI array identity(const dim_t d0, const dtype ty=f32);
107
117 AFAPI array identity(const dim_t d0, const dim_t d1, const dtype ty=f32);
118
129 AFAPI array identity(const dim_t d0, const dim_t d1,
130 const dim_t d2, const dtype ty=f32);
131
143 AFAPI array identity(const dim_t d0, const dim_t d1,
144 const dim_t d2, const dim_t d3, const dtype ty=f32);
145
155 AFAPI array range(const dim4 &dims, const int seq_dim = -1, const dtype ty=f32);
156
169 AFAPI array range(const dim_t d0, const dim_t d1 = 1, const dim_t d2 = 1,
170 const dim_t d3 = 1, const int seq_dim = -1, const dtype ty=f32);
171
181 AFAPI array iota(const dim4 &dims, const dim4 &tile_dims = dim4(1), const dtype ty=f32);
182
193 AFAPI array diag(const array &in, const int num = 0, const bool extract = true);
194
207 AFAPI array join(const int dim, const array &first, const array &second);
208
222 AFAPI array join(const int dim, const array &first, const array &second, const array &third);
223
238 AFAPI array join(const int dim, const array &first, const array &second,
239 const array &third, const array &fourth);
240
255 AFAPI array tile(const array &in, const unsigned x, const unsigned y=1,
256 const unsigned z=1, const unsigned w=1);
257
269 AFAPI array tile(const array &in, const dim4 &dims);
270
281 AFAPI array reorder(const array& in, const unsigned x,
282 const unsigned y=1, const unsigned z=2, const unsigned w=3);
283
295 AFAPI array shift(const array& in, const int x, const int y=0, const int z=0, const int w=0);
296
305 AFAPI array moddims(const array& in, const unsigned ndims, const dim_t * const dims);
306
314 AFAPI array moddims(const array& in, const dim4& dims);
315
326 AFAPI array moddims(const array& in, const dim_t d0, const dim_t d1=1, const dim_t d2=1, const dim_t d3=1);
327
334 AFAPI array flat(const array &in);
335
343 AFAPI array flip(const array &in, const unsigned dim);
344
352 AFAPI array lower(const array &in, bool is_unit_diag=false);
353
361 AFAPI array upper(const array &in, bool is_unit_diag=false);
362
363#if AF_API_VERSION >= 31
372 AFAPI array select(const array &cond, const array &a, const array &b);
373#endif
374
375#if AF_API_VERSION >= 31
384 AFAPI array select(const array &cond, const array &a, const double &b);
385#endif
386
387#if AF_API_VERSION >= 31
396 AFAPI array select(const array &cond, const double &a, const array &b);
397#endif
398
399#if AF_API_VERSION >= 31
409 AFAPI void replace(array &a, const array &cond, const array &b);
410#endif
411
412#if AF_API_VERSION >= 31
422 AFAPI void replace(array &a, const array &cond, const double &b);
423#endif
424
425#if AF_API_VERSION >= 37
438 AFAPI array pad(const array &in, const dim4 &beginPadding,
439 const dim4 &endPadding, const borderType padFillType);
440#endif
441}
442#endif
443
444#ifdef __cplusplus
445extern "C" {
446#endif
456 AFAPI af_err af_constant(af_array *arr, const double val, const unsigned ndims, const dim_t * const dims, const af_dtype type);
457
469 AFAPI af_err af_constant_complex(af_array *arr, const double real, const double imag,
470 const unsigned ndims, const dim_t * const dims, const af_dtype type);
471
481 AFAPI af_err af_constant_long (af_array *arr, const long long val, const unsigned ndims, const dim_t * const dims);
482
492 AFAPI af_err af_constant_ulong(af_array *arr, const unsigned long long val, const unsigned ndims, const dim_t * const dims);
493
503 AFAPI af_err af_range(af_array *out, const unsigned ndims, const dim_t * const dims,
504 const int seq_dim, const af_dtype type);
505
516 AFAPI af_err af_iota(af_array *out, const unsigned ndims, const dim_t * const dims,
517 const unsigned t_ndims, const dim_t * const tdims, const af_dtype type);
518
519
528 AFAPI af_err af_identity(af_array *out, const unsigned ndims, const dim_t * const dims, const af_dtype type);
529
537 AFAPI af_err af_diag_create(af_array *out, const af_array in, const int num);
538
546 AFAPI af_err af_diag_extract(af_array *out, const af_array in, const int num);
547
560 AFAPI af_err af_join(af_array *out, const int dim, const af_array first, const af_array second);
561
576 AFAPI af_err af_join_many(af_array *out, const int dim, const unsigned n_arrays, const af_array *inputs);
577
593 const unsigned x, const unsigned y, const unsigned z, const unsigned w);
594
606 const unsigned x, const unsigned y, const unsigned z, const unsigned w);
607
618 AFAPI af_err af_shift(af_array *out, const af_array in, const int x, const int y, const int z, const int w);
619
628 AFAPI af_err af_moddims(af_array *out, const af_array in, const unsigned ndims, const dim_t * const dims);
629
637
645 AFAPI af_err af_flip(af_array *out, const af_array in, const unsigned dim);
646
654 AFAPI af_err af_lower(af_array *out, const af_array in, bool is_unit_diag);
655
663 AFAPI af_err af_upper(af_array *out, const af_array in, bool is_unit_diag);
664
665#if AF_API_VERSION >= 31
674 AFAPI af_err af_select(af_array *out, const af_array cond, const af_array a, const af_array b);
675#endif
676
677#if AF_API_VERSION >= 31
686 AFAPI af_err af_select_scalar_r(af_array *out, const af_array cond, const af_array a, const double b);
687#endif
688
689#if AF_API_VERSION >= 31
698 AFAPI af_err af_select_scalar_l(af_array *out, const af_array cond, const double a, const af_array b);
699#endif
700
701#if AF_API_VERSION >= 31
712#endif
713
714#if AF_API_VERSION >= 31
724 AFAPI af_err af_replace_scalar(af_array a, const af_array cond, const double b);
725#endif
726
727#if AF_API_VERSION >= 37
742 const unsigned begin_ndims,
743 const dim_t *const begin_dims, const unsigned end_ndims,
744 const dim_t *const end_dims,
745 const af_border_type pad_fill_type);
746#endif
747
748#ifdef __cplusplus
749}
750#endif
A multi dimensional data container.
Definition: array.h:37
Generic object that represents size and shape.
Definition: dim4.hpp:26
af_dtype
Definition: defines.h:210
@ f32
32-bit floating point values
Definition: defines.h:211
af_border_type
Definition: defines.h:266
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 array imag(const array &in)
C++ Interface for getting imaginary part from complex array.
AFAPI array real(const array &in)
C++ Interface for getting real part from complex array.
AFAPI af_err af_constant_long(af_array *arr, const long long val, const unsigned ndims, const dim_t *const dims)
array constant(T val, const dim4 &dims, const dtype ty=(af_dtype) dtype_traits< T >::ctype)
AFAPI af_err af_constant_complex(af_array *arr, const double real, const double imag, const unsigned ndims, const dim_t *const dims, const af_dtype type)
AFAPI af_err af_constant_ulong(af_array *arr, const unsigned long long val, const unsigned ndims, const dim_t *const dims)
AFAPI af_err af_constant(af_array *arr, const double val, const unsigned ndims, const dim_t *const dims, const af_dtype type)
AFAPI af_err af_diag_extract(af_array *out, const af_array in, const int num)
AFAPI array diag(const array &in, const int num=0, const bool extract=true)
AFAPI af_err af_diag_create(af_array *out, const af_array in, const int num)
AFAPI af_err af_identity(af_array *out, const unsigned ndims, const dim_t *const dims, const af_dtype type)
AFAPI array identity(const dim4 &dims, const dtype ty=f32)
AFAPI af_err af_iota(af_array *out, const unsigned ndims, const dim_t *const dims, const unsigned t_ndims, const dim_t *const tdims, const af_dtype type)
AFAPI array iota(const dim4 &dims, const dim4 &tile_dims=dim4(1), const dtype ty=f32)
AFAPI array lower(const array &in, bool is_unit_diag=false)
AFAPI af_err af_lower(af_array *out, const af_array in, bool is_unit_diag)
AFAPI array pad(const array &in, const dim4 &beginPadding, const dim4 &endPadding, const borderType padFillType)
AFAPI af_err af_pad(af_array *out, const af_array in, const unsigned begin_ndims, const dim_t *const begin_dims, const unsigned end_ndims, const dim_t *const end_dims, const af_border_type pad_fill_type)
AFAPI array range(const dim4 &dims, const int seq_dim=-1, const dtype ty=f32)
AFAPI af_err af_range(af_array *out, const unsigned ndims, const dim_t *const dims, const int seq_dim, const af_dtype type)
AFAPI void replace(array &a, const array &cond, const array &b)
AFAPI af_err af_replace_scalar(af_array a, const af_array cond, const double b)
AFAPI af_err af_replace(af_array a, const af_array cond, const af_array b)
AFAPI af_err af_select_scalar_l(af_array *out, const af_array cond, const double a, const af_array b)
AFAPI array select(const array &cond, const array &a, const array &b)
AFAPI af_err af_select_scalar_r(af_array *out, const af_array cond, const af_array a, const double b)
AFAPI af_err af_select(af_array *out, const af_array cond, const af_array a, const af_array b)
AFAPI array upper(const array &in, bool is_unit_diag=false)
AFAPI af_err af_upper(af_array *out, const af_array in, bool is_unit_diag)
AFAPI array flat(const array &in)
AFAPI af_err af_flat(af_array *out, const af_array in)
AFAPI array flip(const array &in, const unsigned dim)
AFAPI af_err af_flip(af_array *out, const af_array in, const unsigned dim)
AFAPI af_err af_join(af_array *out, const int dim, const af_array first, const af_array second)
Join 2 arrays along dim.
AFAPI af_err af_join_many(af_array *out, const int dim, const unsigned n_arrays, const af_array *inputs)
Join many arrays along dim.
AFAPI array join(const int dim, const array &first, const array &second)
Join 2 arrays along dim.
AFAPI array moddims(const array &in, const unsigned ndims, const dim_t *const dims)
AFAPI af_err af_moddims(af_array *out, const af_array in, const unsigned ndims, const dim_t *const dims)
AFAPI af_err af_reorder(af_array *out, const af_array in, const unsigned x, const unsigned y, const unsigned z, const unsigned w)
AFAPI array reorder(const array &in, const unsigned x, const unsigned y=1, const unsigned z=2, const unsigned w=3)
AFAPI array shift(const array &in, const int x, const int y=0, const int z=0, const int w=0)
AFAPI af_err af_shift(af_array *out, const af_array in, const int x, const int y, const int z, const int w)
AFAPI af_err af_tile(af_array *out, const af_array in, const unsigned x, const unsigned y, const unsigned z, const unsigned w)
AFAPI array tile(const array &in, const unsigned x, const unsigned y=1, const unsigned z=1, const unsigned w=1)
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
Definition: algorithm.h:15