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;
180 #if AF_API_VERSION >= 37
181 #if AF_COMPILER_CXX_RVALUE_REFERENCES
578 dim_t elements()
const;
583 template<
typename T> T* host()
const;
588 void host(
void *ptr)
const;
593 template<
typename T>
void write(
const T *ptr,
const size_t bytes,
af::source src =
afHost);
608 dim_t dims(
unsigned dim)
const;
613 unsigned numdims()
const;
618 size_t bytes()
const;
624 size_t allocated()
const;
634 bool isempty()
const;
639 bool isscalar()
const;
644 bool isvector()
const;
654 bool iscolumn()
const;
659 bool iscomplex()
const;
664 inline bool isreal()
const {
return !iscomplex(); }
669 bool isdouble()
const;
674 bool issingle()
const;
676 #if AF_API_VERSION >= 37
686 bool isrealfloating()
const;
691 bool isfloating()
const;
696 bool isinteger()
const;
703 #if AF_API_VERSION >= 34
707 bool issparse()
const;
720 template<
typename T> T scalar()
const;
735 template<
typename T> T* device()
const;
904 #define ASSIGN_(OP2) \
905 array& OP2(const array &val); \
906 array& OP2(const double &val); \
907 array& OP2(const cdouble &val); \
908 array& OP2(const cfloat &val); \
909 array& OP2(const float &val); \
910 array& OP2(const int &val); \
911 array& OP2(const unsigned &val); \
912 array& OP2(const bool &val); \
913 array& OP2(const char &val); \
914 array& OP2(const unsigned char &val); \
915 array& OP2(const long &val); \
916 array& OP2(const unsigned long &val); \
917 array& OP2(const long long &val); \
918 array& OP2(const unsigned long long &val);
921 #if AF_API_VERSION >= 32
924 array& OP(const short &val); \
925 array& OP(const unsigned short &val);
928 #define ASSIGN(OP) ASSIGN_(OP)
1009 array operator !()
const;
1015 int nonzeros()
const;
1026 #if AF_API_VERSION >= 34
1027 bool isLocked()
const;
1041 void unlock()
const;
1045 #define BIN_OP_(OP) \
1046 AFAPI array OP (const array& lhs, const array& rhs); \
1047 AFAPI array OP (const bool& lhs, const array& rhs); \
1048 AFAPI array OP (const int& lhs, const array& rhs); \
1049 AFAPI array OP (const unsigned& lhs, const array& rhs); \
1050 AFAPI array OP (const char& lhs, const array& rhs); \
1051 AFAPI array OP (const unsigned char& lhs, const array& rhs); \
1052 AFAPI array OP (const long& lhs, const array& rhs); \
1053 AFAPI array OP (const unsigned long& lhs, const array& rhs); \
1054 AFAPI array OP (const long long& lhs, const array& rhs); \
1055 AFAPI array OP (const unsigned long long& lhs, const array& rhs); \
1056 AFAPI array OP (const double& lhs, const array& rhs); \
1057 AFAPI array OP (const float& lhs, const array& rhs); \
1058 AFAPI array OP (const cfloat& lhs, const array& rhs); \
1059 AFAPI array OP (const cdouble& lhs, const array& rhs); \
1060 AFAPI array OP (const array& lhs, const bool& rhs); \
1061 AFAPI array OP (const array& lhs, const int& rhs); \
1062 AFAPI array OP (const array& lhs, const unsigned& rhs); \
1063 AFAPI array OP (const array& lhs, const char& rhs); \
1064 AFAPI array OP (const array& lhs, const unsigned char& rhs); \
1065 AFAPI array OP (const array& lhs, const long& rhs); \
1066 AFAPI array OP (const array& lhs, const unsigned long& rhs); \
1067 AFAPI array OP (const array& lhs, const long long& rhs); \
1068 AFAPI array OP (const array& lhs, const unsigned long long& rhs); \
1069 AFAPI array OP (const array& lhs, const double& rhs); \
1070 AFAPI array OP (const array& lhs, const float& rhs); \
1071 AFAPI array OP (const array& lhs, const cfloat& rhs); \
1072 AFAPI array OP (const array& lhs, const cdouble& rhs);
1074 #if AF_API_VERSION >= 32
1075 #define BIN_OP(OP) \
1077 AFAPI array OP (const short& lhs, const array& rhs); \
1078 AFAPI array OP (const unsigned short& lhs, const array& rhs); \
1079 AFAPI array OP (const array& lhs, const short& rhs); \
1080 AFAPI array OP (const array& lhs, const unsigned short& rhs);
1083 #define BIN_OP(OP) BIN_OP_(OP)
1374 #if AF_API_VERSION >= 34
1383 #if AF_API_VERSION >= 34
1384 array *arrays[] = {&a, &b};
1385 return eval(2, arrays);
1393 #if AF_API_VERSION >= 34
1394 array *arrays[] = {&a, &b, &c};
1395 return eval(3, arrays);
1397 eval(a, b); c.eval();
1403 #if AF_API_VERSION >= 34
1404 array *arrays[] = {&a, &b, &c, &d};
1405 return eval(4, arrays);
1407 eval(a, b, c); d.eval();
1414 #if AF_API_VERSION >= 34
1415 array *arrays[] = {&a, &b, &c, &d, &e};
1416 return eval(5, arrays);
1418 eval(a, b, c, d); e.eval();
1424 #if AF_API_VERSION >= 34
1425 array *arrays[] = {&a, &b, &c, &d, &e, &f};
1426 return eval(6, arrays);
1428 eval(a, b, c, d, e); f.eval();
1432 #if AF_API_VERSION >= 37
1441 #if AF_COMPILER_CXX_VARIADIC_TEMPLATES
1442 template <
typename... ARRAYS>
1443 inline void eval(ARRAYS... in) {
1444 array *arrays[] = {
const_cast<array *
>(&in)...};
1445 eval((
int)
sizeof...(in), arrays);
1452 const array *arrays[] = {&a, &b};
1453 return eval(2,
const_cast<array **
>(arrays));
1458 const array *arrays[] = {&a, &b, &c};
1459 return eval(3,
const_cast<array **
>(arrays));
1465 const array *arrays[] = {&a, &b, &c, &d};
1466 return eval(4,
const_cast<array **
>(arrays));
1472 const array *arrays[] = {&a, &b, &c, &d, &e};
1473 return eval(5,
const_cast<array **
>(arrays));
1479 const array *arrays[] = {&a, &b, &c, &d, &e, &f};
1480 return eval(6,
const_cast<array **
>(arrays));
1482 #endif // AF_COMPILER_CXX_VARIADIC_TEMPLATES
1485 #if AF_API_VERSION >= 34
1492 #if AF_API_VERSION >= 34
1576 #if AF_API_VERSION >= 31
1597 #if AF_API_VERSION >= 34
1604 #if AF_API_VERSION >= 34
1611 #if AF_API_VERSION >= 34
1763 #if AF_API_VERSION >= 37
1818 #if AF_API_VERSION >= 34
1830 #if AF_API_VERSION >= 35
AFAPI af_err af_is_half(bool *result, const af_array arr)
Check if an array is 16 bit floating point type.
AFAPI af_err af_get_data_ref_count(int *use_count, const af_array in)
Generic object that represents size and shape.
AFAPI array operator&(const array &lhs, const array &rhs)
Performs an bitwise AND operation on two arrays or an array and a value.
AFAPI bool getManualEvalFlag()
Get the manual eval flag.
AFAPI af_err af_set_manual_eval_flag(bool flag)
Turn the manual eval flag on or off.
AFAPI af_err af_get_manual_eval_flag(bool *flag)
Get the manual eval flag.
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_empty(bool *result, const af_array arr)
Check if an array is empty.
void eval() const
Evaluate any JIT expressions to generate data for the array.
AFAPI af_err af_is_floating(bool *result, const af_array arr)
Check if an array is floating precision type.
A multi dimensional data container.
AFAPI af_err af_get_type(af_dtype *type, const af_array arr)
Gets the type of an array.
AFAPI af_err af_eval_multiple(const int num, af_array *arrays)
Evaluate multiple arrays together.
AFAPI void setManualEvalFlag(bool flag)
Turn the manual eval flag on or off.
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.
Struct used to index an af_array.
AFAPI af_err af_is_single(bool *result, const af_array arr)
Check if an array is single precision type.
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.
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 array operator-(const array &lhs, const array &rhs)
Subtracts two arrays or an array and a value.
AFAPI af_err af_is_real(bool *result, const af_array arr)
Check if an array is real type.
AFAPI af_err af_is_realfloating(bool *result, const af_array arr)
Check if an array is real floating point type.
AFAPI af_err af_is_complex(bool *result, const af_array arr)
Check if an array is complex type.
AFAPI af_err af_is_scalar(bool *result, const af_array arr)
Check if an array is scalar, ie.
AFAPI af_err af_is_row(bool *result, const af_array arr)
Check if an array is row vector.
AFAPI af_err af_release_array(af_array arr)
Reduce the reference count of the af_array.
AFAPI af_err af_get_scalar(void *output_value, const af_array arr)
Get first element from an array.
AFAPI af_err af_retain_array(af_array *out, const af_array in)
Increments an af_array reference count.
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_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_is_integer(bool *result, const af_array arr)
Check if an array is integer 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_is_vector(bool *result, const af_array arr)
Check if an array is a vector.
AFAPI seq span
A special value representing the entire axis of an af::array.
AFAPI af_err af_copy_array(af_array *arr, const af_array in)
AFAPI af_err af_is_bool(bool *result, const af_array arr)
Check if an array is bool type.
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 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_eval(af_array in)
Evaluate any expressions in the 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 array operator&&(const array &lhs, const array &rhs)
Performs a logical AND operation on two arrays or an array and a value.
@ f32
32-bit floating point values
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.