get rid of NestParentByRefBit

This commit is contained in:
Gael Guennebaud 2010-02-08 16:51:41 +01:00
parent 871698d3aa
commit 8b016e717f
22 changed files with 25 additions and 72 deletions

View File

@ -55,7 +55,7 @@ struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> >
: ColFactor * MatrixType::ColsAtCompileTime, : ColFactor * MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = RowsAtCompileTime, MaxRowsAtCompileTime = RowsAtCompileTime,
MaxColsAtCompileTime = ColsAtCompileTime, MaxColsAtCompileTime = ColsAtCompileTime,
Flags = (_MatrixTypeNested::Flags & HereditaryBits) | EIGEN_PROPAGATE_NESTING_BIT(MatrixType::Flags), Flags = (_MatrixTypeNested::Flags & HereditaryBits),
CoeffReadCost = _MatrixTypeNested::CoeffReadCost CoeffReadCost = _MatrixTypeNested::CoeffReadCost
}; };
}; };

View File

@ -59,9 +59,7 @@ struct ei_traits<Reverse<MatrixType, Direction> >
LinearAccess = ( (Direction==BothDirections) && (int(_MatrixTypeNested::Flags)&PacketAccessBit) ) LinearAccess = ( (Direction==BothDirections) && (int(_MatrixTypeNested::Flags)&PacketAccessBit) )
? LinearAccessBit : 0, ? LinearAccessBit : 0,
Flags = (int(_MatrixTypeNested::Flags) Flags = int(_MatrixTypeNested::Flags) & (HereditaryBits | PacketAccessBit | LinearAccess),
& (HereditaryBits | PacketAccessBit | LinearAccess))
| EIGEN_PROPAGATE_NESTING_BIT(MatrixType::Flags),
CoeffReadCost = _MatrixTypeNested::CoeffReadCost CoeffReadCost = _MatrixTypeNested::CoeffReadCost
}; };

View File

@ -55,11 +55,10 @@ struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
ColsAtCompileTime = ConditionMatrixType::ColsAtCompileTime, ColsAtCompileTime = ConditionMatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = ConditionMatrixType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = ConditionMatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = ConditionMatrixType::MaxColsAtCompileTime, MaxColsAtCompileTime = ConditionMatrixType::MaxColsAtCompileTime,
Flags = ((unsigned int)ThenMatrixType::Flags & ElseMatrixType::Flags & HereditaryBits) Flags = (unsigned int)ThenMatrixType::Flags & ElseMatrixType::Flags & HereditaryBits,
| EIGEN_PROPAGATE_NESTING_BIT(ConditionMatrixType::Flags|ThenMatrixType::Flags|ElseMatrixType::Flags), CoeffReadCost = ei_traits<typename ei_cleantype<ConditionMatrixNested>::type>::CoeffReadCost
CoeffReadCost = ei_traits<typename ei_cleantype<ConditionMatrixNested>::type>::CoeffReadCost + EIGEN_ENUM_MAX(ei_traits<typename ei_cleantype<ThenMatrixNested>::type>::CoeffReadCost,
+ EIGEN_ENUM_MAX(ei_traits<typename ei_cleantype<ThenMatrixNested>::type>::CoeffReadCost, ei_traits<typename ei_cleantype<ElseMatrixNested>::type>::CoeffReadCost)
ei_traits<typename ei_cleantype<ElseMatrixNested>::type>::CoeffReadCost)
}; };
}; };

View File

@ -60,8 +60,7 @@ struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime, ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime, MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime,
Flags = ((unsigned int)_MatrixTypeNested::Flags & HereditaryBits) Flags = (unsigned int)_MatrixTypeNested::Flags & HereditaryBits,
| EIGEN_PROPAGATE_NESTING_BIT(_MatrixTypeNested::Flags),
TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime
}; };
#if EIGEN_GNUC_AT_LEAST(3,4) #if EIGEN_GNUC_AT_LEAST(3,4)

View File

