Finally, the simplest remains to deffer resizing at the latest

This commit is contained in:
Gael Guennebaud 2014-02-18 13:31:44 +01:00
parent 1b5de5a37b
commit 8cfb138e73
2 changed files with 6 additions and 12 deletions

View File

@ -676,12 +676,7 @@ void call_assignment(const Dst& dst, const Src& src)
template<typename Dst, typename Src, typename Func>
void call_assignment(Dst& dst, const Src& src, const Func& func, typename enable_if<evaluator_traits<Src>::AssumeAliasing==1, void*>::type = 0)
{TRACK;
// The following initial implementation through an EvalToTemp object does not permit to
// perform deferred resizing as in 'A = A * B' when the size of 'A' as to be changed
// typedef typename internal::conditional<evaluator_traits<Src>::AssumeAliasing==1, EvalToTemp<Src>, Src>::type ActualSrc;
// Assignment<Dst,ActualSrc,Func>::run(dst, src, func);
// TODO we should simply do tmp(src);
#ifdef EIGEN_TEST_EVALUATORS
typename Src::PlainObject tmp(src);
#else
@ -697,8 +692,6 @@ void call_assignment(Dst& dst, const Src& src, const Func& func, typename enable
template<typename Dst, typename Src, typename Func>
void call_assignment(Dst& dst, const Src& src, const Func& func, typename enable_if<evaluator_traits<Src>::AssumeAliasing==0, void*>::type = 0)
{TRACK;
// There is no explicit no-aliasing, so we must resize here:
dst.resize(src.rows(), src.cols());
call_assignment_no_alias(dst, src, func);
}
@ -728,6 +721,9 @@ void call_assignment_no_alias(Dst& dst, const Src& src, const Func& func)
&& int(Dst::SizeAtCompileTime) != 1
};
dst.resize(NeedToTranspose ? src.cols() : src.rows(),
NeedToTranspose ? src.rows() : src.cols());
typedef typename internal::conditional<NeedToTranspose, Transpose<Dst>, Dst>::type ActualDstTypeCleaned;
typedef typename internal::conditional<NeedToTranspose, Transpose<Dst>, Dst&>::type ActualDstType;
ActualDstType actualDst(dst);

View File

@ -40,9 +40,7 @@ class NoAlias
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other)
{
// TODO either call resize here or call "call_assignment" through m_expression.lazyAssign() ??
m_expression.resize(other.derived().rows(), other.derived().cols());
call_assignment(*this, other.derived(), internal::assign_op<Scalar>());
call_assignment_no_alias(m_expression, other.derived(), internal::assign_op<Scalar>());
return m_expression;
}
@ -50,7 +48,7 @@ class NoAlias
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other)
{
call_assignment(*this, other.derived(), internal::add_assign_op<Scalar>());
call_assignment_no_alias(m_expression, other.derived(), internal::add_assign_op<Scalar>());
return m_expression;
}
@ -58,7 +56,7 @@ class NoAlias
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other)
{
call_assignment(*this, other.derived(), internal::sub_assign_op<Scalar>());
call_assignment_no_alias(m_expression, other.derived(), internal::sub_assign_op<Scalar>());
return m_expression;
}