diff options
author | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2014-07-31 17:39:04 -0700 |
---|---|---|
committer | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2014-07-31 17:39:04 -0700 |
commit | 647622281e5409e617854d35450afc0cd3a4dd49 (patch) | |
tree | 4dbb5930f9b203b627930f0cdfcdce2a9daeba1b /unsupported/Eigen/CXX11/src | |
parent | 2116e261fb27c795d153f171467cf7912ff3eec5 (diff) |
The tensor assignment code now resizes the destination tensor as needed.
Diffstat (limited to 'unsupported/Eigen/CXX11/src')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/Tensor.h | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/Tensor.h b/unsupported/Eigen/CXX11/src/Tensor/Tensor.h index 547bb74d1..fdbe8df4c 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/Tensor.h +++ b/unsupported/Eigen/CXX11/src/Tensor/Tensor.h @@ -79,6 +79,7 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_> > }; static const int Options = Options_; + static const std::size_t NumIndices = NumIndices_; typedef DSizes<DenseIndex, NumIndices_> Dimensions; @@ -232,11 +233,9 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_> > EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor& operator=(const Tensor& other) { - // FIXME: we need to resize the tensor to fix the dimensions of the other. - // Unfortunately this isn't possible yet when the rhs is an expression. - // resize(other.dimensions()); typedef TensorAssignOp<Tensor, const Tensor> Assign; Assign assign(*this, other); + resize(TensorEvaluator<const Assign, DefaultDevice>(assign, DefaultDevice()).dimensions()); internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice()); return *this; } @@ -244,11 +243,9 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_> > EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor& operator=(const OtherDerived& other) { - // FIXME: we need to resize the tensor to fix the dimensions of the other. - // Unfortunately this isn't possible yet when the rhs is an expression. - // resize(other.dimensions()); typedef TensorAssignOp<Tensor, const OtherDerived> Assign; Assign assign(*this, other); + resize(TensorEvaluator<const Assign, DefaultDevice>(assign, DefaultDevice()).dimensions()); internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice()); return *this; } |