From c0f2cb016e60b7dbde1d5946f42234a709a711f9 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Mon, 28 Apr 2014 10:32:27 -0700 Subject: Extended support for Tensors: * Added ability to map a region of the memory to a tensor * Added basic support for unary and binary coefficient wise expressions, such as addition or square root * Provided an emulation layer to make it possible to compile the code with compilers (such as nvcc) that don't support cxx11. --- unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h | 52 +++++++++++++--------- 1 file changed, 30 insertions(+), 22 deletions(-) (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h') diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h b/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h index a34600ee6..503d7cfd6 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h @@ -37,14 +37,19 @@ template class TensorStorage : public TensorStorage::type> { - typedef TensorStorage::type> Base_; + typedef TensorStorage::type> Base_; + public: - TensorStorage() = default; - TensorStorage(const TensorStorage&) = default; - TensorStorage(TensorStorage&&) = default; + TensorStorage() { } + TensorStorage(const TensorStorage& other) : Base_(other) { } + +#ifdef EIGEN_HAVE_RVALUE_REFERENCES +// TensorStorage(TensorStorage&&) = default; +#endif TensorStorage(internal::constructor_without_unaligned_array_assert) : Base_(internal::constructor_without_unaligned_array_assert()) {} - TensorStorage(DenseIndex size, const std::array& dimensions) : Base_(size, dimensions) {} - TensorStorage& operator=(const TensorStorage&) = default; + TensorStorage(DenseIndex size, const array& dimensions) : Base_(size, dimensions) {} + + // TensorStorage& operator=(const TensorStorage&) = default; }; // pure dynamic @@ -52,17 +57,17 @@ template class TensorStorage::type> { T *m_data; - std::array m_dimensions; + array m_dimensions; typedef TensorStorage::type> Self_; public: - TensorStorage() : m_data(0), m_dimensions(internal::template repeat(0)) {} + TensorStorage() : m_data(0), m_dimensions() {} TensorStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_dimensions(internal::template repeat(0)) {} - TensorStorage(DenseIndex size, const std::array& dimensions) - : m_data(internal::conditional_aligned_new_auto(size)), m_dimensions(dimensions) - { EIGEN_INTERNAL_TENSOR_STORAGE_CTOR_PLUGIN } - TensorStorage(const Self_& other) + TensorStorage(DenseIndex size, const array& dimensions) + : m_data(internal::conditional_aligned_new_auto(size)), m_dimensions(dimensions) + { EIGEN_INTERNAL_TENSOR_STORAGE_CTOR_PLUGIN } + TensorStorage(const Self_& other) : m_data(internal::conditional_aligned_new_auto(internal::array_prod(other.m_dimensions))) , m_dimensions(other.m_dimensions) { @@ -76,28 +81,34 @@ class TensorStorage(m_data, internal::array_prod(m_dimensions)); } void swap(Self_& other) { std::swap(m_data,other.m_data); std::swap(m_dimensions,other.m_dimensions); } - std::array dimensions(void) const {return m_dimensions;} - void conservativeResize(DenseIndex size, const std::array& nbDimensions) + const array& dimensions() const {return m_dimensions;} + + void conservativeResize(DenseIndex size, const array& nbDimensions) { m_data = internal::conditional_aligned_realloc_new_auto(m_data, size, internal::array_prod(m_dimensions)); m_dimensions = nbDimensions; } - void resize(DenseIndex size, const std::array& nbDimensions) + void resize(DenseIndex size, const array& nbDimensions) { if(size != internal::array_prod(m_dimensions)) { @@ -110,8 +121,9 @@ class TensorStorage