diff options
28 files changed, 236 insertions, 285 deletions
diff --git a/Eigen/src/Array/Array.h b/Eigen/src/Array/Array.h index ceef71afd..533d638a4 100644 --- a/Eigen/src/Array/Array.h +++ b/Eigen/src/Array/Array.h @@ -213,6 +213,9 @@ class Array void swap(ArrayBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other) { this->_swap(other.derived()); } + inline int innerStride() const { return 1; } + inline int outerStride() const { return this->innerSize(); } + #ifdef EIGEN_ARRAY_PLUGIN #include EIGEN_ARRAY_PLUGIN #endif diff --git a/Eigen/src/Array/ArrayWrapper.h b/Eigen/src/Array/ArrayWrapper.h index 75bc33770..0075dd537 100644 --- a/Eigen/src/Array/ArrayWrapper.h +++ b/Eigen/src/Array/ArrayWrapper.h @@ -55,7 +55,8 @@ class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> > inline int rows() const { return m_expression.rows(); } inline int cols() const { return m_expression.cols(); } - inline int stride() const { return m_expression.stride(); } + inline int outerStride() const { return m_expression.outerStride(); } + inline int innerStride() const { return m_expression.innerStride(); } inline const CoeffReturnType coeff(int row, int col) const { @@ -139,7 +140,8 @@ class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> > inline int rows() const { return m_expression.rows(); } inline int cols() const { return m_expression.cols(); } - inline int stride() const { return m_expression.stride(); } + inline int outerStride() const { return m_expression.outerStride(); } + inline int innerStride() const { return m_expression.innerStride(); } inline const CoeffReturnType coeff(int row, int col) const { diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index 174fd0080..3133aa03a 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -55,7 +55,9 @@ private: }; enum { - StorageOrdersAgree = (int(Derived::Flags)&RowMajorBit)==(int(OtherDerived::Flags)&RowMajorBit), + LhsIsEffectivelyRowMajor = (Derived::RowsAtCompileTime==1) || (int(Derived::Flags)&RowMajorBit), + RhsIsEffectivelyRowMajor = (OtherDerived::RowsAtCompileTime==1) || (int(OtherDerived::Flags)&RowMajorBit), + StorageOrdersAgree = (LhsIsEffectivelyRowMajor == RhsIsEffectivelyRowMajor), MightVectorize = StorageOrdersAgree && (int(Derived::Flags) & int(OtherDerived::Flags) & ActualPacketAccessBit), MayInnerVectorize = MightVectorize && int(InnerSize)!=Dynamic && int(InnerSize)%int(PacketSize)==0 @@ -139,17 +141,13 @@ template<typename Derived1, typename Derived2, int Index, int Stop> struct ei_assign_DefaultTraversal_CompleteUnrolling { enum { - row = int(Derived1::Flags)&RowMajorBit - ? Index / int(Derived1::ColsAtCompileTime) - : Index % Derived1::RowsAtCompileTime, - col = int(Derived1::Flags)&RowMajorBit - ? Index % int(Derived1::ColsAtCompileTime) - : Index / Derived1::RowsAtCompileTime + outer = Index / Derived1::InnerSizeAtCompileTime, + inner = Index % Derived1::InnerSizeAtCompileTime }; EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { - dst.copyCoeff(row, col, src); + dst.copyCoeffByOuterInner(outer, inner, src); ei_assign_DefaultTraversal_CompleteUnrolling<Derived1, Derived2, Index+1, Stop>::run(dst, src); } }; @@ -163,13 +161,10 @@ struct ei_assign_DefaultTraversal_CompleteUnrolling<Derived1, Derived2, Stop, St template<typename Derived1, typename Derived2, int Index, int Stop> struct ei_assign_DefaultTraversal_InnerUnrolling { - EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src, int row_or_col) + EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src, int outer) { - const bool rowMajor = int(Derived1::Flags)&RowMajorBit; - const int row = rowMajor ? row_or_col : Index; - const int col = rowMajor ? Index : row_or_col; - dst.copyCoeff(row, col, src); - ei_assign_DefaultTraversal_InnerUnrolling<Derived1, Derived2, Index+1, Stop>::run(dst, src, row_or_col); + dst.copyCoeffByOuterInner(outer, Index, src); + ei_assign_DefaultTraversal_InnerUnrolling<Derived1, Derived2, Index+1, Stop>::run(dst, src, outer); } }; @@ -207,18 +202,14 @@ template<typename Derived1, typename Derived2, int Index, int Stop> struct ei_assign_innervec_CompleteUnrolling { enum { - row = int(Derived1::Flags)&RowMajorBit - ? Index / int(Derived1::ColsAtCompileTime) - : Index % Derived1::RowsAtCompileTime, - col = int(Derived1::Flags)&RowMajorBit - ? Index % int(Derived1::ColsAtCompileTime) - : Index / Derived1::RowsAtCompileTime, + outer = Index / Derived1::InnerSizeAtCompileTime, + inner = Index % Derived1::InnerSizeAtCompileTime, JointAlignment = ei_assign_traits<Derived1,Derived2>::JointAlignment }; EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { - dst.template copyPacket<Derived2, Aligned, JointAlignment>(row, col, src); + dst.template copyPacketByOuterInner<Derived2, Aligned, JointAlignment>(outer, inner, src); ei_assign_innervec_CompleteUnrolling<Derived1, Derived2, Index+ei_packet_traits<typename Derived1::Scalar>::size, Stop>::run(dst, src); } @@ -233,13 +224,11 @@ struct ei_assign_innervec_CompleteUnrolling<Derived1, Derived2, Stop, Stop> template<typename Derived1, typename Derived2, int Index, int Stop> struct ei_assign_innervec_InnerUnrolling { - EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src, int row_or_col) + EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src, int outer) { - const int row = int(Derived1::Flags)&RowMajorBit ? row_or_col : Index; - const int col = int(Derived1::Flags)&RowMajorBit ? Index : row_or_col; - dst.template copyPacket<Derived2, Aligned, Aligned>(row, col, src); + dst.template copyPacketByOuterInner<Derived2, Aligned, Aligned>(outer, Index, src); ei_assign_innervec_InnerUnrolling<Derived1, Derived2, - Index+ei_packet_traits<typename Derived1::Scalar>::size, Stop>::run(dst, src, row_or_col); + Index+ei_packet_traits<typename Derived1::Scalar>::size, Stop>::run(dst, src, outer); } }; @@ -267,29 +256,11 @@ struct ei_assign_impl<Derived1, Derived2, DefaultTraversal, NoUnrolling> { inline static void run(Derived1 &dst, const Derived2 &src) { - if(Derived1::ColsAtCompileTime == 1) - { - for(int i = 0; i < dst.rows(); ++i) - dst.copyCoeff(i, 0, src); - } - else if(Derived1::RowsAtCompileTime == 1) - { - for(int i = 0; i < dst.cols(); ++i) - dst.copyCoeff(0, i, src); - } - else - { - const int innerSize = dst.innerSize(); - const int outerSize = dst.outerSize(); - for(int j = 0; j < outerSize; ++j) - for(int i = 0; i < innerSize; ++i) - { - if(int(Derived1::Flags)&RowMajorBit) - dst.copyCoeff(j, i, src); - else - dst.copyCoeff(i, j, src); - } - } + const int innerSize = dst.innerSize(); + const int outerSize = dst.outerSize(); + for(int outer = 0; outer < outerSize; ++outer) + for(int inner = 0; inner < innerSize; ++inner) + dst.copyCoeffByOuterInner(outer, inner, src); } }; @@ -308,12 +279,10 @@ struct ei_assign_impl<Derived1, Derived2, DefaultTraversal, InnerUnrolling> { EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { - const bool rowMajor = int(Derived1::Flags)&RowMajorBit; - const int innerSize = rowMajor ? Derived1::ColsAtCompileTime : Derived1::RowsAtCompileTime; const int outerSize = dst.outerSize(); - for(int j = 0; j < outerSize; ++j) - ei_assign_DefaultTraversal_InnerUnrolling<Derived1, Derived2, 0, innerSize> - ::run(dst, src, j); + for(int outer = 0; outer < outerSize; ++outer) + ei_assign_DefaultTraversal_InnerUnrolling<Derived1, Derived2, 0, Derived1::InnerSizeAtCompileTime> + ::run(dst, src, outer); } }; @@ -354,14 +323,9 @@ struct ei_assign_impl<Derived1, Derived2, InnerVectorizedTraversal, NoUnrolling> const int innerSize = dst.innerSize(); const int outerSize = dst.outerSize(); const int packetSize = ei_packet_traits<typename Derived1::Scalar>::size; - for(int j = 0; j < outerSize; ++j) - for(int i = 0; i < innerSize; i+=packetSize) - { - if(int(Derived1::Flags)&RowMajorBit) - dst.template copyPacket<Derived2, Aligned, Aligned>(j, i, src); - else - dst.template copyPacket<Derived2, Aligned, Aligned>(i, j, src); - } + for(int outer = 0; outer < outerSize; ++outer) + for(int inner = 0; inner < innerSize; inner+=packetSize) + dst.template copyPacketByOuterInner<Derived2, Aligned, Aligned>(outer, inner, src); } }; @@ -380,12 +344,10 @@ struct ei_assign_impl<Derived1, Derived2, InnerVectorizedTraversal, InnerUnrolli { EIGEN_STRONG_INLINE static void run(Derived1 &dst, const Derived2 &src) { - const bool rowMajor = int(Derived1::Flags)&RowMajorBit; - const int innerSize = rowMajor ? Derived1::ColsAtCompileTime : Derived1::RowsAtCompileTime; const int outerSize = dst.outerSize(); - for(int j = 0; j < outerSize; ++j) - ei_assign_innervec_InnerUnrolling<Derived1, Derived2, 0, innerSize> - ::run(dst, src, j); + for(int outer = 0; outer < outerSize; ++outer) + ei_assign_innervec_InnerUnrolling<Derived1, Derived2, 0, Derived1::InnerSizeAtCompileTime> + ::run(dst, src, outer); } }; @@ -471,36 +433,20 @@ struct ei_assign_impl<Derived1, Derived2, SliceVectorizedTraversal, NoUnrolling> int alignedStart = ei_assign_traits<Derived1,Derived2>::DstIsAligned ? 0 : ei_first_aligned(&dst.coeffRef(0,0), innerSize); - for(int i = 0; i < outerSize; ++i) + for(int outer = 0; outer < outerSize; ++outer) { const int alignedEnd = alignedStart + ((innerSize-alignedStart) & ~packetAlignedMask); - // do the non-vectorizable part of the assignment - for (int index = 0; index<alignedStart ; ++index) - { - if(Derived1::Flags&RowMajorBit) - dst.copyCoeff(i, index, src); - else - dst.copyCoeff(index, i, src); - } + for(int inner = 0; inner<alignedStart ; ++inner) + dst.copyCoeffByOuterInner(outer, inner, src); // do the vectorizable part of the assignment - for (int index = alignedStart; index<alignedEnd; index+=packetSize) - { - if(Derived1::Flags&RowMajorBit) - dst.template copyPacket<Derived2, Aligned, Unaligned>(i, index, src); - else - dst.template copyPacket<Derived2, Aligned, Unaligned>(index, i, src); - } + for(int inner = alignedStart; inner<alignedEnd; inner+=packetSize) + dst.template copyPacketByOuterInner<Derived2, Aligned, Unaligned>(outer, inner, src); // do the non-vectorizable part of the assignment - for (int index = alignedEnd; index<innerSize ; ++index) - { - if(Derived1::Flags&RowMajorBit) - dst.copyCoeff(i, index, src); - else - dst.copyCoeff(index, i, src); - } + for(int inner = alignedEnd; inner<innerSize ; ++inner) + dst.copyCoeffByOuterInner(outer, inner, src); alignedStart = std::min<int>((alignedStart+alignedStep)%packetSize, innerSize); } @@ -519,14 +465,6 @@ EIGEN_STRONG_INLINE Derived& DenseBase<Derived> EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived) EIGEN_STATIC_ASSERT((ei_is_same_type<typename Derived::Scalar, typename OtherDerived::Scalar>::ret), YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) - if(Derived::ColsAtCompileTime == 1) - { - ei_assert(OtherDerived::RowsAtCompileTime == 1 || other.cols() == 1); - } - if(Derived::RowsAtCompileTime == 1) - { - ei_assert(OtherDerived::ColsAtCompileTime == 1 || other.rows() == 1); - } #ifdef EIGEN_DEBUG_ASSIGN ei_assign_traits<Derived, OtherDerived>::debug(); #endif diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 8a7aea91f..d3c4dfa99 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -80,20 +80,6 @@ struct ei_traits<Block<MatrixType, BlockRows, BlockCols, _DirectAccessStatus> > }; }; -template<typename MatrixType, int BlockRows, int BlockCols> -struct ei_traits<Block<MatrixType, BlockRows, BlockCols, true> > : ei_traits<Block<MatrixType, BlockRows, BlockCols, false> > -{ - enum { - InnerStrideAtCompileTime = - (BlockRows==1 && !(int(MatrixType::Flags)&RowMajorBit)) - || (BlockCols==1 && (int(MatrixType::Flags)&RowMajorBit)) - ? MatrixType::OuterStrideAtCompileTime - : MatrixType::InnerStrideAtCompileTime, - OuterStrideAtCompileTime = - (BlockRows==1||BlockCols==1) ? 0 : MatrixType::OuterStrideAtCompileTime - }; -}; - template<typename MatrixType, int BlockRows, int BlockCols, int _DirectAccessStatus> class Block : public MatrixType::template MakeBase< Block<MatrixType, BlockRows, BlockCols, _DirectAccessStatus> >::Type { @@ -114,8 +100,8 @@ template<typename MatrixType, int BlockRows, int BlockCols, int _DirectAccessSta // The case a 1x1 matrix seems ambiguous, but the result is the same anyway. m_startRow( (BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) ? i : 0), m_startCol( (BlockRows==MatrixType::RowsAtCompileTime) && (BlockCols==1) ? i : 0), - m_blockRows(matrix.rows()), // if it is a row, then m_blockRows has a fixed-size of 1, so no pb to try to overwrite it - m_blockCols(matrix.cols()) // same for m_blockCols + m_blockRows(BlockRows==1 ? 1 : matrix.rows()), + m_blockCols(BlockCols==1 ? 1 : matrix.cols()) { ei_assert( (i>=0) && ( ((BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) && i<matrix.rows()) @@ -126,7 +112,7 @@ template<typename MatrixType, int BlockRows, int BlockCols, int _DirectAccessSta */ inline Block(const MatrixType& matrix, int startRow, int startCol) : m_matrix(matrix), m_startRow(startRow), m_startCol(startCol), - m_blockRows(matrix.rows()), m_blockCols(matrix.cols()) + m_blockRows(BlockRows), m_blockCols(BlockCols) { EIGEN_STATIC_ASSERT(RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE) ei_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= matrix.rows() @@ -277,16 +263,15 @@ class Block<MatrixType,BlockRows,BlockCols,HasDirectAccess> /** \sa MapBase::innerStride() */ inline int innerStride() const { - return (RowsAtCompileTime==1 && !(int(MatrixType::Flags)&RowMajorBit)) - || (ColsAtCompileTime==1 && (int(MatrixType::Flags)&RowMajorBit)) - ? m_matrix.outerStride() - : m_matrix.innerStride(); + return RowsAtCompileTime==1 ? m_matrix.colStride() + : ColsAtCompileTime==1 ? m_matrix.rowStride() + : m_matrix.innerStride(); } /** \sa MapBase::outerStride() */ inline int outerStride() const { - return IsVectorAtCompileTime ? 0 : m_matrix.outerStride(); + return IsVectorAtCompileTime ? this->size() : m_matrix.outerStride(); } #ifndef __SUNPRO_CC diff --git a/Eigen/src/Core/Coeffs.h b/Eigen/src/Core/Coeffs.h index ebfd0c80e..da7b9153f 100644 --- a/Eigen/src/Core/Coeffs.h +++ b/Eigen/src/Core/Coeffs.h @@ -25,6 +25,24 @@ #ifndef EIGEN_COEFFS_H #define EIGEN_COEFFS_H +template<typename Derived> +EIGEN_STRONG_INLINE int DenseBase<Derived>::rowIndexByOuterInner(int outer, int inner) +{ + return int(Derived::RowsAtCompileTime) == 1 ? 0 + : int(Derived::ColsAtCompileTime) == 1 ? inner + : int(Derived::Flags)&RowMajorBit ? outer + : inner; +} + +template<typename Derived> +EIGEN_STRONG_INLINE int DenseBase<Derived>::colIndexByOuterInner(int outer, int inner) +{ + return int(Derived::ColsAtCompileTime) == 1 ? 0 + : int(Derived::RowsAtCompileTime) == 1 ? inner + : int(Derived::Flags)&RowMajorBit ? inner + : outer; +} + /** Short version: don't use this function, use * \link operator()(int,int) const \endlink instead. * @@ -48,6 +66,14 @@ EIGEN_STRONG_INLINE const typename DenseBase<Derived>::CoeffReturnType DenseBase return derived().coeff(row, col); } +template<typename Derived> +EIGEN_STRONG_INLINE const typename DenseBase<Derived>::CoeffReturnType DenseBase<Derived> + ::coeffByOuterInner(int outer, int inner) const +{ + return coeff(rowIndexByOuterInner(outer, inner), + colIndexByOuterInner(outer, inner)); +} + /** \returns the coefficient at given the given row and column. * * \sa operator()(int,int), operator[](int) const @@ -84,6 +110,14 @@ EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& DenseBase<Derived> return derived().coeffRef(row, col); } +template<typename Derived> +EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& DenseBase<Derived> + ::coeffRefByOuterInner(int outer, int inner) +{ + return coeffRef(rowIndexByOuterInner(outer, inner), + colIndexByOuterInner(outer, inner)); +} + /** \returns a reference to the coefficient at given the given row and column. * * \sa operator()(int,int) const, operator[](int) @@ -261,6 +295,15 @@ DenseBase<Derived>::packet(int row, int col) const return derived().template packet<LoadMode>(row,col); } +template<typename Derived> +template<int LoadMode> +EIGEN_STRONG_INLINE typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type +DenseBase<Derived>::packetByOuterInner(int outer, int inner) const +{ + return packet<LoadMode>(rowIndexByOuterInner(outer, inner), + colIndexByOuterInner(outer, inner)); +} + /** Stores the given packet of coefficients, at the given row and column of this expression. It is your responsibility * to ensure that a packet really starts there. This method is only available on expressions having the * PacketAccessBit. @@ -279,6 +322,16 @@ EIGEN_STRONG_INLINE void DenseBase<Derived>::writePacket derived().template writePacket<StoreMode>(row,col,x); } +template<typename Derived> +template<int StoreMode> +EIGEN_STRONG_INLINE void DenseBase<Derived>::writePacketByOuterInner +(int outer, int inner, const typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type& x) +{ + writePacket<StoreMode>(rowIndexByOuterInner(outer, inner), + colIndexByOuterInner(outer, inner), + x); +} + /** \returns the packet of coefficients starting at the given index. It is your responsibility * to ensure that a packet really starts there. This method is only available on expressions having the * PacketAccessBit and the LinearAccessBit. @@ -346,6 +399,16 @@ EIGEN_STRONG_INLINE void DenseBase<Derived>::copyCoeff(int index, const DenseBas derived().coeffRef(index) = other.derived().coeff(index); } +template<typename Derived> +template<typename OtherDerived> +EIGEN_STRONG_INLINE void DenseBase<Derived>::copyCoeffByOuterInner(int outer, int inner, const DenseBase<OtherDerived>& other) +{ + const int row = Derived::rowIndexByOuterInner(outer,inner); + const int col = Derived::colIndexByOuterInner(outer,inner); + // derived() is important here: copyCoeff() may be reimplemented in Derived! + derived().copyCoeff(row, col, other); +} + /** \internal Copies the packet at position (row,col) of other into *this. * * This method is overridden in SwapWrapper, allowing swap() assignments to share 99% of their code @@ -379,6 +442,16 @@ EIGEN_STRONG_INLINE void DenseBase<Derived>::copyPacket(int index, const DenseBa other.derived().template packet<LoadMode>(index)); } +template<typename Derived> +template<typename OtherDerived, int StoreMode, int LoadMode> +EIGEN_STRONG_INLINE void DenseBase<Derived>::copyPacketByOuterInner(int outer, int inner, const DenseBase<OtherDerived>& other) +{ + const int row = Derived::rowIndexByOuterInner(outer,inner); + const int col = Derived::colIndexByOuterInner(outer,inner); + // derived() is important here: copyCoeff() may be reimplemented in Derived! + derived().copyPacket<OtherDerived, StoreMode, LoadMode>(row, col, other); +} + template<typename Derived, bool JustReturnZero> struct ei_first_aligned_impl { diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index d8f789ae0..2078f023b 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -124,6 +124,11 @@ template<typename Derived> class DenseBase * constructed from this one. See the \ref flags "list of flags". */ + IsRowMajor = int(Flags) & RowMajorBit, /**< True if this expression is row major. */ + + InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? SizeAtCompileTime + : int(Flags)&RowMajorBit ? ColsAtCompileTime : RowsAtCompileTime, + CoeffReadCost = ei_traits<Derived>::CoeffReadCost, /**< This is a rough measure of how expensive it is to read one coefficient from * this expression. @@ -200,20 +205,64 @@ template<typename Derived> class DenseBase && "DenseBase::resize() does not actually allow to resize."); } - int innerStride() const + /** \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. + * + * \sa outerStride(), rowStride(), colStride() + */ + inline int innerStride() const { EIGEN_STATIC_ASSERT(int(Flags)&DirectAccessBit, THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES) return derived().innerStride(); } - int outerStride() const + /** \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 { EIGEN_STATIC_ASSERT(int(Flags)&DirectAccessBit, THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES) return derived().outerStride(); } + inline int stride() const + { + return IsVectorAtCompileTime ? innerStride() : outerStride(); + } + + /** \returns the pointer increment between two consecutive rows. + * + * \sa innerStride(), outerStride(), colStride() + */ + inline int rowStride() const + { + return ColsAtCompileTime==1 ? innerStride() + : RowsAtCompileTime==1 ? outerStride() + : IsRowMajor ? outerStride() + : innerStride(); + } + + /** \returns the pointer increment between two consecutive columns. + * + * \sa innerStride(), outerStride(), rowStride() + */ + inline int colStride() const + { + return ColsAtCompileTime==1 ? outerStride() + : RowsAtCompileTime==1 ? innerStride() + : IsRowMajor ? innerStride() + : outerStride(); + } + #ifndef EIGEN_PARSED_BY_DOXYGEN /** \internal the return type of coeff() */ @@ -269,9 +318,11 @@ template<typename Derived> class DenseBase CommaInitializer<Derived> operator<< (const DenseBase<OtherDerived>& other); const CoeffReturnType coeff(int row, int col) const; + const CoeffReturnType coeffByOuterInner(int outer, int inner) const; const CoeffReturnType operator()(int row, int col) const; Scalar& coeffRef(int row, int col); + Scalar& coeffRefByOuterInner(int outer, int inner); Scalar& operator()(int row, int col); const CoeffReturnType coeff(int index) const; @@ -286,17 +337,30 @@ template<typename Derived> class DenseBase template<typename OtherDerived> void copyCoeff(int row, int col, const DenseBase<OtherDerived>& other); template<typename OtherDerived> + void copyCoeffByOuterInner(int outer, int inner, const DenseBase<OtherDerived>& other); + template<typename OtherDerived> void copyCoeff(int index, const DenseBase<OtherDerived>& other); template<typename OtherDerived, int StoreMode, int LoadMode> void copyPacket(int row, int col, const DenseBase<OtherDerived>& other); template<typename OtherDerived, int StoreMode, int LoadMode> + void copyPacketByOuterInner(int outer, int inner, const DenseBase<OtherDerived>& other); + template<typename OtherDerived, int StoreMode, int LoadMode> void copyPacket(int index, const DenseBase<OtherDerived>& other); + + private: + static int rowIndexByOuterInner(int outer, int inner); + static int colIndexByOuterInner(int outer, int inner); + public: #endif // not EIGEN_PARSED_BY_DOXYGEN template<int LoadMode> PacketScalar packet(int row, int col) const; + template<int LoadMode> + PacketScalar packetByOuterInner(int outer, int inner) const; template<int StoreMode> void writePacket(int row, int col, const PacketScalar& x); + template<int StoreMode> + void writePacketByOuterInner(int outer, int inner, const PacketScalar& x); template<int LoadMode> PacketScalar packet(int index) const; diff --git a/Eigen/src/Core/DenseStorageBase.h b/Eigen/src/Core/DenseStorageBase.h index 04dfb1176..e93e439e6 100644 --- a/Eigen/src/Core/DenseStorageBase.h +++ b/Eigen/src/Core/DenseStorageBase.h @@ -75,23 +75,6 @@ class DenseStorageBase : public _Base<Derived> EIGEN_STRONG_INLINE int rows() const { return m_storage.rows(); } EIGEN_STRONG_INLINE int cols() const { return m_storage.cols(); } - /** Returns the leading dimension (for matrices) or the increment (for vectors) to be used with data(). - * - * More precisely: - * - for a column major matrix it returns the number of elements between two successive columns - * - for a row major matrix it returns the number of elements between two successive rows - * - for a vector it returns the number of elements between two successive coefficients - * This function has to be used together with the MapBase::data() function. - * - * \sa data() */ - EIGEN_STRONG_INLINE int stride() const - { - if(IsVectorAtCompileTime) - return 1; - else - return (Flags & RowMajorBit) ? m_storage.cols() : m_storage.rows(); - } - EIGEN_STRONG_INLINE const Scalar& coeff(int row, int col) const { if(Flags & RowMajorBit) @@ -253,13 +236,13 @@ class DenseStorageBase : public _Base<Derived> { if(RowsAtCompileTime == 1) { - ei_assert(other.rows() == 1); - resize(1, other.cols()); + ei_assert(other.rows() == 1 || other.cols() == 1); + resize(1, other.size()); } else if(ColsAtCompileTime == 1) { - ei_assert(other.cols() == 1); - resize(other.rows(), 1); + ei_assert(other.rows() == 1 || other.cols() == 1); + resize(other.size(), 1); } else resize(other.rows(), other.cols()); } diff --git a/Eigen/src/Core/Flagged.h b/Eigen/src/Core/Flagged.h index 7f42a1e73..9d14aceaa 100644 --- a/Eigen/src/Core/Flagged.h +++ b/Eigen/src/Core/Flagged.h @@ -60,7 +60,8 @@ template<typename ExpressionType, unsigned int Added, unsigned int Removed> clas inline int rows() const { return m_matrix.rows(); } inline int cols() const { return m_matrix.cols(); } - inline int stride() const { return m_matrix.stride(); } + inline int outerStride() const { return m_matrix.outerStride(); } + inline int innerStride() const { return m_matrix.innerStride(); } inline const Scalar coeff(int row, int col) const { diff --git a/Eigen/src/Core/ForceAlignedAccess.h b/Eigen/src/Core/ForceAlignedAccess.h index 927f43413..300b22329 100644 --- a/Eigen/src/Core/ForceAlignedAccess.h +++ b/Eigen/src/Core/ForceAlignedAccess.h @@ -52,7 +52,8 @@ template<typename ExpressionType> class ForceAlignedAccess inline int rows() const { return m_expression.rows(); } inline int cols() const { return m_expression.cols(); } - inline int stride() const { return m_expression.stride(); } + inline int outerStride() const { return m_expression.outerStride(); } + inline int innerStride() const { return m_expression.innerStride(); } inline const CoeffReturnType coeff(int row, int col) const { diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index 432bf1661..d9ccb1b20 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -56,14 +56,8 @@ struct ei_traits<Map<MatrixType, Options, StrideType> > Flags0 = ei_traits<MatrixType>::Flags, Flags1 = ((Options&Aligned)==Aligned ? Flags0 | AlignedBit : Flags0 & ~AlignedBit), - Flags = int(StrideType::InnerStrideAtCompileTime)==1 ? Flags1 : (Flags1 & ~PacketAccessBit), - InnerStrideAtCompileTime = int(StrideType::InnerStrideAtCompileTime) != 0 ? int(StrideType::InnerStrideAtCompileTime) : 1, - OuterStrideAtCompileTime = - int(StrideType::OuterStrideAtCompileTime != 0) ? int(StrideType::OuterStrideAtCompileTime) - : int(MatrixType::IsVectorAtCompileTime) ? int(MatrixType::SizeAtCompileTime) - : int(Flags)&RowMajorBit ? int(MatrixType::ColsAtCompileTime) - : int(MatrixType::RowsAtCompileTime) - }; + Flags = int(StrideType::InnerStrideAtCompileTime)==1 ? Flags1 : (Flags1 & ~PacketAccessBit) + }; }; template<typename MatrixType, int Options, typename StrideType> class Map diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index 6bac2ed4c..d735cfc47 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -38,57 +38,22 @@ template<typename Derived, typename Base> class MapBase public: enum { - IsRowMajor = (int(ei_traits<Derived>::Flags) & RowMajorBit) ? 1 : 0, RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime, ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime, - SizeAtCompileTime = Base::SizeAtCompileTime, - InnerStrideAtCompileTime = ei_traits<Derived>::InnerStrideAtCompileTime + SizeAtCompileTime = Base::SizeAtCompileTime }; typedef typename ei_traits<Derived>::Scalar Scalar; typedef typename Base::PacketScalar PacketScalar; using Base::derived; + using Base::innerStride; + using Base::outerStride; + using Base::rowStride; + using Base::colStride; inline int rows() const { return m_rows.value(); } inline int cols() const { return m_cols.value(); } - /** \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. - * - * \sa outerStride(), data(), rowStride(), colStride() - */ - inline int innerStride() const { return derived().innerStride(); } - - /** \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(), data(), rowStride(), colStride() - */ - inline int outerStride() const { return derived().outerStride(); } - - /** \returns the pointer increment between two consecutive rows. - * - * \sa data(), innerStride(), outerStride(), colStride() - */ - inline int rowStride() const - { - return (RowsAtCompileTime==1 || IsRowMajor) ? outerStride() : innerStride(); - } - - /** \returns the pointer increment between two consecutive columns. - * - * \sa data(), innerStride(), outerStride(), rowStride() - */ - inline int colStride() const - { - return (RowsAtCompileTime==1 || IsRowMajor) ? innerStride() : outerStride(); - } - /** Returns a pointer to the first coefficient of the matrix or vector. * * \note When addressing this data, make sure to honor the strides returned by innerStride() and outerStride(). diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index e011ae8b9..b494b2f00 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -120,10 +120,7 @@ struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > MaxRowsAtCompileTime = _MaxRows, MaxColsAtCompileTime = _MaxCols, Flags = ei_compute_matrix_flags<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ret, - CoeffReadCost = NumTraits<Scalar>::ReadCost, - InnerStrideAtCompileTime = 1, - OuterStrideAtCompileTime = (RowsAtCompileTime==1||ColsAtCompileTime==1) ? 1 - : (int(Flags)&RowMajorBit) ? RowsAtCompileTime : ColsAtCompileTime + CoeffReadCost = NumTraits<Scalar>::ReadCost }; }; diff --git a/Eigen/src/Core/NestByValue.h b/Eigen/src/Core/NestByValue.h index 9f6d1c0c0..497ce828b 100644 --- a/Eigen/src/Core/NestByValue.h +++ b/Eigen/src/Core/NestByValue.h @@ -53,7 +53,8 @@ template<typename ExpressionType> class NestByValue inline int rows() const { return m_expression.rows(); } inline int cols() const { return m_expression.cols(); } - inline int stride() const { return m_expression.stride(); } + inline int outerStride() const { return m_expression.outerStride(); } + inline int innerStride() const { return m_expression.innerStride(); } inline const CoeffReturnType coeff(int row, int col) const { diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 53277169c..af05773ee 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -336,7 +336,7 @@ template<> struct ei_gemv_selector<OnTheRight,ColMajor,true> ei_cache_friendly_product_colmajor_times_vector <LhsBlasTraits::NeedToConjugate,RhsBlasTraits::NeedToConjugate>( dest.size(), - &actualLhs.const_cast_derived().coeffRef(0,0), ei_outer_stride_or_outer_size(actualLhs), + &actualLhs.const_cast_derived().coeffRef(0,0), actualLhs.stride(), actualRhs, actualDest, actualAlpha); if (!EvalToDest) @@ -381,7 +381,7 @@ template<> struct ei_gemv_selector<OnTheRight,RowMajor,true> ei_cache_friendly_product_rowmajor_times_vector <LhsBlasTraits::NeedToConjugate,RhsBlasTraits::NeedToConjugate>( - &actualLhs.const_cast_derived().coeffRef(0,0), ei_outer_stride_or_outer_size(actualLhs), + &actualLhs.const_cast_derived().coeffRef(0,0), actualLhs.stride(), rhs_data, prod.rhs().size(), dest, actualAlpha); if (!DirectlyUseRhs) ei_aligned_stack_delete(Scalar, rhs_data, prod.rhs().size()); diff --git a/Eigen/src/Core/SelfAdjointView.h b/Eigen/src/Core/SelfAdjointView.h index 6d01ee495..add5a3afb 100644 --- a/Eigen/src/Core/SelfAdjointView.h +++ b/Eigen/src/Core/SelfAdjointView.h @@ -75,8 +75,9 @@ template<typename MatrixType, unsigned int UpLo> class SelfAdjointView inline int rows() const { return m_matrix.rows(); } inline int cols() const { return m_matrix.cols(); } - inline int stride() const { return m_matrix.stride(); } - + inline int outerStride() const { return m_matrix.outerStride(); } + inline int innerStride() const { return m_matrix.innerStride(); } + /** \sa MatrixBase::coeff() * \warning the coordinates must fit into the referenced triangular part */ diff --git a/Eigen/src/Core/SelfCwiseBinaryOp.h b/Eigen/src/Core/SelfCwiseBinaryOp.h index 7ae2e82a4..58aee182d 100644 --- a/Eigen/src/Core/SelfCwiseBinaryOp.h +++ b/Eigen/src/Core/SelfCwiseBinaryOp.h @@ -57,7 +57,8 @@ template<typename BinaryOp, typename MatrixType> class SelfCwiseBinaryOp inline int rows() const { return m_matrix.rows(); } inline int cols() const { return m_matrix.cols(); } - inline int stride() const { return m_matrix.stride(); } + inline int outerStride() const { return m_matrix.outerStride(); } + inline int innerStride() const { return m_matrix.innerStride(); } inline const Scalar* data() const { return m_matrix.data(); } // note that this function is needed by assign to correctly align loads/stores diff --git a/Eigen/src/Core/Stride.h b/Eigen/src/Core/Stride.h index ba0b19de3..7982035fd 100644 --- a/Eigen/src/Core/Stride.h +++ b/Eigen/src/Core/Stride.h @@ -54,20 +54,6 @@ class Stride inline int inner() const { return m_inner.value(); } inline int outer() const { return m_outer.value(); } - template<int OtherInnerStrideAtCompileTime, int OtherOuterStrideAtCompileTime> - Stride<EIGEN_ENUM_MAX(InnerStrideAtCompileTime, OtherInnerStrideAtCompileTime), - EIGEN_ENUM_MAX(OuterStrideAtCompileTime, OtherOuterStrideAtCompileTime)> - operator|(const Stride<OtherInnerStrideAtCompileTime, OtherOuterStrideAtCompileTime>& other) - { - EIGEN_STATIC_ASSERT(!((InnerStrideAtCompileTime && OtherInnerStrideAtCompileTime) - || (OuterStrideAtCompileTime && OtherOuterStrideAtCompileTime)), - YOU_ALREADY_SPECIFIED_THIS_STRIDE) - int result_inner = InnerStrideAtCompileTime ? inner() : other.inner(); - int result_outer = OuterStrideAtCompileTime ? outer() : other.outer(); - return Stride<EIGEN_ENUM_MAX(InnerStrideAtCompileTime, OtherInnerStrideAtCompileTime), - EIGEN_ENUM_MAX(OuterStrideAtCompileTime, OtherOuterStrideAtCompileTime)> - (result_inner, result_outer); - } protected: ei_int_if_dynamic<InnerStrideAtCompileTime> m_inner; ei_int_if_dynamic<OuterStrideAtCompileTime> m_outer; @@ -91,46 +77,4 @@ class OuterStride : public Stride<0, Value> OuterStride(int v) : Base(0,v) {} }; -template<typename T, bool HasDirectAccess = int(ei_traits<T>::Flags)&DirectAccessBit> -struct ei_outer_stride_or_outer_size_impl -{ - static inline int value(const T& x) { return x.outerStride(); } -}; - -template<typename T> -struct ei_outer_stride_or_outer_size_impl<T, false> -{ - static inline int value(const T& x) { return x.outerSize(); } -}; - -template<typename T> -inline int ei_outer_stride_or_outer_size(const T& x) -{ - return ei_outer_stride_or_outer_size_impl<T>::value(x); -} - -template<typename T, bool HasDirectAccess = int(ei_traits<typename ei_cleantype<T>::type>::Flags)&DirectAccessBit> -struct ei_inner_stride_at_compile_time -{ - enum { ret = ei_traits<typename ei_cleantype<T>::type>::InnerStrideAtCompileTime }; -}; - -template<typename T> -struct ei_inner_stride_at_compile_time<T, false> -{ - enum { ret = 1 }; -}; - -template<typename T, bool HasDirectAccess = int(ei_traits<typename ei_cleantype<T>::type>::Flags)&DirectAccessBit> -struct ei_outer_stride_at_compile_time -{ - enum { ret = ei_traits<typename ei_cleantype<T>::type>::OuterStrideAtCompileTime }; -}; - -template<typename T> -struct ei_outer_stride_at_compile_time<T, false> -{ - enum { ret = 1 }; -}; - #endif // EIGEN_STRIDE_H diff --git a/Eigen/src/Core/Swap.h b/Eigen/src/Core/Swap.h index 186268af0..c3c641097 100644 --- a/Eigen/src/Core/Swap.h +++ b/Eigen/src/Core/Swap.h @@ -47,7 +47,8 @@ template<typename ExpressionType> class SwapWrapper inline int rows() const { return m_expression.rows(); } inline int cols() const { return m_expression.cols(); } - inline int stride() const { return m_expression.stride(); } + inline int outerStride() const { return m_expression.outerStride(); } + inline int innerStride() const { return m_expression.innerStride(); } inline Scalar& coeffRef(int row, int col) { @@ -60,7 +61,7 @@ template<typename ExpressionType> class SwapWrapper } template<typename OtherDerived> - void copyCoeff(int row, int col, const MatrixBase<OtherDerived>& other) + void copyCoeff(int row, int col, const DenseBase<OtherDerived>& other) { OtherDerived& _other = other.const_cast_derived(); ei_internal_assert(row >= 0 && row < rows() @@ -71,7 +72,7 @@ template<typename ExpressionType> class SwapWrapper } template<typename OtherDerived> - void copyCoeff(int index, const MatrixBase<OtherDerived>& other) + void copyCoeff(int index, const DenseBase<OtherDerived>& other) { OtherDerived& _other = other.const_cast_derived(); ei_internal_assert(index >= 0 && index < m_expression.size()); @@ -81,7 +82,7 @@ template<typename ExpressionType> class SwapWrapper } template<typename OtherDerived, int StoreMode, int LoadMode> - void copyPacket(int row, int col, const MatrixBase<OtherDerived>& other) + void copyPacket(int row, int col, const DenseBase<OtherDerived>& other) { OtherDerived& _other = other.const_cast_derived(); ei_internal_assert(row >= 0 && row < rows() @@ -94,7 +95,7 @@ template<typename ExpressionType> class SwapWrapper } template<typename OtherDerived, int StoreMode, int LoadMode> - void copyPacket(int index, const MatrixBase<OtherDerived>& other) + void copyPacket(int index, const DenseBase<OtherDerived>& other) { OtherDerived& _other = other.const_cast_derived(); ei_internal_assert(index >= 0 && index < m_expression.size()); diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 753a67ee0..47dae5776 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -80,9 +80,6 @@ template<typename MatrixType> class Transpose typename ei_cleantype<typename MatrixType::Nested>::type& nestedExpression() { return m_matrix.const_cast_derived(); } - enum { InnerStrideAtCompileTime = ei_inner_stride_at_compile_time<MatrixType>::ret, - OuterStrideAtCompileTime = ei_outer_stride_at_compile_time<MatrixType>::ret }; - protected: const typename MatrixType::Nested m_matrix; }; diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h index 8bea0aa68..c61a6d7cc 100644 --- a/Eigen/src/Core/TriangularMatrix.h +++ b/Eigen/src/Core/TriangularMatrix.h @@ -50,7 +50,8 @@ template<typename Derived> class TriangularBase : public AnyMatrixBase<Derived> inline int rows() const { return derived().rows(); } inline int cols() const { return derived().cols(); } - inline int stride() const { return derived().stride(); } + inline int outerStride() const { return derived().outerStride(); } + inline int innerStride() const { return derived().innerStride(); } inline Scalar coeff(int row, int col) const { return derived().coeff(row,col); } inline Scalar& coeffRef(int row, int col) { return derived().coeffRef(row,col); } @@ -165,7 +166,8 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView inline int rows() const { return m_matrix.rows(); } inline int cols() const { return m_matrix.cols(); } - inline int stride() const { return m_matrix.stride(); } + inline int outerStride() const { return m_matrix.outerStride(); } + inline int innerStride() const { return m_matrix.innerStride(); } /** \sa MatrixBase::operator+=() */ template<typename Other> TriangularView& operator+=(const Other& other) { return *this = m_matrix + other; } diff --git a/Eigen/src/Core/VectorBlock.h b/Eigen/src/Core/VectorBlock.h index cbf97aeb3..5bb7fd35d 100644 --- a/Eigen/src/Core/VectorBlock.h +++ b/Eigen/src/Core/VectorBlock.h @@ -86,7 +86,6 @@ template<typename VectorType, int Size> class VectorBlock IsColVector ? start : 0, IsColVector ? 0 : start, IsColVector ? size : 1, IsColVector ? 1 : size) { - EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock); } diff --git a/Eigen/src/Core/products/GeneralMatrixMatrix.h b/Eigen/src/Core/products/GeneralMatrixMatrix.h index 03c77cc78..beec17ee4 100644 --- a/Eigen/src/Core/products/GeneralMatrixMatrix.h +++ b/Eigen/src/Core/products/GeneralMatrixMatrix.h @@ -147,7 +147,6 @@ class GeneralProduct<Lhs, Rhs, GemmProduct> const ActualLhsType lhs = LhsBlasTraits::extract(m_lhs); const ActualRhsType rhs = RhsBlasTraits::extract(m_rhs); - ei_assert(ei_inner_stride_at_compile_time<ActualLhsType>::ret == 1); Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(m_lhs) * RhsBlasTraits::extractScalarFactor(m_rhs); @@ -159,9 +158,9 @@ class GeneralProduct<Lhs, Rhs, GemmProduct> (Dest::Flags&RowMajorBit) ? RowMajor : ColMajor> ::run( this->rows(), this->cols(), lhs.cols(), - (const Scalar*)&(lhs.const_cast_derived().coeffRef(0,0)), ei_outer_stride_or_outer_size(lhs), - (const Scalar*)&(rhs.const_cast_derived().coeffRef(0,0)), ei_outer_stride_or_outer_size(rhs), - (Scalar*)&(dst.coeffRef(0,0)), ei_outer_stride_or_outer_size(dst), + (const Scalar*)&(lhs.const_cast_derived().coeffRef(0,0)), lhs.stride(), + (const Scalar*)&(rhs.const_cast_derived().coeffRef(0,0)), rhs.stride(), + (Scalar*)&(dst.coeffRef(0,0)), dst.stride(), actualAlpha); } }; diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h index 51590b03d..c27c979a6 100644 --- a/Eigen/src/Core/util/Constants.h +++ b/Eigen/src/Core/util/Constants.h @@ -140,7 +140,7 @@ const unsigned int LinearAccessBit = 0x10; * Means that the underlying array of coefficients can be directly accessed. This means two things. * First, references to the coefficients must be available through coeffRef(int, int). This rules out read-only * expressions whose coefficients are computed on demand by coeff(int, int). Second, the memory layout of the - * array of coefficients must be exactly the natural one suggested by rows(), cols(), stride(), and the RowMajorBit. + * array of coefficients must be exactly the natural one suggested by rows(), cols(), outerStride(), innerStride(), and the RowMajorBit. * This rules out expressions such as Diagonal, whose coefficients, though referencable, do not have * such a regular memory layout. */ diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index d4920d213..c7b95d334 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -232,7 +232,7 @@ inline static Integer ei_first_aligned(const Scalar* array, Integer size) enum { PacketSize = ei_packet_traits<Scalar>::size, PacketAlignedMask = PacketSize-1 }; - + if(PacketSize==1) { // Either there is no vectorization, or a packet consists of exactly 1 scalar so that all elements diff --git a/Eigen/src/LU/PartialPivLU.h b/Eigen/src/LU/PartialPivLU.h index 809e4aad6..3925ac1b0 100644 --- a/Eigen/src/LU/PartialPivLU.h +++ b/Eigen/src/LU/PartialPivLU.h @@ -368,7 +368,7 @@ void ei_partial_lu_inplace(MatrixType& lu, IntVector& row_transpositions, int& n ei_partial_lu_impl <typename MatrixType::Scalar, MatrixType::Flags&RowMajorBit?RowMajor:ColMajor> - ::blocked_lu(lu.rows(), lu.cols(), &lu.coeffRef(0,0), lu.stride(), &row_transpositions.coeffRef(0), nb_transpositions); + ::blocked_lu(lu.rows(), lu.cols(), &lu.coeffRef(0,0), lu.outerStride(), &row_transpositions.coeffRef(0), nb_transpositions); } template<typename MatrixType> diff --git a/Eigen/src/Sparse/CholmodSupport.h b/Eigen/src/Sparse/CholmodSupport.h index fd33b1507..248f56533 100644 --- a/Eigen/src/Sparse/CholmodSupport.h +++ b/Eigen/src/Sparse/CholmodSupport.h @@ -99,7 +99,7 @@ cholmod_dense ei_cholmod_map_eigen_to_dense(MatrixBase<Derived>& mat) res.nrow = mat.rows(); res.ncol = mat.cols(); res.nzmax = res.nrow * res.ncol; - res.d = Derived::IsVectorAtCompileTime ? mat.derived().size() : mat.derived().stride(); + res.d = Derived::IsVectorAtCompileTime ? mat.derived().size() : mat.derived().outerStride(); res.x = mat.derived().data(); res.z = 0; diff --git a/Eigen/src/Sparse/SuperLUSupport.h b/Eigen/src/Sparse/SuperLUSupport.h index 1a765c75b..9a5bec554 100644 --- a/Eigen/src/Sparse/SuperLUSupport.h +++ b/Eigen/src/Sparse/SuperLUSupport.h @@ -161,7 +161,7 @@ struct SluMatrix : SuperMatrix res.nrow = mat.rows(); res.ncol = mat.cols(); - res.storage.lda = MatrixType::IsVectorAtCompileTime ? mat.size() : mat.stride(); + res.storage.lda = MatrixType::IsVectorAtCompileTime ? mat.size() : mat.outerStride(); res.storage.values = mat.data(); return res; } @@ -217,7 +217,7 @@ struct SluMatrixMapHelper<Matrix<Scalar,Rows,Cols,Options,MRows,MCols> > res.nrow = mat.rows(); res.ncol = mat.cols(); - res.storage.lda = mat.stride(); + res.storage.lda = mat.outerStride(); res.storage.values = mat.data(); } }; diff --git a/test/submatrices.cpp b/test/submatrices.cpp index a9dcf8476..e71c28ceb 100644 --- a/test/submatrices.cpp +++ b/test/submatrices.cpp @@ -217,11 +217,11 @@ void data_and_stride(const MatrixType& m) MatrixType m1 = MatrixType::Random(rows, cols); compare_using_data_and_stride(m1.block(r1, c1, r2-r1+1, c2-c1+1)); - //compare_using_data_and_stride(m1.transpose().block(c1, r1, c2-c1+1, r2-r1+1)); + compare_using_data_and_stride(m1.transpose().block(c1, r1, c2-c1+1, r2-r1+1)); compare_using_data_and_stride(m1.row(r1)); compare_using_data_and_stride(m1.col(c1)); - //compare_using_data_and_stride(m1.row(r1).transpose()); - //compare_using_data_and_stride(m1.col(c1).transpose()); + compare_using_data_and_stride(m1.row(r1).transpose()); + compare_using_data_and_stride(m1.col(c1).transpose()); } void test_submatrices() |