mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 03:39:01 +08:00
* as promised, remove the "optimization" for Product::diagonal()
* add MatrixBase::lazyProduct
This commit is contained in:
parent
9ce1212d7c
commit
840977529f
@ -188,6 +188,10 @@ template<typename Derived> class MatrixBase
|
||||
const typename ProductReturnType<Derived,OtherDerived>::Type
|
||||
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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user