mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-21 07:19:46 +08:00
Fix reshape strides when input has non-zero inner stride.
This commit is contained in:
parent
23524ab6fc
commit
2260e11eb0
@ -251,7 +251,7 @@ class ReshapedImpl_dense<XprType, Rows, Cols, Order, true>
|
||||
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:
|
||||
|
@ -196,6 +196,24 @@ void reshape4x4(MatType m)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename BlockType>
|
||||
void reshape_block(const BlockType& M) {
|
||||
auto 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<rows; ++i) {
|
||||
VERIFY_IS_EQUAL(dense.reshaped(rows, cols).row(i),
|
||||
M.reshaped(rows, cols).row(i));
|
||||
}
|
||||
|
||||
for (Index j = 0; j<cols; ++j) {
|
||||
VERIFY_IS_EQUAL(dense.reshaped(rows, cols).col(j),
|
||||
M.reshaped(rows, cols).col(j));
|
||||
}
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(reshape)
|
||||
{
|
||||
typedef Matrix<int,Dynamic,Dynamic,RowMajor> RowMatrixXi;
|
||||
@ -216,4 +234,5 @@ EIGEN_DECLARE_TEST(reshape)
|
||||
|
||||
CALL_SUBTEST(reshape4x4(rmx));
|
||||
CALL_SUBTEST(reshape4x4(rm4));
|
||||
CALL_SUBTEST(reshape_block(rm4.col(1)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user