My Project
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/defines.h>
12 #include <af/seq.h>
13 #include <af/util.h>
14 #include <af/index.h>
15 
16 #ifdef __cplusplus
17 #include <af/traits.hpp>
18 namespace af
19 {
20 
21  class dim4;
22 
26  class AFAPI array {
27  af_array arr;
28 
29 
30  public:
37  void set(af_array tmp);
38 
45  {
46  struct array_proxy_impl; //forward declaration
47  array_proxy_impl *impl; // implementation
48 
49  public:
50  array_proxy(array& par, af_index_t *ssss, bool linear = false);
51  array_proxy(const array_proxy &other);
52 #if __cplusplus > 199711L
53  array_proxy(array_proxy &&other);
54  array_proxy & operator=(array_proxy &&other);
55 #endif
56  ~array_proxy();
57 
58  // Implicit conversion operators
59  operator array() const;
60  operator array();
61 
62 #define ASSIGN(OP) \
63  array_proxy& operator OP(const array_proxy &a); \
64  array_proxy& operator OP(const array &a); \
65  array_proxy& operator OP(const double &a); \
66  array_proxy& operator OP(const cdouble &a); \
67  array_proxy& operator OP(const cfloat &a); \
68  array_proxy& operator OP(const float &a); \
69  array_proxy& operator OP(const int &a); \
70  array_proxy& operator OP(const unsigned &a); \
71  array_proxy& operator OP(const bool &a); \
72  array_proxy& operator OP(const char &a); \
73  array_proxy& operator OP(const unsigned char &a); \
74  array_proxy& operator OP(const long &a); \
75  array_proxy& operator OP(const unsigned long &a); \
76  array_proxy& operator OP(const long long &a); \
77  array_proxy& operator OP(const unsigned long long &a);
78 
79  ASSIGN(=)
80  ASSIGN(+=)
81  ASSIGN(-=)
82  ASSIGN(*=)
83  ASSIGN(/=)
84 #undef ASSIGN
85 
86 #if AF_API_VERSION >= 32
87 #define ASSIGN(OP) \
88  array_proxy& operator OP(const short &a); \
89  array_proxy& operator OP(const unsigned short &a);
90 
91  ASSIGN(=)
92  ASSIGN(+=)
93  ASSIGN(-=)
94  ASSIGN(*=)
95  ASSIGN(/=)
96 #undef ASSIGN
97 #endif
98 
99  // af::array member functions. same behavior as those below
100  af_array get();
101  af_array get() const;
102  dim_t elements() const;
103  template<typename T> T* host() const;
104  void host(void *ptr) const;
105  dtype type() const;
106  dim4 dims() const;
107  dim_t dims(unsigned dim) const;
108  unsigned numdims() const;
109  size_t bytes() const;
110  size_t allocated() const;
111  array copy() const;
112  bool isempty() const;
113  bool isscalar() const;
114  bool isvector() const;
115  bool isrow() const;
116  bool iscolumn() const;
117  bool iscomplex() const;
118  inline bool isreal() const { return !iscomplex(); }
119  bool isdouble() const;
120  bool issingle() const;
121  bool isrealfloating() const;
122  bool isfloating() const;
123  bool isinteger() const;
124  bool isbool() const;
125 #if AF_API_VERSION >= 34
126  bool issparse() const;
127 #endif
128  void eval() const;
129  array as(dtype type) const;
130  array T() const;
131  array H() const;
132  template<typename T> T scalar() const;
133  template<typename T> T* device() const;
134  void unlock() const;
135 #if AF_API_VERSION >= 31
136  void lock() const;
137 #endif
138 
139 #if AF_API_VERSION >= 34
140  bool isLocked() const;
141 #endif
142 
143  array::array_proxy row(int index);
144  const array::array_proxy row(int index) const;
145 
146  array::array_proxy rows(int first, int last);
147  const array::array_proxy rows(int first, int last) const;
148 
149  array::array_proxy col(int index);
150  const array::array_proxy col(int index) const;
151  array::array_proxy cols(int first, int last);
152  const array::array_proxy cols(int first, int last) const;
153 
154  array::array_proxy slice(int index);
155  const array::array_proxy slice(int index) const;
156 
157  array::array_proxy slices(int first, int last);
158  const array::array_proxy slices(int first, int last) const;
159  };
160 
161  //array(af_array in, const array *par, af_index_t seqs[4]);
173  array();
174 
179  explicit
180  array(const af_array handle);
181 
187  array(const array& in);
188 
211  array(dim_t dim0, dtype ty = f32);
212 
236  array(dim_t dim0, dim_t dim1, dtype ty = f32);
237 
262  array(dim_t dim0, dim_t dim1, dim_t dim2, dtype ty = f32);
263 
289  array(dim_t dim0, dim_t dim1, dim_t dim2, dim_t dim3, dtype ty = f32);
290 
316  explicit
317  array(const dim4& dims, dtype ty = f32);
318 
343  template<typename T>
344  array(dim_t dim0,
345  const T *pointer, af::source src=afHost);
346 
347 
366  template<typename T>
367  array(dim_t dim0, dim_t dim1,
368  const T *pointer, af::source src=afHost);
369 
370 
392  template<typename T>
393  array(dim_t dim0, dim_t dim1, dim_t dim2,
394  const T *pointer, af::source src=afHost);
395 
396 
419  template<typename T>
420  array(dim_t dim0, dim_t dim1, dim_t dim2, dim_t dim3,
421  const T *pointer, af::source src=afHost);
422 
456  template<typename T>
457  explicit
458  array(const dim4& dims,
459  const T *pointer, af::source src=afHost);
460 
488  array(const array& input, const dim4& dims);
489 
521  array( const array& input,
522  const dim_t dim0, const dim_t dim1 = 1,
523  const dim_t dim2 = 1, const dim_t dim3 = 1);
524 
537  af_array get();
538 
542  af_array get() const;
543 
547  dim_t elements() const;
548 
552  template<typename T> T* host() const;
553 
557  void host(void *ptr) const;
558 
562  template<typename T> void write(const T *ptr, const size_t bytes, af::source src = afHost);
563 
567  dtype type() const;
568 
572  dim4 dims() const;
573 
577  dim_t dims(unsigned dim) const;
578 
582  unsigned numdims() const;
583 
587  size_t bytes() const;
588 
593  size_t allocated() const;
594 
598  array copy() const;
599 
603  bool isempty() const;
604 
608  bool isscalar() const;
609 
613  bool isvector() const;
614 
618  bool isrow() const;
619 
623  bool iscolumn() const;
624 
628  bool iscomplex() const;
629 
633  inline bool isreal() const { return !iscomplex(); }
634 
638  bool isdouble() const;
639 
643  bool issingle() const;
644 
648  bool isrealfloating() const;
649 
653  bool isfloating() const;
654 
658  bool isinteger() const;
659 
663  bool isbool() const;
664 
665 #if AF_API_VERSION >= 34
666 
669  bool issparse() const;
670 #endif
671 
675  void eval() const;
676 
682  template<typename T> T scalar() const;
683 
700  template<typename T> T* device() const;
705  // INDEXING
706  // Single arguments
707 
725  array::array_proxy operator()(const index &s0);
726 
732  const array::array_proxy operator()(const index &s0) const;
733 
734 
752  array::array_proxy operator()(const index &s0,
753  const index &s1,
754  const index &s2 = span,
755  const index &s3 = span);
756 
762  const array::array_proxy operator()(const index &s0,
763  const index &s1,
764  const index &s2 = span,
765  const index &s3 = span) const;
766 
767 
779  array::array_proxy row(int index);
780  const array::array_proxy row(int index) const;
781 
791  array::array_proxy rows(int first, int last);
792  const array::array_proxy rows(int first, int last) const;
793 
806  array::array_proxy col(int index);
807  const array::array_proxy col(int index) const;
808 
818  array::array_proxy cols(int first, int last);
819  const array::array_proxy cols(int first, int last) const;
820 
833  array::array_proxy slice(int index);
834  const array::array_proxy slice(int index) const;
835 
844  array::array_proxy slices(int first, int last);
845  const array::array_proxy slices(int first, int last) const;
846 
853  const array as(dtype type) const;
854 
855 
856  ~array();
857 
862  array T() const;
867  array H() const;
868 
869 #define ASSIGN_(OP2) \
870  array& OP2(const array &val); \
871  array& OP2(const double &val); \
872  array& OP2(const cdouble &val); \
873  array& OP2(const cfloat &val); \
874  array& OP2(const float &val); \
875  array& OP2(const int &val); \
876  array& OP2(const unsigned &val); \
877  array& OP2(const bool &val); \
878  array& OP2(const char &val); \
879  array& OP2(const unsigned char &val); \
880  array& OP2(const long &val); \
881  array& OP2(const unsigned long &val); \
882  array& OP2(const long long &val); \
883  array& OP2(const unsigned long long &val);
884 
885 
886 #if AF_API_VERSION >= 32
887 #define ASSIGN(OP) \
888  ASSIGN_(OP) \
889  array& OP(const short &val); \
890  array& OP(const unsigned short &val);
891 
892 #else
893 #define ASSIGN(OP) ASSIGN_(OP)
894 #endif
895 
896 
906  ASSIGN(operator=)
908 
918  ASSIGN(operator+=)
920 
930  ASSIGN(operator-=)
932 
942  ASSIGN(operator*=)
944 
955  ASSIGN(operator/=)
957 
958 
959 #undef ASSIGN
960 #undef ASSIGN_
961 
967  array operator -() const;
968 
974  array operator !() const;
975 
980  int nonzeros() const;
981 
982 
988  void lock() const;
989 
990 
991 #if AF_API_VERSION >= 34
992  bool isLocked() const;
998 #endif
999 
1000 
1006  void unlock() const;
1007  };
1008  // end of class array
1009 
1010 #define BIN_OP_(OP) \
1011  AFAPI array OP (const array& lhs, const array& rhs); \
1012  AFAPI array OP (const bool& lhs, const array& rhs); \
1013  AFAPI array OP (const int& lhs, const array& rhs); \
1014  AFAPI array OP (const unsigned& lhs, const array& rhs); \
1015  AFAPI array OP (const char& lhs, const array& rhs); \
1016  AFAPI array OP (const unsigned char& lhs, const array& rhs); \
1017  AFAPI array OP (const long& lhs, const array& rhs); \
1018  AFAPI array OP (const unsigned long& lhs, const array& rhs); \
1019  AFAPI array OP (const long long& lhs, const array& rhs); \
1020  AFAPI array OP (const unsigned long long& lhs, const array& rhs); \
1021  AFAPI array OP (const double& lhs, const array& rhs); \
1022  AFAPI array OP (const float& lhs, const array& rhs); \
1023  AFAPI array OP (const cfloat& lhs, const array& rhs); \
1024  AFAPI array OP (const cdouble& lhs, const array& rhs); \
1025  AFAPI array OP (const array& lhs, const bool& rhs); \
1026  AFAPI array OP (const array& lhs, const int& rhs); \
1027  AFAPI array OP (const array& lhs, const unsigned& rhs); \
1028  AFAPI array OP (const array& lhs, const char& rhs); \
1029  AFAPI array OP (const array& lhs, const unsigned char& rhs); \
1030  AFAPI array OP (const array& lhs, const long& rhs); \
1031  AFAPI array OP (const array& lhs, const unsigned long& rhs); \
1032  AFAPI array OP (const array& lhs, const long long& rhs); \
1033  AFAPI array OP (const array& lhs, const unsigned long long& rhs); \
1034  AFAPI array OP (const array& lhs, const double& rhs); \
1035  AFAPI array OP (const array& lhs, const float& rhs); \
1036  AFAPI array OP (const array& lhs, const cfloat& rhs); \
1037  AFAPI array OP (const array& lhs, const cdouble& rhs);
1038 
1039 #if AF_API_VERSION >= 32
1040 #define BIN_OP(OP) \
1041  BIN_OP_(OP) \
1042  AFAPI array OP (const short& lhs, const array& rhs); \
1043  AFAPI array OP (const unsigned short& lhs, const array& rhs); \
1044  AFAPI array OP (const array& lhs, const short& rhs); \
1045  AFAPI array OP (const array& lhs, const unsigned short& rhs);
1046 
1047 #else
1048 #define BIN_OP(OP) BIN_OP_(OP)
1049 #endif
1050 
1059  BIN_OP(operator+ )
1061 
1070  BIN_OP(operator- )
1072 
1081  BIN_OP(operator* )
1083 
1092  BIN_OP(operator/ )
1094 
1103  BIN_OP(operator==)
1105 
1115  BIN_OP(operator!=)
1117 
1127  BIN_OP(operator< )
1129 
1138  BIN_OP(operator<=)
1140 
1150  BIN_OP(operator> )
1152 
1162  BIN_OP(operator>=)
1164 
1175  BIN_OP(operator||)
1177 
1187  BIN_OP(operator% )
1189 
1200  BIN_OP(operator| )
1202 
1213  BIN_OP(operator^ )
1215 
1226  BIN_OP(operator<<)
1228 
1239  BIN_OP(operator>>)
1241 
1242 #undef BIN_OP
1243 #undef BIN_OP_
1244 
1255  AFAPI array operator&(const array& lhs, const array& rhs);
1256  AFAPI array operator&(const array& lhs, const bool& rhs);
1257  AFAPI array operator&(const array& lhs, const cdouble& rhs);
1258  AFAPI array operator&(const array& lhs, const cfloat& rhs);
1259  AFAPI array operator&(const array& lhs, const char& rhs);
1260  AFAPI array operator&(const array& lhs, const double& rhs);
1261  AFAPI array operator&(const array& lhs, const float& rhs);
1262  AFAPI array operator&(const array& lhs, const int& rhs);
1263  AFAPI array operator&(const array& lhs, const long long& rhs);
1264  AFAPI array operator&(const array& lhs, const long& rhs);
1265  AFAPI array operator&(const array& lhs, const short& rhs);
1266  AFAPI array operator&(const array& lhs, const unsigned char& rhs);
1267  AFAPI array operator&(const array& lhs, const unsigned long long& rhs);
1268  AFAPI array operator&(const array& lhs, const unsigned long& rhs);
1269  AFAPI array operator&(const array& lhs, const unsigned short& rhs);
1270  AFAPI array operator&(const array& lhs, const unsigned& rhs);
1271  AFAPI array operator&(const bool& lhs, const array& rhs);
1272  AFAPI array operator&(const cdouble& lhs, const array& rhs);
1273  AFAPI array operator&(const cfloat& lhs, const array& rhs);
1274  AFAPI array operator&(const char& lhs, const array& rhs);
1275  AFAPI array operator&(const double& lhs, const array& rhs);
1276  AFAPI array operator&(const float& lhs, const array& rhs);
1277  AFAPI array operator&(const int& lhs, const array& rhs);
1278  AFAPI array operator&(const long long& lhs, const array& rhs);
1279  AFAPI array operator&(const long& lhs, const array& rhs);
1280  AFAPI array operator&(const short& lhs, const array& rhs);
1281  AFAPI array operator&(const unsigned char& lhs, const array& rhs);
1282  AFAPI array operator&(const unsigned long long& lhs, const array& rhs);
1283  AFAPI array operator&(const unsigned long& lhs, const array& rhs);
1284  AFAPI array operator&(const unsigned short& lhs, const array& rhs);
1285  AFAPI array operator&(const unsigned& lhs, const array& rhs);
1287 
1298  AFAPI array operator&&(const array& lhs, const array& rhs);
1299  AFAPI array operator&&(const array& lhs, const bool& rhs);
1300  AFAPI array operator&&(const array& lhs, const cdouble& rhs);
1301  AFAPI array operator&&(const array& lhs, const cfloat& rhs);
1302  AFAPI array operator&&(const array& lhs, const char& rhs);
1303  AFAPI array operator&&(const array& lhs, const double& rhs);
1304  AFAPI array operator&&(const array& lhs, const float& rhs);
1305  AFAPI array operator&&(const array& lhs, const int& rhs);
1306  AFAPI array operator&&(const array& lhs, const long long& rhs);
1307  AFAPI array operator&&(const array& lhs, const long& rhs);
1308  AFAPI array operator&&(const array& lhs, const short& rhs);
1309  AFAPI array operator&&(const array& lhs, const unsigned char& rhs);
1310  AFAPI array operator&&(const array& lhs, const unsigned long long& rhs);
1311  AFAPI array operator&&(const array& lhs, const unsigned long& rhs);
1312  AFAPI array operator&&(const array& lhs, const unsigned short& rhs);
1313  AFAPI array operator&&(const array& lhs, const unsigned& rhs);
1314  AFAPI array operator&&(const bool& lhs, const array& rhs);
1315  AFAPI array operator&&(const cdouble& lhs, const array& rhs);
1316  AFAPI array operator&&(const cfloat& lhs, const array& rhs);
1317  AFAPI array operator&&(const char& lhs, const array& rhs);
1318  AFAPI array operator&&(const double& lhs, const array& rhs);
1319  AFAPI array operator&&(const float& lhs, const array& rhs);
1320  AFAPI array operator&&(const int& lhs, const array& rhs);
1321  AFAPI array operator&&(const long long& lhs, const array& rhs);
1322  AFAPI array operator&&(const long& lhs, const array& rhs);
1323  AFAPI array operator&&(const short& lhs, const array& rhs);
1324  AFAPI array operator&&(const unsigned char& lhs, const array& rhs);
1325  AFAPI array operator&&(const unsigned long long& lhs, const array& rhs);
1326  AFAPI array operator&&(const unsigned long& lhs, const array& rhs);
1327  AFAPI array operator&&(const unsigned short& lhs, const array& rhs);
1328  AFAPI array operator&&(const unsigned& lhs, const array& rhs);
1330 
1331 
1333 
1337  inline array &eval(array &a) { a.eval(); return a; }
1338 
1339 #if AF_API_VERSION >= 34
1340  AFAPI void eval(int num, array **arrays);
1344 #endif
1345 
1346  inline void eval(array &a, array &b)
1347  {
1348 #if AF_API_VERSION >= 34
1349  array *arrays[] = {&a, &b};
1350  return eval(2, arrays);
1351 #else
1352  eval(a); b.eval();
1353 #endif
1354  }
1355 
1356  inline void eval(array &a, array &b, array &c)
1357  {
1358 #if AF_API_VERSION >= 34
1359  array *arrays[] = {&a, &b, &c};
1360  return eval(3, arrays);
1361 #else
1362  eval(a, b); c.eval();
1363 #endif
1364  }
1365 
1366  inline void eval(array &a, array &b, array &c, array &d)
1367  {
1368 #if AF_API_VERSION >= 34
1369  array *arrays[] = {&a, &b, &c, &d};
1370  return eval(4, arrays);
1371 #else
1372  eval(a, b, c); d.eval();
1373 #endif
1374 
1375  }
1376 
1377  inline void eval(array &a, array &b, array &c, array &d, array &e)
1378  {
1379 #if AF_API_VERSION >= 34
1380  array *arrays[] = {&a, &b, &c, &d, &e};
1381  return eval(5, arrays);
1382 #else
1383  eval(a, b, c, d); e.eval();
1384 #endif
1385  }
1386 
1387  inline void eval(array &a, array &b, array &c, array &d, array &e, array &f)
1388  {
1389 #if AF_API_VERSION >= 34
1390  array *arrays[] = {&a, &b, &c, &d, &e, &f};
1391  return eval(6, arrays);
1392 #else
1393  eval(a, b, c, d, e); f.eval();
1394 #endif
1395  }
1396 
1397 #if AF_API_VERSION >= 34
1398  AFAPI void setManualEvalFlag(bool flag);
1402 #endif
1403 
1404 #if AF_API_VERSION >= 34
1405  AFAPI bool getManualEvalFlag();
1407 #endif
1408 
1413 }
1414 #endif
1415 
1416 #ifdef __cplusplus
1417 extern "C" {
1418 #endif
1419 
1438  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);
1439 
1450  AFAPI af_err af_create_handle(af_array *arr, const unsigned ndims, const dim_t * const dims, const af_dtype type);
1451 
1462  AFAPI af_err af_copy_array(af_array *arr, const af_array in);
1463 
1467  AFAPI af_err af_write_array(af_array arr, const void *data, const size_t bytes, af_source src);
1468 
1474  AFAPI af_err af_get_data_ptr(void *data, const af_array arr);
1475 
1480 
1484  AFAPI af_err af_retain_array(af_array *out, const af_array in);
1485 
1486 #if AF_API_VERSION >= 31
1487 
1493  AFAPI af_err af_get_data_ref_count(int *use_count, const af_array in);
1494 #endif
1495 
1496 
1501 
1507 #if AF_API_VERSION >= 34
1508 
1511  AFAPI af_err af_eval_multiple(const int num, af_array *arrays);
1515 #endif
1516 
1517 #if AF_API_VERSION >= 34
1518 
1525 #endif
1526 
1527 #if AF_API_VERSION >= 34
1528 
1531  AFAPI af_err af_get_manual_eval_flag(bool *flag);
1535 #endif
1536 
1549  AFAPI af_err af_get_elements(dim_t *elems, const af_array arr);
1550 
1559  AFAPI af_err af_get_type(af_dtype *type, const af_array arr);
1560 
1572  AFAPI af_err af_get_dims(dim_t *d0, dim_t *d1, dim_t *d2, dim_t *d3,
1573  const af_array arr);
1574 
1583  AFAPI af_err af_get_numdims(unsigned *result, const af_array arr);
1584 
1593  AFAPI af_err af_is_empty (bool *result, const af_array arr);
1594 
1603  AFAPI af_err af_is_scalar (bool *result, const af_array arr);
1604 
1613  AFAPI af_err af_is_row (bool *result, const af_array arr);
1614 
1623  AFAPI af_err af_is_column (bool *result, const af_array arr);
1624 
1635  AFAPI af_err af_is_vector (bool *result, const af_array arr);
1636 
1645  AFAPI af_err af_is_complex (bool *result, const af_array arr);
1646 
1657  AFAPI af_err af_is_real (bool *result, const af_array arr);
1658 
1667  AFAPI af_err af_is_double (bool *result, const af_array arr);
1668 
1677  AFAPI af_err af_is_single (bool *result, const af_array arr);
1678 
1687  AFAPI af_err af_is_realfloating (bool *result, const af_array arr);
1688 
1699  AFAPI af_err af_is_floating (bool *result, const af_array arr);
1700 
1709  AFAPI af_err af_is_integer (bool *result, const af_array arr);
1710 
1719  AFAPI af_err af_is_bool (bool *result, const af_array arr);
1720 
1721 #if AF_API_VERSION >= 34
1722 
1730  AFAPI af_err af_is_sparse (bool *result, const af_array arr);
1731 #endif
1732 
1733 #if AF_API_VERSION >= 35
1734 
1741  AFAPI af_err af_get_scalar(void* output_value, const af_array arr);
1742 #endif
1743 
1748 #ifdef __cplusplus
1749 }
1750 #endif
AFAPI af_err af_set_manual_eval_flag(bool flag)
Turn the manual eval flag on or off.
AFAPI void setManualEvalFlag(bool flag)
Turn the manual eval flag on or off.
AFAPI af_err af_is_row(bool *result, const af_array arr)
Check if an array is row vector.
AFAPI af_err af_is_real(bool *result, const af_array arr)
Check if an array is real type.
bool isreal() const
Definition: array.h:118
Definition: algorithm.h:14
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_copy_array(af_array *arr, const af_array in)
Deep copy an array to another.
AFAPI af_err af_is_sparse(bool *result, const af_array arr)
Check if an array is sparse.
AFAPI af_err af_eval_multiple(const int num, af_array *arrays)
Evaluate multiple arrays together.
AFAPI af_err af_get_data_ptr(void *data, const af_array arr)
Copy data from an af_array to a C pointer.
#define ASSIGN(OP)
Definition: array.h:887
AFAPI af_err af_is_complex(bool *result, const af_array arr)
Check if an array is complex type.
af::af_cfloat cfloat
Definition: complex.h:44
AFAPI array operator &(const array &lhs, const array &rhs)
Performs an bitwise AND operation on two arrays or an array and a value.
void eval() const
Evaluate any JIT expressions to generate data for the array.
A multi dimensional data container.
Definition: array.h:26
AFAPI af_err af_is_bool(bool *result, const af_array arr)
Check if an array is bool type.
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_vector(bool *result, const af_array arr)
Check if an array is a vector.
AFAPI af_err af_is_integer(bool *result, const af_array arr)
Check if an array is integer type.
array & eval(array &a)
Evaluate an expression (nonblocking).
Definition: array.h:1337
bool isreal() const
Returns true if the array type is neither c32 nor c64.
Definition: array.h:633
Struct used while indexing af_array.
Definition: index.h:23
af_err
Definition: defines.h:65
AFAPI seq span
af_source
Definition: defines.h:216
AFAPI af_err af_get_type(af_dtype *type, const af_array arr)
Gets the type of an array.
AFAPI af::cfloat operator -(const af::cfloat &lhs, const af::cfloat &rhs)
long long dim_t
Definition: defines.h:50
#define BIN_OP(OP)
Definition: array.h:1040
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_dims(dim_t *d0, dim_t *d1, dim_t *d2, dim_t *d3, const af_array arr)
Gets the dimensions of an array.
Wrapper for af_index.
Definition: index.h:52
#define AFAPI
Definition: defines.h:31
AFAPI af_err af_is_scalar(bool *result, const af_array arr)
Check if an array is scalar, ie.
AFAPI af_err af_get_elements(dim_t *elems, const af_array arr)
Gets the number of elements in 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.
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_empty(bool *result, const af_array arr)
Check if an array is empty.
AFAPI af_err af_release_array(af_array arr)
Reduce the reference count of the af_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.
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::af_cdouble cdouble
Definition: complex.h:45
AFAPI af_err af_is_column(bool *result, const af_array arr)
Check if an array is a column vector.
AFAPI af_err af_retain_array(af_array *out, const af_array in)
Increments an af_array reference count.
void * af_array
Definition: defines.h:224
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_create_handle(af_array *arr, const unsigned ndims, const dim_t *const dims, const af_dtype type)
Create af_array handle.
32-bit floating point values
Definition: defines.h:198
AFAPI af_err af_get_data_ref_count(int *use_count, const af_array in)
Get the use count of af_array
Intermediate data class.
Definition: array.h:44
AFAPI af_err af_get_manual_eval_flag(bool *flag)
Get the manual eval flag.
AFAPI bool getManualEvalFlag()
Get the manual eval flag.
Host pointer.
Definition: defines.h:218
AFAPI af_err af_get_scalar(void *output_value, const af_array arr)
Get first element from an array.
AFAPI af_err af_is_floating(bool *result, const af_array arr)
Check if an array is floating precision type.
af_dtype
Definition: defines.h:197
AFAPI af_err af_eval(af_array in)
Evaluate any expressions in the Array.
AFAPI array operator &&(const array &lhs, const array &rhs)
Performs a logical AND operation on two arrays or an array and a value.