mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
fix flag and cost computations for nested expressions
This commit is contained in:
parent
5588def0cf
commit
ef5b20bc50
@ -55,17 +55,25 @@ struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
|
||||
typename Rhs::Scalar
|
||||
)
|
||||
>::type Scalar;
|
||||
typedef typename Lhs::Nested LhsNested;
|
||||
typedef typename Rhs::Nested RhsNested;
|
||||
typedef typename ei_unref<LhsNested>::type _LhsNested;
|
||||
typedef typename ei_unref<RhsNested>::type _RhsNested;
|
||||
enum {
|
||||
LhsCoeffReadCost = _LhsNested::CoeffReadCost,
|
||||
RhsCoeffReadCost = _RhsNested::CoeffReadCost,
|
||||
LhsFlags = _LhsNested::Flags,
|
||||
RhsFlags = _RhsNested::Flags,
|
||||
RowsAtCompileTime = Lhs::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Lhs::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = Lhs::MaxColsAtCompileTime,
|
||||
Flags = ((Lhs::Flags | Rhs::Flags) & (
|
||||
Flags = ((LhsFlags | RhsFlags) & (
|
||||
DefaultLostFlagMask
|
||||
| Like1DArrayBit
|
||||
| (ei_functor_traits<BinaryOp>::IsVectorizable && ((Lhs::Flags & RowMajorBit)==(Rhs::Flags & RowMajorBit))
|
||||
? Lhs::Flags & Rhs::Flags & VectorizableBit : 0))),
|
||||
CoeffReadCost = Lhs::CoeffReadCost + Rhs::CoeffReadCost + ei_functor_traits<BinaryOp>::Cost
|
||||
| (ei_functor_traits<BinaryOp>::IsVectorizable && ((LhsFlags & RowMajorBit)==(RhsFlags & RowMajorBit))
|
||||
? LhsFlags & RhsFlags & VectorizableBit : 0))),
|
||||
CoeffReadCost = LhsCoeffReadCost + RhsCoeffReadCost + ei_functor_traits<BinaryOp>::Cost
|
||||
};
|
||||
};
|
||||
|
||||
@ -76,6 +84,8 @@ class CwiseBinaryOp : ei_no_assignment_operator,
|
||||
public:
|
||||
|
||||
EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseBinaryOp)
|
||||
typedef typename ei_traits<CwiseBinaryOp>::LhsNested LhsNested;
|
||||
typedef typename ei_traits<CwiseBinaryOp>::RhsNested RhsNested;
|
||||
|
||||
CwiseBinaryOp(const Lhs& lhs, const Rhs& rhs, const BinaryOp& func = BinaryOp())
|
||||
: m_lhs(lhs), m_rhs(rhs), m_functor(func)
|
||||
@ -99,8 +109,8 @@ class CwiseBinaryOp : ei_no_assignment_operator,
|
||||
}
|
||||
|
||||
protected:
|
||||
const typename Lhs::Nested m_lhs;
|
||||
const typename Rhs::Nested m_rhs;
|
||||
const LhsNested m_lhs;
|
||||
const RhsNested m_rhs;
|
||||
const BinaryOp m_functor;
|
||||
};
|
||||
|
||||
|
@ -45,15 +45,19 @@ struct ei_traits<CwiseUnaryOp<UnaryOp, MatrixType> >
|
||||
typedef typename ei_result_of<
|
||||
UnaryOp(typename MatrixType::Scalar)
|
||||
>::type Scalar;
|
||||
typedef typename MatrixType::Nested MatrixTypeNested;
|
||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
enum {
|
||||
MatrixTypeCoeffReadCost = _MatrixTypeNested::CoeffReadCost,
|
||||
MatrixTypeFlags = _MatrixTypeNested::Flags,
|
||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
|
||||
Flags = (MatrixType::Flags & (
|
||||
Flags = (MatrixTypeFlags & (
|
||||
DefaultLostFlagMask | Like1DArrayBit
|
||||
| (ei_functor_traits<UnaryOp>::IsVectorizable ? VectorizableBit : 0))),
|
||||
CoeffReadCost = MatrixType::CoeffReadCost + ei_functor_traits<UnaryOp>::Cost
|
||||
CoeffReadCost = MatrixTypeCoeffReadCost + ei_functor_traits<UnaryOp>::Cost
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -43,6 +43,8 @@ template<typename MatrixType>
|
||||
struct ei_traits<DiagonalCoeffs<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::SizeAtCompileTime == Dynamic ? Dynamic
|
||||
: EIGEN_ENUM_MIN(MatrixType::RowsAtCompileTime,
|
||||
@ -53,9 +55,9 @@ struct ei_traits<DiagonalCoeffs<MatrixType> >
|
||||
MatrixType::MaxColsAtCompileTime),
|
||||
MaxColsAtCompileTime = 1,
|
||||
Flags = (RowsAtCompileTime == Dynamic && ColsAtCompileTime == Dynamic
|
||||
? (unsigned int)MatrixType::Flags
|
||||
: (unsigned int)MatrixType::Flags &~ LargeBit) & DefaultLostFlagMask,
|
||||
CoeffReadCost = MatrixType::CoeffReadCost
|
||||
? (unsigned int)_MatrixTypeNested::Flags
|
||||
: (unsigned int)_MatrixTypeNested::Flags &~ LargeBit) & DefaultLostFlagMask,
|
||||
CoeffReadCost = _MatrixTypeNested::CoeffReadCost
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -42,13 +42,15 @@ template<typename CoeffsVectorType>
|
||||
struct ei_traits<DiagonalMatrix<CoeffsVectorType> >
|
||||
{
|
||||
typedef typename CoeffsVectorType::Scalar Scalar;
|
||||
typedef typename ei_nested<CoeffsVectorType>::type CoeffsVectorTypeTypeNested;
|
||||
typedef typename ei_unref<CoeffsVectorTypeTypeNested>::type _CoeffsVectorTypeTypeNested;
|
||||
enum {
|
||||
RowsAtCompileTime = CoeffsVectorType::SizeAtCompileTime,
|
||||
ColsAtCompileTime = CoeffsVectorType::SizeAtCompileTime,
|
||||
MaxRowsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime,
|
||||
MaxColsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime,
|
||||
Flags = CoeffsVectorType::Flags & DefaultLostFlagMask,
|
||||
CoeffReadCost = CoeffsVectorType::CoeffReadCost
|
||||
Flags = _CoeffsVectorTypeTypeNested::Flags & DefaultLostFlagMask,
|
||||
CoeffReadCost = _CoeffsVectorTypeTypeNested::CoeffReadCost
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -41,6 +41,8 @@ template<typename MatrixType>
|
||||
struct ei_traits<Minor<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
enum {
|
||||
RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ?
|
||||
MatrixType::RowsAtCompileTime - 1 : Dynamic,
|
||||
@ -50,8 +52,8 @@ struct ei_traits<Minor<MatrixType> >
|
||||
MatrixType::MaxRowsAtCompileTime - 1 : Dynamic,
|
||||
MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ?
|
||||
MatrixType::MaxColsAtCompileTime - 1 : Dynamic,
|
||||
Flags = MatrixType::Flags & DefaultLostFlagMask,
|
||||
CoeffReadCost = MatrixType::CoeffReadCost
|
||||
Flags = _MatrixTypeNested::Flags & DefaultLostFlagMask,
|
||||
CoeffReadCost = _MatrixTypeNested::CoeffReadCost
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -41,13 +41,15 @@ template<typename MatrixType>
|
||||
struct ei_traits<Transpose<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||
Flags = MatrixType::Flags ^ RowMajorBit,
|
||||
CoeffReadCost = MatrixType::CoeffReadCost
|
||||
Flags = _MatrixTypeNested::Flags ^ RowMajorBit,
|
||||
CoeffReadCost = _MatrixTypeNested::CoeffReadCost
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -60,13 +60,15 @@ template<int Mode, typename MatrixType>
|
||||
struct ei_traits<Triangular<Mode, MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
|
||||
Flags = MatrixType::Flags & (~(VectorizableBit | Like1DArrayBit)) | Mode,
|
||||
CoeffReadCost = MatrixType::CoeffReadCost
|
||||
Flags = _MatrixTypeNested::Flags & (~(VectorizableBit | Like1DArrayBit)) | Mode,
|
||||
CoeffReadCost = _MatrixTypeNested::CoeffReadCost
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user