| 47 | |
| 48 | |
| 49 | static 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 | |
| 75 | void test_cxx11_tensor_forced_eval() |