13 #include <Eigen/CXX11/Tensor> 16 template<
int DataLayout>
19 Tensor<int, 0, DataLayout> tensor;
25 std::string expected(
"123");
26 VERIFY_IS_EQUAL(std::string(os.str()), expected);
30 template<
int DataLayout>
33 Tensor<int, 1, DataLayout> tensor(5);
34 for (
int i = 0; i < 5; ++i) {
41 std::string expected(
"0\n1\n2\n3\n4");
42 VERIFY_IS_EQUAL(std::string(os.str()), expected);
45 std::stringstream empty_os;
46 empty_os << empty_tensor;
47 std::string empty_string;
48 VERIFY_IS_EQUAL(std::string(empty_os.str()), empty_string);
52 template<
int DataLayout>
55 Tensor<int, 2, DataLayout> tensor(5, 3);
56 for (
int i = 0; i < 5; ++i) {
57 for (
int j = 0; j < 3; ++j) {
65 std::string expected(
"0 0 0\n0 1 2\n0 2 4\n0 3 6\n0 4 8");
66 VERIFY_IS_EQUAL(std::string(os.str()), expected);
70 template<
int DataLayout>
73 Tensor<int, 1, DataLayout> tensor1(5);
74 Tensor<int, 1, DataLayout> tensor2(5);
75 for (
int i = 0; i < 5; ++i) {
81 os << tensor1 + tensor2;
83 std::string expected(
" 7\n 8\n 9\n10\n11");
84 VERIFY_IS_EQUAL(std::string(os.str()), expected);
88 template<
int DataLayout>
91 Tensor<std::string, 2, DataLayout> tensor(5, 3);
92 tensor.setConstant(std::string(
"foo"));
94 std::cout << tensor << std::endl;
99 std::string expected(
"foo foo foo\nfoo foo foo\nfoo foo foo\nfoo foo foo\nfoo foo foo");
100 VERIFY_IS_EQUAL(std::string(os.str()), expected);
104 template<
int DataLayout>
107 Tensor<int, 1, DataLayout> tensor(5);
108 for (
int i = 0; i < 5; ++i) {
112 TensorMap<Tensor<const int, 1, DataLayout> > tensor_map(tensor.data(), 5);
114 std::stringstream os;
117 std::string expected(
"0\n1\n2\n3\n4");
118 VERIFY_IS_EQUAL(std::string(os.str()), expected);
124 CALL_SUBTEST(test_output_0d<ColMajor>());
125 CALL_SUBTEST(test_output_0d<RowMajor>());
126 CALL_SUBTEST(test_output_1d<ColMajor>());
127 CALL_SUBTEST(test_output_1d<RowMajor>());
128 CALL_SUBTEST(test_output_2d<ColMajor>());
129 CALL_SUBTEST(test_output_2d<RowMajor>());
130 CALL_SUBTEST(test_output_expr<ColMajor>());
131 CALL_SUBTEST(test_output_expr<RowMajor>());
132 CALL_SUBTEST(test_output_string<ColMajor>());
133 CALL_SUBTEST(test_output_string<RowMajor>());
134 CALL_SUBTEST(test_output_const<ColMajor>());
135 CALL_SUBTEST(test_output_const<RowMajor>());
static void test_output_0d()
static void test_output_const()
static void test_output_string()
static void test_output_expr()
void test_cxx11_tensor_io()
static void test_output_2d()
static void test_output_1d()