1 // This file is part of Eigen, a lightweight C++ template library 2 // for linear algebra. 3 // 4 // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com> 5 // 6 // This Source Code Form is subject to the terms of the Mozilla 7 // Public License v. 2.0. If a copy of the MPL was not distributed 8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 10 #include "main.h" 11 12 #include <Eigen/CXX11/Tensor> 13 14 using Eigen::Tensor; 15 using Eigen::RowMajor; 16 17 18 static void test_compound_assignment() 19 { 20 Tensor<float, 3> mat1(2,3,7); 21 Tensor<float, 3> mat2(2,3,7); 22 Tensor<float, 3> mat3(2,3,7); 23 24 mat1.setRandom(); 25 mat2.setRandom(); 26 mat3 = mat1; 27 mat3 += mat2; 28 29 for (int i = 0; i < 2; ++i) { 30 for (int j = 0; j < 3; ++j) { 31 for (int k = 0; k < 7; ++k) { 32 VERIFY_IS_APPROX(mat3(i,j,k), mat1(i,j,k) + mat2(i,j,k)); 33 } 34 } 35 } 36 } 37 38 39 void test_cxx11_tensor_lvalue() 40 { 41 CALL_SUBTEST(test_compound_assignment()); 42 } 43