@@ -1020,14 +1020,16 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
10201020 EIGEN_DEVICE_FUNC explicit unary_evaluator (const XprType& block)
10211021 : m_argImpl(block.nestedExpression()),
10221022 m_startRow(block.startRow()),
1023- m_startCol(block.startCol())
1023+ m_startCol(block.startCol()),
1024+ m_linear_offset(InnerPanel?(XprType::IsRowMajor ? block.startRow()*block.cols() : block.startCol()*block.rows()):0)
10241025 { }
10251026
10261027 typedef typename XprType::Scalar Scalar;
10271028 typedef typename XprType::CoeffReturnType CoeffReturnType;
10281029
10291030 enum {
1030- RowsAtCompileTime = XprType::RowsAtCompileTime
1031+ RowsAtCompileTime = XprType::RowsAtCompileTime,
1032+ ForwardLinearAccess = InnerPanel && bool (evaluator<ArgType>::Flags&LinearAccessBit)
10311033 };
10321034
10331035 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
@@ -1039,7 +1041,10 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
10391041 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
10401042 CoeffReturnType coeff (Index index) const
10411043 {
1042- return coeff (RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0 );
1044+ if (ForwardLinearAccess)
1045+ return m_argImpl.coeff (m_linear_offset.value () + index);
1046+ else
1047+ return coeff (RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0 );
10431048 }
10441049
10451050 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
@@ -1051,7 +1056,10 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
10511056 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
10521057 Scalar& coeffRef (Index index)
10531058 {
1054- return coeffRef (RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0 );
1059+ if (ForwardLinearAccess)
1060+ return m_argImpl.coeffRef (m_linear_offset.value () + index);
1061+ else
1062+ return coeffRef (RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0 );
10551063 }
10561064
10571065 template <int LoadMode, typename PacketType>
@@ -1065,8 +1073,11 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
10651073 EIGEN_STRONG_INLINE
10661074 PacketType packet (Index index) const
10671075 {
1068- return packet<LoadMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1069- RowsAtCompileTime == 1 ? index : 0 );
1076+ if (ForwardLinearAccess)
1077+ return m_argImpl.template packet <LoadMode,PacketType>(m_linear_offset.value () + index);
1078+ else
1079+ return packet<LoadMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1080+ RowsAtCompileTime == 1 ? index : 0 );
10701081 }
10711082
10721083 template <int StoreMode, typename PacketType>
@@ -1080,15 +1091,19 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
10801091 EIGEN_STRONG_INLINE
10811092 void writePacket (Index index, const PacketType& x)
10821093 {
1083- return writePacket<StoreMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1084- RowsAtCompileTime == 1 ? index : 0 ,
1085- x);
1094+ if (ForwardLinearAccess)
1095+ return m_argImpl.template writePacket <StoreMode,PacketType>(m_linear_offset.value () + index, x);
1096+ else
1097+ return writePacket<StoreMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1098+ RowsAtCompileTime == 1 ? index : 0 ,
1099+ x);
10861100 }
10871101
10881102protected:
10891103 evaluator<ArgType> m_argImpl;
10901104 const variable_if_dynamic<Index, (ArgType::RowsAtCompileTime == 1 && BlockRows==1 ) ? 0 : Dynamic> m_startRow;
10911105 const variable_if_dynamic<Index, (ArgType::ColsAtCompileTime == 1 && BlockCols==1 ) ? 0 : Dynamic> m_startCol;
1106+ const variable_if_dynamic<Index, InnerPanel ? Dynamic : 0 > m_linear_offset;
10921107};
10931108
10941109// TODO: This evaluator does not actually use the child evaluator;
0 commit comments