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 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 
205  AFAPI array join(const int dim, const array &first, const array &second);
206 
218  AFAPI array join(const int dim, const array &first, const array &second, const array &third);
219 
232  AFAPI array join(const int dim, const array &first, const array &second,
233  const array &third, const array &fourth);
234 
249  AFAPI array tile(const array &in, const unsigned x, const unsigned y=1,
250  const unsigned z=1, const unsigned w=1);
251 
263  AFAPI array tile(const array &in, const dim4 &dims);
264 
275  AFAPI array reorder(const array& in, const unsigned x,
276  const unsigned y=1, const unsigned z=2, const unsigned w=3);
277 
289  AFAPI array shift(const array& in, const int x, const int y=0, const int z=0, const int w=0);
290 
299  AFAPI array moddims(const array& in, const unsigned ndims, const dim_t * const dims);
300 
308  AFAPI array moddims(const array& in, const dim4& dims);
309 
320  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);
321 
328  AFAPI array flat(const array &in);
329 
337  AFAPI array flip(const array &in, const unsigned dim);
338 
346  AFAPI array lower(const array &in, bool is_unit_diag=false);
347 
355  AFAPI array upper(const array &in, bool is_unit_diag=false);
356 
357 #if AF_API_VERSION >= 31
358 
366  AFAPI array select(const array &cond, const array &a, const array &b);
367 #endif
368 
369 #if AF_API_VERSION >= 31
370 
378  AFAPI array select(const array &cond, const array &a, const double &b);
379 #endif
380 
381 #if AF_API_VERSION >= 31
382 
390  AFAPI array select(const array &cond, const double &a, const array &b);
391 #endif
392 
393 #if AF_API_VERSION >= 31
394 
403  AFAPI void replace(array &a, const array &cond, const array &b);
404 #endif
405 
406 #if AF_API_VERSION >= 31
407 
416  AFAPI void replace(array &a, const array &cond, const double &b);
417 #endif
418 
419 #if AF_API_VERSION >= 37
420 
432  AFAPI array pad(const array &in, const dim4 &beginPadding,
433  const dim4 &endPadding, const borderType padFillType);
434 #endif
435 }
436 #endif
437 
438 #ifdef __cplusplus
439 extern "C" {
440 #endif
441 
450  AFAPI af_err af_constant(af_array *arr, const double val, const unsigned ndims, const dim_t * const dims, const af_dtype type);
451 
463  AFAPI af_err af_constant_complex(af_array *arr, const double real, const double imag,
464  const unsigned ndims, const dim_t * const dims, const af_dtype type);
465 
475  AFAPI af_err af_constant_long (af_array *arr, const long long val, const unsigned ndims, const dim_t * const dims);
476 
486  AFAPI af_err af_constant_ulong(af_array *arr, const unsigned long long val, const unsigned ndims, const dim_t * const dims);
487 
497  AFAPI af_err af_range(af_array *out, const unsigned ndims, const dim_t * const dims,
498  const int seq_dim, const af_dtype type);
499 
510  AFAPI af_err af_iota(af_array *out, const unsigned ndims, const dim_t * const dims,
511  const unsigned t_ndims, const dim_t * const tdims, const af_dtype type);
512 
513 
522  AFAPI af_err af_identity(af_array *out, const unsigned ndims, const dim_t * const dims, const af_dtype type);
523 
531  AFAPI af_err af_diag_create(af_array *out, const af_array in, const int num);
532 
540  AFAPI af_err af_diag_extract(af_array *out, const af_array in, const int num);
541 
552  AFAPI af_err af_join(af_array *out, const int dim, const af_array first, const af_array second);
553 
566  AFAPI af_err af_join_many(af_array *out, const int dim, const unsigned n_arrays, const af_array *inputs);
567 
582  AFAPI af_err af_tile(af_array *out, const af_array in,
583  const unsigned x, const unsigned y, const unsigned z, const unsigned w);
584 
595  AFAPI af_err af_reorder(af_array *out, const af_array in,
596  const unsigned x, const unsigned y, const unsigned z, const unsigned w);
597 
608  AFAPI af_err af_shift(af_array *out, const af_array in, const int x, const int y, const int z, const int w);
609 
618  AFAPI af_err af_moddims(af_array *out, const af_array in, const unsigned ndims, const dim_t * const dims);
619 
626  AFAPI af_err af_flat(af_array *out, const af_array in);
627 
635  AFAPI af_err af_flip(af_array *out, const af_array in, const unsigned dim);
636 
644  AFAPI af_err af_lower(af_array *out, const af_array in, bool is_unit_diag);
645 
653  AFAPI af_err af_upper(af_array *out, const af_array in, bool is_unit_diag);
654 
655 #if AF_API_VERSION >= 31
656 
664  AFAPI af_err af_select(af_array *out, const af_array cond, const af_array a, const af_array b);
665 #endif
666 
667 #if AF_API_VERSION >= 31
668 
676  AFAPI af_err af_select_scalar_r(af_array *out, const af_array cond, const af_array a, const double b);
677 #endif
678 
679 #if AF_API_VERSION >= 31
680 
688  AFAPI af_err af_select_scalar_l(af_array *out, const af_array cond, const double a, const af_array b);
689 #endif
690 
691 #if AF_API_VERSION >= 31
692 
701  AFAPI af_err af_replace(af_array a, const af_array cond, const af_array b);
702 #endif
703 
704 #if AF_API_VERSION >= 31
705 
714  AFAPI af_err af_replace_scalar(af_array a, const af_array cond, const double b);
715 #endif
716 
717 #if AF_API_VERSION >= 37
718 
731  AFAPI af_err af_pad(af_array *out, const af_array in,
732  const unsigned begin_ndims,
733  const dim_t *const begin_dims, const unsigned end_ndims,
734  const dim_t *const end_dims,
735  const af_border_type pad_fill_type);
736 #endif
737 
738 #ifdef __cplusplus
739 }
740 #endif
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::pad
AFAPI array pad(const array &in, const dim4 &beginPadding, const dim4 &endPadding, const borderType padFillType)
af::range
AFAPI array range(const dim4 &dims, const int seq_dim=-1, const dtype ty=f32)
af::lower
AFAPI array lower(const array &in, bool is_unit_diag=false)
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)
traits.hpp
af::select
AFAPI array select(const array &cond, const array &a, const array &b)
af_replace_scalar
AFAPI af_err af_replace_scalar(af_array a, const af_array cond, const double b)
dim_t
long long dim_t
Definition: defines.h:56
af_flat
AFAPI af_err af_flat(af_array *out, const af_array in)
af::constant
array constant(T val, const dim4 &dims, const dtype ty=(af_dtype) dtype_traits< T >::ctype)
af::join
AFAPI array join(const int dim, const array &first, const array &second)
Join 2 arrays along dim.
af::moddims
AFAPI array moddims(const array &in, const unsigned ndims, const dim_t *const dims)
af_upper
AFAPI af_err af_upper(af_array *out, const af_array in, bool is_unit_diag)
af_moddims
AFAPI af_err af_moddims(af_array *out, const af_array in, const unsigned ndims, const dim_t *const dims)
af::dtype
af_dtype dtype
Definition: defines.h:549
AFAPI
#define AFAPI
Definition: defines.h:38
af::flip
AFAPI array flip(const array &in, const unsigned dim)
af
Definition: algorithm.h:14
af_diag_extract
AFAPI af_err af_diag_extract(af_array *out, const af_array in, const int num)
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_lower
AFAPI af_err af_lower(af_array *out, const af_array in, bool is_unit_diag)
af_array
void * af_array
Definition: defines.h:240
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.
dim4.hpp
af::reorder
AFAPI array reorder(const array &in, const unsigned x, const unsigned y=1, const unsigned z=2, const unsigned w=3)
af::flat
AFAPI array flat(const array &in)
af::shift
AFAPI array shift(const array &in, const int x, const int y=0, const int z=0, const int w=0)
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::borderType
af_border_type borderType
Definition: defines.h:552
af_dtype
af_dtype
Definition: defines.h:210
af::diag
AFAPI array diag(const array &in, const int num=0, const bool extract=true)
af::replace
AFAPI void replace(array &a, const array &cond, const array &b)
af::real
AFAPI array real(const array &in)
C++ Interface for getting real part from complex array.
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)
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:327
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_identity
AFAPI af_err af_identity(af_array *out, const unsigned ndims, const dim_t *const dims, const af_dtype type)
af_constant_ulong
AFAPI af_err af_constant_ulong(af_array *arr, const unsigned long long val, const unsigned ndims, const dim_t *const dims)
af::tile
AFAPI array tile(const array &in, const unsigned x, const unsigned y=1, const unsigned z=1, const unsigned w=1)
af_flip
AFAPI af_err af_flip(af_array *out, const af_array in, const unsigned dim)
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::iota
AFAPI array iota(const dim4 &dims, const dim4 &tile_dims=dim4(1), const dtype ty=f32)
af_pad
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)
af_constant_long
AFAPI af_err af_constant_long(af_array *arr, const long long val, const unsigned ndims, const dim_t *const dims)
af_border_type
af_border_type
Definition: defines.h:266
af::imag
AFAPI array imag(const array &in)
C++ Interface for getting imaginary part from complex array.
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)
af::upper
AFAPI array upper(const array &in, bool is_unit_diag=false)
af_select
AFAPI af_err af_select(af_array *out, const af_array cond, const af_array a, const af_array b)
af::identity
AFAPI array identity(const dim4 &dims, const dtype ty=f32)
af_replace
AFAPI af_err af_replace(af_array a, const af_array cond, const af_array b)
af_diag_create
AFAPI af_err af_diag_create(af_array *out, const af_array in, const int num)
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)
af_err
af_err
Definition: defines.h:71
defines.h
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)
f32
@ f32
32-bit floating point values
Definition: defines.h:211