MatrixFunctions: replace eval() by nested.

This eliminates an unnecessary copy in some situations, e.g. Map.
This commit is contained in:
Jitse Niesen
2013-07-31 14:57:20 +01:00
parent 43df1e707c
commit 68168e9eae
4 changed files with 29 additions and 24 deletions

View File

@@ -318,7 +318,10 @@ struct matrix_sqrt_compute<MatrixType, 1>
template<typename Derived> class MatrixSquareRootReturnValue
: public ReturnByValue<MatrixSquareRootReturnValue<Derived> >
{
protected:
typedef typename Derived::Index Index;
typedef typename internal::nested<Derived, 10>::type DerivedNested;
public:
/** \brief Constructor.
*
@@ -335,16 +338,15 @@ template<typename Derived> class MatrixSquareRootReturnValue
template <typename ResultType>
inline void evalTo(ResultType& result) const
{
typedef typename Derived::PlainObject PlainObject;
const PlainObject srcEvaluated = m_src.eval();
internal::matrix_sqrt_compute<PlainObject>::run(srcEvaluated, result);
typedef typename internal::remove_all<DerivedNested>::type DerivedNestedClean;
internal::matrix_sqrt_compute<DerivedNestedClean>::run(m_src, result);
}
Index rows() const { return m_src.rows(); }
Index cols() const { return m_src.cols(); }
protected:
const Derived& m_src;
const DerivedNested m_src;
};
namespace internal {