cxx11_tensor_lvalue.cpp
Go to the documentation of this file.
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 
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 
40 {
42 }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor< Scalar_, NumIndices_, Options_, IndexType_ > & setRandom()
Definition: TensorBase.h:850
MatrixXd mat1(size, size)
#define VERIFY_IS_APPROX(a, b)
static void test_compound_assignment()
#define CALL_SUBTEST(FUNC)
Definition: main.h:342
void test_cxx11_tensor_lvalue()
std::ptrdiff_t j
The tensor class.
Definition: Tensor.h:63


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:55