[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/eigen2/Eigen
From: BenoƮt Jacob <jacob () math ! jussieu ! fr>
Date: 2008-05-28 5:14:16
Message-ID: 1211951656.650111.5730.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 813550 by bjacob:
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.
M +1 -0 Core
M +1 -14 src/Core/Flagged.h
M +4 -3 src/Core/MatrixBase.h
A src/Core/NestByValue.h src/Core/Temporary.h#807500 [License: GPL \
(v3+) LGPL (v3+)] M +2 -2 src/Core/Product.h
M +2 -2 src/Core/Transpose.h
M +0 -1 src/Core/util/Constants.h
M +1 -0 src/Core/util/ForwardDeclarations.h
M +0 -1 src/Core/util/Macros.h
M +4 -1 src/Core/util/Meta.h
--- branches/work/eigen2/Eigen/Core #813549:813550
@@ -30,6 +30,7 @@
#include "src/Core/Coeffs.h"
#include "src/Core/Assign.h"
#include "src/Core/MatrixStorage.h"
+#include "src/Core/NestByValue.h"
#include "src/Core/Flagged.h"
#include "src/Core/Matrix.h"
#include "src/Core/CwiseBinaryOp.h"
--- branches/work/eigen2/Eigen/src/Core/Flagged.h #813549:813550
@@ -94,11 +94,7 @@
}
protected:
- const typename ei_meta_if<
- Added & ~Removed & NestByValueBit,
- ExpressionType,
- typename ExpressionType::Nested
- >::ret m_matrix;
+ typename ExpressionType::Nested m_matrix;
};
/** \returns an expression of *this with added flags
@@ -121,13 +117,4 @@
return derived();
}
-/** \returns an expression of *this with the NestByValueBit flag added.
- */
-template<typename Derived>
-inline const Flagged<Derived, NestByValueBit, 0>
-MatrixBase<Derived>::nestByValue() const
-{
- return derived();
-}
-
#endif // EIGEN_FLAGGED_H
--- branches/work/eigen2/Eigen/src/Core/MatrixBase.h #813549:813550
@@ -305,8 +305,8 @@
Transpose<Derived> transpose();
const Transpose<Derived> transpose() const;
const Transpose<
- Flagged<CwiseUnaryOp<ei_scalar_conjugate_op<typename \
ei_traits<Derived>::Scalar>, Derived>
- , NestByValueBit, 0> >
+ NestByValue<CwiseUnaryOp<ei_scalar_conjugate_op<typename \
ei_traits<Derived>::Scalar>, Derived> > + >
adjoint() const;
//@}
@@ -452,7 +452,6 @@
template<unsigned int Added>
const Flagged<Derived, Added, 0> marked() const;
const Flagged<Derived, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit> lazy() \
const;
- const Flagged<Derived, NestByValueBit, 0> nestByValue() const;
/** \returns number of elements to skip to pass from one row (resp. column) to \
another
* for a row-major (resp. column-major) matrix.
@@ -460,6 +459,8 @@
* of the underlying matrix.
*/
inline int stride(void) const { return derived()._stride(); }
+
+ inline const NestByValue<Derived> nestByValue() const;
//@}
/// \name Coefficient-wise operations
--- branches/work/eigen2/Eigen/src/Core/Product.h #813549:813550
@@ -165,7 +165,7 @@
template<typename T, int n=1> struct ei_product_nested_rhs
{
typedef typename ei_meta_if<
- (ei_traits<T>::Flags & NestByValueBit) && (!(ei_traits<T>::Flags & RowMajorBit)) \
&& (int(ei_traits<T>::Flags) & DirectAccessBit), + ei_must_nest_by_value<T>::ret \
&& (!(ei_traits<T>::Flags & RowMajorBit)) && (int(ei_traits<T>::Flags) & \
DirectAccessBit), T,
typename ei_meta_if<
((ei_traits<T>::Flags & EvalBeforeNestingBit)
@@ -181,7 +181,7 @@
template<typename T, int n=1> struct ei_product_nested_lhs
{
typedef typename ei_meta_if<
- ei_traits<T>::Flags & NestByValueBit && (int(ei_traits<T>::Flags) & \
DirectAccessBit), + ei_must_nest_by_value<T>::ret && (int(ei_traits<T>::Flags) & \
DirectAccessBit), T,
typename ei_meta_if<
int(ei_traits<T>::Flags) & EvalBeforeNestingBit
--- branches/work/eigen2/Eigen/src/Core/Transpose.h #813549:813550
@@ -126,8 +126,8 @@
* \sa transpose(), conjugate(), class Transpose, class ei_scalar_conjugate_op */
template<typename Derived>
inline const Transpose<
- Flagged<CwiseUnaryOp<ei_scalar_conjugate_op<typename \
ei_traits<Derived>::Scalar>, Derived >
- , NestByValueBit, 0> >
+ NestByValue<CwiseUnaryOp<ei_scalar_conjugate_op<typename \
ei_traits<Derived>::Scalar>, Derived > > + >
MatrixBase<Derived>::adjoint() const
{
return conjugate().nestByValue();
--- branches/work/eigen2/Eigen/src/Core/util/Constants.h #813549:813550
@@ -45,7 +45,6 @@
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
--- branches/work/eigen2/Eigen/src/Core/util/ForwardDeclarations.h #813549:813550
@@ -35,6 +35,7 @@
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;
--- branches/work/eigen2/Eigen/src/Core/util/Macros.h #813549:813550
@@ -135,7 +135,6 @@
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, \
--- branches/work/eigen2/Eigen/src/Core/util/Meta.h #813549:813550
@@ -192,11 +192,14 @@
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic