mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-02-05 17:50:26 +08:00
Implement interface for NoAlias assignments.
* Rename the old copy_using_evaluators to noalias_copy_using_evaluators. * Write a new copy_using_evaluators which strips NoAlias expression, if present, and calls noalias_copy_using_evaluators; in future, it will also take care of aliasing in products. * Add expression() getter to NoAlias.
This commit is contained in:
parent
069fd0e4be
commit
c1eb820e50
@ -605,9 +605,24 @@ struct copy_using_evaluator_impl<DstXprType, SrcXprType, SliceVectorizedTraversa
|
|||||||
|
|
||||||
// Based on DenseBase::LazyAssign()
|
// Based on DenseBase::LazyAssign()
|
||||||
|
|
||||||
|
template<typename DstXprType, template <typename> class StorageBase, typename SrcXprType>
|
||||||
|
EIGEN_STRONG_INLINE
|
||||||
|
const DstXprType& copy_using_evaluator(const NoAlias<DstXprType, StorageBase>& dst,
|
||||||
|
const EigenBase<SrcXprType>& src)
|
||||||
|
{
|
||||||
|
return noalias_copy_using_evaluator(dst.expression(), src.derived());
|
||||||
|
}
|
||||||
|
|
||||||
template<typename DstXprType, typename SrcXprType>
|
template<typename DstXprType, typename SrcXprType>
|
||||||
EIGEN_STRONG_INLINE
|
EIGEN_STRONG_INLINE
|
||||||
const DstXprType& copy_using_evaluator(const PlainObjectBase<DstXprType>& dst, const EigenBase<SrcXprType>& src)
|
const DstXprType& copy_using_evaluator(const EigenBase<DstXprType>& dst, const EigenBase<SrcXprType>& src)
|
||||||
|
{
|
||||||
|
return noalias_copy_using_evaluator(dst.const_cast_derived(), src.derived());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename DstXprType, typename SrcXprType>
|
||||||
|
EIGEN_STRONG_INLINE
|
||||||
|
const DstXprType& noalias_copy_using_evaluator(const PlainObjectBase<DstXprType>& dst, const EigenBase<SrcXprType>& src)
|
||||||
{
|
{
|
||||||
#ifdef EIGEN_DEBUG_ASSIGN
|
#ifdef EIGEN_DEBUG_ASSIGN
|
||||||
internal::copy_using_evaluator_traits<DstXprType, SrcXprType>::debug();
|
internal::copy_using_evaluator_traits<DstXprType, SrcXprType>::debug();
|
||||||
@ -624,7 +639,7 @@ const DstXprType& copy_using_evaluator(const PlainObjectBase<DstXprType>& dst, c
|
|||||||
|
|
||||||
template<typename DstXprType, typename SrcXprType>
|
template<typename DstXprType, typename SrcXprType>
|
||||||
EIGEN_STRONG_INLINE
|
EIGEN_STRONG_INLINE
|
||||||
const DstXprType& copy_using_evaluator(const EigenBase<DstXprType>& dst, const EigenBase<SrcXprType>& src)
|
const DstXprType& noalias_copy_using_evaluator(const EigenBase<DstXprType>& dst, const EigenBase<SrcXprType>& src)
|
||||||
{
|
{
|
||||||
return copy_using_evaluator_without_resizing(dst.const_cast_derived(), src.derived());
|
return copy_using_evaluator_without_resizing(dst.const_cast_derived(), src.derived());
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,11 @@ class NoAlias
|
|||||||
{ return m_expression.derived() -= CoeffBasedProduct<Lhs,Rhs,NestByRefBit>(other.lhs(), other.rhs()); }
|
{ return m_expression.derived() -= CoeffBasedProduct<Lhs,Rhs,NestByRefBit>(other.lhs(), other.rhs()); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ExpressionType& expression() const
|
||||||
|
{
|
||||||
|
return m_expression;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ExpressionType& m_expression;
|
ExpressionType& m_expression;
|
||||||
};
|
};
|
||||||
|
@ -60,6 +60,7 @@ void test_evaluators()
|
|||||||
VERIFY_IS_APPROX_EVALUATOR(d, (a + b));
|
VERIFY_IS_APPROX_EVALUATOR(d, (a + b));
|
||||||
VERIFY_IS_APPROX_EVALUATOR(d, (a + b).transpose());
|
VERIFY_IS_APPROX_EVALUATOR(d, (a + b).transpose());
|
||||||
VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b), a*b);
|
VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b), a*b);
|
||||||
|
VERIFY_IS_APPROX_EVALUATOR2(d.noalias(), prod(a,b), a*b);
|
||||||
VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b) + c, a*b + c);
|
VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b) + c, a*b + c);
|
||||||
VERIFY_IS_APPROX_EVALUATOR2(d, s * prod(a,b), s * a*b);
|
VERIFY_IS_APPROX_EVALUATOR2(d, s * prod(a,b), s * a*b);
|
||||||
VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b).transpose(), (a*b).transpose());
|
VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b).transpose(), (a*b).transpose());
|
||||||
|
Loading…
Reference in New Issue
Block a user