implement a ProductBase class and, as a proof of concept, update TriangularProduct

and SelfAdjointMatrixProduct to take advantage of it => fewer LOC
This commit is contained in:
Gael Guennebaud
2009-08-04 16:54:17 +02:00
parent f3a6bc48c4
commit 7d607048a9
9 changed files with 219 additions and 160 deletions

View File

@@ -38,14 +38,14 @@
template<typename Derived> struct AnyMatrixBase
{
typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType;
Derived& derived() { return *static_cast<Derived*>(this); }
const Derived& derived() const { return *static_cast<const Derived*>(this); }
/** \returns the number of rows. \sa cols(), RowsAtCompileTime */
inline int rows() const { return derived().rows(); }
/** \returns the number of columns. \sa rows(), ColsAtCompileTime*/
inline int cols() const { return derived().cols(); }
template<typename Dest> inline void evalTo(Dest& dst) const
{ derived().evalTo(dst); }
@@ -55,7 +55,7 @@ template<typename Derived> struct AnyMatrixBase
evalToDense(res);
dst += res;
}
template<typename Dest> inline void subToDense(Dest& dst) const
{
typename Dest::PlainMatrixType res(rows(),cols());
@@ -318,6 +318,17 @@ template<typename Derived> class MatrixBase
Derived& operator-=(const AnyMatrixBase<OtherDerived> &other)
{ other.derived().subToDense(derived()); return derived(); }
template<typename ProductDerived, typename Lhs, typename Rhs>
Derived& operator=(const ProductBase<ProductDerived, Lhs, Rhs> &other);
template<typename ProductDerived, typename Lhs, typename Rhs>
Derived& operator+=(const ProductBase<ProductDerived, Lhs, Rhs> &other);
template<typename ProductDerived, typename Lhs, typename Rhs>
Derived& operator-=(const ProductBase<ProductDerived, Lhs, Rhs> &other);
template<typename OtherDerived,typename OtherEvalType>
Derived& operator=(const ReturnByValue<OtherDerived,OtherEvalType>& func);
@@ -776,7 +787,7 @@ template<typename Derived> class MatrixBase
template<typename EssentialPart>
void applyHouseholderOnTheRight(const EssentialPart& essential,
const RealScalar& beta);
#ifdef EIGEN_MATRIXBASE_PLUGIN
#include EIGEN_MATRIXBASE_PLUGIN