From d1a29d6319d6919e0c3d1c624ad45d8202be1942 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 3 Apr 2008 11:10:17 +0000 Subject: -new: recursive costs system, useful to determine automatically when to evaluate arguments and when to meta-unroll. -use it in Product to determine when to eval args. not yet used to determine when to unroll. for now, not used anywhere else but that'll follow. -fix badness of my last commit --- Eigen/src/Core/AssociativeFunctors.h | 20 +++--- Eigen/src/Core/Block.h | 3 +- Eigen/src/Core/CommaInitializer.h | 6 +- Eigen/src/Core/CwiseBinaryOp.h | 39 ++++++----- Eigen/src/Core/CwiseUnaryOp.h | 123 ++++++++++++++++++++--------------- Eigen/src/Core/DiagonalCoeffs.h | 5 +- Eigen/src/Core/DiagonalMatrix.h | 3 +- Eigen/src/Core/ForwardDeclarations.h | 60 +++++++++-------- Eigen/src/Core/Identity.h | 3 +- Eigen/src/Core/Lazy.h | 91 ++++++++++++++++++++++++++ Eigen/src/Core/Map.h | 3 +- Eigen/src/Core/Matrix.h | 3 +- Eigen/src/Core/MatrixBase.h | 58 +++++++++-------- Eigen/src/Core/Minor.h | 3 +- Eigen/src/Core/NumTraits.h | 30 +++++++-- Eigen/src/Core/Ones.h | 3 +- Eigen/src/Core/Product.h | 52 ++++++++++----- Eigen/src/Core/Random.h | 9 +-- Eigen/src/Core/Redux.h | 10 +-- Eigen/src/Core/Swap.h | 2 +- Eigen/src/Core/Transpose.h | 5 +- Eigen/src/Core/Util.h | 17 ++--- Eigen/src/Core/Zero.h | 3 +- 23 files changed, 359 insertions(+), 192 deletions(-) create mode 100644 Eigen/src/Core/Lazy.h (limited to 'Eigen/src/Core') diff --git a/Eigen/src/Core/AssociativeFunctors.h b/Eigen/src/Core/AssociativeFunctors.h index fd42de9ec..3b3a09ed9 100644 --- a/Eigen/src/Core/AssociativeFunctors.h +++ b/Eigen/src/Core/AssociativeFunctors.h @@ -30,8 +30,9 @@ * * \sa class CwiseBinaryOp, MatrixBase::operator+, class PartialRedux, MatrixBase::sum() */ -struct ei_scalar_sum_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a, const Scalar& b) const { return a + b; } +template struct ei_scalar_sum_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a, const Scalar& b) const { return a + b; } + enum { Cost = NumTraits::AddCost }; }; /** \internal @@ -39,8 +40,9 @@ struct ei_scalar_sum_op EIGEN_EMPTY_STRUCT { * * \sa class CwiseBinaryOp, MatrixBase::cwiseProduct(), class PartialRedux, MatrixBase::redux() */ -struct ei_scalar_product_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a, const Scalar& b) const { return a * b; } +template struct ei_scalar_product_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a, const Scalar& b) const { return a * b; } + enum { Cost = NumTraits::MulCost }; }; /** \internal @@ -48,8 +50,9 @@ struct ei_scalar_product_op EIGEN_EMPTY_STRUCT { * * \sa class CwiseBinaryOp, MatrixBase::cwiseMin, class PartialRedux, MatrixBase::minCoeff() */ -struct ei_scalar_min_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a, const Scalar& b) const { return std::min(a, b); } +template struct ei_scalar_min_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a, const Scalar& b) const { return std::min(a, b); } + enum { Cost = ConditionalJumpCost + NumTraits::AddCost }; }; /** \internal @@ -57,8 +60,9 @@ struct ei_scalar_min_op EIGEN_EMPTY_STRUCT { * * \sa class CwiseBinaryOp, MatrixBase::cwiseMax, class PartialRedux, MatrixBase::maxCoeff() */ -struct ei_scalar_max_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a, const Scalar& b) const { return std::max(a, b); } +template struct ei_scalar_max_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a, const Scalar& b) const { return std::max(a, b); } + enum { Cost = ConditionalJumpCost + NumTraits::AddCost }; }; #endif // EIGEN_ASSOCIATIVE_FUNCTORS_H diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 4c672e4f2..34f98030e 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -69,7 +69,8 @@ struct ei_traits > : (BlockCols==Dynamic ? MatrixType::MaxColsAtCompileTime : BlockCols), Flags = RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic ? (unsigned int)MatrixType::Flags - : (unsigned int)MatrixType::Flags &~ LargeBit + : (unsigned int)MatrixType::Flags &~ LargeBit, + CoeffReadCost = MatrixType::CoeffReadCost }; }; diff --git a/Eigen/src/Core/CommaInitializer.h b/Eigen/src/Core/CommaInitializer.h index 656ee3002..d7a5fcb47 100644 --- a/Eigen/src/Core/CommaInitializer.h +++ b/Eigen/src/Core/CommaInitializer.h @@ -23,8 +23,8 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . -#ifndef EIGEN_COMMA_INITIALIZER_H -#define EIGEN_COMMA_INITIALIZER_H +#ifndef EIGEN_COMMAINITIALIZER_H +#define EIGEN_COMMAINITIALIZER_H /** \internal * Helper class to define the MatrixBase::operator<< @@ -120,4 +120,4 @@ MatrixBase::operator<<(const MatrixBase& other) return CommaInitializer(*static_cast(this), other); } -#endif // EIGEN_COMMA_INITIALIZER_H +#endif // EIGEN_COMMAINITIALIZER_H diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index 9a83f4257..12da94a6c 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -60,7 +60,8 @@ struct ei_traits > ColsAtCompileTime = Lhs::ColsAtCompileTime, MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime, MaxColsAtCompileTime = Lhs::MaxColsAtCompileTime, - Flags = Lhs::Flags | Rhs::Flags + Flags = Lhs::Flags | Rhs::Flags, + CoeffReadCost = Lhs::CoeffReadCost + Rhs::CoeffReadCost + BinaryOp::Cost }; }; @@ -99,8 +100,9 @@ class CwiseBinaryOp : ei_no_assignment_operator, * * \sa class CwiseBinaryOp, MatrixBase::operator- */ -struct ei_scalar_difference_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a, const Scalar& b) const { return a - b; } +template struct ei_scalar_difference_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a, const Scalar& b) const { return a - b; } + enum { Cost = NumTraits::AddCost }; }; /** \internal @@ -108,8 +110,9 @@ struct ei_scalar_difference_op EIGEN_EMPTY_STRUCT { * * \sa class CwiseBinaryOp, MatrixBase::cwiseQuotient() */ -struct ei_scalar_quotient_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a, const Scalar& b) const { return a / b; } +template struct ei_scalar_quotient_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a, const Scalar& b) const { return a / b; } + enum { Cost = 2 * NumTraits::MulCost }; }; /**\returns an expression of the difference of \c *this and \a other @@ -118,10 +121,12 @@ struct ei_scalar_quotient_op EIGEN_EMPTY_STRUCT { */ template template -const CwiseBinaryOp +const CwiseBinaryOp::Scalar>, + Derived, OtherDerived> MatrixBase::operator-(const MatrixBase &other) const { - return CwiseBinaryOp(derived(), other.derived()); + return CwiseBinaryOp, + Derived, OtherDerived>(derived(), other.derived()); } /** replaces \c *this by \c *this - \a other. @@ -144,10 +149,10 @@ MatrixBase::operator-=(const MatrixBase &other) */ template template -const CwiseBinaryOp +const CwiseBinaryOp::Scalar>, Derived, OtherDerived> MatrixBase::operator+(const MatrixBase &other) const { - return CwiseBinaryOp(derived(), other.derived()); + return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); } /** replaces \c *this by \c *this + \a other. @@ -168,10 +173,10 @@ MatrixBase::operator+=(const MatrixBase& other) */ template template -const CwiseBinaryOp +const CwiseBinaryOp::Scalar>, Derived, OtherDerived> MatrixBase::cwiseProduct(const MatrixBase &other) const { - return CwiseBinaryOp(derived(), other.derived()); + return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); } /** \returns an expression of the coefficient-wise quotient of *this and \a other @@ -180,10 +185,10 @@ MatrixBase::cwiseProduct(const MatrixBase &other) const */ template template -const CwiseBinaryOp +const CwiseBinaryOp::Scalar>, Derived, OtherDerived> MatrixBase::cwiseQuotient(const MatrixBase &other) const { - return CwiseBinaryOp(derived(), other.derived()); + return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); } /** \returns an expression of the coefficient-wise min of *this and \a other @@ -192,10 +197,10 @@ MatrixBase::cwiseQuotient(const MatrixBase &other) const */ template template -const CwiseBinaryOp +const CwiseBinaryOp::Scalar>, Derived, OtherDerived> MatrixBase::cwiseMin(const MatrixBase &other) const { - return CwiseBinaryOp(derived(), other.derived()); + return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); } /** \returns an expression of the coefficient-wise max of *this and \a other @@ -204,10 +209,10 @@ MatrixBase::cwiseMin(const MatrixBase &other) const */ template template -const CwiseBinaryOp +const CwiseBinaryOp::Scalar>, Derived, OtherDerived> MatrixBase::cwiseMax(const MatrixBase &other) const { - return CwiseBinaryOp(derived(), other.derived()); + return CwiseBinaryOp, Derived, OtherDerived>(derived(), other.derived()); } /** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h index d3cc6ad30..548d500a1 100644 --- a/Eigen/src/Core/CwiseUnaryOp.h +++ b/Eigen/src/Core/CwiseUnaryOp.h @@ -50,7 +50,8 @@ struct ei_traits > ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - Flags = MatrixType::Flags + Flags = MatrixType::Flags, + CoeffReadCost = MatrixType::CoeffReadCost + UnaryOp::Cost }; }; @@ -103,17 +104,18 @@ MatrixBase::cwise(const CustomUnaryOp& func) const * * \sa class CwiseUnaryOp, MatrixBase::operator- */ -struct ei_scalar_opposite_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a) const { return -a; } +template struct ei_scalar_opposite_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a) const { return -a; } + enum { Cost = NumTraits::AddCost }; }; /** \returns an expression of the opposite of \c *this */ template -const CwiseUnaryOp +const CwiseUnaryOp::Scalar>,Derived> MatrixBase::operator-() const { - return CwiseUnaryOp(derived()); + return CwiseUnaryOp, Derived>(derived()); } /** \internal @@ -121,17 +123,18 @@ MatrixBase::operator-() const * * \sa class CwiseUnaryOp, MatrixBase::cwiseAbs */ -struct ei_scalar_abs_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a) const { return ei_abs(a); } +template struct ei_scalar_abs_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a) const { return ei_abs(a); } + enum { Cost = NumTraits::AddCost }; }; /** \returns an expression of the coefficient-wise absolute value of \c *this */ template -const CwiseUnaryOp +const CwiseUnaryOp::Scalar>,Derived> MatrixBase::cwiseAbs() const { - return CwiseUnaryOp(derived()); + return CwiseUnaryOp,Derived>(derived()); } /** \internal @@ -139,17 +142,18 @@ MatrixBase::cwiseAbs() const * * \sa class CwiseUnaryOp, MatrixBase::cwiseAbs2 */ -struct ei_scalar_abs2_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a) const { return ei_abs2(a); } +template struct ei_scalar_abs2_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a) const { return ei_abs2(a); } + enum { Cost = NumTraits::MulCost }; }; /** \returns an expression of the coefficient-wise squared absolute value of \c *this */ template -const CwiseUnaryOp +const CwiseUnaryOp::Scalar>,Derived> MatrixBase::cwiseAbs2() const { - return CwiseUnaryOp(derived()); + return CwiseUnaryOp,Derived>(derived()); } /** \internal @@ -157,18 +161,19 @@ MatrixBase::cwiseAbs2() const * * \sa class CwiseUnaryOp, MatrixBase::conjugate() */ -struct ei_scalar_conjugate_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a) const { return ei_conj(a); } +template struct ei_scalar_conjugate_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a) const { return ei_conj(a); } + enum { Cost = NumTraits::IsComplex ? NumTraits::AddCost : 0 }; }; /** \returns an expression of the complex conjugate of *this. * * \sa adjoint() */ template -const CwiseUnaryOp +const CwiseUnaryOp::Scalar>, Derived> MatrixBase::conjugate() const { - return CwiseUnaryOp(derived()); + return CwiseUnaryOp, Derived>(derived()); } /** \internal @@ -176,10 +181,11 @@ MatrixBase::conjugate() const * * \sa class CwiseUnaryOp, MatrixBase::cast() */ -template +template struct ei_scalar_cast_op EIGEN_EMPTY_STRUCT { - typedef NewType result_type; - template NewType operator() (const Scalar& a) const { return static_cast(a); } + typedef NewType result_type; + const NewType operator() (const Scalar& a) const { return static_cast(a); } + enum { Cost = ei_is_same_type::ret ? 0 : NumTraits::AddCost }; }; /** \returns an expression of *this with the \a Scalar type casted to @@ -191,10 +197,10 @@ struct ei_scalar_cast_op EIGEN_EMPTY_STRUCT { */ template template -const CwiseUnaryOp, Derived> +const CwiseUnaryOp::Scalar, NewType>, Derived> MatrixBase::cast() const { - return CwiseUnaryOp, Derived>(derived()); + return CwiseUnaryOp, Derived>(derived()); } /** \internal @@ -204,23 +210,26 @@ MatrixBase::cast() const */ template struct ei_scalar_multiple_op { - ei_scalar_multiple_op(const Scalar& other) : m_other(other) {} - Scalar operator() (const Scalar& a) const { return a * m_other; } - const Scalar m_other; + ei_scalar_multiple_op(const Scalar& other) : m_other(other) {} + Scalar operator() (const Scalar& a) const { return a * m_other; } + const Scalar m_other; + enum { Cost = NumTraits::MulCost }; }; template struct ei_scalar_quotient1_impl { - ei_scalar_quotient1_impl(const Scalar& other) : m_other(static_cast(1) / other) {} - Scalar operator() (const Scalar& a) const { return a * m_other; } - const Scalar m_other; + ei_scalar_quotient1_impl(const Scalar& other) : m_other(static_cast(1) / other) {} + Scalar operator() (const Scalar& a) const { return a * m_other; } + const Scalar m_other; + enum { Cost = NumTraits::MulCost }; }; template struct ei_scalar_quotient1_impl { - ei_scalar_quotient1_impl(const Scalar& other) : m_other(other) {} - Scalar operator() (const Scalar& a) const { return a / m_other; } - const Scalar m_other; + ei_scalar_quotient1_impl(const Scalar& other) : m_other(other) {} + Scalar operator() (const Scalar& a) const { return a / m_other; } + const Scalar m_other; + enum { Cost = 2 * NumTraits::MulCost }; }; /** \internal @@ -274,16 +283,17 @@ MatrixBase::operator/=(const Scalar& other) * * \sa class CwiseUnaryOp, MatrixBase::cwiseSqrt() */ -struct ei_scalar_sqrt_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a) const { return ei_sqrt(a); } +template struct ei_scalar_sqrt_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a) const { return ei_sqrt(a); } + enum { Cost = 5 * NumTraits::MulCost }; }; /** \returns an expression of the coefficient-wise square root of *this. */ template -const CwiseUnaryOp +const CwiseUnaryOp::Scalar>, Derived> MatrixBase::cwiseSqrt() const { - return CwiseUnaryOp(derived()); + return CwiseUnaryOp, Derived>(derived()); } /** \internal @@ -291,16 +301,17 @@ MatrixBase::cwiseSqrt() const * * \sa class CwiseUnaryOp, MatrixBase::cwiseExp() */ -struct ei_scalar_exp_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a) const { return ei_exp(a); } +template struct ei_scalar_exp_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a) const { return ei_exp(a); } + enum { Cost = 5 * NumTraits::MulCost }; }; /** \returns an expression of the coefficient-wise exponential of *this. */ template -const CwiseUnaryOp +const CwiseUnaryOp::Scalar>, Derived> MatrixBase::cwiseExp() const { - return CwiseUnaryOp(derived()); + return CwiseUnaryOp, Derived>(derived()); } /** \internal @@ -308,16 +319,17 @@ MatrixBase::cwiseExp() const * * \sa class CwiseUnaryOp, MatrixBase::cwiseLog() */ -struct ei_scalar_log_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a) const { return ei_log(a); } +template struct ei_scalar_log_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a) const { return ei_log(a); } + enum { Cost = 5 * NumTraits::MulCost }; }; /** \returns an expression of the coefficient-wise logarithm of *this. */ template -const CwiseUnaryOp +const CwiseUnaryOp::Scalar>, Derived> MatrixBase::cwiseLog() const { - return CwiseUnaryOp(derived()); + return CwiseUnaryOp, Derived>(derived()); } /** \internal @@ -325,16 +337,17 @@ MatrixBase::cwiseLog() const * * \sa class CwiseUnaryOp, MatrixBase::cwiseCos() */ -struct ei_scalar_cos_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a) const { return ei_cos(a); } +template struct ei_scalar_cos_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a) const { return ei_cos(a); } + enum { Cost = 5 * NumTraits::MulCost }; }; /** \returns an expression of the coefficient-wise cosine of *this. */ template -const CwiseUnaryOp +const CwiseUnaryOp::Scalar>, Derived> MatrixBase::cwiseCos() const { - return CwiseUnaryOp(derived()); + return CwiseUnaryOp, Derived>(derived()); } /** \internal @@ -342,16 +355,17 @@ MatrixBase::cwiseCos() const * * \sa class CwiseUnaryOp, MatrixBase::cwiseSin() */ -struct ei_scalar_sin_op EIGEN_EMPTY_STRUCT { - template Scalar operator() (const Scalar& a) const { return ei_sin(a); } +template struct ei_scalar_sin_op EIGEN_EMPTY_STRUCT { + const Scalar operator() (const Scalar& a) const { return ei_sin(a); } + enum { Cost = 5 * NumTraits::MulCost }; }; /** \returns an expression of the coefficient-wise sine of *this. */ template -const CwiseUnaryOp +const CwiseUnaryOp::Scalar>, Derived> MatrixBase::cwiseSin() const { - return CwiseUnaryOp(derived()); + return CwiseUnaryOp, Derived>(derived()); } /** \internal @@ -361,9 +375,10 @@ MatrixBase::cwiseSin() const */ template struct ei_scalar_pow_op { - ei_scalar_pow_op(const Scalar& exponent) : m_exponent(exponent) {} - Scalar operator() (const Scalar& a) const { return ei_pow(a, m_exponent); } - const Scalar m_exponent; + ei_scalar_pow_op(const Scalar& exponent) : m_exponent(exponent) {} + Scalar operator() (const Scalar& a) const { return ei_pow(a, m_exponent); } + const Scalar m_exponent; + enum { Cost = 5 * NumTraits::MulCost }; }; /** \relates MatrixBase */ diff --git a/Eigen/src/Core/DiagonalCoeffs.h b/Eigen/src/Core/DiagonalCoeffs.h index 417daa8ce..030de5cf0 100644 --- a/Eigen/src/Core/DiagonalCoeffs.h +++ b/Eigen/src/Core/DiagonalCoeffs.h @@ -52,9 +52,10 @@ struct ei_traits > : EIGEN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime), MaxColsAtCompileTime = 1, - Flags = RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic + Flags = RowsAtCompileTime == Dynamic && ColsAtCompileTime == Dynamic ? (unsigned int)MatrixType::Flags - : (unsigned int)MatrixType::Flags &~ LargeBit + : (unsigned int)MatrixType::Flags &~ LargeBit, + CoeffReadCost = MatrixType::CoeffReadCost }; }; diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index f46e8ad0d..b7fffab72 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -47,7 +47,8 @@ struct ei_traits > ColsAtCompileTime = CoeffsVectorType::SizeAtCompileTime, MaxRowsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime, MaxColsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime, - Flags = CoeffsVectorType::Flags + Flags = CoeffsVectorType::Flags, + CoeffReadCost = CoeffsVectorType::CoeffReadCost }; }; diff --git a/Eigen/src/Core/ForwardDeclarations.h b/Eigen/src/Core/ForwardDeclarations.h index 58e1bf353..50cffe637 100644 --- a/Eigen/src/Core/ForwardDeclarations.h +++ b/Eigen/src/Core/ForwardDeclarations.h @@ -36,7 +36,7 @@ template class Transpose; template class Conjugate; template class CwiseBinaryOp; template class CwiseUnaryOp; -template::EvalMode > class Product; +template::value> class Product; template class Random; template class Zero; template class Ones; @@ -48,55 +48,53 @@ template class Eval; template class EvalOMP; template class PartialRedux; -struct ei_scalar_sum_op; -struct ei_scalar_difference_op; -struct ei_scalar_product_op; -struct ei_scalar_quotient_op; -struct ei_scalar_opposite_op; -struct ei_scalar_conjugate_op; -struct ei_scalar_abs_op; -struct ei_scalar_abs2_op; -struct ei_scalar_sqrt_op; -struct ei_scalar_exp_op; -struct ei_scalar_log_op; -struct ei_scalar_cos_op; -struct ei_scalar_sin_op; -template struct ei_scalar_pow_op; -template struct ei_scalar_cast_op; -template struct ei_scalar_multiple_op; -template struct ei_scalar_quotient1_op; -struct ei_scalar_min_op; -struct ei_scalar_max_op; +template struct ei_scalar_sum_op; +template struct ei_scalar_difference_op; +template struct ei_scalar_product_op; +template struct ei_scalar_quotient_op; +template struct ei_scalar_opposite_op; +template struct ei_scalar_conjugate_op; +template struct ei_scalar_abs_op; +template struct ei_scalar_abs2_op; +template struct ei_scalar_sqrt_op; +template struct ei_scalar_exp_op; +template struct ei_scalar_log_op; +template struct ei_scalar_cos_op; +template struct ei_scalar_sin_op; +template struct ei_scalar_pow_op; +template struct ei_scalar_cast_op; +template struct ei_scalar_multiple_op; +template struct ei_scalar_quotient1_op; +template struct ei_scalar_min_op; +template struct ei_scalar_max_op; template struct ei_xpr_copy { - typedef T Type; + typedef T type; }; template struct ei_xpr_copy > { - typedef const Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> & Type; + typedef const Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> & type; }; -template struct ei_conditional_eval -{ - typedef T Type; -}; - -template struct ei_conditional_eval +template struct ei_eval { typedef Matrix::Scalar, ei_traits::RowsAtCompileTime, ei_traits::ColsAtCompileTime, - ei_traits::Flags, + ei_traits::Flags & ~LazyBit, // unset lazy bit after evaluation ei_traits::MaxRowsAtCompileTime, - ei_traits::MaxColsAtCompileTime> Type; + ei_traits::MaxColsAtCompileTime> type; }; template struct ei_eval_unless_lazy { - typedef typename ei_conditional_eval::Flags & LazyBit)>::Type Type; + typedef typename ei_meta_if::Flags & LazyBit, + T, + typename ei_eval::type + >::ret type; }; #endif // EIGEN_FORWARDDECLARATIONS_H diff --git a/Eigen/src/Core/Identity.h b/Eigen/src/Core/Identity.h index 532167b9c..104a06e2f 100644 --- a/Eigen/src/Core/Identity.h +++ b/Eigen/src/Core/Identity.h @@ -40,7 +40,8 @@ struct ei_traits > ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - Flags = MatrixType::Flags + Flags = MatrixType::Flags, + CoeffReadCost = NumTraits::ReadCost }; }; diff --git a/Eigen/src/Core/Lazy.h b/Eigen/src/Core/Lazy.h new file mode 100644 index 000000000..0968e254f --- /dev/null +++ b/Eigen/src/Core/Lazy.h @@ -0,0 +1,91 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. Eigen itself is part of the KDE project. +// +// Copyright (C) 2006-2008 Benoit Jacob +// +// Eigen is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. +// +// Alternatively, you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License and a copy of the GNU General Public License along with +// Eigen. If not, see . + +#ifndef EIGEN_LAZY_H +#define EIGEN_LAZY_H + +/** \class Lazy + * + * \brief Expression with the lazy flag set + * + * \param ExpressionType the type of the object of which we are taking the lazy version + * + * This class represents the lazy version of an expression. + * It is the return type of MatrixBase::lazy() + * and most of the time this is the only way it is used. + * + * \sa MatrixBase::lazy() + */ +template +struct ei_traits > +{ + typedef typename ExpressionType::Scalar Scalar; + enum { + RowsAtCompileTime = ExpressionType::RowsAtCompileTime, + ColsAtCompileTime = ExpressionType::ColsAtCompileTime, + MaxRowsAtCompileTime = ExpressionType::MaxRowsAtCompileTime, + MaxColsAtCompileTime = ExpressionType::MaxColsAtCompileTime, + Flags = ExpressionType::Flags | LazyBit, + CoeffReadCost = ExpressionType::CoeffReadCost + }; +}; + +template class Lazy + : public MatrixBase > +{ + public: + + EIGEN_GENERIC_PUBLIC_INTERFACE(Lazy) + + Lazy(const ExpressionType& matrix) : m_expression(matrix) {} + + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Lazy) + + private: + + int _rows() const { return m_expression.rows(); } + int _cols() const { return m_expression.cols(); } + + const Scalar _coeff(int row, int col) const + { + return m_expression.coeff(row, col); + } + + protected: + const typename ExpressionType::XprCopy m_expression; +}; + +/** \returns an expression of the lazy version of *this. + * + * Example: \include MatrixBase_lazy.cpp + * Output: \verbinclude MatrixBase_lazy.out + */ +template +const Lazy +MatrixBase::lazy() const +{ + return Lazy(derived()); +} + +#endif // EIGEN_LAZY_H diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index 4872b3f60..cbb1633ad 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -47,7 +47,8 @@ struct ei_traits > ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - Flags = MatrixType::Flags + Flags = MatrixType::Flags, + CoeffReadCost = NumTraits::ReadCost }; }; diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 9ccad4e7e..fa40364c7 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -79,7 +79,8 @@ struct ei_traits > ColsAtCompileTime = _Cols, MaxRowsAtCompileTime = _MaxRows, MaxColsAtCompileTime = _MaxCols, - Flags = _Flags + Flags = _Flags, + CoeffReadCost = NumTraits::ReadCost }; }; diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 7f8283e9f..77ecb2906 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -126,7 +126,7 @@ template class MatrixBase * we are dealing with a column-vector (if there is only one column) or with * a row-vector (if there is only one row). */ - Flags = ei_traits::Flags + Flags = ei_traits::Flags, /**< This stores expression metadata which typically is inherited by new expressions * constructed from this one. The available flags are: * \li \c RowMajorBit: if this bit is set, the preferred storage order for an evaluation @@ -136,6 +136,8 @@ template class MatrixBase * \li \c LargeBit: if this bit is set, optimization will be tuned for large matrices (typically, * at least 32x32). */ + + CoeffReadCost = ei_traits::CoeffReadCost }; /** This is the "real scalar" type; if the \a Scalar type is already real numbers @@ -219,14 +221,14 @@ template class MatrixBase * sum, scalar multiple, ... */ //@{ - const CwiseUnaryOp operator-() const; + const CwiseUnaryOp::Scalar>,Derived> operator-() const; template - const CwiseBinaryOp + const CwiseBinaryOp::Scalar>, Derived, OtherDerived> operator+(const MatrixBase &other) const; template - const CwiseBinaryOp + const CwiseBinaryOp::Scalar>, Derived, OtherDerived> operator-(const MatrixBase &other) const; template @@ -237,10 +239,10 @@ template class MatrixBase Derived& operator*=(const Scalar& other); Derived& operator/=(const Scalar& other); - const CwiseUnaryOp, Derived> operator*(const Scalar& scalar) const; - const CwiseUnaryOp, Derived> operator/(const Scalar& scalar) const; + const CwiseUnaryOp::Scalar>, Derived> operator*(const Scalar& scalar) const; + const CwiseUnaryOp::Scalar>, Derived> operator/(const Scalar& scalar) const; - friend const CwiseUnaryOp, Derived> + friend const CwiseUnaryOp::Scalar>, Derived> operator*(const Scalar& scalar, const MatrixBase& matrix) { return matrix*scalar; } //@} @@ -250,7 +252,7 @@ template class MatrixBase */ //@{ template - const typename ei_eval_unless_lazy >::Type + const typename ei_eval_unless_lazy >::type operator*(const MatrixBase &other) const; template @@ -265,11 +267,11 @@ template class MatrixBase Scalar dot(const MatrixBase& other) const; RealScalar norm2() const; RealScalar norm() const; - const CwiseUnaryOp, Derived> normalized() const; + const CwiseUnaryOp::Scalar>, Derived> normalized() const; Transpose transpose(); const Transpose transpose() const; - const Transpose > adjoint() const; + const Transpose::Scalar>, Derived> > adjoint() const; //@} /// \name Sub-matrices @@ -310,9 +312,9 @@ template class MatrixBase /// \name Generating special matrices //@{ - static const typename ei_eval_unless_lazy >::Type random(int rows, int cols); - static const typename ei_eval_unless_lazy >::Type random(int size); - static const typename ei_eval_unless_lazy >::Type random(); + static const typename ei_eval_unless_lazy >::type random(int rows, int cols); + static const typename ei_eval_unless_lazy >::type random(int size); + static const typename ei_eval_unless_lazy >::type random(); static const Zero zero(int rows, int cols); static const Zero zero(int size); static const Zero zero(); @@ -354,11 +356,11 @@ template class MatrixBase /// \name Special functions //@{ template - const CwiseUnaryOp, Derived> cast() const; + const CwiseUnaryOp::Scalar, NewType>, Derived> cast() const; - const typename ei_eval_unless_lazy::Type eval() const EIGEN_ALWAYS_INLINE + const typename ei_eval_unless_lazy::type eval() const EIGEN_ALWAYS_INLINE { - return typename ei_eval_unless_lazy::Type(derived()); + return typename ei_eval_unless_lazy::type(derived()); } template @@ -369,31 +371,31 @@ template class MatrixBase /// \name Coefficient-wise operations //@{ - const CwiseUnaryOp conjugate() const; + const CwiseUnaryOp::Scalar>, Derived> conjugate() const; template - const CwiseBinaryOp + const CwiseBinaryOp::Scalar>, Derived, OtherDerived> cwiseProduct(const MatrixBase &other) const; template - const CwiseBinaryOp + const CwiseBinaryOp::Scalar>, Derived, OtherDerived> cwiseQuotient(const MatrixBase &other) const; template - const CwiseBinaryOp + const CwiseBinaryOp::Scalar>, Derived, OtherDerived> cwiseMin(const MatrixBase &other) const; template - const CwiseBinaryOp + const CwiseBinaryOp::Scalar>, Derived, OtherDerived> cwiseMax(const MatrixBase &other) const; - const CwiseUnaryOp cwiseAbs() const; - const CwiseUnaryOp cwiseAbs2() const; - const CwiseUnaryOp cwiseSqrt() const; - const CwiseUnaryOp cwiseExp() const; - const CwiseUnaryOp cwiseLog() const; - const CwiseUnaryOp cwiseCos() const; - const CwiseUnaryOp cwiseSin() const; + const CwiseUnaryOp::Scalar>, Derived> cwiseAbs() const; + const CwiseUnaryOp::Scalar>, Derived> cwiseAbs2() const; + const CwiseUnaryOp::Scalar>, Derived> cwiseSqrt() const; + const CwiseUnaryOp::Scalar>, Derived> cwiseExp() const; + const CwiseUnaryOp::Scalar>, Derived> cwiseLog() const; + const CwiseUnaryOp::Scalar>, Derived> cwiseCos() const; + const CwiseUnaryOp::Scalar>, Derived> cwiseSin() const; const CwiseUnaryOp::Scalar>, Derived> cwisePow(const Scalar& exponent) const; diff --git a/Eigen/src/Core/Minor.h b/Eigen/src/Core/Minor.h index 62941d764..911ac2151 100644 --- a/Eigen/src/Core/Minor.h +++ b/Eigen/src/Core/Minor.h @@ -50,7 +50,8 @@ struct ei_traits > MatrixType::MaxRowsAtCompileTime - 1 : Dynamic, MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ? MatrixType::MaxColsAtCompileTime - 1 : Dynamic, - Flags = MatrixType::Flags + Flags = MatrixType::Flags, + CoeffReadCost = MatrixType::CoeffReadCost }; }; diff --git a/Eigen/src/Core/NumTraits.h b/Eigen/src/Core/NumTraits.h index cc541af8f..cb601b160 100644 --- a/Eigen/src/Core/NumTraits.h +++ b/Eigen/src/Core/NumTraits.h @@ -53,7 +53,10 @@ template<> struct NumTraits typedef double FloatingPoint; enum { IsComplex = 0, - HasFloatingPoint = 0 + HasFloatingPoint = 0, + ReadCost = 1, + AddCost = 1, + MulCost = 3 }; }; @@ -63,7 +66,10 @@ template<> struct NumTraits typedef float FloatingPoint; enum { IsComplex = 0, - HasFloatingPoint = 1 + HasFloatingPoint = 1, + ReadCost = 1, + AddCost = 2, + MulCost = 6 }; }; @@ -73,7 +79,10 @@ template<> struct NumTraits typedef double FloatingPoint; enum { IsComplex = 0, - HasFloatingPoint = 1 + HasFloatingPoint = 1, + ReadCost = 1, + AddCost = 2, + MulCost = 6 }; }; @@ -83,7 +92,10 @@ template struct NumTraits > typedef std::complex<_Real> FloatingPoint; enum { IsComplex = 1, - HasFloatingPoint = 1 // anyway we don't allow std::complex + HasFloatingPoint = NumTraits::HasFloatingPoint, + ReadCost = 2, + AddCost = 2 * NumTraits::AddCost, + MulCost = 4 * NumTraits::MulCost + 2 * NumTraits::AddCost }; }; @@ -93,7 +105,10 @@ template<> struct NumTraits typedef long double FloatingPoint; enum { IsComplex = 0, - HasFloatingPoint = 0 + HasFloatingPoint = 0, + ReadCost = 1, + AddCost = 2, + MulCost = 6 }; }; @@ -103,7 +118,10 @@ template<> struct NumTraits typedef long double FloatingPoint; enum { IsComplex = 0, - HasFloatingPoint = 1 + HasFloatingPoint = 1, + ReadCost = 1, + AddCost = 2, + MulCost = 6 }; }; diff --git a/Eigen/src/Core/Ones.h b/Eigen/src/Core/Ones.h index 05d9b4270..4cb4bc348 100644 --- a/Eigen/src/Core/Ones.h +++ b/Eigen/src/Core/Ones.h @@ -41,7 +41,8 @@ struct ei_traits > ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - Flags = MatrixType::Flags + Flags = MatrixType::Flags, + CoeffReadCost = NumTraits::ReadCost }; }; diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 62e1b6317..c71637779 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -78,6 +78,23 @@ template struct ei_traits > { typedef typename Lhs::Scalar Scalar; + typedef typename ei_meta_if< + (int)NumTraits::ReadCost < (int)Lhs::CoeffReadCost, + typename Lhs::Eval, + Lhs>::ret ActualLhs; + typedef typename ei_meta_if< + (int)NumTraits::ReadCost < (int)Lhs::CoeffReadCost, + typename Lhs::Eval, + typename Lhs::XprCopy>::ret ActualLhsXprCopy; + + typedef typename ei_meta_if< + (int)NumTraits::ReadCost < (int)Rhs::CoeffReadCost, + typename Rhs::Eval, + Rhs>::ret ActualRhs; + typedef typename ei_meta_if< + (int)NumTraits::ReadCost < (int)Rhs::CoeffReadCost, + typename Rhs::Eval, + typename Rhs::XprCopy>::ret ActualRhsXprCopy; enum { RowsAtCompileTime = Lhs::RowsAtCompileTime, ColsAtCompileTime = Rhs::ColsAtCompileTime, @@ -85,20 +102,20 @@ struct ei_traits > MaxColsAtCompileTime = Rhs::MaxColsAtCompileTime, Flags = (RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic) ? (unsigned int)(Lhs::Flags | Rhs::Flags) - : (unsigned int)(Lhs::Flags | Rhs::Flags) & ~LargeBit + : (unsigned int)(Lhs::Flags | Rhs::Flags) & ~LargeBit, + CoeffReadCost + = Lhs::ColsAtCompileTime == Dynamic + ? Dynamic + : Lhs::ColsAtCompileTime + * (NumTraits::MulCost + ActualLhs::CoeffReadCost + ActualRhs::CoeffReadCost) + + (Lhs::ColsAtCompileTime - 1) * NumTraits::AddCost }; }; -template -struct ei_product_eval_mode +template struct ei_product_eval_mode { - enum { - SizeAtCompileTime = MatrixBase >::SizeAtCompileTime, - MaxSizeAtCompileTime = MatrixBase >::MaxSizeAtCompileTime, - EvalMode = ( EIGEN_UNROLLED_LOOPS - && MaxSizeAtCompileTime != Dynamic - && SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT) ? UnrolledDotProduct : CacheOptimal, - }; + enum{ value = Lhs::MaxRowsAtCompileTime == Dynamic || Rhs::MaxColsAtCompileTime == Dynamic + ? CacheOptimal : UnrolledDotProduct }; }; template class Product : ei_no_assignment_operator, @@ -107,6 +124,10 @@ template class Product : ei_no_assignm public: EIGEN_GENERIC_PUBLIC_INTERFACE(Product) + typedef typename ei_traits::ActualLhs ActualLhs; + typedef typename ei_traits::ActualRhs ActualRhs; + typedef typename ei_traits::ActualLhsXprCopy ActualLhsXprCopy; + typedef typename ei_traits::ActualRhsXprCopy ActualRhsXprCopy; Product(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs) @@ -132,7 +153,7 @@ template class Product : ei_no_assignm ei_product_unroller + ActualLhs, ActualRhs> ::run(row, col, m_lhs, m_rhs, res); else { @@ -144,8 +165,8 @@ template class Product : ei_no_assignm } protected: - const typename Lhs::XprCopy m_lhs; - const typename Rhs::XprCopy m_rhs; + const ActualLhsXprCopy m_lhs; + const ActualRhsXprCopy m_rhs; }; /** \returns the matrix product of \c *this and \a other. @@ -157,7 +178,7 @@ template class Product : ei_no_assignm */ template template -const typename ei_eval_unless_lazy >::Type +const typename ei_eval_unless_lazy >::type MatrixBase::operator*(const MatrixBase &other) const { return Product(derived(), other.derived()).eval(); @@ -199,7 +220,8 @@ void Product::_cacheOptimalEval(DestDerived& res) const const Scalar tmp2 = m_rhs.coeff(j+2,k); const Scalar tmp3 = m_rhs.coeff(j+3,k); for (int i=0; i > ColsAtCompileTime = ei_traits::ColsAtCompileTime, MaxRowsAtCompileTime = ei_traits::MaxRowsAtCompileTime, MaxColsAtCompileTime = ei_traits::MaxColsAtCompileTime, - Flags = ei_traits::Flags + Flags = ei_traits::Flags, + CoeffReadCost = 2 * NumTraits::MulCost // FIXME: arbitrary value }; }; @@ -92,7 +93,7 @@ template class Random : ei_no_assignment_operator, * \sa ei_random(), ei_random(int) */ template -const typename ei_eval_unless_lazy >::Type +const typename ei_eval_unless_lazy >::type MatrixBase::random(int rows, int cols) { return Random(rows, cols).eval(); @@ -115,7 +116,7 @@ MatrixBase::random(int rows, int cols) * \sa ei_random(), ei_random(int,int) */ template -const typename ei_eval_unless_lazy >::Type +const typename ei_eval_unless_lazy >::type MatrixBase::random(int size) { ei_assert(IsVectorAtCompileTime); @@ -135,7 +136,7 @@ MatrixBase::random(int size) * \sa ei_random(int), ei_random(int,int) */ template -const typename ei_eval_unless_lazy >::Type +const typename ei_eval_unless_lazy >::type MatrixBase::random() { return Random(RowsAtCompileTime, ColsAtCompileTime).eval(); diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h index 34eefca7c..05d73afc2 100644 --- a/Eigen/src/Core/Redux.h +++ b/Eigen/src/Core/Redux.h @@ -26,7 +26,6 @@ #ifndef EIGEN_REDUX_H #define EIGEN_REDUX_H - template struct ei_redux_unroller { @@ -95,7 +94,8 @@ struct ei_traits > MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, Flags = (RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic) ? (unsigned int)MatrixType::Flags - : (unsigned int)MatrixType::Flags & ~LargeBit + : (unsigned int)MatrixType::Flags & ~LargeBit, + CoeffReadCost = 1 //FIXME -- unimplemented! }; }; @@ -198,7 +198,7 @@ template typename ei_traits::Scalar MatrixBase::sum() const { - return this->redux(Eigen::ei_scalar_sum_op()); + return this->redux(Eigen::ei_scalar_sum_op()); } /** \returns the trace of \c *this, i.e. the sum of the coefficients on the main diagonal. @@ -220,7 +220,7 @@ template typename ei_traits::Scalar MatrixBase::minCoeff() const { - return this->redux(Eigen::ei_scalar_min_op()); + return this->redux(Eigen::ei_scalar_min_op()); } /** \returns the maximum of all coefficients of *this @@ -229,7 +229,7 @@ template typename ei_traits::Scalar MatrixBase::maxCoeff() const { - return this->redux(Eigen::ei_scalar_max_op()); + return this->redux(Eigen::ei_scalar_max_op()); } #endif // EIGEN_REDUX_H diff --git a/Eigen/src/Core/Swap.h b/Eigen/src/Core/Swap.h index db096e6f2..cffdb1cc6 100644 --- a/Eigen/src/Core/Swap.h +++ b/Eigen/src/Core/Swap.h @@ -63,7 +63,7 @@ void MatrixBase::swap(const MatrixBase& other) } else // SizeAtCompileTime != Dynamic { - typename Eval::MatrixType buf(*this); + typename Derived::Eval buf(*this); *this = other; *_other = buf; } diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 51799b33e..3eb5d1f71 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -46,7 +46,8 @@ struct ei_traits > ColsAtCompileTime = MatrixType::RowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - Flags = MatrixType::Flags ^ RowMajorBit + Flags = MatrixType::Flags ^ RowMajorBit, + CoeffReadCost = MatrixType::CoeffReadCost }; }; @@ -108,7 +109,7 @@ MatrixBase::transpose() const * * \sa transpose(), conjugate(), class Transpose, class ei_scalar_conjugate_op */ template -const Transpose > +const Transpose::Scalar>, Derived> > MatrixBase::adjoint() const { return conjugate().transpose(); diff --git a/Eigen/src/Core/Util.h b/Eigen/src/Core/Util.h index 9aaac9ae2..d82ec574f 100644 --- a/Eigen/src/Core/Util.h +++ b/Eigen/src/Core/Util.h @@ -109,7 +109,8 @@ EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=) #define _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, BaseClass) \ typedef BaseClass Base; \ typedef typename Eigen::ei_traits::Scalar Scalar; \ -typedef typename Eigen::ei_xpr_copy::Type XprCopy; \ +typedef typename Eigen::ei_xpr_copy::type XprCopy; \ +typedef typename Eigen::ei_eval::type Eval; \ enum { RowsAtCompileTime = Base::RowsAtCompileTime, \ ColsAtCompileTime = Base::ColsAtCompileTime, \ MaxRowsAtCompileTime = Base::MaxRowsAtCompileTime, \ @@ -117,13 +118,8 @@ enum { RowsAtCompileTime = Base::RowsAtCompileTime, \ SizeAtCompileTime = Base::SizeAtCompileTime, \ MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \ IsVectorAtCompileTime = Base::IsVectorAtCompileTime, \ - Flags = Base::Flags }; \ -typedef Matrix Eval; + Flags = Base::Flags, \ + CoeffReadCost = Base::CoeffReadCost }; #define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \ _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::MatrixBase) \ @@ -138,6 +134,8 @@ const unsigned int RowMajorBit = 0x1; const unsigned int LazyBit = 0x2; const unsigned int LargeBit = 0x4; +enum { ConditionalJumpCost = 5 }; + enum CornerType { TopLeft, TopRight, BottomLeft, BottomRight }; enum DirectionType { Vertical, Horizontal }; @@ -185,6 +183,9 @@ struct ei_meta_if { typedef Then ret; }; template struct ei_meta_if { typedef Else ret; }; +template struct ei_is_same_type { enum { ret = 0 }; }; +template struct ei_is_same_type { enum { ret = 1 }; }; + /** \internal * Convenient struct to get the result type of a unary or binary functor. diff --git a/Eigen/src/Core/Zero.h b/Eigen/src/Core/Zero.h index 106742d32..15108b794 100644 --- a/Eigen/src/Core/Zero.h +++ b/Eigen/src/Core/Zero.h @@ -41,7 +41,8 @@ struct ei_traits > ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - Flags = MatrixType::Flags + Flags = MatrixType::Flags, + CoeffReadCost = NumTraits::ReadCost }; }; -- cgit v1.2.3