@ -76,9 +76,7 @@ struct ei_traits<Block<MatrixType, BlockRows, BlockCols, _DirectAccessStatus> >
MaskPacketAccessBit = (InnerMaxSize == Dynamic || (InnerSize >= ei_packet_traits<Scalar>::size)) MaskPacketAccessBit = (InnerMaxSize == Dynamic || (InnerSize >= ei_packet_traits<Scalar>::size))
? PacketAccessBit : 0, ? PacketAccessBit : 0,
FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0, FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0,
Flags = (ei_traits<MatrixType>::Flags & (HereditaryBits | MaskPacketAccessBit | DirectAccessBit)) Flags = (ei_traits<MatrixType>::Flags & (HereditaryBits | MaskPacketAccessBit | DirectAccessBit)) | FlagsLinearAccessBit
| FlagsLinearAccessBit
| EIGEN_PROPAGATE_NESTING_BIT(ei_traits<MatrixType>::Flags)
}; };
}; };

View File

@ -343,7 +343,7 @@ template<typename OtherDerived>
EIGEN_STRONG_INLINE void DenseBase<Derived>::copyCoeff(int index, const DenseBase<OtherDerived>& other) EIGEN_STRONG_INLINE void DenseBase<Derived>::copyCoeff(int index, const DenseBase<OtherDerived>& other)
{ {
ei_internal_assert(index >= 0 && index < size()); ei_internal_assert(index >= 0 && index < size());
derived().coeffRef(index) = Scalar(other.derived().coeff(index)); derived().coeffRef(index) = other.derived().coeff(index);
} }
/** \internal Copies the packet at position (row,col) of other into *this. /** \internal Copies the packet at position (row,col) of other into *this.

View File

@ -72,7 +72,6 @@ struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > : ei_traits<Lhs>
( AlignedBit ( AlignedBit
| (StorageOrdersAgree ? LinearAccessBit : 0) | (StorageOrdersAgree ? LinearAccessBit : 0)
| (ei_functor_traits<BinaryOp>::PacketAccess && StorageOrdersAgree ? PacketAccessBit : 0) | (ei_functor_traits<BinaryOp>::PacketAccess && StorageOrdersAgree ? PacketAccessBit : 0)
| EIGEN_PROPAGATE_NESTING_BIT(Lhs::Flags|Rhs::Flags)
) )
) )
), ),

View File

@ -48,8 +48,7 @@ struct ei_traits<CwiseNullaryOp<NullaryOp, MatrixType> > : ei_traits<MatrixType>
& ( HereditaryBits & ( HereditaryBits
| (ei_functor_has_linear_access<NullaryOp>::ret ? LinearAccessBit : 0) | (ei_functor_has_linear_access<NullaryOp>::ret ? LinearAccessBit : 0)
| (ei_functor_traits<NullaryOp>::PacketAccess ? PacketAccessBit : 0))) | (ei_functor_traits<NullaryOp>::PacketAccess ? PacketAccessBit : 0)))
| (ei_functor_traits<NullaryOp>::IsRepeatable ? 0 : EvalBeforeNestingBit) | (ei_functor_traits<NullaryOp>::IsRepeatable ? 0 : EvalBeforeNestingBit),
| EIGEN_PROPAGATE_NESTING_BIT(ei_traits<MatrixType>::Flags),
CoeffReadCost = ei_functor_traits<NullaryOp>::Cost CoeffReadCost = ei_functor_traits<NullaryOp>::Cost
}; };
}; };

View File

@ -49,10 +49,9 @@ struct ei_traits<CwiseUnaryOp<UnaryOp, MatrixType> >
typedef typename MatrixType::Nested MatrixTypeNested; typedef typename MatrixType::Nested MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum { enum {
Flags = (_MatrixTypeNested::Flags & ( Flags = _MatrixTypeNested::Flags & (
HereditaryBits | LinearAccessBit | AlignedBit HereditaryBits | LinearAccessBit | AlignedBit
| (ei_functor_traits<UnaryOp>::PacketAccess ? PacketAccessBit : 0))) | (ei_functor_traits<UnaryOp>::PacketAccess ? PacketAccessBit : 0)),
| EIGEN_PROPAGATE_NESTING_BIT(ei_traits<MatrixType>::Flags),
CoeffReadCost = _MatrixTypeNested::CoeffReadCost + ei_functor_traits<UnaryOp>::Cost CoeffReadCost = _MatrixTypeNested::CoeffReadCost + ei_functor_traits<UnaryOp>::Cost
}; };
}; };

View File

@ -47,8 +47,7 @@ struct ei_traits<CwiseUnaryView<ViewOp, MatrixType> >
typedef typename MatrixType::Nested MatrixTypeNested; typedef typename MatrixType::Nested MatrixTypeNested;
typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested; typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested;
enum { enum {
Flags = (ei_traits<_MatrixTypeNested>::Flags & (HereditaryBits | LinearAccessBit | AlignedBit)) Flags = (ei_traits<_MatrixTypeNested>::Flags & (HereditaryBits | LinearAccessBit | AlignedBit)),
| EIGEN_PROPAGATE_NESTING_BIT(ei_traits<MatrixType>::Flags), // if I am not wrong, I need to test this on MatrixType and not on the nested type
CoeffReadCost = ei_traits<_MatrixTypeNested>::CoeffReadCost + ei_functor_traits<ViewOp>::Cost CoeffReadCost = ei_traits<_MatrixTypeNested>::CoeffReadCost + ei_functor_traits<ViewOp>::Cost
}; };
}; };

View File

@ -58,8 +58,7 @@ struct ei_traits<Diagonal<MatrixType,Index> >
: Index == Dynamic ? EIGEN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime) : Index == Dynamic ? EIGEN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime)
: (EIGEN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime) - AbsIndex), : (EIGEN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime) - AbsIndex),
MaxColsAtCompileTime = 1, MaxColsAtCompileTime = 1,
Flags = ((unsigned int)_MatrixTypeNested::Flags & (HereditaryBits | LinearAccessBit)) Flags = (unsigned int)_MatrixTypeNested::Flags & (HereditaryBits | LinearAccessBit),
| EIGEN_PROPAGATE_NESTING_BIT(ei_traits<MatrixType>::Flags),
CoeffReadCost = _MatrixTypeNested::CoeffReadCost CoeffReadCost = _MatrixTypeNested::CoeffReadCost
}; };
}; };

View File

@ -37,8 +37,7 @@ struct ei_traits<DiagonalProduct<MatrixType, DiagonalType, ProductOrder> >
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
Flags = (HereditaryBits & (unsigned int)(MatrixType::Flags)) Flags = (HereditaryBits & (unsigned int)(MatrixType::Flags))
| (PacketAccessBit & (unsigned int)(MatrixType::Flags) & (unsigned int)(DiagonalType::DiagonalVectorType::Flags)) | (PacketAccessBit & (unsigned int)(MatrixType::Flags) & (unsigned int)(DiagonalType::DiagonalVectorType::Flags)),
| EIGEN_PROPAGATE_NESTING_BIT(ei_traits<MatrixType>::Flags),
CoeffReadCost = NumTraits<Scalar>::MulCost + MatrixType::CoeffReadCost + DiagonalType::DiagonalVectorType::CoeffReadCost CoeffReadCost = NumTraits<Scalar>::MulCost + MatrixType::CoeffReadCost + DiagonalType::DiagonalVectorType::CoeffReadCost
}; };
}; };

View File

@ -53,8 +53,7 @@ struct ei_traits<Minor<MatrixType> >
int(MatrixType::MaxRowsAtCompileTime) - 1 : Dynamic, int(MatrixType::MaxRowsAtCompileTime) - 1 : Dynamic,
MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ? MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ?
int(MatrixType::MaxColsAtCompileTime) - 1 : Dynamic, int(MatrixType::MaxColsAtCompileTime) - 1 : Dynamic,
Flags = (_MatrixTypeNested::Flags & HereditaryBits) Flags = _MatrixTypeNested::Flags & HereditaryBits,
| EIGEN_PROPAGATE_NESTING_BIT(ei_traits<MatrixType>::Flags),
CoeffReadCost = _MatrixTypeNested::CoeffReadCost // minor is used typically on tiny matrices, CoeffReadCost = _MatrixTypeNested::CoeffReadCost // minor is used typically on tiny matrices,
// where loops are unrolled and the 'if' evaluates at compile time // where loops are unrolled and the 'if' evaluates at compile time
}; };

View File

@ -42,10 +42,7 @@ struct ei_traits<ProductBase<Derived,_Lhs,_Rhs> > //: ei_traits<typename ei_clea
ColsAtCompileTime = ei_traits<Rhs>::ColsAtCompileTime, ColsAtCompileTime = ei_traits<Rhs>::ColsAtCompileTime,
MaxRowsAtCompileTime = ei_traits<Lhs>::MaxRowsAtCompileTime, MaxRowsAtCompileTime = ei_traits<Lhs>::MaxRowsAtCompileTime,
MaxColsAtCompileTime = ei_traits<Rhs>::MaxColsAtCompileTime, MaxColsAtCompileTime = ei_traits<Rhs>::MaxColsAtCompileTime,
Flags = EvalBeforeNestingBit Flags = EvalBeforeNestingBit | EvalBeforeAssigningBit,
| EvalBeforeAssigningBit
| NestParentByRefBit
| EIGEN_PROPAGATE_NESTING_BIT(Lhs::Flags|Rhs::Flags),
CoeffReadCost = 0 // FIXME why is it needed ? CoeffReadCost = 0 // FIXME why is it needed ?
}; };
}; };

View File

@ -47,9 +47,8 @@ struct ei_traits<SelfAdjointView<MatrixType, TriangularPart> > : ei_traits<Matri
typedef MatrixType ExpressionType; typedef MatrixType ExpressionType;
enum { enum {
Mode = TriangularPart | SelfAdjoint, Mode = TriangularPart | SelfAdjoint,
Flags = (_MatrixTypeNested::Flags & (HereditaryBits) Flags = _MatrixTypeNested::Flags & (HereditaryBits)
& (~(PacketAccessBit | DirectAccessBit | LinearAccessBit))) // FIXME these flags should be preserved & (~(PacketAccessBit | DirectAccessBit | LinearAccessBit)), // FIXME these flags should be preserved
| EIGEN_PROPAGATE_NESTING_BIT(ei_traits<MatrixType>::Flags),
CoeffReadCost = _MatrixTypeNested::CoeffReadCost CoeffReadCost = _MatrixTypeNested::CoeffReadCost
}; };
}; };

View File

@ -90,7 +90,7 @@ template<typename BinaryOp, typename MatrixType> class SelfCwiseBinaryOp
OtherDerived& _other = other.const_cast_derived(); OtherDerived& _other = other.const_cast_derived();
ei_internal_assert(index >= 0 && index < m_matrix.size()); ei_internal_assert(index >= 0 && index < m_matrix.size());
Scalar& tmp = m_matrix.coeffRef(index); Scalar& tmp = m_matrix.coeffRef(index);
tmp = m_functor(tmp, Scalar(_other.coeff(index))); tmp = m_functor(tmp, _other.coeff(index));
} }
template<typename OtherDerived, int StoreMode, int LoadMode> template<typename OtherDerived, int StoreMode, int LoadMode>

View File

@ -50,8 +50,7 @@ struct ei_traits<Transpose<MatrixType> > : ei_traits<MatrixType>
ColsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::RowsAtCompileTime,
MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime,
MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
Flags = (int(_MatrixTypeNested::Flags & ~NestByRefBit) ^ RowMajorBit) Flags = int(_MatrixTypeNested::Flags & ~NestByRefBit) ^ RowMajorBit,
| EIGEN_PROPAGATE_NESTING_BIT(ei_traits<MatrixType>::Flags),
CoeffReadCost = _MatrixTypeNested::CoeffReadCost CoeffReadCost = _MatrixTypeNested::CoeffReadCost
}; };
}; };
@ -64,7 +63,7 @@ template<typename MatrixType> class Transpose
public: public:
typedef typename TransposeImpl<MatrixType,typename ei_traits<MatrixType>::StorageType>::Base Base; typedef typename TransposeImpl<MatrixType,typename ei_traits<MatrixType>::StorageType>::Base Base;
EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(Transpose) EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(Transpose)
inline Transpose(const MatrixType& matrix) : m_matrix(matrix) {} inline Transpose(const MatrixType& matrix) : m_matrix(matrix) {}

View File

@ -130,8 +130,7 @@ struct ei_traits<TriangularView<MatrixType, _Mode> > : ei_traits<MatrixType>
typedef MatrixType ExpressionType; typedef MatrixType ExpressionType;
enum { enum {
Mode = _Mode, Mode = _Mode,
Flags = (_MatrixTypeNested::Flags & (HereditaryBits) & (~(PacketAccessBit | DirectAccessBit | LinearAccessBit))) | Mode Flags = (_MatrixTypeNested::Flags & (HereditaryBits) & (~(PacketAccessBit | DirectAccessBit | LinearAccessBit))) | Mode,
| EIGEN_PROPAGATE_NESTING_BIT(ei_traits<MatrixType>::Flags),
CoeffReadCost = _MatrixTypeNested::CoeffReadCost CoeffReadCost = _MatrixTypeNested::CoeffReadCost
}; };
}; };

View File

@ -81,10 +81,8 @@ struct ei_traits<GeneralProduct<LhsNested,RhsNested,UnrolledProduct> >
Flags = ((unsigned int)(LhsFlags | RhsFlags) & HereditaryBits & RemovedBits) Flags = ((unsigned int)(LhsFlags | RhsFlags) & HereditaryBits & RemovedBits)
| EvalBeforeAssigningBit | EvalBeforeAssigningBit
| EvalBeforeNestingBit | EvalBeforeNestingBit
| NestParentByRefBit
| (CanVectorizeLhs || CanVectorizeRhs ? PacketAccessBit : 0) | (CanVectorizeLhs || CanVectorizeRhs ? PacketAccessBit : 0)
| (LhsFlags & RhsFlags & AlignedBit) | (LhsFlags & RhsFlags & AlignedBit),
| EIGEN_PROPAGATE_NESTING_BIT(LhsFlags|RhsFlags),
CoeffReadCost = InnerSize == Dynamic ? Dynamic CoeffReadCost = InnerSize == Dynamic ? Dynamic
: InnerSize * (NumTraits<Scalar>::MulCost + LhsCoeffReadCost + RhsCoeffReadCost) : InnerSize * (NumTraits<Scalar>::MulCost + LhsCoeffReadCost + RhsCoeffReadCost)

View File

@ -97,7 +97,6 @@ const unsigned int EvalBeforeAssigningBit = 0x4;
*/ */
const unsigned int PacketAccessBit = 0x8; const unsigned int PacketAccessBit = 0x8;
const unsigned int NestParentByRefBit = 0x80;
const unsigned int NestByRefBit = 0x100; const unsigned int NestByRefBit = 0x100;
#ifdef EIGEN_VECTORIZE #ifdef EIGEN_VECTORIZE

