Since there is no reason for evaluators to be nested by reference, let's remove the evaluator<>::nestedType indirection.

This commit is contained in:
Gael Guennebaud 2015-09-02 22:10:39 +02:00
parent 51455824ea
commit aa768add0b
17 changed files with 35 additions and 65 deletions

View File

@ -89,7 +89,6 @@ template<typename T>
struct evaluator<const T>
: evaluator<T>
{
typedef evaluator<const T> nestedType;
explicit evaluator(const T& xpr) : evaluator<T>(xpr) {}
};
@ -98,10 +97,6 @@ struct evaluator<const T>
template<typename ExpressionType>
struct evaluator_base : public noncopyable
{
// TODO Check whether nestedType is really needed:
// As long as evaluator are non-copyable, there is no reason to make it different.
typedef evaluator<ExpressionType> nestedType;
// FIXME is it really usefull?
typedef typename traits<ExpressionType>::StorageIndex StorageIndex;
@ -307,7 +302,7 @@ struct unary_evaluator<Transpose<ArgType>, IndexBased>
}
protected:
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
};
// -------------------- CwiseNullaryOp --------------------
@ -411,7 +406,7 @@ struct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, IndexBased >
protected:
const UnaryOp m_functor;
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
};
// -------------------- CwiseBinaryOp --------------------
@ -486,8 +481,8 @@ struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IndexBase
protected:
const BinaryOp m_functor;
typename evaluator<Lhs>::nestedType m_lhsImpl;
typename evaluator<Rhs>::nestedType m_rhsImpl;
evaluator<Lhs> m_lhsImpl;
evaluator<Rhs> m_rhsImpl;
};
// -------------------- CwiseUnaryView --------------------
@ -536,7 +531,7 @@ struct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType>, IndexBased>
protected:
const UnaryOp m_unaryOp;
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
};
// -------------------- Map --------------------
@ -810,7 +805,7 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
}
protected:
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
const variable_if_dynamic<Index, ArgType::RowsAtCompileTime == 1 ? 0 : Dynamic> m_startRow;
const variable_if_dynamic<Index, ArgType::ColsAtCompileTime == 1 ? 0 : Dynamic> m_startCol;
};
@ -879,9 +874,9 @@ struct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
}
protected:
typename evaluator<ConditionMatrixType>::nestedType m_conditionImpl;
typename evaluator<ThenMatrixType>::nestedType m_thenImpl;
typename evaluator<ElseMatrixType>::nestedType m_elseImpl;
evaluator<ConditionMatrixType> m_conditionImpl;
evaluator<ThenMatrixType> m_thenImpl;
evaluator<ElseMatrixType> m_elseImpl;
};
@ -962,7 +957,7 @@ struct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor> >
protected:
const ArgTypeNested m_arg; // FIXME is it OK to store both the argument and its evaluator?? (we have the same situation in evaluator_product)
typename evaluator<ArgTypeNestedCleaned>::nestedType m_argImpl;
evaluator<ArgTypeNestedCleaned> m_argImpl;
const variable_if_dynamic<Index, ArgType::RowsAtCompileTime> m_rows;
const variable_if_dynamic<Index, ArgType::ColsAtCompileTime> m_cols;
};
@ -1080,7 +1075,7 @@ struct evaluator_wrapper_base
}
protected:
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
};
template<typename TArgType>
@ -1215,7 +1210,7 @@ struct unary_evaluator<Reverse<ArgType, Direction> >
}
protected:
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
// If we do not reverse rows, then we do not need to know the number of rows; same for columns
const variable_if_dynamic<Index, ReverseRow ? ArgType::RowsAtCompileTime : 0> m_rows;
@ -1270,7 +1265,7 @@ struct evaluator<Diagonal<ArgType, DiagIndex> >
}
protected:
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
const internal::variable_if_dynamicindex<Index, XprType::DiagIndex> m_index;
private:
@ -1334,8 +1329,6 @@ struct evaluator<EvalToTemp<ArgType> >
typedef typename ArgType::PlainObject PlainObject;
typedef evaluator<PlainObject> Base;
typedef evaluator nestedType;
EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr)
: m_result(xpr.rows(), xpr.cols())
{

View File

@ -106,8 +106,6 @@ struct unary_evaluator<Inverse<ArgType> >
typedef typename InverseType::PlainObject PlainObject;
typedef evaluator<PlainObject> Base;
typedef evaluator<InverseType> nestedType;
enum { Flags = Base::Flags | EvalBeforeNestingBit };
unary_evaluator(const InverseType& inv_xpr)

View File

@ -32,8 +32,6 @@ struct evaluator<Product<Lhs, Rhs, Options> >
typedef Product<Lhs, Rhs, Options> XprType;
typedef product_evaluator<XprType> Base;
typedef evaluator nestedType;
EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(xpr) {}
};
@ -46,8 +44,6 @@ struct evaluator<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, const Produ
typedef CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, const Product<Lhs, Rhs, DefaultProduct> > XprType;
typedef evaluator<Product<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>,const Lhs>, Rhs, DefaultProduct> > Base;
typedef evaluator nestedType;
EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr)
: Base(xpr.functor().m_other * xpr.nestedExpression().lhs() * xpr.nestedExpression().rhs())
{}
@ -61,8 +57,6 @@ struct evaluator<Diagonal<const Product<Lhs, Rhs, DefaultProduct>, DiagIndex> >
typedef Diagonal<const Product<Lhs, Rhs, DefaultProduct>, DiagIndex> XprType;
typedef evaluator<Diagonal<const Product<Lhs, Rhs, LazyProduct>, DiagIndex> > Base;
typedef evaluator nestedType;
EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr)
: Base(Diagonal<const Product<Lhs, Rhs, LazyProduct>, DiagIndex>(
Product<Lhs, Rhs, LazyProduct>(xpr.nestedExpression().lhs(), xpr.nestedExpression().rhs()),
@ -735,8 +729,8 @@ protected:
m_diagImpl.template packet<DiagonalPacketLoadMode,PacketType>(id));
}
typename evaluator<DiagonalType>::nestedType m_diagImpl;
typename evaluator<MatrixType>::nestedType m_matImpl;
evaluator<DiagonalType> m_diagImpl;
evaluator<MatrixType> m_matImpl;
};
// diagonal * dense

