11 #include <af/compilers.h> 23 #if AF_API_VERSION >= 38 24 #if AF_COMPILER_CXX_GENERALIZED_INITIALIZERS 25 #include <initializer_list> 58 struct array_proxy_impl;
59 array_proxy_impl *impl;
64 #if AF_COMPILER_CXX_RVALUE_REFERENCES 71 operator array()
const;
75 array_proxy& operator OP(const array_proxy &a); \ 76 array_proxy& operator OP(const array &a); \ 77 array_proxy& operator OP(const double &a); \ 78 array_proxy& operator OP(const cdouble &a); \ 79 array_proxy& operator OP(const cfloat &a); \ 80 array_proxy& operator OP(const float &a); \ 81 array_proxy& operator OP(const int &a); \ 82 array_proxy& operator OP(const unsigned &a); \ 83 array_proxy& operator OP(const bool &a); \ 84 array_proxy& operator OP(const char &a); \ 85 array_proxy& operator OP(const unsigned char &a); \ 86 array_proxy& operator OP(const long &a); \ 87 array_proxy& operator OP(const unsigned long &a); \ 88 array_proxy& operator OP(const long long &a); \ 89 array_proxy& operator OP(const unsigned long long &a); 98 #if AF_API_VERSION >= 32 100 array_proxy& operator OP(const short &a); \ 101 array_proxy& operator OP(const unsigned short &a); 114 dim_t elements()
const;
115 template<
typename T> T* host()
const;
116 void host(
void *ptr)
const;
119 dim_t dims(
unsigned dim)
const;
120 unsigned numdims()
const;
121 size_t bytes()
const;
122 size_t allocated()
const;
124 bool isempty()
const;
125 bool isscalar()
const;
126 bool isvector()
const;
128 bool iscolumn()
const;
129 bool iscomplex()
const;
130 inline bool isreal()
const {
return !iscomplex(); }
131 bool isdouble()
const;
132 bool issingle()
const;
133 #if AF_API_VERSION >= 37 136 bool isrealfloating()
const;
137 bool isfloating()
const;
138 bool isinteger()
const;
140 #if AF_API_VERSION >= 34 141 bool issparse()
const;
147 template<
typename T> T scalar()
const;
148 template<
typename T> T* device()
const;
150 #if AF_API_VERSION >= 31 154 #if AF_API_VERSION >= 34 155 bool isLocked()
const;
185 #if AF_API_VERSION >= 37 186 #if AF_COMPILER_CXX_RVALUE_REFERENCES 530 #if AF_API_VERSION >= 38 531 #if AF_COMPILER_CXX_GENERALIZED_INITIALIZERS 532 template <
typename T,
typename =
typename std::enable_if<
534 std::is_fundamental<T>::value,
void>::type>
535 array(std::initializer_list<T> list)
537 dim_t size = list.size();
542 af::exception ex(msg, __PRETTY_FUNCTION__,
"include/af/array.h",
550 template <
typename T,
typename =
typename std::enable_if<
551 std::is_fundamental<T>::value,
void>::type>
560 af::exception ex(msg, __PRETTY_FUNCTION__,
"include/af/array.h",
644 dim_t elements()
const;
649 template<
typename T> T* host()
const;
654 void host(
void *ptr)
const;
659 template<
typename T>
void write(
const T *ptr,
const size_t bytes,
af::source src =
afHost);
674 dim_t dims(
unsigned dim)
const;
679 unsigned numdims()
const;
684 size_t bytes()
const;
690 size_t allocated()
const;
700 bool isempty()
const;
705 bool isscalar()
const;
711 bool isvector()
const;
723 bool iscolumn()
const;
728 bool iscomplex()
const;
733 inline bool isreal()
const {
return !iscomplex(); }
738 bool isdouble()
const;
743 bool issingle()
const;
745 #if AF_API_VERSION >= 37 755 bool isrealfloating()
const;
761 bool isfloating()
const;
767 bool isinteger()
const;
774 #if AF_API_VERSION >= 34 778 bool issparse()
const;
792 template<
typename T> T scalar()
const;
802 template<
typename T> T* device()
const;
990 #define ASSIGN_(OP2) \ 991 array& OP2(const array &val); \ 992 array& OP2(const double &val); \ 993 array& OP2(const cdouble &val); \ 994 array& OP2(const cfloat &val); \ 995 array& OP2(const float &val); \ 996 array& OP2(const int &val); \ 997 array& OP2(const unsigned &val); \ 998 array& OP2(const bool &val); \ 999 array& OP2(const char &val); \ 1000 array& OP2(const unsigned char &val); \ 1001 array& OP2(const long &val); \ 1002 array& OP2(const unsigned long &val); \ 1003 array& OP2(const long long &val); \ 1004 array& OP2(const unsigned long long &val); 1007 #if AF_API_VERSION >= 32 1008 #define ASSIGN(OP) \ 1010 array& OP(const short &val); \ 1011 array& OP(const unsigned short &val); 1014 #define ASSIGN(OP) ASSIGN_(OP) 1095 array operator !()
const;
1097 #if AF_API_VERSION >= 38 1098 array operator ~()
const;
1110 int nonzeros()
const;
1121 #if AF_API_VERSION >= 34 1122 bool isLocked()
const;
1136 void unlock()
const;
1140 #define BIN_OP_(OP) \ 1141 AFAPI array OP (const array& lhs, const array& rhs); \ 1142 AFAPI array OP (const bool& lhs, const array& rhs); \ 1143 AFAPI array OP (const int& lhs, const array& rhs); \ 1144 AFAPI array OP (const unsigned& lhs, const array& rhs); \ 1145 AFAPI array OP (const char& lhs, const array& rhs); \ 1146 AFAPI array OP (const unsigned char& lhs, const array& rhs); \ 1147 AFAPI array OP (const long& lhs, const array& rhs); \ 1148 AFAPI array OP (const unsigned long& lhs, const array& rhs); \ 1149 AFAPI array OP (const long long& lhs, const array& rhs); \ 1150 AFAPI array OP (const unsigned long long& lhs, const array& rhs); \ 1151 AFAPI array OP (const double& lhs, const array& rhs); \ 1152 AFAPI array OP (const float& lhs, const array& rhs); \ 1153 AFAPI array OP (const cfloat& lhs, const array& rhs); \ 1154 AFAPI array OP (const cdouble& lhs, const array& rhs); \ 1155 AFAPI array OP (const array& lhs, const bool& rhs); \ 1156 AFAPI array OP (const array& lhs, const int& rhs); \ 1157 AFAPI array OP (const array& lhs, const unsigned& rhs); \ 1158 AFAPI array OP (const array& lhs, const char& rhs); \ 1159 AFAPI array OP (const array& lhs, const unsigned char& rhs); \ 1160 AFAPI array OP (const array& lhs, const long& rhs); \ 1161 AFAPI array OP (const array& lhs, const unsigned long& rhs); \ 1162 AFAPI array OP (const array& lhs, const long long& rhs); \ 1163 AFAPI array OP (const array& lhs, const unsigned long long& rhs); \ 1164 AFAPI array OP (const array& lhs, const double& rhs); \ 1165 AFAPI array OP (const array& lhs, const float& rhs); \ 1166 AFAPI array OP (const array& lhs, const cfloat& rhs); \ 1167 AFAPI array OP (const array& lhs, const cdouble& rhs); 1169 #if AF_API_VERSION >= 32 1170 #define BIN_OP(OP) \ 1172 AFAPI array OP (const short& lhs, const array& rhs); \ 1173 AFAPI array OP (const unsigned short& lhs, const array& rhs); \ 1174 AFAPI array OP (const array& lhs, const short& rhs); \ 1175 AFAPI array OP (const array& lhs, const unsigned short& rhs); 1178 #define BIN_OP(OP) BIN_OP_(OP) 1469 #if AF_API_VERSION >= 34 1478 #if AF_API_VERSION >= 34 1479 array *arrays[] = {&a, &b};
1480 return eval(2, arrays);
1488 #if AF_API_VERSION >= 34 1489 array *arrays[] = {&a, &b, &c};
1490 return eval(3, arrays);
1498 #if AF_API_VERSION >= 34 1499 array *arrays[] = {&a, &b, &c, &d};
1500 return eval(4, arrays);
1509 #if AF_API_VERSION >= 34 1510 array *arrays[] = {&a, &b, &c, &d, &e};
1511 return eval(5, arrays);
1519 #if AF_API_VERSION >= 34 1520 array *arrays[] = {&a, &b, &c, &d, &e, &f};
1521 return eval(6, arrays);
1527 #if AF_API_VERSION >= 37 1532 #if AF_COMPILER_CXX_VARIADIC_TEMPLATES 1533 template <
typename... ARRAYS>
1534 inline void eval(ARRAYS... in) {
1535 array *arrays[] = {
const_cast<array *
>(&in)...};
1536 eval((
int)
sizeof...(in), arrays);
1543 const array *arrays[] = {&a, &b};
1544 return eval(2, const_cast<array **>(arrays));
1549 const array *arrays[] = {&a, &b, &c};
1550 return eval(3, const_cast<array **>(arrays));
1556 const array *arrays[] = {&a, &b, &c, &d};
1557 return eval(4, const_cast<array **>(arrays));
1563 const array *arrays[] = {&a, &b, &c, &d, &e};
1564 return eval(5, const_cast<array **>(arrays));
1570 const array *arrays[] = {&a, &b, &c, &d, &e, &f};
1571 return eval(6, const_cast<array **>(arrays));
1573 #endif // AF_COMPILER_CXX_VARIADIC_TEMPLATES 1576 #if AF_API_VERSION >= 34 1583 #if AF_API_VERSION >= 34 1663 #if AF_API_VERSION >= 31 1675 #if AF_API_VERSION >= 34 1682 #if AF_API_VERSION >= 34 1689 #if AF_API_VERSION >= 34 1834 #if AF_API_VERSION >= 37 1889 #if AF_API_VERSION >= 34 1901 #if AF_API_VERSION >= 35 An ArrayFire exception class.
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 af_err af_get_numdims(unsigned *result, const af_array arr)
Gets the number of dimensions of an array.
AFAPI void af_get_last_error(char **msg, dim_t *len)
Returns the last error message that occurred and its error message.
AFAPI af_err af_is_column(bool *result, const af_array arr)
Check if an array is a column vector.
AFAPI af_err af_get_scalar(void *output_value, const af_array arr)
Get first element from an array.
AFAPI af_err af_get_type(af_dtype *type, const af_array arr)
Gets the type of an array.
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_is_complex(bool *result, const af_array arr)
Check if an array is complex type.
AFAPI af_err af_retain_array(af_array *out, const af_array in)
Increments an af_array reference count.
AFAPI af_err af_is_scalar(bool *result, const af_array arr)
Check if an array is scalar, ie.
AFAPI af_err af_eval(af_array in)
Evaluate any expressions in the Array.
A multi dimensional data container.
AFAPI af_err af_is_integer(bool *result, const af_array arr)
Check if an array is integer 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 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_elements(dim_t *elems, const af_array arr)
Get the total number of elements across all dimensions of the array.
AFAPI af_err af_is_double(bool *result, const af_array arr)
Check if an array is double precision type.
Struct used to index an af_array.
AFAPI seq span
A special value representing the entire axis of an af::array.
AFAPI af_err af_free_host(void *ptr)
AFAPI af_err af_get_data_ptr(void *data, const af_array arr)
Copy data from an af_array to a C pointer.
dim_t * get()
Returns the underlying pointer to the dim4 object.
AFAPI af_err af_get_manual_eval_flag(bool *flag)
Get the manual eval flag.
AFAPI af_err af_set_manual_eval_flag(bool flag)
Turn the manual eval flag on or off.
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_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_is_row(bool *result, const af_array arr)
Check if an array is row vector.
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.
AFAPI af_err af_is_single(bool *result, const af_array arr)
Check if an array is single precision type.
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.
array & eval(array &a)
Evaluate an expression (nonblocking).
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 void setManualEvalFlag(bool flag)
Turn the manual eval flag on or off.
AFAPI af_err af_eval_multiple(const int num, af_array *arrays)
Evaluate multiple arrays together.
AFAPI af_err af_is_empty(bool *result, const af_array arr)
Check if an array is empty.
AFAPI af_err af_copy_array(af_array *arr, const af_array in)
Deep copy an array to another.
bool isreal() const
Returns true if the array type is neither c32 nor c64.
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 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.
32-bit floating point values
AFAPI af_err af_is_real(bool *result, const af_array arr)
Check if an array is real type.
AFAPI af_err af_is_sparse(bool *result, const af_array arr)
Check if an array is sparse.
Generic object that represents size and shape.
AFAPI af_err af_is_bool(bool *result, const af_array arr)
Check if an array is bool 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_realfloating(bool *result, const af_array arr)
Check if an array is real floating point type.
AFAPI bool getManualEvalFlag()
Get the manual eval flag.
AFAPI af_err af_release_array(af_array arr)
Reduce the reference count of the af_array.