View File

@ -201,28 +201,6 @@ template<typename T> struct ei_plain_matrix_type_row_major
// we should be able to get rid of this one too // we should be able to get rid of this one too
template<typename T> struct ei_must_nest_by_value { enum { ret = false }; }; template<typename T> struct ei_must_nest_by_value { enum { ret = false }; };
template<class T>
struct ei_is_reference
{
#ifndef NDEBUG
static void check() { std::cout << typeid(T).name() << std::endl; }
#else
static void check() {}
#endif
enum { ret = false };
};
template<class T>
struct ei_is_reference<T&>
{
#ifndef NDEBUG
static void check() { std::cout << typeid(T).name() << "&" << std::endl; }
#else
static void check() {}
#endif
enum { ret = true };
};
/** /**
* The reference selector for template expressions. The idea is that we don't * The reference selector for template expressions. The idea is that we don't
* need to use references for expressions since they are light weight proxy * need to use references for expressions since they are light weight proxy
@ -238,8 +216,6 @@ struct ei_ref_selector
>::ret type; >::ret type;
}; };
#define EIGEN_PROPAGATE_NESTING_BIT(ReferenceFlags) ((ReferenceFlags) & NestParentByRefBit)<<1
/** \internal Determines how a given expression should be nested into another one. /** \internal Determines how a given expression should be nested into another one.
* For example, when you do a * (b+c), Eigen will determine how the expression b+c should be * For example, when you do a * (b+c), Eigen will determine how the expression b+c should be
* nested into the bigger product expression. The choice is between nesting the expression b+c as-is, or * nested into the bigger product expression. The choice is between nesting the expression b+c as-is, or

View File

@ -55,8 +55,7 @@ struct ei_traits<Homogeneous<MatrixType,Direction> >
ColsAtCompileTime = Direction==Horizontal ? ColsPlusOne : MatrixType::ColsAtCompileTime, ColsAtCompileTime = Direction==Horizontal ? ColsPlusOne : MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = RowsAtCompileTime, MaxRowsAtCompileTime = RowsAtCompileTime,
MaxColsAtCompileTime = ColsAtCompileTime, MaxColsAtCompileTime = ColsAtCompileTime,
Flags = _MatrixTypeNested::Flags & HereditaryBits Flags = _MatrixTypeNested::Flags & HereditaryBits,
| EIGEN_PROPAGATE_NESTING_BIT(ei_traits<MatrixType>::Flags),
CoeffReadCost = _MatrixTypeNested::CoeffReadCost CoeffReadCost = _MatrixTypeNested::CoeffReadCost
}; };
}; };