mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
bug #1543: fix linear indexing in generic block evaluation (this completes the fix in commit 12efc7d41b80259b996be5781bf596c249c90d3f
)
This commit is contained in:
parent
35b31353ab
commit
5679e439e0
@ -1087,7 +1087,8 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
|
|||||||
typedef typename XprType::CoeffReturnType CoeffReturnType;
|
typedef typename XprType::CoeffReturnType CoeffReturnType;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
RowsAtCompileTime = XprType::RowsAtCompileTime
|
RowsAtCompileTime = XprType::RowsAtCompileTime,
|
||||||
|
ForwardLinearAccess = InnerPanel && bool(evaluator<ArgType>::Flags&LinearAccessBit)
|
||||||
};
|
};
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
@ -1099,7 +1100,7 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
|
|||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
CoeffReturnType coeff(Index index) const
|
CoeffReturnType coeff(Index index) const
|
||||||
{
|
{
|
||||||
if (InnerPanel)
|
if (ForwardLinearAccess)
|
||||||
return m_argImpl.coeff(m_linear_offset.value() + index);
|
return m_argImpl.coeff(m_linear_offset.value() + index);
|
||||||
else
|
else
|
||||||
return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
|
return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
|
||||||
@ -1114,7 +1115,7 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
|
|||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
Scalar& coeffRef(Index index)
|
Scalar& coeffRef(Index index)
|
||||||
{
|
{
|
||||||
if (InnerPanel)
|
if (ForwardLinearAccess)
|
||||||
return m_argImpl.coeffRef(m_linear_offset.value() + index);
|
return m_argImpl.coeffRef(m_linear_offset.value() + index);
|
||||||
else
|
else
|
||||||
return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
|
return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
|
||||||
@ -1131,7 +1132,7 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
|
|||||||
EIGEN_STRONG_INLINE
|
EIGEN_STRONG_INLINE
|
||||||
PacketType packet(Index index) const
|
PacketType packet(Index index) const
|
||||||
{
|
{
|
||||||
if (InnerPanel)
|
if (ForwardLinearAccess)
|
||||||
return m_argImpl.template packet<LoadMode,PacketType>(m_linear_offset.value() + index);
|
return m_argImpl.template packet<LoadMode,PacketType>(m_linear_offset.value() + index);
|
||||||
else
|
else
|
||||||
return packet<LoadMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
|
return packet<LoadMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
|
||||||
@ -1149,7 +1150,7 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
|
|||||||
EIGEN_STRONG_INLINE
|
EIGEN_STRONG_INLINE
|
||||||
void writePacket(Index index, const PacketType& x)
|
void writePacket(Index index, const PacketType& x)
|
||||||
{
|
{
|
||||||
if (InnerPanel)
|
if (ForwardLinearAccess)
|
||||||
return m_argImpl.template writePacket<StoreMode,PacketType>(m_linear_offset.value() + index, x);
|
return m_argImpl.template writePacket<StoreMode,PacketType>(m_linear_offset.value() + index, x);
|
||||||
else
|
else
|
||||||
return writePacket<StoreMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
|
return writePacket<StoreMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
|
||||||
|
@ -99,6 +99,12 @@ template<typename MatrixType> void diagonalmatrices(const MatrixType& m)
|
|||||||
VERIFY_IS_APPROX( (sq_m1 += (s1*v1).asDiagonal()), sq_m2 += (s1*v1).asDiagonal().toDenseMatrix() );
|
VERIFY_IS_APPROX( (sq_m1 += (s1*v1).asDiagonal()), sq_m2 += (s1*v1).asDiagonal().toDenseMatrix() );
|
||||||
VERIFY_IS_APPROX( (sq_m1 -= (s1*v1).asDiagonal()), sq_m2 -= (s1*v1).asDiagonal().toDenseMatrix() );
|
VERIFY_IS_APPROX( (sq_m1 -= (s1*v1).asDiagonal()), sq_m2 -= (s1*v1).asDiagonal().toDenseMatrix() );
|
||||||
VERIFY_IS_APPROX( (sq_m1 = (s1*v1).asDiagonal()), (s1*v1).asDiagonal().toDenseMatrix() );
|
VERIFY_IS_APPROX( (sq_m1 = (s1*v1).asDiagonal()), (s1*v1).asDiagonal().toDenseMatrix() );
|
||||||
|
|
||||||
|
sq_m1.setRandom();
|
||||||
|
sq_m2 = v1.asDiagonal();
|
||||||
|
sq_m2 = sq_m1 * sq_m2;
|
||||||
|
VERIFY_IS_APPROX( (sq_m1*v1.asDiagonal()).col(i), sq_m2.col(i) );
|
||||||
|
VERIFY_IS_APPROX( (sq_m1*v1.asDiagonal()).row(i), sq_m2.row(i) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<int>
|
template<int>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user