View File

@ -390,7 +390,7 @@ public:
const XprType & nestedExpression() const { return m_xpr; }
protected:
typename internal::evaluator<XprType>::nestedType m_evaluator;
internal::evaluator<XprType> m_evaluator;
const XprType &m_xpr;
};

View File

@ -100,8 +100,6 @@ struct evaluator<ReturnByValue<Derived> >
typedef typename internal::traits<Derived>::ReturnType PlainObject;
typedef evaluator<PlainObject> Base;
typedef evaluator nestedType;
EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr)
: m_result(xpr.rows(), xpr.cols())
{

View File

@ -119,8 +119,6 @@ struct evaluator<Solve<Decomposition,RhsType> >
typedef typename SolveType::PlainObject PlainObject;
typedef evaluator<PlainObject> Base;
typedef evaluator nestedType;
EIGEN_DEVICE_FUNC explicit evaluator(const SolveType& solve)
: m_result(solve.rows(), solve.cols())
{

View File

@ -79,7 +79,7 @@ public:
{ return m_evaluator.coeff(row, col); }
protected:
typename internal::evaluator<XprType>::nestedType m_evaluator;
internal::evaluator<XprType> m_evaluator;
const XprType &m_xpr;
};
} // end namespace internal

View File

@ -317,7 +317,6 @@ struct unary_evaluator<Homogeneous<ArgType,Direction>, IndexBased>
typedef Homogeneous<ArgType,Direction> XprType;
typedef typename XprType::PlainObject PlainObject;
typedef evaluator<PlainObject> Base;
typedef evaluator<XprType> nestedType;
explicit unary_evaluator(const XprType& op)
: Base(), m_temp(op)
@ -388,8 +387,6 @@ struct product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, Homogeneous
typedef typename helper::Xpr RefactoredXpr;
typedef evaluator<RefactoredXpr> Base;
typedef evaluator<XprType> nestedType;
EIGEN_DEVICE_FUNC explicit product_evaluator(const XprType& xpr)
: Base( xpr.lhs().nestedExpression() .lazyProduct( xpr.rhs().template topRows<helper::Dim>(xpr.lhs().nestedExpression().cols()) )
+ ConstantBlock(xpr.rhs().row(xpr.rhs().rows()-1),xpr.lhs().rows(), 1) )
@ -431,8 +428,6 @@ struct product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, DenseShape,
typedef typename helper::Xpr RefactoredXpr;
typedef evaluator<RefactoredXpr> Base;
typedef evaluator<XprType> nestedType;
EIGEN_DEVICE_FUNC explicit product_evaluator(const XprType& xpr)
: Base( xpr.lhs().template leftCols<helper::Dim>(xpr.rhs().nestedExpression().rows()) .lazyProduct( xpr.rhs().nestedExpression() )
+ ConstantBlock(xpr.lhs().col(xpr.lhs().cols()-1),1,xpr.rhs().cols()) )

View File

@ -76,8 +76,6 @@ struct evaluator<SolveWithGuess<Decomposition,RhsType, GuessType> >
typedef SolveWithGuess<Decomposition,RhsType,GuessType> SolveType;
typedef typename SolveType::PlainObject PlainObject;
typedef evaluator<PlainObject> Base;
typedef evaluator nestedType;
evaluator(const SolveType& solve)
: m_result(solve.rows(), solve.cols())

View File

@ -456,7 +456,7 @@ struct unary_evaluator<Block<ArgType,BlockRows,BlockCols,InnerPanel>, IteratorBa
protected:
typedef typename evaluator<ArgType>::InnerIterator EvalIterator;
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
const XprType &m_block;
};

View File

