Eigen::internal::swap_assign_op< Scalar > Struct Template Reference

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

#include <AssignmentFunctors.h>

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.

Member Function Documentation

◆ assignCoeff()

template<typename Scalar >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void Eigen::internal::swap_assign_op< Scalar >::assignCoeff ( Scalar a,
const Scalar b 
) const
inline
148  {
149 #ifdef EIGEN_GPUCC
150  // FIXME is there some kind of cuda::swap?
151  Scalar t = b;
152  const_cast<Scalar&>(b) = a;
153  a = t;
154 #else
155  using std::swap;
156  swap(a, const_cast<Scalar&>(b));
157 #endif
158  }
Scalar * b
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
EIGEN_BLAS_FUNC() swap(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
Definition: level1_impl.h:117
const Scalar * a
Definition: level2_cplx_impl.h:32
void swap(scoped_array< T > &a, scoped_array< T > &b)
Definition: Memory.h:734
t
Definition: plotPSD.py:36

References a, b, swap(), Eigen::internal::swap(), and plotPSD::t.


The documentation for this struct was generated from the following file: