Go to the documentation of this file.
11 #include <af/compilers.h>
46 class AFAPI array_proxy
48 struct array_proxy_impl;
49 array_proxy_impl *impl;
54 #if AF_COMPILER_CXX_RVALUE_REFERENCES
61 operator array()
const;
65 array_proxy& operator OP(const array_proxy &a); \
66 array_proxy& operator OP(const array &a); \
67 array_proxy& operator OP(const double &a); \
68 array_proxy& operator OP(const cdouble &a); \
69 array_proxy& operator OP(const cfloat &a); \
70 array_proxy& operator OP(const float &a); \
71 array_proxy& operator OP(const int &a); \
72 array_proxy& operator OP(const unsigned &a); \
73 array_proxy& operator OP(const bool &a); \
74 array_proxy& operator OP(const char &a); \
75 array_proxy& operator OP(const unsigned char &a); \
76 array_proxy& operator OP(const long &a); \
77 array_proxy& operator OP(const unsigned long &a); \
78 array_proxy& operator OP(const long long &a); \
79 array_proxy& operator OP(const unsigned long long &a);
88 #if AF_API_VERSION >= 32
90 array_proxy& operator OP(const short &a); \
91 array_proxy& operator OP(const unsigned short &a);
104 dim_t elements()
const;
105 template<
typename T> T* host()
const;
106 void host(
void *ptr)
const;
109 dim_t dims(
unsigned dim)
const;
110 unsigned numdims()
const;
111 size_t bytes()
const;
112 size_t allocated()
const;
114 bool isempty()
const;
115 bool isscalar()
const;
116 bool isvector()
const;
118 bool iscolumn()
const;
119 bool iscomplex()
const;
120 inline bool isreal()
const {
return !iscomplex(); }
121 bool isdouble()
const;
122 bool issingle()
const;
123 #if AF_API_VERSION >= 37
126 bool isrealfloating()
const;
127 bool isfloating()
const;
128 bool isinteger()
const;
130 #if AF_API_VERSION >= 34
131 bool issparse()
const;
137 template<
typename T> T scalar()
const;
138 template<
typename T> T* device()
const;
140 #if AF_API_VERSION >= 31
144 #if AF_API_VERSION >= 34
145 bool isLocked()
const;
175 #if AF_API_VERSION >= 37
176 #if AF_COMPILER_CXX_RVALUE_REFERENCES
564 dim_t elements()
const;
569 template<
typename T> T* host()
const;
574 void host(
void *ptr)
const;
579 template<
typename T>
void write(
const T *ptr,
const size_t bytes,
af::source src =
afHost);
594 dim_t dims(
unsigned dim)
const;
599 unsigned numdims()
const;
604 size_t bytes()
const;
610 size_t allocated()
const;
620 bool isempty()
const;
625 bool isscalar()
const;
630 bool isvector()
const;
640 bool iscolumn()
const;
645 bool iscomplex()
const;
650 inline bool isreal()
const {
return !iscomplex(); }
655 bool isdouble()
const;
660 bool issingle()
const;
662 #if AF_API_VERSION >= 37
672 bool isrealfloating()
const;
677 bool isfloating()
const;
682 bool isinteger()
const;
689 #if AF_API_VERSION >= 34
693 bool issparse()
const;
706 template<
typename T> T scalar()
const;
714 template<
typename T> T* device()
const;
877 #define ASSIGN_(OP2) \
878 array& OP2(const array &val); \
879 array& OP2(const double &val); \
880 array& OP2(const cdouble &val); \
881 array& OP2(const cfloat &val); \
882 array& OP2(const float &val); \
883 array& OP2(const int &val); \
884 array& OP2(const unsigned &val); \
885 array& OP2(const bool &val); \
886 array& OP2(const char &val); \
887 array& OP2(const unsigned char &val); \
888 array& OP2(const long &val); \
889 array& OP2(const unsigned long &val); \
890 array& OP2(const long long &val); \
891 array& OP2(const unsigned long long &val);
894 #if AF_API_VERSION >= 32
897 array& OP(const short &val); \
898 array& OP(const unsigned short &val);
901 #define ASSIGN(OP) ASSIGN_(OP)
982 array operator !()
const;
988 int nonzeros()
const;
999 #if AF_API_VERSION >= 34
1000 bool isLocked()
const;
1014 void unlock()
const;
1018 #define BIN_OP_(OP) \
1019 AFAPI array OP (const array& lhs, const array& rhs); \
1020 AFAPI array OP (const bool& lhs, const array& rhs); \
1021 AFAPI array OP (const int& lhs, const array& rhs); \
1022 AFAPI array OP (const unsigned& lhs, const array& rhs); \
1023 AFAPI array OP (const char& lhs, const array& rhs); \
1024 AFAPI array OP (const unsigned char& lhs, const array& rhs); \
1025 AFAPI array OP (const long& lhs, const array& rhs); \
1026 AFAPI array OP (const unsigned long& lhs, const array& rhs); \
1027 AFAPI array OP (const long long& lhs, const array& rhs); \
1028 AFAPI array OP (const unsigned long long& lhs, const array& rhs); \
1029 AFAPI array OP (const double& lhs, const array& rhs); \
1030 AFAPI array OP (const float& lhs, const array& rhs); \
1031 AFAPI array OP (const cfloat& lhs, const array& rhs); \
1032 AFAPI array OP (const cdouble& lhs, const array& rhs); \
1033 AFAPI array OP (const array& lhs, const bool& rhs); \
1034 AFAPI array OP (const array& lhs, const int& rhs); \
1035 AFAPI array OP (const array& lhs, const unsigned& rhs); \
1036 AFAPI array OP (const array& lhs, const char& rhs); \
1037 AFAPI array OP (const array& lhs, const unsigned char& rhs); \
1038 AFAPI array OP (const array& lhs, const long& rhs); \
1039 AFAPI array OP (const array& lhs, const unsigned long& rhs); \
1040 AFAPI array OP (const array& lhs, const long long& rhs); \
1041 AFAPI array OP (const array& lhs, const unsigned long long& rhs); \
1042 AFAPI array OP (const array& lhs, const double& rhs); \
1043 AFAPI array OP (const array& lhs, const float& rhs); \
1044 AFAPI array OP (const array& lhs, const cfloat& rhs); \
1045 AFAPI array OP (const array& lhs, const cdouble& rhs);
1047 #if AF_API_VERSION >= 32
1048 #define BIN_OP(OP) \
1050 AFAPI array OP (const short& lhs, const array& rhs); \
1051 AFAPI array OP (const unsigned short& lhs, const array& rhs); \
1052 AFAPI array OP (const array& lhs, const short& rhs); \
1053 AFAPI array OP (const array& lhs, const unsigned short& rhs);
1056 #define BIN_OP(OP) BIN_OP_(OP)
1347 #if AF_API_VERSION >= 34
1356 #if AF_API_VERSION >= 34
1357 array *arrays[] = {&a, &b};
1358 return eval(2, arrays);
1366 #if AF_API_VERSION >= 34
1367 array *arrays[] = {&a, &b, &c};
1368 return eval(3, arrays);
1370 eval(a, b); c.eval();
1376 #if AF_API_VERSION >= 34
1377 array *arrays[] = {&a, &b, &c, &d};
1378 return eval(4, arrays);
1380 eval(a, b, c); d.eval();
1387 #if AF_API_VERSION >= 34
1388 array *arrays[] = {&a, &b, &c, &d, &e};
1389 return eval(5, arrays);
1391 eval(a, b, c, d); e.eval();
1397 #if AF_API_VERSION >= 34
1398 array *arrays[] = {&a, &b, &c, &d, &e, &f};
1399 return eval(6, arrays);
1401 eval(a, b, c, d, e); f.eval();
1405 #if AF_API_VERSION >= 37
1410 #if AF_COMPILER_CXX_VARIADIC_TEMPLATES
1411 template <
typename... ARRAYS>
1412 inline void eval(ARRAYS... in) {
1413 array *arrays[] = {
const_cast<array *
>(&in)...};
1414 eval((
int)
sizeof...(in), arrays);
1421 const array *arrays[] = {&a, &b};
1422 return eval(2,
const_cast<array **
>(arrays));
1427 const array *arrays[] = {&a, &b, &c};
1428 return eval(3,
const_cast<array **
>(arrays));
1434 const array *arrays[] = {&a, &b, &c, &d};
1435 return eval(4,
const_cast<array **
>(arrays));
1441 const array *arrays[] = {&a, &b, &c, &d, &e};
1442 return eval(5,
const_cast<array **
>(arrays));
1448 const array *arrays[] = {&a, &b, &c, &d, &e, &f};
1449 return eval(6,
const_cast<array **
>(arrays));
1451 #endif // AF_COMPILER_CXX_VARIADIC_TEMPLATES
1454 #if AF_API_VERSION >= 34
1461 #if AF_API_VERSION >= 34
1541 #if AF_API_VERSION >= 31
1553 #if AF_API_VERSION >= 34
1560 #if AF_API_VERSION >= 34
1567 #if AF_API_VERSION >= 34
1712 #if AF_API_VERSION >= 37
1767 #if AF_API_VERSION >= 34
1779 #if AF_API_VERSION >= 35
Generic object that represents size and shape.
AFAPI af_err af_retain_array(af_array *out, const af_array in)
Increments an af_array reference count.
AFAPI array operator&(const array &lhs, const array &rhs)
Performs an bitwise AND operation on two arrays or an array and a value.
AFAPI af_err af_is_integer(bool *result, const af_array arr)
Check if an array is integer type.
AFAPI af_err af_get_manual_eval_flag(bool *flag)
Get the manual eval flag.
AFAPI af_err af_get_dims(dim_t *d0, dim_t *d1, dim_t *d2, dim_t *d3, const af_array arr)
Gets the dimensions of an array.
AFAPI af_err af_is_empty(bool *result, const af_array arr)
Check if an array is empty.
AFAPI af_err af_set_manual_eval_flag(bool flag)
Turn the manual eval flag on or off.
AFAPI af_err af_is_double(bool *result, const af_array arr)
Check if an array is double precision type.
AFAPI af_err af_is_sparse(bool *result, const af_array arr)
Check if an array is sparse.
AFAPI af_err af_is_row(bool *result, const af_array arr)
Check if an array is row vector.
AFAPI af_err af_is_single(bool *result, const af_array arr)
Check if an array is single precision type.
A multi dimensional data container.
AFAPI af_err af_write_array(af_array arr, const void *data, const size_t bytes, af_source src)
Copy data from a C pointer (host/device) to an existing array.
AFAPI af_err af_get_data_ptr(void *data, const af_array arr)
Copy data from an af_array to a C pointer.
AFAPI af_err af_eval_multiple(const int num, af_array *arrays)
Evaluate multiple arrays together.
AFAPI af_err af_is_realfloating(bool *result, const af_array arr)
Check if an array is real floating point type.
Struct used to index an af_array.
AFAPI af_err af_copy_array(af_array *arr, const af_array in)
Deep copy an array to another.
AFAPI array operator-(const array &lhs, const array &rhs)
Subtracts two arrays or an array and a value.
void eval() const
Evaluate any JIT expressions to generate data for the array.
AFAPI af_err af_create_array(af_array *arr, const void *const data, const unsigned ndims, const dim_t *const dims, const af_dtype type)
Create an af_array handle initialized with user defined data.
AFAPI af_err af_is_real(bool *result, const af_array arr)
Check if an array is real type.
AFAPI af_err af_is_floating(bool *result, const af_array arr)
Check if an array is floating precision type.
AFAPI af_err af_is_bool(bool *result, const af_array arr)
Check if an array is bool type.
AFAPI af_err af_get_numdims(unsigned *result, const af_array arr)
Gets the number of dimensions of an array.
AFAPI af_err af_release_array(af_array arr)
Reduce the reference count of the af_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.
AFAPI af_err af_is_column(bool *result, const af_array arr)
Check if an array is a column vector.
AFAPI af_err af_is_vector(bool *result, const af_array arr)
Check if an array is a vector.
AFAPI af_err af_is_half(bool *result, const af_array arr)
Check if an array is 16 bit floating point type.
AFAPI seq span
A special value representing the entire axis of an af::array.
AFAPI af_err af_eval(af_array in)
Evaluate any expressions in the Array.
AFAPI void setManualEvalFlag(bool flag)
Turn the manual eval flag on or off.
AFAPI af_err af_get_scalar(void *output_value, const af_array arr)
Get first element from an array.
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.
array & eval(array &a)
Evaluate an expression (nonblocking).
AFAPI af_err af_is_scalar(bool *result, const af_array arr)
Check if an array is scalar, ie.
AFAPI af_err af_get_data_ref_count(int *use_count, const af_array in)
Get the reference count of af_array.
AFAPI af_err af_get_type(af_dtype *type, const af_array arr)
Gets the type of an array.
AFAPI bool getManualEvalFlag()
Get the manual eval flag.
AFAPI array operator&&(const array &lhs, const array &rhs)
Performs a logical AND operation on two arrays or an array and a value.
AFAPI af_err af_create_handle(af_array *arr, const unsigned ndims, const dim_t *const dims, const af_dtype type)
Create af_array handle.
AFAPI af_err af_get_elements(dim_t *elems, const af_array arr)
Get the total number of elements across all dimensions of the array.
@ f32
32-bit floating point values
AFAPI af_err af_is_complex(bool *result, const af_array arr)
Check if an array is complex type.