diff --git a/Eigen/Core b/Eigen/Core index 12c8ea97f..b6e383210 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -199,6 +199,7 @@ struct Dense {}; #include "src/Core/IO.h" #include "src/Core/Swap.h" #include "src/Core/CommaInitializer.h" +#include "src/Core/Flagged.h" #include "src/Core/ProductBase.h" #include "src/Core/Product.h" #include "src/Core/TriangularMatrix.h" diff --git a/Eigen/Eigen2Support b/Eigen/Eigen2Support index 9e3bff68f..bd6306aff 100644 --- a/Eigen/Eigen2Support +++ b/Eigen/Eigen2Support @@ -42,7 +42,6 @@ namespace Eigen { * */ -#include "src/Eigen2Support/Flagged.h" #include "src/Eigen2Support/Lazy.h" #include "src/Eigen2Support/Cwise.h" #include "src/Eigen2Support/CwiseOperators.h" diff --git a/Eigen/src/Eigen2Support/Flagged.h b/Eigen/src/Core/Flagged.h similarity index 70% rename from Eigen/src/Eigen2Support/Flagged.h rename to Eigen/src/Core/Flagged.h index 470db1d7b..af00a68be 100644 --- a/Eigen/src/Eigen2Support/Flagged.h +++ b/Eigen/src/Core/Flagged.h @@ -25,9 +25,7 @@ #ifndef EIGEN_FLAGGED_H #define EIGEN_FLAGGED_H -/** \deprecated it is only used by lazy() which is deprecated - * - * \class Flagged +/** \class Flagged * * \brief Expression with modified flags * @@ -120,58 +118,4 @@ template clas ExpressionTypeNested m_matrix; }; -/** \deprecated it is only used by lazy() which is deprecated - * - * \returns an expression of *this with added flags - * - * Example: \include MatrixBase_marked.cpp - * Output: \verbinclude MatrixBase_marked.out - * - * \sa class Flagged, extract(), part() - */ -template -template -inline const Flagged -MatrixBase::marked() const -{ - return derived(); -} - -/** \deprecated use MatrixBase::noalias() - * - * \returns an expression of *this with the EvalBeforeAssigningBit flag removed. - * - * Example: \include MatrixBase_lazy.cpp - * Output: \verbinclude MatrixBase_lazy.out - * - * \sa class Flagged, marked() - */ -template -inline const Flagged -MatrixBase::lazy() const -{ - return derived(); -} - - -/** \internal - * Overloaded to perform an efficient C += (A*B).lazy() */ -template -template -Derived& MatrixBase::operator+=(const Flagged, 0, - EvalBeforeAssigningBit>& other) -{ - other._expression().derived().addTo(derived()); return derived(); -} - -/** \internal - * Overloaded to perform an efficient C -= (A*B).lazy() */ -template -template -Derived& MatrixBase::operator-=(const Flagged, 0, - EvalBeforeAssigningBit>& other) -{ - other._expression().derived().subTo(derived()); return derived(); -} - #endif // EIGEN_FLAGGED_H diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 7cfdee6cf..d7f17dd28 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -54,8 +54,6 @@ enum { Small = Dynamic/2 }; -enum { OuterProduct, InnerProduct, UnrolledProduct, GemvProduct, GemmProduct }; - template struct ei_product_type { typedef typename ei_cleantype::type _Lhs; diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index 4e5490d6a..ef986baaa 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -25,6 +25,8 @@ #ifndef EIGEN_PRODUCTBASE_H #define EIGEN_PRODUCTBASE_H +enum { OuterProduct, InnerProduct, UnrolledProduct, GemvProduct, GemmProduct }; + /** \class ProductBase * */ @@ -69,7 +71,7 @@ class ProductBase : public MatrixBase public: typedef MatrixBase Base; EIGEN_DENSE_PUBLIC_INTERFACE(ProductBase) - + protected: typedef typename Lhs::Nested LhsNested; typedef typename ei_cleantype::type _LhsNested; typedef ei_blas_traits<_LhsNested> LhsBlasTraits; @@ -82,6 +84,10 @@ class ProductBase : public MatrixBase typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType; typedef typename ei_cleantype::type _ActualRhsType; + typedef typename ProductReturnType::Type CoeffBaseProductType; + typedef Flagged LazyCoeffBaseProductType; + public: + typedef typename Base::PlainMatrixType PlainMatrixType; ProductBase(const Lhs& lhs, const Rhs& rhs) @@ -113,6 +119,26 @@ class ProductBase : public MatrixBase const _LhsNested& lhs() const { return m_lhs; } const _RhsNested& rhs() const { return m_rhs; } + const Diagonal diagonal() const + { return Diagonal(CoeffBaseProductType(m_lhs, m_rhs)); } + + Diagonal diagonal() + { return Diagonal(CoeffBaseProductType(m_lhs, m_rhs)); } + + template + const Diagonal diagonal() const + { return Diagonal(CoeffBaseProductType(m_lhs, m_rhs)); } + + template + Diagonal diagonal() + { return Diagonal(CoeffBaseProductType(m_lhs, m_rhs)); } + + const Diagonal diagonal(int index) const + { return Diagonal(LazyCoeffBaseProductType(CoeffBaseProductType(m_lhs, m_rhs))).diagonal(index); } + + Diagonal diagonal(int index) + { return Diagonal(LazyCoeffBaseProductType(CoeffBaseProductType(m_lhs, m_rhs))).diagonal(index); } + protected: const LhsNested m_lhs; diff --git a/Eigen/src/Eigen2Support/Lazy.h b/Eigen/src/Eigen2Support/Lazy.h index e69de29bb..c4288ede2 100644 --- a/Eigen/src/Eigen2Support/Lazy.h +++ b/Eigen/src/Eigen2Support/Lazy.h @@ -0,0 +1,82 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 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 + +/** \deprecated it is only used by lazy() which is deprecated + * + * \returns an expression of *this with added flags + * + * Example: \include MatrixBase_marked.cpp + * Output: \verbinclude MatrixBase_marked.out + * + * \sa class Flagged, extract(), part() + */ +template +template +inline const Flagged +MatrixBase::marked() const +{ + return derived(); +} + +/** \deprecated use MatrixBase::noalias() + * + * \returns an expression of *this with the EvalBeforeAssigningBit flag removed. + * + * Example: \include MatrixBase_lazy.cpp + * Output: \verbinclude MatrixBase_lazy.out + * + * \sa class Flagged, marked() + */ +template +inline const Flagged +MatrixBase::lazy() const +{ + return derived(); +} + + +/** \internal + * Overloaded to perform an efficient C += (A*B).lazy() */ +template +template +Derived& MatrixBase::operator+=(const Flagged, 0, + EvalBeforeAssigningBit>& other) +{ + other._expression().derived().addTo(derived()); return derived(); +} + +/** \internal + * Overloaded to perform an efficient C -= (A*B).lazy() */ +template +template +Derived& MatrixBase::operator-=(const Flagged, 0, + EvalBeforeAssigningBit>& other) +{ + other._expression().derived().subTo(derived()); return derived(); +} + +#endif // EIGEN_LAZY_H