diff options
author | Gael Guennebaud <g.gael@free.fr> | 2009-11-20 16:30:14 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2009-11-20 16:30:14 +0100 |
commit | 4af1753b6fa83e2c0013f38e6d9e8538896d9d3c (patch) | |
tree | 65d8d1573ba8505e30f22e5939b804f0206135de /Eigen/src/Core/MapBase.h | |
parent | eb8f4500719b52f410c545f738d8fda399cea587 (diff) |
* remove EnforceAlignedAccess option to Block, VectorBlock, Map and MapBase
because thanks to the previous commit this is not needed anymore
* add a more general ForceAlignedAccess expression which can be used for any expression.
It is already used by StableNorm.h.
Diffstat (limited to 'Eigen/src/Core/MapBase.h')
-rw-r--r-- | Eigen/src/Core/MapBase.h | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index 0f0986bc5..31a0dbc6b 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -30,20 +30,6 @@ * * \brief Base class for Map and Block expression with direct access * - * Expression classes inheriting MapBase must define the constant \c PacketAccess, - * and type \c AlignedDerivedType in their respective ei_traits<> specialization structure. - * The value of \c PacketAccess can be either \b AsRequested, or set to \b EnforceAlignedAccess which - * enforces both aligned loads and stores. - * - * \c EnforceAlignedAccess is automatically set in expressions such as - * \code A += B; \endcode where A is either a Block or a Map. Here, - * this expression is transfomed into \code A = A_with_EnforceAlignedAccess + B; \endcode - * avoiding unaligned loads from A. Indeed, since Eigen's packet evaluation mechanism - * automatically align to the destination matrix, we know that loads to A will be aligned too. - * - * The type \c AlignedDerivedType should correspond to the equivalent expression type - * with \c PacketAccess set to \c EnforceAlignedAccess. - * * \sa class Map, class Block */ template<typename Derived> class MapBase @@ -54,13 +40,11 @@ template<typename Derived> class MapBase typedef MatrixBase<Derived> Base; enum { IsRowMajor = (int(ei_traits<Derived>::Flags) & RowMajorBit) ? 1 : 0, - PacketAccess = ei_traits<Derived>::PacketAccess, RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime, ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime, SizeAtCompileTime = Base::SizeAtCompileTime }; - typedef typename ei_traits<Derived>::AlignedDerivedType AlignedDerivedType; typedef typename ei_traits<Derived>::Scalar Scalar; typedef typename Base::PacketScalar PacketScalar; using Base::derived; @@ -85,21 +69,6 @@ template<typename Derived> class MapBase * \sa MapBase::stride() */ inline const Scalar* data() const { return m_data; } - template<bool IsEnforceAlignedAccess,typename Dummy> struct force_aligned_impl { - static AlignedDerivedType run(MapBase& a) { return a.derived(); } - }; - - template<typename Dummy> struct force_aligned_impl<false,Dummy> { - static AlignedDerivedType run(MapBase& a) { return a.derived()._convertToEnforceAlignedAccess(); } - }; - - /** \returns an expression equivalent to \c *this but having the \c PacketAccess constant - * set to \c EnforceAlignedAccess. Must be reimplemented by the derived class. */ - AlignedDerivedType forceAligned() - { - return force_aligned_impl<int(PacketAccess)==int(EnforceAlignedAccess),Derived>::run(*this); - } - inline const Scalar& coeff(int row, int col) const { if(IsRowMajor) @@ -137,7 +106,7 @@ template<typename Derived> class MapBase template<int LoadMode> inline PacketScalar packet(int row, int col) const { - return ei_ploadt<Scalar, int(PacketAccess) == EnforceAlignedAccess ? Aligned : LoadMode> + return ei_ploadt<Scalar, LoadMode> (m_data + (IsRowMajor ? col + row * stride() : row + col * stride())); } @@ -145,13 +114,13 @@ template<typename Derived> class MapBase template<int LoadMode> inline PacketScalar packet(int index) const { - return ei_ploadt<Scalar, int(PacketAccess) == EnforceAlignedAccess ? Aligned : LoadMode>(m_data + index); + return ei_ploadt<Scalar, LoadMode>(m_data + index); } template<int StoreMode> inline void writePacket(int row, int col, const PacketScalar& x) { - ei_pstoret<Scalar, PacketScalar, int(PacketAccess) == EnforceAlignedAccess ? Aligned : StoreMode> + ei_pstoret<Scalar, PacketScalar, StoreMode> (const_cast<Scalar*>(m_data) + (IsRowMajor ? col + row * stride() : row + col * stride()), x); } @@ -159,7 +128,7 @@ template<typename Derived> class MapBase template<int StoreMode> inline void writePacket(int index, const PacketScalar& x) { - ei_pstoret<Scalar, PacketScalar, int(PacketAccess) == EnforceAlignedAccess ? Aligned : StoreMode> + ei_pstoret<Scalar, PacketScalar, StoreMode> (const_cast<Scalar*>(m_data) + index, x); } |