array.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/compilers.h>
12 #include <af/defines.h>
13 #include <af/index.h>
14 #include <af/seq.h>
15 #include <af/util.h>
16 
17 #ifdef __cplusplus
18 #include <af/traits.hpp>
19 
20 namespace af
21 {
22 
23  class dim4;
24 
28  class AFAPI array {
29  af_array arr;
30 
31 
32  public:
39  void set(af_array tmp);
40 
46  class AFAPI array_proxy
47  {
48  struct array_proxy_impl; //forward declaration
49  array_proxy_impl *impl; // implementation
50 
51  public:
52  array_proxy(array& par, af_index_t *ssss, bool linear = false);
53  array_proxy(const array_proxy &other);
54 #if AF_COMPILER_CXX_RVALUE_REFERENCES
55  array_proxy(array_proxy &&other);
56  array_proxy & operator=(array_proxy &&other);
57 #endif
58  ~array_proxy();
59 
60  // Implicit conversion operators
61  operator array() const;
62  operator array();
63 
64 #define ASSIGN(OP) \
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);
80 
81  ASSIGN(=)
82  ASSIGN(+=)
83  ASSIGN(-=)
84  ASSIGN(*=)
85  ASSIGN(/=)
86 #undef ASSIGN
87 
88 #if AF_API_VERSION >= 32
89 #define ASSIGN(OP) \
90  array_proxy& operator OP(const short &a); \
91  array_proxy& operator OP(const unsigned short &a);
92 
93  ASSIGN(=)
94  ASSIGN(+=)
95  ASSIGN(-=)
96  ASSIGN(*=)
97  ASSIGN(/=)
98 #undef ASSIGN
99 #endif
100 
101  // af::array member functions. same behavior as those below
102  af_array get();
103  af_array get() const;
104  dim_t elements() const;
105  template<typename T> T* host() const;
106  void host(void *ptr) const;
107  dtype type() const;
108  dim4 dims() const;
109  dim_t dims(unsigned dim) const;
110  unsigned numdims() const;
111  size_t bytes() const;
112  size_t allocated() const;
113  array copy() const;
114  bool isempty() const;
115  bool isscalar() const;
116  bool isvector() const;
117  bool isrow() 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
124  bool ishalf() const;
125 #endif
126  bool isrealfloating() const;
127  bool isfloating() const;
128  bool isinteger() const;
129  bool isbool() const;
130 #if AF_API_VERSION >= 34
131  bool issparse() const;
132 #endif
133  void eval() const;
134  array as(dtype type) const;
135  array T() const;
136  array H() const;
137  template<typename T> T scalar() const;
138  template<typename T> T* device() const;
139  void unlock() const;
140 #if AF_API_VERSION >= 31
141  void lock() const;
142 #endif
143 
144 #if AF_API_VERSION >= 34
145  bool isLocked() const;
146 #endif
147 
148  array::array_proxy row(int index);
149  const array::array_proxy row(int index) const;
150 
151  array::array_proxy rows(int first, int last);
152  const array::array_proxy rows(int first, int last) const;
153 
154  array::array_proxy col(int index);
155  const array::array_proxy col(int index) const;
156  array::array_proxy cols(int first, int last);
157  const array::array_proxy cols(int first, int last) const;
158 
159  array::array_proxy slice(int index);
160  const array::array_proxy slice(int index) const;
161 
162  array::array_proxy slices(int first, int last);
163  const array::array_proxy slices(int first, int last) const;
164  };
165 
166  //array(af_array in, const array *par, af_index_t seqs[4]);
178  array();
179 
180 #if AF_API_VERSION >= 37
181 #if AF_COMPILER_CXX_RVALUE_REFERENCES
182 
190  array(array &&other) AF_NOEXCEPT;
191 
202  array &operator=(array &&other) AF_NOEXCEPT;
203 #endif
204 #endif
205 
212  explicit
213  array(const af_array handle);
214 
220  array(const array& in);
221 
244  array(dim_t dim0, dtype ty = f32);
245 
269  array(dim_t dim0, dim_t dim1, dtype ty = f32);
270 
295  array(dim_t dim0, dim_t dim1, dim_t dim2, dtype ty = f32);
296 
322  array(dim_t dim0, dim_t dim1, dim_t dim2, dim_t dim3, dtype ty = f32);
323 
349  explicit
350  array(const dim4& dims, dtype ty = f32);
351 
376  template<typename T>
377  array(dim_t dim0,
378  const T *pointer, af::source src=afHost);
379 
380 
399  template<typename T>
400  array(dim_t dim0, dim_t dim1,
401  const T *pointer, af::source src=afHost);
402 
403 
425  template<typename T>
426  array(dim_t dim0, dim_t dim1, dim_t dim2,
427  const T *pointer, af::source src=afHost);
428 
429 
452  template<typename T>
453  array(dim_t dim0, dim_t dim1, dim_t dim2, dim_t dim3,
454  const T *pointer, af::source src=afHost);
455 
489  template<typename T>
490  explicit
491  array(const dim4& dims,
492  const T *pointer, af::source src=afHost);
493 
520  array(const array& input, const dim4& dims);
521 
552  array( const array& input,
553  const dim_t dim0, const dim_t dim1 = 1,
554  const dim_t dim2 = 1, const dim_t dim3 = 1);
555 
568  af_array get();
569 
573  af_array get() const;
574 
578  dim_t elements() const;
579 
583  template<typename T> T* host() const;
584 
588  void host(void *ptr) const;
589 
593  template<typename T> void write(const T *ptr, const size_t bytes, af::source src = afHost);
594 
598  dtype type() const;
599 
603  dim4 dims() const;
604 
608  dim_t dims(unsigned dim) const;
609 
613  unsigned numdims() const;
614 
618  size_t bytes() const;
619 
624  size_t allocated() const;
625 
629  array copy() const;
630 
634  bool isempty() const;
635 
639  bool isscalar() const;
640 
644  bool isvector() const;
645 
649  bool isrow() const;
650 
654  bool iscolumn() const;
655 
659  bool iscomplex() const;
660 
664  inline bool isreal() const { return !iscomplex(); }
665 
669  bool isdouble() const;
670 
674  bool issingle() const;
675 
676 #if AF_API_VERSION >= 37
677 
680  bool ishalf() const;
681 #endif
682 
686  bool isrealfloating() const;
687 
691  bool isfloating() const;
692 
696  bool isinteger() const;
697 
701  bool isbool() const;
702 
703 #if AF_API_VERSION >= 34
704 
707  bool issparse() const;
708 #endif
709 
713  void eval() const;
714 
720  template<typename T> T scalar() const;
721 
735  template<typename T> T* device() const;
740  // INDEXING
741  // Single arguments
742 
760  array::array_proxy operator()(const index &s0);
761 
767  const array::array_proxy operator()(const index &s0) const;
768 
769 
787  array::array_proxy operator()(const index &s0,
788  const index &s1,
789  const index &s2 = span,
790  const index &s3 = span);
791 
797  const array::array_proxy operator()(const index &s0,
798  const index &s1,
799  const index &s2 = span,
800  const index &s3 = span) const;
801 
802 
814  array::array_proxy row(int index);
815  const array::array_proxy row(int index) const;
816 
826  array::array_proxy rows(int first, int last);
827  const array::array_proxy rows(int first, int last) const;
828 
841  array::array_proxy col(int index);
842  const array::array_proxy col(int index) const;
843 
853  array::array_proxy cols(int first, int last);
854  const array::array_proxy cols(int first, int last) const;
855 
868  array::array_proxy slice(int index);
869  const array::array_proxy slice(int index) const;
870 
879  array::array_proxy slices(int first, int last);
880  const array::array_proxy slices(int first, int last) const;
881 
888  const array as(dtype type) const;
889 
890 
891  ~array();
892 
897  array T() const;
902  array H() const;
903 
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);
919 
920 
921 #if AF_API_VERSION >= 32
922 #define ASSIGN(OP) \
923  ASSIGN_(OP) \
924  array& OP(const short &val); \
925  array& OP(const unsigned short &val);
926 
927 #else
928 #define ASSIGN(OP) ASSIGN_(OP)
929 #endif
930 
931 
941  ASSIGN(operator=)
943 
953  ASSIGN(operator+=)
955 
965  ASSIGN(operator-=)
967 
977  ASSIGN(operator*=)
979 
990  ASSIGN(operator/=)
992 
993 
994 #undef ASSIGN
995 #undef ASSIGN_
996 
1002  array operator -() const;
1003 
1009  array operator !() const;
1010 
1015  int nonzeros() const;
1016 
1017 
1023  void lock() const;
1024 
1025 
1026 #if AF_API_VERSION >= 34
1027  bool isLocked() const;
1033 #endif
1034 
1035 
1041  void unlock() const;
1042  };
1043  // end of class array
1044 
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);
1073 
1074 #if AF_API_VERSION >= 32
1075 #define BIN_OP(OP) \
1076  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);
1081 
1082 #else
1083 #define BIN_OP(OP) BIN_OP_(OP)
1084 #endif
1085 
1094  BIN_OP(operator+ )
1096 
1105  BIN_OP(operator- )
1107 
1116  BIN_OP(operator* )
1118 
1127  BIN_OP(operator/ )
1129 
1138  BIN_OP(operator==)
1140 
1150  BIN_OP(operator!=)
1152 
1162  BIN_OP(operator< )
1164 
1173  BIN_OP(operator<=)
1175 
1185  BIN_OP(operator> )
1187 
1197  BIN_OP(operator>=)
1199 
1210  BIN_OP(operator||)
1212 
1222  BIN_OP(operator% )
1224 
1235  BIN_OP(operator| )
1237 
1248  BIN_OP(operator^ )
1250 
1261  BIN_OP(operator<<)
1263 
1274  BIN_OP(operator>>)
1276 
1277 #undef BIN_OP
1278 #undef BIN_OP_
1279 
1290  AFAPI array operator&(const array& lhs, const array& rhs);
1291  AFAPI array operator&(const array& lhs, const bool& rhs);
1292  AFAPI array operator&(const array& lhs, const cdouble& rhs);
1293  AFAPI array operator&(const array& lhs, const cfloat& rhs);
1294  AFAPI array operator&(const array& lhs, const char& rhs);
1295  AFAPI array operator&(const array& lhs, const double& rhs);
1296  AFAPI array operator&(const array& lhs, const float& rhs);
1297  AFAPI array operator&(const array& lhs, const int& rhs);
1298  AFAPI array operator&(const array& lhs, const long long& rhs);
1299  AFAPI array operator&(const array& lhs, const long& rhs);
1300  AFAPI array operator&(const array& lhs, const short& rhs);
1301  AFAPI array operator&(const array& lhs, const unsigned char& rhs);
1302  AFAPI array operator&(const array& lhs, const unsigned long long& rhs);
1303  AFAPI array operator&(const array& lhs, const unsigned long& rhs);
1304  AFAPI array operator&(const array& lhs, const unsigned short& rhs);
1305  AFAPI array operator&(const array& lhs, const unsigned& rhs);
1306  AFAPI array operator&(const bool& lhs, const array& rhs);
1307  AFAPI array operator&(const cdouble& lhs, const array& rhs);
1308  AFAPI array operator&(const cfloat& lhs, const array& rhs);
1309  AFAPI array operator&(const char& lhs, const array& rhs);
1310  AFAPI array operator&(const double& lhs, const array& rhs);
1311  AFAPI array operator&(const float& lhs, const array& rhs);
1312  AFAPI array operator&(const int& lhs, const array& rhs);
1313  AFAPI array operator&(const long long& lhs, const array& rhs);
1314  AFAPI array operator&(const long& lhs, const array& rhs);
1315  AFAPI array operator&(const short& lhs, const array& rhs);
1316  AFAPI array operator&(const unsigned char& lhs, const array& rhs);
1317  AFAPI array operator&(const unsigned long long& lhs, const array& rhs);
1318  AFAPI array operator&(const unsigned long& lhs, const array& rhs);
1319  AFAPI array operator&(const unsigned short& lhs, const array& rhs);
1320  AFAPI array operator&(const unsigned& lhs, const array& rhs);
1322 
1333  AFAPI array operator&&(const array& lhs, const array& rhs);
1334  AFAPI array operator&&(const array& lhs, const bool& rhs);
1335  AFAPI array operator&&(const array& lhs, const cdouble& rhs);
1336  AFAPI array operator&&(const array& lhs, const cfloat& rhs);
1337  AFAPI array operator&&(const array& lhs, const char& rhs);
1338  AFAPI array operator&&(const array& lhs, const double& rhs);
1339  AFAPI array operator&&(const array& lhs, const float& rhs);
1340  AFAPI array operator&&(const array& lhs, const int& rhs);
1341  AFAPI array operator&&(const array& lhs, const long long& rhs);
1342  AFAPI array operator&&(const array& lhs, const long& rhs);
1343  AFAPI array operator&&(const array& lhs, const short& rhs);
1344  AFAPI array operator&&(const array& lhs, const unsigned char& rhs);
1345  AFAPI array operator&&(const array& lhs, const unsigned long long& rhs);
1346  AFAPI array operator&&(const array& lhs, const unsigned long& rhs);
1347  AFAPI array operator&&(const array& lhs, const unsigned short& rhs);
1348  AFAPI array operator&&(const array& lhs, const unsigned& rhs);
1349  AFAPI array operator&&(const bool& lhs, const array& rhs);
1350  AFAPI array operator&&(const cdouble& lhs, const array& rhs);
1351  AFAPI array operator&&(const cfloat& lhs, const array& rhs);
1352  AFAPI array operator&&(const char& lhs, const array& rhs);
1353  AFAPI array operator&&(const double& lhs, const array& rhs);
1354  AFAPI array operator&&(const float& lhs, const array& rhs);
1355  AFAPI array operator&&(const int& lhs, const array& rhs);
1356  AFAPI array operator&&(const long long& lhs, const array& rhs);
1357  AFAPI array operator&&(const long& lhs, const array& rhs);
1358  AFAPI array operator&&(const short& lhs, const array& rhs);
1359  AFAPI array operator&&(const unsigned char& lhs, const array& rhs);
1360  AFAPI array operator&&(const unsigned long long& lhs, const array& rhs);
1361  AFAPI array operator&&(const unsigned long& lhs, const array& rhs);
1362  AFAPI array operator&&(const unsigned short& lhs, const array& rhs);
1363  AFAPI array operator&&(const unsigned& lhs, const array& rhs);
1365 
1366 
1368 
1372  inline array &eval(array &a) { a.eval(); return a; }
1373 
1374 #if AF_API_VERSION >= 34
1375  AFAPI void eval(int num, array **arrays);
1379 #endif
1380 
1381  inline void eval(array &a, array &b)
1382  {
1383 #if AF_API_VERSION >= 34
1384  array *arrays[] = {&a, &b};
1385  return eval(2, arrays);
1386 #else
1387  eval(a); b.eval();
1388 #endif
1389  }
1390 
1391  inline void eval(array &a, array &b, array &c)
1392  {
1393 #if AF_API_VERSION >= 34
1394  array *arrays[] = {&a, &b, &c};
1395  return eval(3, arrays);
1396 #else
1397  eval(a, b); c.eval();
1398 #endif
1399  }
1400 
1401  inline void eval(array &a, array &b, array &c, array &d)
1402  {
1403 #if AF_API_VERSION >= 34
1404  array *arrays[] = {&a, &b, &c, &d};
1405  return eval(4, arrays);
1406 #else
1407  eval(a, b, c); d.eval();
1408 #endif
1409 
1410  }
1411 
1412  inline void eval(array &a, array &b, array &c, array &d, array &e)
1413  {
1414 #if AF_API_VERSION >= 34
1415  array *arrays[] = {&a, &b, &c, &d, &e};
1416  return eval(5, arrays);
1417 #else
1418  eval(a, b, c, d); e.eval();
1419 #endif
1420  }
1421 
1422  inline void eval(array &a, array &b, array &c, array &d, array &e, array &f)
1423  {
1424 #if AF_API_VERSION >= 34
1425  array *arrays[] = {&a, &b, &c, &d, &e, &f};
1426  return eval(6, arrays);
1427 #else
1428  eval(a, b, c, d, e); f.eval();
1429 #endif
1430  }
1431 
1432 #if AF_API_VERSION >= 37
1433 
1435 
1439  inline const array &eval(const array &a) { a.eval(); return a; }
1440 
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);
1446  }
1447 
1448 #else
1449 
1450  inline void eval(const array &a, const array &b)
1451  {
1452  const array *arrays[] = {&a, &b};
1453  return eval(2, const_cast<array **>(arrays));
1454  }
1455 
1456  inline void eval(const array &a, const array &b, const array &c)
1457  {
1458  const array *arrays[] = {&a, &b, &c};
1459  return eval(3, const_cast<array **>(arrays));
1460  }
1461 
1462  inline void eval(const array &a, const array &b, const array &c,
1463  const array &d)
1464  {
1465  const array *arrays[] = {&a, &b, &c, &d};
1466  return eval(4, const_cast<array **>(arrays));
1467  }
1468 
1469  inline void eval(const array &a, const array &b, const array &c,
1470  const array &d, const array &e)
1471  {
1472  const array *arrays[] = {&a, &b, &c, &d, &e};
1473  return eval(5, const_cast<array **>(arrays));
1474  }
1475 
1476  inline void eval(const array &a, const array &b, const array &c,
1477  const array &d, const array &e, const array &f)
1478  {
1479  const array *arrays[] = {&a, &b, &c, &d, &e, &f};
1480  return eval(6, const_cast<array **>(arrays));
1481  }
1482 #endif // AF_COMPILER_CXX_VARIADIC_TEMPLATES
1483 #endif
1484 
1485 #if AF_API_VERSION >= 34
1486  AFAPI void setManualEvalFlag(bool flag);
1490 #endif
1491 
1492 #if AF_API_VERSION >= 34
1493  AFAPI bool getManualEvalFlag();
1495 #endif
1496 
1501 }
1502 #endif
1503 
1504 #ifdef __cplusplus
1505 extern "C" {
1506 #endif
1507 
1526  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);
1527 
1538  AFAPI af_err af_create_handle(af_array *arr, const unsigned ndims, const dim_t * const dims, const af_dtype type);
1539 
1550  AFAPI af_err af_copy_array(af_array *arr, const af_array in);
1551 
1555  AFAPI af_err af_write_array(af_array arr, const void *data, const size_t bytes, af_source src);
1556 
1562  AFAPI af_err af_get_data_ptr(void *data, const af_array arr);
1563 
1570 
1574  AFAPI af_err af_retain_array(af_array *out, const af_array in);
1575 
1576 #if AF_API_VERSION >= 31
1577 
1583  AFAPI af_err af_get_data_ref_count(int *use_count, const af_array in);
1584 #endif
1585 
1586 
1591 
1597 #if AF_API_VERSION >= 34
1598 
1601  AFAPI af_err af_eval_multiple(const int num, af_array *arrays);
1602 #endif
1603 
1604 #if AF_API_VERSION >= 34
1605 
1609 #endif
1610 
1611 #if AF_API_VERSION >= 34
1612 
1615  AFAPI af_err af_get_manual_eval_flag(bool *flag);
1616 #endif
1617 
1633  AFAPI af_err af_get_elements(dim_t *elems, const af_array arr);
1634 
1643  AFAPI af_err af_get_type(af_dtype *type, const af_array arr);
1644 
1656  AFAPI af_err af_get_dims(dim_t *d0, dim_t *d1, dim_t *d2, dim_t *d3,
1657  const af_array arr);
1658 
1667  AFAPI af_err af_get_numdims(unsigned *result, const af_array arr);
1668 
1677  AFAPI af_err af_is_empty (bool *result, const af_array arr);
1678 
1687  AFAPI af_err af_is_scalar (bool *result, const af_array arr);
1688 
1697  AFAPI af_err af_is_row (bool *result, const af_array arr);
1698 
1707  AFAPI af_err af_is_column (bool *result, const af_array arr);
1708 
1719  AFAPI af_err af_is_vector (bool *result, const af_array arr);
1720 
1729  AFAPI af_err af_is_complex (bool *result, const af_array arr);
1730 
1741  AFAPI af_err af_is_real (bool *result, const af_array arr);
1742 
1751  AFAPI af_err af_is_double (bool *result, const af_array arr);
1752 
1761  AFAPI af_err af_is_single (bool *result, const af_array arr);
1762 
1763 #if AF_API_VERSION >= 37
1764 
1772  AFAPI af_err af_is_half(bool *result, const af_array arr);
1773 #endif
1774 
1783  AFAPI af_err af_is_realfloating (bool *result, const af_array arr);
1784 
1796  AFAPI af_err af_is_floating (bool *result, const af_array arr);
1797 
1806  AFAPI af_err af_is_integer (bool *result, const af_array arr);
1807 
1816  AFAPI af_err af_is_bool (bool *result, const af_array arr);
1817 
1818 #if AF_API_VERSION >= 34
1819 
1827  AFAPI af_err af_is_sparse (bool *result, const af_array arr);
1828 #endif
1829 
1830 #if AF_API_VERSION >= 35
1831 
1838  AFAPI af_err af_get_scalar(void* output_value, const af_array arr);
1839 #endif
1840 
1845 #ifdef __cplusplus
1846 }
1847 #endif
af_is_half
AFAPI af_err af_is_half(bool *result, const af_array arr)
Check if an array is 16 bit floating point type.
af_get_data_ref_count
AFAPI af_err af_get_data_ref_count(int *use_count, const af_array in)
af::dim4
Generic object that represents size and shape.
Definition: dim4.hpp:32
af::operator&
AFAPI array operator&(const array &lhs, const array &rhs)
Performs an bitwise AND operation on two arrays or an array and a value.
af::getManualEvalFlag
AFAPI bool getManualEvalFlag()
Get the manual eval flag.
af_set_manual_eval_flag
AFAPI af_err af_set_manual_eval_flag(bool flag)
Turn the manual eval flag on or off.
af_source
af_source
Definition: defines.h:232
traits.hpp
BIN_OP
#define BIN_OP(OP)
Definition: array.h:1082
af_get_manual_eval_flag
AFAPI af_err af_get_manual_eval_flag(bool *flag)
Get the manual eval flag.
af_is_column
AFAPI af_err af_is_column(bool *result, const af_array arr)
Check if an array is a column vector.
util.h
dim_t
long long dim_t
Definition: defines.h:56
af_is_empty
AFAPI af_err af_is_empty(bool *result, const af_array arr)
Check if an array is empty.
af::array::eval
void eval() const
Evaluate any JIT expressions to generate data for the array.
af::cfloat
af::af_cfloat cfloat
Definition: complex.h:51
af_is_floating
AFAPI af_err af_is_floating(bool *result, const af_array arr)
Check if an array is floating precision type.
index.h
AFAPI
#define AFAPI
Definition: defines.h:38
af::array
A multi dimensional data container.
Definition: array.h:35
afHost
@ afHost
Host pointer.
Definition: defines.h:234
af_get_type
AFAPI af_err af_get_type(af_dtype *type, const af_array arr)
Gets the type of an array.
af
Definition: algorithm.h:14
af_eval_multiple
AFAPI af_err af_eval_multiple(const int num, af_array *arrays)
Evaluate multiple arrays together.
af::setManualEvalFlag
AFAPI void setManualEvalFlag(bool flag)
Turn the manual eval flag on or off.
af_create_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.
af_index_t
Struct used to index an af_array.
Definition: index.h:22
af_is_single
AFAPI af_err af_is_single(bool *result, const af_array arr)
Check if an array is single precision type.
af_get_elements
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.
af_create_handle
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.
af::operator-
AFAPI array operator-(const array &lhs, const array &rhs)
Subtracts two arrays or an array and a value.
af_array
void * af_array
Definition: defines.h:240
af_is_real
AFAPI af_err af_is_real(bool *result, const af_array arr)
Check if an array is real type.
af_is_realfloating
AFAPI af_err af_is_realfloating(bool *result, const af_array arr)
Check if an array is real floating point type.
af_is_complex
AFAPI af_err af_is_complex(bool *result, const af_array arr)
Check if an array is complex type.
af_is_scalar
AFAPI af_err af_is_scalar(bool *result, const af_array arr)
Check if an array is scalar, ie.
af::index
Wrapper for af_index.
Definition: index.h:52
af_dtype
af_dtype
Definition: defines.h:210
af_is_row
AFAPI af_err af_is_row(bool *result, const af_array arr)
Check if an array is row vector.
af_release_array
AFAPI af_err af_release_array(af_array arr)
Reduce the reference count of the af_array.
af_get_scalar
AFAPI af_err af_get_scalar(void *output_value, const af_array arr)
Get first element from an array.
af_retain_array
AFAPI af_err af_retain_array(af_array *out, const af_array in)
Increments an af_array reference count.
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_write_array
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.
af_is_integer
AFAPI af_err af_is_integer(bool *result, const af_array arr)
Check if an array is integer type.
af_get_numdims
AFAPI af_err af_get_numdims(unsigned *result, const af_array arr)
Gets the number of dimensions of an array.
ASSIGN
#define ASSIGN(OP)
Definition: array.h:929
af_is_vector
AFAPI af_err af_is_vector(bool *result, const af_array arr)
Check if an array is a vector.
af::span
AFAPI seq span
A special value representing the entire axis of an af::array.
seq.h
af_copy_array
AFAPI af_err af_copy_array(af_array *arr, const af_array in)
af_is_bool
AFAPI af_err af_is_bool(bool *result, const af_array arr)
Check if an array is bool type.
af_get_dims
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.
af::array::array_proxy
Intermediate data class.
Definition: array.h:53
af::copy
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.
af::eval
array & eval(array &a)
Evaluate an expression (nonblocking).
Definition: array.h:1379
af_eval
AFAPI af_err af_eval(af_array in)
Evaluate any expressions in the Array.
af_get_data_ptr
AFAPI af_err af_get_data_ptr(void *data, const af_array arr)
Copy data from an af_array to a C pointer.
af_err
af_err
Definition: defines.h:71
af::operator&&
AFAPI array operator&&(const array &lhs, const array &rhs)
Performs a logical AND operation on two arrays or an array and a value.
defines.h
af::cdouble
af::af_cdouble cdouble
Definition: complex.h:52
f32
@ f32
32-bit floating point values
Definition: defines.h:211
af_is_double
AFAPI af_err af_is_double(bool *result, const af_array arr)
Check if an array is double precision type.
af_is_sparse
AFAPI af_err af_is_sparse(bool *result, const af_array arr)
Check if an array is sparse.