From f50548e86af75fd8e0d1689a9fb4184cf1fec509 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Thu, 4 Sep 2014 19:50:27 -0700 Subject: Added missing tensor copy constructors. As a result it is now possible to declare and initialize a tensor on the same line, as in: Tensor T = A + B; or Tensor T(A.reshape(new_shape)); --- unsupported/Eigen/CXX11/src/Tensor/Tensor.h | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'unsupported/Eigen/CXX11/src/Tensor/Tensor.h') diff --git a/unsupported/Eigen/CXX11/src/Tensor/Tensor.h b/unsupported/Eigen/CXX11/src/Tensor/Tensor.h index fdbe8df4c..879057f38 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/Tensor.h +++ b/unsupported/Eigen/CXX11/src/Tensor/Tensor.h @@ -55,7 +55,7 @@ namespace Eigen { * change dramatically. * * - * \ref TopicStorageOrders + * \ref TopicStorageOrders */ template @@ -75,7 +75,7 @@ class Tensor : public TensorBase > enum { IsAligned = bool(EIGEN_ALIGN) & !(Options_&DontAlign), - PacketAccess = true, + PacketAccess = (internal::packet_traits::size > 1), }; static const int Options = Options_; @@ -224,12 +224,31 @@ class Tensor : public TensorBase > } #endif - inline Tensor(const array& dimensions) - : m_storage(internal::array_prod(dimensions), dimensions) + inline explicit Tensor(const array& dimensions) + : m_storage(internal::array_prod(dimensions), dimensions) { EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED } + template + EIGEN_DEVICE_FUNC + EIGEN_STRONG_INLINE Tensor(const TensorBase& other) + { + typedef TensorAssignOp Assign; + Assign assign(*this, other.derived()); + resize(TensorEvaluator(assign, DefaultDevice()).dimensions()); + internal::TensorExecutor::run(assign, DefaultDevice()); + } + template + EIGEN_DEVICE_FUNC + EIGEN_STRONG_INLINE Tensor(const TensorBase& other) + { + typedef TensorAssignOp Assign; + Assign assign(*this, other.derived()); + resize(TensorEvaluator(assign, DefaultDevice()).dimensions()); + internal::TensorExecutor::run(assign, DefaultDevice()); + } + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor& operator=(const Tensor& other) { -- cgit v1.2.3