diff options
author | 2010-02-09 14:34:31 +0100 | |
---|---|---|
committer | 2010-02-09 14:34:31 +0100 | |
commit | 840977529fd0e674e46a7cb6c5a5519c403b05bc (patch) | |
tree | eabb04999185ef96f479d274da996fb93965ed6c /Eigen/src | |
parent | 9ce1212d7cf1574d989a5e6269f0a614b4ce17ed (diff) |
* as promised, remove the "optimization" for Product::diagonal()
* add MatrixBase::lazyProduct
Diffstat (limited to 'Eigen/src')
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/Product.h | 25 | ||||
-rw-r--r-- | Eigen/src/Core/ProductBase.h | 25 | ||||
-rw-r--r-- | Eigen/src/Core/products/CoeffBasedProduct.h | 4 |
4 files changed, 29 insertions, 29 deletions
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index e599a9e03..65b3bfb7c 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -189,6 +189,10 @@ template<typename Derived> class MatrixBase operator*(const MatrixBase<OtherDerived> &other) const; template<typename OtherDerived> + const typename ProductReturnType<Derived,OtherDerived,LazyCoeffBasedProductMode>::Type + lazyProduct(const MatrixBase<OtherDerived> &other) const; + + template<typename OtherDerived> Derived& operator*=(const AnyMatrixBase<OtherDerived>& other); template<typename OtherDerived> diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 07aeae165..304dbc3ee 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -445,4 +445,29 @@ MatrixBase<Derived>::operator*(const MatrixBase<OtherDerived> &other) const return typename ProductReturnType<Derived,OtherDerived>::Type(derived(), other.derived()); } + +template<typename Derived> +template<typename OtherDerived> +const typename ProductReturnType<Derived,OtherDerived,LazyCoeffBasedProductMode>::Type +MatrixBase<Derived>::lazyProduct(const MatrixBase<OtherDerived> &other) const +{ + enum { + ProductIsValid = Derived::ColsAtCompileTime==Dynamic + || OtherDerived::RowsAtCompileTime==Dynamic + || int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime), + AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime, + SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived,OtherDerived) + }; + // note to the lost user: + // * for a dot product use: v1.dot(v2) + // * for a coeff-wise product use: v1.cwiseProduct(v2) + EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes), + INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS) + EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors), + INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION) + EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT) + + return typename ProductReturnType<Derived,OtherDerived,LazyCoeffBasedProductMode>::Type(derived(), other.derived()); +} + #endif // EIGEN_PRODUCT_H diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index 4c95684f0..bbd77f059 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -83,11 +83,6 @@ class ProductBase : public MatrixBase<Derived> typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType; typedef typename ei_cleantype<ActualRhsType>::type _ActualRhsType; - // here we don't use ProductReturnType<LazyCoeffBasedProductMode>::Type because we must nest it by value. - typedef typename ei_nested<_LhsNested, _RhsNested::ColsAtCompileTime, typename ei_plain_matrix_type<_LhsNested>::type >::type LazyLhsNested; - typedef typename ei_nested<_RhsNested, _LhsNested::RowsAtCompileTime, typename ei_plain_matrix_type<_RhsNested>::type >::type LazyRhsNested; - typedef CoeffBasedProduct<LazyLhsNested, LazyRhsNested, 0> NestedByValueLazyCoeffBaseProductType; - public: typedef typename Base::PlainMatrixType PlainMatrixType; @@ -118,26 +113,6 @@ class ProductBase : public MatrixBase<Derived> const _LhsNested& lhs() const { return m_lhs; } const _RhsNested& rhs() const { return m_rhs; } - const Diagonal<NestedByValueLazyCoeffBaseProductType,0> diagonal() const - { return NestedByValueLazyCoeffBaseProductType(m_lhs, m_rhs); } - - Diagonal<NestedByValueLazyCoeffBaseProductType,0> diagonal() - { return NestedByValueLazyCoeffBaseProductType(m_lhs, m_rhs); } - - template<int Index> - const Diagonal<NestedByValueLazyCoeffBaseProductType,Index> diagonal() const - { return NestedByValueLazyCoeffBaseProductType(m_lhs, m_rhs); } - - template<int Index> - Diagonal<NestedByValueLazyCoeffBaseProductType,Index> diagonal() - { return NestedByValueLazyCoeffBaseProductType(m_lhs, m_rhs); } - - const Diagonal<NestedByValueLazyCoeffBaseProductType,Dynamic> diagonal(int index) const - { return NestedByValueLazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); } - - Diagonal<NestedByValueLazyCoeffBaseProductType,Dynamic> diagonal(int index) - { return NestedByValueLazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); } - // Implicit convertion to the nested type (trigger the evaluation of the product) operator const PlainMatrixType& () const { diff --git a/Eigen/src/Core/products/CoeffBasedProduct.h b/Eigen/src/Core/products/CoeffBasedProduct.h index af0d2e2a2..c9d333072 100644 --- a/Eigen/src/Core/products/CoeffBasedProduct.h +++ b/Eigen/src/Core/products/CoeffBasedProduct.h @@ -129,10 +129,6 @@ class CoeffBasedProduct public: - inline CoeffBasedProduct(const CoeffBasedProduct& other) - : Base(), m_lhs(other.m_lhs), m_rhs(other.m_rhs) - {} - template<typename Lhs, typename Rhs> inline CoeffBasedProduct(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs) |