@ -146,8 +146,8 @@ public:
protected:
const BinaryOp m_functor;
typename evaluator<Lhs>::nestedType m_lhsImpl;
typename evaluator<Rhs>::nestedType m_rhsImpl;
evaluator<Lhs> m_lhsImpl;
evaluator<Rhs> m_rhsImpl;
};
// "sparse .* sparse"
@ -227,8 +227,8 @@ public:
protected:
const BinaryOp m_functor;
typename evaluator<Lhs>::nestedType m_lhsImpl;
typename evaluator<Rhs>::nestedType m_rhsImpl;
evaluator<Lhs> m_lhsImpl;
evaluator<Rhs> m_rhsImpl;
};
// "dense .* sparse"
@ -295,8 +295,8 @@ public:
protected:
const BinaryOp m_functor;
typename evaluator<Lhs>::nestedType m_lhsImpl;
typename evaluator<Rhs>::nestedType m_rhsImpl;
evaluator<Lhs> m_lhsImpl;
evaluator<Rhs> m_rhsImpl;
};
// "sparse .* dense"
@ -364,8 +364,8 @@ public:
protected:
const BinaryOp m_functor;
typename evaluator<Lhs>::nestedType m_lhsImpl;
typename evaluator<Rhs>::nestedType m_rhsImpl;
evaluator<Lhs> m_lhsImpl;
evaluator<Rhs> m_rhsImpl;
};
}

View File

@ -40,7 +40,7 @@ struct unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>
// typedef typename evaluator<ArgType>::ReverseInnerIterator EvalReverseIterator;
const UnaryOp m_functor;
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
};
template<typename UnaryOp, typename ArgType>
@ -115,7 +115,7 @@ struct unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>
// typedef typename evaluator<ArgType>::ReverseInnerIterator EvalReverseIterator;
const ViewOp m_functor;
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
};
template<typename ViewOp, typename ArgType>

View File

@ -272,8 +272,8 @@ public:
protected:
const LhsArg m_lhs;
typename evaluator<ActualLhs>::nestedType m_lhsXprImpl;
typename evaluator<ActualRhs>::nestedType m_rhsXprImpl;
evaluator<ActualLhs> m_lhsXprImpl;
evaluator<ActualRhs> m_rhsXprImpl;
};
// sparse * dense outer product

View File

@ -39,7 +39,6 @@ struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, Diagonal
: public sparse_diagonal_product_evaluator<Rhs, typename Lhs::DiagonalVectorType, Rhs::Flags&RowMajorBit?SDP_AsScalarProduct:SDP_AsCwiseProduct>
{
typedef Product<Lhs, Rhs, DefaultProduct> XprType;
typedef evaluator<XprType> nestedType;
enum { CoeffReadCost = Dynamic, Flags = Rhs::Flags&RowMajorBit, Alignment = 0 }; // FIXME CoeffReadCost & Flags
typedef sparse_diagonal_product_evaluator<Rhs, typename Lhs::DiagonalVectorType, Rhs::Flags&RowMajorBit?SDP_AsScalarProduct:SDP_AsCwiseProduct> Base;
@ -51,7 +50,6 @@ struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, SparseSh
: public sparse_diagonal_product_evaluator<Lhs, Transpose<const typename Rhs::DiagonalVectorType>, Lhs::Flags&RowMajorBit?SDP_AsCwiseProduct:SDP_AsScalarProduct>
{
typedef Product<Lhs, Rhs, DefaultProduct> XprType;
typedef evaluator<XprType> nestedType;
enum { CoeffReadCost = Dynamic, Flags = Lhs::Flags&RowMajorBit, Alignment = 0 }; // FIXME CoeffReadCost & Flags
typedef sparse_diagonal_product_evaluator<Lhs, Transpose<const typename Rhs::DiagonalVectorType>, Lhs::Flags&RowMajorBit?SDP_AsCwiseProduct:SDP_AsScalarProduct> Base;
@ -84,8 +82,8 @@ public:
{}
protected:
typename evaluator<SparseXprType>::nestedType m_sparseXprImpl;
typename evaluator<DiagonalCoeffType>::nestedType m_diagCoeffImpl;
evaluator<SparseXprType> m_sparseXprImpl;
evaluator<DiagonalCoeffType> m_diagCoeffImpl;
};

View File

@ -69,8 +69,6 @@ struct evaluator<SparseView<Product<Lhs, Rhs, Options> > >
typedef typename XprType::PlainObject PlainObject;
typedef evaluator<PlainObject> Base;
typedef evaluator nestedType;
explicit evaluator(const XprType& xpr)
: m_result(xpr.rows(), xpr.cols())
{

View File

@ -92,7 +92,7 @@ struct unary_evaluator<Transpose<ArgType>, IteratorBased>
explicit unary_evaluator(const XprType& op) :m_argImpl(op.nestedExpression()) {}
protected:
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
};
} // end namespace internal

View File

@ -114,7 +114,7 @@ struct unary_evaluator<SparseView<ArgType>, IteratorBased>
explicit unary_evaluator(const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_view(xpr) {}
protected:
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
const XprType &m_view;
};
@ -182,7 +182,7 @@ struct unary_evaluator<SparseView<ArgType>, IndexBased>
explicit unary_evaluator(const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_view(xpr) {}
protected:
typename evaluator<ArgType>::nestedType m_argImpl;
evaluator<ArgType> m_argImpl;
const XprType &m_view;
};