aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/products
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2010-02-10 14:08:47 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2010-02-10 14:08:47 +0100
commit0ca67afe6abbe9c19a8254d50daaddd2a343531c (patch)
treee832b7636a793c649ad947304c0369ed94167ac5 /Eigen/src/Core/products
parent71b64d34987ae7d3fbe70f0098c12a7c65b41084 (diff)
finally here is a simple solution making (a*b).diagonal() even faster than a.lazyProduct(b).diagonal() !!
Diffstat (limited to 'Eigen/src/Core/products')
-rw-r--r--Eigen/src/Core/products/CoeffBasedProduct.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/Eigen/src/Core/products/CoeffBasedProduct.h b/Eigen/src/Core/products/CoeffBasedProduct.h
index c9d333072..f030d59b5 100644
--- a/Eigen/src/Core/products/CoeffBasedProduct.h
+++ b/Eigen/src/Core/products/CoeffBasedProduct.h
@@ -127,8 +127,14 @@ class CoeffBasedProduct
Unroll ? InnerSize-1 : Dynamic,
_LhsNested, _RhsNested, Scalar> ScalarCoeffImpl;
+ typedef CoeffBasedProduct<LhsNested,RhsNested,NestByRefBit> LazyCoeffBasedProductType;
+
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)
@@ -185,6 +191,16 @@ class CoeffBasedProduct
const _LhsNested& lhs() const { return m_lhs; }
const _RhsNested& rhs() const { return m_rhs; }
+ const Diagonal<LazyCoeffBasedProductType,0> diagonal() const
+ { return reinterpret_cast<const LazyCoeffBasedProductType&>(*this); }
+
+ template<int Index>
+ const Diagonal<LazyCoeffBasedProductType,Index> diagonal() const
+ { return reinterpret_cast<const LazyCoeffBasedProductType&>(*this); }
+
+ const Diagonal<LazyCoeffBasedProductType,Dynamic> diagonal(int index) const
+ { return reinterpret_cast<const LazyCoeffBasedProductType&>(*this).diagonal(index); }
+
protected:
const LhsNested m_lhs;
const RhsNested m_rhs;