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

Function TEST

test/clamp.cpp:157–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157TEST(Clamp, FloatArrayArray) {
158 array in = randu(num, f32);
159 array lo = randu(num, f32) / 10; // Ensure lo <= 0.1
160 array hi = 1.0 - randu(num, f32) / 10; // Ensure hi >= 0.9
161 eval(lo, hi);
162
163 vector<float> hout(num), hin(num), hlo(num), hhi(num);
164 array out = clamp(in, lo, hi);
165 out.host(&hout[0]);
166 in.host(&hin[0]);
167 lo.host(&hlo[0]);
168 hi.host(&hhi[0]);
169
170 for (int i = 0; i < num; i++) {
171 ASSERT_LE(hout[i], hhi[i]);
172 ASSERT_GE(hout[i], hlo[i]);
173 ASSERT_EQ(true,
174 hout[i] == hin[i] || hout[i] == hlo[i] || hout[i] == hhi[i]);
175 }
176}
177
178TEST(Clamp, FloatArrayScalar) {
179 array in = randu(num, f32);

Callers

nothing calls this directly

Calls 4

randuFunction · 0.85
hostMethod · 0.80
evalFunction · 0.50
clampFunction · 0.50

Tested by

no test coverage detected