10 #ifndef EIGEN_ASSIGNMENT_FUNCTORS_H
11 #define EIGEN_ASSIGNMENT_FUNCTORS_H
13 #include "../InternalHeaderCheck.h"
23 template<
typename DstScalar,
typename SrcScalar>
struct assign_op {
25 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void assignCoeff(DstScalar&
a,
const SrcScalar&
b)
const {
a =
b; }
27 template<
int Alignment,
typename Packet>
28 EIGEN_STRONG_INLINE
void assignPacket(DstScalar*
a,
const Packet&
b)
const
29 { internal::pstoret<DstScalar,Packet,Alignment>(
a,
b); }
33 template<
typename DstScalar>
struct assign_op<DstScalar,void> {};
35 template<
typename DstScalar,
typename SrcScalar>
36 struct functor_traits<assign_op<DstScalar,SrcScalar> > {
39 PacketAccess = is_same<DstScalar,SrcScalar>::value && packet_traits<DstScalar>::Vectorizable && packet_traits<SrcScalar>::Vectorizable
47 template<
typename DstScalar,
typename SrcScalar>
struct add_assign_op {
49 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void assignCoeff(DstScalar&
a,
const SrcScalar&
b)
const {
a +=
b; }
51 template<
int Alignment,
typename Packet>
52 EIGEN_STRONG_INLINE
void assignPacket(DstScalar*
a,
const Packet&
b)
const
53 { internal::pstoret<DstScalar,Packet,Alignment>(
a,
internal::padd(internal::ploadt<Packet,Alignment>(
a),
b)); }
55 template<
typename DstScalar,
typename SrcScalar>
56 struct functor_traits<add_assign_op<DstScalar,SrcScalar> > {
59 PacketAccess = is_same<DstScalar,SrcScalar>::value && packet_traits<DstScalar>::HasAdd
67 template<
typename DstScalar,
typename SrcScalar>
struct sub_assign_op {
69 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void assignCoeff(DstScalar&
a,
const SrcScalar&
b)
const {
a -=
b; }
71 template<
int Alignment,
typename Packet>
72 EIGEN_STRONG_INLINE
void assignPacket(DstScalar*
a,
const Packet&
b)
const
73 { internal::pstoret<DstScalar,Packet,Alignment>(
a,
internal::psub(internal::ploadt<Packet,Alignment>(
a),
b)); }
75 template<
typename DstScalar,
typename SrcScalar>
76 struct functor_traits<sub_assign_op<DstScalar,SrcScalar> > {
79 PacketAccess = is_same<DstScalar,SrcScalar>::value && packet_traits<DstScalar>::HasSub
87 template<
typename DstScalar,
typename SrcScalar=DstScalar>
88 struct mul_assign_op {
90 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void assignCoeff(DstScalar&
a,
const SrcScalar&
b)
const {
a *=
b; }
92 template<
int Alignment,
typename Packet>
93 EIGEN_STRONG_INLINE
void assignPacket(DstScalar*
a,
const Packet&
b)
const
94 { internal::pstoret<DstScalar,Packet,Alignment>(
a,
internal::pmul(internal::ploadt<Packet,Alignment>(
a),
b)); }
96 template<
typename DstScalar,
typename SrcScalar>
97 struct functor_traits<mul_assign_op<DstScalar,SrcScalar> > {
100 PacketAccess = is_same<DstScalar,SrcScalar>::value && packet_traits<DstScalar>::HasMul
108 template<
typename DstScalar,
typename SrcScalar=DstScalar>
struct div_assign_op {
110 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void assignCoeff(DstScalar&
a,
const SrcScalar&
b)
const {
a /=
b; }
112 template<
int Alignment,
typename Packet>
113 EIGEN_STRONG_INLINE
void assignPacket(DstScalar*
a,
const Packet&
b)
const
114 { internal::pstoret<DstScalar,Packet,Alignment>(
a,
internal::pdiv(internal::ploadt<Packet,Alignment>(
a),
b)); }
116 template<
typename DstScalar,
typename SrcScalar>
117 struct functor_traits<div_assign_op<DstScalar,SrcScalar> > {
120 PacketAccess = is_same<DstScalar,SrcScalar>::value && packet_traits<DstScalar>::HasDiv
139 template<
typename Scalar>
struct swap_assign_op {
145 Scalar t=
b;
const_cast<Scalar&
>(
b)=
a;
a=t;
148 swap(
a,
const_cast<Scalar&
>(
b));
152 template<
typename Scalar>
153 struct functor_traits<swap_assign_op<Scalar> > {
157 #if defined(EIGEN_VECTORIZE_AVX) && (EIGEN_CLANG_STRICT_LESS_THAN(8,0,0) || EIGEN_COMP_CLANGAPPLE)
164 packet_traits<Scalar>::Vectorizable
#define EIGEN_DEVICE_FUNC
Packet padd(const Packet &a, const Packet &b)
Packet pmul(const Packet &a, const Packet &b)
Packet psub(const Packet &a, const Packet &b)
Packet pdiv(const Packet &a, const Packet &b)
void swap(scoped_array< T > &a, scoped_array< T > &b)