diff options
-rw-r--r-- | Eigen/Core | 2 | ||||
-rw-r--r-- | Eigen/src/Core/DenseBase.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/TriangularMatrix.h | 23 | ||||
-rw-r--r-- | test/evaluators.cpp | 12 |
4 files changed, 23 insertions, 18 deletions
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<typename Derived> class DenseBase void swap(const DenseBase<OtherDerived>& other, int = OtherDerived::ThisConstantIsPrivateInPlainObjectBase) { - swap_using_evaluator(derived(), other.derived()); + call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>()); } /** swaps *this with the matrix or array \a other. @@ -407,7 +407,7 @@ template<typename Derived> class DenseBase EIGEN_DEVICE_FUNC void swap(PlainObjectBase<OtherDerived>& other) { - swap_using_evaluator(derived(), other.derived()); + call_assignment(derived(), other.derived(), internal::swap_assign_op<Scalar>()); } #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<typename _MatrixType, unsigned int _Mode> class TriangularView EIGEN_DEVICE_FUNC void swap(TriangularBase<OtherDerived> const & other) { -// #ifdef EIGEN_TEST_EVALUATORS -// swap_using_evaluator(this->derived(), other.derived()); -// #else - TriangularView<SwapWrapper<MatrixType>,Mode>(const_cast<MatrixType&>(m_matrix)).lazyAssign(other.derived()); -// #endif + #ifdef EIGEN_TEST_EVALUATORS + call_assignment(*this, other.const_cast_derived(), internal::swap_assign_op<Scalar>()); + #else + TriangularView<SwapWrapper<MatrixType>,Mode>(const_cast<MatrixType&>(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<typename _MatrixType, unsigned int _Mode> class TriangularView EIGEN_DEVICE_FUNC void swap(MatrixBase<OtherDerived> 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<Scalar>()); + #else SwapWrapper<MatrixType> swaper(const_cast<MatrixType&>(m_matrix)); TriangularView<SwapWrapper<MatrixType>,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<Mode,ClearOpposite>(dst, src, internal::assign_op<typename DstXprType::Scalar>()); } - template<> struct AssignmentKind<TriangularShape,TriangularShape> { typedef Triangular2Triangular Kind; }; template<> struct AssignmentKind<DenseShape,TriangularShape> { typedef Triangular2Dense Kind; }; template<> struct AssignmentKind<TriangularShape,DenseShape> { typedef Dense2Triangular Kind; }; @@ -1028,8 +1027,8 @@ template<typename Kernel, unsigned int Mode, int UnrollCount, bool ClearOpposite struct triangular_assignment_loop { enum { - col = (UnrollCount-1) / Kernel::RowsAtCompileTime, - row = (UnrollCount-1) % Kernel::RowsAtCompileTime + col = (UnrollCount-1) / Kernel::DstEvaluatorType::RowsAtCompileTime, + row = (UnrollCount-1) % Kernel::DstEvaluatorType::RowsAtCompileTime }; typedef typename Kernel::Scalar Scalar; diff --git a/test/evaluators.cpp b/test/evaluators.cpp index 63f940318..7a20014dd 100644 --- a/test/evaluators.cpp +++ b/test/evaluators.cpp @@ -106,7 +106,7 @@ void test_evaluators() copy_using_evaluator(w.transpose(), v_const); VERIFY_IS_APPROX(w,v_const.transpose().eval()); -#if 0 + // Testing Array evaluator { ArrayXXf a(2,3); @@ -194,7 +194,7 @@ void test_evaluators() VERIFY_IS_APPROX_EVALUATOR2(resXX, prod(mX4,m4X), mX4*m4X); VERIFY_IS_APPROX_EVALUATOR2(resXX, prod(mXX,mXX), mXX*mXX); } -#endif + { ArrayXXf a(2,3); ArrayXXf b(3,2); @@ -409,7 +409,7 @@ void test_evaluators() { // test triangular shapes - MatrixXd A = MatrixXd::Random(6,6), B(6,6), C(6,6); + MatrixXd A = MatrixXd::Random(6,6), B(6,6), C(6,6), D(6,6); A.setRandom();B.setRandom(); VERIFY_IS_APPROX_EVALUATOR2(B, A.triangularView<Upper>(), MatrixXd(A.triangularView<Upper>())); @@ -434,5 +434,11 @@ void test_evaluators() C = B; C.triangularView<Lower>() = A.triangularView<Upper>().transpose(); copy_using_evaluator(B.triangularView<Lower>(), A.triangularView<Upper>().transpose()); VERIFY(B.isApprox(C) && "copy_using_evaluator(B.triangularView<Lower>(), A.triangularView<Lower>().transpose())"); + + + A.setRandom();B.setRandom(); C = B; D = A; + C.triangularView<Upper>().swap(D.triangularView<Upper>()); + swap_using_evaluator(B.triangularView<Upper>(), A.triangularView<Upper>()); + VERIFY(B.isApprox(C) && "swap_using_evaluator(B.triangularView<Upper>(), A.triangularView<Upper>())"); } } |