diff options
author | 2012-06-28 15:25:25 +0100 | |
---|---|---|
committer | 2012-06-28 15:25:25 +0100 | |
commit | 23184527faeae819480560592c7a2bdf6c272b82 (patch) | |
tree | 091515bdb174f6c01aa92d9182d92d6adb34f324 /Eigen | |
parent | 139c91bf302717dd4a99f93b19c727cd3f14f10d (diff) |
Resize lhs automatically in copy_using_evaluator().
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/Core/AssignEvaluator.h | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/Eigen/src/Core/AssignEvaluator.h b/Eigen/src/Core/AssignEvaluator.h index 7d1bb5cdd..9ae463018 100644 --- a/Eigen/src/Core/AssignEvaluator.h +++ b/Eigen/src/Core/AssignEvaluator.h @@ -3,7 +3,7 @@ // // Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com> // Copyright (C) 2011 Gael Guennebaud <gael.guennebaud@inria.fr> -// Copyright (C) 2011 Jitse Niesen <jitse@maths.leeds.ac.uk> +// Copyright (C) 2011-2012 Jitse Niesen <jitse@maths.leeds.ac.uk> // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -606,11 +606,36 @@ struct copy_using_evaluator_impl<DstXprType, SrcXprType, SliceVectorizedTraversa // Based on DenseBase::LazyAssign() template<typename DstXprType, typename SrcXprType> -const DstXprType& copy_using_evaluator(const DstXprType& dst, const SrcXprType& src) +EIGEN_STRONG_INLINE +const DstXprType& copy_using_evaluator(const PlainObjectBase<DstXprType>& dst, const EigenBase<SrcXprType>& src) { #ifdef EIGEN_DEBUG_ASSIGN internal::copy_using_evaluator_traits<DstXprType, SrcXprType>::debug(); #endif +#ifdef EIGEN_NO_AUTOMATIC_RESIZING + eigen_assert((dst.size()==0 || (IsVectorAtCompileTime ? (dst.size() == src.size()) + : (dst.rows() == src.rows() && dst.cols() == src.cols()))) + && "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined"); +#else + dst.const_cast_derived().resizeLike(src.derived()); +#endif + return copy_using_evaluator_without_resizing(dst.const_cast_derived(), src.derived()); +} + +template<typename DstXprType, typename SrcXprType> +EIGEN_STRONG_INLINE +const DstXprType& copy_using_evaluator(const EigenBase<DstXprType>& dst, const EigenBase<SrcXprType>& src) +{ + return copy_using_evaluator_without_resizing(dst.const_cast_derived(), src.derived()); +} + +template<typename DstXprType, typename SrcXprType> +const DstXprType& copy_using_evaluator_without_resizing(const DstXprType& dst, const SrcXprType& src) +{ +#ifdef EIGEN_DEBUG_ASSIGN + internal::copy_using_evaluator_traits<DstXprType, SrcXprType>::debug(); +#endif + eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); copy_using_evaluator_impl<DstXprType, SrcXprType>::run(const_cast<DstXprType&>(dst), src); return dst; } |