mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
overload operartor* with a ProductBase such that "scalar * (mat * mat)" is optimized
as one could naturally expect
This commit is contained in:
@@ -153,7 +153,7 @@ class GeneralProduct<Lhs, Rhs, InnerProduct>
|
||||
|
||||
GeneralProduct(const Lhs& lhs, const Rhs& rhs) : Base(lhs,rhs) {}
|
||||
|
||||
template<typename Dest> void addTo(Dest& dst, Scalar alpha) const
|
||||
template<typename Dest> void scaleAndAddTo(Dest& dst, Scalar alpha) const
|
||||
{
|
||||
ei_assert(dst.rows()==1 && dst.cols()==1);
|
||||
dst.coeffRef(0,0) += alpha * (m_lhs.cwise()*m_rhs).sum();
|
||||
@@ -179,7 +179,7 @@ class GeneralProduct<Lhs, Rhs, OuterProduct>
|
||||
|
||||
GeneralProduct(const Lhs& lhs, const Rhs& rhs) : Base(lhs,rhs) {}
|
||||
|
||||
template<typename Dest> void addTo(Dest& dest, Scalar alpha) const
|
||||
template<typename Dest> void scaleAndAddTo(Dest& dest, Scalar alpha) const
|
||||
{
|
||||
ei_outer_product_selector<Dest::Flags&RowMajorBit>::run(*this, dest, alpha);
|
||||
}
|
||||
@@ -236,7 +236,7 @@ class GeneralProduct<Lhs, Rhs, GemvProduct>
|
||||
enum { Side = Lhs::IsVectorAtCompileTime ? OnTheLeft : OnTheRight };
|
||||
typedef typename ei_meta_if<int(Side)==OnTheRight,_LhsNested,_RhsNested>::ret MatrixType;
|
||||
|
||||
template<typename Dest> void addTo(Dest& dst, Scalar alpha) const
|
||||
template<typename Dest> void scaleAndAddTo(Dest& dst, Scalar alpha) const
|
||||
{
|
||||
ei_assert(m_lhs.rows() == dst.rows() && m_rhs.cols() == dst.cols());
|
||||
ei_gemv_selector<Side,int(MatrixType::Flags)&RowMajorBit,
|
||||
|
||||
Reference in New Issue
Block a user