mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
More clever evaluation of arguments: now it occurs in earlier, in operator*,
before the Product<> type is constructed. This resets template depth on each intermediate evaluation, and gives simpler code. Introducing ei_eval_if_expensive<Derived, n> which evaluates Derived if it's worth it given that each of its coeffs will be accessed n times. Operator* uses this with adequate values of n to evaluate args exactly when needed.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
template<typename T> struct ei_traits;
|
||||
template<typename Lhs, typename Rhs> struct ei_product_eval_mode;
|
||||
template<typename T> struct NumTraits;
|
||||
|
||||
template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols> class Matrix;
|
||||
template<typename ExpressionType> class Lazy;
|
||||
@@ -89,6 +90,13 @@ template<typename T> struct ei_eval
|
||||
ei_traits<T>::MaxColsAtCompileTime> type;
|
||||
};
|
||||
|
||||
template<typename T, int n> struct ei_eval_if_expensive
|
||||
{
|
||||
enum { eval = n * NumTraits<typename T::Scalar>::ReadCost < (n-1) * T::CoeffReadCost };
|
||||
typedef typename ei_meta_if<eval, typename T::Eval, T>::ret type;
|
||||
typedef typename ei_meta_if<eval, typename T::Eval, T&>::ret reftype;
|
||||
};
|
||||
|
||||
template<typename T> struct ei_eval_unless_lazy
|
||||
{
|
||||
typedef typename ei_meta_if<ei_traits<T>::Flags & LazyBit,
|
||||
|
||||
Reference in New Issue
Block a user