hehe, the complicated nesting scheme in Flagged in the previous commit

was a sign that we were doing something wrong. In fact, having
NestByValue as a special case of Flagged was wrong, and the previous
commit, while not buggy, was inefficient because then when the resulting
NestByValue xpr was nested -- hence copied -- the original xpr which was
already nested by value was copied again; hence instead of 1 copy we got
3 copies.
The solution was to ressuscitate the old Temporary.h (renamed
NestByValue.h) as it was the right approach.
This commit is contained in:
Benoit Jacob
2008-05-28 05:14:16 +00:00
parent aebecae510
commit f54760c889
10 changed files with 108 additions and 24 deletions

View File

@@ -45,7 +45,6 @@ const unsigned int SelfAdjointBit = 0x100; ///< means the matrix is selfadjoint
const unsigned int UpperTriangularBit = 0x200; ///< means the strictly triangular lower part is 0
const unsigned int LowerTriangularBit = 0x400; ///< means the strictly triangular upper part is 0
const unsigned int DirectAccessBit = 0x800; ///< means the underlying matrix data can be direclty accessed
const unsigned int NestByValueBit = 0x1000; ///< means the expression should be copied by value when nested
// list of flags that are inherited by default
const unsigned int HereditaryBits = RowMajorBit

View File

@@ -35,6 +35,7 @@ template<typename _Scalar, int _Rows, int _Cols,
class Matrix;
template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged;
template<typename ExpressionType> class NestByValue;
template<typename MatrixType> class Minor;
template<typename MatrixType, int BlockRows=Dynamic, int BlockCols=Dynamic> class Block;
template<typename MatrixType> class Transpose;

View File

@@ -135,7 +135,6 @@ typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
typedef typename Base::PacketScalar PacketScalar; \
typedef typename Eigen::ei_nested<Derived>::type Nested; \
typedef typename Eigen::ei_eval<Derived>::type Eval; \
typedef Eigen::Flagged<Derived, NestByValueBit, 0> Temporary; \
enum { RowsAtCompileTime = Base::RowsAtCompileTime, \
ColsAtCompileTime = Base::ColsAtCompileTime, \
MaxRowsAtCompileTime = Base::MaxRowsAtCompileTime, \

View File

@@ -192,11 +192,14 @@ template<typename T> struct ei_unref<T&> { typedef T type; };
template<typename T> struct ei_unconst { typedef T type; };
template<typename T> struct ei_unconst<const T> { typedef T type; };
template<typename T> struct ei_must_nest_by_value { enum { ret = false }; };
template<typename T> struct ei_must_nest_by_value<NestByValue<T> > { enum { ret = true }; };
template<typename T, int n=1> struct ei_nested
{
typedef typename ei_meta_if<
ei_traits<T>::Flags & NestByValueBit,
ei_must_nest_by_value<T>::ret,
T,
typename ei_meta_if<
int(ei_traits<T>::Flags) & EvalBeforeNestingBit