aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Eigen/src/Core/Block.h13
-rw-r--r--Eigen/src/Core/DenseBase.h14
-rw-r--r--Eigen/src/Core/DenseStorageBase.h36
-rw-r--r--Eigen/src/Core/Map.h16
-rw-r--r--Eigen/src/Core/util/ForwardDeclarations.h9
-rw-r--r--Eigen/src/Core/util/Macros.h1
6 files changed, 52 insertions, 37 deletions
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<Block<MatrixType, BlockRows, BlockCols, _DirectAccessStatus> >
: (BlockRows==Dynamic ? int(ei_traits<MatrixType>::MaxRowsAtCompileTime) : BlockRows),
MaxColsAtCompileTime = ColsAtCompileTime == 1 ? 1
: (BlockCols==Dynamic ? int(ei_traits<MatrixType>::MaxColsAtCompileTime) : BlockCols),
- RowMajor = int(ei_traits<MatrixType>::Flags)&RowMajorBit,
+ MatrixTypeIsRowMajor = int(ei_traits<MatrixType>::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<Scalar>::size))
+ MaskPacketAccessBit = (InnerSize == Dynamic || (InnerSize % ei_packet_traits<Scalar>::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<MatrixType>::Flags & (HereditaryBits | MaskPacketAccessBit | DirectAccessBit)) | FlagsLinearAccessBit
+ Flags0 = ei_traits<MatrixType>::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<typename Derived> 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<typename Derived> 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<typename Derived> 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<Derived>
return ei_assign_selector<Derived,OtherDerived,false>::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)<Dynamic)
- && (_Options & (DontAlign|RowMajor)) == _Options),
- INVALID_MATRIX_TEMPLATE_PARAMETERS)
- }
-
-
template<typename T0, typename T1>
EIGEN_STRONG_INLINE void _init2(int rows, int cols, typename ei_enable_if<Base::SizeAtCompileTime!=2,T0>::type* = 0)
{
@@ -521,6 +505,26 @@ class DenseStorageBase : public _Base<Derived>
enum { SwapPointers = ei_is_same_type<Derived, OtherDerived>::ret && Base::SizeAtCompileTime==Dynamic };
ei_matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::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)<Dynamic)
+ && (_Options & (DontAlign|RowMajor)) == _Options),
+ INVALID_MATRIX_TEMPLATE_PARAMETERS)
+ }
+#endif
};
diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h
index 6e9a5439e..0608c784f 100644
--- a/Eigen/src/Core/Map.h
+++ b/Eigen/src/Core/Map.h
@@ -128,7 +128,10 @@ template<typename MatrixType, int Options, typename StrideType> 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<typename MatrixType, int Options, typename StrideType> 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<typename MatrixType, int Options, typename StrideType> 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<typename T> struct NumTraits;
template<typename Derived> struct EigenBase;
template<typename _Scalar, int _Rows, int _Cols,
- int _Options = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION | AutoAlign,
- int _MaxRows = _Rows, int _MaxCols = _Cols> 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<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged;
template<typename ExpressionType, template <typename> 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<typename OtherDerived> \