mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
finally here is a simple solution making (a*b).diagonal() even faster than a.lazyProduct(b).diagonal() !!
This commit is contained in:
@@ -83,6 +83,9 @@ class ProductBase : public MatrixBase<Derived>
|
||||
typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
|
||||
typedef typename ei_cleantype<ActualRhsType>::type _ActualRhsType;
|
||||
|
||||
// Diagonal of a product: no need to evaluate the arguments because they are going to be evaluated only once
|
||||
typedef CoeffBasedProduct<LhsNested, RhsNested, 0> FullyLazyCoeffBaseProductType;
|
||||
|
||||
public:
|
||||
|
||||
typedef typename Base::PlainMatrixType PlainMatrixType;
|
||||
@@ -121,6 +124,16 @@ class ProductBase : public MatrixBase<Derived>
|
||||
return m_result;
|
||||
}
|
||||
|
||||
const Diagonal<FullyLazyCoeffBaseProductType,0> diagonal() const
|
||||
{ return FullyLazyCoeffBaseProductType(m_lhs, m_rhs); }
|
||||
|
||||
template<int Index>
|
||||
const Diagonal<FullyLazyCoeffBaseProductType,Index> diagonal() const
|
||||
{ return FullyLazyCoeffBaseProductType(m_lhs, m_rhs); }
|
||||
|
||||
const Diagonal<FullyLazyCoeffBaseProductType,Dynamic> diagonal(int index) const
|
||||
{ return FullyLazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); }
|
||||
|
||||
protected:
|
||||
|
||||
const LhsNested m_lhs;
|
||||
|
||||
Reference in New Issue
Block a user