aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h
blob: f1df827f979b3da9879e8f4e9d4e39d62328cf95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef EIGEN_CXX11_TENSOR_TENSOR_ASSIGN_H
#define EIGEN_CXX11_TENSOR_TENSOR_ASSIGN_H


namespace Eigen {

/** \class TensorAssign
  * \ingroup CXX11_Tensor_Module
  *
  * \brief The tensor assignment class.
  *
  * This class is responsible for triggering the evaluation of the expressions
  * used on the lhs and rhs of an assignment operator and copy the result of
  * the evaluation of the rhs expression at the address computed during the
  * evaluation lhs expression.
  *
  * TODO: vectorization. For now the code only uses scalars
  * TODO: parallelisation using multithreading on cpu, or kernels on gpu.
  */
namespace internal {

template<typename Derived1, typename Derived2>
struct TensorAssign
{
  typedef typename Derived1::Index Index;
  EIGEN_DEVICE_FUNC
  static inline void run(Derived1& dst, const Derived2& src)
  {
    TensorEvaluator<Derived1> evalDst(dst);
    TensorEvaluator<Derived2> evalSrc(src);
    const Index size = dst.size();
    for(Index i = 0; i < size; ++i) {
      evalDst.coeffRef(i) = evalSrc.coeff(i);
    }
  }
};


} // end namespace internal

} // end namespace Eigen

#endif // EIGEN_CXX11_TENSOR_TENSOR_ASSIGN_H