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

Function replaceTest

test/replace.cpp:44–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

randuFunction · 0.85
asMethod · 0.80
hostMethod · 0.80
replaceFunction · 0.50
copyMethod · 0.45
elementsMethod · 0.45

Tested by

no test coverage detected