diff --git a/Eigen/Core b/Eigen/Core index e2c9c69cd..cdc2f2d46 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -305,6 +305,7 @@ using std::ptrdiff_t; #include "src/Core/functors/UnaryFunctors.h" #include "src/Core/functors/NullaryFunctors.h" #include "src/Core/functors/StlFunctors.h" +#include "src/Core/functors/AssignmentFunctors.h" #include "src/Core/DenseCoeffsBase.h" #include "src/Core/DenseBase.h" @@ -312,7 +313,6 @@ using std::ptrdiff_t; #include "src/Core/EigenBase.h" #ifdef EIGEN_ENABLE_EVALUATORS -#include "src/Core/functors/AssignmentFunctors.h" #include "src/Core/Product.h" #include "src/Core/CoreEvaluators.h" #include "src/Core/AssignEvaluator.h" diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index 50a63c85c..9bbfacbcf 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -397,7 +397,7 @@ template class DenseBase void swap(const DenseBase& other, int = OtherDerived::ThisConstantIsPrivateInPlainObjectBase) { - swap_using_evaluator(derived(), other.derived()); + call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op()); } /** swaps *this with the matrix or array \a other. @@ -407,7 +407,7 @@ template class DenseBase EIGEN_DEVICE_FUNC void swap(PlainObjectBase& other) { - swap_using_evaluator(derived(), other.derived()); + call_assignment(derived(), other.derived(), internal::swap_assign_op()); } #else // EIGEN_TEST_EVALUATORS /** swaps *this with the expression \a other. diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h index 96ed9cef9..d1fd21ad7 100644 --- a/Eigen/src/Core/TriangularMatrix.h +++ b/Eigen/src/Core/TriangularMatrix.h @@ -414,11 +414,11 @@ template class TriangularView EIGEN_DEVICE_FUNC void swap(TriangularBase const & other) { -// #ifdef EIGEN_TEST_EVALUATORS -// swap_using_evaluator(this->derived(), other.derived()); -// #else - TriangularView,Mode>(const_cast(m_matrix)).lazyAssign(other.derived()); -// #endif + #ifdef EIGEN_TEST_EVALUATORS + call_assignment(*this, other.const_cast_derived(), internal::swap_assign_op()); + #else + TriangularView,Mode>(const_cast(m_matrix)).lazyAssign(other.const_cast_derived().nestedExpression()); + #endif } // TODO: this overload is ambiguous and it should be deprecated (Gael) @@ -426,12 +426,12 @@ template class TriangularView EIGEN_DEVICE_FUNC void swap(MatrixBase const & other) { -// #ifdef EIGEN_TEST_EVALUATORS -// swap_using_evaluator(this->derived(), other.derived()); -// #else + #ifdef EIGEN_TEST_EVALUATORS + call_assignment(*this, other.const_cast_derived(), internal::swap_assign_op()); + #else SwapWrapper swaper(const_cast(m_matrix)); TriangularView,Mode>(swaper).lazyAssign(other.derived()); -// #endif + #endif } EIGEN_DEVICE_FUNC @@ -988,7 +988,6 @@ void call_triangular_assignment_loop(const DstXprType& dst, const SrcXprType& sr call_triangular_assignment_loop(dst, src, internal::assign_op()); } - template<> struct AssignmentKind { typedef Triangular2Triangular Kind; }; template<> struct AssignmentKind { typedef Triangular2Dense Kind; }; template<> struct AssignmentKind { typedef Dense2Triangular Kind; }; @@ -1028,8 +1027,8 @@ template(), MatrixXd(A.triangularView())); @@ -434,5 +434,11 @@ void test_evaluators() C = B; C.triangularView() = A.triangularView().transpose(); copy_using_evaluator(B.triangularView(), A.triangularView().transpose()); VERIFY(B.isApprox(C) && "copy_using_evaluator(B.triangularView(), A.triangularView().transpose())"); + + + A.setRandom();B.setRandom(); C = B; D = A; + C.triangularView().swap(D.triangularView()); + swap_using_evaluator(B.triangularView(), A.triangularView()); + VERIFY(B.isApprox(C) && "swap_using_evaluator(B.triangularView(), A.triangularView())"); } }