diff options
-rw-r--r-- | Eigen/src/Core/Reshape.h | 27 | ||||
-rw-r--r-- | test/reshape.cpp | 22 |
2 files changed, 21 insertions, 28 deletions
diff --git a/Eigen/src/Core/Reshape.h b/Eigen/src/Core/Reshape.h index e82136bd4..e4a71312c 100644 --- a/Eigen/src/Core/Reshape.h +++ b/Eigen/src/Core/Reshape.h @@ -53,20 +53,16 @@ struct traits<Reshape<XprType, ReshapeRows, ReshapeCols> > : traits<XprType> typedef typename traits<XprType>::Scalar Scalar; typedef typename traits<XprType>::StorageKind StorageKind; typedef typename traits<XprType>::XprKind XprKind; - typedef typename nested<XprType>::type XprTypeNested; - typedef typename remove_reference<XprTypeNested>::type _XprTypeNested; enum{ MatrixRows = traits<XprType>::RowsAtCompileTime, MatrixCols = traits<XprType>::ColsAtCompileTime, - RowsAtCompileTime = MatrixRows == 0 ? 0 : ReshapeRows, - ColsAtCompileTime = MatrixCols == 0 ? 0 : ReshapeCols, - MaxRowsAtCompileTime = ReshapeRows==0 ? 0 - : int(RowsAtCompileTime), - MaxColsAtCompileTime = ReshapeCols==0 ? 0 - : int(ColsAtCompileTime), - XprTypeIsRowMajor = (int(traits<XprType>::Flags)&RowMajorBit) != 0, - IsRowMajor = (MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1 - : (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0 + RowsAtCompileTime = ReshapeRows, + ColsAtCompileTime = ReshapeCols, + MaxRowsAtCompileTime = ReshapeRows, + MaxColsAtCompileTime = ReshapeCols, + XprTypeIsRowMajor = (int(traits<XprType>::Flags) & RowMajorBit) != 0, + IsRowMajor = (RowsAtCompileTime == 1 && ColsAtCompileTime != 1) ? 1 + : (ColsAtCompileTime == 1 && RowsAtCompileTime != 1) ? 0 : XprTypeIsRowMajor, HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor), InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime), @@ -83,14 +79,11 @@ struct traits<Reshape<XprType, ReshapeRows, ReshapeCols> > : traits<XprType> FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0, FlagsLvalueBit = is_lvalue<XprType>::value ? LvalueBit : 0, FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0, - IsSameShapeAtCompileTime = RowsAtCompileTime == ReshapeRows - && ColsAtCompileTime == ReshapeCols - && RowsAtCompileTime != Dynamic - && ColsAtCompileTime != Dynamic, Flags0 = traits<XprType>::Flags & ( (HereditaryBits & ~RowMajorBit) | - (traits<XprType>::Flags & ~DirectAccessBit) | MaskPacketAccessBit | - MaskAlignedBit), + MaskAlignedBit) + & ~DirectAccessBit, + Flags = (Flags0 | FlagsLinearAccessBit | FlagsLvalueBit | FlagsRowMajorBit) }; }; diff --git a/test/reshape.cpp b/test/reshape.cpp index eeab155f3..0298a2fe4 100644 --- a/test/reshape.cpp +++ b/test/reshape.cpp @@ -18,18 +18,18 @@ template <typename MatType> void reshape_all_size(MatType m) { typedef Eigen::Map<MatrixXi> MapMat; // dynamic - VERIFY_IS_EQUAL((m.template reshape( 1, 16)), MapMat(m.eval().data(), 1, 16)); - VERIFY_IS_EQUAL((m.template reshape( 2, 8)), MapMat(m.eval().data(), 2, 8)); - VERIFY_IS_EQUAL((m.template reshape( 4, 4)), MapMat(m.eval().data(), 4, 4)); - VERIFY_IS_EQUAL((m.template reshape( 8, 2)), MapMat(m.eval().data(), 8, 2)); - VERIFY_IS_EQUAL((m.template reshape(16, 1)), MapMat(m.eval().data(), 16, 1)); + VERIFY_IS_EQUAL((m.template reshape( 1, 16)), MapMat(m.data(), 1, 16)); + VERIFY_IS_EQUAL((m.template reshape( 2, 8)), MapMat(m.data(), 2, 8)); + VERIFY_IS_EQUAL((m.template reshape( 4, 4)), MapMat(m.data(), 4, 4)); + VERIFY_IS_EQUAL((m.template reshape( 8, 2)), MapMat(m.data(), 8, 2)); + VERIFY_IS_EQUAL((m.template reshape(16, 1)), MapMat(m.data(), 16, 1)); // static - VERIFY_IS_EQUAL((m.template reshape< 1, 16>()), MapMat(m.eval().data(), 1, 16)); - VERIFY_IS_EQUAL((m.template reshape< 2, 8>()), MapMat(m.eval().data(), 2, 8)); - VERIFY_IS_EQUAL((m.template reshape< 4, 4>()), MapMat(m.eval().data(), 4, 4)); - VERIFY_IS_EQUAL((m.template reshape< 8, 2>()), MapMat(m.eval().data(), 8, 2)); - VERIFY_IS_EQUAL((m.template reshape<16, 1>()), MapMat(m.eval().data(), 16, 1)); + VERIFY_IS_EQUAL((m.template reshape< 1, 16>()), MapMat(m.data(), 1, 16)); + VERIFY_IS_EQUAL((m.template reshape< 2, 8>()), MapMat(m.data(), 2, 8)); + VERIFY_IS_EQUAL((m.template reshape< 4, 4>()), MapMat(m.data(), 4, 4)); + VERIFY_IS_EQUAL((m.template reshape< 8, 2>()), MapMat(m.data(), 8, 2)); + VERIFY_IS_EQUAL((m.template reshape<16, 1>()), MapMat(m.data(), 16, 1)); // reshape chain VERIFY_IS_EQUAL( @@ -45,7 +45,7 @@ void reshape_all_size(MatType m) { .template reshape( 8, 2) .template reshape< 4, 4>() ), - MapMat(m.eval().data(), 4, 4) + MapMat(m.data(), 4, 4) ); } |