aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2014-07-09 12:48:34 -0700
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2014-07-09 12:48:34 -0700
commit25b2f6624d092ed99d0c4936de0c83c9ea4a024d (patch)
treed1f66f75e50e11270eba7abd63fe193f34100ef7 /unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
parentea0906dfd877b3be91b5b0a28d2040ec360b1d3a (diff)
Improved the speed of slicing operations.
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h')
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h b/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
index 55954a3a7..f6f67afa7 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
@@ -320,11 +320,12 @@ struct TensorEvaluator<const TensorSlicingOp<StartIndices, Sizes, ArgType>, Devi
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
{
Index inputIndex = 0;
- for (int i = NumDims - 1; i >= 0; --i) {
+ for (int i = NumDims - 1; i > 0; --i) {
const Index idx = index / m_outputStrides[i];
inputIndex += (idx + m_offsets[i]) * m_inputStrides[i];
index -= idx * m_outputStrides[i];
}
+ inputIndex += (index + m_offsets[0]);
return m_impl.coeff(inputIndex);
}
@@ -399,11 +400,12 @@ struct TensorEvaluator<TensorSlicingOp<StartIndices, Sizes, ArgType>, Device>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
{
Index inputIndex = 0;
- for (int i = NumDims - 1; i >= 0; --i) {
+ for (int i = NumDims - 1; i > 0; --i) {
const Index idx = index / m_outputStrides[i];
inputIndex += (idx + m_offsets[i]) * m_inputStrides[i];
index -= idx * m_outputStrides[i];
}
+ inputIndex += (index + m_offsets[0]);
return m_impl.coeff(inputIndex);
}
@@ -416,11 +418,12 @@ struct TensorEvaluator<TensorSlicingOp<StartIndices, Sizes, ArgType>, Device>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType& coeffRef(Index index)
{
Index inputIndex = 0;
- for (int i = NumDims - 1; i >= 0; --i) {
+ for (int i = NumDims - 1; i > 0; --i) {
const Index idx = index / m_outputStrides[i];
inputIndex += (idx + m_offsets[i]) * m_inputStrides[i];
index -= idx * m_outputStrides[i];
}
+ inputIndex += (index + m_offsets[0]);
return m_impl.coeffRef(inputIndex);
}