AssignmentFunctors.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_ASSIGNMENT_FUNCTORS_H
11 #define EIGEN_ASSIGNMENT_FUNCTORS_H
12 
13 namespace Eigen {
14 
15 namespace internal {
16 
21 template<typename DstScalar,typename SrcScalar> struct assign_op {
22 
24  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(DstScalar& a, const SrcScalar& b) const { a = b; }
25 
26  template<int Alignment, typename Packet>
27  EIGEN_STRONG_INLINE void assignPacket(DstScalar* a, const Packet& b) const
28  { internal::pstoret<DstScalar,Packet,Alignment>(a,b); }
29 };
30 
31 // Empty overload for void type (used by PermutationMatrix)
32 template<typename DstScalar> struct assign_op<DstScalar,void> {};
33 
34 template<typename DstScalar,typename SrcScalar>
35 struct functor_traits<assign_op<DstScalar,SrcScalar> > {
36  enum {
39  };
40 };
41 
46 template<typename DstScalar,typename SrcScalar> struct add_assign_op {
47 
49  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(DstScalar& a, const SrcScalar& b) const { a += b; }
50 
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)); }
54 };
55 template<typename DstScalar,typename SrcScalar>
56 struct functor_traits<add_assign_op<DstScalar,SrcScalar> > {
57  enum {
60  };
61 };
62 
67 template<typename DstScalar,typename SrcScalar> struct sub_assign_op {
68 
70  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(DstScalar& a, const SrcScalar& b) const { a -= b; }
71 
72  template<int Alignment, typename Packet>
73  EIGEN_STRONG_INLINE void assignPacket(DstScalar* a, const Packet& b) const
74  { internal::pstoret<DstScalar,Packet,Alignment>(a,internal::psub(internal::ploadt<Packet,Alignment>(a),b)); }
75 };
76 template<typename DstScalar,typename SrcScalar>
77 struct functor_traits<sub_assign_op<DstScalar,SrcScalar> > {
78  enum {
81  };
82 };
83 
88 template<typename DstScalar, typename SrcScalar=DstScalar>
89 struct mul_assign_op {
90 
92  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(DstScalar& a, const SrcScalar& b) const { a *= b; }
93 
94  template<int Alignment, typename Packet>
95  EIGEN_STRONG_INLINE void assignPacket(DstScalar* a, const Packet& b) const
96  { internal::pstoret<DstScalar,Packet,Alignment>(a,internal::pmul(internal::ploadt<Packet,Alignment>(a),b)); }
97 };
98 template<typename DstScalar, typename SrcScalar>
99 struct functor_traits<mul_assign_op<DstScalar,SrcScalar> > {
100  enum {
103  };
104 };
105 
110 template<typename DstScalar, typename SrcScalar=DstScalar> struct div_assign_op {
111 
113  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(DstScalar& a, const SrcScalar& b) const { a /= b; }
114 
115  template<int Alignment, typename Packet>
116  EIGEN_STRONG_INLINE void assignPacket(DstScalar* a, const Packet& b) const
117  { internal::pstoret<DstScalar,Packet,Alignment>(a,internal::pdiv(internal::ploadt<Packet,Alignment>(a),b)); }
118 };
119 template<typename DstScalar, typename SrcScalar>
120 struct functor_traits<div_assign_op<DstScalar,SrcScalar> > {
121  enum {
124  };
125 };
126 
142 template<typename Scalar> struct swap_assign_op {
143 
145  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(Scalar& a, const Scalar& b) const
146  {
147 #ifdef __CUDACC__
148  // FIXME is there some kind of cuda::swap?
149  Scalar t=b; const_cast<Scalar&>(b)=a; a=t;
150 #else
151  using std::swap;
152  swap(a,const_cast<Scalar&>(b));
153 #endif
154  }
155 };
156 template<typename Scalar>
158  enum {
161  };
162 };
163 
164 } // namespace internal
165 
166 } // namespace Eigen
167 
168 #endif // EIGEN_ASSIGNMENT_FUNCTORS_H
EIGEN_STRONG_INLINE void assignPacket(DstScalar *a, const Packet &b) const
EIGEN_STRONG_INLINE void assignPacket(DstScalar *a, const Packet &b) const
SCALAR Scalar
Definition: bench_gemm.cpp:33
#define EIGEN_STRONG_INLINE
Definition: Macros.h:494
#define EIGEN_EMPTY_STRUCT_CTOR(X)
Definition: XprHelper.h:22
Scalar * b
Definition: benchVecAdd.cpp:17
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void assignCoeff(DstScalar &a, const SrcScalar &b) const
EIGEN_STRONG_INLINE void assignPacket(DstScalar *a, const Packet &b) const
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:150
Array33i a
EIGEN_DEVICE_FUNC Packet padd(const Packet &a, const Packet &b)
EIGEN_STRONG_INLINE void assignPacket(DstScalar *a, const Packet &b) const
EIGEN_DEVICE_FUNC Packet pdiv(const Packet &a, const Packet &b)
EIGEN_DEVICE_FUNC Packet psub(const Packet &a, const Packet &b)
EIGEN_DEVICE_FUNC Packet pmul(const Packet &a, const Packet &b)
void swap(mpfr::mpreal &x, mpfr::mpreal &y)
Definition: mpreal.h:2986
Point2 t(10, 10)
void swap(scoped_array< T > &a, scoped_array< T > &b)
Definition: Memory.h:602
EIGEN_STRONG_INLINE void assignPacket(DstScalar *a, const Packet &b) const


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:39