diff options
author | Gael Guennebaud <g.gael@free.fr> | 2008-05-01 18:58:30 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2008-05-01 18:58:30 +0000 |
commit | ef5b20bc50fb0a44ca48e6167d98437f4f2ee75e (patch) | |
tree | c9bec2736df55f9cb4027fc62ac48982146dba8a | |
parent | 5588def0cf53e0b65740bf51658123a3c6401287 (diff) |
fix flag and cost computations for nested expressions
-rw-r--r-- | Eigen/src/Core/CwiseBinaryOp.h | 22 | ||||
-rw-r--r-- | Eigen/src/Core/CwiseUnaryOp.h | 8 | ||||
-rw-r--r-- | Eigen/src/Core/DiagonalCoeffs.h | 8 | ||||
-rw-r--r-- | Eigen/src/Core/DiagonalMatrix.h | 6 | ||||
-rw-r--r-- | Eigen/src/Core/Minor.h | 6 | ||||
-rw-r--r-- | Eigen/src/Core/Transpose.h | 6 | ||||
-rwxr-xr-x | Eigen/src/Core/Triangular.h | 6 |
7 files changed, 43 insertions, 19 deletions
diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index ca7913efc..3de3e2dd5 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -55,17 +55,25 @@ struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > typename Rhs::Scalar ) >::type Scalar; + typedef typename Lhs::Nested LhsNested; + typedef typename Rhs::Nested RhsNested; + typedef typename ei_unref<LhsNested>::type _LhsNested; + typedef typename ei_unref<RhsNested>::type _RhsNested; enum { + LhsCoeffReadCost = _LhsNested::CoeffReadCost, + RhsCoeffReadCost = _RhsNested::CoeffReadCost, + LhsFlags = _LhsNested::Flags, + RhsFlags = _RhsNested::Flags, RowsAtCompileTime = Lhs::RowsAtCompileTime, ColsAtCompileTime = Lhs::ColsAtCompileTime, MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime, MaxColsAtCompileTime = Lhs::MaxColsAtCompileTime, - Flags = ((Lhs::Flags | Rhs::Flags) & ( + Flags = ((LhsFlags | RhsFlags) & ( DefaultLostFlagMask | Like1DArrayBit - | (ei_functor_traits<BinaryOp>::IsVectorizable && ((Lhs::Flags & RowMajorBit)==(Rhs::Flags & RowMajorBit)) - ? Lhs::Flags & Rhs::Flags & VectorizableBit : 0))), - CoeffReadCost = Lhs::CoeffReadCost + Rhs::CoeffReadCost + ei_functor_traits<BinaryOp>::Cost + | (ei_functor_traits<BinaryOp>::IsVectorizable && ((LhsFlags & RowMajorBit)==(RhsFlags & RowMajorBit)) + ? LhsFlags & RhsFlags & VectorizableBit : 0))), + CoeffReadCost = LhsCoeffReadCost + RhsCoeffReadCost + ei_functor_traits<BinaryOp>::Cost }; }; @@ -76,6 +84,8 @@ class CwiseBinaryOp : ei_no_assignment_operator, public: EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseBinaryOp) + typedef typename ei_traits<CwiseBinaryOp>::LhsNested LhsNested; + typedef typename ei_traits<CwiseBinaryOp>::RhsNested RhsNested; CwiseBinaryOp(const Lhs& lhs, const Rhs& rhs, const BinaryOp& func = BinaryOp()) : m_lhs(lhs), m_rhs(rhs), m_functor(func) @@ -99,8 +109,8 @@ class CwiseBinaryOp : ei_no_assignment_operator, } protected: - const typename Lhs::Nested m_lhs; - const typename Rhs::Nested m_rhs; + const LhsNested m_lhs; + const RhsNested m_rhs; const BinaryOp m_functor; }; diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h index 5106254d2..76c6ed818 100644 --- a/Eigen/src/Core/CwiseUnaryOp.h +++ b/Eigen/src/Core/CwiseUnaryOp.h @@ -45,15 +45,19 @@ struct ei_traits<CwiseUnaryOp<UnaryOp, MatrixType> > typedef typename ei_result_of< UnaryOp(typename MatrixType::Scalar) >::type Scalar; + typedef typename MatrixType::Nested MatrixTypeNested; + typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; enum { + MatrixTypeCoeffReadCost = _MatrixTypeNested::CoeffReadCost, + MatrixTypeFlags = _MatrixTypeNested::Flags, RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - Flags = (MatrixType::Flags & ( + Flags = (MatrixTypeFlags & ( DefaultLostFlagMask | Like1DArrayBit | (ei_functor_traits<UnaryOp>::IsVectorizable ? VectorizableBit : 0))), - CoeffReadCost = MatrixType::CoeffReadCost + ei_functor_traits<UnaryOp>::Cost + CoeffReadCost = MatrixTypeCoeffReadCost + ei_functor_traits<UnaryOp>::Cost }; }; diff --git a/Eigen/src/Core/DiagonalCoeffs.h b/Eigen/src/Core/DiagonalCoeffs.h index 8cdb4735e..635d847f7 100644 --- a/Eigen/src/Core/DiagonalCoeffs.h +++ b/Eigen/src/Core/DiagonalCoeffs.h @@ -43,6 +43,8 @@ template<typename MatrixType> struct ei_traits<DiagonalCoeffs<MatrixType> > { typedef typename MatrixType::Scalar Scalar; + typedef typename ei_nested<MatrixType>::type MatrixTypeNested; + typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; enum { RowsAtCompileTime = MatrixType::SizeAtCompileTime == Dynamic ? Dynamic : EIGEN_ENUM_MIN(MatrixType::RowsAtCompileTime, @@ -53,9 +55,9 @@ struct ei_traits<DiagonalCoeffs<MatrixType> > MatrixType::MaxColsAtCompileTime), MaxColsAtCompileTime = 1, Flags = (RowsAtCompileTime == Dynamic && ColsAtCompileTime == Dynamic - ? (unsigned int)MatrixType::Flags - : (unsigned int)MatrixType::Flags &~ LargeBit) & DefaultLostFlagMask, - CoeffReadCost = MatrixType::CoeffReadCost + ? (unsigned int)_MatrixTypeNested::Flags + : (unsigned int)_MatrixTypeNested::Flags &~ LargeBit) & DefaultLostFlagMask, + CoeffReadCost = _MatrixTypeNested::CoeffReadCost }; }; diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index 94c7d2b88..972ef464e 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -42,13 +42,15 @@ template<typename CoeffsVectorType> struct ei_traits<DiagonalMatrix<CoeffsVectorType> > { typedef typename CoeffsVectorType::Scalar Scalar; + typedef typename ei_nested<CoeffsVectorType>::type CoeffsVectorTypeTypeNested; + typedef typename ei_unref<CoeffsVectorTypeTypeNested>::type _CoeffsVectorTypeTypeNested; enum { RowsAtCompileTime = CoeffsVectorType::SizeAtCompileTime, ColsAtCompileTime = CoeffsVectorType::SizeAtCompileTime, MaxRowsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime, MaxColsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime, - Flags = CoeffsVectorType::Flags & DefaultLostFlagMask, - CoeffReadCost = CoeffsVectorType::CoeffReadCost + Flags = _CoeffsVectorTypeTypeNested::Flags & DefaultLostFlagMask, + CoeffReadCost = _CoeffsVectorTypeTypeNested::CoeffReadCost }; }; diff --git a/Eigen/src/Core/Minor.h b/Eigen/src/Core/Minor.h index b44dca6e5..ef61a7f60 100644 --- a/Eigen/src/Core/Minor.h +++ b/Eigen/src/Core/Minor.h @@ -41,6 +41,8 @@ template<typename MatrixType> struct ei_traits<Minor<MatrixType> > { typedef typename MatrixType::Scalar Scalar; + typedef typename ei_nested<MatrixType>::type MatrixTypeNested; + typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; enum { RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ? MatrixType::RowsAtCompileTime - 1 : Dynamic, @@ -50,8 +52,8 @@ struct ei_traits<Minor<MatrixType> > MatrixType::MaxRowsAtCompileTime - 1 : Dynamic, MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ? MatrixType::MaxColsAtCompileTime - 1 : Dynamic, - Flags = MatrixType::Flags & DefaultLostFlagMask, - CoeffReadCost = MatrixType::CoeffReadCost + Flags = _MatrixTypeNested::Flags & DefaultLostFlagMask, + CoeffReadCost = _MatrixTypeNested::CoeffReadCost }; }; diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 424557754..c2ca4a63d 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -41,13 +41,15 @@ template<typename MatrixType> struct ei_traits<Transpose<MatrixType> > { typedef typename MatrixType::Scalar Scalar; + typedef typename ei_nested<MatrixType>::type MatrixTypeNested; + typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; enum { RowsAtCompileTime = MatrixType::ColsAtCompileTime, ColsAtCompileTime = MatrixType::RowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - Flags = MatrixType::Flags ^ RowMajorBit, - CoeffReadCost = MatrixType::CoeffReadCost + Flags = _MatrixTypeNested::Flags ^ RowMajorBit, + CoeffReadCost = _MatrixTypeNested::CoeffReadCost }; }; diff --git a/Eigen/src/Core/Triangular.h b/Eigen/src/Core/Triangular.h index 0e53111b9..c867b8483 100755 --- a/Eigen/src/Core/Triangular.h +++ b/Eigen/src/Core/Triangular.h @@ -60,13 +60,15 @@ template<int Mode, typename MatrixType> struct ei_traits<Triangular<Mode, MatrixType> > { typedef typename MatrixType::Scalar Scalar; + typedef typename ei_nested<MatrixType>::type MatrixTypeNested; + typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; enum { RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - Flags = MatrixType::Flags & (~(VectorizableBit | Like1DArrayBit)) | Mode, - CoeffReadCost = MatrixType::CoeffReadCost + Flags = _MatrixTypeNested::Flags & (~(VectorizableBit | Like1DArrayBit)) | Mode, + CoeffReadCost = _MatrixTypeNested::CoeffReadCost }; }; |