MCPcopy Create free account
hub / github.com/abess-team/abess / test_const

Function test_const

python/include/unsupported/test/cxx11_tensor_forced_eval.cpp:49–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47
48
49static void test_const()
50{
51 MatrixXf input(3,3);
52 input.setRandom();
53 MatrixXf output = input;
54 output.rowwise() -= input.colwise().maxCoeff();
55
56 Eigen::array<int, 1> depth_dim;
57 depth_dim[0] = 0;
58 Tensor<float, 2>::Dimensions dims2d;
59 dims2d[0] = 1;
60 dims2d[1] = 3;
61 Eigen::array<int, 2> bcast;
62 bcast[0] = 3;
63 bcast[1] = 1;
64 const TensorMap<Tensor<const float, 2> > input_tensor(input.data(), 3, 3);
65 Tensor<float, 2> output_tensor= (input_tensor - input_tensor.maximum(depth_dim).eval().reshape(dims2d).broadcast(bcast));
66
67 for (int i = 0; i < 3; ++i) {
68 for (int j = 0; j < 3; ++j) {
69 VERIFY_IS_APPROX(output(i, j), output_tensor(i, j));
70 }
71 }
72}
73
74
75void test_cxx11_tensor_forced_eval()

Callers 1

Calls 6

rowwiseMethod · 0.80
colwiseMethod · 0.80
maximumMethod · 0.80
maxCoeffMethod · 0.45
dataMethod · 0.45
evalMethod · 0.45

Tested by

no test coverage detected