mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Enable direct access for NestByValue.
This commit is contained in:
parent
b59f18b4f7
commit
03c9b4738c
@ -43,6 +43,8 @@ template<typename ExpressionType> class NestByValue
|
||||
public:
|
||||
|
||||
typedef typename internal::dense_xpr_base<NestByValue>::type Base;
|
||||
static constexpr bool HasDirectAccess = internal::has_direct_access<ExpressionType>::ret;
|
||||
|
||||
EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue)
|
||||
|
||||
EIGEN_DEVICE_FUNC explicit inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {}
|
||||
@ -54,6 +56,18 @@ template<typename ExpressionType> class NestByValue
|
||||
|
||||
EIGEN_DEVICE_FUNC const ExpressionType& nestedExpression() const { return m_expression; }
|
||||
|
||||
EIGEN_DEVICE_FUNC typename std::enable_if<HasDirectAccess, const Scalar*>::type data() const {
|
||||
return m_expression.data();
|
||||
}
|
||||
|
||||
EIGEN_DEVICE_FUNC typename std::enable_if<HasDirectAccess, Index>::type innerStride() const {
|
||||
return m_expression.innerStride();
|
||||
}
|
||||
|
||||
EIGEN_DEVICE_FUNC typename std::enable_if<HasDirectAccess, Index>::type outerStride() const {
|
||||
return m_expression.outerStride();
|
||||
}
|
||||
|
||||
protected:
|
||||
const ExpressionType m_expression;
|
||||
};
|
||||
|
@ -33,5 +33,7 @@ EIGEN_DECLARE_TEST(nestbyvalue)
|
||||
MatrixXd b = x;
|
||||
VERIFY_IS_EQUAL(nb_temporaries,6+1);
|
||||
VERIFY_IS_APPROX(b, a.rowwise().reverse().eval() + (a+a).eval());
|
||||
// Block expressions work with dense NestByValue.
|
||||
VERIFY_IS_APPROX(b, a.nestByValue().rowwise().reverse().eval() + (a.nestByValue()+a.nestByValue()).eval());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user