From bc072c5cba4cb6e9e7a6fd5f1e8f0e1231203223 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Mon, 7 Jul 2014 14:08:45 -0700 Subject: [PATCH] Added support for tensor slicing --- .../Eigen/CXX11/src/Tensor/TensorBase.h | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h b/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h index 6b53d2a3d..527d47c57 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h @@ -204,11 +204,16 @@ class TensorBase return TensorSelectOp(derived(), thenTensor.derived(), elseTensor.derived()); } - // Morphing operators (slicing tbd). + // Morphing operators. template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE - const TensorReshapingOp + const TensorReshapingOp reshape(const NewDimensions& newDimensions) const { - return TensorReshapingOp(derived(), newDimensions); + return TensorReshapingOp(derived(), newDimensions); + } + template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE + const TensorSlicingOp + slice(const StartIndices& startIndices, const Sizes& sizes) const { + return TensorSlicingOp(derived(), startIndices, sizes); } // Force the evaluation of the expression. @@ -257,6 +262,17 @@ class TensorBase : public TensorBase, const Derived, const OtherDerived>(derived(), other.derived()); } + template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE + TensorReshapingOp + reshape(const NewDimensions& newDimensions) { + return TensorReshapingOp(derived(), newDimensions); + } + template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE + TensorSlicingOp + slice(const StartIndices& startIndices, const Sizes& sizes) const { + return TensorSlicingOp(derived(), startIndices, sizes); + } + // Select the device on which to evaluate the expression. template TensorDevice device(const DeviceType& device) {