MCPcopy Create free account
hub / github.com/Derious/cuMPC / test_boolean

Function test_boolean

dependence/eigen-3.4.0/unsupported/test/cxx11_tensor_expr.cpp:196–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196static void test_boolean()
197{
198 const int kSize = 31;
199 Tensor<int, 1> vec(kSize);
200 std::iota(vec.data(), vec.data() + kSize, 0);
201
202 // Test ||.
203 Tensor<bool, 1> bool1 = vec < vec.constant(1) || vec > vec.constant(4);
204 for (int i = 0; i < kSize; ++i) {
205 bool expected = i < 1 || i > 4;
206 VERIFY_IS_EQUAL(bool1[i], expected);
207 }
208
209 // Test &&, including cast of operand vec.
210 Tensor<bool, 1> bool2 = vec.cast<bool>() && vec < vec.constant(4);
211 for (int i = 0; i < kSize; ++i) {
212 bool expected = bool(i) && i < 4;
213 VERIFY_IS_EQUAL(bool2[i], expected);
214 }
215
216 // Compilation tests:
217 // Test Tensor<bool> against results of cast or comparison; verifies that
218 // CoeffReturnType is set to match Op return type of bool for Unary and Binary
219 // Ops.
220 Tensor<bool, 1> bool3 = vec.cast<bool>() && bool2;
221 bool3 = vec < vec.constant(4) && bool2;
222}
223
224static void test_functors()
225{

Callers 1

EIGEN_DECLARE_TESTFunction · 0.85

Calls 2

constantMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected