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

@@ -339,11 +339,18 @@ class Matrix
return Base::operator=(func);
}
template<typename ProductDerived, typename Lhs, typename Rhs>
EIGEN_STRONG_INLINE Matrix& operator=(const ProductBase<ProductDerived,Lhs,Rhs>& other)
{
resize(other.rows(), other.cols());
return Base::operator=(other);
}
using Base::operator +=;
using Base::operator -=;
using Base::operator *=;
using Base::operator /=;
/** Default constructor.
*
* For fixed-size matrices, does nothing.
@@ -444,6 +451,15 @@ class Matrix
resize(other.rows(), other.cols());
other.evalTo(*this);
}
template<typename ProductDerived, typename Lhs, typename Rhs>
EIGEN_STRONG_INLINE Matrix(const ProductBase<ProductDerived,Lhs,Rhs>& other)
{
_check_template_params();
resize(other.rows(), other.cols());
other.evalTo(*this);
}
/** Destructor */
inline ~Matrix() {}
@@ -605,7 +621,7 @@ class Matrix
#ifdef EIGEN_DEBUG_MATRIX_CTOR
EIGEN_DEBUG_MATRIX_CTOR(Matrix);
#endif
EIGEN_STATIC_ASSERT(((_Rows >= _MaxRows)
&& (_Cols >= _MaxCols)
&& (_MaxRows >= 0)