// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2006-2008 Benoit Jacob // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef EIGEN_SWAP_H #define EIGEN_SWAP_H namespace Eigen { namespace internal { // Overload default assignPacket behavior for swapping them template class generic_dense_assignment_kernel, Specialized> : public generic_dense_assignment_kernel, BuiltIn> { protected: typedef generic_dense_assignment_kernel, BuiltIn> Base; typedef typename DstEvaluatorTypeT::PacketScalar PacketScalar; using Base::m_dst; using Base::m_src; using Base::m_functor; public: typedef typename Base::Scalar Scalar; typedef typename Base::Index Index; typedef typename Base::DstXprType DstXprType; typedef swap_assign_op Functor; generic_dense_assignment_kernel(DstEvaluatorTypeT &dst, const SrcEvaluatorTypeT &src, const Functor &func, DstXprType& dstExpr) : Base(dst, src, func, dstExpr) {} template void assignPacket(Index row, Index col) { m_functor.template swapPacket(&m_dst.coeffRef(row,col), &const_cast(m_src).coeffRef(row,col)); } template void assignPacket(Index index) { m_functor.template swapPacket(&m_dst.coeffRef(index), &const_cast(m_src).coeffRef(index)); } // TODO find a simple way not to have to copy/paste this function from generic_dense_assignment_kernel, by simple I mean no CRTP (Gael) template void assignPacketByOuterInner(Index outer, Index inner) { Index row = Base::rowIndexByOuterInner(outer, inner); Index col = Base::colIndexByOuterInner(outer, inner); assignPacket(row, col); } }; } // namespace internal } // end namespace Eigen #endif // EIGEN_SWAP_H