aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-01-14 12:39:34 -0800
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-01-14 12:39:34 -0800
commitb12dd1ae3cc4077740dded430bc244623a6cc3b8 (patch)
tree65bbb11013a10d8835b915d8ac434268d3b97b5b /unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h
parent71676eaddd7fb6b8abdc5713f437750f3c963fcb (diff)
Misc improvements for fixed size tensors
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h')
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h b/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h
index 1af2d7bcd..94b3f957b 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h
@@ -42,7 +42,9 @@ class TensorFixedSize : public TensorBase<TensorFixedSize<Scalar_, Dimensions_,
enum {
IsAligned = bool(EIGEN_ALIGN),
PacketAccess = (internal::packet_traits<Scalar>::size > 1),
- };
+ Layout = Options_ & RowMajor ? RowMajor : ColMajor,
+ CoordAccess = true,
+ };
typedef Dimensions_ Dimensions;
static const std::size_t NumIndices = Dimensions::count;
@@ -51,11 +53,12 @@ class TensorFixedSize : public TensorBase<TensorFixedSize<Scalar_, Dimensions_,
TensorStorage<Scalar, NumIndices, Dimensions::total_size, Options, Dimensions> m_storage;
public:
- EIGEN_STRONG_INLINE Index dimension(std::size_t n) const { return m_storage.dimensions()[n]; }
- EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_storage.dimensions(); }
- EIGEN_STRONG_INLINE Index size() const { return m_storage.size(); }
- EIGEN_STRONG_INLINE Scalar *data() { return m_storage.data(); }
- EIGEN_STRONG_INLINE const Scalar *data() const { return m_storage.data(); }
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rank() const { return NumIndices; }
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension(std::size_t n) const { return m_storage.dimensions()[n]; }
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_storage.dimensions(); }
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const { return m_storage.size(); }
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar *data() { return m_storage.data(); }
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar *data() const { return m_storage.data(); }
// This makes EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
// work, because that uses base().coeffRef() - and we don't yet
@@ -187,6 +190,23 @@ class TensorFixedSize : public TensorBase<TensorFixedSize<Scalar_, Dimensions_,
{
}
+#ifdef EIGEN_HAVE_RVALUE_REFERENCES
+ inline TensorFixedSize(Self&& other)
+ : m_storage(other.m_storage)
+ {
+ }
+#endif
+
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE TensorFixedSize& operator=(const TensorFixedSize& other)
+ {
+ // FIXME: check that the dimensions of other match the dimensions of *this.
+ // Unfortunately this isn't possible yet when the rhs is an expression.
+ typedef TensorAssignOp<Self, const TensorFixedSize> Assign;
+ Assign assign(*this, other);
+ internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
+ return *this;
+ }
template<typename OtherDerived>
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE TensorFixedSize& operator=(const OtherDerived& other)