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:
Benoit Jacob
2008-04-03 14:17:56 +00:00
parent 4448f2620d
commit b8900d0b80
2 changed files with 21 additions and 7 deletions

View File

@@ -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,