diff options
author | 2009-10-23 14:26:14 +0200 | |
---|---|---|
committer | 2009-10-23 14:26:14 +0200 | |
commit | a382963b04d4b847c6b0ef0611511fb6a8e11718 (patch) | |
tree | ad12bedf1d6537b14219889c49b82773a9bc8fab /Eigen/src/Core/Map.h | |
parent | 83a7b7c44c4842e1cfa89179624f4448d39a9e5b (diff) |
* extend Map to allow the user to specify whether the mapped data
is aligned or not. This is done using the Aligned constant:
Map<MatrixType,Aligned>::Map(data);
* rename ForceAligned to EnforceAlignedAccess, and update its doc,
and emphasize this is mainly an internal stuff.
Diffstat (limited to 'Eigen/src/Core/Map.h')
-rw-r--r-- | Eigen/src/Core/Map.h | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index f6bc814e2..dba7e20e4 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -31,16 +31,14 @@ * \brief A matrix or vector expression mapping an existing array of data. * * \param MatrixType the equivalent matrix type of the mapped data - * \param _PacketAccess allows to enforce aligned loads and stores if set to ForceAligned. - * The default is AsRequested. This parameter is internaly used by Eigen - * in expressions such as \code Map<...>(...) += other; \endcode and most - * of the time this is the only way it is used. + * \param PointerAlignment specifies whether the pointer is \c Aligned, or \c Unaligned. + * The default is \c Unaligned. * * This class represents a matrix or vector expression mapping an existing array of data. * It can be used to let Eigen interface without any overhead with non-Eigen data structures, * such as plain C arrays or structures from other libraries. * - * \b Tips: to change the array of data mapped by a Map object, you can use the C++ + * \b Tip: to change the array of data mapped by a Map object, you can use the C++ * placement new syntax: * * Example: \include Map_placement_new.cpp @@ -48,22 +46,27 @@ * * This class is the return type of Matrix::Map() but can also be used directly. * + * \b Note \b to \b Eigen \b developers: The template parameter \c PointerAlignment + * can also be or-ed with \c EnforceAlignedAccess in order to enforce aligned read + * in expressions such as \code A += B; \endcode. See class MapBase for further details. + * * \sa Matrix::Map() */ -template<typename MatrixType, int _PacketAccess> -struct ei_traits<Map<MatrixType, _PacketAccess> > : public ei_traits<MatrixType> +template<typename MatrixType, int Options> +struct ei_traits<Map<MatrixType, Options> > : public ei_traits<MatrixType> { enum { - PacketAccess = _PacketAccess, - Flags = ei_traits<MatrixType>::Flags & ~AlignedBit + PacketAccess = Options & EnforceAlignedAccess, + Flags = (Options&Aligned)==Aligned ? ei_traits<MatrixType>::Flags | AlignedBit + : ei_traits<MatrixType>::Flags & ~AlignedBit }; - typedef typename ei_meta_if<int(PacketAccess)==ForceAligned, - Map<MatrixType, _PacketAccess>&, - Map<MatrixType, ForceAligned> >::ret AlignedDerivedType; + typedef typename ei_meta_if<int(PacketAccess)==EnforceAlignedAccess, + Map<MatrixType, Options>&, + Map<MatrixType, Options|EnforceAlignedAccess> >::ret AlignedDerivedType; }; -template<typename MatrixType, int PacketAccess> class Map - : public MapBase<Map<MatrixType, PacketAccess> > +template<typename MatrixType, int Options> class Map + : public MapBase<Map<MatrixType, Options> > { public: @@ -72,9 +75,9 @@ template<typename MatrixType, int PacketAccess> class Map inline int stride() const { return this->innerSize(); } - AlignedDerivedType _convertToForceAligned() + AlignedDerivedType _convertToEnforceAlignedAccess() { - return Map<MatrixType,ForceAligned>(Base::m_data, Base::m_rows.value(), Base::m_cols.value()); + return AlignedDerivedType(Base::m_data, Base::m_rows.value(), Base::m_cols.value()); } inline Map(const Scalar* data) : Base(data) {} |