diff options
author | 2008-08-09 21:57:50 +0000 | |
---|---|---|
committer | 2008-08-09 21:57:50 +0000 | |
commit | 55e8d670ce206ea91aed5520688442ee6fed0fd2 (patch) | |
tree | a9746894658200f41e4ab80fc64b980081566a05 /Eigen/src/Core/MapBase.h | |
parent | b13148c3588c2be8805630c117cdc2b4cfb00576 (diff) |
Renamed allowAligned() => forceAligned() and added the constants ForceAligned
and AsRequested for the PacketAccess parameter of MapBase. Updated respective
documentation.
Diffstat (limited to 'Eigen/src/Core/MapBase.h')
-rw-r--r-- | Eigen/src/Core/MapBase.h | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index 0b54ca7b8..4c1a0cf2f 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -26,12 +26,18 @@ #ifndef EIGEN_MAPBASE_H #define EIGEN_MAPBASE_H -/** \internal - * - * \class MapBase +/** \class MapBase * * \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 ForceAligned which enforces both aligned loads and stores + * - \b AsRequested which is the default behavior + * The type \c AlignedDerivedType should correspond to the equivalent expression type + * with \c PacketAccess being \c ForceAligned. + * * \sa class Map, class Block */ template<typename Derived> class MapBase @@ -57,7 +63,10 @@ template<typename Derived> class MapBase inline int cols() const { return m_cols.value(); } inline int stride() const { return derived().stride(); } - AlignedDerivedType allowAligned() { return derived().allowAligned(); } + + /** \Returns an expression equivalent to \c *this but having the \c PacketAccess constant + * set to \c ForceAligned. Must be reimplemented by the derived class. */ + AlignedDerivedType forceAligned() { return derived().forceAligned(); } inline const Scalar& coeff(int row, int col) const { @@ -92,7 +101,7 @@ template<typename Derived> class MapBase template<int LoadMode> inline PacketScalar packet(int row, int col) const { - return ei_ploadt<Scalar, int(PacketAccess) == Aligned ? Aligned : LoadMode> + return ei_ploadt<Scalar, int(PacketAccess) == ForceAligned ? Aligned : LoadMode> (m_data + (IsRowMajor ? col + row * stride() : row + col * stride())); } @@ -100,13 +109,13 @@ template<typename Derived> class MapBase template<int LoadMode> inline PacketScalar packet(int index) const { - return ei_ploadt<Scalar, int(PacketAccess) == Aligned ? Aligned : LoadMode>(m_data + index); + return ei_ploadt<Scalar, int(PacketAccess) == ForceAligned ? Aligned : LoadMode>(m_data + index); } template<int StoreMode> inline void writePacket(int row, int col, const PacketScalar& x) { - ei_pstoret<Scalar, PacketScalar, int(PacketAccess) == Aligned ? Aligned : StoreMode> + ei_pstoret<Scalar, PacketScalar, int(PacketAccess) == ForceAligned ? Aligned : StoreMode> (const_cast<Scalar*>(m_data) + (IsRowMajor ? col + row * stride() : row + col * stride()), x); } @@ -114,7 +123,7 @@ template<typename Derived> class MapBase template<int StoreMode> inline void writePacket(int index, const PacketScalar& x) { - ei_pstoret<Scalar, PacketScalar, int(PacketAccess) == Aligned ? Aligned : StoreMode> + ei_pstoret<Scalar, PacketScalar, int(PacketAccess) == ForceAligned ? Aligned : StoreMode> (const_cast<Scalar*>(m_data) + index, x); } @@ -142,21 +151,19 @@ template<typename Derived> class MapBase EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MapBase) -// EIGEN_INHERIT_ASSIGNMENT_OPERATOR(MapBase, =) - template<typename OtherDerived> Derived& operator+=(const MatrixBase<OtherDerived>& other) - { return derived() = allowAligned() + other; } + { return derived() = forceAligned() + other; } template<typename OtherDerived> Derived& operator-=(const MatrixBase<OtherDerived>& other) - { return derived() = allowAligned() - other; } + { return derived() = forceAligned() - other; } Derived& operator*=(const Scalar& other) - { return derived() = allowAligned() * other; } + { return derived() = forceAligned() * other; } Derived& operator/=(const Scalar& other) - { return derived() = allowAligned() / other; } + { return derived() = forceAligned() / other; } protected: const Scalar* __restrict__ m_data; |