diff --git a/Eigen/src/Core/Reshaped.h b/Eigen/src/Core/Reshaped.h index 52de73b6f..882314cfe 100644 --- a/Eigen/src/Core/Reshaped.h +++ b/Eigen/src/Core/Reshaped.h @@ -250,7 +250,7 @@ class ReshapedImpl_dense EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index outerStride() const { - return ((Flags&RowMajorBit)==RowMajorBit) ? this->cols() : this->rows(); + return (((Flags&RowMajorBit)==RowMajorBit) ? this->cols() : this->rows()) * m_xpr.innerStride(); } protected: diff --git a/test/reshape.cpp b/test/reshape.cpp index 7b16742a2..1f966ebae 100644 --- a/test/reshape.cpp +++ b/test/reshape.cpp @@ -193,6 +193,24 @@ void reshape4x4(MatType m) } } +template +void reshape_block(const BlockType& M) { + typename BlockType::PlainObject dense = M.eval(); + Index rows = M.size() / 2; + Index cols = M.size() / rows; + VERIFY_IS_EQUAL(dense.reshaped(rows, cols), M.reshaped(rows, cols)); + + for (Index i=0; i RowMatrixXi; @@ -213,4 +231,5 @@ EIGEN_DECLARE_TEST(reshape) CALL_SUBTEST(reshape4x4(rmx)); CALL_SUBTEST(reshape4x4(rm4)); + CALL_SUBTEST(reshape_block(rm4.col(1))); }