added optimized matrix times diagonal matrix product via Diagonal flag shortcut.

This commit is contained in:
Gael Guennebaud
2008-05-31 21:35:11 +00:00
parent 310f7aa096
commit fcf4457b78
8 changed files with 56 additions and 17 deletions

View File

@@ -76,6 +76,14 @@ MatrixBase<Derived>::cwisePow(const Scalar& exponent) const
(derived(), ei_scalar_pow_op<Scalar>(exponent));
}
/** \returns an expression of the coefficient-wise reciprocal of *this. */
template<typename Derived>
inline const CwiseUnaryOp<ei_scalar_inverse_op<typename ei_traits<Derived>::Scalar>, Derived>
MatrixBase<Derived>::cwiseInverse() const
{
return derived();
}
// -- binary operators --
/** \returns an expression of the coefficient-wise \< operator of *this and \a other

View File

@@ -100,6 +100,19 @@ template<typename Scalar>
struct ei_functor_traits<ei_scalar_pow_op<Scalar> >
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, IsVectorizable = false }; };
/** \internal
* \brief Template functor to compute the reciprocal of a scalar
*
* \sa class CwiseUnaryOp, MatrixBase::cwiseInverse
*/
template<typename Scalar>
struct ei_scalar_inverse_op {
inline Scalar operator() (const Scalar& a) const { return Scalar(1)/a; }
};
template<typename Scalar>
struct ei_functor_traits<ei_scalar_inverse_op<Scalar> >
{ enum { Cost = NumTraits<Scalar>::MulCost, IsVectorizable = false }; };
// default ei_functor_traits for STL functors:
template<typename T>