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
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);
115 template<
typename T> T*
host()
const;
130 inline bool isreal()
const {
return !iscomplex(); }
133#if AF_API_VERSION >= 37
140#if AF_API_VERSION >= 34
150#if AF_API_VERSION >= 31
154#if AF_API_VERSION >= 34
185#if AF_API_VERSION >= 37
186#if AF_COMPILER_CXX_RVALUE_REFERENCES
522#if AF_API_VERSION >= 38
523#if AF_COMPILER_CXX_GENERALIZED_INITIALIZERS
525 template <
typename T,
typename =
typename std::enable_if<
526 std::is_fundamental<T>::value,
void>::type>
527 array(std::initializer_list<T> list)
529 dim_t size = list.size();
534 af::exception ex(msg, __PRETTY_FUNCTION__,
"include/af/array.h",
542 template <
typename T,
typename =
typename std::enable_if<
543 std::is_fundamental<T>::value,
void>::type>
544 array(
const af::dim4 &dims, std::initializer_list<T> list)
552 af::exception ex(msg, __PRETTY_FUNCTION__,
"include/af/array.h",
641 template<
typename T> T*
host()
const;
725 inline bool isreal()
const {
return !iscomplex(); }
737#if AF_API_VERSION >= 37
766#if AF_API_VERSION >= 34
845 const index &s2 = span,
846 const index &s3 = span);
855 const index &s2 = span,
856 const index &s3 = span)
const;
982#define ASSIGN_(OP2) \
983 array& OP2(const array &val); \
984 array& OP2(const double &val); \
985 array& OP2(const cdouble &val); \
986 array& OP2(const cfloat &val); \
987 array& OP2(const float &val); \
988 array& OP2(const int &val); \
989 array& OP2(const unsigned &val); \
990 array& OP2(const bool &val); \
991 array& OP2(const char &val); \
992 array& OP2(const unsigned char &val); \
993 array& OP2(const long &val); \
994 array& OP2(const unsigned long &val); \
995 array& OP2(const long long &val); \
996 array& OP2(const unsigned long long &val);
999#if AF_API_VERSION >= 32
1002 array& OP(const short &val); \
1003 array& OP(const unsigned short &val);
1006#define ASSIGN(OP) ASSIGN_(OP)
1089#if AF_API_VERSION >= 38
1113#if AF_API_VERSION >= 34
1132#define BIN_OP_(OP) \
1133 AFAPI array OP (const array& lhs, const array& rhs); \
1134 AFAPI array OP (const bool& lhs, const array& rhs); \
1135 AFAPI array OP (const int& lhs, const array& rhs); \
1136 AFAPI array OP (const unsigned& lhs, const array& rhs); \
1137 AFAPI array OP (const char& lhs, const array& rhs); \
1138 AFAPI array OP (const unsigned char& lhs, const array& rhs); \
1139 AFAPI array OP (const long& lhs, const array& rhs); \
1140 AFAPI array OP (const unsigned long& lhs, const array& rhs); \
1141 AFAPI array OP (const long long& lhs, const array& rhs); \
1142 AFAPI array OP (const unsigned long long& lhs, const array& rhs); \
1143 AFAPI array OP (const double& lhs, const array& rhs); \
1144 AFAPI array OP (const float& lhs, const array& rhs); \
1145 AFAPI array OP (const cfloat& lhs, const array& rhs); \
1146 AFAPI array OP (const cdouble& lhs, const array& rhs); \
1147 AFAPI array OP (const array& lhs, const bool& rhs); \
1148 AFAPI array OP (const array& lhs, const int& rhs); \
1149 AFAPI array OP (const array& lhs, const unsigned& rhs); \
1150 AFAPI array OP (const array& lhs, const char& rhs); \
1151 AFAPI array OP (const array& lhs, const unsigned char& rhs); \
1152 AFAPI array OP (const array& lhs, const long& rhs); \
1153 AFAPI array OP (const array& lhs, const unsigned long& rhs); \
1154 AFAPI array OP (const array& lhs, const long long& rhs); \
1155 AFAPI array OP (const array& lhs, const unsigned long long& rhs); \
1156 AFAPI array OP (const array& lhs, const double& rhs); \
1157 AFAPI array OP (const array& lhs, const float& rhs); \
1158 AFAPI array OP (const array& lhs, const cfloat& rhs); \
1159 AFAPI array OP (const array& lhs, const cdouble& rhs);
1161#if AF_API_VERSION >= 32
1164 AFAPI array OP (const short& lhs, const array& rhs); \
1165 AFAPI array OP (const unsigned short& lhs, const array& rhs); \
1166 AFAPI array OP (const array& lhs, const short& rhs); \
1167 AFAPI array OP (const array& lhs, const unsigned short& rhs);
1170#define BIN_OP(OP) BIN_OP_(OP)
1461#if AF_API_VERSION >= 34
1470#if AF_API_VERSION >= 34
1471 array *arrays[] = {&a, &b};
1472 return eval(2, arrays);
1480#if AF_API_VERSION >= 34
1481 array *arrays[] = {&a, &b, &c};
1482 return eval(3, arrays);
1490#if AF_API_VERSION >= 34
1491 array *arrays[] = {&a, &b, &c, &d};
1492 return eval(4, arrays);
1501#if AF_API_VERSION >= 34
1502 array *arrays[] = {&a, &b, &c, &d, &e};
1503 return eval(5, arrays);
1511#if AF_API_VERSION >= 34
1512 array *arrays[] = {&a, &b, &c, &d, &e, &f};
1513 return eval(6, arrays);
1519#if AF_API_VERSION >= 37
1524#if AF_COMPILER_CXX_VARIADIC_TEMPLATES
1525 template <
typename... ARRAYS>
1526 inline void eval(ARRAYS... in) {
1527 array *arrays[] = {
const_cast<array *
>(&in)...};
1528 eval((
int)
sizeof...(in), arrays);
1535 const array *arrays[] = {&a, &b};
1536 return eval(2,
const_cast<array **
>(arrays));
1541 const array *arrays[] = {&a, &b, &c};
1542 return eval(3,
const_cast<array **
>(arrays));
1548 const array *arrays[] = {&a, &b, &c, &d};
1549 return eval(4,
const_cast<array **
>(arrays));
1555 const array *arrays[] = {&a, &b, &c, &d, &e};
1556 return eval(5,
const_cast<array **
>(arrays));
1562 const array *arrays[] = {&a, &b, &c, &d, &e, &f};
1563 return eval(6,
const_cast<array **
>(arrays));
1568#if AF_API_VERSION >= 34
1575#if AF_API_VERSION >= 34
1655#if AF_API_VERSION >= 31
1667#if AF_API_VERSION >= 34
1674#if AF_API_VERSION >= 34
1681#if AF_API_VERSION >= 34
1826#if AF_API_VERSION >= 37
1881#if AF_API_VERSION >= 34
1893#if AF_API_VERSION >= 35
array::array_proxy slices(int first, int last)
bool isrealfloating() const
array as(dtype type) const
const array::array_proxy slice(int index) const
void host(void *ptr) const
array::array_proxy slice(int index)
array_proxy(const array_proxy &other)
dim_t dims(unsigned dim) const
array_proxy(array &par, af_index_t *ssss, bool linear=false)
const array::array_proxy rows(int first, int last) const
const array::array_proxy row(int index) const
const array::array_proxy cols(int first, int last) const
array::array_proxy row(int index)
array::array_proxy cols(int first, int last)
array::array_proxy rows(int first, int last)
const array::array_proxy slices(int first, int last) const
array::array_proxy col(int index)
const array::array_proxy col(int index) const
A multi dimensional data container.
bool isempty() const
Returns true of the array is empty.
T scalar() const
Get the first element of the array as a scalar.
void lock() const
Locks the device buffer in the memory manager.
dim4 dims() const
Get dimensions of the array.
array(const dim4 &dims, const T *pointer, af::source src=afHost)
Create an array of specified size on the device using a host/device pointer.
dtype type() const
Get array data type.
array(dim_t dim0, dim_t dim1, dtype ty=f32)
Allocate a two-dimensional array of a specified size with undefined contents.
array H() const
Get the conjugate-transpose of the current array.
bool isvector() const
Returns true if only one of the array dimensions has more than one element.
bool isrealfloating() const
Returns true if the array type is f16 f32 or f64.
bool iscomplex() const
Returns true if the array type is c32 or c64.
size_t bytes() const
Get the size of the array in bytes.
bool ishalf() const
Returns true if the array type is f16.
bool isscalar() const
Returns true of the array contains only one value.
bool isLocked() const
Query if the array has been locked by the user.
T * host() const
Copy array data to host and return host pointer.
void set(af_array tmp)
Updates the internal af_array object.
array(const array &input, const dim_t dim0, const dim_t dim1=1, const dim_t dim2=1, const dim_t dim3=1)
Adjust the dimensions of an N-D array (fast).
bool isinteger() const
Returns true if the array type is u8, b8, s32 u32, s64, u64, s16, u16.
bool issparse() const
Returns true if the array is a sparse array.
array(const dim4 &dims, dtype ty=f32)
Allocate an array of a specified size with undefined contents.
const array as(dtype type) const
Casts the array into another data type.
void host(void *ptr) const
Copy array data to existing host pointer.
T * device() const
Get the device pointer from the array and lock the buffer in memory manager.
array(dim_t dim0, dim_t dim1, dim_t dim2, dtype ty=f32)
Allocate a three-dimensional (3D) array of a specified size with undefined contents.
void eval() const
Evaluate any JIT expressions to generate data for the array.
array(dim_t dim0, dim_t dim1, dim_t dim2, dim_t dim3, dtype ty=f32)
Allocate a four-dimensional (4D) array of a specified size with undefined contents.
array(dim_t dim0, dtype ty=f32)
Allocate a one-dimensional array of a specified size with undefined contents.
bool isbool() const
Returns true if the array type is b8.
array T() const
Get the transposed the array.
bool issingle() const
Returns true if the array type is either f32 nor c32.
dim_t dims(unsigned dim) const
Get dimensions of the array.
dim_t elements() const
Get the total number of elements across all dimensions of the array.
size_t allocated() const
Get the size of the array in memory.
array(dim_t dim0, const T *pointer, af::source src=afHost)
Create a column vector on the device using a host/device pointer.
bool isrow() const
Returns true if only the second dimension has more than one element.
array()
Create an uninitialized array (no data, undefined size)
array(dim_t dim0, dim_t dim1, const T *pointer, af::source src=afHost)
Create a 2D array on the device using a host/device pointer.
void write(const T *ptr, const size_t bytes, af::source src=afHost)
Perform deep copy from host/device pointer to an existing array.
array copy() const
Perform deep copy of the array.
array(dim_t dim0, dim_t dim1, dim_t dim2, dim_t dim3, const T *pointer, af::source src=afHost)
Create a 4D array on the device using a host/device pointer.
af_array get()
get the af_array handle
bool isfloating() const
Returns true if the array type is f16 f32, f64, c32 or c64.
array(const array &input, const dim4 &dims)
Adjust the dimensions of an N-D array (fast).
void unlock() const
Unlocks the device buffer in the memory manager.
array(dim_t dim0, dim_t dim1, dim_t dim2, const T *pointer, af::source src=afHost)
Create a 3D array on the device using a host/device pointer.
array(const array &in)
Creates a copy to the in array.
array(const af_array handle)
Creates an array from an af_array handle.
bool isdouble() const
Returns true if the array type is f64 or c64.
af_array get() const
get the af_array handle
bool isreal() const
Returns true if the array type is neither c32 nor c64.
int nonzeros() const
Get the count of non-zero elements in the array.
unsigned numdims() const
Get the number of dimensions of the array.
bool iscolumn() const
Returns true if only the first dimension has more than one element.
Generic object that represents size and shape.
dim_t * get()
Returns the underlying pointer to the dim4 object.
An ArrayFire exception class.
@ f32
32-bit floating point values
AFAPI void af_get_last_error(char **msg, dim_t *len)
Returns the last error message that occurred and its error message.
AFAPI array operator&&(const array &lhs, const array &rhs)
Performs a logical AND operation on two arrays or an array and a value.
AFAPI array operator&(const array &lhs, const array &rhs)
Performs an bitwise AND operation on two arrays or an array and a value.
const array::array_proxy cols(int first, int last) const
Returns a reference to sequence of columns.
array::array_proxy cols(int first, int last)
Returns a reference to sequence of columns.
array::array_proxy col(int index)
Returns a reference to a col.
const array::array_proxy col(int index) const
Returns a reference to a col.
array::array_proxy operator()(const index &s0)
This operator returns a reference of the original array at a given coordinate.
const array::array_proxy operator()(const index &s0, const index &s1, const index &s2=span, const index &s3=span) const
This operator returns a reference of the original array at a given coordinate.
const array::array_proxy operator()(const index &s0) const
This operator returns a reference of the original array at a given coordinate.
array::array_proxy operator()(const index &s0, const index &s1, const index &s2=span, const index &s3=span)
This operator returns a reference of the original array at a given coordinate.
const array::array_proxy rows(int first, int last) const
Returns a reference to sequence of rows.
const array::array_proxy row(int index) const
Returns a reference to a row.
array::array_proxy row(int index)
Returns a reference to a row.
array::array_proxy rows(int first, int last)
Returns a reference to sequence of rows.
array::array_proxy slices(int first, int last)
Returns a reference to a matrix in a volume.
const array::array_proxy slice(int index) const
Returns a reference to a matrix in a volume.
array::array_proxy slice(int index)
Returns a reference to a matrix in a volume.
const array::array_proxy slices(int first, int last) const
Returns a reference to a matrix in a volume.
AFAPI af_err af_is_vector(bool *result, const af_array arr)
Check if an array is a vector.
AFAPI af_err af_get_type(af_dtype *type, const af_array arr)
Gets the type of an array.
AFAPI af_err af_copy_array(af_array *arr, const af_array in)
Deep copy an array to another.
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.
AFAPI af_err af_is_single(bool *result, const af_array arr)
Check if an array is single precision type.
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)
Get the reference count of af_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 af_err af_is_floating(bool *result, const af_array arr)
Check if an array is floating precision type.
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_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_realfloating(bool *result, const af_array arr)
Check if an array is real floating point type.
AFAPI af_err af_is_integer(bool *result, const af_array arr)
Check if an array is integer type.
AFAPI af_err af_retain_array(af_array *out, const af_array in)
Increments an af_array reference count.
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_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_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_eval(af_array in)
Evaluate any expressions in the Array.
AFAPI af_err af_eval_multiple(const int num, af_array *arrays)
Evaluate multiple arrays together.
AFAPI af_err af_is_row(bool *result, const af_array arr)
Check if an array is row vector.
AFAPI af_err af_is_sparse(bool *result, const af_array arr)
Check if an array is sparse.
AFAPI af_err af_is_complex(bool *result, const af_array arr)
Check if an array is complex type.
AFAPI af_err af_release_array(af_array arr)
Reduce the reference count of the af_array.
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_scalar(bool *result, const af_array arr)
Check if an array is scalar, ie.
AFAPI af_err af_get_numdims(unsigned *result, const af_array arr)
Gets the number of dimensions of an array.
AFAPI af_err af_get_scalar(void *output_value, const af_array arr)
Get first element from an array.
AFAPI af_err af_is_real(bool *result, const af_array arr)
Check if an array is real type.
AFAPI af_err af_is_bool(bool *result, const af_array arr)
Check if an array is bool 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.
AFAPI bool getManualEvalFlag()
Get the manual eval flag.
AFAPI void setManualEvalFlag(bool flag)
Turn the manual eval flag on or off.
array & eval(array &a)
Evaluate an expression (nonblocking).
AFAPI af_err af_free_host(void *ptr)
Struct used to index an af_array.