DenseBase::IsRowMajor now takes the special case of vectors into account.

This commit is contained in:
Benoit Jacob 2010-02-25 21:24:42 -05:00
parent b1c6c215a4
commit f56ac04c34
3 changed files with 9 additions and 13 deletions

View File

@ -85,7 +85,7 @@ template<typename MatrixType, int Direction> class Reverse
protected: protected:
enum { enum {
PacketSize = ei_packet_traits<Scalar>::size, PacketSize = ei_packet_traits<Scalar>::size,
IsRowMajor = Flags & RowMajorBit, IsRowMajor = MatrixType::IsRowMajor,
IsColMajor = !IsRowMajor, IsColMajor = !IsRowMajor,
ReverseRow = (Direction == Vertical) || (Direction == BothDirections), ReverseRow = (Direction == Vertical) || (Direction == BothDirections),
ReverseCol = (Direction == Horizontal) || (Direction == BothDirections), ReverseCol = (Direction == Horizontal) || (Direction == BothDirections),

View File

@ -55,9 +55,7 @@ private:
}; };
enum { enum {
LhsIsEffectivelyRowMajor = (Derived::RowsAtCompileTime==1) || (int(Derived::Flags)&RowMajorBit), StorageOrdersAgree = (int(Derived::IsRowMajor) == int(OtherDerived::IsRowMajor)),
RhsIsEffectivelyRowMajor = (OtherDerived::RowsAtCompileTime==1) || (int(OtherDerived::Flags)&RowMajorBit),
StorageOrdersAgree = (LhsIsEffectivelyRowMajor == RhsIsEffectivelyRowMajor),
MightVectorize = StorageOrdersAgree MightVectorize = StorageOrdersAgree
&& (int(Derived::Flags) & int(OtherDerived::Flags) & ActualPacketAccessBit), && (int(Derived::Flags) & int(OtherDerived::Flags) & ActualPacketAccessBit),
MayInnerVectorize = MightVectorize && int(InnerSize)!=Dynamic && int(InnerSize)%int(PacketSize)==0 MayInnerVectorize = MightVectorize && int(InnerSize)!=Dynamic && int(InnerSize)%int(PacketSize)==0

View File

@ -124,7 +124,11 @@ template<typename Derived> class DenseBase
* constructed from this one. See the \ref flags "list of flags". * constructed from this one. See the \ref flags "list of flags".
*/ */
IsRowMajor = int(Flags) & RowMajorBit, /**< True if this expression is row major. */ IsRowMajor = RowsAtCompileTime==1 ? 1
: ColsAtCompileTime==1 ? 0
: int(Flags) & RowMajorBit, /**< True if this expression has row-major effective addressing.
For non-vectors, it is like reading the RowMajorBit on the Flags. For vectors, this is
overriden by the convention that row-vectors are row-major and column-vectors are column-major. */
InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? SizeAtCompileTime InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? SizeAtCompileTime
: int(Flags)&RowMajorBit ? ColsAtCompileTime : RowsAtCompileTime, : int(Flags)&RowMajorBit ? ColsAtCompileTime : RowsAtCompileTime,
@ -245,10 +249,7 @@ template<typename Derived> class DenseBase
*/ */
inline int rowStride() const inline int rowStride() const
{ {
return ColsAtCompileTime==1 ? innerStride() return IsRowMajor ? outerStride() : innerStride();
: RowsAtCompileTime==1 ? outerStride()
: IsRowMajor ? outerStride()
: innerStride();
} }
/** \returns the pointer increment between two consecutive columns. /** \returns the pointer increment between two consecutive columns.
@ -257,10 +258,7 @@ template<typename Derived> class DenseBase
*/ */
inline int colStride() const inline int colStride() const
{ {
return ColsAtCompileTime==1 ? outerStride() return IsRowMajor ? innerStride() : outerStride();
: RowsAtCompileTime==1 ? innerStride()
: IsRowMajor ? innerStride()
: outerStride();
} }
#ifndef EIGEN_PARSED_BY_DOXYGEN #ifndef EIGEN_PARSED_BY_DOXYGEN