mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-14 18:33:16 +08:00
fix MapBase's ForceAligned concept which was not working at all....
This commit is contained in:
parent
3f80c68be5
commit
db6c3d0197
@ -221,15 +221,13 @@ class Block<MatrixType,BlockRows,BlockCols,PacketAccess,HasDirectAccess>
|
|||||||
|
|
||||||
class InnerIterator;
|
class InnerIterator;
|
||||||
typedef typename ei_traits<Block>::AlignedDerivedType AlignedDerivedType;
|
typedef typename ei_traits<Block>::AlignedDerivedType AlignedDerivedType;
|
||||||
|
friend class Block<MatrixType,BlockRows,BlockCols,AsRequested,HasDirectAccess>;
|
||||||
|
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
|
||||||
|
|
||||||
AlignedDerivedType forceAligned()
|
AlignedDerivedType _convertToForceAligned()
|
||||||
{
|
{
|
||||||
if (PacketAccess==ForceAligned)
|
return Block<MatrixType,BlockRows,BlockCols,ForceAligned,HasDirectAccess>
|
||||||
return *this;
|
|
||||||
else
|
|
||||||
return Block<MatrixType,BlockRows,BlockCols,ForceAligned,HasDirectAccess>
|
|
||||||
(m_matrix, Base::m_data, Base::m_rows.value(), Base::m_cols.value());
|
(m_matrix, Base::m_data, Base::m_rows.value(), Base::m_cols.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,12 +72,9 @@ template<typename MatrixType, int PacketAccess> class Map
|
|||||||
|
|
||||||
inline int stride() const { return this->innerSize(); }
|
inline int stride() const { return this->innerSize(); }
|
||||||
|
|
||||||
AlignedDerivedType forceAligned()
|
AlignedDerivedType _convertToForceAligned()
|
||||||
{
|
{
|
||||||
if (PacketAccess==ForceAligned)
|
return Map<MatrixType,ForceAligned>(Base::m_data, Base::m_rows.value(), Base::m_cols.value());
|
||||||
return *this;
|
|
||||||
else
|
|
||||||
return Map<MatrixType,ForceAligned>(Base::m_data, Base::m_rows.value(), Base::m_cols.value());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Map(const Scalar* data) : Base(data) {}
|
inline Map(const Scalar* data) : Base(data) {}
|
||||||
|
@ -65,9 +65,20 @@ template<typename Derived> class MapBase
|
|||||||
inline int stride() const { return derived().stride(); }
|
inline int stride() const { return derived().stride(); }
|
||||||
inline const Scalar* data() const { return m_data; }
|
inline const Scalar* data() const { return m_data; }
|
||||||
|
|
||||||
|
template<bool IsForceAligned,typename Dummy> struct force_aligned_impl {
|
||||||
|
AlignedDerivedType static run(MapBase& a) { return a.derived(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Dummy> struct force_aligned_impl<false,Dummy> {
|
||||||
|
AlignedDerivedType static run(MapBase& a) { return a.derived()._convertToForceAligned(); }
|
||||||
|
};
|
||||||
|
|
||||||
/** \returns an expression equivalent to \c *this but having the \c PacketAccess constant
|
/** \returns an expression equivalent to \c *this but having the \c PacketAccess constant
|
||||||
* set to \c ForceAligned. Must be reimplemented by the derived class. */
|
* set to \c ForceAligned. Must be reimplemented by the derived class. */
|
||||||
AlignedDerivedType forceAligned() { return derived().forceAligned(); }
|
AlignedDerivedType forceAligned()
|
||||||
|
{
|
||||||
|
return force_aligned_impl<int(PacketAccess)==int(ForceAligned),Derived>::run(*this);
|
||||||
|
}
|
||||||
|
|
||||||
inline const Scalar& coeff(int row, int col) const
|
inline const Scalar& coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
@ -155,6 +166,17 @@ template<typename Derived> class MapBase
|
|||||||
&& cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)));
|
&& cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Derived& operator=(const MapBase& other)
|
||||||
|
{
|
||||||
|
return Base::operator=(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename OtherDerived>
|
||||||
|
Derived& operator=(const MatrixBase<OtherDerived>& other)
|
||||||
|
{
|
||||||
|
return Base::operator=(other);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived& operator+=(const MatrixBase<OtherDerived>& other)
|
Derived& operator+=(const MatrixBase<OtherDerived>& other)
|
||||||
{ return derived() = forceAligned() + other; }
|
{ return derived() = forceAligned() + other; }
|
||||||
|
@ -204,18 +204,18 @@ using Eigen::ei_cos;
|
|||||||
template<typename OtherDerived> \
|
template<typename OtherDerived> \
|
||||||
EIGEN_STRONG_INLINE Derived& operator Op(const Eigen::MatrixBase<OtherDerived>& other) \
|
EIGEN_STRONG_INLINE Derived& operator Op(const Eigen::MatrixBase<OtherDerived>& other) \
|
||||||
{ \
|
{ \
|
||||||
return Eigen::MatrixBase<Derived>::operator Op(other.derived()); \
|
return Base::operator Op(other.derived()); \
|
||||||
} \
|
} \
|
||||||
EIGEN_STRONG_INLINE Derived& operator Op(const Derived& other) \
|
EIGEN_STRONG_INLINE Derived& operator Op(const Derived& other) \
|
||||||
{ \
|
{ \
|
||||||
return Eigen::MatrixBase<Derived>::operator Op(other); \
|
return Base::operator Op(other); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
|
#define EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
|
||||||
template<typename Other> \
|
template<typename Other> \
|
||||||
EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \
|
EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \
|
||||||
{ \
|
{ \
|
||||||
return Eigen::MatrixBase<Derived>::operator Op(scalar); \
|
return Base::operator Op(scalar); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
|
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user