diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index e6cfb0859..b2b82b0f9 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -70,13 +70,18 @@ struct ei_traits > : (BlockRows==Dynamic ? int(ei_traits::MaxRowsAtCompileTime) : BlockRows), MaxColsAtCompileTime = ColsAtCompileTime == 1 ? 1 : (BlockCols==Dynamic ? int(ei_traits::MaxColsAtCompileTime) : BlockCols), - RowMajor = int(ei_traits::Flags)&RowMajorBit, + MatrixTypeIsRowMajor = int(ei_traits::Flags)&RowMajorBit, + IsRowMajor = (BlockRows==1&&BlockCols!=1) ? 1 + : (BlockCols==1&&BlockRows!=1) ? 0 + : MatrixTypeIsRowMajor, InnerSize = RowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime), - InnerMaxSize = RowMajor ? int(MaxColsAtCompileTime) : int(MaxRowsAtCompileTime), - MaskPacketAccessBit = (InnerMaxSize == Dynamic || (InnerSize >= ei_packet_traits::size)) + MaskPacketAccessBit = (InnerSize == Dynamic || (InnerSize % ei_packet_traits::size) == 0) + && (IsRowMajor == MatrixTypeIsRowMajor) // check for bad case of row-xpr inside col-major matrix... ? PacketAccessBit : 0, FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0, - Flags = (ei_traits::Flags & (HereditaryBits | MaskPacketAccessBit | DirectAccessBit)) | FlagsLinearAccessBit + Flags0 = ei_traits::Flags & (HereditaryBits | MaskPacketAccessBit | DirectAccessBit), + Flags1 = Flags0 | FlagsLinearAccessBit, + Flags = (Flags1 & ~RowMajorBit) | (IsRowMajor ? RowMajorBit : 0) }; }; diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index 52a883811..ecce3ad05 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -124,11 +124,7 @@ template class DenseBase * constructed from this one. See the \ref flags "list of flags". */ - 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. */ + IsRowMajor = int(Flags) & RowMajorBit, /**< True if this expression has row-major storage order. */ InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? SizeAtCompileTime : int(Flags)&RowMajorBit ? ColsAtCompileTime : RowsAtCompileTime, @@ -209,10 +205,7 @@ template class DenseBase && "DenseBase::resize() does not actually allow to resize."); } - /** \returns the pointer increment between two consecutive elements. - * - * \note For vectors, the storage order is ignored. For matrices (non-vectors), we're looking - * at the increment between two consecutive elements within a slice in the inner direction. + /** \returns the pointer increment between two consecutive elements within a slice in the inner direction. * * \sa outerStride(), rowStride(), colStride() */ @@ -226,9 +219,6 @@ template class DenseBase /** \returns the pointer increment between two consecutive inner slices (for example, between two consecutive columns * in a column-major matrix). * - * \note For vectors, the storage order is ignored, there is only one inner slice, and so this method returns 1. - * For matrices (non-vectors), the notion of inner slice depends on the storage order. - * * \sa innerStride(), rowStride(), colStride() */ inline int outerStride() const diff --git a/Eigen/src/Core/DenseStorageBase.h b/Eigen/src/Core/DenseStorageBase.h index 58579b3d3..922b45be8 100644 --- a/Eigen/src/Core/DenseStorageBase.h +++ b/Eigen/src/Core/DenseStorageBase.h @@ -477,22 +477,6 @@ class DenseStorageBase : public _Base return ei_assign_selector::run(this->derived(), other.derived()); } - EIGEN_STRONG_INLINE void _check_template_params() - { - EIGEN_STATIC_ASSERT(((RowsAtCompileTime >= MaxRowsAtCompileTime) - && (ColsAtCompileTime >= MaxColsAtCompileTime) - && (MaxRowsAtCompileTime >= 0) - && (MaxColsAtCompileTime >= 0) - && (RowsAtCompileTime <= Dynamic) - && (ColsAtCompileTime <= Dynamic) - && (MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime==Dynamic) - && (MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime==Dynamic) - && ((MaxRowsAtCompileTime==Dynamic?1:MaxRowsAtCompileTime)*(MaxColsAtCompileTime==Dynamic?1:MaxColsAtCompileTime) EIGEN_STRONG_INLINE void _init2(int rows, int cols, typename ei_enable_if::type* = 0) { @@ -521,6 +505,26 @@ class DenseStorageBase : public _Base enum { SwapPointers = ei_is_same_type::ret && Base::SizeAtCompileTime==Dynamic }; ei_matrix_swap_impl::run(this->derived(), other.const_cast_derived()); } + + public: +#ifndef EIGEN_PARSED_BY_DOXYGEN + EIGEN_STRONG_INLINE static void _check_template_params() + { + EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(RowsAtCompileTime==1 && ColsAtCompileTime!=1, (_Options&RowMajor)==RowMajor) + && EIGEN_IMPLIES(ColsAtCompileTime==1 && RowsAtCompileTime!=1, (_Options&RowMajor)==0) + && (RowsAtCompileTime >= MaxRowsAtCompileTime) + && (ColsAtCompileTime >= MaxColsAtCompileTime) + && (MaxRowsAtCompileTime >= 1) + && (MaxColsAtCompileTime >= 1) + && (RowsAtCompileTime <= Dynamic) + && (ColsAtCompileTime <= Dynamic) + && (MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime==Dynamic) + && (MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime==Dynamic) + && ((MaxRowsAtCompileTime==Dynamic?1:MaxRowsAtCompileTime)*(MaxColsAtCompileTime==Dynamic?1:MaxColsAtCompileTime) class Map * \param stride optional Stride object, passing the strides. */ inline Map(const Scalar* data, const StrideType& stride = StrideType()) - : Base(data), m_stride(stride) {} + : Base(data), m_stride(stride) + { + MatrixType::Base::_check_template_params(); + } /** Constructor in the dynamic-size vector case. * @@ -137,7 +140,10 @@ template class Map * \param stride optional Stride object, passing the strides. */ inline Map(const Scalar* data, int size, const StrideType& stride = StrideType()) - : Base(data, size), m_stride(stride) {} + : Base(data, size), m_stride(stride) + { + MatrixType::Base::_check_template_params(); + } /** Constructor in the dynamic-size matrix case. * @@ -147,7 +153,11 @@ template class Map * \param stride optional Stride object, passing the strides. */ inline Map(const Scalar* data, int rows, int cols, const StrideType& stride = StrideType()) - : Base(data, rows, cols), m_stride(stride) {} + : Base(data, rows, cols), m_stride(stride) + { + MatrixType::Base::_check_template_params(); + } + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map) diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index aa01fdab2..d0ba7328f 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -32,8 +32,13 @@ template struct NumTraits; template struct EigenBase; template class Matrix; + int _Options = AutoAlign | + ( (_Rows==1 && _Cols!=1) ? RowMajor + : (_Cols==1 && _Rows!=1) ? ColMajor + : EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ), + int _MaxRows = _Rows, + int _MaxCols = _Cols +> class Matrix; template class Flagged; template class StorageBase > class NoAlias; diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 94c15f0a7..73e733cb3 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -317,6 +317,7 @@ using Eigen::ei_cos; #define EIGEN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b) #define EIGEN_LOGICAL_XOR(a,b) (((a) || (b)) && !((a) && (b))) +#define EIGEN_IMPLIES(a,b) (!(a) || (b)) #define EIGEN_MAKE_CWISE_BINARY_OP(METHOD,FUNCTOR) \ template \