Fixed the assignment operator of the Tensor and TensorMap classes.

This commit is contained in:
Benoit Steiner 2014-07-22 10:31:21 -07:00
parent 40bb98e76a
commit f7bb7ee3f3
2 changed files with 19 additions and 1 deletions

View File

@ -229,6 +229,17 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_> >
EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
}
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);
internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
return *this;
}
template<typename OtherDerived>
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Tensor& operator=(const OtherDerived& other)

View File

@ -241,9 +241,16 @@ template<typename PlainObjectType, int Options_> class TensorMap : public Tensor
}
#endif
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Self& operator=(const Self& other)
{
typedef TensorAssignOp<Self, const Self> Assign;
Assign assign(*this, other);
internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
return *this;
}
template<typename OtherDerived>
EIGEN_DEVICE_FUNC
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Self& operator=(const OtherDerived& other)
{
typedef TensorAssignOp<Self, const OtherDerived> Assign;