13 #include <Eigen/CXX11/Tensor> 15 using Eigen::MatrixXf;
25 TensorMap<Tensor<float, 2> > mat1(m1.data(), 3,3);
26 TensorMap<Tensor<float, 2> > mat2(m2.data(), 3,3);
35 mat3 = mat3.contract(mat2, dims).eval();
37 VERIFY_IS_APPROX(mat3(0, 0), (m1*m2).eval()(0,0));
38 VERIFY_IS_APPROX(mat3(0, 1), (m1*m2).eval()(0,1));
39 VERIFY_IS_APPROX(mat3(0, 2), (m1*m2).eval()(0,2));
40 VERIFY_IS_APPROX(mat3(1, 0), (m1*m2).eval()(1,0));
41 VERIFY_IS_APPROX(mat3(1, 1), (m1*m2).eval()(1,1));
42 VERIFY_IS_APPROX(mat3(1, 2), (m1*m2).eval()(1,2));
43 VERIFY_IS_APPROX(mat3(2, 0), (m1*m2).eval()(2,0));
44 VERIFY_IS_APPROX(mat3(2, 1), (m1*m2).eval()(2,1));
45 VERIFY_IS_APPROX(mat3(2, 2), (m1*m2).eval()(2,2));
53 MatrixXf output = input;
54 output.rowwise() -= input.colwise().maxCoeff();
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));
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));
static void test_simple()
Tensor< float, 1 >::DimensionPair DimPair
void test_cxx11_tensor_forced_eval()