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

Function IdentityCPPCheck

test/constant.cpp:74–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72
73template<typename T>
74void IdentityCPPCheck() {
75 SUPPORTED_TYPE_CHECK(T);
76
77 int num = 1000;
78 dtype dty = (dtype)dtype_traits<T>::af_type;
79 array out = identity(num, num, dty);
80
81 vector<T> h_in(num * num);
82 out.host(&h_in.front());
83
84 for (int i = 0; i < num; i++) {
85 for (int j = 0; j < num; j++) {
86 if (j == i)
87 ASSERT_EQ(h_in[i * num + j], T(1));
88 else
89 ASSERT_EQ(h_in[i * num + j], T(0));
90 }
91 }
92
93 num = 100;
94 out = identity(num, num, num, dty);
95
96 h_in.resize(num * num * num);
97 out.host(&h_in.front());
98
99 for (int h = 0; h < num; h++) {
100 for (int i = 0; i < num; i++) {
101 for (int j = 0; j < num; j++) {
102 if (j == i)
103 ASSERT_EQ(h_in[i * num + j], T(1));
104 else
105 ASSERT_EQ(h_in[i * num + j], T(0));
106 }
107 }
108 }
109}
110
111template<typename T>
112void IdentityLargeDimCheck() {

Callers

nothing calls this directly

Calls 2

hostMethod · 0.80
identityFunction · 0.50

Tested by

no test coverage detected