aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-01-14 15:33:11 -0800
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-01-14 15:33:11 -0800
commit8a382aa119274efd2eb73b822ae7cd2afa128cc5 (patch)
tree3ddd220d77336c30a7a4a6ee1f325c40ab57813f /unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h
parent703c526355c929cc6c422b7599ecfed57642e988 (diff)
Improved the resizing of tensors
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h')
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h12
1 files changed, 3 insertions, 9 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h b/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h
index aaec39756..dfe85602a 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h
@@ -114,16 +114,12 @@ class TensorStorage<T, NumIndices_, Dynamic, Options_, typename internal::gen_nu
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const DSizes<DenseIndex, NumIndices_>& dimensions() const {return m_dimensions;}
- void conservativeResize(DenseIndex size, const array<DenseIndex, NumIndices_>& nbDimensions)
- {
- m_data = internal::conditional_aligned_realloc_new_auto<T,(Options_&DontAlign)==0>(m_data, size, internal::array_prod(m_dimensions));
- m_dimensions = nbDimensions;
- }
void resize(DenseIndex size, const array<DenseIndex, NumIndices_>& nbDimensions)
{
- if(size != internal::array_prod(m_dimensions))
+ const DenseIndex currentSz = internal::array_prod(m_dimensions);
+ if(size != currentSz)
{
- internal::conditional_aligned_delete_auto<T,(Options_&DontAlign)==0>(m_data, internal::array_prod(m_dimensions));
+ internal::conditional_aligned_delete_auto<T,(Options_&DontAlign)==0>(m_data, currentSz);
if (size)
m_data = internal::conditional_aligned_new_auto<T,(Options_&DontAlign)==0>(size);
else
@@ -139,8 +135,6 @@ class TensorStorage<T, NumIndices_, Dynamic, Options_, typename internal::gen_nu
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DenseIndex size() const { return m_dimensions.TotalSize(); }
};
-
-
} // end namespace Eigen
#endif // EIGEN_CXX11_TENSOR_TENSORSTORAGE_H