array.h (2020-07-07 17:43:34 +0530, (build 218dd2c99))
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  * https://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 
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 
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 
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 
173  array();
174 
175 #if AF_API_VERSION >= 37
176 #if AF_COMPILER_CXX_RVALUE_REFERENCES
177 
185  array(array &&other) AF_NOEXCEPT;
186 
197  array &operator=(array &&other) AF_NOEXCEPT;
198 #endif
199 #endif
200 
207  explicit
208  array(const af_array handle);
209 
215  array(const array& in);
216 
239  array(dim_t dim0, dtype ty = f32);
240 
264  array(dim_t dim0, dim_t dim1, dtype ty = f32);
265 
290  array(dim_t dim0, dim_t dim1, dim_t dim2, dtype ty = f32);
291 
317  array(dim_t dim0, dim_t dim1, dim_t dim2, dim_t dim3, dtype ty = f32);
318 
344  explicit
345  array(const dim4& dims, dtype ty = f32);
346 
371  template<typename T>
372  array(dim_t dim0,
373  const T *pointer, af::source src=afHost);
374 
375 
394  template<typename T>
395  array(dim_t dim0, dim_t dim1,
396  const T *pointer, af::source src=afHost);
397 
398 
420  template<typename T>
421  array(dim_t dim0, dim_t dim1, dim_t dim2,
422  const T *pointer, af::source src=afHost);
423 
424 
447  template<typename T>
448  array(dim_t dim0, dim_t dim1, dim_t dim2, dim_t dim3,
449  const T *pointer, af::source src=afHost);
450 
484  template<typename T>
485  explicit
486  array(const dim4& dims,
487  const T *pointer, af::source src=afHost);
488 
515  array(const array& input, const dim4& dims);
516 
547  array( const array& input,
548  const dim_t dim0, const dim_t dim1 = 1,
549  const dim_t dim2 = 1, const dim_t dim3 = 1);
550 
554  af_array get();
555 
559  af_array get() const;
560 
564  dim_t elements() const;
565 
569  template<typename T> T* host() const;
570 
574  void host(void *ptr) const;
575 
579  template<typename T> void write(const T *ptr, const size_t bytes, af::source src = afHost);
580 
584  dtype type() const;
585 
589  dim4 dims() const;
590 
594  dim_t dims(unsigned dim) const;
595 
599  unsigned numdims() const;
600 
604  size_t bytes() const;
605 
610  size_t allocated() const;
611 
615  array copy() const;
616 
620  bool isempty() const;
621 
625  bool isscalar() const;
626 
630  bool isvector() const;
631 
635  bool isrow() const;
636 
640  bool iscolumn() const;
641 
645  bool iscomplex() const;
646 
650  inline bool isreal() const { return !iscomplex(); }
651 
655  bool isdouble() const;
656 
660  bool issingle() const;
661 
662 #if AF_API_VERSION >= 37
663 
666  bool ishalf() const;
667 #endif
668 
672  bool isrealfloating() const;
673 
677  bool isfloating() const;
678 
682  bool isinteger() const;
683 
687  bool isbool() const;
688 
689 #if AF_API_VERSION >= 34
690 
693  bool issparse() const;
694 #endif
695 
699  void eval() const;
700 
706  template<typename T> T scalar() const;
707 
716  template<typename T> T* device() const;
717 
718  // INDEXING
719  // Single arguments
720 
738  array::array_proxy operator()(const index &s0);
739 
745  const array::array_proxy operator()(const index &s0) const;
746 
747 
765  array::array_proxy operator()(const index &s0,
766  const index &s1,
767  const index &s2 = span,
768  const index &s3 = span);
769 
775  const array::array_proxy operator()(const index &s0,
776  const index &s1,
777  const index &s2 = span,
778  const index &s3 = span) const;
779 
780 
792  array::array_proxy row(int index);
793  const array::array_proxy row(int index) const;
794 
804  array::array_proxy rows(int first, int last);
805  const array::array_proxy rows(int first, int last) const;
806 
819  array::array_proxy col(int index);
820  const array::array_proxy col(int index) const;
821 
831  array::array_proxy cols(int first, int last);
832  const array::array_proxy cols(int first, int last) const;
833 
846  array::array_proxy slice(int index);
847  const array::array_proxy slice(int index) const;
848 
857  array::array_proxy slices(int first, int last);
858  const array::array_proxy slices(int first, int last) const;
859 
865  const array as(dtype type) const;
866 
867 
868  ~array();
869 
873  array T() const;
877  array H() const;
878 
879 #define ASSIGN_(OP2) \
880  array& OP2(const array &val); \
881  array& OP2(const double &val); \
882  array& OP2(const cdouble &val); \
883  array& OP2(const cfloat &val); \
884  array& OP2(const float &val); \
885  array& OP2(const int &val); \
886  array& OP2(const unsigned &val); \
887  array& OP2(const bool &val); \
888  array& OP2(const char &val); \
889  array& OP2(const unsigned char &val); \
890  array& OP2(const long &val); \
891  array& OP2(const unsigned long &val); \
892  array& OP2(const long long &val); \
893  array& OP2(const unsigned long long &val);
894 
895 
896 #if AF_API_VERSION >= 32
897 #define ASSIGN(OP) \
898  ASSIGN_(OP) \
899  array& OP(const short &val); \
900  array& OP(const unsigned short &val);
901 
902 #else
903 #define ASSIGN(OP) ASSIGN_(OP)
904 #endif
905 
906 
916  ASSIGN(operator=)
918 
928  ASSIGN(operator+=)
930 
940  ASSIGN(operator-=)
942 
952  ASSIGN(operator*=)
954 
965  ASSIGN(operator/=)
967 
968 
969 #undef ASSIGN
970 #undef ASSIGN_
971 
977  array operator -() const;
978 
984  array operator !() const;
985 
990  int nonzeros() const;
991 
992 
998  void lock() const;
999 
1000 
1001 #if AF_API_VERSION >= 34
1002  bool isLocked() const;
1008 #endif
1009 
1010 
1016  void unlock() const;
1017  };
1018  // end of class array
1019 
1020 #define BIN_OP_(OP) \
1021  AFAPI array OP (const array& lhs, const array& rhs); \
1022  AFAPI array OP (const bool& lhs, const array& rhs); \
1023  AFAPI array OP (const int& lhs, const array& rhs); \
1024  AFAPI array OP (const unsigned& lhs, const array& rhs); \
1025  AFAPI array OP (const char& lhs, const array& rhs); \
1026  AFAPI array OP (const unsigned char& lhs, const array& rhs); \
1027  AFAPI array OP (const long& lhs, const array& rhs); \
1028  AFAPI array OP (const unsigned long& lhs, const array& rhs); \
1029  AFAPI array OP (const long long& lhs, const array& rhs); \
1030  AFAPI array OP (const unsigned long long& lhs, const array& rhs); \
1031  AFAPI array OP (const double& lhs, const array& rhs); \
1032  AFAPI array OP (const float& lhs, const array& rhs); \
1033  AFAPI array OP (const cfloat& lhs, const array& rhs); \
1034  AFAPI array OP (const cdouble& lhs, const array& rhs); \
1035  AFAPI array OP (const array& lhs, const bool& rhs); \
1036  AFAPI array OP (const array& lhs, const int& rhs); \
1037  AFAPI array OP (const array& lhs, const unsigned& rhs); \
1038  AFAPI array OP (const array& lhs, const char& rhs); \
1039  AFAPI array OP (const array& lhs, const unsigned char& rhs); \
1040  AFAPI array OP (const array& lhs, const long& rhs); \
1041  AFAPI array OP (const array& lhs, const unsigned long& rhs); \
1042  AFAPI array OP (const array& lhs, const long long& rhs); \
1043  AFAPI array OP (const array& lhs, const unsigned long long& rhs); \
1044  AFAPI array OP (const array& lhs, const double& rhs); \
1045  AFAPI array OP (const array& lhs, const float& rhs); \
1046  AFAPI array OP (const array& lhs, const cfloat& rhs); \
1047  AFAPI array OP (const array& lhs, const cdouble& rhs);
1048 
1049 #if AF_API_VERSION >= 32
1050 #define BIN_OP(OP) \
1051  BIN_OP_(OP) \
1052  AFAPI array OP (const short& lhs, const array& rhs); \
1053  AFAPI array OP (const unsigned short& lhs, const array& rhs); \
1054  AFAPI array OP (const array& lhs, const short& rhs); \
1055  AFAPI array OP (const array& lhs, const unsigned short& rhs);
1056 
1057 #else
1058 #define BIN_OP(OP) BIN_OP_(OP)
1059 #endif
1060 
1069  BIN_OP(operator+ )
1071 
1080  BIN_OP(operator- )
1082 
1091  BIN_OP(operator* )
1093 
1102  BIN_OP(operator/ )
1104 
1113  BIN_OP(operator==)
1115 
1125  BIN_OP(operator!=)
1127 
1137  BIN_OP(operator< )
1139 
1148  BIN_OP(operator<=)
1150 
1160  BIN_OP(operator> )
1162 
1172  BIN_OP(operator>=)
1174 
1185  BIN_OP(operator||)
1187 
1197  BIN_OP(operator% )
1199 
1210  BIN_OP(operator| )
1212 
1223  BIN_OP(operator^ )
1225 
1236  BIN_OP(operator<<)
1238 
1249  BIN_OP(operator>>)
1251 
1252 #undef BIN_OP
1253 #undef BIN_OP_
1254 
1265  AFAPI array operator&(const array& lhs, const array& rhs);
1266  AFAPI array operator&(const array& lhs, const bool& rhs);
1267  AFAPI array operator&(const array& lhs, const cdouble& rhs);
1268  AFAPI array operator&(const array& lhs, const cfloat& rhs);
1269  AFAPI array operator&(const array& lhs, const char& rhs);
1270  AFAPI array operator&(const array& lhs, const double& rhs);
1271  AFAPI array operator&(const array& lhs, const float& rhs);
1272  AFAPI array operator&(const array& lhs, const int& rhs);
1273  AFAPI array operator&(const array& lhs, const long long& rhs);
1274  AFAPI array operator&(const array& lhs, const long& rhs);
1275  AFAPI array operator&(const array& lhs, const short& rhs);
1276  AFAPI array operator&(const array& lhs, const unsigned char& rhs);
1277  AFAPI array operator&(const array& lhs, const unsigned long long& rhs);
1278  AFAPI array operator&(const array& lhs, const unsigned long& rhs);
1279  AFAPI array operator&(const array& lhs, const unsigned short& rhs);
1280  AFAPI array operator&(const array& lhs, const unsigned& rhs);
1281  AFAPI array operator&(const bool& lhs, const array& rhs);
1282  AFAPI array operator&(const cdouble& lhs, const array& rhs);
1283  AFAPI array operator&(const cfloat& lhs, const array& rhs);
1284  AFAPI array operator&(const char& lhs, const array& rhs);
1285  AFAPI array operator&(const double& lhs, const array& rhs);
1286  AFAPI array operator&(const float& lhs, const array& rhs);
1287  AFAPI array operator&(const int& lhs, const array& rhs);
1288  AFAPI array operator&(const long long& lhs, const array& rhs);
1289  AFAPI array operator&(const long& lhs, const array& rhs);
1290  AFAPI array operator&(const short& lhs, const array& rhs);
1291  AFAPI array operator&(const unsigned char& lhs, const array& rhs);
1292  AFAPI array operator&(const unsigned long long& lhs, const array& rhs);
1293  AFAPI array operator&(const unsigned long& lhs, const array& rhs);
1294  AFAPI array operator&(const unsigned short& lhs, const array& rhs);
1295  AFAPI array operator&(const unsigned& lhs, const array& rhs);
1308  AFAPI array operator&&(const array& lhs, const array& rhs);
1309  AFAPI array operator&&(const array& lhs, const bool& rhs);
1310  AFAPI array operator&&(const array& lhs, const cdouble& rhs);
1311  AFAPI array operator&&(const array& lhs, const cfloat& rhs);
1312  AFAPI array operator&&(const array& lhs, const char& rhs);
1313  AFAPI array operator&&(const array& lhs, const double& rhs);
1314  AFAPI array operator&&(const array& lhs, const float& rhs);
1315  AFAPI array operator&&(const array& lhs, const int& rhs);
1316  AFAPI array operator&&(const array& lhs, const long long& rhs);
1317  AFAPI array operator&&(const array& lhs, const long& rhs);
1318  AFAPI array operator&&(const array& lhs, const short& rhs);
1319  AFAPI array operator&&(const array& lhs, const unsigned char& rhs);
1320  AFAPI array operator&&(const array& lhs, const unsigned long long& rhs);
1321  AFAPI array operator&&(const array& lhs, const unsigned long& rhs);
1322  AFAPI array operator&&(const array& lhs, const unsigned short& rhs);
1323  AFAPI array operator&&(const array& lhs, const unsigned& rhs);
1324  AFAPI array operator&&(const bool& lhs, const array& rhs);
1325  AFAPI array operator&&(const cdouble& lhs, const array& rhs);
1326  AFAPI array operator&&(const cfloat& lhs, const array& rhs);
1327  AFAPI array operator&&(const char& lhs, const array& rhs);
1328  AFAPI array operator&&(const double& lhs, const array& rhs);
1329  AFAPI array operator&&(const float& lhs, const array& rhs);
1330  AFAPI array operator&&(const int& lhs, const array& rhs);
1331  AFAPI array operator&&(const long long& lhs, const array& rhs);
1332  AFAPI array operator&&(const long& lhs, const array& rhs);
1333  AFAPI array operator&&(const short& lhs, const array& rhs);
1334  AFAPI array operator&&(const unsigned char& lhs, const array& rhs);
1335  AFAPI array operator&&(const unsigned long long& lhs, const array& rhs);
1336  AFAPI array operator&&(const unsigned long& lhs, const array& rhs);
1337  AFAPI array operator&&(const unsigned short& lhs, const array& rhs);
1338  AFAPI array operator&&(const unsigned& lhs, const array& rhs);
1347  inline array &eval(array &a) { a.eval(); return a; }
1348 
1349 #if AF_API_VERSION >= 34
1350  AFAPI void eval(int num, array **arrays);
1354 #endif
1355 
1356  inline void eval(array &a, array &b)
1357  {
1358 #if AF_API_VERSION >= 34
1359  array *arrays[] = {&a, &b};
1360  return eval(2, arrays);
1361 #else
1362  eval(a); b.eval();
1363 #endif
1364  }
1365 
1366  inline void eval(array &a, array &b, array &c)
1367  {
1368 #if AF_API_VERSION >= 34
1369  array *arrays[] = {&a, &b, &c};
1370  return eval(3, arrays);
1371 #else
1372  eval(a, b); c.eval();
1373 #endif
1374  }
1375 
1376  inline void eval(array &a, array &b, array &c, array &d)
1377  {
1378 #if AF_API_VERSION >= 34
1379  array *arrays[] = {&a, &b, &c, &d};
1380  return eval(4, arrays);
1381 #else
1382  eval(a, b, c); d.eval();
1383 #endif
1384 
1385  }
1386 
1387  inline void eval(array &a, array &b, array &c, array &d, array &e)
1388  {
1389 #if AF_API_VERSION >= 34
1390  array *arrays[] = {&a, &b, &c, &d, &e};
1391  return eval(5, arrays);
1392 #else
1393  eval(a, b, c, d); e.eval();
1394 #endif
1395  }
1396 
1397  inline void eval(array &a, array &b, array &c, array &d, array &e, array &f)
1398  {
1399 #if AF_API_VERSION >= 34
1400  array *arrays[] = {&a, &b, &c, &d, &e, &f};
1401  return eval(6, arrays);
1402 #else
1403  eval(a, b, c, d, e); f.eval();
1404 #endif
1405  }
1406 
1407 #if AF_API_VERSION >= 37
1408 
1410  inline const array &eval(const array &a) { a.eval(); return a; }
1411 
1412 #if AF_COMPILER_CXX_VARIADIC_TEMPLATES
1413  template <typename... ARRAYS>
1414  inline void eval(ARRAYS... in) {
1415  array *arrays[] = {const_cast<array *>(&in)...};
1416  eval((int)sizeof...(in), arrays);
1417  }
1418 
1419 #else
1420 
1421  inline void eval(const array &a, const array &b)
1422  {
1423  const array *arrays[] = {&a, &b};
1424  return eval(2, const_cast<array **>(arrays));
1425  }
1426 
1427  inline void eval(const array &a, const array &b, const array &c)
1428  {
1429  const array *arrays[] = {&a, &b, &c};
1430  return eval(3, const_cast<array **>(arrays));
1431  }
1432 
1433  inline void eval(const array &a, const array &b, const array &c,
1434  const array &d)
1435  {
1436  const array *arrays[] = {&a, &b, &c, &d};
1437  return eval(4, const_cast<array **>(arrays));
1438  }
1439 
1440  inline void eval(const array &a, const array &b, const array &c,
1441  const array &d, const array &e)
1442  {
1443  const array *arrays[] = {&a, &b, &c, &d, &e};
1444  return eval(5, const_cast<array **>(arrays));
1445  }
1446 
1447  inline void eval(const array &a, const array &b, const array &c,
1448  const array &d, const array &e, const array &f)
1449  {
1450  const array *arrays[] = {&a, &b, &c, &d, &e, &f};
1451  return eval(6, const_cast<array **>(arrays));
1452  }
1453 #endif // AF_COMPILER_CXX_VARIADIC_TEMPLATES
1454 #endif
1455 
1456 #if AF_API_VERSION >= 34
1457  AFAPI void setManualEvalFlag(bool flag);
1461 #endif
1462 
1463 #if AF_API_VERSION >= 34
1464  AFAPI bool getManualEvalFlag();
1466 #endif
1473 #endif
1474 
1475 #ifdef __cplusplus
1476 extern "C" {
1477 #endif
1478 
1497  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);
1498 
1512  AFAPI af_err af_create_handle(af_array *arr, const unsigned ndims, const dim_t * const dims, const af_dtype type);
1513 
1518 
1522  AFAPI af_err af_write_array(af_array arr, const void *data, const size_t bytes, af_source src);
1523 
1529  AFAPI af_err af_get_data_ptr(void *data, const af_array arr);
1530 
1537 
1542 
1543 #if AF_API_VERSION >= 31
1544 
1547  AFAPI af_err af_get_data_ref_count(int *use_count, const af_array in);
1548 #endif
1549 
1554 
1555 #if AF_API_VERSION >= 34
1556 
1559  AFAPI af_err af_eval_multiple(const int num, af_array *arrays);
1560 #endif
1561 
1562 #if AF_API_VERSION >= 34
1563 
1567 #endif
1568 
1569 #if AF_API_VERSION >= 34
1570 
1574 #endif
1575 
1585 
1595 
1608  const af_array arr);
1609 
1618  AFAPI af_err af_get_numdims(unsigned *result, const af_array arr);
1619 
1628  AFAPI af_err af_is_empty (bool *result, const af_array arr);
1629 
1638  AFAPI af_err af_is_scalar (bool *result, const af_array arr);
1639 
1648  AFAPI af_err af_is_row (bool *result, const af_array arr);
1649 
1658  AFAPI af_err af_is_column (bool *result, const af_array arr);
1659 
1670  AFAPI af_err af_is_vector (bool *result, const af_array arr);
1671 
1680  AFAPI af_err af_is_complex (bool *result, const af_array arr);
1681 
1692  AFAPI af_err af_is_real (bool *result, const af_array arr);
1693 
1702  AFAPI af_err af_is_double (bool *result, const af_array arr);
1703 
1712  AFAPI af_err af_is_single (bool *result, const af_array arr);
1713 
1714 #if AF_API_VERSION >= 37
1715 
1723  AFAPI af_err af_is_half(bool *result, const af_array arr);
1724 #endif
1725 
1734  AFAPI af_err af_is_realfloating (bool *result, const af_array arr);
1735 
1747  AFAPI af_err af_is_floating (bool *result, const af_array arr);
1748 
1757  AFAPI af_err af_is_integer (bool *result, const af_array arr);
1758 
1767  AFAPI af_err af_is_bool (bool *result, const af_array arr);
1768 
1769 #if AF_API_VERSION >= 34
1770 
1778  AFAPI af_err af_is_sparse (bool *result, const af_array arr);
1779 #endif
1780 
1781 #if AF_API_VERSION >= 35
1782 
1789  AFAPI af_err af_get_scalar(void* output_value, const af_array arr);
1790 #endif
1791 
1796 #ifdef __cplusplus
1797 }
1798 #endif
af::dim4
Generic object that represents size and shape.
Definition: dim4.hpp:33
af_retain_array
AFAPI af_err af_retain_array(af_array *out, const af_array in)
Increments an af_array reference count.
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_source
af_source
Definition: defines.h:232
af_is_integer
AFAPI af_err af_is_integer(bool *result, const af_array arr)
Check if an array is integer type.
traits.hpp
BIN_OP
#define BIN_OP(OP)
Definition: array.h:1057
af_get_manual_eval_flag
AFAPI af_err af_get_manual_eval_flag(bool *flag)
Get the manual eval flag.
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_is_empty
AFAPI af_err af_is_empty(bool *result, const af_array arr)
Check if an array is empty.
util.h
dim_t
long long dim_t
Definition: defines.h:56
af_set_manual_eval_flag
AFAPI af_err af_set_manual_eval_flag(bool flag)
Turn the manual eval flag on or off.
af::cfloat
af::af_cfloat cfloat
Definition: complex.h:51
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.
index.h
af_is_row
AFAPI af_err af_is_row(bool *result, const af_array arr)
Check if an array is row vector.
af_is_single
AFAPI af_err af_is_single(bool *result, const af_array arr)
Check if an array is single precision type.
AFAPI
#define AFAPI
Definition: defines.h:38
af::array
A multi dimensional data container.
Definition: array.h:35
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.
afHost
@ afHost
Host pointer.
Definition: defines.h:234
af
Definition: algorithm.h:15
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_eval_multiple
AFAPI af_err af_eval_multiple(const int num, af_array *arrays)
Evaluate multiple arrays together.
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_index_t
Struct used to index an af_array.
Definition: index.h:22
af_copy_array
AFAPI af_err af_copy_array(af_array *arr, const af_array in)
Deep copy an array to another.
af::operator-
AFAPI array operator-(const array &lhs, const array &rhs)
Subtracts two arrays or an array and a value.
af::array::eval
void eval() const
Evaluate any JIT expressions to generate data for the array.
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_is_real
AFAPI af_err af_is_real(bool *result, const af_array arr)
Check if an array is real type.
af_array
void * af_array
Definition: defines.h:240
af_is_floating
AFAPI af_err af_is_floating(bool *result, const af_array arr)
Check if an array is floating precision type.
af::index
Wrapper for af_index.
Definition: index.h:52
af_is_bool
AFAPI af_err af_is_bool(bool *result, const af_array arr)
Check if an array is bool type.
af_get_numdims
AFAPI af_err af_get_numdims(unsigned *result, const af_array arr)
Gets the number of dimensions of an array.
af_dtype
af_dtype
Definition: defines.h:210
af_release_array
AFAPI af_err af_release_array(af_array arr)
Reduce the reference count of the af_array.
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_is_column
AFAPI af_err af_is_column(bool *result, const af_array arr)
Check if an array is a column vector.
af_is_vector
AFAPI af_err af_is_vector(bool *result, const af_array arr)
Check if an array is a vector.
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.
ASSIGN
#define ASSIGN(OP)
Definition: array.h:904
af::span
AFAPI seq span
A special value representing the entire axis of an af::array.
af_eval
AFAPI af_err af_eval(af_array in)
Evaluate any expressions in the Array.
seq.h
af::setManualEvalFlag
AFAPI void setManualEvalFlag(bool flag)
Turn the manual eval flag on or off.
af_get_scalar
AFAPI af_err af_get_scalar(void *output_value, const af_array arr)
Get first element from an array.
af::array::array_proxy
Intermediate data class.
Definition: array.h:54
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::af_cdouble
Definition: complex.h:39
af::array::array
array(const af_array handle)
Creates an array from an af_array handle.
af::eval
array & eval(array &a)
Evaluate an expression (nonblocking).
Definition: array.h:1354
af::af_cfloat
Definition: complex.h:31
af_is_scalar
AFAPI af_err af_is_scalar(bool *result, const af_array arr)
Check if an array is scalar, ie.
af_get_data_ref_count
AFAPI af_err af_get_data_ref_count(int *use_count, const af_array in)
Get the reference count of af_array.
af_get_type
AFAPI af_err af_get_type(af_dtype *type, const af_array arr)
Gets the type of an array.
af_err
af_err
Definition: defines.h:71
af::getManualEvalFlag
AFAPI bool getManualEvalFlag()
Get the manual eval flag.
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.
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.
defines.h
af::cdouble
af::af_cdouble cdouble
Definition: complex.h:52
af::array::operator()
array::array_proxy operator()(const index &s0)
This operator returns a reference of the original array at a given coordinate.
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.
f32
@ f32
32-bit floating point values
Definition: defines.h:211
af_is_complex
AFAPI af_err af_is_complex(bool *result, const af_array arr)
Check if an array is complex type.