MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / selectTest

Function selectTest

test/select.cpp:50–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49template<typename T>
50void selectTest(const dim4& dims) {
51 SUPPORTED_TYPE_CHECK(T);
52 dtype ty = (dtype)dtype_traits<T>::af_type;
53
54 array a = randu(dims, ty);
55 array b = randu(dims, ty);
56
57 if (a.isinteger()) {
58 a = (a % (1 << 30)).as(ty);
59 b = (b % (1 << 30)).as(ty);
60 }
61
62 array cond = randu(dims, ty) > a;
63
64 array c = select(cond, a, b);
65
66 int num = (int)a.elements();
67
68 vector<T> ha(num);
69 vector<T> hb(num);
70 vector<T> hc(num);
71 vector<char> hcond(num);
72
73 a.host(&ha[0]);
74 b.host(&hb[0]);
75 c.host(&hc[0]);
76 cond.host(&hcond[0]);
77
78 for (int i = 0; i < num; i++) {
79 ASSERT_EQ(hc[i], hcond[i] ? ha[i] : hb[i]);
80 }
81}
82
83template<typename T, bool is_right>
84void selectScalarTest(const dim4& dims) {

Callers

nothing calls this directly

Calls 5

randuFunction · 0.85
asMethod · 0.80
hostMethod · 0.80
selectFunction · 0.50
elementsMethod · 0.45

Tested by

no test coverage detected