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 
216  AFAPI void setSeed(const uintl seed);
217 
228  AFAPI uintl getSeed();
229 
230 
239  AFAPI array identity(const dim4 &dims, const dtype ty=f32);
240 
249  AFAPI array identity(const dim_t d0, const dtype ty=f32);
250 
260  AFAPI array identity(const dim_t d0, const dim_t d1, const dtype ty=f32);
261 
272  AFAPI array identity(const dim_t d0, const dim_t d1,
273  const dim_t d2, const dtype ty=f32);
274 
286  AFAPI array identity(const dim_t d0, const dim_t d1,
287  const dim_t d2, const dim_t d3, const dtype ty=f32);
288 
298  AFAPI array range(const dim4 &dims, const int seq_dim = -1, const dtype ty=f32);
299 
312  AFAPI array range(const dim_t d0, const dim_t d1 = 1, const dim_t d2 = 1,
313  const dim_t d3 = 1, const int seq_dim = -1, const dtype ty=f32);
314 
324  AFAPI array iota(const dim4 &dims, const dim4 &tile_dims = dim4(1), const dtype ty=f32);
325 
336  AFAPI array diag(const array &in, const int num = 0, const bool extract = true);
337 
348  AFAPI array join(const int dim, const array &first, const array &second);
349 
361  AFAPI array join(const int dim, const array &first, const array &second, const array &third);
362 
375  AFAPI array join(const int dim, const array &first, const array &second,
376  const array &third, const array &fourth);
377 
388  AFAPI array tile(const array &in, const unsigned x, const unsigned y=1,
389  const unsigned z=1, const unsigned w=1);
390 
398  AFAPI array tile(const array &in, const dim4 &dims);
399 
410  AFAPI array reorder(const array& in, const unsigned x,
411  const unsigned y=1, const unsigned z=2, const unsigned w=3);
412 
424  AFAPI array shift(const array& in, const int x, const int y=0, const int z=0, const int w=0);
425 
434  AFAPI array moddims(const array& in, const unsigned ndims, const dim_t * const dims);
435 
443  AFAPI array moddims(const array& in, const dim4& dims);
444 
455  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);
456 
463  AFAPI array flat(const array &in);
464 
472  AFAPI array flip(const array &in, const unsigned dim);
473 
481  AFAPI array lower(const array &in, bool is_unit_diag=false);
482 
490  AFAPI array upper(const array &in, bool is_unit_diag=false);
491 
495 }
496 #endif
497 
498 #ifdef __cplusplus
499 extern "C" {
500 #endif
501 
502 
512  AFAPI af_err af_constant(af_array *arr, const double val, const unsigned ndims, const dim_t * const dims, const af_dtype type);
513 
525  AFAPI af_err af_constant_complex(af_array *arr, const double real, const double imag,
526  const unsigned ndims, const dim_t * const dims, const af_dtype type);
527 
537  AFAPI af_err af_constant_long (af_array *arr, const intl val, const unsigned ndims, const dim_t * const dims);
538 
548  AFAPI af_err af_constant_ulong(af_array *arr, const uintl val, const unsigned ndims, const dim_t * const dims);
562  AFAPI af_err af_range(af_array *out, const unsigned ndims, const dim_t * const dims,
563  const int seq_dim, const af_dtype type);
564 
575  AFAPI af_err af_iota(af_array *out, const unsigned ndims, const dim_t * const dims,
576  const unsigned t_ndims, const dim_t * const tdims, const af_dtype type);
577 
586  AFAPI af_err af_randu(af_array *out, const unsigned ndims, const dim_t * const dims, const af_dtype type);
587 
596  AFAPI af_err af_randn(af_array *out, const unsigned ndims, const dim_t * const dims, const af_dtype type);
597 
608  AFAPI af_err af_set_seed(const uintl seed);
609 
620  AFAPI af_err af_get_seed(uintl *seed);
621 
622 
631  AFAPI af_err af_identity(af_array *out, const unsigned ndims, const dim_t * const dims, const af_dtype type);
632 
640  AFAPI af_err af_diag_create(af_array *out, const af_array in, const int num);
641 
649  AFAPI af_err af_diag_extract(af_array *out, const af_array in, const int num);
650 
661  AFAPI af_err af_join(af_array *out, const int dim, const af_array first, const af_array second);
662 
675  AFAPI af_err af_join_many(af_array *out, const int dim, const unsigned n_arrays, const af_array *inputs);
676 
687  AFAPI af_err af_tile(af_array *out, const af_array in,
688  const unsigned x, const unsigned y, const unsigned z, const unsigned w);
689 
700  AFAPI af_err af_reorder(af_array *out, const af_array in,
701  const unsigned x, const unsigned y, const unsigned z, const unsigned w);
702 
713  AFAPI af_err af_shift(af_array *out, const af_array in, const int x, const int y, const int z, const int w);
714 
723  AFAPI af_err af_moddims(af_array *out, const af_array in, const unsigned ndims, const dim_t * const dims);
724 
731  AFAPI af_err af_flat(af_array *out, const af_array in);
732 
740  AFAPI af_err af_flip(af_array *out, const af_array in, const unsigned dim);
741 
749  AFAPI af_err af_lower(af_array *out, const af_array in, bool is_unit_diag);
750 
758  AFAPI af_err af_upper(af_array *out, const af_array in, bool is_unit_diag);
762 #ifdef __cplusplus
763 }
764 #endif
AFAPI af_err af_randu(af_array *out, const unsigned ndims, const dim_t *const dims, const af_dtype type)
AFAPI array randn(const dim4 &dims, const dtype ty=f32)
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_constant_complex(af_array *arr, const double real, const double imag, const unsigned ndims, const dim_t *const dims, const af_dtype type)
AFAPI array lower(const array &in, bool is_unit_diag=false)
Definition: algorithm.h:14
AFAPI array flip(const array &in, const unsigned dim)
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_moddims(af_array *out, const af_array in, const unsigned ndims, const dim_t *const dims)
AFAPI af_err af_constant_long(af_array *arr, const intl val, const unsigned ndims, const dim_t *const dims)
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 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 af_err af_identity(af_array *out, const unsigned ndims, const dim_t *const dims, const af_dtype type)
AFAPI af_err af_randn(af_array *out, const unsigned ndims, const dim_t *const dims, const af_dtype type)
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 af_err af_diag_extract(af_array *out, const af_array in, const int num)
AFAPI af_err af_flat(af_array *out, const af_array in)
AFAPI array range(const dim4 &dims, const int seq_dim=-1, const dtype ty=f32)
AFAPI array diag(const array &in, const int num=0, const bool extract=true)
AFAPI array reorder(const array &in, const unsigned x, const unsigned y=1, const unsigned z=2, const unsigned w=3)
AFAPI uintl getSeed()
af_err
Definition: defines.h:58
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_diag_create(af_array *out, const af_array in, const int num)
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_upper(af_array *out, const af_array in, bool is_unit_diag)
long long dim_t
Definition: defines.h:50
AFAPI array imag(const array &in)
C++ Interface for getting imaginary part from complex array.
AFAPI array randu(const dim4 &dims, const dtype ty=f32)
AFAPI af_err af_get_seed(uintl *seed)
AFAPI array real(const array &in)
C++ Interface for getting real part from complex array.
AFAPI array flat(const array &in)
AFAPI af_err af_constant_ulong(af_array *arr, const uintl val, const unsigned ndims, const dim_t *const dims)
#define AFAPI
Definition: defines.h:31
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:105
AFAPI af_err af_tile(af_array *out, const af_array in, const unsigned x, const unsigned y, const unsigned z, const unsigned w)
unsigned long long uintl
Definition: defines.h:56
array constant(T val, const dim4 &dims, const dtype ty=(af_dtype) dtype_traits< T >::ctype)
AFAPI array tile(const array &in, const unsigned x, const unsigned y=1, const unsigned z=1, const unsigned w=1)
AFAPI af_err af_reorder(af_array *out, const af_array in, const unsigned x, const unsigned y, const unsigned z, const unsigned w)
void * af_array
Definition: defines.h:172
32-bit floating point values
Definition: defines.h:152
AFAPI af_err af_lower(af_array *out, const af_array in, bool is_unit_diag)
AFAPI array shift(const array &in, const int x, const int y=0, const int z=0, const int w=0)
AFAPI array iota(const dim4 &dims, const dim4 &tile_dims=dim4(1), const dtype ty=f32)
AFAPI void setSeed(const uintl seed)
af_dtype
Definition: defines.h:151
AFAPI af_err af_flip(af_array *out, const af_array in, const unsigned dim)
af_dtype dtype
Definition: defines.h:289
long long intl
Definition: defines.h:55
AFAPI af_err af_set_seed(const uintl seed)
AFAPI array upper(const array &in, bool is_unit_diag=false)
AFAPI array identity(const dim4 &dims, const dtype ty=f32)