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

Function triangleTester

test/triangle.cpp:44–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43template<typename T>
44void triangleTester(const dim4 dims, bool is_upper, bool is_unit_diag = false) {
45 SUPPORTED_TYPE_CHECK(T);
46#if 1
47 array in = cpu_randu<T>(dims);
48#else
49 array in = randu(dims, (dtype)dtype_traits<T>::af_type);
50#endif
51
52 T *h_in = in.host<T>();
53 array out = is_upper ? upper(in, is_unit_diag) : lower(in, is_unit_diag);
54 T *h_out = out.host<T>();
55
56 int m = dims[0];
57 int n = dims[1];
58
59 for (int z = 0; z < (int)(dims[2] * dims[3]); z++) {
60 int z_off = z * m * n;
61
62 for (int y = 0; y < n; y++) {
63 int y_off = z_off + y * m;
64
65 for (int x = 0; x < m; x++) {
66 T val = T(0);
67 if (((y <= x) && !is_upper) || ((y >= x) && is_upper)) {
68 val = (is_unit_diag && y == x) ? (T)(1) : h_in[y_off + x];
69 }
70
71 ASSERT_EQ(h_out[y_off + x], val)
72 << "at (" << x << ", " << y << ")";
73 }
74 }
75 }
76
77 freeHost(h_in);
78 freeHost(h_out);
79}
80
81TYPED_TEST(Triangle, Lower2DRect0) {
82 triangleTester<TypeParam>(dim4(500, 600), false);

Callers

nothing calls this directly

Calls 4

randuFunction · 0.85
upperFunction · 0.85
lowerFunction · 0.85
freeHostFunction · 0.85

Tested by

no test coverage detected