mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
MatrixFunctions: replace eval() by nested.
This eliminates an unnecessary copy in some situations, e.g. Map.
This commit is contained in:
@@ -481,11 +481,15 @@ template<typename Derived> class MatrixFunctionReturnValue
|
||||
: public ReturnByValue<MatrixFunctionReturnValue<Derived> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename Derived::Scalar Scalar;
|
||||
typedef typename Derived::Index Index;
|
||||
typedef typename internal::stem_function<Scalar>::type StemFunction;
|
||||
|
||||
protected:
|
||||
typedef typename internal::nested<Derived, 10>::type DerivedNested;
|
||||
|
||||
public:
|
||||
|
||||
/** \brief Constructor.
|
||||
*
|
||||
* \param[in] A %Matrix (expression) forming the argument of the matrix function.
|
||||
@@ -500,26 +504,25 @@ template<typename Derived> class MatrixFunctionReturnValue
|
||||
template <typename ResultType>
|
||||
inline void evalTo(ResultType& result) const
|
||||
{
|
||||
typedef typename Derived::PlainObject PlainObject;
|
||||
typedef internal::traits<PlainObject> Traits;
|
||||
typedef typename internal::remove_all<DerivedNested>::type DerivedNestedClean;
|
||||
typedef internal::traits<DerivedNestedClean> Traits;
|
||||
static const int RowsAtCompileTime = Traits::RowsAtCompileTime;
|
||||
static const int ColsAtCompileTime = Traits::ColsAtCompileTime;
|
||||
static const int Options = PlainObject::Options;
|
||||
static const int Options = DerivedNestedClean::Options;
|
||||
typedef std::complex<typename NumTraits<Scalar>::Real> ComplexScalar;
|
||||
typedef Matrix<ComplexScalar, Dynamic, Dynamic, Options, RowsAtCompileTime, ColsAtCompileTime> DynMatrixType;
|
||||
|
||||
typedef internal::MatrixFunctionAtomic<DynMatrixType> AtomicType;
|
||||
AtomicType atomic(m_f);
|
||||
|
||||
const PlainObject Aevaluated = m_A.eval();
|
||||
internal::matrix_function_compute<PlainObject>::run(Aevaluated, atomic, result);
|
||||
internal::matrix_function_compute<DerivedNestedClean>::run(m_A, atomic, result);
|
||||
}
|
||||
|
||||
Index rows() const { return m_A.rows(); }
|
||||
Index cols() const { return m_A.cols(); }
|
||||
|
||||
private:
|
||||
typename internal::nested<Derived>::type m_A;
|
||||
const DerivedNested m_A;
|
||||
StemFunction *m_f;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user