Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:56:18

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
0005 //
0006 // This Source Code Form is subject to the terms of the Mozilla
0007 // Public License v. 2.0. If a copy of the MPL was not distributed
0008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0009 
0010 #ifndef EIGEN_SWAP_H
0011 #define EIGEN_SWAP_H
0012 
0013 namespace Eigen { 
0014 
0015 namespace internal {
0016 
0017 // Overload default assignPacket behavior for swapping them
0018 template<typename DstEvaluatorTypeT, typename SrcEvaluatorTypeT>
0019 class generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, swap_assign_op<typename DstEvaluatorTypeT::Scalar>, Specialized>
0020  : public generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, swap_assign_op<typename DstEvaluatorTypeT::Scalar>, BuiltIn>
0021 {
0022 protected:
0023   typedef generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, swap_assign_op<typename DstEvaluatorTypeT::Scalar>, BuiltIn> Base;
0024   using Base::m_dst;
0025   using Base::m_src;
0026   using Base::m_functor;
0027   
0028 public:
0029   typedef typename Base::Scalar Scalar;
0030   typedef typename Base::DstXprType DstXprType;
0031   typedef swap_assign_op<Scalar> Functor;
0032   
0033   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0034   generic_dense_assignment_kernel(DstEvaluatorTypeT &dst, const SrcEvaluatorTypeT &src, const Functor &func, DstXprType& dstExpr)
0035     : Base(dst, src, func, dstExpr)
0036   {}
0037   
0038   template<int StoreMode, int LoadMode, typename PacketType>
0039   EIGEN_STRONG_INLINE void assignPacket(Index row, Index col)
0040   {
0041     PacketType tmp = m_src.template packet<LoadMode,PacketType>(row,col);
0042     const_cast<SrcEvaluatorTypeT&>(m_src).template writePacket<LoadMode>(row,col, m_dst.template packet<StoreMode,PacketType>(row,col));
0043     m_dst.template writePacket<StoreMode>(row,col,tmp);
0044   }
0045   
0046   template<int StoreMode, int LoadMode, typename PacketType>
0047   EIGEN_STRONG_INLINE void assignPacket(Index index)
0048   {
0049     PacketType tmp = m_src.template packet<LoadMode,PacketType>(index);
0050     const_cast<SrcEvaluatorTypeT&>(m_src).template writePacket<LoadMode>(index, m_dst.template packet<StoreMode,PacketType>(index));
0051     m_dst.template writePacket<StoreMode>(index,tmp);
0052   }
0053   
0054   // 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)
0055   template<int StoreMode, int LoadMode, typename PacketType>
0056   EIGEN_STRONG_INLINE void assignPacketByOuterInner(Index outer, Index inner)
0057   {
0058     Index row = Base::rowIndexByOuterInner(outer, inner); 
0059     Index col = Base::colIndexByOuterInner(outer, inner);
0060     assignPacket<StoreMode,LoadMode,PacketType>(row, col);
0061   }
0062 };
0063 
0064 } // namespace internal
0065 
0066 } // end namespace Eigen
0067 
0068 #endif // EIGEN_SWAP_H