MOAB  4.9.3pre
Eigen::internal::swap_assign_op< Scalar > Struct Template Reference

Template functor for scalar/packet assignment with swapping. More...

#include <AssignmentFunctors.h>

Inheritance diagram for Eigen::internal::swap_assign_op< Scalar >:

List of all members.

Public Member Functions

EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE void 
assignCoeff (Scalar &a, const Scalar &b) const

Detailed Description

template<typename Scalar>
struct Eigen::internal::swap_assign_op< Scalar >

Template functor for scalar/packet assignment with swapping.

It works as follow. For a non-vectorized evaluation loop, we have: for(i) func(A.coeffRef(i), B.coeff(i)); where B is a SwapWrapper expression. The trick is to make SwapWrapper::coeff behaves like a non-const coeffRef. Actually, SwapWrapper might not even be needed since even if B is a plain expression, since it has to be writable B.coeff already returns a const reference to the underlying scalar value.

The case of a vectorized loop is more tricky: for(i,j) func.assignPacket<A_Align>(&A.coeffRef(i,j), B.packet<B_Align>(i,j)); Here, B must be a SwapWrapper whose packet function actually returns a proxy object holding a Scalar*, the actual alignment and Packet type.

Definition at line 140 of file AssignmentFunctors.h.


Member Function Documentation

template<typename Scalar>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void Eigen::internal::swap_assign_op< Scalar >::assignCoeff ( Scalar &  a,
const Scalar &  b 
) const [inline]

Definition at line 143 of file AssignmentFunctors.h.

  {
#ifdef __CUDACC__
    // FIXME is there some kind of cuda::swap?
    Scalar t=b; const_cast<Scalar&>(b)=a; a=t;
#else
    using std::swap;
    swap(a,const_cast<Scalar&>(b));
#endif
  }

The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines