diff options
author | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-10-26 14:29:26 -0700 |
---|---|---|
committer | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-10-26 14:29:26 -0700 |
commit | 1c8312c811344beaa06f7ae9258f66c38337c607 (patch) | |
tree | 4436a04ce900a997aa6adf9d42d0c6dab0a07fac /unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h | |
parent | 1f4c98abb1634bdbdd6583b55ba36dcc09ef5773 (diff) |
Started to add support for tensors of rank 0
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h b/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h index 9e4cf039d..ee6f14b8f 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h @@ -71,7 +71,11 @@ class TensorStorage<T, DSizes<IndexType, NumIndices_>, Options_> typedef DSizes<IndexType, NumIndices_> Dimensions; typedef TensorStorage<T, DSizes<IndexType, NumIndices_>, Options_> Self; - EIGEN_DEVICE_FUNC TensorStorage() : m_data(0), m_dimensions() {} + EIGEN_DEVICE_FUNC TensorStorage() : m_data(0), m_dimensions() { + if (NumIndices_ == 0) { + m_data = internal::conditional_aligned_new_auto<T,(Options_&DontAlign)==0>(1); + } + } EIGEN_DEVICE_FUNC TensorStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_dimensions(internal::template repeat<NumIndices_, Index>(0)) {} EIGEN_DEVICE_FUNC TensorStorage(Index size, const array<Index, NumIndices_>& dimensions) @@ -101,13 +105,17 @@ class TensorStorage<T, DSizes<IndexType, NumIndices_>, Options_> EIGEN_DEVICE_FUNC void resize(Index size, const array<Index, NumIndices_>& nbDimensions) { + eigen_assert(size >= 1); const Index currentSz = internal::array_prod(m_dimensions); if(size != currentSz) { 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 + else if (NumIndices_ == 0) { + m_data = internal::conditional_aligned_new_auto<T,(Options_&DontAlign)==0>(1); + } + else m_data = 0; EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } |