- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

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>
16 namespace 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>
44 array constant(T val, const dim_t d0, const af_dtype ty=(af_dtype)dtype_traits<T>::ctype);
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 randu(const dim4 &dims, const dtype ty=f32);
97
106 AFAPI array randu(const dim_t d0, const dtype ty=f32);
107
117 AFAPI array randu(const dim_t d0,
118 const dim_t d1, const dtype ty=f32);
119
130 AFAPI array randu(const dim_t d0,
131 const dim_t d1, const dim_t d2, const dtype ty=f32);
132
144 AFAPI array randu(const dim_t d0,
145 const dim_t d1, const dim_t d2,
146 const dim_t d3, const dtype ty=f32);
147
156 AFAPI array randn(const dim4 &dims, const dtype ty=f32);
157
166 AFAPI array randn(const dim_t d0, const dtype ty=f32);
176 AFAPI array randn(const dim_t d0,
177 const dim_t d1, const dtype ty=f32);
188 AFAPI array randn(const dim_t d0,
189 const dim_t d1, const dim_t d2, const dtype ty=f32);
190
202 AFAPI array randn(const dim_t d0,
203 const dim_t d1, const dim_t d2,
204 const dim_t d3, const dtype ty=f32);
205
211 AFAPI void setSeed(const uintl seed);
212
218 AFAPI uintl getSeed();
219
220
229 AFAPI array identity(const dim4 &dims, const dtype ty=f32);
230
239 AFAPI array identity(const dim_t d0, const dtype ty=f32);
240
250 AFAPI array identity(const dim_t d0, const dim_t d1, const dtype ty=f32);
251
262 AFAPI array identity(const dim_t d0, const dim_t d1,
263 const dim_t d2, const dtype ty=f32);
264
276 AFAPI array identity(const dim_t d0, const dim_t d1,
277 const dim_t d2, const dim_t d3, const dtype ty=f32);
278
288 AFAPI array range(const dim4 &dims, const int seq_dim = -1, const dtype ty=f32);
289
302 AFAPI array range(const dim_t d0, const dim_t d1 = 1, const dim_t d2 = 1,
303 const dim_t d3 = 1, const int seq_dim = -1, const dtype ty=f32);
304
314 AFAPI array iota(const dim4 &dims, const dim4 &tile_dims = dim4(1), const dtype ty=f32);
315
326 AFAPI array diag(const array &in, const int num = 0, const bool extract = true);
327
338 AFAPI array join(const int dim, const array &first, const array &second);
339
351 AFAPI array join(const int dim, const array &first, const array &second, const array &third);
352
365 AFAPI array join(const int dim, const array &first, const array &second,
366 const array &third, const array &fourth);
367
378 AFAPI array tile(const array &in, const unsigned x, const unsigned y=1,
379 const unsigned z=1, const unsigned w=1);
380
388 AFAPI array tile(const array &in, const dim4 &dims);
389
400 AFAPI array reorder(const array& in, const unsigned x,
401 const unsigned y=1, const unsigned z=2, const unsigned w=3);
402
414 AFAPI array shift(const array& in, const int x, const int y=0, const int z=0, const int w=0);
415
424 AFAPI array moddims(const array& in, const unsigned ndims, const dim_t * const dims);
425
433 AFAPI array moddims(const array& in, const dim4& dims);
434
445 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);
446
453 AFAPI array flat(const array &in);
454
462 AFAPI array flip(const array &in, const unsigned dim);
463
471 AFAPI array lower(const array &in, bool is_unit_diag=false);
472
480 AFAPI array upper(const array &in, bool is_unit_diag=false);
481
482 #if AF_API_VERSION >= 31
483
491 AFAPI array select(const array &cond, const array &a, const array &b);
492 #endif
493
494 #if AF_API_VERSION >= 31
495
503 AFAPI array select(const array &cond, const array &a, const double &b);
504 #endif
505
506 #if AF_API_VERSION >= 31
507
515 AFAPI array select(const array &cond, const double &a, const array &b);
516 #endif
517
518 #if AF_API_VERSION >= 31
519
526 AFAPI void replace(array &a, const array &cond, const array &b);
527 #endif
528
529 #if AF_API_VERSION >= 31
530
537 AFAPI void replace(array &a, const array &cond, const double &b);
538 #endif
539
543 }
544 #endif
545
546 #ifdef __cplusplus
547 extern "C" {
548 #endif
549
550
560 AFAPI af_err af_constant(af_array *arr, const double val, const unsigned ndims, const dim_t * const dims, const af_dtype type);
561
573 AFAPI af_err af_constant_complex(af_array *arr, const double real, const double imag,
574 const unsigned ndims, const dim_t * const dims, const af_dtype type);
575
585 AFAPI af_err af_constant_long (af_array *arr, const intl val, const unsigned ndims, const dim_t * const dims);
586
596 AFAPI af_err af_constant_ulong(af_array *arr, const uintl val, const unsigned ndims, const dim_t * const dims);
610 AFAPI af_err af_range(af_array *out, const unsigned ndims, const dim_t * const dims,
611 const int seq_dim, const af_dtype type);
612
623 AFAPI af_err af_iota(af_array *out, const unsigned ndims, const dim_t * const dims,
624 const unsigned t_ndims, const dim_t * const tdims, const af_dtype type);
625
634 AFAPI af_err af_randu(af_array *out, const unsigned ndims, const dim_t * const dims, const af_dtype type);
635
644 AFAPI af_err af_randn(af_array *out, const unsigned ndims, const dim_t * const dims, const af_dtype type);
645
651 AFAPI af_err af_set_seed(const uintl seed);
652
658 AFAPI af_err af_get_seed(uintl *seed);
659
660
669 AFAPI af_err af_identity(af_array *out, const unsigned ndims, const dim_t * const dims, const af_dtype type);
670
678 AFAPI af_err af_diag_create(af_array *out, const af_array in, const int num);
679
687 AFAPI af_err af_diag_extract(af_array *out, const af_array in, const int num);
688
699 AFAPI af_err af_join(af_array *out, const int dim, const af_array first, const af_array second);
700
713 AFAPI af_err af_join_many(af_array *out, const int dim, const unsigned n_arrays, const af_array *inputs);
714
725 AFAPI af_err af_tile(af_array *out, const af_array in,
726 const unsigned x, const unsigned y, const unsigned z, const unsigned w);
727
738 AFAPI af_err af_reorder(af_array *out, const af_array in,
739 const unsigned x, const unsigned y, const unsigned z, const unsigned w);
740
751 AFAPI af_err af_shift(af_array *out, const af_array in, const int x, const int y, const int z, const int w);
752
761 AFAPI af_err af_moddims(af_array *out, const af_array in, const unsigned ndims, const dim_t * const dims);
762
769 AFAPI af_err af_flat(af_array *out, const af_array in);
770
778 AFAPI af_err af_flip(af_array *out, const af_array in, const unsigned dim);
779
787 AFAPI af_err af_lower(af_array *out, const af_array in, bool is_unit_diag);
788
796 AFAPI af_err af_upper(af_array *out, const af_array in, bool is_unit_diag);
801 #if AF_API_VERSION >= 31
802
810 AFAPI af_err af_select(af_array *out, const af_array cond, const af_array a, const af_array b);
811 #endif
812
813 #if AF_API_VERSION >= 31
814
822 AFAPI af_err af_select_scalar_r(af_array *out, const af_array cond, const af_array a, const double b);
823 #endif
824
825 #if AF_API_VERSION >= 31
826
834 AFAPI af_err af_select_scalar_l(af_array *out, const af_array cond, const double a, const af_array b);
835 #endif
836
837 #if AF_API_VERSION >= 31
838
845 AFAPI af_err af_replace(af_array a, const af_array cond, const af_array b);
846 #endif
847
848 #if AF_API_VERSION >= 31
849
856 AFAPI af_err af_replace_scalar(af_array a, const af_array cond, const double b);
857 #endif
858
859 #ifdef __cplusplus
860 }
861 #endif
af_randu
AFAPI af_err af_randu(af_array *out, const unsigned ndims, const dim_t *const dims, const af_dtype type)
af::randn
AFAPI array randn(const dim4 &dims, const dtype ty=f32)
traits.hpp
af::join
AFAPI array join(const int dim, const array &first, const array &second)
Join 2 arrays along dim.
af_set_seed
AFAPI af_err af_set_seed(const uintl seed)
af::moddims
AFAPI array moddims(const array &in, const unsigned ndims, const dim_t *const dims)
af_constant_complex
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)
af::lower
AFAPI array lower(const array &in, bool is_unit_diag=false)
af
Definition: algorithm.h:14
af_get_seed
AFAPI af_err af_get_seed(uintl *seed)
af::flip
AFAPI array flip(const array &in, const unsigned dim)
af_shift
AFAPI af_err af_shift(af_array *out, const af_array in, const int x, const int y, const int z, const int w)
af_moddims
AFAPI af_err af_moddims(af_array *out, const af_array in, const unsigned ndims, const dim_t *const dims)
af_constant_long
AFAPI af_err af_constant_long(af_array *arr, const intl val, const unsigned ndims, const dim_t *const dims)
af_range
AFAPI af_err af_range(af_array *out, const unsigned ndims, const dim_t *const dims, const int seq_dim, const af_dtype type)
af_iota
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)
af_identity
AFAPI af_err af_identity(af_array *out, const unsigned ndims, const dim_t *const dims, const af_dtype type)
af_randn
AFAPI af_err af_randn(af_array *out, const unsigned ndims, const dim_t *const dims, const af_dtype type)
af_replace
AFAPI af_err af_replace(af_array a, const af_array cond, const af_array b)
af_join_many
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.
af_select
AFAPI af_err af_select(af_array *out, const af_array cond, const af_array a, const af_array b)
af_diag_extract
AFAPI af_err af_diag_extract(af_array *out, const af_array in, const int num)
af::getSeed
AFAPI uintl getSeed()
af_flat
AFAPI af_err af_flat(af_array *out, const af_array in)
af::range
AFAPI array range(const dim4 &dims, const int seq_dim=-1, const dtype ty=f32)
dim4.hpp
af::diag
AFAPI array diag(const array &in, const int num=0, const bool extract=true)
af::reorder
AFAPI array reorder(const array &in, const unsigned x, const unsigned y=1, const unsigned z=2, const unsigned w=3)
af_err
af_err
Definition: defines.h:67
af_join
AFAPI af_err af_join(af_array *out, const int dim, const af_array first, const af_array second)
Join 2 arrays along dim.
defines.h
af_diag_create
AFAPI af_err af_diag_create(af_array *out, const af_array in, const int num)
af_constant
AFAPI af_err af_constant(af_array *arr, const double val, const unsigned ndims, const dim_t *const dims, const af_dtype type)
af::select
AFAPI array select(const array &cond, const array &a, const array &b)
af_upper
AFAPI af_err af_upper(af_array *out, const af_array in, bool is_unit_diag)
dim_t
long long dim_t
Definition: defines.h:50
af::imag
AFAPI array imag(const array &in)
C++ Interface for getting imaginary part from complex array.
af::randu
AFAPI array randu(const dim4 &dims, const dtype ty=f32)
af::real
AFAPI array real(const array &in)
C++ Interface for getting real part from complex array.
af::flat
AFAPI array flat(const array &in)
af_constant_ulong
AFAPI af_err af_constant_ulong(af_array *arr, const uintl val, const unsigned ndims, const dim_t *const dims)
af_select_scalar_r
AFAPI af_err af_select_scalar_r(af_array *out, const af_array cond, const af_array a, const double b)
AFAPI
#define AFAPI
Definition: defines.h:31
af_replace_scalar
AFAPI af_err af_replace_scalar(af_array a, const af_array cond, const double b)
af_select_scalar_l
AFAPI af_err af_select_scalar_l(af_array *out, const af_array cond, const double a, const af_array b)
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:136
af_tile
AFAPI af_err af_tile(af_array *out, const af_array in, const unsigned x, const unsigned y, const unsigned z, const unsigned w)
uintl
unsigned long long uintl
Definition: defines.h:60
af::constant
array constant(T val, const dim4 &dims, const dtype ty=(af_dtype) dtype_traits< T >::ctype)
af::tile
AFAPI array tile(const array &in, const unsigned x, const unsigned y=1, const unsigned z=1, const unsigned w=1)
af_reorder
AFAPI af_err af_reorder(af_array *out, const af_array in, const unsigned x, const unsigned y, const unsigned z, const unsigned w)
af_array
void * af_array
Definition: defines.h:187
af::setSeed
AFAPI void setSeed(const uintl seed)
af::replace
AFAPI void replace(array &a, const array &cond, const array &b)
f32
32-bit floating point values
Definition: defines.h:167
af_lower
AFAPI af_err af_lower(af_array *out, const af_array in, bool is_unit_diag)
af::shift
AFAPI array shift(const array &in, const int x, const int y=0, const int z=0, const int w=0)
af::iota
AFAPI array iota(const dim4 &dims, const dim4 &tile_dims=dim4(1), const dtype ty=f32)
af_dtype
af_dtype
Definition: defines.h:166
af_flip
AFAPI af_err af_flip(af_array *out, const af_array in, const unsigned dim)
af::dtype
af_dtype dtype
Definition: defines.h:329
intl
long long intl
Definition: defines.h:59
af::upper
AFAPI array upper(const array &in, bool is_unit_diag=false)
af::identity
AFAPI array identity(const dim4 &dims, const dtype ty=f32)